source: trunk/src/user32/new/oslibres.cpp@ 647

Last change on this file since 647 was 647, checked in by sandervl, 26 years ago

Icon load bugfix + dummy functions for comdlg32

File size: 6.9 KB
Line 
1/* $Id: oslibres.cpp,v 1.6 1999-08-23 13:56:35 sandervl Exp $ */
2/*
3 * Window API wrappers for OS/2
4 *
5 *
6 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12#define INCL_WIN
13#define INCL_PM
14#include <os2.h>
15#include <os2wrap.h>
16#include <stdlib.h>
17#include <string.h>
18
19#include <misc.h>
20#include <winconst.h>
21#include "oslibwin.h"
22#include "oslibutil.h"
23#include "oslibmsg.h"
24#include "oslibgdi.h"
25#include "pmwindow.h"
26
27
28//******************************************************************************
29//******************************************************************************
30HWND OSLibWinCreateMenu(HWND hwndParent, PVOID menutemplate)
31{
32 return WinCreateMenu(hwndParent, menutemplate);
33}
34//******************************************************************************
35//******************************************************************************
36HANDLE OSLibWinSetAccelTable(HWND hwnd, HANDLE hAccel, PVOID acceltemplate)
37{
38 HAB hab = WinQueryAnchorBlock(hwnd);
39
40 if(hAccel == 0) {
41 hAccel = WinCreateAccelTable(hab, (PACCELTABLE)acceltemplate);
42 if(hAccel == 0) {
43 dprintf(("OSLibWinSetAccelTable: WinCreateAccelTable returned 0"));
44 return FALSE;
45 }
46 }
47 if(WinSetAccelTable(hab, hAccel, hwnd) == TRUE) {
48 return hAccel;
49 }
50 else return 0;
51}
52//******************************************************************************
53//TODO: handle single icons
54//******************************************************************************
55HANDLE OSLibWinCreateIcon(PVOID iconbitmap)
56{
57 POINTERINFO pointerInfo = {0};
58 HBITMAP hbmColor, hbmMask;
59 BITMAPARRAYFILEHEADER2 *bafh = (BITMAPARRAYFILEHEADER2 *)iconbitmap;
60 BITMAPFILEHEADER2 *bfhBW;
61 BITMAPFILEHEADER2 *bfhColor;
62 HPS hps;
63 HANDLE hIcon;
64
65 if(iconbitmap == NULL) {
66 dprintf(("OSLibWinCreateIcon iconbitmap == NULL!!"));
67 return 0;
68 }
69 if(bafh->usType == BFT_BITMAPARRAY && bafh->cbSize == sizeof(BITMAPARRAYFILEHEADER2)) {
70 bfhBW = &bafh->bfh2;
71 bfhColor = (BITMAPFILEHEADER2 *)((char *)&bafh->bfh2 + sizeof(RGB2)*2 + sizeof(BITMAPFILEHEADER2));
72 }
73 else {//single icon
74 bfhBW = (BITMAPFILEHEADER2 *)iconbitmap;
75 bfhColor = (BITMAPFILEHEADER2 *)((char *)bfhBW + sizeof(RGB2)*2 + sizeof(BITMAPFILEHEADER2));
76 bafh = (BITMAPARRAYFILEHEADER2 *)bfhBW; //for calculation bitmap offset
77 }
78 hps = WinGetPS(HWND_DESKTOP);
79 hbmColor = GpiCreateBitmap(hps, &bfhColor->bmp2, CBM_INIT,
80 (char *)bafh + bfhColor->offBits,
81 (BITMAPINFO2 *)&bfhColor->bmp2);
82 if(hbmColor == GPI_ERROR) {
83 dprintf(("OSLibWinCreateIcon: GpiCreateBitmap failed!"));
84 WinReleasePS(hps);
85 return 0;
86 }
87 hbmMask = GpiCreateBitmap(hps, &bfhBW->bmp2, CBM_INIT,
88 (char *)bafh + bfhBW->offBits,
89 (BITMAPINFO2 *)&bfhBW->bmp2);
90 if(hbmMask == GPI_ERROR) {
91 dprintf(("OSLibWinCreateIcon: GpiCreateBitmap hbmMask failed!"));
92 GpiDeleteBitmap(hbmColor);
93 WinReleasePS(hps);
94 return 0;
95 }
96
97 pointerInfo.fPointer = FALSE; //icon
98 pointerInfo.xHotspot = bfhBW->xHotspot;
99 pointerInfo.yHotspot = bfhBW->yHotspot;
100 pointerInfo.hbmColor = hbmColor;
101 pointerInfo.hbmPointer = hbmMask;
102 hIcon = WinCreatePointerIndirect(HWND_DESKTOP, &pointerInfo);
103 if(hIcon == NULL) {
104 dprintf(("OSLibWinCreateIcon: WinCreatePointerIndirect failed!"));
105 }
106 GpiDeleteBitmap(hbmMask);
107 GpiDeleteBitmap(hbmColor);
108 WinReleasePS(hps);
109 return hIcon;
110}
111//******************************************************************************
112//******************************************************************************
113HANDLE OSLibWinCreatePointer(PVOID cursorbitmap)
114{
115 POINTERINFO pointerInfo = {0};
116 HBITMAP hbmColor;
117 BITMAPFILEHEADER2 *bfh = (BITMAPFILEHEADER2 *)cursorbitmap;
118 HPS hps;
119 HANDLE hPointer;
120
121 if(cursorbitmap == NULL) {
122 dprintf(("OSLibWinCreatePointer cursorbitmap == NULL!!"));
123 return 0;
124 }
125 //skip xor/and mask
126 hps = WinGetPS(HWND_DESKTOP);
127 hbmColor = GpiCreateBitmap(hps, &bfh->bmp2, CBM_INIT,
128 (char *)bfh + bfh->offBits,
129 (BITMAPINFO2 *)&bfh->bmp2);
130 if(hbmColor == GPI_ERROR) {
131 dprintf(("OSLibWinCreatePointer: GpiCreateBitmap failed!"));
132 WinReleasePS(hps);
133 return 0;
134 }
135
136 pointerInfo.fPointer = TRUE;
137 pointerInfo.xHotspot = bfh->xHotspot;
138 pointerInfo.yHotspot = bfh->yHotspot;
139 pointerInfo.hbmColor = 0;
140 pointerInfo.hbmPointer = hbmColor;
141 hPointer = WinCreatePointerIndirect(HWND_DESKTOP, &pointerInfo);
142 if(hPointer == NULL) {
143 dprintf(("OSLibWinCreatePointer: WinCreatePointerIndirect failed!"));
144 }
145 GpiDeleteBitmap(hbmColor);
146 WinReleasePS(hps);
147 return hPointer;
148}
149//******************************************************************************
150//******************************************************************************
151HANDLE OSLibWinQuerySysIcon(ULONG type)
152{
153 ULONG os2type = 0;
154
155 switch(type) {
156 case IDI_APPLICATION_W:
157 os2type = SPTR_PROGRAM;
158 break;
159 case IDI_HAND_W:
160 os2type = SPTR_ICONWARNING;
161 break;
162 case IDI_QUESTION_W:
163 os2type = SPTR_ICONQUESTION;
164 break;
165 case IDI_EXCLAMATION_W:
166 os2type = SPTR_ICONWARNING;
167 break;
168 case IDI_ASTERISK_W:
169 os2type = SPTR_ICONINFORMATION;
170 break;
171 default:
172 return 0;
173 }
174
175 return WinQuerySysPointer(HWND_DESKTOP, os2type, TRUE);
176}
177//******************************************************************************
178//******************************************************************************
179HANDLE OSLibWinQuerySysPointer(ULONG type)
180{
181 ULONG os2type = 0;
182
183 switch(type) {
184 case IDC_ARROW_W:
185 os2type = SPTR_ARROW;
186 break;
187 case IDC_UPARROW_W:
188 os2type = SPTR_ARROW;
189 break;
190 case IDC_IBEAM_W:
191 os2type = SPTR_TEXT;
192 break;
193 case IDC_ICON_W:
194 os2type = SPTR_PROGRAM;
195 break;
196 case IDC_NO_W:
197 os2type = SPTR_ILLEGAL;
198 break;
199 case IDC_CROSS_W:
200 os2type = SPTR_MOVE;
201 break;
202 case IDC_SIZE_W:
203 os2type = SPTR_MOVE;
204 break;
205 case IDC_SIZEALL_W:
206 os2type = SPTR_MOVE;
207 break;
208 case IDC_SIZENESW_W:
209 os2type = SPTR_SIZENESW;
210 break;
211 case IDC_SIZENS_W:
212 os2type = SPTR_SIZENS;
213 break;
214 case IDC_SIZENWSE_W:
215 os2type = SPTR_SIZENWSE;
216 break;
217 case IDC_SIZEWE_W:
218 os2type = SPTR_SIZEWE;
219 break;
220 case IDC_WAIT_W:
221 os2type = SPTR_WAIT;
222 break;
223 case IDC_APPSTARTING_W:
224 os2type = SPTR_WAIT;
225 break;
226 case IDC_HELP_W: //TODO: Create a cursor for this one
227 os2type = SPTR_WAIT;
228 break;
229 default:
230 return 0;
231 }
232 return WinQuerySysPointer(HWND_DESKTOP, os2type, TRUE);
233}
234//******************************************************************************
235//******************************************************************************
Note: See TracBrowser for help on using the repository browser.