comparison os2/dw.c @ 643:9ab89d89e6b4

Add dw_listview_insert() Default to using webkit for Gtk+ HTML widget Add option to build with libgtkhtml2 - incomplete Initial attempt to use customdraw for Win32 container - not working Added dw_window_get_font() for Gtk+ - not implemented in other ports yet Change package name from dw to dwindows for Linux ports - use dwindows-config now Add debian package build target
author mhessling@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 03 Oct 2010 00:34:36 +0000
parents 9fa3cb5b3290
children c60a4f6cfae8
comparison
equal deleted inserted replaced
642:fda03b13ebda 643:9ab89d89e6b4
58 ULONG aulBuffer[4], GlobalID = 10000; 58 ULONG aulBuffer[4], GlobalID = 10000;
59 HWND lasthcnr = 0, lastitem = 0, popup = 0, desktop; 59 HWND lasthcnr = 0, lastitem = 0, popup = 0, desktop;
60 HMOD wpconfig = 0; 60 HMOD wpconfig = 0;
61 61
62 unsigned long _colors[] = { 62 unsigned long _colors[] = {
63 CLR_BLACK, 63 CLR_BLACK,
64 CLR_DARKRED, 64 CLR_DARKRED,
65 CLR_DARKGREEN, 65 CLR_DARKGREEN,
66 CLR_BROWN, 66 CLR_BROWN,
67 CLR_DARKBLUE, 67 CLR_DARKBLUE,
68 CLR_DARKPINK, 68 CLR_DARKPINK,
69 CLR_DARKCYAN, 69 CLR_DARKCYAN,
70 CLR_PALEGRAY, 70 CLR_PALEGRAY,
71 CLR_DARKGRAY, 71 CLR_DARKGRAY,
72 CLR_RED, 72 CLR_RED,
73 CLR_GREEN, 73 CLR_GREEN,
74 CLR_YELLOW, 74 CLR_YELLOW,
75 CLR_BLUE, 75 CLR_BLUE,
76 CLR_PINK, 76 CLR_PINK,
77 CLR_CYAN, 77 CLR_CYAN,
78 CLR_WHITE 78 CLR_WHITE
79 }; 79 };
80 80
81 #define IS_WARP4() (aulBuffer[0] == 20 && aulBuffer[1] >= 40) 81 #define IS_WARP4() (aulBuffer[0] == 20 && aulBuffer[1] >= 40)
82 82
83 #ifndef min 83 #ifndef min
84 #define min(a, b) (((a < b) ? a : b)) 84 #define min(a, b) (((a < b) ? a : b))
85 #endif 85 #endif
86 86
87 typedef struct _sighandler 87 typedef struct _sighandler
88 { 88 {
89 struct _sighandler *next; 89 struct _sighandler *next;
90 ULONG message; 90 ULONG message;
91 HWND window; 91 HWND window;
92 int id; 92 int id;
93 void *signalfunction; 93 void *signalfunction;
94 void *data; 94 void *data;
95 95
96 } SignalHandler; 96 } SignalHandler;
97 97
98 SignalHandler *Root = NULL; 98 SignalHandler *Root = NULL;
99 99
100 typedef struct 100 typedef struct
101 { 101 {
102 ULONG message; 102 ULONG message;
103 char name[30]; 103 char name[30];
104 104
105 } SignalList; 105 } SignalList;
106 106
107 /* List of signals and their equivilent OS/2 message */ 107 /* List of signals and their equivilent OS/2 message */
108 #define SIGNALMAX 16 108 #define SIGNALMAX 16
109 109
110 SignalList SignalTranslate[SIGNALMAX] = { 110 SignalList SignalTranslate[SIGNALMAX] = {
111 { WM_SIZE, DW_SIGNAL_CONFIGURE }, 111 { WM_SIZE, DW_SIGNAL_CONFIGURE },
112 { WM_CHAR, DW_SIGNAL_KEY_PRESS }, 112 { WM_CHAR, DW_SIGNAL_KEY_PRESS },
113 { WM_BUTTON1DOWN, DW_SIGNAL_BUTTON_PRESS }, 113 { WM_BUTTON1DOWN, DW_SIGNAL_BUTTON_PRESS },
114 { WM_BUTTON1UP, DW_SIGNAL_BUTTON_RELEASE }, 114 { WM_BUTTON1UP, DW_SIGNAL_BUTTON_RELEASE },
115 { WM_MOUSEMOVE, DW_SIGNAL_MOTION_NOTIFY }, 115 { WM_MOUSEMOVE, DW_SIGNAL_MOTION_NOTIFY },
116 { WM_CLOSE, DW_SIGNAL_DELETE }, 116 { WM_CLOSE, DW_SIGNAL_DELETE },
117 { WM_PAINT, DW_SIGNAL_EXPOSE }, 117 { WM_PAINT, DW_SIGNAL_EXPOSE },
118 { WM_COMMAND, DW_SIGNAL_CLICKED }, 118 { WM_COMMAND, DW_SIGNAL_CLICKED },
119 { CN_ENTER, DW_SIGNAL_ITEM_ENTER }, 119 { CN_ENTER, DW_SIGNAL_ITEM_ENTER },
120 { CN_CONTEXTMENU, DW_SIGNAL_ITEM_CONTEXT }, 120 { CN_CONTEXTMENU, DW_SIGNAL_ITEM_CONTEXT },
121 { LN_SELECT, DW_SIGNAL_LIST_SELECT }, 121 { LN_SELECT, DW_SIGNAL_LIST_SELECT },
122 { CN_EMPHASIS, DW_SIGNAL_ITEM_SELECT }, 122 { CN_EMPHASIS, DW_SIGNAL_ITEM_SELECT },
123 { WM_SETFOCUS, DW_SIGNAL_SET_FOCUS }, 123 { WM_SETFOCUS, DW_SIGNAL_SET_FOCUS },
124 { SLN_SLIDERTRACK, DW_SIGNAL_VALUE_CHANGED }, 124 { SLN_SLIDERTRACK, DW_SIGNAL_VALUE_CHANGED },
125 { BKN_PAGESELECTED,DW_SIGNAL_SWITCH_PAGE }, 125 { BKN_PAGESELECTED,DW_SIGNAL_SWITCH_PAGE },
126 { CN_EXPANDTREE, DW_SIGNAL_TREE_EXPAND } 126 { CN_EXPANDTREE, DW_SIGNAL_TREE_EXPAND }
127 }; 127 };
128 128
129 /* This function adds a signal handler callback into the linked list. 129 /* This function adds a signal handler callback into the linked list.
130 */ 130 */
131 void _new_signal(ULONG message, HWND window, int id, void *signalfunction, void *data) 131 void _new_signal(ULONG message, HWND window, int id, void *signalfunction, void *data)
132 { 132 {
133 SignalHandler *new = malloc(sizeof(SignalHandler)); 133 SignalHandler *new = malloc(sizeof(SignalHandler));
134 134
135 new->message = message; 135 new->message = message;
136 new->window = window; 136 new->window = window;
137 new->id = id; 137 new->id = id;
138 new->signalfunction = signalfunction; 138 new->signalfunction = signalfunction;
139 new->data = data; 139 new->data = data;
140 new->next = NULL; 140 new->next = NULL;
141 141
142 if (!Root) 142 if (!Root)
143 Root = new; 143 Root = new;
144 else 144 else
145 { 145 {
146 SignalHandler *prev = NULL, *tmp = Root; 146 SignalHandler *prev = NULL, *tmp = Root;
147 while(tmp) 147 while(tmp)
148 { 148 {
149 if(tmp->message == message && 149 if(tmp->message == message &&
150 tmp->window == window && 150 tmp->window == window &&
151 tmp->id == id && 151 tmp->id == id &&
152 tmp->signalfunction == signalfunction) 152 tmp->signalfunction == signalfunction)
153 { 153 {
154 tmp->data = data; 154 tmp->data = data;
155 free(new); 155 free(new);
156 return; 156 return;
157 } 157 }
158 prev = tmp; 158 prev = tmp;
159 tmp = tmp->next; 159 tmp = tmp->next;
160 } 160 }
161 if(prev) 161 if(prev)
162 prev->next = new; 162 prev->next = new;
163 else 163 else
164 Root = new; 164 Root = new;
165 } 165 }
166 } 166 }
167 167
168 /* Finds the message number for a given signal name */ 168 /* Finds the message number for a given signal name */
169 ULONG _findsigmessage(char *signame) 169 ULONG _findsigmessage(char *signame)
170 { 170 {
171 int z; 171 int z;
172 172
173 for(z=0;z<SIGNALMAX;z++) 173 for(z=0;z<SIGNALMAX;z++)
174 { 174 {
175 if(stricmp(signame, SignalTranslate[z].name) == 0) 175 if(stricmp(signame, SignalTranslate[z].name) == 0)
176 return SignalTranslate[z].message; 176 return SignalTranslate[z].message;
177 } 177 }
178 return 0L; 178 return 0L;
179 } 179 }
180 180
181 typedef struct _CNRITEM 181 typedef struct _CNRITEM
182 { 182 {
183 MINIRECORDCORE rc; 183 MINIRECORDCORE rc;
184 HPOINTER hptrIcon; 184 HPOINTER hptrIcon;
185 PVOID user; 185 PVOID user;
186 HTREEITEM parent; 186 HTREEITEM parent;
187 187
188 } CNRITEM, *PCNRITEM; 188 } CNRITEM, *PCNRITEM;
189 189
190 190
191 int _null_key(HWND window, int key, void *data) 191 int _null_key(HWND window, int key, void *data)
192 { 192 {
193 window = window; /* keep compiler happy */ 193 window = window; /* keep compiler happy */
194 key = key; /* keep compiler happy */ 194 key = key; /* keep compiler happy */
195 data = data; /* keep compiler happy */ 195 data = data; /* keep compiler happy */
196 return TRUE; 196 return TRUE;
197 } 197 }
198 198
199 /* Find the desktop window handle */ 199 /* Find the desktop window handle */
200 HWND _toplevel_window(HWND handle) 200 HWND _toplevel_window(HWND handle)
201 { 201 {
202 HWND box, lastbox = WinQueryWindow(handle, QW_PARENT); 202 HWND box, lastbox = WinQueryWindow(handle, QW_PARENT);
203 203
204 /* Find the toplevel window */ 204 /* Find the toplevel window */
205 while((box = WinQueryWindow(lastbox, QW_PARENT)) != desktop && box > 0) 205 while((box = WinQueryWindow(lastbox, QW_PARENT)) != desktop && box > 0)
206 { 206 {
207 lastbox = box; 207 lastbox = box;
208 } 208 }
209 if(box > 0) 209 if(box > 0)
210 return lastbox; 210 return lastbox;
211 return handle; 211 return handle;
212 } 212 }
213 213
214 214
215 /* Returns height of specified window. */ 215 /* Returns height of specified window. */
216 int _get_height(HWND handle) 216 int _get_height(HWND handle)
217 { 217 {
218 unsigned long height; 218 unsigned long height;
219 dw_window_get_pos_size(handle, NULL, NULL, NULL, &height); 219 dw_window_get_pos_size(handle, NULL, NULL, NULL, &height);
220 return (int)height; 220 return (int)height;
221 } 221 }
222 222
223 /* Find the height of the frame a desktop style window is sitting on */ 223 /* Find the height of the frame a desktop style window is sitting on */
224 int _get_frame_height(HWND handle) 224 int _get_frame_height(HWND handle)
225 { 225 {
226 while(handle) 226 while(handle)
227 { 227 {
228 HWND client; 228 HWND client;
229 if((client = WinWindowFromID(handle, FID_CLIENT)) != NULLHANDLE) 229 if((client = WinWindowFromID(handle, FID_CLIENT)) != NULLHANDLE)
230 { 230 {
231 return _get_height(WinQueryWindow(handle, QW_PARENT)); 231 return _get_height(WinQueryWindow(handle, QW_PARENT));
232 } 232 }
233 handle = WinQueryWindow(handle, QW_PARENT); 233 handle = WinQueryWindow(handle, QW_PARENT);
234 } 234 }
235 return dw_screen_height(); 235 return dw_screen_height();
236 } 236 }
237 237
238 /* A "safe" WinSendMsg() that tries multiple times in case the 238 /* A "safe" WinSendMsg() that tries multiple times in case the
239 * queue is blocked for one reason or another. 239 * queue is blocked for one reason or another.
240 */ 240 */
241 MRESULT _dw_send_msg(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, int failure) 241 MRESULT _dw_send_msg(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, int failure)
242 { 242 {
243 MRESULT res; 243 MRESULT res;
244 int z = 0; 244 int z = 0;
245 245
246 while((int)(res = WinSendMsg(hwnd, msg, mp1, mp2)) == failure) 246 while((int)(res = WinSendMsg(hwnd, msg, mp1, mp2)) == failure)
247 { 247 {
248 z++; 248 z++;
249 if(z > 5000000) 249 if(z > 5000000)
250 return (MRESULT)failure; 250 return (MRESULT)failure;
251 dw_main_sleep(1); 251 dw_main_sleep(1);
252 } 252 }
253 return res; 253 return res;
254 } 254 }
255 255
256 /* Used in the slider and percent classes internally */ 256 /* Used in the slider and percent classes internally */
257 unsigned int _dw_percent_get_range(HWND handle) 257 unsigned int _dw_percent_get_range(HWND handle)
258 { 258 {
259 return SHORT2FROMMP(WinSendMsg(handle, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), 0)); 259 return SHORT2FROMMP(WinSendMsg(handle, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), 0));
260 } 260 }
261 261
262 /* Return the entryfield child of a window */ 262 /* Return the entryfield child of a window */
263 HWND _find_entryfield(HWND handle) 263 HWND _find_entryfield(HWND handle)
264 { 264 {
265 HENUM henum; 265 HENUM henum;
266 HWND child, entry = 0; 266 HWND child, entry = 0;
267 267
268 henum = WinBeginEnumWindows(handle); 268 henum = WinBeginEnumWindows(handle);
269 while((child = WinGetNextWindow(henum)) != NULLHANDLE) 269 while((child = WinGetNextWindow(henum)) != NULLHANDLE)
270 { 270 {
271 char tmpbuf[100]; 271 char tmpbuf[100];
272 272
273 WinQueryClassName(child, 99, tmpbuf); 273 WinQueryClassName(child, 99, tmpbuf);
274 274
275 if(strncmp(tmpbuf, "#6", 3)==0) /* Entryfield */ 275 if(strncmp(tmpbuf, "#6", 3)==0) /* Entryfield */
276 { 276 {
277 entry = child; 277 entry = child;
278 break; 278 break;
279 } 279 }
280 } 280 }
281 WinEndEnumWindows(henum); 281 WinEndEnumWindows(henum);
282 return entry; 282 return entry;
283 } 283 }
284 284
285 /* This function changes the owner of buttons in to the 285 /* This function changes the owner of buttons in to the
286 * dynamicwindows handle to fix a problem in notebooks. 286 * dynamicwindows handle to fix a problem in notebooks.
287 */ 287 */
288 void _fix_button_owner(HWND handle, HWND dw) 288 void _fix_button_owner(HWND handle, HWND dw)
289 { 289 {
290 HENUM henum; 290 HENUM henum;
291 HWND child; 291 HWND child;
292 292
293 henum = WinBeginEnumWindows(handle); 293 henum = WinBeginEnumWindows(handle);
294 while((child = WinGetNextWindow(henum)) != NULLHANDLE) 294 while((child = WinGetNextWindow(henum)) != NULLHANDLE)
295 { 295 {
296 char tmpbuf[100]; 296 char tmpbuf[100];
297 297
298 WinQueryClassName(child, 99, tmpbuf); 298 WinQueryClassName(child, 99, tmpbuf);
299 299
300 if(strncmp(tmpbuf, "#3", 3)==0 && dw) /* Button */ 300 if(strncmp(tmpbuf, "#3", 3)==0 && dw) /* Button */
301 WinSetOwner(child, dw); 301 WinSetOwner(child, dw);
302 else if(strncmp(tmpbuf, "dynamicwindows", 14) == 0) 302 else if(strncmp(tmpbuf, "dynamicwindows", 14) == 0)
303 dw = child; 303 dw = child;
304 304
305 _fix_button_owner(child, dw); 305 _fix_button_owner(child, dw);
306 } 306 }
307 WinEndEnumWindows(henum); 307 WinEndEnumWindows(henum);
308 return; 308 return;
309 } 309 }
310 310
311 /* Free bitmap data associated with a window */ 311 /* Free bitmap data associated with a window */
312 void _free_bitmap(HWND handle) 312 void _free_bitmap(HWND handle)
313 { 313 {
314 HBITMAP hbm = (HBITMAP)dw_window_get_data(handle, "_dw_bitmap"); 314 HBITMAP hbm = (HBITMAP)dw_window_get_data(handle, "_dw_bitmap");
315 HPS hps = (HPS)dw_window_get_data(handle, "_dw_hps"); 315 HPS hps = (HPS)dw_window_get_data(handle, "_dw_hps");
316 HDC hdc = (HDC)dw_window_get_data(handle, "_dw_hdc"); 316 HDC hdc = (HDC)dw_window_get_data(handle, "_dw_hdc");
317 HPIXMAP pixmap = (HPIXMAP)dw_window_get_data(handle, "_dw_hpixmap"); 317 HPIXMAP pixmap = (HPIXMAP)dw_window_get_data(handle, "_dw_hpixmap");
318 HPIXMAP disable = (HPIXMAP)dw_window_get_data(handle, "_dw_hpixmap_disabled"); 318 HPIXMAP disable = (HPIXMAP)dw_window_get_data(handle, "_dw_hpixmap_disabled");
319 HPOINTER icon = (HPOINTER)dw_window_get_data(handle, "_dw_button_icon"); 319 HPOINTER icon = (HPOINTER)dw_window_get_data(handle, "_dw_button_icon");
320 320
321 if(icon) 321 if(icon)
322 WinDestroyPointer(icon); 322 WinDestroyPointer(icon);
323 323
324 if(pixmap) 324 if(pixmap)
325 dw_pixmap_destroy(pixmap); 325 dw_pixmap_destroy(pixmap);
326 326
327 if(disable) 327 if(disable)
328 dw_pixmap_destroy(disable); 328 dw_pixmap_destroy(disable);
329 329
330 if(hps) 330 if(hps)
331 { 331 {
332 GpiSetBitmap(hps, NULLHANDLE); 332 GpiSetBitmap(hps, NULLHANDLE);
333 GpiAssociate(hps, NULLHANDLE); 333 GpiAssociate(hps, NULLHANDLE);
334 GpiDestroyPS(hps); 334 GpiDestroyPS(hps);
335 } 335 }
336 336
337 if(hdc) 337 if(hdc)
338 DevCloseDC(hdc); 338 DevCloseDC(hdc);
339 339
340 if(hbm) 340 if(hbm)
341 GpiDeleteBitmap(hbm); 341 GpiDeleteBitmap(hbm);
342 } 342 }
343 343
344 /* This function removes any handlers on windows and frees 344 /* This function removes any handlers on windows and frees
345 * the user memory allocated to it. 345 * the user memory allocated to it.
346 */ 346 */
347 void _free_window_memory(HWND handle) 347 void _free_window_memory(HWND handle)
348 { 348 {
349 HENUM henum; 349 HENUM henum;
350 HWND child; 350 HWND child;
351 void *ptr = (void *)WinQueryWindowPtr(handle, QWP_USER); 351 void *ptr = (void *)WinQueryWindowPtr(handle, QWP_USER);
352 352
353 dw_signal_disconnect_by_window(handle); 353 dw_signal_disconnect_by_window(handle);
354 354
355 if((child = WinWindowFromID(handle, FID_MENU)) != NULLHANDLE) 355 if((child = WinWindowFromID(handle, FID_MENU)) != NULLHANDLE)
356 _free_menu_data(child); 356 _free_menu_data(child);
357 357
358 if((child = WinWindowFromID(handle, FID_CLIENT)) != NULLHANDLE) 358 if((child = WinWindowFromID(handle, FID_CLIENT)) != NULLHANDLE)
359 { 359 {
360 Box *box = (Box *)WinQueryWindowPtr(child, QWP_USER); 360 Box *box = (Box *)WinQueryWindowPtr(child, QWP_USER);
361 361
362 if(box) 362 if(box)
363 { 363 {
364 if(box->count && box->items) 364 if(box->count && box->items)
365 free(box->items); 365 free(box->items);
366 366
367 WinSetWindowPtr(child, QWP_USER, 0); 367 WinSetWindowPtr(child, QWP_USER, 0);
368 free(box); 368 free(box);
369 } 369 }
370 } 370 }
371 371
372 if(ptr) 372 if(ptr)
373 { 373 {
374 WindowData *wd = (WindowData *)ptr; 374 WindowData *wd = (WindowData *)ptr;
375 char tmpbuf[100]; 375 char tmpbuf[100];
376 376
377 WinQueryClassName(handle, 99, tmpbuf); 377 WinQueryClassName(handle, 99, tmpbuf);
378 378
379 if(strncmp(tmpbuf, "ColorSelectClass", 17)!=0) 379 if(strncmp(tmpbuf, "ColorSelectClass", 17)!=0)
380 { 380 {
381 /* If this window has an associate bitmap destroy it. */ 381 /* If this window has an associate bitmap destroy it. */
382 _free_bitmap(handle); 382 _free_bitmap(handle);
383 383
384 if(strncmp(tmpbuf, "#1", 3)==0 && !WinWindowFromID(handle, FID_CLIENT)) 384 if(strncmp(tmpbuf, "#1", 3)==0 && !WinWindowFromID(handle, FID_CLIENT))
385 { 385 {
386 Box *box = (Box *)ptr; 386 Box *box = (Box *)ptr;
387 387
388 if(box->count && box->items) 388 if(box->count && box->items)
389 free(box->items); 389 free(box->items);
390 } 390 }
391 else if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0) 391 else if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0)
392 { 392 {
393 void *data = dw_window_get_data(handle, "_dw_percent"); 393 void *data = dw_window_get_data(handle, "_dw_percent");
394 394
395 if(data) 395 if(data)
396 free(data); 396 free(data);
397 } 397 }
398 else if(strncmp(tmpbuf, "#37", 4)==0) 398 else if(strncmp(tmpbuf, "#37", 4)==0)
399 { 399 {
400 dw_container_clear(handle, FALSE); 400 dw_container_clear(handle, FALSE);
401 if(wd && dw_window_get_data(handle, "_dw_container")) 401 if(wd && dw_window_get_data(handle, "_dw_container"))
402 { 402 {
403 void *oldflags = wd->data; 403 void *oldflags = wd->data;
404 404
405 wd->data = NULL; 405 wd->data = NULL;
406 free(oldflags); 406 free(oldflags);
407 } 407 }
408 } 408 }
409 409
410 if(wd->oldproc) 410 if(wd->oldproc)
411 WinSubclassWindow(handle, wd->oldproc); 411 WinSubclassWindow(handle, wd->oldproc);
412 412
413 dw_window_set_data(handle, NULL, NULL); 413 dw_window_set_data(handle, NULL, NULL);
414 WinSetWindowPtr(handle, QWP_USER, 0); 414 WinSetWindowPtr(handle, QWP_USER, 0);
415 free(ptr); 415 free(ptr);
416 } 416 }
417 } 417 }
418 418
419 henum = WinBeginEnumWindows(handle); 419 henum = WinBeginEnumWindows(handle);
420 while((child = WinGetNextWindow(henum)) != NULLHANDLE) 420 while((child = WinGetNextWindow(henum)) != NULLHANDLE)
421 _free_window_memory(child); 421 _free_window_memory(child);
422 422
423 WinEndEnumWindows(henum); 423 WinEndEnumWindows(henum);
424 return; 424 return;
425 } 425 }
426 426
427 void _free_menu_data(HWND menu) 427 void _free_menu_data(HWND menu)
428 { 428 {
429 int i, count = (int)WinSendMsg(menu, MM_QUERYITEMCOUNT, 0, 0); 429 int i, count = (int)WinSendMsg(menu, MM_QUERYITEMCOUNT, 0, 0);
430 430
431 dw_signal_disconnect_by_name(menu, DW_SIGNAL_CLICKED); 431 dw_signal_disconnect_by_name(menu, DW_SIGNAL_CLICKED);
432 _free_window_memory(menu); 432 _free_window_memory(menu);
433 433
434 for(i=0;i<count;i++) 434 for(i=0;i<count;i++)
435 { 435 {
436 SHORT menuid = (SHORT)WinSendMsg(menu, MM_ITEMIDFROMPOSITION, MPFROMSHORT(i), 0); 436 SHORT menuid = (SHORT)WinSendMsg(menu, MM_ITEMIDFROMPOSITION, MPFROMSHORT(i), 0);
437 MENUITEM mi; 437 MENUITEM mi;
438 438
439 if(WinSendMsg(menu, MM_QUERYITEM, MPFROMSHORT(menuid), MPFROMP(&mi)) 439 if(WinSendMsg(menu, MM_QUERYITEM, MPFROMSHORT(menuid), MPFROMP(&mi))
440 && mi.hwndSubMenu) 440 && mi.hwndSubMenu)
441 _free_menu_data(mi.hwndSubMenu); 441 _free_menu_data(mi.hwndSubMenu);
442 } 442 }
443 } 443 }
444 444
445 /* This function returns 1 if the window (widget) handle 445 /* This function returns 1 if the window (widget) handle
446 * passed to it is a valid window that can gain input focus. 446 * passed to it is a valid window that can gain input focus.
447 */ 447 */
448 int _validate_focus(HWND handle) 448 int _validate_focus(HWND handle)
449 { 449 {
450 char tmpbuf[100]; 450 char tmpbuf[100];
451 451
452 if(!handle) 452 if(!handle)
453 return 0; 453 return 0;
454 454
455 WinQueryClassName(handle, 99, tmpbuf); 455 WinQueryClassName(handle, 99, tmpbuf);
456 456
457 if(!WinIsWindowEnabled(handle) || 457 if(!WinIsWindowEnabled(handle) ||
458 (strncmp(tmpbuf, "ColorSelectClass", 17) && dw_window_get_data(handle, "_dw_disabled"))) 458 (strncmp(tmpbuf, "ColorSelectClass", 17) && dw_window_get_data(handle, "_dw_disabled")))
459 return 0; 459 return 0;
460 460
461 /* These are the window classes which can 461 /* These are the window classes which can
462 * obtain input focus. 462 * obtain input focus.
463 */ 463 */
464 if(strncmp(tmpbuf, "#2", 3)==0 || /* Combobox */ 464 if(strncmp(tmpbuf, "#2", 3)==0 || /* Combobox */
465 strncmp(tmpbuf, "#3", 3)==0 || /* Button */ 465 strncmp(tmpbuf, "#3", 3)==0 || /* Button */
466 strncmp(tmpbuf, "#6", 3)==0 || /* Entryfield */ 466 strncmp(tmpbuf, "#6", 3)==0 || /* Entryfield */
467 strncmp(tmpbuf, "#7", 3)==0 || /* List box */ 467 strncmp(tmpbuf, "#7", 3)==0 || /* List box */
468 strncmp(tmpbuf, "#10", 4)==0 || /* MLE */ 468 strncmp(tmpbuf, "#10", 4)==0 || /* MLE */
469 strncmp(tmpbuf, "#32", 4)==0 || /* Spinbutton */ 469 strncmp(tmpbuf, "#32", 4)==0 || /* Spinbutton */
470 strncmp(tmpbuf, "#37", 4)==0 || /* Container */ 470 strncmp(tmpbuf, "#37", 4)==0 || /* Container */
471 strncmp(tmpbuf, "#38", 4)== 0) /* Slider */ 471 strncmp(tmpbuf, "#38", 4)== 0) /* Slider */
472 return 1; 472 return 1;
473 return 0; 473 return 0;
474 } 474 }
475 475
476 int _focus_check_box(Box *box, HWND handle, int start, HWND defaultitem) 476 int _focus_check_box(Box *box, HWND handle, int start, HWND defaultitem)
477 { 477 {
478 int z; 478 int z;
479 static HWND lasthwnd, firsthwnd; 479 static HWND lasthwnd, firsthwnd;
480 static int finish_searching; 480 static int finish_searching;
481 481
482 /* Start is 2 when we have cycled completely and 482 /* Start is 2 when we have cycled completely and
483 * need to set the focus to the last widget we found 483 * need to set the focus to the last widget we found
484 * that was valid. 484 * that was valid.
485 */ 485 */
486 if(start == 2) 486 if(start == 2)
487 { 487 {
488 if(lasthwnd) 488 if(lasthwnd)
489 WinSetFocus(HWND_DESKTOP, lasthwnd); 489 WinSetFocus(HWND_DESKTOP, lasthwnd);
490 return 0; 490 return 0;
491 } 491 }
492 492
493 /* Start is 1 when we are entering the function 493 /* Start is 1 when we are entering the function
494 * for the first time, it is zero when entering 494 * for the first time, it is zero when entering
495 * the function recursively. 495 * the function recursively.
496 */ 496 */
497 if(start == 1) 497 if(start == 1)
498 { 498 {
499 lasthwnd = handle; 499 lasthwnd = handle;
500 finish_searching = 0; 500 finish_searching = 0;
501 firsthwnd = 0; 501 firsthwnd = 0;
502 } 502 }
503 503
504 for(z=box->count-1;z>-1;z--) 504 for(z=box->count-1;z>-1;z--)
505 { 505 {
506 if(box->items[z].type == TYPEBOX) 506 if(box->items[z].type == TYPEBOX)
507 { 507 {
508 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER); 508 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER);
509 509
510 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0, defaultitem)) 510 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0, defaultitem))
511 return 1; 511 return 1;
512 } 512 }
513 else 513 else
514 { 514 {
515 if(box->items[z].hwnd == handle) 515 if(box->items[z].hwnd == handle)
516 { 516 {
517 if(lasthwnd == handle && firsthwnd) 517 if(lasthwnd == handle && firsthwnd)
518 WinSetFocus(HWND_DESKTOP, firsthwnd); 518 WinSetFocus(HWND_DESKTOP, firsthwnd);
519 else if(lasthwnd == handle && !firsthwnd) 519 else if(lasthwnd == handle && !firsthwnd)
520 finish_searching = 1; 520 finish_searching = 1;
521 else 521 else
522 WinSetFocus(HWND_DESKTOP, lasthwnd); 522 WinSetFocus(HWND_DESKTOP, lasthwnd);
523 523
524 /* If we aren't looking for the last handle, 524 /* If we aren't looking for the last handle,
525 * return immediately. 525 * return immediately.
526 */ 526 */
527 if(!finish_searching) 527 if(!finish_searching)
528 return 1; 528 return 1;
529 } 529 }
530 if(_validate_focus(box->items[z].hwnd)) 530 if(_validate_focus(box->items[z].hwnd))
531 { 531 {
532 /* Start is 3 when we are looking for the 532 /* Start is 3 when we are looking for the
533 * first valid item in the layout. 533 * first valid item in the layout.
534 */ 534 */
535 if(start == 3) 535 if(start == 3)
536 { 536 {
537 if(!defaultitem || (defaultitem && defaultitem == box->items[z].hwnd)) 537 if(!defaultitem || (defaultitem && defaultitem == box->items[z].hwnd))
538 { 538 {
539 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd); 539 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd);
540 return 1; 540 return 1;
541 } 541 }
542 } 542 }
543 543
544 if(!firsthwnd) 544 if(!firsthwnd)
545 firsthwnd = box->items[z].hwnd; 545 firsthwnd = box->items[z].hwnd;
546 546
547 lasthwnd = box->items[z].hwnd; 547 lasthwnd = box->items[z].hwnd;
548 } 548 }
549 else 549 else
550 { 550 {
551 char tmpbuf[100] = ""; 551 char tmpbuf[100] = "";
552 552
553 WinQueryClassName(box->items[z].hwnd, 99, tmpbuf); 553 WinQueryClassName(box->items[z].hwnd, 99, tmpbuf);
554 if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0) 554 if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0)
555 { 555 {
556 /* Then try the bottom or right box */ 556 /* Then try the bottom or right box */
557 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_bottomright"); 557 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_bottomright");
558 558
559 if(mybox) 559 if(mybox)
560 { 560 {
561 Box *splitbox = (Box *)WinQueryWindowPtr(mybox, QWP_USER); 561 Box *splitbox = (Box *)WinQueryWindowPtr(mybox, QWP_USER);
562 562
563 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem)) 563 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
564 return 1; 564 return 1;
565 } 565 }
566 566
567 /* Try the top or left box */ 567 /* Try the top or left box */
568 mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_topleft"); 568 mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_topleft");
569 569
570 if(mybox) 570 if(mybox)
571 { 571 {
572 Box *splitbox = (Box *)WinQueryWindowPtr(mybox, QWP_USER); 572 Box *splitbox = (Box *)WinQueryWindowPtr(mybox, QWP_USER);
573 573
574 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem)) 574 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
575 return 1; 575 return 1;
576 } 576 }
577 } 577 }
578 else if(strncmp(tmpbuf, "#40", 4)==0) /* Notebook */ 578 else if(strncmp(tmpbuf, "#40", 4)==0) /* Notebook */
579 { 579 {
580 Box *notebox; 580 Box *notebox;
581 HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND, 581 HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND,
582 (MPARAM)dw_notebook_page_get(box->items[z].hwnd), 0); 582 (MPARAM)dw_notebook_page_get(box->items[z].hwnd), 0);
583 583
584 if(page) 584 if(page)
585 { 585 {
586 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER); 586 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER);
587 587
588 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, defaultitem)) 588 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, defaultitem))
589 return 1; 589 return 1;
590 } 590 }
591 } 591 }
592 } 592 }
593 } 593 }
594 } 594 }
595 return 0; 595 return 0;
596 } 596 }
597 597
598 int _focus_check_box_back(Box *box, HWND handle, int start, HWND defaultitem) 598 int _focus_check_box_back(Box *box, HWND handle, int start, HWND defaultitem)
599 { 599 {
600 int z; 600 int z;
601 static HWND lasthwnd, firsthwnd; 601 static HWND lasthwnd, firsthwnd;
602 static int finish_searching; 602 static int finish_searching;
603 603
604 /* Start is 2 when we have cycled completely and 604 /* Start is 2 when we have cycled completely and
605 * need to set the focus to the last widget we found 605 * need to set the focus to the last widget we found
606 * that was valid. 606 * that was valid.
607 */ 607 */
608 if(start == 2) 608 if(start == 2)
609 { 609 {
610 if(lasthwnd) 610 if(lasthwnd)
611 WinSetFocus(HWND_DESKTOP, lasthwnd); 611 WinSetFocus(HWND_DESKTOP, lasthwnd);
612 return 0; 612 return 0;
613 } 613 }
614 614
615 /* Start is 1 when we are entering the function 615 /* Start is 1 when we are entering the function
616 * for the first time, it is zero when entering 616 * for the first time, it is zero when entering
617 * the function recursively. 617 * the function recursively.
618 */ 618 */
619 if(start == 1) 619 if(start == 1)
620 { 620 {
621 lasthwnd = handle; 621 lasthwnd = handle;
622 finish_searching = 0; 622 finish_searching = 0;
623 firsthwnd = 0; 623 firsthwnd = 0;
624 } 624 }
625 625
626 for(z=0;z<box->count;z++) 626 for(z=0;z<box->count;z++)
627 { 627 {
628 if(box->items[z].type == TYPEBOX) 628 if(box->items[z].type == TYPEBOX)
629 { 629 {
630 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER); 630 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER);
631 631
632 if(thisbox && _focus_check_box_back(thisbox, handle, start == 3 ? 3 : 0, defaultitem)) 632 if(thisbox && _focus_check_box_back(thisbox, handle, start == 3 ? 3 : 0, defaultitem))
633 return 1; 633 return 1;
634 } 634 }
635 else 635 else
636 { 636 {
637 if(box->items[z].hwnd == handle) 637 if(box->items[z].hwnd == handle)
638 { 638 {
639 if(lasthwnd == handle && firsthwnd) 639 if(lasthwnd == handle && firsthwnd)
640 WinSetFocus(HWND_DESKTOP, firsthwnd); 640 WinSetFocus(HWND_DESKTOP, firsthwnd);
641 else if(lasthwnd == handle && !firsthwnd) 641 else if(lasthwnd == handle && !firsthwnd)
642 finish_searching = 1; 642 finish_searching = 1;
643 else 643 else
644 WinSetFocus(HWND_DESKTOP, lasthwnd); 644 WinSetFocus(HWND_DESKTOP, lasthwnd);
645 645
646 /* If we aren't looking for the last handle, 646 /* If we aren't looking for the last handle,
647 * return immediately. 647 * return immediately.
648 */ 648 */
649 if(!finish_searching) 649 if(!finish_searching)
650 return 1; 650 return 1;
651 } 651 }
652 if(_validate_focus(box->items[z].hwnd)) 652 if(_validate_focus(box->items[z].hwnd))
653 { 653 {
654 /* Start is 3 when we are looking for the 654 /* Start is 3 when we are looking for the
655 * first valid item in the layout. 655 * first valid item in the layout.
656 */ 656 */
657 if(start == 3) 657 if(start == 3)
658 { 658 {
659 if(!defaultitem || (defaultitem && defaultitem == box->items[z].hwnd)) 659 if(!defaultitem || (defaultitem && defaultitem == box->items[z].hwnd))
660 { 660 {
661 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd); 661 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd);
662 return 1; 662 return 1;
663 } 663 }
664 } 664 }
665 665
666 if(!firsthwnd) 666 if(!firsthwnd)
667 firsthwnd = box->items[z].hwnd; 667 firsthwnd = box->items[z].hwnd;
668 668
669 lasthwnd = box->items[z].hwnd; 669 lasthwnd = box->items[z].hwnd;
670 } 670 }
671 else 671 else
672 { 672 {
673 char tmpbuf[100] = ""; 673 char tmpbuf[100] = "";
674 674
675 WinQueryClassName(box->items[z].hwnd, 99, tmpbuf); 675 WinQueryClassName(box->items[z].hwnd, 99, tmpbuf);
676 if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0) 676 if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0)
677 { 677 {
678 /* Try the top or left box */ 678 /* Try the top or left box */
679 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_topleft"); 679 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_topleft");
680 680
681 if(mybox) 681 if(mybox)
682 { 682 {
683 Box *splitbox = (Box *)WinQueryWindowPtr(mybox, QWP_USER); 683 Box *splitbox = (Box *)WinQueryWindowPtr(mybox, QWP_USER);
684 684
685 if(splitbox && _focus_check_box_back(splitbox, handle, start == 3 ? 3 : 0, defaultitem)) 685 if(splitbox && _focus_check_box_back(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
686 return 1; 686 return 1;
687 } 687 }
688 688
689 /* Then try the bottom or right box */ 689 /* Then try the bottom or right box */
690 mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_bottomright"); 690 mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_bottomright");
691 691
692 if(mybox) 692 if(mybox)
693 { 693 {
694 Box *splitbox = (Box *)WinQueryWindowPtr(mybox, QWP_USER); 694 Box *splitbox = (Box *)WinQueryWindowPtr(mybox, QWP_USER);
695 695
696 if(splitbox && _focus_check_box_back(splitbox, handle, start == 3 ? 3 : 0, defaultitem)) 696 if(splitbox && _focus_check_box_back(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
697 return 1; 697 return 1;
698 } 698 }
699 } 699 }
700 else if(strncmp(tmpbuf, "#40", 4)==0) /* Notebook */ 700 else if(strncmp(tmpbuf, "#40", 4)==0) /* Notebook */
701 { 701 {
702 Box *notebox; 702 Box *notebox;
703 HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND, 703 HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND,
704 (MPARAM)dw_notebook_page_get(box->items[z].hwnd), 0); 704 (MPARAM)dw_notebook_page_get(box->items[z].hwnd), 0);
705 705
706 if(page) 706 if(page)
707 { 707 {
708 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER); 708 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER);
709 709
710 if(notebox && _focus_check_box_back(notebox, handle, start == 3 ? 3 : 0, defaultitem)) 710 if(notebox && _focus_check_box_back(notebox, handle, start == 3 ? 3 : 0, defaultitem))
711 return 1; 711 return 1;
712 } 712 }
713 } 713 }
714 } 714 }
715 } 715 }
716 } 716 }
717 return 0; 717 return 0;
718 } 718 }
719 719
720 /* This function finds the first widget in the 720 /* This function finds the first widget in the
721 * layout and moves the current focus to it. 721 * layout and moves the current focus to it.
722 */ 722 */
723 int _initial_focus(HWND handle) 723 int _initial_focus(HWND handle)
724 { 724 {
725 Box *thisbox = NULL; 725 Box *thisbox = NULL;
726 HWND box; 726 HWND box;
727 727
728 box = WinWindowFromID(handle, FID_CLIENT); 728 box = WinWindowFromID(handle, FID_CLIENT);
729 if(box) 729 if(box)
730 thisbox = WinQueryWindowPtr(box, QWP_USER); 730 thisbox = WinQueryWindowPtr(box, QWP_USER);
731 else 731 else
732 return 1; 732 return 1;
733 733
734 if(thisbox) 734 if(thisbox)
735 _focus_check_box(thisbox, handle, 3, thisbox->defaultitem); 735 _focus_check_box(thisbox, handle, 3, thisbox->defaultitem);
736 return 0; 736 return 0;
737 } 737 }
738 738
739 /* This function finds the current widget in the 739 /* This function finds the current widget in the
740 * layout and moves the current focus to the next item. 740 * layout and moves the current focus to the next item.
741 */ 741 */
742 void _shift_focus(HWND handle) 742 void _shift_focus(HWND handle)
743 { 743 {
744 Box *thisbox; 744 Box *thisbox;
745 HWND box, lastbox = _toplevel_window(handle); 745 HWND box, lastbox = _toplevel_window(handle);
746 746
747 box = WinWindowFromID(lastbox, FID_CLIENT); 747 box = WinWindowFromID(lastbox, FID_CLIENT);
748 if(box) 748 if(box)
749 thisbox = WinQueryWindowPtr(box, QWP_USER); 749 thisbox = WinQueryWindowPtr(box, QWP_USER);
750 else 750 else
751 thisbox = WinQueryWindowPtr(lastbox, QWP_USER); 751 thisbox = WinQueryWindowPtr(lastbox, QWP_USER);
752 752
753 if(thisbox) 753 if(thisbox)
754 { 754 {
755 if(_focus_check_box(thisbox, handle, 1, 0) == 0) 755 if(_focus_check_box(thisbox, handle, 1, 0) == 0)
756 _focus_check_box(thisbox, handle, 2, 0); 756 _focus_check_box(thisbox, handle, 2, 0);
757 } 757 }
758 } 758 }
759 759
760 /* This function finds the current widget in the 760 /* This function finds the current widget in the
761 * layout and moves the current focus to the next item. 761 * layout and moves the current focus to the next item.
762 */ 762 */
763 void _shift_focus_back(HWND handle) 763 void _shift_focus_back(HWND handle)
764 { 764 {
765 Box *thisbox; 765 Box *thisbox;
766 HWND box, lastbox = _toplevel_window(handle); 766 HWND box, lastbox = _toplevel_window(handle);
767 767
768 box = WinWindowFromID(lastbox, FID_CLIENT); 768 box = WinWindowFromID(lastbox, FID_CLIENT);
769 if(box) 769 if(box)
770 thisbox = WinQueryWindowPtr(box, QWP_USER); 770 thisbox = WinQueryWindowPtr(box, QWP_USER);
771 else 771 else
772 thisbox = WinQueryWindowPtr(lastbox, QWP_USER); 772 thisbox = WinQueryWindowPtr(lastbox, QWP_USER);
773 773
774 if(thisbox) 774 if(thisbox)
775 { 775 {
776 if(_focus_check_box_back(thisbox, handle, 1, 0) == 0) 776 if(_focus_check_box_back(thisbox, handle, 1, 0) == 0)
777 _focus_check_box_back(thisbox, handle, 2, 0); 777 _focus_check_box_back(thisbox, handle, 2, 0);
778 } 778 }
779 } 779 }
780 780
781 /* This function will recursively search a box and add up the total height of it */ 781 /* This function will recursively search a box and add up the total height of it */
782 void _count_size(HWND box, int type, int *xsize, int *xorigsize) 782 void _count_size(HWND box, int type, int *xsize, int *xorigsize)
783 { 783 {
784 int size = 0, origsize = 0, z; 784 int size = 0, origsize = 0, z;
785 Box *tmp = WinQueryWindowPtr(box, QWP_USER); 785 Box *tmp = WinQueryWindowPtr(box, QWP_USER);
786 786
787 if(!tmp) 787 if(!tmp)
788 { 788 {
789 *xsize = *xorigsize = 0; 789 *xsize = *xorigsize = 0;
790 return; 790 return;
791 } 791 }
792 792
793 if(type == tmp->type) 793 if(type == tmp->type)
794 { 794 {
795 /* If the box is going in the direction we want, then we 795 /* If the box is going in the direction we want, then we
796 * return the entire sum of the items. 796 * return the entire sum of the items.
797 */ 797 */
798 for(z=0;z<tmp->count;z++) 798 for(z=0;z<tmp->count;z++)
799 { 799 {
800 if(tmp->items[z].type == TYPEBOX) 800 if(tmp->items[z].type == TYPEBOX)
801 { 801 {
802 int s, os; 802 int s, os;
803 803
804 _count_size(tmp->items[z].hwnd, type, &s, &os); 804 _count_size(tmp->items[z].hwnd, type, &s, &os);
805 size += s; 805 size += s;
806 origsize += os; 806 origsize += os;
807 } 807 }
808 else 808 else
809 { 809 {
810 size += (type == DW_HORZ ? tmp->items[z].width : tmp->items[z].height); 810 size += (type == DW_HORZ ? tmp->items[z].width : tmp->items[z].height);
811 origsize += (type == DW_HORZ ? tmp->items[z].origwidth : tmp->items[z].origheight); 811 origsize += (type == DW_HORZ ? tmp->items[z].origwidth : tmp->items[z].origheight);
812 } 812 }
813 } 813 }
814 } 814 }
815 else 815 else
816 { 816 {
817 /* If the box is not going in the direction we want, then we only 817 /* If the box is not going in the direction we want, then we only
818 * want to return the maximum value. 818 * want to return the maximum value.
819 */ 819 */
820 int tmpsize = 0, tmporigsize = 0; 820 int tmpsize = 0, tmporigsize = 0;
821 821
822 for(z=0;z<tmp->count;z++) 822 for(z=0;z<tmp->count;z++)
823 { 823 {
824 if(tmp->items[z].type == TYPEBOX) 824 if(tmp->items[z].type == TYPEBOX)
825 _count_size(tmp->items[z].hwnd, type, &tmpsize, &tmporigsize); 825 _count_size(tmp->items[z].hwnd, type, &tmpsize, &tmporigsize);
826 else 826 else
827 { 827 {
828 tmpsize = (type == DW_HORZ ? tmp->items[z].width : tmp->items[z].height); 828 tmpsize = (type == DW_HORZ ? tmp->items[z].width : tmp->items[z].height);
829 tmporigsize = (type == DW_HORZ ? tmp->items[z].origwidth : tmp->items[z].origheight); 829 tmporigsize = (type == DW_HORZ ? tmp->items[z].origwidth : tmp->items[z].origheight);
830 } 830 }
831 831
832 if(tmpsize > size) 832 if(tmpsize > size)
833 size = tmpsize; 833 size = tmpsize;
834 } 834 }
835 } 835 }
836 836
837 *xsize = size; 837 *xsize = size;
838 *xorigsize = origsize; 838 *xorigsize = origsize;
839 } 839 }
840 840
841 841
842 /* Function: TrackRectangle 842 /* Function: TrackRectangle
843 * Abstract: Tracks given rectangle. 843 * Abstract: Tracks given rectangle.
847 * desktop. 847 * desktop.
848 */ 848 */
849 849
850 BOOL _TrackRectangle(HWND hwndBase, RECTL* rclTrack, RECTL* rclBounds) 850 BOOL _TrackRectangle(HWND hwndBase, RECTL* rclTrack, RECTL* rclBounds)
851 { 851 {
852 TRACKINFO track; 852 TRACKINFO track;
853 APIRET rc; 853 APIRET rc;
854 854
855 track.cxBorder = 1; 855 track.cxBorder = 1;
856 track.cyBorder = 1; 856 track.cyBorder = 1;
857 track.cxGrid = 1; 857 track.cxGrid = 1;
858 track.cyGrid = 1; 858 track.cyGrid = 1;
859 track.cxKeyboard = 8; 859 track.cxKeyboard = 8;
860 track.cyKeyboard = 8; 860 track.cyKeyboard = 8;
861 861
862 if(!rclTrack) 862 if(!rclTrack)
863 return FALSE; 863 return FALSE;
864 864
865 if(rclBounds) 865 if(rclBounds)
866 { 866 {
867 track.rclBoundary = *rclBounds; 867 track.rclBoundary = *rclBounds;
868 } 868 }
869 else 869 else
870 { 870 {
871 track.rclBoundary.yTop = 871 track.rclBoundary.yTop =
872 track.rclBoundary.xRight = 3000; 872 track.rclBoundary.xRight = 3000;
873 track.rclBoundary.yBottom = 873 track.rclBoundary.yBottom =
874 track.rclBoundary.xLeft = -3000; 874 track.rclBoundary.xLeft = -3000;
875 } 875 }
876 876
877 track.rclTrack = *rclTrack; 877 track.rclTrack = *rclTrack;
878 878
879 WinMapWindowPoints(hwndBase, 879 WinMapWindowPoints(hwndBase,
880 HWND_DESKTOP, 880 HWND_DESKTOP,
881 (PPOINTL)&track.rclTrack, 881 (PPOINTL)&track.rclTrack,
882 2); 882 2);
883 883
884 track.ptlMinTrackSize.x = track.rclTrack.xRight 884 track.ptlMinTrackSize.x = track.rclTrack.xRight
885 - track.rclTrack.xLeft; 885 - track.rclTrack.xLeft;
886 track.ptlMinTrackSize.y = track.rclTrack.yTop 886 track.ptlMinTrackSize.y = track.rclTrack.yTop
887 - track.rclTrack.yBottom; 887 - track.rclTrack.yBottom;
888 track.ptlMaxTrackSize.x = track.rclTrack.xRight 888 track.ptlMaxTrackSize.x = track.rclTrack.xRight
889 - track.rclTrack.xLeft; 889 - track.rclTrack.xLeft;
890 track.ptlMaxTrackSize.y = track.rclTrack.yTop 890 track.ptlMaxTrackSize.y = track.rclTrack.yTop
891 - track.rclTrack.yBottom; 891 - track.rclTrack.yBottom;
892 892
893 track.fs = TF_MOVE | TF_ALLINBOUNDARY; 893 track.fs = TF_MOVE | TF_ALLINBOUNDARY;
894 894
895 rc = WinTrackRect(HWND_DESKTOP, 0, &track); 895 rc = WinTrackRect(HWND_DESKTOP, 0, &track);
896 896
897 if(rc) 897 if(rc)
898 *rclTrack = track.rclTrack; 898 *rclTrack = track.rclTrack;
899 899
900 return rc; 900 return rc;
901 } 901 }
902 902
903 void _check_resize_notebook(HWND hwnd) 903 void _check_resize_notebook(HWND hwnd)
904 { 904 {
905 char tmpbuf[100]; 905 char tmpbuf[100];
906 906
907 WinQueryClassName(hwnd, 99, tmpbuf); 907 WinQueryClassName(hwnd, 99, tmpbuf);
908 908
909 /* If we have a notebook we resize the page again. */ 909 /* If we have a notebook we resize the page again. */
910 if(strncmp(tmpbuf, "#40", 4)==0) 910 if(strncmp(tmpbuf, "#40", 4)==0)
911 { 911 {
912 unsigned long x, y, width, height; 912 unsigned long x, y, width, height;
913 ULONG page = (ULONG)WinSendMsg(hwnd, BKM_QUERYPAGEID, 0, MPFROM2SHORT(BKA_FIRST, BKA_MAJOR)); 913 ULONG page = (ULONG)WinSendMsg(hwnd, BKM_QUERYPAGEID, 0, MPFROM2SHORT(BKA_FIRST, BKA_MAJOR));
914 914
915 while(page) 915 while(page)
916 { 916 {
917 HWND pagehwnd = (HWND)WinSendMsg(hwnd, BKM_QUERYPAGEWINDOWHWND, MPFROMLONG(page), 0); 917 HWND pagehwnd = (HWND)WinSendMsg(hwnd, BKM_QUERYPAGEWINDOWHWND, MPFROMLONG(page), 0);
918 RECTL rc; 918 RECTL rc;
919 919
920 Box *pagebox = (Box *)WinQueryWindowPtr(pagehwnd, QWP_USER); 920 Box *pagebox = (Box *)WinQueryWindowPtr(pagehwnd, QWP_USER);
921 if(pagebox) 921 if(pagebox)
922 { 922 {
923 dw_window_get_pos_size(hwnd, &x, &y, &width, &height); 923 dw_window_get_pos_size(hwnd, &x, &y, &width, &height);
924 924
925 rc.xLeft = x; 925 rc.xLeft = x;
926 rc.yBottom = y; 926 rc.yBottom = y;
927 rc.xRight = x + width; 927 rc.xRight = x + width;
928 rc.yTop = y + height; 928 rc.yTop = y + height;
929 929
930 WinSendMsg(hwnd, BKM_CALCPAGERECT, (MPARAM)&rc, (MPARAM)TRUE); 930 WinSendMsg(hwnd, BKM_CALCPAGERECT, (MPARAM)&rc, (MPARAM)TRUE);
931 931
932 _do_resize(pagebox, rc.xRight - rc.xLeft, rc.yTop - rc.yBottom); 932 _do_resize(pagebox, rc.xRight - rc.xLeft, rc.yTop - rc.yBottom);
933 } 933 }
934 page = (ULONG)WinSendMsg(hwnd, BKM_QUERYPAGEID, (MPARAM)page, MPFROM2SHORT(BKA_NEXT, BKA_MAJOR)); 934 page = (ULONG)WinSendMsg(hwnd, BKM_QUERYPAGEID, (MPARAM)page, MPFROM2SHORT(BKA_NEXT, BKA_MAJOR));
935 } 935 }
936 936
937 } 937 }
938 } 938 }
939 939
940 /* Return the OS/2 color from the DW color */ 940 /* Return the OS/2 color from the DW color */
941 unsigned long _internal_color(unsigned long color) 941 unsigned long _internal_color(unsigned long color)
942 { 942 {
943 if(color < 16) 943 if(color < 16)
944 return _colors[color]; 944 return _colors[color];
945 return color; 945 return color;
946 } 946 }
947 947
948 unsigned long _os2_color(unsigned long color) 948 unsigned long _os2_color(unsigned long color)
949 { 949 {
950 return DW_RED_VALUE(color) << 16 | DW_GREEN_VALUE(color) << 8 | DW_BLUE_VALUE(color); 950 return DW_RED_VALUE(color) << 16 | DW_GREEN_VALUE(color) << 8 | DW_BLUE_VALUE(color);
951 } 951 }
952 952
953 BOOL _MySetWindowPos(HWND hwnd, HWND parent, HWND behind, LONG x, LONG y, LONG cx, LONG cy, ULONG fl) 953 BOOL _MySetWindowPos(HWND hwnd, HWND parent, HWND behind, LONG x, LONG y, LONG cx, LONG cy, ULONG fl)
954 { 954 {
955 int height = _get_height(parent); 955 int height = _get_height(parent);
956 956
957 return WinSetWindowPos(hwnd, behind, x, height - y - cy, cx, cy, fl); 957 return WinSetWindowPos(hwnd, behind, x, height - y - cy, cx, cy, fl);
958 } 958 }
959 959
960 /* This function calculates how much space the widgets and boxes require 960 /* This function calculates how much space the widgets and boxes require
961 * and does expansion as necessary. 961 * and does expansion as necessary.
962 */ 962 */
963 int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy, 963 int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy,
964 int pass, int *usedpadx, int *usedpady) 964 int pass, int *usedpadx, int *usedpady)
965 { 965 {
966 int z, currentx = 0, currenty = 0; 966 int z, currentx = 0, currenty = 0;
967 int uymax = 0, uxmax = 0; 967 int uymax = 0, uxmax = 0;
968 int upymax = 0, upxmax = 0; 968 int upymax = 0, upxmax = 0;
969 /* Used for the SIZEEXPAND */ 969 /* Used for the SIZEEXPAND */
970 int nux = *usedx, nuy = *usedy; 970 int nux = *usedx, nuy = *usedy;
971 int nupx = *usedpadx, nupy = *usedpady; 971 int nupx = *usedpadx, nupy = *usedpady;
972 972
973 (*usedx) += (thisbox->pad * 2); 973 (*usedx) += (thisbox->pad * 2);
974 (*usedy) += (thisbox->pad * 2); 974 (*usedy) += (thisbox->pad * 2);
975 975
976 if(thisbox->grouphwnd) 976 if(thisbox->grouphwnd)
977 { 977 {
978 char *text = dw_window_get_text(thisbox->grouphwnd); 978 char *text = dw_window_get_text(thisbox->grouphwnd);
979 979
980 thisbox->grouppady = 0; 980 thisbox->grouppady = 0;
981 981
982 if(text) 982 if(text)
983 { 983 {
984 dw_font_text_extents_get(thisbox->grouphwnd, 0, text, NULL, &thisbox->grouppady); 984 dw_font_text_extents_get(thisbox->grouphwnd, 0, text, NULL, &thisbox->grouppady);
985 dw_free(text); 985 dw_free(text);
986 } 986 }
987 987
988 if(thisbox->grouppady) 988 if(thisbox->grouppady)
989 thisbox->grouppady += 3; 989 thisbox->grouppady += 3;
990 else 990 else
991 thisbox->grouppady = 6; 991 thisbox->grouppady = 6;
992 992
993 thisbox->grouppadx = 6; 993 thisbox->grouppadx = 6;
994 994
995 (*usedx) += thisbox->grouppadx; 995 (*usedx) += thisbox->grouppadx;
996 (*usedpadx) += thisbox->grouppadx; 996 (*usedpadx) += thisbox->grouppadx;
997 (*usedy) += thisbox->grouppady; 997 (*usedy) += thisbox->grouppady;
998 (*usedpady) += thisbox->grouppady; 998 (*usedpady) += thisbox->grouppady;
999 } 999 }
1000 1000
1001 for(z=0;z<thisbox->count;z++) 1001 for(z=0;z<thisbox->count;z++)
1002 { 1002 {
1003 if(thisbox->items[z].type == TYPEBOX) 1003 if(thisbox->items[z].type == TYPEBOX)
1004 { 1004 {
1005 int initialx, initialy; 1005 int initialx, initialy;
1006 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); 1006 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER);
1007 1007
1008 initialx = x - (*usedx); 1008 initialx = x - (*usedx);
1009 initialy = y - (*usedy); 1009 initialy = y - (*usedy);
1010 1010
1011 if(tmp) 1011 if(tmp)
1012 { 1012 {
1013 int newx, newy; 1013 int newx, newy;
1014 int nux = *usedx, nuy = *usedy; 1014 int nux = *usedx, nuy = *usedy;
1015 int upx = *usedpadx + (tmp->pad*2), upy = *usedpady + (tmp->pad*2); 1015 int upx = *usedpadx + (tmp->pad*2), upy = *usedpady + (tmp->pad*2);
1016 1016
1017 /* On the second pass we know how big the box needs to be and how 1017 /* On the second pass we know how big the box needs to be and how
1018 * much space we have, so we can calculate a ratio for the new box. 1018 * much space we have, so we can calculate a ratio for the new box.
1019 */ 1019 */
1020 if(pass == 2) 1020 if(pass == 2)
1021 { 1021 {
1022 int deep = *depth + 1; 1022 int deep = *depth + 1;
1023 1023
1024 _resize_box(tmp, &deep, x, y, &nux, &nuy, 1, &upx, &upy); 1024 _resize_box(tmp, &deep, x, y, &nux, &nuy, 1, &upx, &upy);
1025 1025
1026 tmp->upx = upx - *usedpadx; 1026 tmp->upx = upx - *usedpadx;
1027 tmp->upy = upy - *usedpady; 1027 tmp->upy = upy - *usedpady;
1028 1028
1029 newx = x - nux; 1029 newx = x - nux;
1030 newy = y - nuy; 1030 newy = y - nuy;
1031 1031
1032 tmp->width = thisbox->items[z].width = initialx - newx; 1032 tmp->width = thisbox->items[z].width = initialx - newx;
1033 tmp->height = thisbox->items[z].height = initialy - newy; 1033 tmp->height = thisbox->items[z].height = initialy - newy;
1034 1034
1035 tmp->parentxratio = thisbox->xratio; 1035 tmp->parentxratio = thisbox->xratio;
1036 tmp->parentyratio = thisbox->yratio; 1036 tmp->parentyratio = thisbox->yratio;
1037 1037
1038 tmp->parentpad = tmp->pad; 1038 tmp->parentpad = tmp->pad;
1039 1039
1040 /* Just in case */ 1040 /* Just in case */
1041 tmp->xratio = thisbox->xratio; 1041 tmp->xratio = thisbox->xratio;
1042 tmp->yratio = thisbox->yratio; 1042 tmp->yratio = thisbox->yratio;
1043 1043
1044 if(thisbox->type == DW_VERT) 1044 if(thisbox->type == DW_VERT)
1045 { 1045 {
1046 int tmppad = (thisbox->items[z].pad*2)+(tmp->pad*2)+tmp->grouppady; 1046 int tmppad = (thisbox->items[z].pad*2)+(tmp->pad*2)+tmp->grouppady;
1047 1047
1048 if((thisbox->items[z].width - tmppad)!=0) 1048 if((thisbox->items[z].width - tmppad)!=0)
1049 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmppad))/((float)(thisbox->items[z].width-tmppad)); 1049 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmppad))/((float)(thisbox->items[z].width-tmppad));
1050 } 1050 }
1051 else 1051 else
1052 { 1052 {
1053 if((thisbox->items[z].width-tmp->upx)!=0) 1053 if((thisbox->items[z].width-tmp->upx)!=0)
1054 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx)); 1054 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx));
1055 } 1055 }
1056 if(thisbox->type == DW_HORZ) 1056 if(thisbox->type == DW_HORZ)
1057 { 1057 {
1058 int tmppad = (thisbox->items[z].pad*2)+(tmp->pad*2)+tmp->grouppadx; 1058 int tmppad = (thisbox->items[z].pad*2)+(tmp->pad*2)+tmp->grouppadx;
1059 1059
1060 if((thisbox->items[z].height-tmppad)!=0) 1060 if((thisbox->items[z].height-tmppad)!=0)
1061 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmppad))/((float)(thisbox->items[z].height-tmppad)); 1061 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmppad))/((float)(thisbox->items[z].height-tmppad));
1062 } 1062 }
1063 else 1063 else
1064 { 1064 {
1065 if((thisbox->items[z].height-tmp->upy)!=0) 1065 if((thisbox->items[z].height-tmp->upy)!=0)
1066 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy)); 1066 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy));
1067 } 1067 }
1068 1068
1069 nux = *usedx; nuy = *usedy; 1069 nux = *usedx; nuy = *usedy;
1070 upx = *usedpadx + (tmp->pad*2); upy = *usedpady + (tmp->pad*2); 1070 upx = *usedpadx + (tmp->pad*2); upy = *usedpady + (tmp->pad*2);
1071 } 1071 }
1072 1072
1073 (*depth)++; 1073 (*depth)++;
1074 1074
1075 _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &upx, &upy); 1075 _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &upx, &upy);
1076 1076
1077 (*depth)--; 1077 (*depth)--;
1078 1078
1079 newx = x - nux; 1079 newx = x - nux;
1080 newy = y - nuy; 1080 newy = y - nuy;
1081 1081
1082 tmp->minwidth = thisbox->items[z].width = initialx - newx; 1082 tmp->minwidth = thisbox->items[z].width = initialx - newx;
1083 tmp->minheight = thisbox->items[z].height = initialy - newy; 1083 tmp->minheight = thisbox->items[z].height = initialy - newy;
1084 } 1084 }
1085 } 1085 }
1086 1086
1087 if(pass > 1 && *depth > 0) 1087 if(pass > 1 && *depth > 0)
1088 { 1088 {
1089 if(thisbox->type == DW_VERT) 1089 if(thisbox->type == DW_VERT)
1090 { 1090 {
1091 int tmppad = (thisbox->items[z].pad*2)+(thisbox->parentpad*2)+thisbox->grouppadx; 1091 int tmppad = (thisbox->items[z].pad*2)+(thisbox->parentpad*2)+thisbox->grouppadx;
1092 1092
1093 if((thisbox->minwidth-tmppad) == 0) 1093 if((thisbox->minwidth-tmppad) == 0)
1094 thisbox->items[z].xratio = 1.0; 1094 thisbox->items[z].xratio = 1.0;
1095 else 1095 else
1096 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-tmppad))/((float)(thisbox->minwidth-tmppad)); 1096 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-tmppad))/((float)(thisbox->minwidth-tmppad));
1097 } 1097 }
1098 else 1098 else
1099 { 1099 {
1100 if(thisbox->minwidth-thisbox->upx == 0) 1100 if(thisbox->minwidth-thisbox->upx == 0)
1101 thisbox->items[z].xratio = 1.0; 1101 thisbox->items[z].xratio = 1.0;
1102 else 1102 else
1103 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx)); 1103 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx));
1104 } 1104 }
1105 1105
1106 if(thisbox->type == DW_HORZ) 1106 if(thisbox->type == DW_HORZ)
1107 { 1107 {
1108 int tmppad = (thisbox->items[z].pad*2)+(thisbox->parentpad*2)+thisbox->grouppady; 1108 int tmppad = (thisbox->items[z].pad*2)+(thisbox->parentpad*2)+thisbox->grouppady;
1109 1109
1110 if((thisbox->minheight-tmppad) == 0) 1110 if((thisbox->minheight-tmppad) == 0)
1111 thisbox->items[z].yratio = 1.0; 1111 thisbox->items[z].yratio = 1.0;
1112 else 1112 else
1113 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-tmppad))/((float)(thisbox->minheight-tmppad)); 1113 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-tmppad))/((float)(thisbox->minheight-tmppad));
1114 } 1114 }
1115 else 1115 else
1116 { 1116 {
1117 if(thisbox->minheight-thisbox->upy == 0) 1117 if(thisbox->minheight-thisbox->upy == 0)
1118 thisbox->items[z].yratio = 1.0; 1118 thisbox->items[z].yratio = 1.0;
1119 else 1119 else
1120 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy)); 1120 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy));
1121 } 1121 }
1122 1122
1123 if(thisbox->items[z].type == TYPEBOX) 1123 if(thisbox->items[z].type == TYPEBOX)
1124 { 1124 {
1125 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); 1125 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER);
1126 1126
1127 if(tmp) 1127 if(tmp)
1128 { 1128 {
1129 tmp->parentxratio = thisbox->items[z].xratio; 1129 tmp->parentxratio = thisbox->items[z].xratio;
1130 tmp->parentyratio = thisbox->items[z].yratio; 1130 tmp->parentyratio = thisbox->items[z].yratio;
1131 } 1131 }
1132 } 1132 }
1133 } 1133 }
1134 else 1134 else
1135 { 1135 {
1136 thisbox->items[z].xratio = thisbox->xratio; 1136 thisbox->items[z].xratio = thisbox->xratio;
1137 thisbox->items[z].yratio = thisbox->yratio; 1137 thisbox->items[z].yratio = thisbox->yratio;
1138 } 1138 }
1139 1139
1140 if(thisbox->type == DW_VERT) 1140 if(thisbox->type == DW_VERT)
1141 { 1141 {
1142 int itemwidth = thisbox->items[z].width + (thisbox->items[z].pad*2); 1142 int itemwidth = thisbox->items[z].width + (thisbox->items[z].pad*2);
1143 1143
1144 if(itemwidth > uxmax) 1144 if(itemwidth > uxmax)
1145 uxmax = itemwidth; 1145 uxmax = itemwidth;
1146 if(thisbox->items[z].hsize != SIZEEXPAND) 1146 if(thisbox->items[z].hsize != SIZEEXPAND)
1147 { 1147 {
1148 if(itemwidth > upxmax) 1148 if(itemwidth > upxmax)
1149 upxmax = itemwidth; 1149 upxmax = itemwidth;
1150 } 1150 }
1151 else 1151 else
1152 { 1152 {
1153 if(thisbox->items[z].pad*2 > upxmax) 1153 if(thisbox->items[z].pad*2 > upxmax)
1154 upxmax = thisbox->items[z].pad*2; 1154 upxmax = thisbox->items[z].pad*2;
1155 } 1155 }
1156 } 1156 }
1157 else 1157 else
1158 { 1158 {
1159 if(thisbox->items[z].width == -1) 1159 if(thisbox->items[z].width == -1)
1160 { 1160 {
1161 /* figure out how much space this item requires */ 1161 /* figure out how much space this item requires */
1162 /* thisbox->items[z].width = */ 1162 /* thisbox->items[z].width = */
1163 } 1163 }
1164 else 1164 else
1165 { 1165 {
1166 (*usedx) += thisbox->items[z].width + (thisbox->items[z].pad*2); 1166 (*usedx) += thisbox->items[z].width + (thisbox->items[z].pad*2);
1167 if(thisbox->items[z].hsize != SIZEEXPAND) 1167 if(thisbox->items[z].hsize != SIZEEXPAND)
1168 (*usedpadx) += (thisbox->items[z].pad*2) + thisbox->items[z].width; 1168 (*usedpadx) += (thisbox->items[z].pad*2) + thisbox->items[z].width;
1169 else 1169 else
1170 (*usedpadx) += thisbox->items[z].pad*2; 1170 (*usedpadx) += thisbox->items[z].pad*2;
1171 } 1171 }
1172 } 1172 }
1173 if(thisbox->type == DW_HORZ) 1173 if(thisbox->type == DW_HORZ)
1174 { 1174 {
1175 int itemheight = thisbox->items[z].height + (thisbox->items[z].pad*2); 1175 int itemheight = thisbox->items[z].height + (thisbox->items[z].pad*2);
1176 1176
1177 if(itemheight > uymax) 1177 if(itemheight > uymax)
1178 uymax = itemheight; 1178 uymax = itemheight;
1179 if(thisbox->items[z].vsize != SIZEEXPAND) 1179 if(thisbox->items[z].vsize != SIZEEXPAND)
1180 { 1180 {
1181 if(itemheight > upymax) 1181 if(itemheight > upymax)
1182 upymax = itemheight; 1182 upymax = itemheight;
1183 } 1183 }
1184 else 1184 else
1185 { 1185 {
1186 if(thisbox->items[z].pad*2 > upymax) 1186 if(thisbox->items[z].pad*2 > upymax)
1187 upymax = thisbox->items[z].pad*2; 1187 upymax = thisbox->items[z].pad*2;
1188 } 1188 }
1189 } 1189 }
1190 else 1190 else
1191 { 1191 {
1192 if(thisbox->items[z].height == -1) 1192 if(thisbox->items[z].height == -1)
1193 { 1193 {
1194 /* figure out how much space this item requires */ 1194 /* figure out how much space this item requires */
1195 /* thisbox->items[z].height = */ 1195 /* thisbox->items[z].height = */
1196 } 1196 }
1197 else 1197 else
1198 { 1198 {
1199 (*usedy) += thisbox->items[z].height + (thisbox->items[z].pad*2); 1199 (*usedy) += thisbox->items[z].height + (thisbox->items[z].pad*2);
1200 if(thisbox->items[z].vsize != SIZEEXPAND) 1200 if(thisbox->items[z].vsize != SIZEEXPAND)
1201 (*usedpady) += (thisbox->items[z].pad*2) + thisbox->items[z].height; 1201 (*usedpady) += (thisbox->items[z].pad*2) + thisbox->items[z].height;
1202 else 1202 else
1203 (*usedpady) += thisbox->items[z].pad*2; 1203 (*usedpady) += thisbox->items[z].pad*2;
1204 } 1204 }
1205 } 1205 }
1206 } 1206 }
1207 1207
1208 (*usedx) += uxmax; 1208 (*usedx) += uxmax;
1209 (*usedy) += uymax; 1209 (*usedy) += uymax;
1210 (*usedpadx) += upxmax; 1210 (*usedpadx) += upxmax;
1211 (*usedpady) += upymax; 1211 (*usedpady) += upymax;
1212 1212
1213 currentx += thisbox->pad; 1213 currentx += thisbox->pad;
1214 currenty += thisbox->pad; 1214 currenty += thisbox->pad;
1215 1215
1216 if(thisbox->grouphwnd) 1216 if(thisbox->grouphwnd)
1217 { 1217 {
1218 currentx += 3; 1218 currentx += 3;
1219 currenty += thisbox->grouppady - 3; 1219 currenty += thisbox->grouppady - 3;
1220 } 1220 }
1221 1221
1222 /* The second pass is for expansion and actual placement. */ 1222 /* The second pass is for expansion and actual placement. */
1223 if(pass > 1) 1223 if(pass > 1)
1224 { 1224 {
1225 /* Any SIZEEXPAND items should be set to uxmax/uymax */ 1225 /* Any SIZEEXPAND items should be set to uxmax/uymax */
1226 for(z=0;z<thisbox->count;z++) 1226 for(z=0;z<thisbox->count;z++)
1227 { 1227 {
1228 if(thisbox->items[z].hsize == SIZEEXPAND && thisbox->type == DW_VERT) 1228 if(thisbox->items[z].hsize == SIZEEXPAND && thisbox->type == DW_VERT)
1229 thisbox->items[z].width = uxmax-(thisbox->items[z].pad*2); 1229 thisbox->items[z].width = uxmax-(thisbox->items[z].pad*2);
1230 if(thisbox->items[z].vsize == SIZEEXPAND && thisbox->type == DW_HORZ) 1230 if(thisbox->items[z].vsize == SIZEEXPAND && thisbox->type == DW_HORZ)
1231 thisbox->items[z].height = uymax-(thisbox->items[z].pad*2); 1231 thisbox->items[z].height = uymax-(thisbox->items[z].pad*2);
1232 /* Run this code segment again to finalize the sized after setting uxmax/uymax values. */ 1232 /* Run this code segment again to finalize the sized after setting uxmax/uymax values. */
1233 if(thisbox->items[z].type == TYPEBOX) 1233 if(thisbox->items[z].type == TYPEBOX)
1234 { 1234 {
1235 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); 1235 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER);
1236 1236
1237 if(tmp) 1237 if(tmp)
1238 { 1238 {
1239 if(*depth > 0) 1239 if(*depth > 0)
1240 { 1240 {
1241 float calcval; 1241 float calcval;
1242 1242
1243 if(thisbox->type == DW_VERT) 1243 if(thisbox->type == DW_VERT)
1244 { 1244 {
1245 calcval = (float)(tmp->minwidth-((thisbox->items[z].pad*2)+(thisbox->pad*2))); 1245 calcval = (float)(tmp->minwidth-((thisbox->items[z].pad*2)+(thisbox->pad*2)));
1246 if(calcval == 0.0) 1246 if(calcval == 0.0)
1247 tmp->xratio = thisbox->xratio; 1247 tmp->xratio = thisbox->xratio;
1248 else 1248 else
1249 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/calcval; 1249 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/calcval;
1250 tmp->width = thisbox->items[z].width; 1250 tmp->width = thisbox->items[z].width;
1251 } 1251 }
1252 if(thisbox->type == DW_HORZ) 1252 if(thisbox->type == DW_HORZ)
1253 { 1253 {
1254 calcval = (float)(tmp->minheight-((thisbox->items[z].pad*2)+(thisbox->pad*2))); 1254 calcval = (float)(tmp->minheight-((thisbox->items[z].pad*2)+(thisbox->pad*2)));
1255 if(calcval == 0.0) 1255 if(calcval == 0.0)
1256 tmp->yratio = thisbox->yratio; 1256 tmp->yratio = thisbox->yratio;
1257 else 1257 else
1258 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/calcval; 1258 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/calcval;
1259 tmp->height = thisbox->items[z].height; 1259 tmp->height = thisbox->items[z].height;
1260 } 1260 }
1261 } 1261 }
1262 1262
1263 (*depth)++; 1263 (*depth)++;
1264 1264
1265 _resize_box(tmp, depth, x, y, &nux, &nuy, 3, &nupx, &nupy); 1265 _resize_box(tmp, depth, x, y, &nux, &nuy, 3, &nupx, &nupy);
1266 1266
1267 (*depth)--; 1267 (*depth)--;
1268 1268
1269 } 1269 }
1270 } 1270 }
1271 } 1271 }
1272 1272
1273 for(z=0;z<(thisbox->count);z++) 1273 for(z=0;z<(thisbox->count);z++)
1274 { 1274 {
1275 int height = thisbox->items[z].height; 1275 int height = thisbox->items[z].height;
1276 int width = thisbox->items[z].width; 1276 int width = thisbox->items[z].width;
1277 int pad = thisbox->items[z].pad; 1277 int pad = thisbox->items[z].pad;
1278 HWND handle = thisbox->items[z].hwnd; 1278 HWND handle = thisbox->items[z].hwnd;
1279 int vectorx, vectory; 1279 int vectorx, vectory;
1280 1280
1281 /* When upxmax != pad*2 then ratios are incorrect. */ 1281 /* When upxmax != pad*2 then ratios are incorrect. */
1282 vectorx = (int)((width*thisbox->items[z].xratio)-width); 1282 vectorx = (int)((width*thisbox->items[z].xratio)-width);
1283 vectory = (int)((height*thisbox->items[z].yratio)-height); 1283 vectory = (int)((height*thisbox->items[z].yratio)-height);
1284 1284
1285 if(width > 0 && height > 0) 1285 if(width > 0 && height > 0)
1286 { 1286 {
1287 char tmpbuf[100]; 1287 char tmpbuf[100];
1288 /* This is a hack to fix rounding of the sizing */ 1288 /* This is a hack to fix rounding of the sizing */
1289 if(*depth == 0) 1289 if(*depth == 0)
1290 { 1290 {
1291 vectorx++; 1291 vectorx++;
1292 vectory++; 1292 vectory++;
1293 } 1293 }
1294 1294
1295 /* If this item isn't going to expand... reset the vectors to 0 */ 1295 /* If this item isn't going to expand... reset the vectors to 0 */
1296 if(thisbox->items[z].vsize != SIZEEXPAND) 1296 if(thisbox->items[z].vsize != SIZEEXPAND)
1297 vectory = 0; 1297 vectory = 0;
1298 if(thisbox->items[z].hsize != SIZEEXPAND) 1298 if(thisbox->items[z].hsize != SIZEEXPAND)
1299 vectorx = 0; 1299 vectorx = 0;
1300 1300
1301 WinQueryClassName(handle, 99, tmpbuf); 1301 WinQueryClassName(handle, 99, tmpbuf);
1302 1302
1303 if(strncmp(tmpbuf, "#2", 3)==0) 1303 if(strncmp(tmpbuf, "#2", 3)==0)
1304 { 1304 {
1305 HWND frame = (HWND)dw_window_get_data(handle, "_dw_combo_box"); 1305 HWND frame = (HWND)dw_window_get_data(handle, "_dw_combo_box");
1306 /* Make the combobox big enough to drop down. :) */ 1306 /* Make the combobox big enough to drop down. :) */
1307 WinSetWindowPos(handle, HWND_TOP, 0, -100, 1307 WinSetWindowPos(handle, HWND_TOP, 0, -100,
1308 width + vectorx, (height + vectory) + 100, SWP_MOVE | SWP_SIZE | SWP_ZORDER); 1308 width + vectorx, (height + vectory) + 100, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
1309 _MySetWindowPos(frame, thisbox->hwnd, HWND_TOP, currentx + pad, currenty + pad, 1309 _MySetWindowPos(frame, thisbox->hwnd, HWND_TOP, currentx + pad, currenty + pad,
1310 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER); 1310 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
1311 } 1311 }
1312 else if(strncmp(tmpbuf, "#6", 3)==0) 1312 else if(strncmp(tmpbuf, "#6", 3)==0)
1313 { 1313 {
1314 /* Entryfields on OS/2 have a thick border that isn't on Windows and GTK */ 1314 /* Entryfields on OS/2 have a thick border that isn't on Windows and GTK */
1315 _MySetWindowPos(handle, thisbox->hwnd, HWND_TOP, (currentx + pad) + 3, (currenty + pad) + 3, 1315 _MySetWindowPos(handle, thisbox->hwnd, HWND_TOP, (currentx + pad) + 3, (currenty + pad) + 3,
1316 (width + vectorx) - 6, (height + vectory) - 6, SWP_MOVE | SWP_SIZE | SWP_ZORDER); 1316 (width + vectorx) - 6, (height + vectory) - 6, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
1317 } 1317 }
1318 else if(strncmp(tmpbuf, "#40", 5)==0) 1318 else if(strncmp(tmpbuf, "#40", 5)==0)
1319 { 1319 {
1320 _MySetWindowPos(handle, thisbox->hwnd, HWND_TOP, currentx + pad, currenty + pad, 1320 _MySetWindowPos(handle, thisbox->hwnd, HWND_TOP, currentx + pad, currenty + pad,
1321 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER); 1321 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
1322 _check_resize_notebook(handle); 1322 _check_resize_notebook(handle);
1323 } 1323 }
1324 else if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0) 1324 else if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0)
1325 { 1325 {
1326 /* Then try the bottom or right box */ 1326 /* Then try the bottom or right box */
1327 float *percent = (float *)dw_window_get_data(handle, "_dw_percent"); 1327 float *percent = (float *)dw_window_get_data(handle, "_dw_percent");
1328 int type = (int)dw_window_get_data(handle, "_dw_type"); 1328 int type = (int)dw_window_get_data(handle, "_dw_type");
1329 int cx = width + vectorx; 1329 int cx = width + vectorx;
1330 int cy = height + vectory; 1330 int cy = height + vectory;
1331 1331
1332 _MySetWindowPos(handle, thisbox->hwnd, HWND_TOP, currentx + pad, currenty + pad, 1332 _MySetWindowPos(handle, thisbox->hwnd, HWND_TOP, currentx + pad, currenty + pad,
1333 cx, cy, SWP_MOVE | SWP_SIZE | SWP_ZORDER); 1333 cx, cy, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
1334 1334
1335 if(cx > 0 && cy > 0 && percent) 1335 if(cx > 0 && cy > 0 && percent)
1336 _handle_splitbar_resize(handle, *percent, type, cx, cy); 1336 _handle_splitbar_resize(handle, *percent, type, cx, cy);
1337 } 1337 }
1338 else 1338 else
1339 { 1339 {
1340 _MySetWindowPos(handle, thisbox->hwnd, HWND_TOP, currentx + pad, currenty + pad, 1340 _MySetWindowPos(handle, thisbox->hwnd, HWND_TOP, currentx + pad, currenty + pad,
1341 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER); 1341 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
1342 if(thisbox->items[z].type == TYPEBOX) 1342 if(thisbox->items[z].type == TYPEBOX)
1343 { 1343 {
1344 Box *boxinfo = WinQueryWindowPtr(handle, QWP_USER); 1344 Box *boxinfo = WinQueryWindowPtr(handle, QWP_USER);
1345 1345
1346 if(boxinfo && boxinfo->grouphwnd) 1346 if(boxinfo && boxinfo->grouphwnd)
1347 WinSetWindowPos(boxinfo->grouphwnd, HWND_TOP, 0, 0, 1347 WinSetWindowPos(boxinfo->grouphwnd, HWND_TOP, 0, 0,
1348 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE); 1348 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE);
1349 1349
1350 } 1350 }
1351 1351
1352 } 1352 }
1353 1353
1354 if(thisbox->type == DW_HORZ) 1354 if(thisbox->type == DW_HORZ)
1355 currentx += width + vectorx + (pad * 2); 1355 currentx += width + vectorx + (pad * 2);
1356 if(thisbox->type == DW_VERT) 1356 if(thisbox->type == DW_VERT)
1357 currenty += height + vectory + (pad * 2); 1357 currenty += height + vectory + (pad * 2);
1358 } 1358 }
1359 } 1359 }
1360 } 1360 }
1361 return 0; 1361 return 0;
1362 } 1362 }
1363 1363
1364 void _do_resize(Box *thisbox, int x, int y) 1364 void _do_resize(Box *thisbox, int x, int y)
1365 { 1365 {
1366 if(x != 0 && y != 0) 1366 if(x != 0 && y != 0)
1367 { 1367 {
1368 if(thisbox) 1368 if(thisbox)
1369 { 1369 {
1370 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0; 1370 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0;
1371 1371
1372 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady); 1372 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady);
1373 1373
1374 if(usedx-usedpadx == 0 || usedy-usedpady == 0) 1374 if(usedx-usedpadx == 0 || usedy-usedpady == 0)
1375 return; 1375 return;
1376 1376
1377 thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx)); 1377 thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx));
1378 thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady)); 1378 thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady));
1379 1379
1380 usedx = usedy = usedpadx = usedpady = depth = 0; 1380 usedx = usedy = usedpadx = usedpady = depth = 0;
1381 1381
1382 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady); 1382 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady);
1383 } 1383 }
1384 } 1384 }
1385 } 1385 }
1386 1386
1387 /* This procedure handles WM_QUERYTRACKINFO requests from the frame */ 1387 /* This procedure handles WM_QUERYTRACKINFO requests from the frame */
1388 MRESULT EXPENTRY _sizeproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1388 MRESULT EXPENTRY _sizeproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1389 { 1389 {
1390 PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER); 1390 PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER);
1391 Box *thisbox = NULL; 1391 Box *thisbox = NULL;
1392 HWND box; 1392 HWND box;
1393 1393
1394 box = WinWindowFromID(hWnd, FID_CLIENT); 1394 box = WinWindowFromID(hWnd, FID_CLIENT);
1395 if(box) 1395 if(box)
1396 thisbox = WinQueryWindowPtr(box, QWP_USER); 1396 thisbox = WinQueryWindowPtr(box, QWP_USER);
1397 1397
1398 if(thisbox && !thisbox->titlebar) 1398 if(thisbox && !thisbox->titlebar)
1399 { 1399 {
1400 switch(msg) 1400 switch(msg)
1401 { 1401 {
1402 case WM_QUERYTRACKINFO: 1402 case WM_QUERYTRACKINFO:
1403 { 1403 {
1404 if(blah && *blah) 1404 if(blah && *blah)
1405 { 1405 {
1406 PTRACKINFO ptInfo; 1406 PTRACKINFO ptInfo;
1407 int res; 1407 int res;
1408 PFNWP myfunc = *blah; 1408 PFNWP myfunc = *blah;
1409 res = (int)myfunc(hWnd, msg, mp1, mp2); 1409 res = (int)myfunc(hWnd, msg, mp1, mp2);
1410 1410
1411 ptInfo = (PTRACKINFO)(mp2); 1411 ptInfo = (PTRACKINFO)(mp2);
1412 1412
1413 ptInfo->ptlMinTrackSize.y = 8; 1413 ptInfo->ptlMinTrackSize.y = 8;
1414 ptInfo->ptlMinTrackSize.x = 8; 1414 ptInfo->ptlMinTrackSize.x = 8;
1415 1415
1416 return (MRESULT)res; 1416 return (MRESULT)res;
1417 } 1417 }
1418 } 1418 }
1419 } 1419 }
1420 } 1420 }
1421 1421
1422 if(blah && *blah) 1422 if(blah && *blah)
1423 { 1423 {
1424 PFNWP myfunc = *blah; 1424 PFNWP myfunc = *blah;
1425 return myfunc(hWnd, msg, mp1, mp2); 1425 return myfunc(hWnd, msg, mp1, mp2);
1426 } 1426 }
1427 1427
1428 return WinDefWindowProc(hWnd, msg, mp1, mp2); 1428 return WinDefWindowProc(hWnd, msg, mp1, mp2);
1429 } 1429 }
1430 1430
1431 void _Top(HPS hpsPaint, RECTL rclPaint) 1431 void _Top(HPS hpsPaint, RECTL rclPaint)
1432 { 1432 {
1433 POINTL ptl1, ptl2; 1433 POINTL ptl1, ptl2;
1434 1434
1435 ptl1.x = rclPaint.xLeft; 1435 ptl1.x = rclPaint.xLeft;
1436 ptl2.y = ptl1.y = rclPaint.yTop - 1; 1436 ptl2.y = ptl1.y = rclPaint.yTop - 1;
1437 ptl2.x = rclPaint.xRight - 1; 1437 ptl2.x = rclPaint.xRight - 1;
1438 GpiMove(hpsPaint, &ptl1); 1438 GpiMove(hpsPaint, &ptl1);
1439 GpiLine(hpsPaint, &ptl2); 1439 GpiLine(hpsPaint, &ptl2);
1440 } 1440 }
1441 1441
1442 /* Left hits the bottom */ 1442 /* Left hits the bottom */
1443 void _Left(HPS hpsPaint, RECTL rclPaint) 1443 void _Left(HPS hpsPaint, RECTL rclPaint)
1444 { 1444 {
1445 POINTL ptl1, ptl2; 1445 POINTL ptl1, ptl2;
1446 1446
1447 ptl2.x = ptl1.x = rclPaint.xLeft; 1447 ptl2.x = ptl1.x = rclPaint.xLeft;
1448 ptl1.y = rclPaint.yTop - 1; 1448 ptl1.y = rclPaint.yTop - 1;
1449 ptl2.y = rclPaint.yBottom; 1449 ptl2.y = rclPaint.yBottom;
1450 GpiMove(hpsPaint, &ptl1); 1450 GpiMove(hpsPaint, &ptl1);
1451 GpiLine(hpsPaint, &ptl2); 1451 GpiLine(hpsPaint, &ptl2);
1452 } 1452 }
1453 1453
1454 void _Bottom(HPS hpsPaint, RECTL rclPaint) 1454 void _Bottom(HPS hpsPaint, RECTL rclPaint)
1455 { 1455 {
1456 POINTL ptl1, ptl2; 1456 POINTL ptl1, ptl2;
1457 1457
1458 ptl1.x = rclPaint.xRight - 1; 1458 ptl1.x = rclPaint.xRight - 1;
1459 ptl1.y = ptl2.y = rclPaint.yBottom; 1459 ptl1.y = ptl2.y = rclPaint.yBottom;
1460 ptl2.x = rclPaint.xLeft; 1460 ptl2.x = rclPaint.xLeft;
1461 GpiMove(hpsPaint, &ptl1); 1461 GpiMove(hpsPaint, &ptl1);
1462 GpiLine(hpsPaint, &ptl2); 1462 GpiLine(hpsPaint, &ptl2);
1463 } 1463 }
1464 1464
1465 /* Right hits the top */ 1465 /* Right hits the top */
1466 void _Right(HPS hpsPaint, RECTL rclPaint) 1466 void _Right(HPS hpsPaint, RECTL rclPaint)
1467 { 1467 {
1468 POINTL ptl1, ptl2; 1468 POINTL ptl1, ptl2;
1469 1469
1470 ptl2.x = ptl1.x = rclPaint.xRight - 1; 1470 ptl2.x = ptl1.x = rclPaint.xRight - 1;
1471 ptl1.y = rclPaint.yBottom + 1; 1471 ptl1.y = rclPaint.yBottom + 1;
1472 ptl2.y = rclPaint.yTop - 1; 1472 ptl2.y = rclPaint.yTop - 1;
1473 GpiMove(hpsPaint, &ptl1); 1473 GpiMove(hpsPaint, &ptl1);
1474 GpiLine(hpsPaint, &ptl2); 1474 GpiLine(hpsPaint, &ptl2);
1475 } 1475 }
1476 1476
1477 /* This procedure handles drawing of a status border */ 1477 /* This procedure handles drawing of a status border */
1478 MRESULT EXPENTRY _statusproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1478 MRESULT EXPENTRY _statusproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1479 { 1479 {
1480 PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER); 1480 PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER);
1481 1481
1482 if(msg == WM_MOUSEMOVE && _wndproc(hWnd, msg, mp1, mp2)) 1482 if(msg == WM_MOUSEMOVE && _wndproc(hWnd, msg, mp1, mp2))
1483 return MPFROMSHORT(FALSE); 1483 return MPFROMSHORT(FALSE);
1484 1484
1485 if(blah && *blah) 1485 if(blah && *blah)
1486 { 1486 {
1487 PFNWP myfunc = *blah; 1487 PFNWP myfunc = *blah;
1488 1488
1489 switch(msg) 1489 switch(msg)
1490 { 1490 {
1491 case WM_PAINT: 1491 case WM_PAINT:
1492 { 1492 {
1493 HPS hpsPaint; 1493 HPS hpsPaint;
1494 RECTL rclPaint; 1494 RECTL rclPaint;
1495 char buf[1024]; 1495 char buf[1024];
1496 1496
1497 hpsPaint = WinBeginPaint(hWnd, 0, 0); 1497 hpsPaint = WinBeginPaint(hWnd, 0, 0);
1498 WinQueryWindowRect(hWnd, &rclPaint); 1498 WinQueryWindowRect(hWnd, &rclPaint);
1499 WinFillRect(hpsPaint, &rclPaint, CLR_PALEGRAY); 1499 WinFillRect(hpsPaint, &rclPaint, CLR_PALEGRAY);
1500 1500
1501 GpiSetColor(hpsPaint, CLR_DARKGRAY); 1501 GpiSetColor(hpsPaint, CLR_DARKGRAY);
1502 _Top(hpsPaint, rclPaint); 1502 _Top(hpsPaint, rclPaint);
1503 _Left(hpsPaint, rclPaint); 1503 _Left(hpsPaint, rclPaint);
1504 1504
1505 GpiSetColor(hpsPaint, CLR_WHITE); 1505 GpiSetColor(hpsPaint, CLR_WHITE);
1506 _Right(hpsPaint, rclPaint); 1506 _Right(hpsPaint, rclPaint);
1507 _Bottom(hpsPaint, rclPaint); 1507 _Bottom(hpsPaint, rclPaint);
1508 1508
1509 WinQueryWindowText(hWnd, 1024, buf); 1509 WinQueryWindowText(hWnd, 1024, buf);
1510 rclPaint.xLeft += 3; 1510 rclPaint.xLeft += 3;
1511 rclPaint.xRight--; 1511 rclPaint.xRight--;
1512 rclPaint.yTop--; 1512 rclPaint.yTop--;
1513 rclPaint.yBottom++; 1513 rclPaint.yBottom++;
1514 1514
1515 GpiSetColor(hpsPaint, CLR_BLACK); 1515 GpiSetColor(hpsPaint, CLR_BLACK);
1516 WinDrawText(hpsPaint, -1, buf, &rclPaint, DT_TEXTATTRS, DT_TEXTATTRS, DT_VCENTER | DT_LEFT | DT_TEXTATTRS); 1516 WinDrawText(hpsPaint, -1, buf, &rclPaint, DT_TEXTATTRS, DT_TEXTATTRS, DT_VCENTER | DT_LEFT | DT_TEXTATTRS);
1517 WinEndPaint(hpsPaint); 1517 WinEndPaint(hpsPaint);
1518 1518
1519 return (MRESULT)TRUE; 1519 return (MRESULT)TRUE;
1520 } 1520 }
1521 } 1521 }
1522 return myfunc(hWnd, msg, mp1, mp2); 1522 return myfunc(hWnd, msg, mp1, mp2);
1523 } 1523 }
1524 1524
1525 return WinDefWindowProc(hWnd, msg, mp1, mp2); 1525 return WinDefWindowProc(hWnd, msg, mp1, mp2);
1526 } 1526 }
1527 1527
1528 /* This procedure handles pointer changes */ 1528 /* This procedure handles pointer changes */
1529 MRESULT EXPENTRY _textproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1529 MRESULT EXPENTRY _textproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1530 { 1530 {
1531 PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER); 1531 PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER);
1532 1532
1533 if(msg == WM_MOUSEMOVE &&_wndproc(hWnd, msg, mp1, mp2)) 1533 if(msg == WM_MOUSEMOVE &&_wndproc(hWnd, msg, mp1, mp2))
1534 return MPFROMSHORT(FALSE); 1534 return MPFROMSHORT(FALSE);
1535 1535
1536 if(blah && *blah) 1536 if(blah && *blah)
1537 { 1537 {
1538 PFNWP myfunc = *blah; 1538 PFNWP myfunc = *blah;
1539 1539
1540 return myfunc(hWnd, msg, mp1, mp2); 1540 return myfunc(hWnd, msg, mp1, mp2);
1541 } 1541 }
1542 1542
1543 return WinDefWindowProc(hWnd, msg, mp1, mp2); 1543 return WinDefWindowProc(hWnd, msg, mp1, mp2);
1544 } 1544 }
1545 1545
1546 void _click_default(HWND handle) 1546 void _click_default(HWND handle)
1547 { 1547 {
1548 char tmpbuf[100]; 1548 char tmpbuf[100];
1549 1549
1550 WinQueryClassName(handle, 99, tmpbuf); 1550 WinQueryClassName(handle, 99, tmpbuf);
1551 1551
1552 /* These are the window classes which can 1552 /* These are the window classes which can
1553 * obtain input focus. 1553 * obtain input focus.
1554 */ 1554 */
1555 if(strncmp(tmpbuf, "#3", 3)==0) 1555 if(strncmp(tmpbuf, "#3", 3)==0)
1556 { 1556 {
1557 /* Generate click on default item */ 1557 /* Generate click on default item */
1558 SignalHandler *tmp = Root; 1558 SignalHandler *tmp = Root;
1559 1559
1560 /* Find any callbacks for this function */ 1560 /* Find any callbacks for this function */
1561 while(tmp) 1561 while(tmp)
1562 { 1562 {
1563 if(tmp->message == WM_COMMAND) 1563 if(tmp->message == WM_COMMAND)
1564 { 1564 {
1565 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))tmp->signalfunction; 1565 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))tmp->signalfunction;
1566 1566
1567 /* Make sure it's the right window, and the right ID */ 1567 /* Make sure it's the right window, and the right ID */
1568 if(tmp->window == handle) 1568 if(tmp->window == handle)
1569 { 1569 {
1570 clickfunc(tmp->window, tmp->data); 1570 clickfunc(tmp->window, tmp->data);
1571 tmp = NULL; 1571 tmp = NULL;
1572 } 1572 }
1573 } 1573 }
1574 if(tmp) 1574 if(tmp)
1575 tmp= tmp->next; 1575 tmp= tmp->next;
1576 } 1576 }
1577 } 1577 }
1578 else 1578 else
1579 WinSetFocus(HWND_DESKTOP, handle); 1579 WinSetFocus(HWND_DESKTOP, handle);
1580 } 1580 }
1581 1581
1582 #define ENTRY_CUT 1001 1582 #define ENTRY_CUT 1001
1583 #define ENTRY_COPY 1002 1583 #define ENTRY_COPY 1002
1584 #define ENTRY_PASTE 1003 1584 #define ENTRY_PASTE 1003
1588 /* Originally just intended for entryfields, it now serves as a generic 1588 /* Originally just intended for entryfields, it now serves as a generic
1589 * procedure for handling TAB presses to change input focus on controls. 1589 * procedure for handling TAB presses to change input focus on controls.
1590 */ 1590 */
1591 MRESULT EXPENTRY _entryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1591 MRESULT EXPENTRY _entryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1592 { 1592 {
1593 WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER); 1593 WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER);
1594 PFNWP oldproc = 0; 1594 PFNWP oldproc = 0;
1595 char tmpbuf[100]; 1595 char tmpbuf[100];
1596 1596
1597 if(blah) 1597 if(blah)
1598 oldproc = blah->oldproc; 1598 oldproc = blah->oldproc;
1599 1599
1600 WinQueryClassName(hWnd, 99, tmpbuf); 1600 WinQueryClassName(hWnd, 99, tmpbuf);
1601 1601
1602 /* These are the window classes which should get a menu */ 1602 /* These are the window classes which should get a menu */
1603 if(strncmp(tmpbuf, "#2", 3)==0 || /* Combobox */ 1603 if(strncmp(tmpbuf, "#2", 3)==0 || /* Combobox */
1604 strncmp(tmpbuf, "#6", 3)==0 || /* Entryfield */ 1604 strncmp(tmpbuf, "#6", 3)==0 || /* Entryfield */
1605 strncmp(tmpbuf, "#10", 4)==0 || /* MLE */ 1605 strncmp(tmpbuf, "#10", 4)==0 || /* MLE */
1606 strncmp(tmpbuf, "#32", 4)==0) /* Spinbutton */ 1606 strncmp(tmpbuf, "#32", 4)==0) /* Spinbutton */
1607 { 1607 {
1608 switch(msg) 1608 switch(msg)
1609 { 1609 {
1610 case WM_CONTEXTMENU: 1610 case WM_CONTEXTMENU:
1611 { 1611 {
1612 HMENUI hwndMenu = dw_menu_new(0L); 1612 HMENUI hwndMenu = dw_menu_new(0L);
1613 long x, y; 1613 long x, y;
1614 1614
1615 if(strncmp(tmpbuf, "#10", 4)==0 && !WinSendMsg(hWnd, MLM_QUERYREADONLY, 0, 0)) 1615 if(strncmp(tmpbuf, "#10", 4)==0 && !WinSendMsg(hWnd, MLM_QUERYREADONLY, 0, 0))
1616 { 1616 {
1617 dw_menu_append_item(hwndMenu, "Undo", ENTRY_UNDO, 0L, TRUE, FALSE, 0L); 1617 dw_menu_append_item(hwndMenu, "Undo", ENTRY_UNDO, 0L, TRUE, FALSE, 0L);
1618 dw_menu_append_item(hwndMenu, "", 0L, 0L, TRUE, FALSE, 0L); 1618 dw_menu_append_item(hwndMenu, "", 0L, 0L, TRUE, FALSE, 0L);
1619 } 1619 }
1620 dw_menu_append_item(hwndMenu, "Copy", ENTRY_COPY, 0L, TRUE, FALSE, 0L); 1620 dw_menu_append_item(hwndMenu, "Copy", ENTRY_COPY, 0L, TRUE, FALSE, 0L);
1621 if((strncmp(tmpbuf, "#10", 4)!=0 && !dw_window_get_data(hWnd, "_dw_disabled")) || (strncmp(tmpbuf, "#10", 4)==0 && !WinSendMsg(hWnd, MLM_QUERYREADONLY, 0, 0))) 1621 if((strncmp(tmpbuf, "#10", 4)!=0 && !dw_window_get_data(hWnd, "_dw_disabled")) || (strncmp(tmpbuf, "#10", 4)==0 && !WinSendMsg(hWnd, MLM_QUERYREADONLY, 0, 0)))
1622 { 1622 {
1623 dw_menu_append_item(hwndMenu, "Cut", ENTRY_CUT, 0L, TRUE, FALSE, 0L); 1623 dw_menu_append_item(hwndMenu, "Cut", ENTRY_CUT, 0L, TRUE, FALSE, 0L);
1624 dw_menu_append_item(hwndMenu, "Paste", ENTRY_PASTE, 0L, TRUE, FALSE, 0L); 1624 dw_menu_append_item(hwndMenu, "Paste", ENTRY_PASTE, 0L, TRUE, FALSE, 0L);
1625 } 1625 }
1626 dw_menu_append_item(hwndMenu, "", 0L, 0L, TRUE, FALSE, 0L); 1626 dw_menu_append_item(hwndMenu, "", 0L, 0L, TRUE, FALSE, 0L);
1627 dw_menu_append_item(hwndMenu, "Select All", ENTRY_SALL, 0L, TRUE, FALSE, 0L); 1627 dw_menu_append_item(hwndMenu, "Select All", ENTRY_SALL, 0L, TRUE, FALSE, 0L);
1628 1628
1629 WinSetFocus(HWND_DESKTOP, hWnd); 1629 WinSetFocus(HWND_DESKTOP, hWnd);
1630 dw_pointer_query_pos(&x, &y); 1630 dw_pointer_query_pos(&x, &y);
1631 dw_menu_popup(&hwndMenu, hWnd, x, y); 1631 dw_menu_popup(&hwndMenu, hWnd, x, y);
1632 } 1632 }
1633 break; 1633 break;
1634 case WM_COMMAND: 1634 case WM_COMMAND:
1635 { 1635 {
1636 ULONG command = COMMANDMSG(&msg)->cmd; 1636 ULONG command = COMMANDMSG(&msg)->cmd;
1637 1637
1638 /* MLE */ 1638 /* MLE */
1639 if(strncmp(tmpbuf, "#10", 4)==0) 1639 if(strncmp(tmpbuf, "#10", 4)==0)
1640 { 1640 {
1641 switch(command) 1641 switch(command)
1642 { 1642 {
1643 case ENTRY_CUT: 1643 case ENTRY_CUT:
1644 return WinSendMsg(hWnd, MLM_CUT, 0, 0); 1644 return WinSendMsg(hWnd, MLM_CUT, 0, 0);
1645 case ENTRY_COPY: 1645 case ENTRY_COPY:
1646 return WinSendMsg(hWnd, MLM_COPY, 0, 0); 1646 return WinSendMsg(hWnd, MLM_COPY, 0, 0);
1647 case ENTRY_PASTE: 1647 case ENTRY_PASTE:
1648 return WinSendMsg(hWnd, MLM_PASTE, 0, 0); 1648 return WinSendMsg(hWnd, MLM_PASTE, 0, 0);
1649 case ENTRY_UNDO: 1649 case ENTRY_UNDO:
1650 return WinSendMsg(hWnd, MLM_UNDO, 0, 0); 1650 return WinSendMsg(hWnd, MLM_UNDO, 0, 0);
1651 case ENTRY_SALL: 1651 case ENTRY_SALL:
1652 { 1652 {
1653 ULONG len = (ULONG)WinSendMsg(hWnd, MLM_QUERYTEXTLENGTH, 0, 0); 1653 ULONG len = (ULONG)WinSendMsg(hWnd, MLM_QUERYTEXTLENGTH, 0, 0);
1654 return WinSendMsg(hWnd, MLM_SETSEL, 0, (MPARAM)len); 1654 return WinSendMsg(hWnd, MLM_SETSEL, 0, (MPARAM)len);
1655 } 1655 }
1656 } 1656 }
1657 } 1657 }
1658 else /* Other */ 1658 else /* Other */
1659 { 1659 {
1660 HWND handle = hWnd; 1660 HWND handle = hWnd;
1661 1661
1662 /* Get the entryfield handle from multi window controls */ 1662 /* Get the entryfield handle from multi window controls */
1663 if(strncmp(tmpbuf, "#2", 3)==0) 1663 if(strncmp(tmpbuf, "#2", 3)==0)
1664 handle = WinWindowFromID(hWnd, 667); 1664 handle = WinWindowFromID(hWnd, 667);
1665 1665
1666 if(handle) 1666 if(handle)
1667 { 1667 {
1668 switch(command) 1668 switch(command)
1669 { 1669 {
1670 case ENTRY_CUT: 1670 case ENTRY_CUT:
1671 return WinSendMsg(handle, EM_CUT, 0, 0); 1671 return WinSendMsg(handle, EM_CUT, 0, 0);
1672 case ENTRY_COPY: 1672 case ENTRY_COPY:
1673 return WinSendMsg(handle, EM_COPY, 0, 0); 1673 return WinSendMsg(handle, EM_COPY, 0, 0);
1674 case ENTRY_PASTE: 1674 case ENTRY_PASTE:
1675 return WinSendMsg(handle, EM_PASTE, 0, 0); 1675 return WinSendMsg(handle, EM_PASTE, 0, 0);
1676 case ENTRY_SALL: 1676 case ENTRY_SALL:
1677 { 1677 {
1678 LONG len = WinQueryWindowTextLength(hWnd); 1678 LONG len = WinQueryWindowTextLength(hWnd);
1679 return WinSendMsg(hWnd, EM_SETSEL, MPFROM2SHORT(0, (SHORT)len), 0); 1679 return WinSendMsg(hWnd, EM_SETSEL, MPFROM2SHORT(0, (SHORT)len), 0);
1680 } 1680 }
1681 } 1681 }
1682 } 1682 }
1683 } 1683 }
1684 } 1684 }
1685 break; 1685 break;
1686 } 1686 }
1687 } 1687 }
1688 1688
1689 switch(msg) 1689 switch(msg)
1690 { 1690 {
1691 case WM_BUTTON1DOWN: 1691 case WM_BUTTON1DOWN:
1692 case WM_BUTTON2DOWN: 1692 case WM_BUTTON2DOWN:
1693 case WM_BUTTON3DOWN: 1693 case WM_BUTTON3DOWN:
1694 { 1694 {
1695 if(strncmp(tmpbuf, "#32", 4)==0) 1695 if(strncmp(tmpbuf, "#32", 4)==0)
1696 _run_event(hWnd, WM_SETFOCUS, (MPARAM)FALSE, (MPARAM)TRUE); 1696 _run_event(hWnd, WM_SETFOCUS, (MPARAM)FALSE, (MPARAM)TRUE);
1697 } 1697 }
1698 break; 1698 break;
1699 case WM_CONTROL: 1699 case WM_CONTROL:
1700 { 1700 {
1701 if(strncmp(tmpbuf, "#38", 4)==0) 1701 if(strncmp(tmpbuf, "#38", 4)==0)
1702 _run_event(hWnd, msg, mp1, mp2); 1702 _run_event(hWnd, msg, mp1, mp2);
1703 } 1703 }
1704 break; 1704 break;
1705 case WM_SETFOCUS: 1705 case WM_SETFOCUS:
1706 _run_event(hWnd, msg, mp1, mp2); 1706 _run_event(hWnd, msg, mp1, mp2);
1707 break; 1707 break;
1708 case WM_CHAR: 1708 case WM_CHAR:
1709 if(_run_event(hWnd, msg, mp1, mp2) == (MRESULT)TRUE) 1709 if(_run_event(hWnd, msg, mp1, mp2) == (MRESULT)TRUE)
1710 return (MRESULT)TRUE; 1710 return (MRESULT)TRUE;
1711 if(SHORT1FROMMP(mp2) == '\t') 1711 if(SHORT1FROMMP(mp2) == '\t')
1712 { 1712 {
1713 if(CHARMSG(&msg)->fs & KC_SHIFT) 1713 if(CHARMSG(&msg)->fs & KC_SHIFT)
1714 _shift_focus_back(hWnd); 1714 _shift_focus_back(hWnd);
1715 else 1715 else
1716 _shift_focus(hWnd); 1716 _shift_focus(hWnd);
1717 return FALSE; 1717 return FALSE;
1718 } 1718 }
1719 else if(SHORT1FROMMP(mp2) == '\r' && blah && blah->clickdefault) 1719 else if(SHORT1FROMMP(mp2) == '\r' && blah && blah->clickdefault)
1720 _click_default(blah->clickdefault); 1720 _click_default(blah->clickdefault);
1721 /* When you hit escape we get this value and the 1721 /* When you hit escape we get this value and the
1722 * window hangs for reasons unknown. (in an MLE) 1722 * window hangs for reasons unknown. (in an MLE)
1723 */ 1723 */
1724 else if(SHORT1FROMMP(mp2) == 283) 1724 else if(SHORT1FROMMP(mp2) == 283)
1725 return (MRESULT)TRUE; 1725 return (MRESULT)TRUE;
1726 1726
1727 break; 1727 break;
1728 case WM_SIZE: 1728 case WM_SIZE:
1729 { 1729 {
1730 /* If it's a slider... make sure it shows the correct value */ 1730 /* If it's a slider... make sure it shows the correct value */
1731 if(strncmp(tmpbuf, "#38", 4)==0) 1731 if(strncmp(tmpbuf, "#38", 4)==0)
1732 WinPostMsg(hWnd, WM_USER+7, 0, 0); 1732 WinPostMsg(hWnd, WM_USER+7, 0, 0);
1733 } 1733 }
1734 break; 1734 break;
1735 case WM_USER+7: 1735 case WM_USER+7:
1736 { 1736 {
1737 int pos = (int)dw_window_get_data(hWnd, "_dw_slider_value"); 1737 int pos = (int)dw_window_get_data(hWnd, "_dw_slider_value");
1738 WinSendMsg(hWnd, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), (MPARAM)pos); 1738 WinSendMsg(hWnd, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), (MPARAM)pos);
1739 } 1739 }
1740 break; 1740 break;
1741 case WM_MOUSEMOVE: 1741 case WM_MOUSEMOVE:
1742 if(_wndproc(hWnd, msg, mp1, mp2)) 1742 if(_wndproc(hWnd, msg, mp1, mp2))
1743 return MPFROMSHORT(FALSE); 1743 return MPFROMSHORT(FALSE);
1744 break; 1744 break;
1745 } 1745 }
1746 1746
1747 if(oldproc) 1747 if(oldproc)
1748 return oldproc(hWnd, msg, mp1, mp2); 1748 return oldproc(hWnd, msg, mp1, mp2);
1749 1749
1750 return WinDefWindowProc(hWnd, msg, mp1, mp2); 1750 return WinDefWindowProc(hWnd, msg, mp1, mp2);
1751 } 1751 }
1752 1752
1753 /* Deal with combobox specifics and enhancements */ 1753 /* Deal with combobox specifics and enhancements */
1754 MRESULT EXPENTRY _comboentryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1754 MRESULT EXPENTRY _comboentryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1755 { 1755 {
1756 WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER); 1756 WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER);
1757 1757
1758 switch(msg) 1758 switch(msg)
1759 { 1759 {
1760 case WM_MOUSEMOVE: 1760 case WM_MOUSEMOVE:
1761 if(_wndproc(hWnd, msg, mp1, mp2)) 1761 if(_wndproc(hWnd, msg, mp1, mp2))
1762 return MPFROMSHORT(FALSE); 1762 return MPFROMSHORT(FALSE);
1763 break; 1763 break;
1764 case WM_CONTEXTMENU: 1764 case WM_CONTEXTMENU:
1765 case WM_COMMAND: 1765 case WM_COMMAND:
1766 return _entryproc(hWnd, msg, mp1, mp2); 1766 return _entryproc(hWnd, msg, mp1, mp2);
1767 case WM_SETFOCUS: 1767 case WM_SETFOCUS:
1768 _run_event(hWnd, msg, mp1, mp2); 1768 _run_event(hWnd, msg, mp1, mp2);
1769 break; 1769 break;
1770 case WM_CHAR: 1770 case WM_CHAR:
1771 if(_run_event(hWnd, msg, mp1, mp2) == (MRESULT)TRUE) 1771 if(_run_event(hWnd, msg, mp1, mp2) == (MRESULT)TRUE)
1772 return (MRESULT)TRUE; 1772 return (MRESULT)TRUE;
1773 /* A Similar problem to the MLE, if ESC just return */ 1773 /* A Similar problem to the MLE, if ESC just return */
1774 if(SHORT1FROMMP(mp2) == 283) 1774 if(SHORT1FROMMP(mp2) == 283)
1775 return (MRESULT)TRUE; 1775 return (MRESULT)TRUE;
1776 break; 1776 break;
1777 } 1777 }
1778 1778
1779 if(blah && blah->oldproc) 1779 if(blah && blah->oldproc)
1780 return blah->oldproc(hWnd, msg, mp1, mp2); 1780 return blah->oldproc(hWnd, msg, mp1, mp2);
1781 1781
1782 return WinDefWindowProc(hWnd, msg, mp1, mp2); 1782 return WinDefWindowProc(hWnd, msg, mp1, mp2);
1783 } 1783 }
1784 1784
1785 /* Enhance the standard OS/2 MLE control */ 1785 /* Enhance the standard OS/2 MLE control */
1786 MRESULT EXPENTRY _mleproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1786 MRESULT EXPENTRY _mleproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1787 { 1787 {
1788 switch(msg) 1788 switch(msg)
1789 { 1789 {
1790 case WM_VSCROLL: 1790 case WM_VSCROLL:
1791 if(SHORT2FROMMP(mp2) == SB_SLIDERTRACK) 1791 if(SHORT2FROMMP(mp2) == SB_SLIDERTRACK)
1792 { 1792 {
1793 USHORT pos = SHORT1FROMMP(mp2); 1793 USHORT pos = SHORT1FROMMP(mp2);
1794 1794
1795 WinSendMsg(hWnd, msg, mp1, MPFROM2SHORT(pos, SB_SLIDERPOSITION)); 1795 WinSendMsg(hWnd, msg, mp1, MPFROM2SHORT(pos, SB_SLIDERPOSITION));
1796 } 1796 }
1797 break; 1797 break;
1798 } 1798 }
1799 return _entryproc(hWnd, msg, mp1, mp2); 1799 return _entryproc(hWnd, msg, mp1, mp2);
1800 } 1800 }
1801 1801
1802 /* Handle special messages for the spinbutton's entryfield */ 1802 /* Handle special messages for the spinbutton's entryfield */
1803 MRESULT EXPENTRY _spinentryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1803 MRESULT EXPENTRY _spinentryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1804 { 1804 {
1805 WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER); 1805 WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER);
1806 PFNWP oldproc = 0; 1806 PFNWP oldproc = 0;
1807 1807
1808 if(blah) 1808 if(blah)
1809 oldproc = blah->oldproc; 1809 oldproc = blah->oldproc;
1810 1810
1811 switch(msg) 1811 switch(msg)
1812 { 1812 {
1813 case WM_MOUSEMOVE: 1813 case WM_MOUSEMOVE:
1814 if(_wndproc(hWnd, msg, mp1, mp2)) 1814 if(_wndproc(hWnd, msg, mp1, mp2))
1815 return MPFROMSHORT(FALSE); 1815 return MPFROMSHORT(FALSE);
1816 break; 1816 break;
1817 case WM_CONTEXTMENU: 1817 case WM_CONTEXTMENU:
1818 case WM_COMMAND: 1818 case WM_COMMAND:
1819 return _entryproc(hWnd, msg, mp1, mp2); 1819 return _entryproc(hWnd, msg, mp1, mp2);
1820 } 1820 }
1821 1821
1822 if(oldproc) 1822 if(oldproc)
1823 return oldproc(hWnd, msg, mp1, mp2); 1823 return oldproc(hWnd, msg, mp1, mp2);
1824 1824
1825 return WinDefWindowProc(hWnd, msg, mp1, mp2); 1825 return WinDefWindowProc(hWnd, msg, mp1, mp2);
1826 } 1826 }
1827 1827
1828 int _dw_int_pos(HWND hwnd) 1828 int _dw_int_pos(HWND hwnd)
1829 { 1829 {
1830 int pos = (int)dw_window_get_data(hwnd, "_dw_percent_value"); 1830 int pos = (int)dw_window_get_data(hwnd, "_dw_percent_value");
1831 int range = _dw_percent_get_range(hwnd); 1831 int range = _dw_percent_get_range(hwnd);
1832 float fpos = (float)pos; 1832 float fpos = (float)pos;
1833 float frange = (float)range; 1833 float frange = (float)range;
1834 float fnew = (fpos/1000.0)*frange; 1834 float fnew = (fpos/1000.0)*frange;
1835 return (int)fnew; 1835 return (int)fnew;
1836 } 1836 }
1837 1837
1838 void _dw_int_set(HWND hwnd, int pos) 1838 void _dw_int_set(HWND hwnd, int pos)
1839 { 1839 {
1840 int inew, range = _dw_percent_get_range(hwnd); 1840 int inew, range = _dw_percent_get_range(hwnd);
1841 if(range) 1841 if(range)
1842 { 1842 {
1843 float fpos = (float)pos; 1843 float fpos = (float)pos;
1844 float frange = (float)range; 1844 float frange = (float)range;
1845 float fnew = (fpos/frange)*1000.0; 1845 float fnew = (fpos/frange)*1000.0;
1846 inew = (int)fnew; 1846 inew = (int)fnew;
1847 dw_window_set_data(hwnd, "_dw_percent_value", (void *)inew); 1847 dw_window_set_data(hwnd, "_dw_percent_value", (void *)inew);
1848 } 1848 }
1849 } 1849 }
1850 1850
1851 /* Handle size changes in the percent class */ 1851 /* Handle size changes in the percent class */
1852 MRESULT EXPENTRY _percentproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1852 MRESULT EXPENTRY _percentproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1853 { 1853 {
1854 WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER); 1854 WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER);
1855 PFNWP oldproc = 0; 1855 PFNWP oldproc = 0;
1856 1856
1857 if(blah) 1857 if(blah)
1858 oldproc = blah->oldproc; 1858 oldproc = blah->oldproc;
1859 1859
1860 switch(msg) 1860 switch(msg)
1861 { 1861 {
1862 case WM_MOUSEMOVE: 1862 case WM_MOUSEMOVE:
1863 if(_wndproc(hWnd, msg, mp1, mp2)) 1863 if(_wndproc(hWnd, msg, mp1, mp2))
1864 return MPFROMSHORT(FALSE); 1864 return MPFROMSHORT(FALSE);
1865 break; 1865 break;
1866 case WM_SIZE: 1866 case WM_SIZE:
1867 WinPostMsg(hWnd, WM_USER+7, 0, 0); 1867 WinPostMsg(hWnd, WM_USER+7, 0, 0);
1868 break; 1868 break;
1869 case WM_USER+7: 1869 case WM_USER+7:
1870 WinSendMsg(hWnd, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)_dw_int_pos(hWnd)); 1870 WinSendMsg(hWnd, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)_dw_int_pos(hWnd));
1871 break; 1871 break;
1872 } 1872 }
1873 1873
1874 if(oldproc) 1874 if(oldproc)
1875 return oldproc(hWnd, msg, mp1, mp2); 1875 return oldproc(hWnd, msg, mp1, mp2);
1876 1876
1877 return WinDefWindowProc(hWnd, msg, mp1, mp2); 1877 return WinDefWindowProc(hWnd, msg, mp1, mp2);
1878 } 1878 }
1879 1879
1880 /* Handle correct painting of a combobox with the WS_CLIPCHILDREN 1880 /* Handle correct painting of a combobox with the WS_CLIPCHILDREN
1881 * flag enabled, and also handle TABs to switch input focus. 1881 * flag enabled, and also handle TABs to switch input focus.
1882 */ 1882 */
1883 MRESULT EXPENTRY _comboproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1883 MRESULT EXPENTRY _comboproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1884 { 1884 {
1885 WindowData *blah = WinQueryWindowPtr(hWnd, QWP_USER); 1885 WindowData *blah = WinQueryWindowPtr(hWnd, QWP_USER);
1886 PFNWP oldproc = 0; 1886 PFNWP oldproc = 0;
1887 1887
1888 if(blah) 1888 if(blah)
1889 oldproc = blah->oldproc; 1889 oldproc = blah->oldproc;
1890 1890
1891 switch(msg) 1891 switch(msg)
1892 { 1892 {
1893 case WM_MOUSEMOVE: 1893 case WM_MOUSEMOVE:
1894 if(_wndproc(hWnd, msg, mp1, mp2)) 1894 if(_wndproc(hWnd, msg, mp1, mp2))
1895 return MPFROMSHORT(FALSE); 1895 return MPFROMSHORT(FALSE);
1896 break; 1896 break;
1897 case WM_CHAR: 1897 case WM_CHAR:
1898 if(SHORT1FROMMP(mp2) == '\t') 1898 if(SHORT1FROMMP(mp2) == '\t')
1899 { 1899 {
1900 if(CHARMSG(&msg)->fs & KC_SHIFT) 1900 if(CHARMSG(&msg)->fs & KC_SHIFT)
1901 _shift_focus_back(hWnd); 1901 _shift_focus_back(hWnd);
1902 else 1902 else
1903 _shift_focus(hWnd); 1903 _shift_focus(hWnd);
1904 return FALSE; 1904 return FALSE;
1905 } 1905 }
1906 else if(SHORT1FROMMP(mp2) == '\r' && blah && blah->clickdefault) 1906 else if(SHORT1FROMMP(mp2) == '\r' && blah && blah->clickdefault)
1907 _click_default(blah->clickdefault); 1907 _click_default(blah->clickdefault);
1908 break; 1908 break;
1909 case WM_BUTTON1DBLCLK: 1909 case WM_BUTTON1DBLCLK:
1910 case WM_BUTTON2DBLCLK: 1910 case WM_BUTTON2DBLCLK:
1911 case WM_BUTTON3DBLCLK: 1911 case WM_BUTTON3DBLCLK:
1912 if(dw_window_get_data(hWnd, "_dw_disabled")) 1912 if(dw_window_get_data(hWnd, "_dw_disabled"))
1913 return (MRESULT)TRUE; 1913 return (MRESULT)TRUE;
1914 break; 1914 break;
1915 case WM_BUTTON1DOWN: 1915 case WM_BUTTON1DOWN:
1916 case WM_BUTTON2DOWN: 1916 case WM_BUTTON2DOWN:
1917 case WM_BUTTON3DOWN: 1917 case WM_BUTTON3DOWN:
1918 if(_run_event(hWnd, msg, mp1, mp2) == (MRESULT)TRUE) 1918 if(_run_event(hWnd, msg, mp1, mp2) == (MRESULT)TRUE)
1919 return (MRESULT)TRUE; 1919 return (MRESULT)TRUE;
1920 _run_event(hWnd, WM_SETFOCUS, (MPARAM)FALSE, (MPARAM)TRUE); 1920 _run_event(hWnd, WM_SETFOCUS, (MPARAM)FALSE, (MPARAM)TRUE);
1921 break; 1921 break;
1922 case WM_SETFOCUS: 1922 case WM_SETFOCUS:
1923 _run_event(hWnd, msg, mp1, mp2); 1923 _run_event(hWnd, msg, mp1, mp2);
1924 break; 1924 break;
1925 case WM_PAINT: 1925 case WM_PAINT:
1926 { 1926 {
1927 HWND entry, frame = (HWND)dw_window_get_data(hWnd, "_dw_combo_box"), parent = WinQueryWindow(frame, QW_PARENT); 1927 HWND entry, frame = (HWND)dw_window_get_data(hWnd, "_dw_combo_box"), parent = WinQueryWindow(frame, QW_PARENT);
1928 HPS hpsPaint; 1928 HPS hpsPaint;
1929 POINTL ptl; 1929 POINTL ptl;
1930 unsigned long width, height, thumbheight = 0; 1930 unsigned long width, height, thumbheight = 0;
1931 ULONG color; 1931 ULONG color;
1932 1932
1933 if((entry = (HWND)dw_window_get_data(hWnd, "_dw_comboentry")) != NULLHANDLE) 1933 if((entry = (HWND)dw_window_get_data(hWnd, "_dw_comboentry")) != NULLHANDLE)
1934 dw_window_get_pos_size(entry, 0, 0, 0, &thumbheight); 1934 dw_window_get_pos_size(entry, 0, 0, 0, &thumbheight);
1935 1935
1936 if(!thumbheight) 1936 if(!thumbheight)
1937 thumbheight = WinQuerySysValue(HWND_DESKTOP, SV_CYVSCROLLARROW); 1937 thumbheight = WinQuerySysValue(HWND_DESKTOP, SV_CYVSCROLLARROW);
1938 1938
1939 /* Add 6 because it has a thick border like the entryfield */ 1939 /* Add 6 because it has a thick border like the entryfield */
1940 thumbheight += 6; 1940 thumbheight += 6;
1941 1941
1942 color = (ULONG)dw_window_get_data(parent, "_dw_fore"); 1942 color = (ULONG)dw_window_get_data(parent, "_dw_fore");
1943 dw_window_get_pos_size(hWnd, 0, 0, &width, &height); 1943 dw_window_get_pos_size(hWnd, 0, 0, &width, &height);
1944 1944
1945 if(height > thumbheight) 1945 if(height > thumbheight)
1946 { 1946 {
1947 hpsPaint = WinGetPS(hWnd); 1947 hpsPaint = WinGetPS(hWnd);
1948 if(color) 1948 if(color)
1949 GpiSetColor(hpsPaint, _internal_color(color-1)); 1949 GpiSetColor(hpsPaint, _internal_color(color-1));
1950 else 1950 else
1951 GpiSetColor(hpsPaint, CLR_PALEGRAY); 1951 GpiSetColor(hpsPaint, CLR_PALEGRAY);
1952 1952
1953 ptl.x = ptl.y = 0; 1953 ptl.x = ptl.y = 0;
1954 GpiMove(hpsPaint, &ptl); 1954 GpiMove(hpsPaint, &ptl);
1955 1955
1956 ptl.x = width; 1956 ptl.x = width;
1957 ptl.y = height - thumbheight; 1957 ptl.y = height - thumbheight;
1958 GpiBox(hpsPaint, DRO_FILL, &ptl, 0, 0); 1958 GpiBox(hpsPaint, DRO_FILL, &ptl, 0, 0);
1959 1959
1960 WinReleasePS(hpsPaint); 1960 WinReleasePS(hpsPaint);
1961 } 1961 }
1962 } 1962 }
1963 break; 1963 break;
1964 } 1964 }
1965 if(oldproc) 1965 if(oldproc)
1966 return oldproc(hWnd, msg, mp1, mp2); 1966 return oldproc(hWnd, msg, mp1, mp2);
1967 1967
1968 return WinDefWindowProc(hWnd, msg, mp1, mp2); 1968 return WinDefWindowProc(hWnd, msg, mp1, mp2);
1969 } 1969 }
1970 1970
1971 void _GetPPFont(HWND hwnd, char *buff) 1971 void _GetPPFont(HWND hwnd, char *buff)
1972 { 1972 {
1973 ULONG AttrFound; 1973 ULONG AttrFound;
1988 } 1988 }
1989 } 1989 }
1990 1990
1991 int _HandleScroller(HWND handle, int pos, int which) 1991 int _HandleScroller(HWND handle, int pos, int which)
1992 { 1992 {
1993 MPARAM res; 1993 MPARAM res;
1994 int min, max, page; 1994 int min, max, page;
1995 1995
1996 if(which == SB_SLIDERTRACK) 1996 if(which == SB_SLIDERTRACK)
1997 return pos; 1997 return pos;
1998 1998
1999 pos = dw_scrollbar_get_pos(handle); 1999 pos = dw_scrollbar_get_pos(handle);
2000 res = WinSendMsg(handle, SBM_QUERYRANGE, 0, 0); 2000 res = WinSendMsg(handle, SBM_QUERYRANGE, 0, 0);
2001 2001
2002 min = SHORT1FROMMP(res); 2002 min = SHORT1FROMMP(res);
2003 max = SHORT2FROMMP(res); 2003 max = SHORT2FROMMP(res);
2004 page = (int)dw_window_get_data(handle, "_dw_scrollbar_visible"); 2004 page = (int)dw_window_get_data(handle, "_dw_scrollbar_visible");
2005 2005
2006 switch(which) 2006 switch(which)
2007 { 2007 {
2008 case SB_LINEUP: 2008 case SB_LINEUP:
2009 pos = pos - 1; 2009 pos = pos - 1;
2010 if(pos < min) 2010 if(pos < min)
2011 pos = min; 2011 pos = min;
2012 dw_scrollbar_set_pos(handle, pos); 2012 dw_scrollbar_set_pos(handle, pos);
2013 return pos; 2013 return pos;
2014 case SB_LINEDOWN: 2014 case SB_LINEDOWN:
2015 pos = pos + 1; 2015 pos = pos + 1;
2016 if(pos > max) 2016 if(pos > max)
2017 pos = max; 2017 pos = max;
2018 dw_scrollbar_set_pos(handle, pos); 2018 dw_scrollbar_set_pos(handle, pos);
2019 return pos; 2019 return pos;
2020 case SB_PAGEUP: 2020 case SB_PAGEUP:
2021 pos = pos - page; 2021 pos = pos - page;
2022 if(pos < min) 2022 if(pos < min)
2023 pos = min; 2023 pos = min;
2024 dw_scrollbar_set_pos(handle, pos); 2024 dw_scrollbar_set_pos(handle, pos);
2025 return pos; 2025 return pos;
2026 case SB_PAGEDOWN: 2026 case SB_PAGEDOWN:
2027 pos = pos + page; 2027 pos = pos + page;
2028 if(pos > max) 2028 if(pos > max)
2029 pos = max; 2029 pos = max;
2030 dw_scrollbar_set_pos(handle, pos); 2030 dw_scrollbar_set_pos(handle, pos);
2031 return pos; 2031 return pos;
2032 } 2032 }
2033 return -1; 2033 return -1;
2034 } 2034 }
2035 2035
2036 void _clear_emphasis(void) 2036 void _clear_emphasis(void)
2037 { 2037 {
2038 if(hwndEmph && WinIsWindow(dwhab, hwndEmph) && pCoreEmph) 2038 if(hwndEmph && WinIsWindow(dwhab, hwndEmph) && pCoreEmph)
2039 WinSendMsg(hwndEmph, CM_SETRECORDEMPHASIS, pCoreEmph, MPFROM2SHORT(FALSE, CRA_SOURCE)); 2039 WinSendMsg(hwndEmph, CM_SETRECORDEMPHASIS, pCoreEmph, MPFROM2SHORT(FALSE, CRA_SOURCE));
2040 hwndEmph = NULLHANDLE; 2040 hwndEmph = NULLHANDLE;
2041 pCoreEmph = NULL; 2041 pCoreEmph = NULL;
2042 } 2042 }
2043 2043
2044 /* Find the desktop window handle */ 2044 /* Find the desktop window handle */
2045 HWND _menu_owner(HWND handle) 2045 HWND _menu_owner(HWND handle)
2046 { 2046 {
2047 HWND menuowner = NULLHANDLE, lastowner = (HWND)dw_window_get_data(handle, "_dw_owner"); 2047 HWND menuowner = NULLHANDLE, lastowner = (HWND)dw_window_get_data(handle, "_dw_owner");
2048 int menubar = (int)dw_window_get_data(handle, "_dw_menubar"); 2048 int menubar = (int)dw_window_get_data(handle, "_dw_menubar");
2049 2049
2050 /* Find the toplevel window */ 2050 /* Find the toplevel window */
2051 while(!menubar && (menuowner = (HWND)dw_window_get_data(lastowner, "_dw_owner")) != NULLHANDLE) 2051 while(!menubar && (menuowner = (HWND)dw_window_get_data(lastowner, "_dw_owner")) != NULLHANDLE)
2052 { 2052 {
2053 menubar = (int)dw_window_get_data(lastowner, "_dw_menubar"); 2053 menubar = (int)dw_window_get_data(lastowner, "_dw_menubar");
2054 lastowner = menuowner; 2054 lastowner = menuowner;
2055 } 2055 }
2056 if(menuowner && menubar) 2056 if(menuowner && menubar)
2057 { 2057 {
2058 HWND client = WinWindowFromID(menuowner, FID_CLIENT); 2058 HWND client = WinWindowFromID(menuowner, FID_CLIENT);
2059 2059
2060 return client ? client : menuowner; 2060 return client ? client : menuowner;
2061 } 2061 }
2062 return NULLHANDLE; 2062 return NULLHANDLE;
2063 } 2063 }
2064 2064
2065 MRESULT EXPENTRY _run_event(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) 2065 MRESULT EXPENTRY _run_event(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
2066 { 2066 {
2067 int result = -1; 2067 int result = -1;
2068 SignalHandler *tmp = Root; 2068 SignalHandler *tmp = Root;
2069 ULONG origmsg = msg; 2069 ULONG origmsg = msg;
2070 2070
2071 if(msg == WM_BUTTON2DOWN || msg == WM_BUTTON3DOWN) 2071 if(msg == WM_BUTTON2DOWN || msg == WM_BUTTON3DOWN)
2072 msg = WM_BUTTON1DOWN; 2072 msg = WM_BUTTON1DOWN;
2073 if(msg == WM_BUTTON2UP || msg == WM_BUTTON3UP) 2073 if(msg == WM_BUTTON2UP || msg == WM_BUTTON3UP)
2074 msg = WM_BUTTON1UP; 2074 msg = WM_BUTTON1UP;
2075 if(msg == WM_VSCROLL || msg == WM_HSCROLL) 2075 if(msg == WM_VSCROLL || msg == WM_HSCROLL)
2076 msg = WM_CONTROL; 2076 msg = WM_CONTROL;
2077 2077
2078 /* Find any callbacks for this function */ 2078 /* Find any callbacks for this function */
2079 while(tmp) 2079 while(tmp)
2080 { 2080 {
2081 if(tmp->message == msg || msg == WM_CONTROL || tmp->message == WM_USER+1) 2081 if(tmp->message == msg || msg == WM_CONTROL || tmp->message == WM_USER+1)
2082 { 2082 {
2083 switch(msg) 2083 switch(msg)
2084 { 2084 {
2085 case WM_SETFOCUS: 2085 case WM_SETFOCUS:
2086 { 2086 {
2087 if((mp2 && tmp->message == WM_SETFOCUS) || (!mp2 && tmp->message == WM_USER+1)) 2087 if((mp2 && tmp->message == WM_SETFOCUS) || (!mp2 && tmp->message == WM_USER+1))
2088 { 2088 {
2089 int (* API setfocusfunc)(HWND, void *) = (int (* API)(HWND, void *))tmp->signalfunction; 2089 int (* API setfocusfunc)(HWND, void *) = (int (* API)(HWND, void *))tmp->signalfunction;
2090 2090
2091 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd) 2091 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd)
2092 { 2092 {
2093 result = setfocusfunc(tmp->window, tmp->data); 2093 result = setfocusfunc(tmp->window, tmp->data);
2094 tmp = NULL; 2094 tmp = NULL;
2095 } 2095 }
2096 } 2096 }
2097 } 2097 }
2098 break; 2098 break;
2099 case WM_TIMER: 2099 case WM_TIMER:
2100 { 2100 {
2101 int (* API timerfunc)(void *) = (int (* API)(void *))tmp->signalfunction; 2101 int (* API timerfunc)(void *) = (int (* API)(void *))tmp->signalfunction;
2102 if(tmp->id == (int)mp1) 2102 if(tmp->id == (int)mp1)
2103 { 2103 {
2104 if(!timerfunc(tmp->data)) 2104 if(!timerfunc(tmp->data))
2105 dw_timer_disconnect(tmp->id); 2105 dw_timer_disconnect(tmp->id);
2106 tmp = NULL; 2106 tmp = NULL;
2107 } 2107 }
2108 result = 0; 2108 result = 0;
2109 } 2109 }
2110 break; 2110 break;
2111 case WM_SIZE: 2111 case WM_SIZE:
2112 { 2112 {
2113 int (* API sizefunc)(HWND, int, int, void *) = (int (* API)(HWND, int, int, void *))tmp->signalfunction; 2113 int (* API sizefunc)(HWND, int, int, void *) = (int (* API)(HWND, int, int, void *))tmp->signalfunction;
2114 2114
2115 if((hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd) && SHORT1FROMMP(mp2) && SHORT2FROMMP(mp2)) 2115 if((hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd) && SHORT1FROMMP(mp2) && SHORT2FROMMP(mp2))
2116 { 2116 {
2117 result = sizefunc(tmp->window, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), tmp->data); 2117 result = sizefunc(tmp->window, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), tmp->data);
2118 tmp = NULL; 2118 tmp = NULL;
2119 } 2119 }
2120 } 2120 }
2121 break; 2121 break;
2122 case WM_BUTTON1DOWN: 2122 case WM_BUTTON1DOWN:
2123 { 2123 {
2124 POINTS pts = (*((POINTS*)&mp1)); 2124 POINTS pts = (*((POINTS*)&mp1));
2125 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))tmp->signalfunction; 2125 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))tmp->signalfunction;
2126 2126
2127 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window) 2127 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window)
2128 { 2128 {
2129 int button = 0; 2129 int button = 0;
2130 2130
2131 switch(origmsg) 2131 switch(origmsg)
2132 { 2132 {
2133 case WM_BUTTON1DOWN: 2133 case WM_BUTTON1DOWN:
2134 button = 1; 2134 button = 1;
2135 break; 2135 break;
2136 case WM_BUTTON2DOWN: 2136 case WM_BUTTON2DOWN:
2137 button = 2; 2137 button = 2;
2138 break; 2138 break;
2139 case WM_BUTTON3DOWN: 2139 case WM_BUTTON3DOWN:
2140 button = 3; 2140 button = 3;
2141 break; 2141 break;
2142 } 2142 }
2143 2143
2144 result = buttonfunc(tmp->window, pts.x, _get_frame_height(tmp->window) - pts.y, button, tmp->data); 2144 result = buttonfunc(tmp->window, pts.x, _get_frame_height(tmp->window) - pts.y, button, tmp->data);
2145 tmp = NULL; 2145 tmp = NULL;
2146 } 2146 }
2147 } 2147 }
2148 break; 2148 break;
2149 case WM_BUTTON1UP: 2149 case WM_BUTTON1UP:
2150 { 2150 {
2151 POINTS pts = (*((POINTS*)&mp1)); 2151 POINTS pts = (*((POINTS*)&mp1));
2152 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))tmp->signalfunction; 2152 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))tmp->signalfunction;
2153 2153
2154 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window) 2154 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window)
2155 { 2155 {
2156 int button = 0; 2156 int button = 0;
2157 2157
2158 switch(origmsg) 2158 switch(origmsg)
2159 { 2159 {
2160 case WM_BUTTON1UP: 2160 case WM_BUTTON1UP:
2161 button = 1; 2161 button = 1;
2162 break; 2162 break;
2163 case WM_BUTTON2UP: 2163 case WM_BUTTON2UP:
2164 button = 2; 2164 button = 2;
2165 break; 2165 break;
2166 case WM_BUTTON3UP: 2166 case WM_BUTTON3UP:
2167 button = 3; 2167 button = 3;
2168 break; 2168 break;
2169 } 2169 }
2170 2170
2171 result = buttonfunc(tmp->window, pts.x, WinQueryWindow(tmp->window, QW_PARENT) == HWND_DESKTOP ? dw_screen_height() - pts.y : _get_height(tmp->window) - pts.y, button, tmp->data); 2171 result = buttonfunc(tmp->window, pts.x, WinQueryWindow(tmp->window, QW_PARENT) == HWND_DESKTOP ? dw_screen_height() - pts.y : _get_height(tmp->window) - pts.y, button, tmp->data);
2172 tmp = NULL; 2172 tmp = NULL;
2173 } 2173 }
2174 } 2174 }
2175 break; 2175 break;
2176 case WM_MOUSEMOVE: 2176 case WM_MOUSEMOVE:
2177 { 2177 {
2178 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))tmp->signalfunction; 2178 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))tmp->signalfunction;
2179 2179
2180 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window) 2180 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window)
2181 { 2181 {
2182 int keys = 0; 2182 int keys = 0;
2183 SHORT x = SHORT1FROMMP(mp1), y = SHORT2FROMMP(mp1); 2183 SHORT x = SHORT1FROMMP(mp1), y = SHORT2FROMMP(mp1);
2184 2184
2185 if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000) 2185 if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000)
2186 keys = DW_BUTTON1_MASK; 2186 keys = DW_BUTTON1_MASK;
2187 if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) & 0x8000) 2187 if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) & 0x8000)
2188 keys |= DW_BUTTON2_MASK; 2188 keys |= DW_BUTTON2_MASK;
2189 if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) & 0x8000) 2189 if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) & 0x8000)
2190 keys |= DW_BUTTON3_MASK; 2190 keys |= DW_BUTTON3_MASK;
2191 2191
2192 result = motionfunc(tmp->window, x, _get_frame_height(tmp->window) - y, keys, tmp->data); 2192 result = motionfunc(tmp->window, x, _get_frame_height(tmp->window) - y, keys, tmp->data);
2193 tmp = NULL; 2193 tmp = NULL;
2194 } 2194 }
2195 } 2195 }
2196 break; 2196 break;
2197 case WM_CHAR: 2197 case WM_CHAR:
2198 { 2198 {
2199 int (* API keypressfunc)(HWND, char, int, int, void *) = (int (* API)(HWND, char, int, int, void *))tmp->signalfunction; 2199 int (* API keypressfunc)(HWND, char, int, int, void *) = (int (* API)(HWND, char, int, int, void *))tmp->signalfunction;
2200 2200
2201 if((hWnd == tmp->window || _toplevel_window(hWnd) == tmp->window) && !(SHORT1FROMMP(mp1) & KC_KEYUP)) 2201 if((hWnd == tmp->window || _toplevel_window(hWnd) == tmp->window) && !(SHORT1FROMMP(mp1) & KC_KEYUP))
2202 { 2202 {
2203 int vk; 2203 int vk;
2204 char ch = 0; 2204 char ch = 0;
2205 2205
2206 if(SHORT1FROMMP(mp1) & KC_CHAR) 2206 if(SHORT1FROMMP(mp1) & KC_CHAR)
2207 ch = (char)SHORT1FROMMP(mp2); 2207 ch = (char)SHORT1FROMMP(mp2);
2208 if(SHORT1FROMMP(mp1) & KC_VIRTUALKEY) 2208 if(SHORT1FROMMP(mp1) & KC_VIRTUALKEY)
2209 vk = SHORT2FROMMP(mp2); 2209 vk = SHORT2FROMMP(mp2);
2210 else 2210 else
2211 vk = SHORT1FROMMP(mp2) + 128; 2211 vk = SHORT1FROMMP(mp2) + 128;
2212 2212
2213 /* This is a hack to fix shift presses showing 2213 /* This is a hack to fix shift presses showing
2214 * up as tabs! 2214 * up as tabs!
2215 */ 2215 */
2216 if(ch == '\t' && !(SHORT1FROMMP(mp1) & KC_CHAR)) 2216 if(ch == '\t' && !(SHORT1FROMMP(mp1) & KC_CHAR))
2217 { 2217 {
2218 ch = 0; 2218 ch = 0;
2219 vk = VK_SHIFT; 2219 vk = VK_SHIFT;
2220 } 2220 }
2221 2221
2222 result = keypressfunc(tmp->window, ch, vk, 2222 result = keypressfunc(tmp->window, ch, vk,
2223 SHORT1FROMMP(mp1) & (KC_ALT | KC_SHIFT | KC_CTRL), tmp->data); 2223 SHORT1FROMMP(mp1) & (KC_ALT | KC_SHIFT | KC_CTRL), tmp->data);
2224 tmp = NULL; 2224 tmp = NULL;
2225 } 2225 }
2226 } 2226 }
2227 break; 2227 break;
2228 case WM_CLOSE: 2228 case WM_CLOSE:
2229 { 2229 {
2230 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))tmp->signalfunction; 2230 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))tmp->signalfunction;
2231 2231
2232 if(hWnd == tmp->window || hWnd == WinWindowFromID(tmp->window, FID_CLIENT)) 2232 if(hWnd == tmp->window || hWnd == WinWindowFromID(tmp->window, FID_CLIENT))
2233 { 2233 {
2234 result = closefunc(tmp->window, tmp->data); 2234 result = closefunc(tmp->window, tmp->data);
2235 if(result) 2235 if(result)
2236 result = FALSE; 2236 result = FALSE;
2237 tmp = NULL; 2237 tmp = NULL;
2238 } 2238 }
2239 } 2239 }
2240 break; 2240 break;
2241 case WM_PAINT: 2241 case WM_PAINT:
2242 { 2242 {
2243 HPS hps; 2243 HPS hps;
2244 DWExpose exp; 2244 DWExpose exp;
2245 int (* API exposefunc)(HWND, DWExpose *, void *) = (int (* API)(HWND, DWExpose *, void *))tmp->signalfunction; 2245 int (* API exposefunc)(HWND, DWExpose *, void *) = (int (* API)(HWND, DWExpose *, void *))tmp->signalfunction;
2246 RECTL rc; 2246 RECTL rc;
2247 2247
2248 if(hWnd == tmp->window) 2248 if(hWnd == tmp->window)
2249 { 2249 {
2250 int height = _get_height(hWnd); 2250 int height = _get_height(hWnd);
2251 2251
2252 hps = WinBeginPaint(hWnd, 0L, &rc); 2252 hps = WinBeginPaint(hWnd, 0L, &rc);
2253 exp.x = rc.xLeft; 2253 exp.x = rc.xLeft;
2254 exp.y = height - rc.yTop - 1; 2254 exp.y = height - rc.yTop - 1;
2255 exp.width = rc.xRight - rc. xLeft; 2255 exp.width = rc.xRight - rc. xLeft;
2256 exp.height = rc.yTop - rc.yBottom; 2256 exp.height = rc.yTop - rc.yBottom;
2257 result = exposefunc(hWnd, &exp, tmp->data); 2257 result = exposefunc(hWnd, &exp, tmp->data);
2258 WinEndPaint(hps); 2258 WinEndPaint(hps);
2259 } 2259 }
2260 } 2260 }
2261 break; 2261 break;
2262 case WM_COMMAND: 2262 case WM_COMMAND:
2263 { 2263 {
2264 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))tmp->signalfunction; 2264 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))tmp->signalfunction;
2265 ULONG command = COMMANDMSG(&msg)->cmd; 2265 ULONG command = COMMANDMSG(&msg)->cmd;
2266 2266
2267 if(tmp->id && command == tmp->id) 2267 if(tmp->id && command == tmp->id)
2268 { 2268 {
2269 HWND menuowner = _menu_owner(tmp->window); 2269 HWND menuowner = _menu_owner(tmp->window);
2270 2270
2271 if(menuowner == hWnd || menuowner == NULLHANDLE) 2271 if(menuowner == hWnd || menuowner == NULLHANDLE)
2272 { 2272 {
2273 result = clickfunc(tmp->window, tmp->data); 2273 result = clickfunc(tmp->window, tmp->data);
2274 tmp = NULL; 2274 tmp = NULL;
2275 } 2275 }
2276 } 2276 }
2277 else if(tmp->window < 65536 && command == tmp->window) 2277 else if(tmp->window < 65536 && command == tmp->window)
2278 { 2278 {
2279 result = clickfunc(popup ? popup : tmp->window, tmp->data); 2279 result = clickfunc(popup ? popup : tmp->window, tmp->data);
2280 tmp = NULL; 2280 tmp = NULL;
2281 } 2281 }
2282 } 2282 }
2283 break; 2283 break;
2284 case WM_CONTROL: 2284 case WM_CONTROL:
2285 if(origmsg == WM_VSCROLL || origmsg == WM_HSCROLL || tmp->message == SHORT2FROMMP(mp1) || 2285 if(origmsg == WM_VSCROLL || origmsg == WM_HSCROLL || tmp->message == SHORT2FROMMP(mp1) ||
2286 (tmp->message == SLN_SLIDERTRACK && SHORT2FROMMP(mp1) == SLN_CHANGE)) 2286 (tmp->message == SLN_SLIDERTRACK && SHORT2FROMMP(mp1) == SLN_CHANGE))
2287 { 2287 {
2288 int svar = SLN_SLIDERTRACK; 2288 int svar = SLN_SLIDERTRACK;
2289 if(origmsg == WM_CONTROL) 2289 if(origmsg == WM_CONTROL)
2290 svar = SHORT2FROMMP(mp1); 2290 svar = SHORT2FROMMP(mp1);
2291 2291
2292 switch(svar) 2292 switch(svar)
2293 { 2293 {
2294 case CN_ENTER: 2294 case CN_ENTER:
2295 { 2295 {
2296 int (* API containerselectfunc)(HWND, char *, void *) = (int (* API)(HWND, char *, void *))tmp->signalfunction; 2296 int (* API containerselectfunc)(HWND, char *, void *) = (int (* API)(HWND, char *, void *))tmp->signalfunction;
2297 int id = SHORT1FROMMP(mp1); 2297 int id = SHORT1FROMMP(mp1);
2298 HWND conthwnd = dw_window_from_id(hWnd, id); 2298 HWND conthwnd = dw_window_from_id(hWnd, id);
2299 char *text = NULL; 2299 char *text = NULL;
2300 2300
2301 if(mp2) 2301 if(mp2)
2302 { 2302 {
2303 PRECORDCORE pre; 2303 PRECORDCORE pre;
2304 2304
2305 pre = ((PNOTIFYRECORDENTER)mp2)->pRecord; 2305 pre = ((PNOTIFYRECORDENTER)mp2)->pRecord;
2306 if(pre) 2306 if(pre)
2307 text = pre->pszIcon; 2307 text = pre->pszIcon;
2308 } 2308 }
2309 2309
2310 if(tmp->window == conthwnd) 2310 if(tmp->window == conthwnd)
2311 { 2311 {
2312 result = containerselectfunc(tmp->window, text, tmp->data); 2312 result = containerselectfunc(tmp->window, text, tmp->data);
2313 tmp = NULL; 2313 tmp = NULL;
2314 } 2314 }
2315 } 2315 }
2316 break; 2316 break;
2317 case CN_EXPANDTREE: 2317 case CN_EXPANDTREE:
2318 { 2318 {
2319 int (* API treeexpandfunc)(HWND, HTREEITEM, void *) = (int (* API)(HWND, HTREEITEM, void *))tmp->signalfunction; 2319 int (* API treeexpandfunc)(HWND, HTREEITEM, void *) = (int (* API)(HWND, HTREEITEM, void *))tmp->signalfunction;
2320 int id = SHORT1FROMMP(mp1); 2320 int id = SHORT1FROMMP(mp1);
2321 HWND conthwnd = dw_window_from_id(hWnd, id); 2321 HWND conthwnd = dw_window_from_id(hWnd, id);
2322 2322
2323 if(tmp->window == conthwnd) 2323 if(tmp->window == conthwnd)
2324 { 2324 {
2325 result = treeexpandfunc(tmp->window, (HTREEITEM)mp2, tmp->data); 2325 result = treeexpandfunc(tmp->window, (HTREEITEM)mp2, tmp->data);
2326 tmp = NULL; 2326 tmp = NULL;
2327 } 2327 }
2328 } 2328 }
2329 break; 2329 break;
2330 case CN_CONTEXTMENU: 2330 case CN_CONTEXTMENU:
2331 { 2331 {
2332 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))tmp->signalfunction; 2332 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))tmp->signalfunction;
2333 int id = SHORT1FROMMP(mp1); 2333 int id = SHORT1FROMMP(mp1);
2334 HWND conthwnd = dw_window_from_id(hWnd, id); 2334 HWND conthwnd = dw_window_from_id(hWnd, id);
2335 char *text = NULL; 2335 char *text = NULL;
2336 void *user = NULL; 2336 void *user = NULL;
2337 LONG x,y; 2337 LONG x,y;
2338 2338
2339 if(mp2) 2339 if(mp2)
2340 { 2340 {
2341 PCNRITEM pci; 2341 PCNRITEM pci;
2342 2342
2343 pci = (PCNRITEM)mp2; 2343 pci = (PCNRITEM)mp2;
2344 2344
2345 text = pci->rc.pszIcon; 2345 text = pci->rc.pszIcon;
2346 user = pci->user; 2346 user = pci->user;
2347 } 2347 }
2348 2348
2349 dw_pointer_query_pos(&x, &y); 2349 dw_pointer_query_pos(&x, &y);
2350 2350
2351 if(tmp->window == conthwnd) 2351 if(tmp->window == conthwnd)
2352 { 2352 {
2353 int container = (int)dw_window_get_data(tmp->window, "_dw_container"); 2353 int container = (int)dw_window_get_data(tmp->window, "_dw_container");
2354 2354
2355 if(mp2) 2355 if(mp2)
2356 { 2356 {
2357 if(!container) 2357 if(!container)
2358 { 2358 {
2359 NOTIFYRECORDEMPHASIS pre; 2359 NOTIFYRECORDEMPHASIS pre;
2360 2360
2361 dw_tree_item_select(tmp->window, (HTREEITEM)mp2); 2361 dw_tree_item_select(tmp->window, (HTREEITEM)mp2);
2362 pre.pRecord = mp2; 2362 pre.pRecord = mp2;
2363 pre.fEmphasisMask = CRA_CURSORED; 2363 pre.fEmphasisMask = CRA_CURSORED;
2364 pre.hwndCnr = tmp->window; 2364 pre.hwndCnr = tmp->window;
2365 _run_event(hWnd, WM_CONTROL, MPFROM2SHORT(0, CN_EMPHASIS), (MPARAM)&pre); 2365 _run_event(hWnd, WM_CONTROL, MPFROM2SHORT(0, CN_EMPHASIS), (MPARAM)&pre);
2366 pre.pRecord->flRecordAttr |= CRA_CURSORED; 2366 pre.pRecord->flRecordAttr |= CRA_CURSORED;
2367 } 2367 }
2368 else 2368 else
2369 { 2369 {
2370 if(pCoreEmph) 2370 if(pCoreEmph)
2371 _clear_emphasis(); 2371 _clear_emphasis();
2372 hwndEmph = tmp->window; 2372 hwndEmph = tmp->window;
2373 pCoreEmph = mp2; 2373 pCoreEmph = mp2;
2374 WinSendMsg(tmp->window, CM_SETRECORDEMPHASIS, mp2, MPFROM2SHORT(TRUE, CRA_SOURCE)); 2374 WinSendMsg(tmp->window, CM_SETRECORDEMPHASIS, mp2, MPFROM2SHORT(TRUE, CRA_SOURCE));
2375 } 2375 }
2376 } 2376 }
2377 result = containercontextfunc(tmp->window, text, x, y, tmp->data, user); 2377 result = containercontextfunc(tmp->window, text, x, y, tmp->data, user);
2378 tmp = NULL; 2378 tmp = NULL;
2379 } 2379 }
2380 } 2380 }
2381 break; 2381 break;
2382 case CN_EMPHASIS: 2382 case CN_EMPHASIS:
2383 { 2383 {
2384 PNOTIFYRECORDEMPHASIS pre = (PNOTIFYRECORDEMPHASIS)mp2; 2384 PNOTIFYRECORDEMPHASIS pre = (PNOTIFYRECORDEMPHASIS)mp2;
2385 static int emph_recurse = 0; 2385 static int emph_recurse = 0;
2386 2386
2387 if(!emph_recurse) 2387 if(!emph_recurse)
2388 { 2388 {
2389 emph_recurse = 1; 2389 emph_recurse = 1;
2390 2390
2391 if(mp2) 2391 if(mp2)
2392 { 2392 {
2393 if(tmp->window == pre->hwndCnr) 2393 if(tmp->window == pre->hwndCnr)
2394 { 2394 {
2395 PCNRITEM pci = (PCNRITEM)pre->pRecord; 2395 PCNRITEM pci = (PCNRITEM)pre->pRecord;
2396 2396
2397 if(pci && pre->fEmphasisMask & CRA_CURSORED && (pci->rc.flRecordAttr & CRA_CURSORED)) 2397 if(pci && pre->fEmphasisMask & CRA_CURSORED && (pci->rc.flRecordAttr & CRA_CURSORED))
2398 { 2398 {
2399 int (* API treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = (int (* API)(HWND, HTREEITEM, char *, void *, void *))tmp->signalfunction; 2399 int (* API treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = (int (* API)(HWND, HTREEITEM, char *, void *, void *))tmp->signalfunction;
2400 2400
2401 if(dw_window_get_data(tmp->window, "_dw_container")) 2401 if(dw_window_get_data(tmp->window, "_dw_container"))
2402 result = treeselectfunc(tmp->window, 0, pci->rc.pszIcon, tmp->data, 0); 2402 result = treeselectfunc(tmp->window, 0, pci->rc.pszIcon, tmp->data, 0);
2403 else 2403 else
2404 { 2404 {
2405 if(lasthcnr == tmp->window && lastitem == (HWND)pci) 2405 if(lasthcnr == tmp->window && lastitem == (HWND)pci)
2406 { 2406 {
2407 lasthcnr = 0; 2407 lasthcnr = 0;
2408 lastitem = 0; 2408 lastitem = 0;
2409 } 2409 }
2410 else 2410 else
2411 { 2411 {
2412 lasthcnr = tmp->window; 2412 lasthcnr = tmp->window;
2413 lastitem = (HWND)pci; 2413 lastitem = (HWND)pci;
2414 result = treeselectfunc(tmp->window, (HTREEITEM)pci, pci->rc.pszIcon, tmp->data, pci->user); 2414 result = treeselectfunc(tmp->window, (HTREEITEM)pci, pci->rc.pszIcon, tmp->data, pci->user);
2415 } 2415 }
2416 } 2416 }
2417 tmp = NULL; 2417 tmp = NULL;
2418 } 2418 }
2419 } 2419 }
2420 } 2420 }
2421 emph_recurse = 0; 2421 emph_recurse = 0;
2422 } 2422 }
2423 } 2423 }
2424 break; 2424 break;
2425 case LN_SELECT: 2425 case LN_SELECT:
2426 { 2426 {
2427 char classbuf[100]; 2427 char classbuf[100];
2428 2428
2429 WinQueryClassName(tmp->window, 99, classbuf); 2429 WinQueryClassName(tmp->window, 99, classbuf);
2430 2430
2431 if(strncmp(classbuf, "#38", 4) == 0) 2431 if(strncmp(classbuf, "#38", 4) == 0)
2432 { 2432 {
2433 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))tmp->signalfunction; 2433 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))tmp->signalfunction;
2434 2434
2435 if(tmp->window == hWnd || WinQueryWindow(tmp->window, QW_PARENT) == hWnd) 2435 if(tmp->window == hWnd || WinQueryWindow(tmp->window, QW_PARENT) == hWnd)
2436 { 2436 {
2437 static int lastvalue = -1; 2437 static int lastvalue = -1;
2438 static HWND lasthwnd = NULLHANDLE; 2438 static HWND lasthwnd = NULLHANDLE;
2439 int ulValue = (int)WinSendMsg(tmp->window, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), 0); 2439 int ulValue = (int)WinSendMsg(tmp->window, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), 0);
2440 if(lastvalue != ulValue || lasthwnd != tmp->window) 2440 if(lastvalue != ulValue || lasthwnd != tmp->window)
2441 { 2441 {
2442 result = valuechangedfunc(tmp->window, ulValue, tmp->data); 2442 result = valuechangedfunc(tmp->window, ulValue, tmp->data);
2443 lastvalue = ulValue; 2443 lastvalue = ulValue;
2444 lasthwnd = tmp->window; 2444 lasthwnd = tmp->window;
2445 } 2445 }
2446 tmp = NULL; 2446 tmp = NULL;
2447 } 2447 }
2448 } 2448 }
2449 else 2449 else
2450 { 2450 {
2451 int (* API listboxselectfunc)(HWND, int, void *) = (int (* API )(HWND, int, void *))tmp->signalfunction; 2451 int (* API listboxselectfunc)(HWND, int, void *) = (int (* API )(HWND, int, void *))tmp->signalfunction;
2452 int id = SHORT1FROMMP(mp1); 2452 int id = SHORT1FROMMP(mp1);
2453 HWND conthwnd = dw_window_from_id(hWnd, id); 2453 HWND conthwnd = dw_window_from_id(hWnd, id);
2454 static int _recursing = 0; 2454 static int _recursing = 0;
2455 2455
2456 if(_recursing == 0 && (tmp->window == conthwnd || (!id && tmp->window == (HWND)mp2))) 2456 if(_recursing == 0 && (tmp->window == conthwnd || (!id && tmp->window == (HWND)mp2)))
2457 { 2457 {
2458 char buf1[500]; 2458 char buf1[500];
2459 unsigned int index = dw_listbox_selected(tmp->window); 2459 unsigned int index = dw_listbox_selected(tmp->window);
2460 2460
2461 dw_listbox_get_text(tmp->window, index, buf1, 500); 2461 dw_listbox_get_text(tmp->window, index, buf1, 500);
2462 2462
2463 _recursing = 1; 2463 _recursing = 1;
2464 2464
2465 if(id && strncmp(classbuf, "#2", 3)==0) 2465 if(id && strncmp(classbuf, "#2", 3)==0)
2466 { 2466 {
2467 char *buf2; 2467 char *buf2;
2468 2468
2469 buf2 = dw_window_get_text(tmp->window); 2469 buf2 = dw_window_get_text(tmp->window);
2470 2470
2471 /* This is to make sure the listboxselect function doesn't 2471 /* This is to make sure the listboxselect function doesn't
2472 * get called if the user is modifying the entry text. 2472 * get called if the user is modifying the entry text.
2473 */ 2473 */
2474 if(buf2 && *buf2 && *buf1 && strncmp(buf1, buf2, 500) == 0) 2474 if(buf2 && *buf2 && *buf1 && strncmp(buf1, buf2, 500) == 0)
2475 result = listboxselectfunc(tmp->window, index, tmp->data); 2475 result = listboxselectfunc(tmp->window, index, tmp->data);
2476 2476
2477 if(buf2) 2477 if(buf2)
2478 free(buf2); 2478 free(buf2);
2479 } 2479 }
2480 else 2480 else
2481 result = listboxselectfunc(tmp->window, index, tmp->data); 2481 result = listboxselectfunc(tmp->window, index, tmp->data);
2482 2482
2483 _recursing = 0; 2483 _recursing = 0;
2484 tmp = NULL; 2484 tmp = NULL;
2485 } 2485 }
2486 } 2486 }
2487 } 2487 }
2488 break; 2488 break;
2489 case SLN_SLIDERTRACK: 2489 case SLN_SLIDERTRACK:
2490 { 2490 {
2491 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))tmp->signalfunction; 2491 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))tmp->signalfunction;
2492 2492
2493 if(origmsg == WM_CONTROL) 2493 if(origmsg == WM_CONTROL)
2494 { 2494 {
2495 /* Handle Slider control */ 2495 /* Handle Slider control */
2496 if(tmp->window == hWnd || WinQueryWindow(tmp->window, QW_PARENT) == hWnd) 2496 if(tmp->window == hWnd || WinQueryWindow(tmp->window, QW_PARENT) == hWnd)
2497 { 2497 {
2498 static int lastvalue = -1; 2498 static int lastvalue = -1;
2499 static HWND lasthwnd = NULLHANDLE; 2499 static HWND lasthwnd = NULLHANDLE;
2500 int ulValue = (int)WinSendMsg(tmp->window, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), 0); 2500 int ulValue = (int)WinSendMsg(tmp->window, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), 0);
2501 if(lastvalue != ulValue || lasthwnd != tmp->window) 2501 if(lastvalue != ulValue || lasthwnd != tmp->window)
2502 { 2502 {
2503 dw_window_set_data(tmp->window, "_dw_slider_value", (void *)ulValue); 2503 dw_window_set_data(tmp->window, "_dw_slider_value", (void *)ulValue);
2504 result = valuechangedfunc(tmp->window, ulValue, tmp->data); 2504 result = valuechangedfunc(tmp->window, ulValue, tmp->data);
2505 lastvalue = ulValue; 2505 lastvalue = ulValue;
2506 lasthwnd = tmp->window; 2506 lasthwnd = tmp->window;
2507 } 2507 }
2508 tmp = NULL; 2508 tmp = NULL;
2509 } 2509 }
2510 } 2510 }
2511 else 2511 else
2512 { 2512 {
2513 /* Handle scrollbar control */ 2513 /* Handle scrollbar control */
2514 if(tmp->window > 65535 && tmp->window == WinWindowFromID(hWnd, (ULONG)mp1)) 2514 if(tmp->window > 65535 && tmp->window == WinWindowFromID(hWnd, (ULONG)mp1))
2515 { 2515 {
2516 int pos = _HandleScroller(tmp->window, (int)SHORT1FROMMP(mp2), (int)SHORT2FROMMP(mp2));; 2516 int pos = _HandleScroller(tmp->window, (int)SHORT1FROMMP(mp2), (int)SHORT2FROMMP(mp2));;
2517 2517
2518 if(pos > -1) 2518 if(pos > -1)
2519 { 2519 {
2520 dw_window_set_data(tmp->window, "_dw_scrollbar_value", (void *)pos); 2520 dw_window_set_data(tmp->window, "_dw_scrollbar_value", (void *)pos);
2521 result = valuechangedfunc(tmp->window, pos, tmp->data); 2521 result = valuechangedfunc(tmp->window, pos, tmp->data);
2522 } 2522 }
2523 result = 0; 2523 result = 0;
2524 tmp = NULL; 2524 tmp = NULL;
2525 } 2525 }
2526 } 2526 }
2527 } 2527 }
2528 break; 2528 break;
2529 case BKN_PAGESELECTED: 2529 case BKN_PAGESELECTED:
2530 { 2530 {
2531 PAGESELECTNOTIFY *psn = (PAGESELECTNOTIFY *)mp2; 2531 PAGESELECTNOTIFY *psn = (PAGESELECTNOTIFY *)mp2;
2532 2532
2533 if(psn && tmp->window == psn->hwndBook) 2533 if(psn && tmp->window == psn->hwndBook)
2534 { 2534 {
2535 int (* API switchpagefunc)(HWND, unsigned long, void *) = (int (* API)(HWND, unsigned long, void *))tmp->signalfunction; 2535 int (* API switchpagefunc)(HWND, unsigned long, void *) = (int (* API)(HWND, unsigned long, void *))tmp->signalfunction;
2536 2536
2537 result = switchpagefunc(tmp->window, psn->ulPageIdNew, tmp->data); 2537 result = switchpagefunc(tmp->window, psn->ulPageIdNew, tmp->data);
2538 tmp = NULL; 2538 tmp = NULL;
2539 } 2539 }
2540 } 2540 }
2541 break; 2541 break;
2542 } 2542 }
2543 } 2543 }
2544 break; 2544 break;
2545 } 2545 }
2546 } 2546 }
2547 2547
2548 if(tmp) 2548 if(tmp)
2549 tmp = tmp->next; 2549 tmp = tmp->next;
2550 2550
2551 } 2551 }
2552 return (MRESULT)result; 2552 return (MRESULT)result;
2553 } 2553 }
2554 2554
2555 /* Gets a DW_RGB value from the three spinbuttons */ 2555 /* Gets a DW_RGB value from the three spinbuttons */
2556 unsigned long _dw_color_spin_get(HWND window) 2556 unsigned long _dw_color_spin_get(HWND window)
2557 { 2557 {
2558 HWND button = (HWND)dw_window_get_data(window, "_dw_red_spin"); 2558 HWND button = (HWND)dw_window_get_data(window, "_dw_red_spin");
2559 long red, green, blue; 2559 long red, green, blue;
2560 2560
2561 red = dw_spinbutton_get_pos(button); 2561 red = dw_spinbutton_get_pos(button);
2562 button = (HWND)dw_window_get_data(window, "_dw_green_spin"); 2562 button = (HWND)dw_window_get_data(window, "_dw_green_spin");
2563 green = dw_spinbutton_get_pos(button); 2563 green = dw_spinbutton_get_pos(button);
2564 button = (HWND)dw_window_get_data(window, "_dw_blue_spin"); 2564 button = (HWND)dw_window_get_data(window, "_dw_blue_spin");
2565 blue = dw_spinbutton_get_pos(button); 2565 blue = dw_spinbutton_get_pos(button);
2566 2566
2567 return DW_RGB(red, green, blue); 2567 return DW_RGB(red, green, blue);
2568 } 2568 }
2569 2569
2570 /* Set the three spinbuttons from a DW_RGB value */ 2570 /* Set the three spinbuttons from a DW_RGB value */
2571 void _dw_color_spin_set(HWND window, unsigned long value) 2571 void _dw_color_spin_set(HWND window, unsigned long value)
2572 { 2572 {
2573 HWND button = (HWND)dw_window_get_data(window, "_dw_red_spin"); 2573 HWND button = (HWND)dw_window_get_data(window, "_dw_red_spin");
2574 dw_window_set_data(window, "_dw_updating", (void *)1); 2574 dw_window_set_data(window, "_dw_updating", (void *)1);
2575 dw_spinbutton_set_pos(button, DW_RED_VALUE(value)); 2575 dw_spinbutton_set_pos(button, DW_RED_VALUE(value));
2576 button = (HWND)dw_window_get_data(window, "_dw_green_spin"); 2576 button = (HWND)dw_window_get_data(window, "_dw_green_spin");
2577 dw_spinbutton_set_pos(button, DW_GREEN_VALUE(value)); 2577 dw_spinbutton_set_pos(button, DW_GREEN_VALUE(value));
2578 button = (HWND)dw_window_get_data(window, "_dw_blue_spin"); 2578 button = (HWND)dw_window_get_data(window, "_dw_blue_spin");
2579 dw_spinbutton_set_pos(button, DW_BLUE_VALUE(value)); 2579 dw_spinbutton_set_pos(button, DW_BLUE_VALUE(value));
2580 dw_window_set_data(window, "_dw_updating", NULL); 2580 dw_window_set_data(window, "_dw_updating", NULL);
2581 } 2581 }
2582 2582
2583 /* Sets the color selection control to be a DW_RGB value */ 2583 /* Sets the color selection control to be a DW_RGB value */
2584 void _dw_col_set(HWND col, unsigned long value) 2584 void _dw_col_set(HWND col, unsigned long value)
2585 { 2585 {
2586 WinSendMsg(col, 0x0602, MPFROMLONG(_os2_color(value)), 0); 2586 WinSendMsg(col, 0x0602, MPFROMLONG(_os2_color(value)), 0);
2587 if(!IS_WARP4()) 2587 if(!IS_WARP4())
2588 WinSendMsg(col, 0x1384, MPFROMLONG(_os2_color(value)), 0); 2588 WinSendMsg(col, 0x1384, MPFROMLONG(_os2_color(value)), 0);
2589 } 2589 }
2590 2590
2591 /* Handles control messages sent to the box (owner). */ 2591 /* Handles control messages sent to the box (owner). */
2592 MRESULT EXPENTRY _controlproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) 2592 MRESULT EXPENTRY _controlproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
2593 { 2593 {
2594 Box *blah = WinQueryWindowPtr(hWnd, QWP_USER); 2594 Box *blah = WinQueryWindowPtr(hWnd, QWP_USER);
2595 2595
2596 switch(msg) 2596 switch(msg)
2597 { 2597 {
2598 case WM_MOUSEMOVE: 2598 case WM_MOUSEMOVE:
2599 if(_wndproc(hWnd, msg, mp1, mp2)) 2599 if(_wndproc(hWnd, msg, mp1, mp2))
2600 return MPFROMSHORT(FALSE); 2600 return MPFROMSHORT(FALSE);
2601 break; 2601 break;
2602 case WM_VSCROLL: 2602 case WM_VSCROLL:
2603 case WM_HSCROLL: 2603 case WM_HSCROLL:
2604 if(_run_event(hWnd, msg, mp1, mp2)) 2604 if(_run_event(hWnd, msg, mp1, mp2))
2605 { 2605 {
2606 HWND window = WinWindowFromID(hWnd, (ULONG)mp1); 2606 HWND window = WinWindowFromID(hWnd, (ULONG)mp1);
2607 _HandleScroller(window, (int)SHORT1FROMMP(mp2), (int)SHORT2FROMMP(mp2)); 2607 _HandleScroller(window, (int)SHORT1FROMMP(mp2), (int)SHORT2FROMMP(mp2));
2608 } 2608 }
2609 break; 2609 break;
2610 /* Handles Color Selection control messages */ 2610 /* Handles Color Selection control messages */
2611 case 0x0601: 2611 case 0x0601:
2612 case 0x130C: 2612 case 0x130C:
2613 { 2613 {
2614 HWND window = (HWND)dw_window_get_data(hWnd, "_dw_window"); 2614 HWND window = (HWND)dw_window_get_data(hWnd, "_dw_window");
2615 unsigned long val = (unsigned long)mp1; 2615 unsigned long val = (unsigned long)mp1;
2616 2616
2617 if(window) 2617 if(window)
2618 _dw_color_spin_set(window, DW_RGB((val & 0xFF0000) >> 16, (val & 0xFF00) >> 8, val & 0xFF)); 2618 _dw_color_spin_set(window, DW_RGB((val & 0xFF0000) >> 16, (val & 0xFF00) >> 8, val & 0xFF));
2619 } 2619 }
2620 break; 2620 break;
2621 case WM_CONTROL: 2621 case WM_CONTROL:
2622 if((SHORT2FROMMP(mp1) == SPBN_CHANGE || SHORT2FROMMP(mp1) == SPBN_ENDSPIN)) 2622 if((SHORT2FROMMP(mp1) == SPBN_CHANGE || SHORT2FROMMP(mp1) == SPBN_ENDSPIN))
2623 { 2623 {
2624 HWND window = (HWND)dw_window_get_data(hWnd, "_dw_window"); 2624 HWND window = (HWND)dw_window_get_data(hWnd, "_dw_window");
2625 2625
2626 if(window && !dw_window_get_data(window, "_dw_updating")) 2626 if(window && !dw_window_get_data(window, "_dw_updating"))
2627 { 2627 {
2628 unsigned long val = _dw_color_spin_get(window); 2628 unsigned long val = _dw_color_spin_get(window);
2629 HWND col = (HWND)dw_window_get_data(window, "_dw_col"); 2629 HWND col = (HWND)dw_window_get_data(window, "_dw_col");
2630 2630
2631 _dw_col_set(col, val); 2631 _dw_col_set(col, val);
2632 } 2632 }
2633 } 2633 }
2634 _run_event(hWnd, msg, mp1, mp2); 2634 _run_event(hWnd, msg, mp1, mp2);
2635 break; 2635 break;
2636 } 2636 }
2637 2637
2638 if(blah && blah->oldproc) 2638 if(blah && blah->oldproc)
2639 return blah->oldproc(hWnd, msg, mp1, mp2); 2639 return blah->oldproc(hWnd, msg, mp1, mp2);
2640 2640
2641 return WinDefWindowProc(hWnd, msg, mp1, mp2); 2641 return WinDefWindowProc(hWnd, msg, mp1, mp2);
2642 } 2642 }
2643 2643
2644 /* The main window procedure for Dynamic Windows, all the resizing code is done here. */ 2644 /* The main window procedure for Dynamic Windows, all the resizing code is done here. */
2645 MRESULT EXPENTRY _wndproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) 2645 MRESULT EXPENTRY _wndproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
2646 { 2646 {
2647 int result = -1; 2647 int result = -1;
2648 static int command_active = 0; 2648 static int command_active = 0;
2649 void (* API windowfunc)(PVOID) = 0L; 2649 void (* API windowfunc)(PVOID) = 0L;
2650 2650
2651 if(!command_active) 2651 if(!command_active)
2652 { 2652 {
2653 /* Make sure we don't end up in infinite recursion */ 2653 /* Make sure we don't end up in infinite recursion */
2654 command_active = 1; 2654 command_active = 1;
2655 2655
2656 result = (int)_run_event(hWnd, msg, mp1, mp2); 2656 result = (int)_run_event(hWnd, msg, mp1, mp2);
2657 2657
2658 command_active = 0; 2658 command_active = 0;
2659 } 2659 }
2660 2660
2661 /* Now that any handlers are done... do normal processing */ 2661 /* Now that any handlers are done... do normal processing */
2662 switch( msg ) 2662 switch( msg )
2663 { 2663 {
2664 case WM_ERASEBACKGROUND: 2664 case WM_ERASEBACKGROUND:
2665 return 0; 2665 return 0;
2666 2666
2667 case WM_PAINT: 2667 case WM_PAINT:
2668 { 2668 {
2669 HPS hps; 2669 HPS hps;
2670 RECTL rc; 2670 RECTL rc;
2671 2671
2672 hps = WinBeginPaint( hWnd, 0L, &rc ); 2672 hps = WinBeginPaint( hWnd, 0L, &rc );
2673 WinEndPaint( hps ); 2673 WinEndPaint( hps );
2674 break; 2674 break;
2675 } 2675 }
2676 2676
2677 case WM_SIZE: 2677 case WM_SIZE:
2678 { 2678 {
2679 Box *mybox = (Box *)WinQueryWindowPtr(hWnd, QWP_USER); 2679 Box *mybox = (Box *)WinQueryWindowPtr(hWnd, QWP_USER);
2680 2680
2681 if(!SHORT1FROMMP(mp2) && !SHORT2FROMMP(mp2)) 2681 if(!SHORT1FROMMP(mp2) && !SHORT2FROMMP(mp2))
2682 return (MPARAM)TRUE; 2682 return (MPARAM)TRUE;
2683 2683
2684 if(mybox && mybox->flags != DW_MINIMIZED) 2684 if(mybox && mybox->flags != DW_MINIMIZED)
2685 { 2685 {
2686 /* Hide the window when recalculating to reduce 2686 /* Hide the window when recalculating to reduce
2687 * CPU load. 2687 * CPU load.
2688 */ 2688 */
2689 WinShowWindow(hWnd, FALSE); 2689 WinShowWindow(hWnd, FALSE);
2690 2690
2691 if(mybox->items) 2691 if(mybox->items)
2692 WinSetWindowPos(mybox->items[0].hwnd, HWND_TOP, 0, 0, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SWP_MOVE | SWP_SIZE); 2692 WinSetWindowPos(mybox->items[0].hwnd, HWND_TOP, 0, 0, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SWP_MOVE | SWP_SIZE);
2693 2693
2694 _do_resize(mybox, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2)); 2694 _do_resize(mybox, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2));
2695 2695
2696 WinShowWindow(hWnd, TRUE); 2696 WinShowWindow(hWnd, TRUE);
2697 } 2697 }
2698 } 2698 }
2699 break; 2699 break;
2700 case WM_MINMAXFRAME: 2700 case WM_MINMAXFRAME:
2701 { 2701 {
2702 Box *mybox = (Box *)WinQueryWindowPtr(hWnd, QWP_USER); 2702 Box *mybox = (Box *)WinQueryWindowPtr(hWnd, QWP_USER);
2703 SWP *swp = (SWP *)mp1; 2703 SWP *swp = (SWP *)mp1;
2704 2704
2705 if(mybox && (swp->fl & SWP_MINIMIZE)) 2705 if(mybox && (swp->fl & SWP_MINIMIZE))
2706 mybox->flags = DW_MINIMIZED; 2706 mybox->flags = DW_MINIMIZED;
2707 2707
2708 if(mybox && (swp->fl & SWP_RESTORE)) 2708 if(mybox && (swp->fl & SWP_RESTORE))
2709 { 2709 {
2710 if(!mybox->titlebar && mybox->hwndtitle) 2710 if(!mybox->titlebar && mybox->hwndtitle)
2711 WinSetParent(mybox->hwndtitle, HWND_OBJECT, FALSE); 2711 WinSetParent(mybox->hwndtitle, HWND_OBJECT, FALSE);
2712 mybox->flags = 0; 2712 mybox->flags = 0;
2713 } 2713 }
2714 2714
2715 if(mybox && (swp->fl & (SWP_MAXIMIZE | SWP_RESTORE))) 2715 if(mybox && (swp->fl & (SWP_MAXIMIZE | SWP_RESTORE)))
2716 { 2716 {
2717 int z; 2717 int z;
2718 SWP swp2; 2718 SWP swp2;
2719 2719
2720 WinQueryWindowPos(swp->hwnd, &swp2); 2720 WinQueryWindowPos(swp->hwnd, &swp2);
2721 2721
2722 if(swp2.cx == swp->cx && swp2.cy == swp->cy) 2722 if(swp2.cx == swp->cx && swp2.cy == swp->cy)
2723 return FALSE; 2723 return FALSE;
2724 2724
2725 mybox->flags = 0; 2725 mybox->flags = 0;
2726 2726
2727 /* Hide the window when recalculating to reduce 2727 /* Hide the window when recalculating to reduce
2728 * CPU load. 2728 * CPU load.
2729 */ 2729 */
2730 WinShowWindow(hWnd, FALSE); 2730 WinShowWindow(hWnd, FALSE);
2731 2731
2732 _do_resize(mybox, swp->cx, swp->cy); 2732 _do_resize(mybox, swp->cx, swp->cy);
2733 2733
2734 if(mybox->count == 1 && mybox->items[0].type == TYPEBOX) 2734 if(mybox->count == 1 && mybox->items[0].type == TYPEBOX)
2735 { 2735 {
2736 mybox = (Box *)WinQueryWindowPtr(mybox->items[0].hwnd, QWP_USER); 2736 mybox = (Box *)WinQueryWindowPtr(mybox->items[0].hwnd, QWP_USER);
2737 2737
2738 for(z=0;z<mybox->count;z++) 2738 for(z=0;z<mybox->count;z++)
2739 _check_resize_notebook(mybox->items[z].hwnd); 2739 _check_resize_notebook(mybox->items[z].hwnd);
2740 2740
2741 } 2741 }
2742 2742
2743 WinShowWindow(hWnd, TRUE); 2743 WinShowWindow(hWnd, TRUE);
2744 } 2744 }
2745 } 2745 }
2746 break; 2746 break;
2747 case WM_CONTROL: 2747 case WM_CONTROL:
2748 switch(SHORT2FROMMP(mp1)) 2748 switch(SHORT2FROMMP(mp1))
2749 { 2749 {
2750 case BKN_PAGESELECTEDPENDING: 2750 case BKN_PAGESELECTEDPENDING:
2751 { 2751 {
2752 PAGESELECTNOTIFY *psn = (PAGESELECTNOTIFY *)mp2; 2752 PAGESELECTNOTIFY *psn = (PAGESELECTNOTIFY *)mp2;
2753 HWND pagehwnd = (HWND)WinSendMsg(psn->hwndBook, BKM_QUERYPAGEWINDOWHWND, MPFROMLONG(psn->ulPageIdNew), 0); 2753 HWND pagehwnd = (HWND)WinSendMsg(psn->hwndBook, BKM_QUERYPAGEWINDOWHWND, MPFROMLONG(psn->ulPageIdNew), 0);
2754 Box *pagebox = (Box *)WinQueryWindowPtr(pagehwnd, QWP_USER); 2754 Box *pagebox = (Box *)WinQueryWindowPtr(pagehwnd, QWP_USER);
2755 unsigned long x, y, width, height; 2755 unsigned long x, y, width, height;
2756 RECTL rc; 2756 RECTL rc;
2757 2757
2758 if(pagebox && psn->ulPageIdNew != psn->ulPageIdCur) 2758 if(pagebox && psn->ulPageIdNew != psn->ulPageIdCur)
2759 { 2759 {
2760 dw_window_get_pos_size(psn->hwndBook, &x, &y, &width, &height); 2760 dw_window_get_pos_size(psn->hwndBook, &x, &y, &width, &height);
2761 2761
2762 rc.xLeft = x; 2762 rc.xLeft = x;
2763 rc.yBottom = y; 2763 rc.yBottom = y;
2764 rc.xRight = x + width; 2764 rc.xRight = x + width;
2765 rc.yTop = y + height; 2765 rc.yTop = y + height;
2766 2766
2767 WinSendMsg(psn->hwndBook, BKM_CALCPAGERECT, (MPARAM)&rc, (MPARAM)TRUE); 2767 WinSendMsg(psn->hwndBook, BKM_CALCPAGERECT, (MPARAM)&rc, (MPARAM)TRUE);
2768 2768
2769 _do_resize(pagebox, rc.xRight - rc.xLeft, rc.yTop - rc.yBottom); 2769 _do_resize(pagebox, rc.xRight - rc.xLeft, rc.yTop - rc.yBottom);
2770 } 2770 }
2771 } 2771 }
2772 break; 2772 break;
2773 } 2773 }
2774 break; 2774 break;
2775 case WM_CLOSE: 2775 case WM_CLOSE:
2776 if(result == -1) 2776 if(result == -1)
2777 { 2777 {
2778 dw_window_destroy(WinQueryWindow(hWnd, QW_PARENT)); 2778 dw_window_destroy(WinQueryWindow(hWnd, QW_PARENT));
2779 return (MRESULT)TRUE; 2779 return (MRESULT)TRUE;
2780 } 2780 }
2781 break; 2781 break;
2782 case WM_MOUSEMOVE: 2782 case WM_MOUSEMOVE:
2783 { 2783 {
2784 HPOINTER pointer; 2784 HPOINTER pointer;
2785 2785
2786 if((pointer = (HPOINTER)dw_window_get_data(hWnd, "_dw_pointer")) || 2786 if((pointer = (HPOINTER)dw_window_get_data(hWnd, "_dw_pointer")) ||
2787 (pointer = (HPOINTER)dw_window_get_data(_toplevel_window(hWnd), "_dw_pointer"))) 2787 (pointer = (HPOINTER)dw_window_get_data(_toplevel_window(hWnd), "_dw_pointer")))
2788 { 2788 {
2789 WinSetPointer(HWND_DESKTOP, pointer); 2789 WinSetPointer(HWND_DESKTOP, pointer);
2790 return MRFROMSHORT(TRUE); 2790 return MRFROMSHORT(TRUE);
2791 } 2791 }
2792 } 2792 }
2793 return MRFROMSHORT(FALSE); 2793 return MRFROMSHORT(FALSE);
2794 case WM_USER: 2794 case WM_USER:
2795 windowfunc = (void (* API)(void *))mp1; 2795 windowfunc = (void (* API)(void *))mp1;
2796 2796
2797 if(windowfunc) 2797 if(windowfunc)
2798 windowfunc((void *)mp2); 2798 windowfunc((void *)mp2);
2799 break; 2799 break;
2800 case WM_CHAR: 2800 case WM_CHAR:
2801 if(SHORT1FROMMP(mp2) == '\t') 2801 if(SHORT1FROMMP(mp2) == '\t')
2802 { 2802 {
2803 if(CHARMSG(&msg)->fs & KC_SHIFT) 2803 if(CHARMSG(&msg)->fs & KC_SHIFT)
2804 _shift_focus_back(hWnd); 2804 _shift_focus_back(hWnd);
2805 else 2805 else
2806 _shift_focus(hWnd); 2806 _shift_focus(hWnd);
2807 return FALSE; 2807 return FALSE;
2808 } 2808 }
2809 break; 2809 break;
2810 case WM_DESTROY: 2810 case WM_DESTROY:
2811 { 2811 {
2812 HWND parent = WinQueryWindow(hWnd, QW_PARENT); 2812 HWND parent = WinQueryWindow(hWnd, QW_PARENT);
2813 2813
2814 /* Free memory before destroying */ 2814 /* Free memory before destroying */
2815 if(parent && WinWindowFromID(parent, FID_CLIENT) == hWnd) 2815 if(parent && WinWindowFromID(parent, FID_CLIENT) == hWnd)
2816 _free_window_memory(parent); 2816 _free_window_memory(parent);
2817 else 2817 else
2818 _free_window_memory(hWnd); 2818 _free_window_memory(hWnd);
2819 } 2819 }
2820 break; 2820 break;
2821 case WM_MENUEND: 2821 case WM_MENUEND:
2822 /* Delay removing the signal until we've executed 2822 /* Delay removing the signal until we've executed
2823 * the signal handler. 2823 * the signal handler.
2824 */ 2824 */
2825 WinPostMsg(hWnd, WM_USER+2, mp1, mp2); 2825 WinPostMsg(hWnd, WM_USER+2, mp1, mp2);
2826 break; 2826 break;
2827 case WM_USER+2: 2827 case WM_USER+2:
2828 _clear_emphasis(); 2828 _clear_emphasis();
2829 if(dw_window_get_data((HWND)mp2, "_dw_popup")) 2829 if(dw_window_get_data((HWND)mp2, "_dw_popup"))
2830 _free_menu_data((HWND)mp2); 2830 _free_menu_data((HWND)mp2);
2831 break; 2831 break;
2832 } 2832 }
2833 2833
2834 if(result != -1) 2834 if(result != -1)
2835 return (MRESULT)result; 2835 return (MRESULT)result;
2836 else 2836 else
2837 return WinDefWindowProc(hWnd, msg, mp1, mp2); 2837 return WinDefWindowProc(hWnd, msg, mp1, mp2);
2838 } 2838 }
2839 2839
2840 void _changebox(Box *thisbox, int percent, int type) 2840 void _changebox(Box *thisbox, int percent, int type)
2841 { 2841 {
2842 int z; 2842 int z;
2843 2843
2844 for(z=0;z<thisbox->count;z++) 2844 for(z=0;z<thisbox->count;z++)
2845 { 2845 {
2846 if(thisbox->items[z].type == TYPEBOX) 2846 if(thisbox->items[z].type == TYPEBOX)
2847 { 2847 {
2848 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); 2848 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER);
2849 _changebox(tmp, percent, type); 2849 _changebox(tmp, percent, type);
2850 } 2850 }
2851 else 2851 else
2852 { 2852 {
2853 if(type == DW_HORZ) 2853 if(type == DW_HORZ)
2854 { 2854 {
2855 if(thisbox->items[z].hsize == SIZEEXPAND) 2855 if(thisbox->items[z].hsize == SIZEEXPAND)
2856 thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0))); 2856 thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0)));
2857 } 2857 }
2858 else 2858 else
2859 { 2859 {
2860 if(thisbox->items[z].vsize == SIZEEXPAND) 2860 if(thisbox->items[z].vsize == SIZEEXPAND)
2861 thisbox->items[z].height = (int)(((float)thisbox->items[z].origheight) * (((float)percent)/((float)100.0))); 2861 thisbox->items[z].height = (int)(((float)thisbox->items[z].origheight) * (((float)percent)/((float)100.0)));
2862 } 2862 }
2863 } 2863 }
2864 } 2864 }
2865 } 2865 }
2866 2866
2867 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y) 2867 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y)
2868 { 2868 {
2869 float ratio = (float)percent/(float)100.0; 2869 float ratio = (float)percent/(float)100.0;
2870 HWND handle1 = (HWND)dw_window_get_data(hwnd, "_dw_topleft"); 2870 HWND handle1 = (HWND)dw_window_get_data(hwnd, "_dw_topleft");
2871 HWND handle2 = (HWND)dw_window_get_data(hwnd, "_dw_bottomright"); 2871 HWND handle2 = (HWND)dw_window_get_data(hwnd, "_dw_bottomright");
2872 Box *tmp = WinQueryWindowPtr(handle1, QWP_USER); 2872 Box *tmp = WinQueryWindowPtr(handle1, QWP_USER);
2873 2873
2874 WinShowWindow(handle1, FALSE); 2874 WinShowWindow(handle1, FALSE);
2875 WinShowWindow(handle2, FALSE); 2875 WinShowWindow(handle2, FALSE);
2876 2876
2877 if(type == DW_HORZ) 2877 if(type == DW_HORZ)
2878 { 2878 {
2879 int newx = (int)((float)x * ratio) - (SPLITBAR_WIDTH/2); 2879 int newx = (int)((float)x * ratio) - (SPLITBAR_WIDTH/2);
2880 2880
2881 WinSetWindowPos(handle1, NULLHANDLE, 0, 0, newx, y, SWP_MOVE | SWP_SIZE); 2881 WinSetWindowPos(handle1, NULLHANDLE, 0, 0, newx, y, SWP_MOVE | SWP_SIZE);
2882 _do_resize(tmp, newx - 1, y - 1); 2882 _do_resize(tmp, newx - 1, y - 1);
2883 2883
2884 dw_window_set_data(hwnd, "_dw_start", (void *)newx); 2884 dw_window_set_data(hwnd, "_dw_start", (void *)newx);
2885 2885
2886 tmp = WinQueryWindowPtr(handle2, QWP_USER); 2886 tmp = WinQueryWindowPtr(handle2, QWP_USER);
2887 2887
2888 newx = x - newx - SPLITBAR_WIDTH; 2888 newx = x - newx - SPLITBAR_WIDTH;
2889 2889
2890 WinSetWindowPos(handle2, NULLHANDLE, x - newx, 0, newx, y, SWP_MOVE | SWP_SIZE); 2890 WinSetWindowPos(handle2, NULLHANDLE, x - newx, 0, newx, y, SWP_MOVE | SWP_SIZE);
2891 _do_resize(tmp, newx - 1, y - 1); 2891 _do_resize(tmp, newx - 1, y - 1);
2892 } 2892 }
2893 else 2893 else
2894 { 2894 {
2895 int newy = (int)((float)y * ratio) - (SPLITBAR_WIDTH/2); 2895 int newy = (int)((float)y * ratio) - (SPLITBAR_WIDTH/2);
2896 2896
2897 WinSetWindowPos(handle1, NULLHANDLE, 0, y - newy, x, newy, SWP_MOVE | SWP_SIZE); 2897 WinSetWindowPos(handle1, NULLHANDLE, 0, y - newy, x, newy, SWP_MOVE | SWP_SIZE);
2898 _do_resize(tmp, x - 1, newy - 1); 2898 _do_resize(tmp, x - 1, newy - 1);
2899 2899
2900 tmp = WinQueryWindowPtr(handle2, QWP_USER); 2900 tmp = WinQueryWindowPtr(handle2, QWP_USER);
2901 2901
2902 newy = y - newy - SPLITBAR_WIDTH; 2902 newy = y - newy - SPLITBAR_WIDTH;
2903 2903
2904 WinSetWindowPos(handle2, NULLHANDLE, 0, 0, x, newy, SWP_MOVE | SWP_SIZE); 2904 WinSetWindowPos(handle2, NULLHANDLE, 0, 0, x, newy, SWP_MOVE | SWP_SIZE);
2905 _do_resize(tmp, x - 1, newy - 1); 2905 _do_resize(tmp, x - 1, newy - 1);
2906 2906
2907 dw_window_set_data(hwnd, "_dw_start", (void *)newy); 2907 dw_window_set_data(hwnd, "_dw_start", (void *)newy);
2908 } 2908 }
2909 2909
2910 WinShowWindow(handle1, TRUE); 2910 WinShowWindow(handle1, TRUE);
2911 WinShowWindow(handle2, TRUE); 2911 WinShowWindow(handle2, TRUE);
2912 } 2912 }
2913 2913
2914 2914
2915 /* This handles any activity on the splitbars (sizers) */ 2915 /* This handles any activity on the splitbars (sizers) */
2916 MRESULT EXPENTRY _splitwndproc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 2916 MRESULT EXPENTRY _splitwndproc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
2917 { 2917 {
2918 switch (msg) 2918 switch (msg)
2919 { 2919 {
2920 case WM_ACTIVATE: 2920 case WM_ACTIVATE:
2921 case WM_SETFOCUS: 2921 case WM_SETFOCUS:
2922 return (MRESULT)(FALSE); 2922 return (MRESULT)(FALSE);
2923 2923
2924 case WM_PAINT: 2924 case WM_PAINT:
2925 { 2925 {
2926 HPS hps; 2926 HPS hps;
2927 POINTL ptl[2]; 2927 POINTL ptl[2];
2928 RECTL rcl; 2928 RECTL rcl;
2929 int type = (int)dw_window_get_data(hwnd, "_dw_type"); 2929 int type = (int)dw_window_get_data(hwnd, "_dw_type");
2930 int start = (int)dw_window_get_data(hwnd, "_dw_start"); 2930 int start = (int)dw_window_get_data(hwnd, "_dw_start");
2931 2931
2932 hps = WinBeginPaint(hwnd, 0, 0); 2932 hps = WinBeginPaint(hwnd, 0, 0);
2933 2933
2934 WinQueryWindowRect(hwnd, &rcl); 2934 WinQueryWindowRect(hwnd, &rcl);
2935 2935
2936 if(type == DW_HORZ) 2936 if(type == DW_HORZ)
2937 { 2937 {
2938 ptl[0].x = rcl.xLeft + start; 2938 ptl[0].x = rcl.xLeft + start;
2939 ptl[0].y = rcl.yBottom; 2939 ptl[0].y = rcl.yBottom;
2940 ptl[1].x = rcl.xRight + start + 3; 2940 ptl[1].x = rcl.xRight + start + 3;
2941 ptl[1].y = rcl.yTop; 2941 ptl[1].y = rcl.yTop;
2942 } 2942 }
2943 else 2943 else
2944 { 2944 {
2945 ptl[0].x = rcl.xLeft; 2945 ptl[0].x = rcl.xLeft;
2946 ptl[0].y = rcl.yBottom + start; 2946 ptl[0].y = rcl.yBottom + start;
2947 ptl[1].x = rcl.xRight; 2947 ptl[1].x = rcl.xRight;
2948 ptl[1].y = rcl.yTop + start + 3; 2948 ptl[1].y = rcl.yTop + start + 3;
2949 } 2949 }
2950 2950
2951 2951
2952 GpiSetColor(hps, CLR_PALEGRAY); 2952 GpiSetColor(hps, CLR_PALEGRAY);
2953 GpiMove(hps, &ptl[0]); 2953 GpiMove(hps, &ptl[0]);
2954 GpiBox(hps, DRO_OUTLINEFILL, &ptl[1], 0, 0); 2954 GpiBox(hps, DRO_OUTLINEFILL, &ptl[1], 0, 0);
2955 WinEndPaint(hps); 2955 WinEndPaint(hps);
2956 } 2956 }
2957 return MRFROMSHORT(FALSE); 2957 return MRFROMSHORT(FALSE);
2958 2958
2959 case WM_MOUSEMOVE: 2959 case WM_MOUSEMOVE:
2960 { 2960 {
2961 int type = (int)dw_window_get_data(hwnd, "_dw_type"); 2961 int type = (int)dw_window_get_data(hwnd, "_dw_type");
2962 2962
2963 if(type == DW_HORZ) 2963 if(type == DW_HORZ)
2964 WinSetPointer(HWND_DESKTOP, 2964 WinSetPointer(HWND_DESKTOP,
2965 WinQuerySysPointer(HWND_DESKTOP, 2965 WinQuerySysPointer(HWND_DESKTOP,
2966 SPTR_SIZEWE, 2966 SPTR_SIZEWE,
2967 FALSE)); 2967 FALSE));
2968 else 2968 else
2969 WinSetPointer(HWND_DESKTOP, 2969 WinSetPointer(HWND_DESKTOP,
2970 WinQuerySysPointer(HWND_DESKTOP, 2970 WinQuerySysPointer(HWND_DESKTOP,
2971 SPTR_SIZENS, 2971 SPTR_SIZENS,
2972 FALSE)); 2972 FALSE));
2973 } 2973 }
2974 return MRFROMSHORT(FALSE); 2974 return MRFROMSHORT(FALSE);
2975 case WM_BUTTON1DOWN: 2975 case WM_BUTTON1DOWN:
2976 { 2976 {
2977 APIRET rc; 2977 APIRET rc;
2978 RECTL rclFrame; 2978 RECTL rclFrame;
2979 RECTL rclBounds; 2979 RECTL rclBounds;
2980 float *percent = (float *)dw_window_get_data(hwnd, "_dw_percent"); 2980 float *percent = (float *)dw_window_get_data(hwnd, "_dw_percent");
2981 int type = (int)dw_window_get_data(hwnd, "_dw_type"); 2981 int type = (int)dw_window_get_data(hwnd, "_dw_type");
2982 int start = (int)dw_window_get_data(hwnd, "_dw_start"); 2982 int start = (int)dw_window_get_data(hwnd, "_dw_start");
2983 2983
2984 WinQueryWindowRect(hwnd, &rclFrame); 2984 WinQueryWindowRect(hwnd, &rclFrame);
2985 WinQueryWindowRect(hwnd, &rclBounds); 2985 WinQueryWindowRect(hwnd, &rclBounds);
2986 2986
2987 WinMapWindowPoints(hwnd, HWND_DESKTOP, 2987 WinMapWindowPoints(hwnd, HWND_DESKTOP,
2988 (PPOINTL)&rclBounds, 2); 2988 (PPOINTL)&rclBounds, 2);
2989 2989
2990 2990
2991 if(type == DW_HORZ) 2991 if(type == DW_HORZ)
2992 { 2992 {
2993 rclFrame.xLeft = start; 2993 rclFrame.xLeft = start;
2994 rclFrame.xRight = start + SPLITBAR_WIDTH; 2994 rclFrame.xRight = start + SPLITBAR_WIDTH;
2995 } 2995 }
2996 else 2996 else
2997 { 2997 {
2998 rclFrame.yBottom = start; 2998 rclFrame.yBottom = start;
2999 rclFrame.yTop = start + SPLITBAR_WIDTH; 2999 rclFrame.yTop = start + SPLITBAR_WIDTH;
3000 } 3000 }
3001 3001
3002 if(percent) 3002 if(percent)
3003 { 3003 {
3004 rc = _TrackRectangle(hwnd, &rclFrame, &rclBounds); 3004 rc = _TrackRectangle(hwnd, &rclFrame, &rclBounds);
3005 3005
3006 if(rc == TRUE) 3006 if(rc == TRUE)
3007 { 3007 {
3008 int width = (rclBounds.xRight - rclBounds.xLeft); 3008 int width = (rclBounds.xRight - rclBounds.xLeft);
3009 int height = (rclBounds.yTop - rclBounds.yBottom); 3009 int height = (rclBounds.yTop - rclBounds.yBottom);
3010 3010
3011 if(type == DW_HORZ) 3011 if(type == DW_HORZ)
3012 { 3012 {
3013 start = rclFrame.xLeft - rclBounds.xLeft; 3013 start = rclFrame.xLeft - rclBounds.xLeft;
3014 if(width - SPLITBAR_WIDTH > 1 && start < width - SPLITBAR_WIDTH) 3014 if(width - SPLITBAR_WIDTH > 1 && start < width - SPLITBAR_WIDTH)
3015 *percent = ((float)start / (float)(width - SPLITBAR_WIDTH)) * 100.0; 3015 *percent = ((float)start / (float)(width - SPLITBAR_WIDTH)) * 100.0;
3016 } 3016 }
3017 else 3017 else
3018 { 3018 {
3019 start = rclFrame.yBottom - rclBounds.yBottom; 3019 start = rclFrame.yBottom - rclBounds.yBottom;
3020 if(height - SPLITBAR_WIDTH > 1 && start < height - SPLITBAR_WIDTH) 3020 if(height - SPLITBAR_WIDTH > 1 && start < height - SPLITBAR_WIDTH)
3021 *percent = 100.0 - (((float)start / (float)(height - SPLITBAR_WIDTH)) * 100.0); 3021 *percent = 100.0 - (((float)start / (float)(height - SPLITBAR_WIDTH)) * 100.0);
3022 } 3022 }
3023 _handle_splitbar_resize(hwnd, *percent, type, width, height); 3023 _handle_splitbar_resize(hwnd, *percent, type, width, height);
3024 _handle_splitbar_resize(hwnd, *percent, type, width, height); 3024 _handle_splitbar_resize(hwnd, *percent, type, width, height);
3025 } 3025 }
3026 } 3026 }
3027 } 3027 }
3028 return MRFROMSHORT(FALSE); 3028 return MRFROMSHORT(FALSE);
3029 } 3029 }
3030 return WinDefWindowProc(hwnd, msg, mp1, mp2); 3030 return WinDefWindowProc(hwnd, msg, mp1, mp2);
3031 } 3031 }
3032 3032
3033 /* Function: BubbleProc 3033 /* Function: BubbleProc
3034 * Abstract: Subclass procedure for bubble help 3034 * Abstract: Subclass procedure for bubble help
3035 */ 3035 */
3036 MRESULT EXPENTRY _BubbleProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 3036 MRESULT EXPENTRY _BubbleProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
3037 { 3037 {
3038 MRESULT res; 3038 MRESULT res;
3039 PFNWP proc = (PFNWP)WinQueryWindowPtr(hwnd, QWL_USER); 3039 PFNWP proc = (PFNWP)WinQueryWindowPtr(hwnd, QWL_USER);
3040 3040
3041 if(proc) 3041 if(proc)
3042 res = proc(hwnd, msg, mp1, mp2); 3042 res = proc(hwnd, msg, mp1, mp2);
3043 else 3043 else
3044 res = WinDefWindowProc(hwnd, msg, mp1, mp2); 3044 res = WinDefWindowProc(hwnd, msg, mp1, mp2);
3045 3045
3046 if(msg == WM_PAINT) 3046 if(msg == WM_PAINT)
3047 { 3047 {
3048 POINTL ptl; 3048 POINTL ptl;
3049 HPS hpsTemp; 3049 HPS hpsTemp;
3050 RECTL rcl; 3050 RECTL rcl;
3051 int height, width; 3051 int height, width;
3052 3052
3053 WinQueryWindowRect(hwnd, &rcl); 3053 WinQueryWindowRect(hwnd, &rcl);
3054 height = rcl.yTop - rcl.yBottom - 1; 3054 height = rcl.yTop - rcl.yBottom - 1;
3055 width = rcl.xRight - rcl.xLeft - 1; 3055 width = rcl.xRight - rcl.xLeft - 1;
3056 3056
3057 /* Draw a border around the bubble help */ 3057 /* Draw a border around the bubble help */
3058 hpsTemp = WinGetPS(hwnd); 3058 hpsTemp = WinGetPS(hwnd);
3059 GpiSetColor(hpsTemp, CLR_BLACK); 3059 GpiSetColor(hpsTemp, CLR_BLACK);
3060 ptl.x = ptl.y = 0; 3060 ptl.x = ptl.y = 0;
3061 GpiMove(hpsTemp, &ptl); 3061 GpiMove(hpsTemp, &ptl);
3062 ptl.x = 0; 3062 ptl.x = 0;
3063 ptl.y = height; 3063 ptl.y = height;
3064 GpiLine(hpsTemp, &ptl); 3064 GpiLine(hpsTemp, &ptl);
3065 ptl.x = ptl.y = 0; 3065 ptl.x = ptl.y = 0;
3066 GpiMove(hpsTemp, &ptl); 3066 GpiMove(hpsTemp, &ptl);
3067 ptl.y = 0; 3067 ptl.y = 0;
3068 ptl.x = width; 3068 ptl.x = width;
3069 GpiLine(hpsTemp, &ptl); 3069 GpiLine(hpsTemp, &ptl);
3070 ptl.x = width; 3070 ptl.x = width;
3071 ptl.y = height; 3071 ptl.y = height;
3072 GpiMove(hpsTemp, &ptl); 3072 GpiMove(hpsTemp, &ptl);
3073 ptl.x = 0; 3073 ptl.x = 0;
3074 ptl.y = height; 3074 ptl.y = height;
3075 GpiLine(hpsTemp, &ptl); 3075 GpiLine(hpsTemp, &ptl);
3076 ptl.x = width; 3076 ptl.x = width;
3077 ptl.y = height; 3077 ptl.y = height;
3078 GpiMove(hpsTemp, &ptl); 3078 GpiMove(hpsTemp, &ptl);
3079 ptl.y = 0; 3079 ptl.y = 0;
3080 ptl.x = width; 3080 ptl.x = width;
3081 GpiLine(hpsTemp, &ptl); 3081 GpiLine(hpsTemp, &ptl);
3082 WinReleasePS(hpsTemp); 3082 WinReleasePS(hpsTemp);
3083 } 3083 }
3084 return res; 3084 return res;
3085 } 3085 }
3086 3086
3087 MRESULT EXPENTRY _button_draw(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, PFNWP oldproc, int indent) 3087 MRESULT EXPENTRY _button_draw(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, PFNWP oldproc, int indent)
3088 { 3088 {
3089 HPIXMAP pixmap = (HPIXMAP)dw_window_get_data(hwnd, "_dw_hpixmap"); 3089 HPIXMAP pixmap = (HPIXMAP)dw_window_get_data(hwnd, "_dw_hpixmap");
3090 HPIXMAP disable = (HPIXMAP)dw_window_get_data(hwnd, "_dw_hpixmap_disabled"); 3090 HPIXMAP disable = (HPIXMAP)dw_window_get_data(hwnd, "_dw_hpixmap_disabled");
3091 HPOINTER icon = (HPOINTER)dw_window_get_data(hwnd, "_dw_button_icon"); 3091 HPOINTER icon = (HPOINTER)dw_window_get_data(hwnd, "_dw_button_icon");
3092 MRESULT res; 3092 MRESULT res;
3093 unsigned long width, height; 3093 unsigned long width, height;
3094 int x = 5, y = 5; 3094 int x = 5, y = 5;
3095 3095
3096 dw_window_get_pos_size(hwnd, NULL, NULL, &width, &height); 3096 dw_window_get_pos_size(hwnd, NULL, NULL, &width, &height);
3097 3097
3098 if(!oldproc) 3098 if(!oldproc)
3099 res = WinDefWindowProc(hwnd, msg, mp1, mp2); 3099 res = WinDefWindowProc(hwnd, msg, mp1, mp2);
3100 res = oldproc(hwnd, msg, mp1, mp2); 3100 res = oldproc(hwnd, msg, mp1, mp2);
3101 3101
3102 if(icon) 3102 if(icon)
3103 { 3103 {
3104 ULONG halftone = DP_NORMAL; 3104 ULONG halftone = DP_NORMAL;
3105 HPS hps = WinGetPS(hwnd); 3105 HPS hps = WinGetPS(hwnd);
3106 POINTERINFO pi; 3106 POINTERINFO pi;
3107 int cx, cy; 3107 int cx, cy;
3108 3108
3109 if(dw_window_get_data(hwnd, "_dw_disabled")) 3109 if(dw_window_get_data(hwnd, "_dw_disabled"))
3110 halftone = DP_HALFTONED; 3110 halftone = DP_HALFTONED;
3111 3111
3112 cx = width - 10; 3112 cx = width - 10;
3113 cy = height - 10; 3113 cy = height - 10;
3114 3114
3115 if(WinQueryPointerInfo(icon, &pi)) 3115 if(WinQueryPointerInfo(icon, &pi))
3116 { 3116 {
3117 BITMAPINFOHEADER sl; 3117 BITMAPINFOHEADER sl;
3118 int newcx = cx, newcy = cy; 3118 int newcx = cx, newcy = cy;
3119 3119
3120 /* Check the mini icon first */ 3120 /* Check the mini icon first */
3121 if(GpiQueryBitmapParameters(pi.hbmMiniColor, &sl)) 3121 if(GpiQueryBitmapParameters(pi.hbmMiniColor, &sl))
3122 { 3122 {
3123 if(sl.cx && sl.cy && cx > sl.cx && cy > sl.cy) 3123 if(sl.cx && sl.cy && cx > sl.cx && cy > sl.cy)
3124 { 3124 {
3125 newcx = sl.cx; 3125 newcx = sl.cx;
3126 newcy = sl.cy; 3126 newcy = sl.cy;
3127 } 3127 }
3128 } 3128 }
3129 /* Check the normal icon second */ 3129 /* Check the normal icon second */
3130 if(GpiQueryBitmapParameters(pi.hbmColor, &sl)) 3130 if(GpiQueryBitmapParameters(pi.hbmColor, &sl))
3131 { 3131 {
3132 if(sl.cx && sl.cy && cx > sl.cx && cy > sl.cy) 3132 if(sl.cx && sl.cy && cx > sl.cx && cy > sl.cy)
3133 { 3133 {
3134 newcx = sl.cx; 3134 newcx = sl.cx;
3135 newcy = sl.cy; 3135 newcy = sl.cy;
3136 } 3136 }
3137 } 3137 }
3138 cx = newcx; cy = newcy; 3138 cx = newcx; cy = newcy;
3139 x = (width - cx)/2; 3139 x = (width - cx)/2;
3140 y = (height - cy)/2; 3140 y = (height - cy)/2;
3141 } 3141 }
3142 WinStretchPointer(hps, x + indent, y - indent, cx, cy, icon, halftone); 3142 WinStretchPointer(hps, x + indent, y - indent, cx, cy, icon, halftone);
3143 WinReleasePS(hps); 3143 WinReleasePS(hps);
3144 } 3144 }
3145 else if(pixmap) 3145 else if(pixmap)
3146 { 3146 {
3147 x = (width - pixmap->width)/2; 3147 x = (width - pixmap->width)/2;
3148 y = (height - pixmap->height)/2; 3148 y = (height - pixmap->height)/2;
3149 3149
3150 if(disable && dw_window_get_data(hwnd, "_dw_disabled")) 3150 if(disable && dw_window_get_data(hwnd, "_dw_disabled"))
3151 dw_pixmap_bitblt(hwnd, 0, x + indent, y + indent, pixmap->width, pixmap->height, 0, disable, 0, 0); 3151 dw_pixmap_bitblt(hwnd, 0, x + indent, y + indent, pixmap->width, pixmap->height, 0, disable, 0, 0);
3152 else 3152 else
3153 dw_pixmap_bitblt(hwnd, 0, x + indent, y + indent, pixmap->width, pixmap->height, 0, pixmap, 0, 0); 3153 dw_pixmap_bitblt(hwnd, 0, x + indent, y + indent, pixmap->width, pixmap->height, 0, pixmap, 0, 0);
3154 } 3154 }
3155 return res; 3155 return res;
3156 } 3156 }
3157 3157
3158 /* Function: BtProc 3158 /* Function: BtProc
3159 * Abstract: Subclass procedure for buttons 3159 * Abstract: Subclass procedure for buttons
3160 */ 3160 */
3161 3161
3162 MRESULT EXPENTRY _BtProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 3162 MRESULT EXPENTRY _BtProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
3163 { 3163 {
3164 BubbleButton *bubble; 3164 BubbleButton *bubble;
3165 PFNWP oldproc; 3165 PFNWP oldproc;
3166 3166
3167 bubble = (BubbleButton *)WinQueryWindowPtr(hwnd, QWL_USER); 3167 bubble = (BubbleButton *)WinQueryWindowPtr(hwnd, QWL_USER);
3168 3168
3169 if(!bubble) 3169 if(!bubble)
3170 return WinDefWindowProc(hwnd, msg, mp1, mp2); 3170 return WinDefWindowProc(hwnd, msg, mp1, mp2);
3171 3171
3172 oldproc = bubble->pOldProc; 3172 oldproc = bubble->pOldProc;
3173 3173
3174 switch(msg) 3174 switch(msg)
3175 { 3175 {
3176 case WM_MOUSEMOVE: 3176 case WM_MOUSEMOVE:
3177 if(_wndproc(hwnd, msg, mp1, mp2)) 3177 if(_wndproc(hwnd, msg, mp1, mp2))
3178 return MPFROMSHORT(FALSE); 3178 return MPFROMSHORT(FALSE);
3179 break; 3179 break;
3180 case WM_PAINT: 3180 case WM_PAINT:
3181 return _button_draw(hwnd, msg, mp1, mp2, oldproc, 0); 3181 return _button_draw(hwnd, msg, mp1, mp2, oldproc, 0);
3182 case BM_SETHILITE: 3182 case BM_SETHILITE:
3183 return _button_draw(hwnd, msg, mp1, mp2, oldproc, (int)mp1); 3183 return _button_draw(hwnd, msg, mp1, mp2, oldproc, (int)mp1);
3184 case WM_SETFOCUS: 3184 case WM_SETFOCUS:
3185 if(mp2) 3185 if(mp2)
3186 _run_event(hwnd, msg, mp1, mp2); 3186 _run_event(hwnd, msg, mp1, mp2);
3187 else 3187 else
3188 WinSendMsg(hwnd, BM_SETDEFAULT, 0, 0); 3188 WinSendMsg(hwnd, BM_SETDEFAULT, 0, 0);
3189 break; 3189 break;
3190 case WM_BUTTON1DOWN: 3190 case WM_BUTTON1DOWN:
3191 case WM_BUTTON2DOWN: 3191 case WM_BUTTON2DOWN:
3192 case WM_BUTTON3DOWN: 3192 case WM_BUTTON3DOWN:
3193 case WM_BUTTON1DBLCLK: 3193 case WM_BUTTON1DBLCLK:
3194 case WM_BUTTON2DBLCLK: 3194 case WM_BUTTON2DBLCLK:
3195 case WM_BUTTON3DBLCLK: 3195 case WM_BUTTON3DBLCLK:
3196 if(dw_window_get_data(hwnd, "_dw_disabled")) 3196 if(dw_window_get_data(hwnd, "_dw_disabled"))
3197 return (MRESULT)FALSE; 3197 return (MRESULT)FALSE;
3198 break; 3198 break;
3199 case WM_BUTTON1UP: 3199 case WM_BUTTON1UP:
3200 { 3200 {
3201 SignalHandler *tmp = Root; 3201 SignalHandler *tmp = Root;
3202 3202
3203 if(WinIsWindowEnabled(hwnd) && !dw_window_get_data(hwnd, "_dw_disabled")) 3203 if(WinIsWindowEnabled(hwnd) && !dw_window_get_data(hwnd, "_dw_disabled"))
3204 { 3204 {
3205 /* Find any callbacks for this function */ 3205 /* Find any callbacks for this function */
3206 while(tmp) 3206 while(tmp)
3207 { 3207 {
3208 if(tmp->message == WM_COMMAND) 3208 if(tmp->message == WM_COMMAND)
3209 { 3209 {
3210 /* Make sure it's the right window, and the right ID */ 3210 /* Make sure it's the right window, and the right ID */
3211 if(tmp->window == hwnd) 3211 if(tmp->window == hwnd)
3212 { 3212 {
3213 /* Due to the fact that if we run the function 3213 /* Due to the fact that if we run the function
3214 * here, finishing actions on the button will occur 3214 * here, finishing actions on the button will occur
3215 * after we run the signal handler. So we post the 3215 * after we run the signal handler. So we post the
3216 * message so the button can finish what it needs to 3216 * message so the button can finish what it needs to
3217 * do before we run our handler. 3217 * do before we run our handler.
3218 */ 3218 */
3219 WinPostMsg(hwnd, WM_USER, (MPARAM)tmp, 0); 3219 WinPostMsg(hwnd, WM_USER, (MPARAM)tmp, 0);
3220 tmp = NULL; 3220 tmp = NULL;
3221 } 3221 }
3222 } 3222 }
3223 if(tmp) 3223 if(tmp)
3224 tmp= tmp->next; 3224 tmp= tmp->next;
3225 } 3225 }
3226 } 3226 }
3227 } 3227 }
3228 break; 3228 break;
3229 case WM_USER: 3229 case WM_USER:
3230 { 3230 {
3231 SignalHandler *tmp = (SignalHandler *)mp1; 3231 SignalHandler *tmp = (SignalHandler *)mp1;
3232 int (* API clickfunc)(HWND, void *) = NULL; 3232 int (* API clickfunc)(HWND, void *) = NULL;
3233 3233
3234 if(tmp) 3234 if(tmp)
3235 { 3235 {
3236 clickfunc = (int (* API)(HWND, void *))tmp->signalfunction; 3236 clickfunc = (int (* API)(HWND, void *))tmp->signalfunction;
3237 3237
3238 clickfunc(tmp->window, tmp->data); 3238 clickfunc(tmp->window, tmp->data);
3239 } 3239 }
3240 } 3240 }
3241 break; 3241 break;
3242 case WM_CHAR: 3242 case WM_CHAR:
3243 { 3243 {
3244 /* A button press should also occur for an ENTER or SPACE press 3244 /* A button press should also occur for an ENTER or SPACE press
3245 * while the button has the active input focus. 3245 * while the button has the active input focus.
3246 */ 3246 */
3247 if(SHORT1FROMMP(mp2) == '\r' || SHORT1FROMMP(mp2) == ' ') 3247 if(SHORT1FROMMP(mp2) == '\r' || SHORT1FROMMP(mp2) == ' ')
3248 { 3248 {
3249 SignalHandler *tmp = Root; 3249 SignalHandler *tmp = Root;
3250 3250
3251 /* Find any callbacks for this function */ 3251 /* Find any callbacks for this function */
3252 while(tmp) 3252 while(tmp)
3253 { 3253 {
3254 if(tmp->message == WM_COMMAND) 3254 if(tmp->message == WM_COMMAND)
3255 { 3255 {
3256 /* Make sure it's the right window, and the right ID */ 3256 /* Make sure it's the right window, and the right ID */
3257 if(tmp->window == hwnd) 3257 if(tmp->window == hwnd)
3258 { 3258 {
3259 WinPostMsg(hwnd, WM_USER, (MPARAM)tmp, 0); 3259 WinPostMsg(hwnd, WM_USER, (MPARAM)tmp, 0);
3260 tmp = NULL; 3260 tmp = NULL;
3261 } 3261 }
3262 } 3262 }
3263 if(tmp) 3263 if(tmp)
3264 tmp= tmp->next; 3264 tmp= tmp->next;
3265 } 3265 }
3266 } 3266 }
3267 if(SHORT1FROMMP(mp2) == '\t') 3267 if(SHORT1FROMMP(mp2) == '\t')
3268 { 3268 {
3269 if(CHARMSG(&msg)->fs & KC_SHIFT) 3269 if(CHARMSG(&msg)->fs & KC_SHIFT)
3270 _shift_focus_back(hwnd); 3270 _shift_focus_back(hwnd);
3271 else 3271 else
3272 _shift_focus(hwnd); 3272 _shift_focus(hwnd);
3273 WinSendMsg(hwnd, BM_SETDEFAULT, 0, 0); 3273 WinSendMsg(hwnd, BM_SETDEFAULT, 0, 0);
3274 return FALSE; 3274 return FALSE;
3275 } 3275 }
3276 else if(!(CHARMSG(&msg)->fs & KC_KEYUP) && (CHARMSG(&msg)->vkey == VK_LEFT || CHARMSG(&msg)->vkey == VK_UP)) 3276 else if(!(CHARMSG(&msg)->fs & KC_KEYUP) && (CHARMSG(&msg)->vkey == VK_LEFT || CHARMSG(&msg)->vkey == VK_UP))
3277 { 3277 {
3278 _shift_focus_back(hwnd); 3278 _shift_focus_back(hwnd);
3279 return FALSE; 3279 return FALSE;
3280 } 3280 }
3281 else if(!(CHARMSG(&msg)->fs & KC_KEYUP) && (CHARMSG(&msg)->vkey == VK_RIGHT || CHARMSG(&msg)->vkey == VK_DOWN)) 3281 else if(!(CHARMSG(&msg)->fs & KC_KEYUP) && (CHARMSG(&msg)->vkey == VK_RIGHT || CHARMSG(&msg)->vkey == VK_DOWN))
3282 { 3282 {
3283 _shift_focus(hwnd); 3283 _shift_focus(hwnd);
3284 return FALSE; 3284 return FALSE;
3285 } 3285 }
3286 } 3286 }
3287 break; 3287 break;
3288 case 0x041f: 3288 case 0x041f:
3289 if (hwndBubble) 3289 if (hwndBubble)
3290 { 3290 {
3291 WinDestroyWindow(hwndBubble); 3291 WinDestroyWindow(hwndBubble);
3292 hwndBubble = 0; 3292 hwndBubble = 0;
3293 } 3293 }
3294 break; 3294 break;
3295 3295
3296 case 0x041e: 3296 case 0x041e:
3297 3297
3298 if(!*bubble->bubbletext) 3298 if(!*bubble->bubbletext)
3299 break; 3299 break;
3300 3300
3301 if(hwndBubble) 3301 if(hwndBubble)
3302 { 3302 {
3303 WinDestroyWindow(hwndBubble); 3303 WinDestroyWindow(hwndBubble);
3304 hwndBubble = 0; 3304 hwndBubble = 0;
3305 } 3305 }
3306 3306
3307 if(!hwndBubble) 3307 if(!hwndBubble)
3308 { 3308 {
3309 HPS hpsTemp = 0; 3309 HPS hpsTemp = 0;
3310 LONG lHight; 3310 LONG lHight;
3311 LONG lWidth; 3311 LONG lWidth;
3312 POINTL txtPointl[TXTBOX_COUNT]; 3312 POINTL txtPointl[TXTBOX_COUNT];
3313 POINTL ptlWork = {0,0}; 3313 POINTL ptlWork = {0,0};
3314 ULONG ulColor = CLR_YELLOW; 3314 ULONG ulColor = CLR_YELLOW;
3315 void *blah; 3315 void *blah;
3316 3316
3317 hwndBubbleLast = hwnd; 3317 hwndBubbleLast = hwnd;
3318 hwndBubble = WinCreateWindow(HWND_DESKTOP, 3318 hwndBubble = WinCreateWindow(HWND_DESKTOP,
3319 WC_STATIC, 3319 WC_STATIC,
3320 "", 3320 "",
3321 SS_TEXT | 3321 SS_TEXT |
3322 DT_CENTER | 3322 DT_CENTER |
3323 DT_VCENTER, 3323 DT_VCENTER,
3324 0,0,0,0, 3324 0,0,0,0,
3325 HWND_DESKTOP, 3325 HWND_DESKTOP,
3326 HWND_TOP, 3326 HWND_TOP,
3327 0, 3327 0,
3328 NULL, 3328 NULL,
3329 NULL); 3329 NULL);
3330 3330
3331 WinSetPresParam(hwndBubble, 3331 WinSetPresParam(hwndBubble,
3332 PP_FONTNAMESIZE, 3332 PP_FONTNAMESIZE,
3333 strlen(DefaultFont)+1, 3333 strlen(DefaultFont)+1,
3334 DefaultFont); 3334 DefaultFont);
3335 3335
3336 3336
3337 WinSetPresParam(hwndBubble, 3337 WinSetPresParam(hwndBubble,
3338 PP_BACKGROUNDCOLORINDEX, 3338 PP_BACKGROUNDCOLORINDEX,
3339 sizeof(ulColor), 3339 sizeof(ulColor),
3340 &ulColor); 3340 &ulColor);
3341 3341
3342 WinSetWindowText(hwndBubble, 3342 WinSetWindowText(hwndBubble,
3343 bubble->bubbletext); 3343 bubble->bubbletext);
3344 3344
3345 WinMapWindowPoints(hwnd, HWND_DESKTOP, &ptlWork, 1); 3345 WinMapWindowPoints(hwnd, HWND_DESKTOP, &ptlWork, 1);
3346 3346
3347 hpsTemp = WinGetPS(hwndBubble); 3347 hpsTemp = WinGetPS(hwndBubble);
3348 GpiQueryTextBox(hpsTemp, 3348 GpiQueryTextBox(hpsTemp,
3349 strlen(bubble->bubbletext), 3349 strlen(bubble->bubbletext),
3350 bubble->bubbletext, 3350 bubble->bubbletext,
3351 TXTBOX_COUNT, 3351 TXTBOX_COUNT,
3352 txtPointl); 3352 txtPointl);
3353 WinReleasePS(hpsTemp); 3353 WinReleasePS(hpsTemp);
3354 3354
3355 lWidth = txtPointl[TXTBOX_TOPRIGHT].x - 3355 lWidth = txtPointl[TXTBOX_TOPRIGHT].x -
3356 txtPointl[TXTBOX_TOPLEFT ].x + 8; 3356 txtPointl[TXTBOX_TOPLEFT ].x + 8;
3357 3357
3358 lHight = txtPointl[TXTBOX_TOPLEFT].y - 3358 lHight = txtPointl[TXTBOX_TOPLEFT].y -
3359 txtPointl[TXTBOX_BOTTOMLEFT].y + 8; 3359 txtPointl[TXTBOX_BOTTOMLEFT].y + 8;
3360 3360
3361 ptlWork.y -= lHight; 3361 ptlWork.y -= lHight;
3362 3362
3363 blah = (void *)WinSubclassWindow(hwndBubble, _BubbleProc); 3363 blah = (void *)WinSubclassWindow(hwndBubble, _BubbleProc);
3364 3364
3365 if(blah) 3365 if(blah)
3366 WinSetWindowPtr(hwndBubble, QWP_USER, blah); 3366 WinSetWindowPtr(hwndBubble, QWP_USER, blah);
3367 3367
3368 WinSetWindowPos(hwndBubble, 3368 WinSetWindowPos(hwndBubble,
3369 HWND_TOP, 3369 HWND_TOP,
3370 ptlWork.x, 3370 ptlWork.x,
3371 ptlWork.y, 3371 ptlWork.y,
3372 lWidth, 3372 lWidth,
3373 lHight, 3373 lHight,
3374 SWP_SIZE | SWP_MOVE | SWP_SHOW); 3374 SWP_SIZE | SWP_MOVE | SWP_SHOW);
3375 } 3375 }
3376 break; 3376 break;
3377 } 3377 }
3378 3378
3379 if(!oldproc) 3379 if(!oldproc)
3380 return WinDefWindowProc(hwnd, msg, mp1, mp2); 3380 return WinDefWindowProc(hwnd, msg, mp1, mp2);
3381 return oldproc(hwnd, msg, mp1, mp2); 3381 return oldproc(hwnd, msg, mp1, mp2);
3382 } 3382 }
3383 3383
3384 MRESULT EXPENTRY _RendProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 3384 MRESULT EXPENTRY _RendProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
3385 { 3385 {
3386 int res = 0; 3386 int res = 0;
3387 res = (int)_run_event(hwnd, msg, mp1, mp2); 3387 res = (int)_run_event(hwnd, msg, mp1, mp2);
3388 switch(msg) 3388 switch(msg)
3389 { 3389 {
3390 case WM_MOUSEMOVE: 3390 case WM_MOUSEMOVE:
3391 if(_wndproc(hwnd, msg, mp1, mp2)) 3391 if(_wndproc(hwnd, msg, mp1, mp2))
3392 return MPFROMSHORT(FALSE); 3392 return MPFROMSHORT(FALSE);
3393 break; 3393 break;
3394 case WM_BUTTON1DOWN: 3394 case WM_BUTTON1DOWN:
3395 case WM_BUTTON2DOWN: 3395 case WM_BUTTON2DOWN:
3396 case WM_BUTTON3DOWN: 3396 case WM_BUTTON3DOWN:
3397 if(res == -1) 3397 if(res == -1)
3398 WinSetFocus(HWND_DESKTOP, hwnd); 3398 WinSetFocus(HWND_DESKTOP, hwnd);
3399 else if(res) 3399 else if(res)
3400 return (MPARAM)TRUE; 3400 return (MPARAM)TRUE;
3401 } 3401 }
3402 return WinDefWindowProc(hwnd, msg, mp1, mp2); 3402 return WinDefWindowProc(hwnd, msg, mp1, mp2);
3403 } 3403 }
3404 3404
3405 MRESULT EXPENTRY _TreeProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 3405 MRESULT EXPENTRY _TreeProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
3406 { 3406 {
3407 WindowData *blah = (WindowData *)WinQueryWindowPtr(hwnd, QWP_USER); 3407 WindowData *blah = (WindowData *)WinQueryWindowPtr(hwnd, QWP_USER);
3408 PFNWP oldproc = 0; 3408 PFNWP oldproc = 0;
3409 3409
3410 if(blah) 3410 if(blah)
3411 oldproc = blah->oldproc; 3411 oldproc = blah->oldproc;
3412 3412
3413 switch(msg) 3413 switch(msg)
3414 { 3414 {
3415 case WM_MOUSEMOVE: 3415 case WM_MOUSEMOVE:
3416 if(_wndproc(hwnd, msg, mp1, mp2)) 3416 if(_wndproc(hwnd, msg, mp1, mp2))
3417 return MPFROMSHORT(FALSE); 3417 return MPFROMSHORT(FALSE);
3418 break; 3418 break;
3419 case WM_PAINT: 3419 case WM_PAINT:
3420 { 3420 {
3421 HPS hps; 3421 HPS hps;
3422 RECTL rcl; 3422 RECTL rcl;
3423 POINTL ptl[2]; 3423 POINTL ptl[2];
3424 3424
3425 if(oldproc) 3425 if(oldproc)
3426 oldproc(hwnd, msg, mp1, mp2); 3426 oldproc(hwnd, msg, mp1, mp2);
3427 3427
3428 hps = WinBeginPaint(hwnd, 0, 0); 3428 hps = WinBeginPaint(hwnd, 0, 0);
3429 WinQueryWindowRect(hwnd, &rcl); 3429 WinQueryWindowRect(hwnd, &rcl);
3430 ptl[0].x = rcl.xLeft + 1; 3430 ptl[0].x = rcl.xLeft + 1;
3431 ptl[0].y = rcl.yBottom + 1; 3431 ptl[0].y = rcl.yBottom + 1;
3432 ptl[1].x = rcl.xRight - 1; 3432 ptl[1].x = rcl.xRight - 1;
3433 ptl[1].y = rcl.yTop - 1; 3433 ptl[1].y = rcl.yTop - 1;
3434 3434
3435 GpiSetColor(hps, CLR_BLACK); 3435 GpiSetColor(hps, CLR_BLACK);
3436 GpiMove(hps, &ptl[0]); 3436 GpiMove(hps, &ptl[0]);
3437 GpiBox(hps, DRO_OUTLINE, &ptl[1], 0, 0); 3437 GpiBox(hps, DRO_OUTLINE, &ptl[1], 0, 0);
3438 WinEndPaint(hps); 3438 WinEndPaint(hps);
3439 } 3439 }
3440 return MRFROMSHORT(FALSE); 3440 return MRFROMSHORT(FALSE);
3441 case WM_SETFOCUS: 3441 case WM_SETFOCUS:
3442 _run_event(hwnd, msg, mp1, mp2); 3442 _run_event(hwnd, msg, mp1, mp2);
3443 break; 3443 break;
3444 case WM_CHAR: 3444 case WM_CHAR:
3445 if(SHORT1FROMMP(mp2) == '\t') 3445 if(SHORT1FROMMP(mp2) == '\t')
3446 { 3446 {
3447 if(CHARMSG(&msg)->fs & KC_SHIFT) 3447 if(CHARMSG(&msg)->fs & KC_SHIFT)
3448 _shift_focus_back(hwnd); 3448 _shift_focus_back(hwnd);
3449 else 3449 else
3450 _shift_focus(hwnd); 3450 _shift_focus(hwnd);
3451 return FALSE; 3451 return FALSE;
3452 } 3452 }
3453 break; 3453 break;
3454 } 3454 }
3455 3455
3456 _run_event(hwnd, msg, mp1, mp2); 3456 _run_event(hwnd, msg, mp1, mp2);
3457 3457
3458 if(oldproc) 3458 if(oldproc)
3459 return oldproc(hwnd, msg, mp1, mp2); 3459 return oldproc(hwnd, msg, mp1, mp2);
3460 3460
3461 return WinDefWindowProc(hwnd, msg, mp1, mp2); 3461 return WinDefWindowProc(hwnd, msg, mp1, mp2);
3462 } 3462 }
3463 3463
3464 /* 3464 /*
3465 * Initializes the Dynamic Windows engine. 3465 * Initializes the Dynamic Windows engine.
3466 * Parameters: 3466 * Parameters:
3467 * newthread: True if this is the only thread. 3467 * newthread: True if this is the only thread.
3468 * False if there is already a message loop running. 3468 * False if there is already a message loop running.
3469 */ 3469 */
3470 int API dw_init(int newthread, int argc, char *argv[]) 3470 int API dw_init(int newthread, int argc, char *argv[])
3471 { 3471 {
3472 APIRET rc; 3472 APIRET rc;
3473 char objnamebuf[300] = ""; 3473 char objnamebuf[300] = "";
3474 3474
3475 argc = argc; /* keep compiler happy */ 3475 argc = argc; /* keep compiler happy */
3476 argv = argv; /* keep compiler happy */ 3476 argv = argv; /* keep compiler happy */
3477 if(newthread) 3477 if(newthread)
3478 { 3478 {
3479 dwhab = WinInitialize(0); 3479 dwhab = WinInitialize(0);
3480 dwhmq = WinCreateMsgQueue(dwhab, 0); 3480 dwhmq = WinCreateMsgQueue(dwhab, 0);
3481 } 3481 }
3482 3482
3483 rc = WinRegisterClass(dwhab, ClassName, _wndproc, CS_SIZEREDRAW | CS_CLIPCHILDREN, 32); 3483 rc = WinRegisterClass(dwhab, ClassName, _wndproc, CS_SIZEREDRAW | CS_CLIPCHILDREN, 32);
3484 rc = WinRegisterClass(dwhab, SplitbarClassName, _splitwndproc, 0L, 32); 3484 rc = WinRegisterClass(dwhab, SplitbarClassName, _splitwndproc, 0L, 32);
3485 3485
3486 /* Get the OS/2 version. */ 3486 /* Get the OS/2 version. */
3487 DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_MS_COUNT,(void *)aulBuffer, 4*sizeof(ULONG)); 3487 DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_MS_COUNT,(void *)aulBuffer, 4*sizeof(ULONG));
3488 3488
3489 desktop = WinQueryDesktopWindow(dwhab, NULLHANDLE); 3489 desktop = WinQueryDesktopWindow(dwhab, NULLHANDLE);
3490 3490
3491 if(!IS_WARP4()) 3491 if(!IS_WARP4())
3492 DefaultFont = "8.Helv"; 3492 DefaultFont = "8.Helv";
3493 3493
3494 /* This is a window that hangs around as long as the 3494 /* This is a window that hangs around as long as the
3495 * application does and handles menu messages. 3495 * application does and handles menu messages.
3496 */ 3496 */
3497 hwndApp = dw_window_new(HWND_OBJECT, "", 0); 3497 hwndApp = dw_window_new(HWND_OBJECT, "", 0);
3498 DosLoadModule(objnamebuf, sizeof(objnamebuf), "WPCONFIG", &wpconfig); 3498 DosLoadModule(objnamebuf, sizeof(objnamebuf), "WPCONFIG", &wpconfig);
3499 3499
3500 return rc; 3500 return rc;
3501 } 3501 }
3502 3502
3503 /* 3503 /*
3504 * Runs a message loop for Dynamic Windows. 3504 * Runs a message loop for Dynamic Windows.
3505 */ 3505 */
3506 void API dw_main(void) 3506 void API dw_main(void)
3507 { 3507 {
3508 QMSG qmsg; 3508 QMSG qmsg;
3509 3509
3510 _dwtid = dw_thread_id(); 3510 _dwtid = dw_thread_id();
3511 3511
3512 while(WinGetMsg(dwhab, &qmsg, 0, 0, 0)) 3512 while(WinGetMsg(dwhab, &qmsg, 0, 0, 0))
3513 { 3513 {
3514 if(qmsg.msg == WM_TIMER && qmsg.hwnd == NULLHANDLE) 3514 if(qmsg.msg == WM_TIMER && qmsg.hwnd == NULLHANDLE)
3515 _run_event(qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2); 3515 _run_event(qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2);
3516 WinDispatchMsg(dwhab, &qmsg); 3516 WinDispatchMsg(dwhab, &qmsg);
3517 } 3517 }
3518 3518
3519 WinDestroyMsgQueue(dwhmq); 3519 WinDestroyMsgQueue(dwhmq);
3520 WinTerminate(dwhab); 3520 WinTerminate(dwhab);
3521 } 3521 }
3522 3522
3523 /* 3523 /*
3524 * Runs a message loop for Dynamic Windows, for a period of milliseconds. 3524 * Runs a message loop for Dynamic Windows, for a period of milliseconds.
3525 * Parameters: 3525 * Parameters:
3526 * milliseconds: Number of milliseconds to run the loop for. 3526 * milliseconds: Number of milliseconds to run the loop for.
3527 */ 3527 */
3528 void API dw_main_sleep(int milliseconds) 3528 void API dw_main_sleep(int milliseconds)
3529 { 3529 {
3530 QMSG qmsg; 3530 QMSG qmsg;
3531 #ifdef __EMX__ 3531 #ifdef __EMX__
3532 struct timeval tv, start; 3532 struct timeval tv, start;
3533 3533
3534 gettimeofday(&start, NULL); 3534 gettimeofday(&start, NULL);
3535 gettimeofday(&tv, NULL); 3535 gettimeofday(&tv, NULL);
3536 3536
3537 while(((tv.tv_sec - start.tv_sec)*1000) + ((tv.tv_usec - start.tv_usec)/1000) <= milliseconds) 3537 while(((tv.tv_sec - start.tv_sec)*1000) + ((tv.tv_usec - start.tv_usec)/1000) <= milliseconds)
3538 { 3538 {
3539 if(WinPeekMsg(dwhab, &qmsg, 0, 0, 0, PM_NOREMOVE)) 3539 if(WinPeekMsg(dwhab, &qmsg, 0, 0, 0, PM_NOREMOVE))
3540 { 3540 {
3541 WinGetMsg(dwhab, &qmsg, 0, 0, 0); 3541 WinGetMsg(dwhab, &qmsg, 0, 0, 0);
3542 if(qmsg.msg == WM_TIMER && qmsg.hwnd == NULLHANDLE) 3542 if(qmsg.msg == WM_TIMER && qmsg.hwnd == NULLHANDLE)
3543 _run_event(qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2); 3543 _run_event(qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2);
3544 WinDispatchMsg(dwhab, &qmsg); 3544 WinDispatchMsg(dwhab, &qmsg);
3545 } 3545 }
3546 else 3546 else
3547 DosSleep(1); 3547 DosSleep(1);
3548 gettimeofday(&tv, NULL); 3548 gettimeofday(&tv, NULL);
3549 } 3549 }
3550 #else 3550 #else
3551 double start = (double)clock(); 3551 double start = (double)clock();
3552 3552
3553 while(((clock() - start) / (CLOCKS_PER_SEC/1000)) <= milliseconds) 3553 while(((clock() - start) / (CLOCKS_PER_SEC/1000)) <= milliseconds)
3554 { 3554 {
3555 if(WinPeekMsg(dwhab, &qmsg, 0, 0, 0, PM_NOREMOVE)) 3555 if(WinPeekMsg(dwhab, &qmsg, 0, 0, 0, PM_NOREMOVE))
3556 { 3556 {
3557 WinGetMsg(dwhab, &qmsg, 0, 0, 0); 3557 WinGetMsg(dwhab, &qmsg, 0, 0, 0);
3558 if(qmsg.msg == WM_TIMER && qmsg.hwnd == NULLHANDLE) 3558 if(qmsg.msg == WM_TIMER && qmsg.hwnd == NULLHANDLE)
3559 _run_event(qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2); 3559 _run_event(qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2);
3560 WinDispatchMsg(dwhab, &qmsg); 3560 WinDispatchMsg(dwhab, &qmsg);
3561 } 3561 }
3562 else 3562 else
3563 DosSleep(1); 3563 DosSleep(1);
3564 } 3564 }
3565 #endif 3565 #endif
3566 } 3566 }
3567 3567
3568 /* 3568 /*
3569 * Processes a single message iteration and returns. 3569 * Processes a single message iteration and returns.
3570 */ 3570 */
3571 void API dw_main_iteration(void) 3571 void API dw_main_iteration(void)
3572 { 3572 {
3573 QMSG qmsg; 3573 QMSG qmsg;
3574 3574
3575 _dwtid = dw_thread_id(); 3575 _dwtid = dw_thread_id();
3576 3576
3577 if(WinGetMsg(dwhab, &qmsg, 0, 0, 0)) 3577 if(WinGetMsg(dwhab, &qmsg, 0, 0, 0))
3578 { 3578 {
3579 if(qmsg.msg == WM_TIMER && qmsg.hwnd == NULLHANDLE) 3579 if(qmsg.msg == WM_TIMER && qmsg.hwnd == NULLHANDLE)
3580 _run_event(qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2); 3580 _run_event(qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2);
3581 WinDispatchMsg(dwhab, &qmsg); 3581 WinDispatchMsg(dwhab, &qmsg);
3582 } 3582 }
3583 } 3583 }
3584 3584
3585 /* 3585 /*
3586 * Free's memory allocated by dynamic windows. 3586 * Free's memory allocated by dynamic windows.
3587 * Parameters: 3587 * Parameters:
3588 * ptr: Pointer to dynamic windows allocated 3588 * ptr: Pointer to dynamic windows allocated
3589 * memory to be free()'d. 3589 * memory to be free()'d.
3590 */ 3590 */
3591 void API dw_free(void *ptr) 3591 void API dw_free(void *ptr)
3592 { 3592 {
3593 free(ptr); 3593 free(ptr);
3594 } 3594 }
3595 3595
3596 /* 3596 /*
3597 * Allocates and initializes a dialog struct. 3597 * Allocates and initializes a dialog struct.
3598 * Parameters: 3598 * Parameters:
3599 * data: User defined data to be passed to functions. 3599 * data: User defined data to be passed to functions.
3600 */ 3600 */
3601 DWDialog * API dw_dialog_new(void *data) 3601 DWDialog * API dw_dialog_new(void *data)
3602 { 3602 {
3603 DWDialog *tmp = malloc(sizeof(DWDialog)); 3603 DWDialog *tmp = malloc(sizeof(DWDialog));
3604 3604
3605 tmp->eve = dw_event_new(); 3605 tmp->eve = dw_event_new();
3606 dw_event_reset(tmp->eve); 3606 dw_event_reset(tmp->eve);
3607 tmp->data = data; 3607 tmp->data = data;
3608 tmp->done = FALSE; 3608 tmp->done = FALSE;
3609 tmp->result = NULL; 3609 tmp->result = NULL;
3610 3610
3611 return tmp; 3611 return tmp;
3612 } 3612 }
3613 3613
3614 /* 3614 /*
3618 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). 3618 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
3619 * result: Data to be returned by dw_dialog_wait(). 3619 * result: Data to be returned by dw_dialog_wait().
3620 */ 3620 */
3621 int API dw_dialog_dismiss(DWDialog *dialog, void *result) 3621 int API dw_dialog_dismiss(DWDialog *dialog, void *result)
3622 { 3622 {
3623 dialog->result = result; 3623 dialog->result = result;
3624 dw_event_post(dialog->eve); 3624 dw_event_post(dialog->eve);
3625 dialog->done = TRUE; 3625 dialog->done = TRUE;
3626 return 0; 3626 return 0;
3627 } 3627 }
3628 3628
3629 /* 3629 /*
3630 * Accepts a dialog struct waits for dw_dialog_dismiss() to be 3630 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
3631 * called by a signal handler with the given dialog struct. 3631 * called by a signal handler with the given dialog struct.
3632 * Parameters: 3632 * Parameters:
3633 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). 3633 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
3634 */ 3634 */
3635 void * API dw_dialog_wait(DWDialog *dialog) 3635 void * API dw_dialog_wait(DWDialog *dialog)
3636 { 3636 {
3637 QMSG qmsg; 3637 QMSG qmsg;
3638 void *tmp; 3638 void *tmp;
3639 3639
3640 while (WinGetMsg(dwhab, &qmsg, 0, 0, 0)) 3640 while (WinGetMsg(dwhab, &qmsg, 0, 0, 0))
3641 { 3641 {
3642 if(qmsg.msg == WM_TIMER && qmsg.hwnd == NULLHANDLE) 3642 if(qmsg.msg == WM_TIMER && qmsg.hwnd == NULLHANDLE)
3643 _run_event(qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2); 3643 _run_event(qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2);
3644 WinDispatchMsg(dwhab, &qmsg); 3644 WinDispatchMsg(dwhab, &qmsg);
3645 if(dialog->done) 3645 if(dialog->done)
3646 break; 3646 break;
3647 } 3647 }
3648 dw_event_close(&dialog->eve); 3648 dw_event_close(&dialog->eve);
3649 tmp = dialog->result; 3649 tmp = dialog->result;
3650 free(dialog); 3650 free(dialog);
3651 return tmp; 3651 return tmp;
3652 } 3652 }
3653 3653
3654 3654
3655 /* 3655 /*
3656 * Displays a Message Box with given text and title.. 3656 * Displays a Message Box with given text and title..
3660 * format: printf style format string. 3660 * format: printf style format string.
3661 * ...: Additional variables for use in the format. 3661 * ...: Additional variables for use in the format.
3662 */ 3662 */
3663 int API dw_messagebox(char *title, int flags, char *format, ...) 3663 int API dw_messagebox(char *title, int flags, char *format, ...)
3664 { 3664 {
3665 va_list args; 3665 va_list args;
3666 char outbuf[1024]; 3666 char outbuf[1024];
3667 int rc; 3667 int rc;
3668 3668
3669 va_start(args, format); 3669 va_start(args, format);
3670 vsprintf(outbuf, format, args); 3670 vsprintf(outbuf, format, args);
3671 va_end(args); 3671 va_end(args);
3672 3672
3673 rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, outbuf, title, 0, flags | MB_MOVEABLE); 3673 rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, outbuf, title, 0, flags | MB_MOVEABLE);
3674 if(rc == MBID_OK) 3674 if(rc == MBID_OK)
3675 return DW_MB_RETURN_OK; 3675 return DW_MB_RETURN_OK;
3676 else if(rc == MBID_YES) 3676 else if(rc == MBID_YES)
3677 return DW_MB_RETURN_YES; 3677 return DW_MB_RETURN_YES;
3678 else if(rc == MBID_NO) 3678 else if(rc == MBID_NO)
3679 return DW_MB_RETURN_NO; 3679 return DW_MB_RETURN_NO;
3680 else if(rc == MBID_CANCEL) 3680 else if(rc == MBID_CANCEL)
3681 return DW_MB_RETURN_CANCEL; 3681 return DW_MB_RETURN_CANCEL;
3682 else return 0; 3682 else return 0;
3683 } 3683 }
3684 3684
3685 /* 3685 /*
3686 * Makes the window topmost. 3686 * Makes the window topmost.
3687 * Parameters: 3687 * Parameters:
3688 * handle: The window handle to make topmost. 3688 * handle: The window handle to make topmost.
3689 */ 3689 */
3690 int API dw_window_raise(HWND handle) 3690 int API dw_window_raise(HWND handle)
3691 { 3691 {
3692 return WinSetWindowPos(handle, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER); 3692 return WinSetWindowPos(handle, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
3693 } 3693 }
3694 3694
3695 /* 3695 /*
3696 * Makes the window bottommost. 3696 * Makes the window bottommost.
3697 * Parameters: 3697 * Parameters:
3698 * handle: The window handle to make bottommost. 3698 * handle: The window handle to make bottommost.
3699 */ 3699 */
3700 int API dw_window_lower(HWND handle) 3700 int API dw_window_lower(HWND handle)
3701 { 3701 {
3702 return WinSetWindowPos(handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER); 3702 return WinSetWindowPos(handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
3703 } 3703 }
3704 3704
3705 /* 3705 /*
3706 * Makes the window visible. 3706 * Makes the window visible.
3707 * Parameters: 3707 * Parameters:
3708 * handle: The window handle to make visible. 3708 * handle: The window handle to make visible.
3709 */ 3709 */
3710 int API dw_window_show(HWND handle) 3710 int API dw_window_show(HWND handle)
3711 { 3711 {
3712 int rc = WinSetWindowPos(handle, NULLHANDLE, 0, 0, 0, 0, SWP_SHOW); 3712 int rc = WinSetWindowPos(handle, NULLHANDLE, 0, 0, 0, 0, SWP_SHOW);
3713 HSWITCH hswitch; 3713 HSWITCH hswitch;
3714 SWCNTRL swcntrl; 3714 SWCNTRL swcntrl;
3715 3715
3716 _fix_button_owner(_toplevel_window(handle), 0); 3716 _fix_button_owner(_toplevel_window(handle), 0);
3717 WinSetFocus(HWND_DESKTOP, handle); 3717 WinSetFocus(HWND_DESKTOP, handle);
3718 _initial_focus(handle); 3718 _initial_focus(handle);
3719 3719
3720 /* If this window has a switch list entry make sure it is visible */ 3720 /* If this window has a switch list entry make sure it is visible */
3721 hswitch = WinQuerySwitchHandle(handle, 0); 3721 hswitch = WinQuerySwitchHandle(handle, 0);
3722 if(hswitch) 3722 if(hswitch)
3723 { 3723 {
3724 WinQuerySwitchEntry(hswitch, &swcntrl); 3724 WinQuerySwitchEntry(hswitch, &swcntrl);
3725 swcntrl.uchVisibility = SWL_VISIBLE; 3725 swcntrl.uchVisibility = SWL_VISIBLE;
3726 WinChangeSwitchEntry(hswitch, &swcntrl); 3726 WinChangeSwitchEntry(hswitch, &swcntrl);
3727 } 3727 }
3728 if(WinWindowFromID(handle, FID_CLIENT)) 3728 if(WinWindowFromID(handle, FID_CLIENT))
3729 { 3729 {
3730 WindowData *blah = WinQueryWindowPtr(handle, QWP_USER); 3730 WindowData *blah = WinQueryWindowPtr(handle, QWP_USER);
3731 3731
3732 if(blah && !(blah->flags & DW_OS2_NEW_WINDOW)) 3732 if(blah && !(blah->flags & DW_OS2_NEW_WINDOW))
3733 { 3733 {
3734 ULONG cx = dw_screen_width(), cy = dw_screen_height(); 3734 ULONG cx = dw_screen_width(), cy = dw_screen_height();
3735 int newx, newy, changed = 0; 3735 int newx, newy, changed = 0;
3736 SWP swp; 3736 SWP swp;
3737 3737
3738 blah->flags |= DW_OS2_NEW_WINDOW; 3738 blah->flags |= DW_OS2_NEW_WINDOW;
3739 3739
3740 WinQueryWindowPos(handle, &swp); 3740 WinQueryWindowPos(handle, &swp);
3741 3741
3742 newx = swp.x; 3742 newx = swp.x;
3743 newy = swp.y; 3743 newy = swp.y;
3744 3744
3745 if((swp.x+swp.cx) > cx) 3745 if((swp.x+swp.cx) > cx)
3746 { 3746 {
3747 newx = (cx - swp.cx)/2; 3747 newx = (cx - swp.cx)/2;
3748 changed = 1; 3748 changed = 1;
3749 } 3749 }
3750 if((swp.y+swp.cy) > cy) 3750 if((swp.y+swp.cy) > cy)
3751 { 3751 {
3752 newy = (cy - swp.cy)/2; 3752 newy = (cy - swp.cy)/2;
3753 changed = 1; 3753 changed = 1;
3754 } 3754 }
3755 if(changed) 3755 if(changed)
3756 WinSetWindowPos(handle, NULLHANDLE, newx, newy, 0, 0, SWP_MOVE); 3756 WinSetWindowPos(handle, NULLHANDLE, newx, newy, 0, 0, SWP_MOVE);
3757 } 3757 }
3758 } 3758 }
3759 return rc; 3759 return rc;
3760 } 3760 }
3761 3761
3762 /* 3762 /*
3763 * Minimizes or Iconifies a top-level window. 3763 * Minimizes or Iconifies a top-level window.
3764 * Parameters: 3764 * Parameters:
3765 * handle: The window handle to minimize. 3765 * handle: The window handle to minimize.
3766 */ 3766 */
3767 int API dw_window_minimize(HWND handle) 3767 int API dw_window_minimize(HWND handle)
3768 { 3768 {
3769 HWND hwndclient = WinWindowFromID(handle, FID_CLIENT); 3769 HWND hwndclient = WinWindowFromID(handle, FID_CLIENT);
3770 3770
3771 if(hwndclient) 3771 if(hwndclient)
3772 { 3772 {
3773 Box *box = (Box *)WinQueryWindowPtr(hwndclient, QWP_USER); 3773 Box *box = (Box *)WinQueryWindowPtr(hwndclient, QWP_USER);
3774 3774
3775 if(box) 3775 if(box)
3776 { 3776 {
3777 if(!box->titlebar && box->hwndtitle) 3777 if(!box->titlebar && box->hwndtitle)
3778 WinSetParent(box->hwndtitle, handle, FALSE); 3778 WinSetParent(box->hwndtitle, handle, FALSE);
3779 } 3779 }
3780 } 3780 }
3781 3781
3782 return WinSetWindowPos(handle, NULLHANDLE, 0, 0, 0, 0, SWP_MINIMIZE); 3782 return WinSetWindowPos(handle, NULLHANDLE, 0, 0, 0, 0, SWP_MINIMIZE);
3783 } 3783 }
3784 3784
3785 /* 3785 /*
3786 * Makes the window invisible. 3786 * Makes the window invisible.
3787 * Parameters: 3787 * Parameters:
3788 * handle: The window handle to make visible. 3788 * handle: The window handle to make visible.
3789 */ 3789 */
3790 int API dw_window_hide(HWND handle) 3790 int API dw_window_hide(HWND handle)
3791 { 3791 {
3792 HSWITCH hswitch; 3792 HSWITCH hswitch;
3793 SWCNTRL swcntrl; 3793 SWCNTRL swcntrl;
3794 3794
3795 /* If this window has a switch list entry make sure it is invisible */ 3795 /* If this window has a switch list entry make sure it is invisible */
3796 hswitch = WinQuerySwitchHandle(handle, 0); 3796 hswitch = WinQuerySwitchHandle(handle, 0);
3797 if(hswitch) 3797 if(hswitch)
3798 { 3798 {
3799 WinQuerySwitchEntry(hswitch, &swcntrl); 3799 WinQuerySwitchEntry(hswitch, &swcntrl);
3800 swcntrl.uchVisibility = SWL_INVISIBLE; 3800 swcntrl.uchVisibility = SWL_INVISIBLE;
3801 WinChangeSwitchEntry(hswitch, &swcntrl); 3801 WinChangeSwitchEntry(hswitch, &swcntrl);
3802 } 3802 }
3803 return WinShowWindow(handle, FALSE); 3803 return WinShowWindow(handle, FALSE);
3804 } 3804 }
3805 3805
3806 /* 3806 /*
3807 * Destroys a window and all of it's children. 3807 * Destroys a window and all of it's children.
3808 * Parameters: 3808 * Parameters:
3809 * handle: The window handle to destroy. 3809 * handle: The window handle to destroy.
3810 */ 3810 */
3811 int API dw_window_destroy(HWND handle) 3811 int API dw_window_destroy(HWND handle)
3812 { 3812 {
3813 HWND frame, menu, parent = WinQueryWindow(handle, QW_PARENT); 3813 HWND frame, menu, parent = WinQueryWindow(handle, QW_PARENT);
3814 Box *thisbox = WinQueryWindowPtr(parent, QWP_USER); 3814 Box *thisbox = WinQueryWindowPtr(parent, QWP_USER);
3815 3815
3816 if(!handle) 3816 if(!handle)
3817 return -1; 3817 return -1;
3818 3818
3819 frame = (HWND)dw_window_get_data(handle, "_dw_combo_box"); 3819 frame = (HWND)dw_window_get_data(handle, "_dw_combo_box");
3820 3820
3821 if((menu = WinWindowFromID(handle, FID_MENU)) != NULLHANDLE) 3821 if((menu = WinWindowFromID(handle, FID_MENU)) != NULLHANDLE)
3822 _free_menu_data(menu); 3822 _free_menu_data(menu);
3823 3823
3824 if(parent != desktop && thisbox && thisbox->count) 3824 if(parent != desktop && thisbox && thisbox->count)
3825 { 3825 {
3826 int z, index = -1; 3826 int z, index = -1;
3827 Item *tmpitem, *thisitem = thisbox->items; 3827 Item *tmpitem, *thisitem = thisbox->items;
3828 3828
3829 for(z=0;z<thisbox->count;z++) 3829 for(z=0;z<thisbox->count;z++)
3830 { 3830 {
3831 if(thisitem[z].hwnd == handle) 3831 if(thisitem[z].hwnd == handle)
3832 index = z; 3832 index = z;
3833 } 3833 }
3834 3834
3835 if(index == -1) 3835 if(index == -1)
3836 return 0; 3836 return 0;
3837 3837
3838 tmpitem = malloc(sizeof(Item)*(thisbox->count-1)); 3838 tmpitem = malloc(sizeof(Item)*(thisbox->count-1));
3839 3839
3840 /* Copy all but the current entry to the new list */ 3840 /* Copy all but the current entry to the new list */
3841 for(z=0;z<index;z++) 3841 for(z=0;z<index;z++)
3842 { 3842 {
3843 tmpitem[z] = thisitem[z]; 3843 tmpitem[z] = thisitem[z];
3844 } 3844 }
3845 for(z=index+1;z<thisbox->count;z++) 3845 for(z=index+1;z<thisbox->count;z++)
3846 { 3846 {
3847 tmpitem[z-1] = thisitem[z]; 3847 tmpitem[z-1] = thisitem[z];
3848 } 3848 }
3849 3849
3850 thisbox->items = tmpitem; 3850 thisbox->items = tmpitem;
3851 free(thisitem); 3851 free(thisitem);
3852 thisbox->count--; 3852 thisbox->count--;
3853 _free_window_memory(frame ? frame : handle); 3853 _free_window_memory(frame ? frame : handle);
3854 } 3854 }
3855 return WinDestroyWindow(frame ? frame : handle); 3855 return WinDestroyWindow(frame ? frame : handle);
3856 } 3856 }
3857 3857
3858 /* Causes entire window to be invalidated and redrawn. 3858 /* Causes entire window to be invalidated and redrawn.
3859 * Parameters: 3859 * Parameters:
3860 * handle: Toplevel window handle to be redrawn. 3860 * handle: Toplevel window handle to be redrawn.
3861 */ 3861 */
3862 void API dw_window_redraw(HWND handle) 3862 void API dw_window_redraw(HWND handle)
3863 { 3863 {
3864 HWND client = WinWindowFromID(handle, FID_CLIENT); 3864 HWND client = WinWindowFromID(handle, FID_CLIENT);
3865 HWND window = client ? client : handle; 3865 HWND window = client ? client : handle;
3866 Box *mybox = (Box *)WinQueryWindowPtr(window, QWP_USER); 3866 Box *mybox = (Box *)WinQueryWindowPtr(window, QWP_USER);
3867 3867
3868 _fix_button_owner(_toplevel_window(handle), 0); 3868 _fix_button_owner(_toplevel_window(handle), 0);
3869 if(window && mybox) 3869 if(window && mybox)
3870 { 3870 {
3871 unsigned long width, height; 3871 unsigned long width, height;
3872 3872
3873 dw_window_get_pos_size(window, NULL, NULL, &width, &height); 3873 dw_window_get_pos_size(window, NULL, NULL, &width, &height);
3874 3874
3875 WinShowWindow(client ? mybox->items[0].hwnd : handle, FALSE); 3875 WinShowWindow(client ? mybox->items[0].hwnd : handle, FALSE);
3876 _do_resize(mybox, width, height); 3876 _do_resize(mybox, width, height);
3877 WinShowWindow(client ? mybox->items[0].hwnd : handle, TRUE); 3877 WinShowWindow(client ? mybox->items[0].hwnd : handle, TRUE);
3878 } 3878 }
3879 } 3879 }
3880 3880
3881 /* 3881 /*
3882 * Changes a window's parent to newparent. 3882 * Changes a window's parent to newparent.
3883 * Parameters: 3883 * Parameters:
3884 * handle: The window handle to destroy. 3884 * handle: The window handle to destroy.
3885 * newparent: The window's new parent window. 3885 * newparent: The window's new parent window.
3886 */ 3886 */
3887 void API dw_window_reparent(HWND handle, HWND newparent) 3887 void API dw_window_reparent(HWND handle, HWND newparent)
3888 { 3888 {
3889 HWND blah = WinWindowFromID(newparent, FID_CLIENT); 3889 HWND blah = WinWindowFromID(newparent, FID_CLIENT);
3890 WinSetParent(handle, blah ? blah : newparent, TRUE); 3890 WinSetParent(handle, blah ? blah : newparent, TRUE);
3891 } 3891 }
3892 3892
3893 /* 3893 /*
3894 * Sets the font used by a specified window (widget) handle. 3894 * Sets the font used by a specified window (widget) handle.
3895 * Parameters: 3895 * Parameters:
3896 * handle: The window (widget) handle. 3896 * handle: The window (widget) handle.
3897 * fontname: Name and size of the font in the form "size.fontname" 3897 * fontname: Name and size of the font in the form "size.fontname"
3898 */ 3898 */
3899 int API dw_window_set_font(HWND handle, char *fontname) 3899 int API dw_window_set_font(HWND handle, char *fontname)
3900 { 3900 {
3901 return WinSetPresParam(handle, PP_FONTNAMESIZE, strlen(fontname)+1, fontname); 3901 return WinSetPresParam(handle, PP_FONTNAMESIZE, strlen(fontname)+1, fontname);
3902 } 3902 }
3903 3903
3904 /* Internal version */ 3904 /* Internal version */
3905 int _dw_window_set_color(HWND handle, ULONG fore, ULONG back) 3905 int _dw_window_set_color(HWND handle, ULONG fore, ULONG back)
3906 { 3906 {
3907 if((fore & DW_RGB_COLOR) == DW_RGB_COLOR) 3907 if((fore & DW_RGB_COLOR) == DW_RGB_COLOR)
3908 { 3908 {
3909 RGB2 rgb2; 3909 RGB2 rgb2;
3910 3910
3911 rgb2.bBlue = DW_BLUE_VALUE(fore); 3911 rgb2.bBlue = DW_BLUE_VALUE(fore);
3912 rgb2.bGreen = DW_GREEN_VALUE(fore); 3912 rgb2.bGreen = DW_GREEN_VALUE(fore);
3913 rgb2.bRed = DW_RED_VALUE(fore); 3913 rgb2.bRed = DW_RED_VALUE(fore);
3914 rgb2.fcOptions = 0; 3914 rgb2.fcOptions = 0;
3915 3915
3916 WinSetPresParam(handle, PP_FOREGROUNDCOLOR, sizeof(RGB2), &rgb2); 3916 WinSetPresParam(handle, PP_FOREGROUNDCOLOR, sizeof(RGB2), &rgb2);
3917 3917
3918 } 3918 }
3919 else if(fore != DW_CLR_DEFAULT) 3919 else if(fore != DW_CLR_DEFAULT)
3920 { 3920 {
3921 fore = _internal_color(fore); 3921 fore = _internal_color(fore);
3922 3922
3923 WinSetPresParam(handle, PP_FOREGROUNDCOLORINDEX, sizeof(ULONG), &fore); 3923 WinSetPresParam(handle, PP_FOREGROUNDCOLORINDEX, sizeof(ULONG), &fore);
3924 } 3924 }
3925 if((back & DW_RGB_COLOR) == DW_RGB_COLOR) 3925 if((back & DW_RGB_COLOR) == DW_RGB_COLOR)
3926 { 3926 {
3927 RGB2 rgb2; 3927 RGB2 rgb2;
3928 3928
3929 rgb2.bBlue = DW_BLUE_VALUE(back); 3929 rgb2.bBlue = DW_BLUE_VALUE(back);
3930 rgb2.bGreen = DW_GREEN_VALUE(back); 3930 rgb2.bGreen = DW_GREEN_VALUE(back);
3931 rgb2.bRed = DW_RED_VALUE(back); 3931 rgb2.bRed = DW_RED_VALUE(back);
3932 rgb2.fcOptions = 0; 3932 rgb2.fcOptions = 0;
3933 3933
3934 WinSetPresParam(handle, PP_BACKGROUNDCOLOR, sizeof(RGB2), &rgb2); 3934 WinSetPresParam(handle, PP_BACKGROUNDCOLOR, sizeof(RGB2), &rgb2);
3935 return 0; 3935 return 0;
3936 } 3936 }
3937 else if(back != DW_CLR_DEFAULT) 3937 else if(back != DW_CLR_DEFAULT)
3938 { 3938 {
3939 back = _internal_color(back); 3939 back = _internal_color(back);
3940 3940
3941 WinSetPresParam(handle, PP_BACKGROUNDCOLORINDEX, sizeof(ULONG), &back); 3941 WinSetPresParam(handle, PP_BACKGROUNDCOLORINDEX, sizeof(ULONG), &back);
3942 } 3942 }
3943 return 0; 3943 return 0;
3944 } 3944 }
3945 /* 3945 /*
3946 * Sets the colors used by a specified window (widget) handle. 3946 * Sets the colors used by a specified window (widget) handle.
3947 * Parameters: 3947 * Parameters:
3948 * handle: The window (widget) handle. 3948 * handle: The window (widget) handle.
3949 * fore: Foreground color in DW_RGB format or a default color index. 3949 * fore: Foreground color in DW_RGB format or a default color index.
3950 * back: Background color in DW_RGB format or a default color index. 3950 * back: Background color in DW_RGB format or a default color index.
3951 */ 3951 */
3952 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back) 3952 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back)
3953 { 3953 {
3954 dw_window_set_data(handle, "_dw_fore", (void *)(fore+1)); 3954 dw_window_set_data(handle, "_dw_fore", (void *)(fore+1));
3955 dw_window_set_data(handle, "_dw_back", (void *)(back+1)); 3955 dw_window_set_data(handle, "_dw_back", (void *)(back+1));
3956 3956
3957 return _dw_window_set_color(handle, fore, back); 3957 return _dw_window_set_color(handle, fore, back);
3958 } 3958 }
3959 3959
3960 /* 3960 /*
3961 * Sets the font used by a specified window (widget) handle. 3961 * Sets the font used by a specified window (widget) handle.
3962 * Parameters: 3962 * Parameters:
3963 * handle: The window (widget) handle. 3963 * handle: The window (widget) handle.
3964 * border: Size of the window border in pixels. 3964 * border: Size of the window border in pixels.
3965 */ 3965 */
3966 int API dw_window_set_border(HWND handle, int border) 3966 int API dw_window_set_border(HWND handle, int border)
3967 { 3967 {
3968 WinSendMsg(handle, WM_SETBORDERSIZE, MPFROMSHORT(border), MPFROMSHORT(border)); 3968 WinSendMsg(handle, WM_SETBORDERSIZE, MPFROMSHORT(border), MPFROMSHORT(border));
3969 return 0; 3969 return 0;
3970 } 3970 }
3971 3971
3972 /* 3972 /*
3973 * Captures the mouse input to this window. 3973 * Captures the mouse input to this window.
3974 * Parameters: 3974 * Parameters:
3975 * handle: Handle to receive mouse input. 3975 * handle: Handle to receive mouse input.
3976 */ 3976 */
3977 void API dw_window_capture(HWND handle) 3977 void API dw_window_capture(HWND handle)
3978 { 3978 {
3979 WinSetCapture(HWND_DESKTOP, handle); 3979 WinSetCapture(HWND_DESKTOP, handle);
3980 } 3980 }
3981 3981
3982 /* 3982 /*
3983 * Releases previous mouse capture. 3983 * Releases previous mouse capture.
3984 */ 3984 */
3985 void API dw_window_release(void) 3985 void API dw_window_release(void)
3986 { 3986 {
3987 WinSetCapture(HWND_DESKTOP, NULLHANDLE); 3987 WinSetCapture(HWND_DESKTOP, NULLHANDLE);
3988 } 3988 }
3989 3989
3990 /* 3990 /*
3991 * Tracks this window movement. 3991 * Tracks this window movement.
3992 * Parameters: 3992 * Parameters:
3993 * handle: Handle to frame to be tracked. 3993 * handle: Handle to frame to be tracked.
3994 */ 3994 */
3995 void API dw_window_track(HWND handle) 3995 void API dw_window_track(HWND handle)
3996 { 3996 {
3997 WinSendMsg(handle, WM_TRACKFRAME, MPFROMSHORT(TF_MOVE), 0); 3997 WinSendMsg(handle, WM_TRACKFRAME, MPFROMSHORT(TF_MOVE), 0);
3998 } 3998 }
3999 3999
4000 /* 4000 /*
4001 * Changes the appearance of the mouse pointer. 4001 * Changes the appearance of the mouse pointer.
4002 * Parameters: 4002 * Parameters:
4003 * handle: Handle to widget for which to change. 4003 * handle: Handle to widget for which to change.
4004 * cursortype: ID of the pointer you want. 4004 * cursortype: ID of the pointer you want.
4005 */ 4005 */
4006 void API dw_window_set_pointer(HWND handle, int pointertype) 4006 void API dw_window_set_pointer(HWND handle, int pointertype)
4007 { 4007 {
4008 HPOINTER pointer = pointertype < 65535 ? 4008 HPOINTER pointer = pointertype < 65535 ?
4009 WinQuerySysPointer(HWND_DESKTOP, pointertype, FALSE) 4009 WinQuerySysPointer(HWND_DESKTOP, pointertype, FALSE)
4010 : (HPOINTER)pointertype; 4010 : (HPOINTER)pointertype;
4011 4011
4012 if(!pointertype) 4012 if(!pointertype)
4013 dw_window_set_data(handle, "_dw_pointer", 0); 4013 dw_window_set_data(handle, "_dw_pointer", 0);
4014 else 4014 else
4015 { 4015 {
4016 WinSetPointer(HWND_DESKTOP, pointer); 4016 WinSetPointer(HWND_DESKTOP, pointer);
4017 4017
4018 if(handle != HWND_DESKTOP) 4018 if(handle != HWND_DESKTOP)
4019 dw_window_set_data(handle, "_dw_pointer", (void *)pointer); 4019 dw_window_set_data(handle, "_dw_pointer", (void *)pointer);
4020 } 4020 }
4021 } 4021 }
4022 4022
4023 /* 4023 /*
4024 * Create a new Window Frame. 4024 * Create a new Window Frame.
4025 * Parameters: 4025 * Parameters:
4027 * title: The Window title. 4027 * title: The Window title.
4028 * flStyle: Style flags, see the PM reference. 4028 * flStyle: Style flags, see the PM reference.
4029 */ 4029 */
4030 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) 4030 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle)
4031 { 4031 {
4032 HWND hwndframe; 4032 HWND hwndframe;
4033 Box *newbox = calloc(1, sizeof(Box)); 4033 Box *newbox = calloc(1, sizeof(Box));
4034 WindowData *blah = calloc(1, sizeof(WindowData)); 4034 WindowData *blah = calloc(1, sizeof(WindowData));
4035 ULONG winStyle = 0L; 4035 ULONG winStyle = 0L;
4036 4036
4037 newbox->pad = 0; 4037 newbox->pad = 0;
4038 newbox->type = DW_VERT; 4038 newbox->type = DW_VERT;
4039 newbox->count = 0; 4039 newbox->count = 0;
4040 4040
4041 flStyle |= FCF_NOBYTEALIGN; 4041 flStyle |= FCF_NOBYTEALIGN;
4042 4042
4043 if(flStyle & DW_FCF_TITLEBAR) 4043 if(flStyle & DW_FCF_TITLEBAR)
4044 newbox->titlebar = 1; 4044 newbox->titlebar = 1;
4045 else 4045 else
4046 flStyle |= FCF_TITLEBAR; 4046 flStyle |= FCF_TITLEBAR;
4047 4047
4048 if(!(flStyle & FCF_SHELLPOSITION)) 4048 if(!(flStyle & FCF_SHELLPOSITION))
4049 blah->flags |= DW_OS2_NEW_WINDOW; 4049 blah->flags |= DW_OS2_NEW_WINDOW;
4050 4050
4051 if(flStyle & WS_MAXIMIZED) 4051 if(flStyle & WS_MAXIMIZED)
4052 { 4052 {
4053 winStyle |= WS_MAXIMIZED; 4053 winStyle |= WS_MAXIMIZED;
4054 flStyle &= ~WS_MAXIMIZED; 4054 flStyle &= ~WS_MAXIMIZED;
4055 } 4055 }
4056 if(flStyle & WS_MINIMIZED) 4056 if(flStyle & WS_MINIMIZED)
4057 { 4057 {
4058 winStyle |= WS_MINIMIZED; 4058 winStyle |= WS_MINIMIZED;
4059 flStyle &= ~WS_MINIMIZED; 4059 flStyle &= ~WS_MINIMIZED;
4060 } 4060 }
4061 4061
4062 hwndframe = WinCreateStdWindow(hwndOwner, winStyle, &flStyle, ClassName, title, 0L, NULLHANDLE, 0L, &newbox->hwnd); 4062 hwndframe = WinCreateStdWindow(hwndOwner, winStyle, &flStyle, ClassName, title, 0L, NULLHANDLE, 0L, &newbox->hwnd);
4063 newbox->hwndtitle = WinWindowFromID(hwndframe, FID_TITLEBAR); 4063 newbox->hwndtitle = WinWindowFromID(hwndframe, FID_TITLEBAR);
4064 if(!newbox->titlebar && newbox->hwndtitle) 4064 if(!newbox->titlebar && newbox->hwndtitle)
4065 WinSetParent(newbox->hwndtitle, HWND_OBJECT, FALSE); 4065 WinSetParent(newbox->hwndtitle, HWND_OBJECT, FALSE);
4066 blah->oldproc = WinSubclassWindow(hwndframe, _sizeproc); 4066 blah->oldproc = WinSubclassWindow(hwndframe, _sizeproc);
4067 WinSetWindowPtr(hwndframe, QWP_USER, blah); 4067 WinSetWindowPtr(hwndframe, QWP_USER, blah);
4068 WinSetWindowPtr(newbox->hwnd, QWP_USER, newbox); 4068 WinSetWindowPtr(newbox->hwnd, QWP_USER, newbox);
4069 4069
4070 return hwndframe; 4070 return hwndframe;
4071 } 4071 }
4072 4072
4073 /* 4073 /*
4074 * Create a new Box to be packed. 4074 * Create a new Box to be packed.
4075 * Parameters: 4075 * Parameters:
4076 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). 4076 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
4077 * pad: Number of pixels to pad around the box. 4077 * pad: Number of pixels to pad around the box.
4078 */ 4078 */
4079 HWND API dw_box_new(int type, int pad) 4079 HWND API dw_box_new(int type, int pad)
4080 { 4080 {
4081 Box *newbox = calloc(1, sizeof(Box)); 4081 Box *newbox = calloc(1, sizeof(Box));
4082 4082
4083 newbox->pad = pad; 4083 newbox->pad = pad;
4084 newbox->type = type; 4084 newbox->type = type;
4085 newbox->count = 0; 4085 newbox->count = 0;
4086 newbox->grouphwnd = NULLHANDLE; 4086 newbox->grouphwnd = NULLHANDLE;
4087 4087
4088 newbox->hwnd = WinCreateWindow(HWND_OBJECT, 4088 newbox->hwnd = WinCreateWindow(HWND_OBJECT,
4089 WC_FRAME, 4089 WC_FRAME,
4090 NULL, 4090 NULL,
4091 WS_VISIBLE | WS_CLIPCHILDREN | 4091 WS_VISIBLE | WS_CLIPCHILDREN |
4092 FS_NOBYTEALIGN, 4092 FS_NOBYTEALIGN,
4093 0,0,2000,1000, 4093 0,0,2000,1000,
4094 NULLHANDLE, 4094 NULLHANDLE,
4095 HWND_TOP, 4095 HWND_TOP,
4096 0L, 4096 0L,
4097 NULL, 4097 NULL,
4098 NULL); 4098 NULL);
4099 4099
4100 newbox->oldproc = WinSubclassWindow(newbox->hwnd, _controlproc); 4100 newbox->oldproc = WinSubclassWindow(newbox->hwnd, _controlproc);
4101 WinSetWindowPtr(newbox->hwnd, QWP_USER, newbox); 4101 WinSetWindowPtr(newbox->hwnd, QWP_USER, newbox);
4102 dw_window_set_color(newbox->hwnd, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); 4102 dw_window_set_color(newbox->hwnd, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
4103 return newbox->hwnd; 4103 return newbox->hwnd;
4104 } 4104 }
4105 4105
4106 /* 4106 /*
4107 * Create a new Group Box to be packed. 4107 * Create a new Group Box to be packed.
4108 * Parameters: 4108 * Parameters:
4110 * pad: Number of pixels to pad around the box. 4110 * pad: Number of pixels to pad around the box.
4111 * title: Text to be displayined in the group outline. 4111 * title: Text to be displayined in the group outline.
4112 */ 4112 */
4113 HWND API dw_groupbox_new(int type, int pad, char *title) 4113 HWND API dw_groupbox_new(int type, int pad, char *title)
4114 { 4114 {
4115 Box *newbox = calloc(1, sizeof(Box)); 4115 Box *newbox = calloc(1, sizeof(Box));
4116 newbox->pad = pad; 4116 newbox->pad = pad;
4117 newbox->type = type; 4117 newbox->type = type;
4118 newbox->count = 0; 4118 newbox->count = 0;
4119 4119
4120 newbox->hwnd = WinCreateWindow(HWND_OBJECT, 4120 newbox->hwnd = WinCreateWindow(HWND_OBJECT,
4121 WC_FRAME, 4121 WC_FRAME,
4122 NULL, 4122 NULL,
4123 WS_VISIBLE | 4123 WS_VISIBLE |
4124 FS_NOBYTEALIGN, 4124 FS_NOBYTEALIGN,
4125 0,0,2000,1000, 4125 0,0,2000,1000,
4126 NULLHANDLE, 4126 NULLHANDLE,
4127 HWND_TOP, 4127 HWND_TOP,
4128 0L, 4128 0L,
4129 NULL, 4129 NULL,
4130 NULL); 4130 NULL);
4131 4131
4132 newbox->grouphwnd = WinCreateWindow(newbox->hwnd, 4132 newbox->grouphwnd = WinCreateWindow(newbox->hwnd,
4133 WC_STATIC, 4133 WC_STATIC,
4134 title, 4134 title,
4135 WS_VISIBLE | SS_GROUPBOX | 4135 WS_VISIBLE | SS_GROUPBOX |
4136 WS_GROUP, 4136 WS_GROUP,
4137 0,0,2000,1000, 4137 0,0,2000,1000,
4138 NULLHANDLE, 4138 NULLHANDLE,
4139 HWND_TOP, 4139 HWND_TOP,
4140 0L, 4140 0L,
4141 NULL, 4141 NULL,
4142 NULL); 4142 NULL);
4143 4143
4144 WinSetWindowPtr(newbox->hwnd, QWP_USER, newbox); 4144 WinSetWindowPtr(newbox->hwnd, QWP_USER, newbox);
4145 dw_window_set_color(newbox->hwnd, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); 4145 dw_window_set_color(newbox->hwnd, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
4146 dw_window_set_color(newbox->grouphwnd, DW_CLR_BLACK, DW_CLR_PALEGRAY); 4146 dw_window_set_color(newbox->grouphwnd, DW_CLR_BLACK, DW_CLR_PALEGRAY);
4147 dw_window_set_font(newbox->grouphwnd, DefaultFont); 4147 dw_window_set_font(newbox->grouphwnd, DefaultFont);
4148 return newbox->hwnd; 4148 return newbox->hwnd;
4149 } 4149 }
4150 4150
4151 /* 4151 /*
4152 * Create a new MDI Frame to be packed. 4152 * Create a new MDI Frame to be packed.
4153 * Parameters: 4153 * Parameters:
4154 * id: An ID to be used with dw_window_from_id or 0L. 4154 * id: An ID to be used with dw_window_from_id or 0L.
4155 */ 4155 */
4156 HWND API dw_mdi_new(unsigned long id) 4156 HWND API dw_mdi_new(unsigned long id)
4157 { 4157 {
4158 HWND hwndframe; 4158 HWND hwndframe;
4159 ULONG back = CLR_DARKGRAY; 4159 ULONG back = CLR_DARKGRAY;
4160 4160
4161 hwndframe = WinCreateWindow(HWND_OBJECT, 4161 hwndframe = WinCreateWindow(HWND_OBJECT,
4162 WC_FRAME, 4162 WC_FRAME,
4163 NULL, 4163 NULL,
4164 WS_VISIBLE | WS_CLIPCHILDREN | 4164 WS_VISIBLE | WS_CLIPCHILDREN |
4165 FS_NOBYTEALIGN, 4165 FS_NOBYTEALIGN,
4166 0,0,2000,1000, 4166 0,0,2000,1000,
4167 NULLHANDLE, 4167 NULLHANDLE,
4168 HWND_TOP, 4168 HWND_TOP,
4169 id, 4169 id,
4170 NULL, 4170 NULL,
4171 NULL); 4171 NULL);
4172 /* Make the MDI Client area the same color as Windows and Unix */ 4172 /* Make the MDI Client area the same color as Windows and Unix */
4173 WinSetPresParam(hwndframe, PP_BACKGROUNDCOLORINDEX, sizeof(ULONG), &back); 4173 WinSetPresParam(hwndframe, PP_BACKGROUNDCOLORINDEX, sizeof(ULONG), &back);
4174 return hwndframe; 4174 return hwndframe;
4175 } 4175 }
4176 4176
4177 /* 4177 /*
4178 * Create a bitmap object to be packed. 4178 * Create a bitmap object to be packed.
4179 * Parameters: 4179 * Parameters:
4180 * id: An ID to be used with dw_window_from_id() or 0L. 4180 * id: An ID to be used with dw_window_from_id() or 0L.
4181 */ 4181 */
4182 HWND API dw_bitmap_new(ULONG id) 4182 HWND API dw_bitmap_new(ULONG id)
4183 { 4183 {
4184 return WinCreateWindow(HWND_OBJECT, 4184 return WinCreateWindow(HWND_OBJECT,
4185 WC_STATIC, 4185 WC_STATIC,
4186 NULL, 4186 NULL,
4187 WS_VISIBLE | SS_TEXT, 4187 WS_VISIBLE | SS_TEXT,
4188 0,0,2000,1000, 4188 0,0,2000,1000,
4189 NULLHANDLE, 4189 NULLHANDLE,
4190 HWND_TOP, 4190 HWND_TOP,
4191 id, 4191 id,
4192 NULL, 4192 NULL,
4193 NULL); 4193 NULL);
4194 } 4194 }
4195 4195
4196 /* 4196 /*
4197 * Create a notebook object to be packed. 4197 * Create a notebook object to be packed.
4198 * Parameters: 4198 * Parameters:
4199 * id: An ID to be used for getting the resource from the 4199 * id: An ID to be used for getting the resource from the
4200 * resource file. 4200 * resource file.
4201 */ 4201 */
4202 HWND API dw_notebook_new(ULONG id, int top) 4202 HWND API dw_notebook_new(ULONG id, int top)
4203 { 4203 {
4204 ULONG flags; 4204 ULONG flags;
4205 HWND tmp; 4205 HWND tmp;
4206 4206
4207 if(top) 4207 if(top)
4208 flags = BKS_MAJORTABTOP; 4208 flags = BKS_MAJORTABTOP;
4209 else 4209 else
4210 flags = BKS_MAJORTABBOTTOM; 4210 flags = BKS_MAJORTABBOTTOM;
4211 4211
4212 tmp = WinCreateWindow(HWND_OBJECT, 4212 tmp = WinCreateWindow(HWND_OBJECT,
4213 WC_NOTEBOOK, 4213 WC_NOTEBOOK,
4214 NULL, 4214 NULL,
4215 WS_VISIBLE | 4215 WS_VISIBLE |
4216 #ifdef BKS_TABBEDDIALOG 4216 #ifdef BKS_TABBEDDIALOG
4217 BKS_TABBEDDIALOG | 4217 BKS_TABBEDDIALOG |
4218 #endif 4218 #endif
4219 flags, 4219 flags,
4220 0,0,2000,1000, 4220 0,0,2000,1000,
4221 NULLHANDLE, 4221 NULLHANDLE,
4222 HWND_TOP, 4222 HWND_TOP,
4223 id, 4223 id,
4224 NULL, 4224 NULL,
4225 NULL); 4225 NULL);
4226 4226
4227 /* Fix tab sizes on Warp 3 */ 4227 /* Fix tab sizes on Warp 3 */
4228 if(!IS_WARP4()) 4228 if(!IS_WARP4())
4229 { 4229 {
4230 /* best sizes to be determined by trial and error */ 4230 /* best sizes to be determined by trial and error */
4231 WinSendMsg(tmp, BKM_SETDIMENSIONS,MPFROM2SHORT(102, 28), MPFROMSHORT( BKA_MAJORTAB)); 4231 WinSendMsg(tmp, BKM_SETDIMENSIONS,MPFROM2SHORT(102, 28), MPFROMSHORT( BKA_MAJORTAB));
4232 } 4232 }
4233 4233
4234 dw_window_set_font(tmp, DefaultFont); 4234 dw_window_set_font(tmp, DefaultFont);
4235 return tmp; 4235 return tmp;
4236 } 4236 }
4237 4237
4238 /* 4238 /*
4239 * Create a menu object to be popped up. 4239 * Create a menu object to be popped up.
4240 * Parameters: 4240 * Parameters:
4241 * id: An ID to be used for getting the resource from the 4241 * id: An ID to be used for getting the resource from the
4242 * resource file. 4242 * resource file.
4243 */ 4243 */
4244 HMENUI API dw_menu_new(ULONG id) 4244 HMENUI API dw_menu_new(ULONG id)
4245 { 4245 {
4246 HMENUI tmp = WinCreateWindow(HWND_OBJECT, 4246 HMENUI tmp = WinCreateWindow(HWND_OBJECT,
4247 WC_MENU, 4247 WC_MENU,
4248 NULL, 4248 NULL,
4249 WS_VISIBLE, 4249 WS_VISIBLE,
4250 0,0,2000,1000, 4250 0,0,2000,1000,
4251 NULLHANDLE, 4251 NULLHANDLE,
4252 HWND_TOP, 4252 HWND_TOP,
4253 id, 4253 id,
4254 NULL, 4254 NULL,
4255 NULL); 4255 NULL);
4256 return tmp; 4256 return tmp;
4257 } 4257 }
4258 4258
4259 /* 4259 /*
4260 * Create a menubar on a window. 4260 * Create a menubar on a window.
4261 * Parameters: 4261 * Parameters:
4262 * location: Handle of a window frame to be attached to. 4262 * location: Handle of a window frame to be attached to.
4263 */ 4263 */
4264 HMENUI API dw_menubar_new(HWND location) 4264 HMENUI API dw_menubar_new(HWND location)
4265 { 4265 {
4266 HMENUI tmp = WinCreateWindow(location, 4266 HMENUI tmp = WinCreateWindow(location,
4267 WC_MENU, 4267 WC_MENU,
4268 NULL, 4268 NULL,
4269 WS_VISIBLE | MS_ACTIONBAR, 4269 WS_VISIBLE | MS_ACTIONBAR,
4270 0,0,2000,1000, 4270 0,0,2000,1000,
4271 location, 4271 location,
4272 HWND_TOP, 4272 HWND_TOP,
4273 FID_MENU, 4273 FID_MENU,
4274 NULL, 4274 NULL,
4275 NULL); 4275 NULL);
4276 dw_window_set_data(tmp, "_dw_owner", (void *)location); 4276 dw_window_set_data(tmp, "_dw_owner", (void *)location);
4277 dw_window_set_data(tmp, "_dw_menubar", (void *)location); 4277 dw_window_set_data(tmp, "_dw_menubar", (void *)location);
4278 return tmp; 4278 return tmp;
4279 } 4279 }
4280 4280
4281 /* 4281 /*
4282 * Destroys a menu created with dw_menubar_new or dw_menu_new. 4282 * Destroys a menu created with dw_menubar_new or dw_menu_new.
4283 * Parameters: 4283 * Parameters:
4284 * menu: Handle of a menu. 4284 * menu: Handle of a menu.
4285 */ 4285 */
4286 void API dw_menu_destroy(HMENUI *menu) 4286 void API dw_menu_destroy(HMENUI *menu)
4287 { 4287 {
4288 if(menu) 4288 if(menu)
4289 WinDestroyWindow(*menu); 4289 WinDestroyWindow(*menu);
4290 } 4290 }
4291 4291
4292 /* 4292 /*
4293 * Adds a menuitem or submenu to an existing menu. 4293 * Adds a menuitem or submenu to an existing menu.
4294 * Parameters: 4294 * Parameters:
4448 * x: X coordinate. 4448 * x: X coordinate.
4449 * y: Y coordinate. 4449 * y: Y coordinate.
4450 */ 4450 */
4451 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) 4451 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
4452 { 4452 {
4453 if(menu) 4453 if(menu)
4454 { 4454 {
4455 popup = parent; 4455 popup = parent;
4456 dw_window_set_data(*menu, "_dw_popup", (void *)1); 4456 dw_window_set_data(*menu, "_dw_popup", (void *)1);
4457 WinPopupMenu(HWND_DESKTOP, parent, *menu, x, dw_screen_height() - y, 0, PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_VCONSTRAIN | PU_HCONSTRAIN); 4457 WinPopupMenu(HWND_DESKTOP, parent, *menu, x, dw_screen_height() - y, 0, PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_VCONSTRAIN | PU_HCONSTRAIN);
4458 } 4458 }
4459 } 4459 }
4460 4460
4461 /* 4461 /*
4462 * Returns the current X and Y coordinates of the mouse pointer. 4462 * Returns the current X and Y coordinates of the mouse pointer.
4463 * Parameters: 4463 * Parameters:
4464 * x: Pointer to variable to store X coordinate. 4464 * x: Pointer to variable to store X coordinate.
4465 * y: Pointer to variable to store Y coordinate. 4465 * y: Pointer to variable to store Y coordinate.
4466 */ 4466 */
4467 void API dw_pointer_query_pos(long *x, long *y) 4467 void API dw_pointer_query_pos(long *x, long *y)
4468 { 4468 {
4469 POINTL ptl; 4469 POINTL ptl;
4470 4470
4471 WinQueryPointerPos(HWND_DESKTOP, &ptl); 4471 WinQueryPointerPos(HWND_DESKTOP, &ptl);
4472 if(x && y) 4472 if(x && y)
4473 { 4473 {
4474 *x = ptl.x; 4474 *x = ptl.x;
4475 *y = dw_screen_height() - ptl.y; 4475 *y = dw_screen_height() - ptl.y;
4476 } 4476 }
4477 } 4477 }
4478 4478
4479 /* 4479 /*
4480 * Sets the X and Y coordinates of the mouse pointer. 4480 * Sets the X and Y coordinates of the mouse pointer.
4481 * Parameters: 4481 * Parameters:
4482 * x: X coordinate. 4482 * x: X coordinate.
4483 * y: Y coordinate. 4483 * y: Y coordinate.
4484 */ 4484 */
4485 void API dw_pointer_set_pos(long x, long y) 4485 void API dw_pointer_set_pos(long x, long y)
4486 { 4486 {
4487 WinSetPointerPos(HWND_DESKTOP, x, dw_screen_height() - y); 4487 WinSetPointerPos(HWND_DESKTOP, x, dw_screen_height() - y);
4488 } 4488 }
4489 4489
4490 4490
4491 /* 4491 /*
4492 * Create a container object to be packed. 4492 * Create a container object to be packed.
4494 * id: An ID to be used for getting the resource from the 4494 * id: An ID to be used for getting the resource from the
4495 * resource file. 4495 * resource file.
4496 */ 4496 */
4497 HWND API dw_container_new(ULONG id, int multi) 4497 HWND API dw_container_new(ULONG id, int multi)
4498 { 4498 {
4499 WindowData *blah = calloc(1, sizeof(WindowData)); 4499 WindowData *blah = calloc(1, sizeof(WindowData));
4500 HWND tmp = WinCreateWindow(HWND_OBJECT, 4500 HWND tmp = WinCreateWindow(HWND_OBJECT,
4501 WC_CONTAINER, 4501 WC_CONTAINER,
4502 NULL, 4502 NULL,
4503 WS_VISIBLE | CCS_READONLY | 4503 WS_VISIBLE | CCS_READONLY |
4504 (multi ? CCS_EXTENDSEL : CCS_SINGLESEL) | 4504 (multi ? CCS_EXTENDSEL : CCS_SINGLESEL) |
4505 CCS_AUTOPOSITION, 4505 CCS_AUTOPOSITION,
4506 0,0,2000,1000, 4506 0,0,2000,1000,
4507 NULLHANDLE, 4507 NULLHANDLE,
4508 HWND_TOP, 4508 HWND_TOP,
4509 id ? id : (GlobalID++), 4509 id ? id : (GlobalID++),
4510 NULL, 4510 NULL,
4511 NULL); 4511 NULL);
4512 blah->oldproc = WinSubclassWindow(tmp, _TreeProc); 4512 blah->oldproc = WinSubclassWindow(tmp, _TreeProc);
4513 WinSetWindowPtr(tmp, QWP_USER, blah); 4513 WinSetWindowPtr(tmp, QWP_USER, blah);
4514 dw_window_set_font(tmp, DefaultFont); 4514 dw_window_set_font(tmp, DefaultFont);
4515 dw_window_set_data(tmp, "_dw_container", (void *)1); 4515 dw_window_set_data(tmp, "_dw_container", (void *)1);
4516 return tmp; 4516 return tmp;
4517 } 4517 }
4518 4518
4519 /* 4519 /*
4520 * Create a tree object to be packed. 4520 * Create a tree object to be packed.
4521 * Parameters: 4521 * Parameters:
4522 * id: An ID to be used for getting the resource from the 4522 * id: An ID to be used for getting the resource from the
4523 * resource file. 4523 * resource file.
4524 */ 4524 */
4525 HWND API dw_tree_new(ULONG id) 4525 HWND API dw_tree_new(ULONG id)
4526 { 4526 {
4527 CNRINFO cnrinfo; 4527 CNRINFO cnrinfo;
4528 WindowData *blah = calloc(1, sizeof(WindowData)); 4528 WindowData *blah = calloc(1, sizeof(WindowData));
4529 HWND tmp = WinCreateWindow(HWND_OBJECT, 4529 HWND tmp = WinCreateWindow(HWND_OBJECT,
4530 WC_CONTAINER, 4530 WC_CONTAINER,
4531 NULL, 4531 NULL,
4532 WS_VISIBLE | CCS_READONLY | 4532 WS_VISIBLE | CCS_READONLY |
4533 CCS_SINGLESEL | CCS_AUTOPOSITION, 4533 CCS_SINGLESEL | CCS_AUTOPOSITION,
4534 0,0,2000,1000, 4534 0,0,2000,1000,
4535 NULLHANDLE, 4535 NULLHANDLE,
4536 HWND_TOP, 4536 HWND_TOP,
4537 id ? id : (GlobalID++), 4537 id ? id : (GlobalID++),
4538 NULL, 4538 NULL,
4539 NULL); 4539 NULL);
4540 4540
4541 cnrinfo.flWindowAttr = CV_TREE | CA_TREELINE; 4541 cnrinfo.flWindowAttr = CV_TREE | CA_TREELINE;
4542 cnrinfo.slBitmapOrIcon.cx = 16; 4542 cnrinfo.slBitmapOrIcon.cx = 16;
4543 cnrinfo.slBitmapOrIcon.cy = 16; 4543 cnrinfo.slBitmapOrIcon.cy = 16;
4544 cnrinfo.cyLineSpacing = 0; 4544 cnrinfo.cyLineSpacing = 0;
4545 cnrinfo.cxTreeIndent = 16; 4545 cnrinfo.cxTreeIndent = 16;
4546 cnrinfo.cxTreeLine = 1; 4546 cnrinfo.cxTreeLine = 1;
4547 4547
4548 WinSendMsg(tmp, CM_SETCNRINFO, &cnrinfo, MPFROMLONG(CMA_FLWINDOWATTR | CMA_SLBITMAPORICON | 4548 WinSendMsg(tmp, CM_SETCNRINFO, &cnrinfo, MPFROMLONG(CMA_FLWINDOWATTR | CMA_SLBITMAPORICON |
4549 CMA_LINESPACING | CMA_CXTREEINDENT | CMA_CXTREELINE)); 4549 CMA_LINESPACING | CMA_CXTREEINDENT | CMA_CXTREELINE));
4550 blah->oldproc = WinSubclassWindow(tmp, _TreeProc); 4550 blah->oldproc = WinSubclassWindow(tmp, _TreeProc);
4551 WinSetWindowPtr(tmp, QWP_USER, blah); 4551 WinSetWindowPtr(tmp, QWP_USER, blah);
4552 dw_window_set_font(tmp, DefaultFont); 4552 dw_window_set_font(tmp, DefaultFont);
4553 return tmp; 4553 return tmp;
4554 } 4554 }
4555 4555
4556 /* 4556 /*
4557 * Create a new static text window (widget) to be packed. 4557 * Create a new static text window (widget) to be packed.
4558 * Parameters: 4558 * Parameters:
4559 * text: The text to be display by the static text widget. 4559 * text: The text to be display by the static text widget.
4560 * id: An ID to be used with dw_window_from_id() or 0L. 4560 * id: An ID to be used with dw_window_from_id() or 0L.
4561 */ 4561 */
4562 HWND API dw_text_new(char *text, ULONG id) 4562 HWND API dw_text_new(char *text, ULONG id)
4563 { 4563 {
4564 WindowData *blah = calloc(sizeof(WindowData), 1); 4564 WindowData *blah = calloc(sizeof(WindowData), 1);
4565 HWND tmp = WinCreateWindow(HWND_OBJECT, 4565 HWND tmp = WinCreateWindow(HWND_OBJECT,
4566 WC_STATIC, 4566 WC_STATIC,
4567 text, 4567 text,
4568 WS_VISIBLE | SS_TEXT, 4568 WS_VISIBLE | SS_TEXT,
4569 0,0,2000,1000, 4569 0,0,2000,1000,
4570 NULLHANDLE, 4570 NULLHANDLE,
4571 HWND_TOP, 4571 HWND_TOP,
4572 id, 4572 id,
4573 NULL, 4573 NULL,
4574 NULL); 4574 NULL);
4575 blah->oldproc = WinSubclassWindow(tmp, _textproc); 4575 blah->oldproc = WinSubclassWindow(tmp, _textproc);
4576 WinSetWindowPtr(tmp, QWP_USER, blah); 4576 WinSetWindowPtr(tmp, QWP_USER, blah);
4577 dw_window_set_font(tmp, DefaultFont); 4577 dw_window_set_font(tmp, DefaultFont);
4578 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); 4578 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY);
4579 return tmp; 4579 return tmp;
4580 } 4580 }
4581 4581
4582 /* 4582 /*
4583 * Create a new status text window (widget) to be packed. 4583 * Create a new status text window (widget) to be packed.
4584 * Parameters: 4584 * Parameters:
4585 * text: The text to be display by the static text widget. 4585 * text: The text to be display by the static text widget.
4586 * id: An ID to be used with dw_window_from_id() or 0L. 4586 * id: An ID to be used with dw_window_from_id() or 0L.
4587 */ 4587 */
4588 HWND API dw_status_text_new(char *text, ULONG id) 4588 HWND API dw_status_text_new(char *text, ULONG id)
4589 { 4589 {
4590 WindowData *blah = calloc(sizeof(WindowData), 1); 4590 WindowData *blah = calloc(sizeof(WindowData), 1);
4591 HWND tmp = WinCreateWindow(HWND_OBJECT, 4591 HWND tmp = WinCreateWindow(HWND_OBJECT,
4592 WC_STATIC, 4592 WC_STATIC,
4593 text, 4593 text,
4594 WS_VISIBLE | SS_TEXT, 4594 WS_VISIBLE | SS_TEXT,
4595 0,0,2000,1000, 4595 0,0,2000,1000,
4596 NULLHANDLE, 4596 NULLHANDLE,
4597 HWND_TOP, 4597 HWND_TOP,
4598 id, 4598 id,
4599 NULL, 4599 NULL,
4600 NULL); 4600 NULL);
4601 blah->oldproc = WinSubclassWindow(tmp, _statusproc); 4601 blah->oldproc = WinSubclassWindow(tmp, _statusproc);
4602 WinSetWindowPtr(tmp, QWP_USER, blah); 4602 WinSetWindowPtr(tmp, QWP_USER, blah);
4603 dw_window_set_font(tmp, DefaultFont); 4603 dw_window_set_font(tmp, DefaultFont);
4604 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); 4604 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY);
4605 return tmp; 4605 return tmp;
4606 } 4606 }
4607 4607
4608 #ifndef MLS_LIMITVSCROLL 4608 #ifndef MLS_LIMITVSCROLL
4609 #define MLS_LIMITVSCROLL 0x00000080L 4609 #define MLS_LIMITVSCROLL 0x00000080L
4610 #endif 4610 #endif
4614 * Parameters: 4614 * Parameters:
4615 * id: An ID to be used with dw_window_from_id() or 0L. 4615 * id: An ID to be used with dw_window_from_id() or 0L.
4616 */ 4616 */
4617 HWND API dw_mle_new(ULONG id) 4617 HWND API dw_mle_new(ULONG id)
4618 { 4618 {
4619 WindowData *blah = calloc(1, sizeof(WindowData)); 4619 WindowData *blah = calloc(1, sizeof(WindowData));
4620 HWND tmp = WinCreateWindow(HWND_OBJECT, 4620 HWND tmp = WinCreateWindow(HWND_OBJECT,
4621 WC_MLE, 4621 WC_MLE,
4622 "", 4622 "",
4623 WS_VISIBLE | 4623 WS_VISIBLE |
4624 MLS_BORDER | MLS_IGNORETAB | 4624 MLS_BORDER | MLS_IGNORETAB |
4625 MLS_READONLY | MLS_VSCROLL | 4625 MLS_READONLY | MLS_VSCROLL |
4626 MLS_LIMITVSCROLL, 4626 MLS_LIMITVSCROLL,
4627 0,0,2000,1000, 4627 0,0,2000,1000,
4628 NULLHANDLE, 4628 NULLHANDLE,
4629 HWND_TOP, 4629 HWND_TOP,
4630 id, 4630 id,
4631 NULL, 4631 NULL,
4632 NULL); 4632 NULL);
4633 blah->oldproc = WinSubclassWindow(tmp, _mleproc); 4633 blah->oldproc = WinSubclassWindow(tmp, _mleproc);
4634 WinSetWindowPtr(tmp, QWP_USER, blah); 4634 WinSetWindowPtr(tmp, QWP_USER, blah);
4635 dw_window_set_font(tmp, DefaultFont); 4635 dw_window_set_font(tmp, DefaultFont);
4636 return tmp; 4636 return tmp;
4637 } 4637 }
4638 4638
4639 /* 4639 /*
4640 * Create a new Entryfield window (widget) to be packed. 4640 * Create a new Entryfield window (widget) to be packed.
4641 * Parameters: 4641 * Parameters:
4643 * id: An ID to be used with dw_window_from_id() or 0L. 4643 * id: An ID to be used with dw_window_from_id() or 0L.
4644 */ 4644 */
4645 HWND API dw_entryfield_new(char *text, ULONG id) 4645 HWND API dw_entryfield_new(char *text, ULONG id)
4646 { 4646 {
4647 4647
4648 WindowData *blah = calloc(1, sizeof(WindowData)); 4648 WindowData *blah = calloc(1, sizeof(WindowData));
4649 HWND tmp = WinCreateWindow(HWND_OBJECT, 4649 HWND tmp = WinCreateWindow(HWND_OBJECT,
4650 WC_ENTRYFIELD, 4650 WC_ENTRYFIELD,
4651 text, 4651 text,
4652 WS_VISIBLE | ES_MARGIN | 4652 WS_VISIBLE | ES_MARGIN |
4653 ES_AUTOSCROLL | WS_TABSTOP, 4653 ES_AUTOSCROLL | WS_TABSTOP,
4654 0,0,2000,1000, 4654 0,0,2000,1000,
4655 NULLHANDLE, 4655 NULLHANDLE,
4656 HWND_TOP, 4656 HWND_TOP,
4657 id, 4657 id,
4658 NULL, 4658 NULL,
4659 NULL); 4659 NULL);
4660 blah->oldproc = WinSubclassWindow(tmp, _entryproc); 4660 blah->oldproc = WinSubclassWindow(tmp, _entryproc);
4661 WinSetWindowPtr(tmp, QWP_USER, blah); 4661 WinSetWindowPtr(tmp, QWP_USER, blah);
4662 dw_window_set_font(tmp, DefaultFont); 4662 dw_window_set_font(tmp, DefaultFont);
4663 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE); 4663 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE);
4664 return tmp; 4664 return tmp;
4665 } 4665 }
4666 4666
4667 /* 4667 /*
4668 * Create a new Entryfield (password) window (widget) to be packed. 4668 * Create a new Entryfield (password) window (widget) to be packed.
4669 * Parameters: 4669 * Parameters:
4670 * text: The default text to be in the entryfield widget. 4670 * text: The default text to be in the entryfield widget.
4671 * id: An ID to be used with dw_window_from_id() or 0L. 4671 * id: An ID to be used with dw_window_from_id() or 0L.
4672 */ 4672 */
4673 HWND API dw_entryfield_password_new(char *text, ULONG id) 4673 HWND API dw_entryfield_password_new(char *text, ULONG id)
4674 { 4674 {
4675 WindowData *blah = calloc(1, sizeof(WindowData)); 4675 WindowData *blah = calloc(1, sizeof(WindowData));
4676 HWND tmp = WinCreateWindow(HWND_OBJECT, 4676 HWND tmp = WinCreateWindow(HWND_OBJECT,
4677 WC_ENTRYFIELD, 4677 WC_ENTRYFIELD,
4678 text, 4678 text,
4679 WS_VISIBLE | ES_MARGIN | ES_UNREADABLE | 4679 WS_VISIBLE | ES_MARGIN | ES_UNREADABLE |
4680 ES_AUTOSCROLL | WS_TABSTOP, 4680 ES_AUTOSCROLL | WS_TABSTOP,
4681 0,0,2000,1000, 4681 0,0,2000,1000,
4682 NULLHANDLE, 4682 NULLHANDLE,
4683 HWND_TOP, 4683 HWND_TOP,
4684 id, 4684 id,
4685 NULL, 4685 NULL,
4686 NULL); 4686 NULL);
4687 blah->oldproc = WinSubclassWindow(tmp, _entryproc); 4687 blah->oldproc = WinSubclassWindow(tmp, _entryproc);
4688 WinSetWindowPtr(tmp, QWP_USER, blah); 4688 WinSetWindowPtr(tmp, QWP_USER, blah);
4689 dw_window_set_font(tmp, DefaultFont); 4689 dw_window_set_font(tmp, DefaultFont);
4690 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE); 4690 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE);
4691 return tmp; 4691 return tmp;
4692 } 4692 }
4693 4693
4694 /* 4694 /*
4695 * Create a new Combobox window (widget) to be packed. 4695 * Create a new Combobox window (widget) to be packed.
4696 * Parameters: 4696 * Parameters:
4697 * text: The default text to be in the combpbox widget. 4697 * text: The default text to be in the combpbox widget.
4698 * id: An ID to be used with dw_window_from_id() or 0L. 4698 * id: An ID to be used with dw_window_from_id() or 0L.
4699 */ 4699 */
4700 HWND API dw_combobox_new(char *text, ULONG id) 4700 HWND API dw_combobox_new(char *text, ULONG id)
4701 { 4701 {
4702 WindowData *blah = calloc(1, sizeof(WindowData)); 4702 WindowData *blah = calloc(1, sizeof(WindowData));
4703 HWND frame = dw_box_new(DW_HORZ, 0); 4703 HWND frame = dw_box_new(DW_HORZ, 0);
4704 HWND tmp = WinCreateWindow(frame, 4704 HWND tmp = WinCreateWindow(frame,
4705 WC_COMBOBOX, 4705 WC_COMBOBOX,
4706 text, 4706 text,
4707 WS_VISIBLE | CBS_DROPDOWN | WS_GROUP, 4707 WS_VISIBLE | CBS_DROPDOWN | WS_GROUP,
4708 0,0,2000,1000, 4708 0,0,2000,1000,
4709 NULLHANDLE, 4709 NULLHANDLE,
4710 HWND_TOP, 4710 HWND_TOP,
4711 id, 4711 id,
4712 NULL, 4712 NULL,
4713 NULL); 4713 NULL);
4714 HENUM henum = WinBeginEnumWindows(tmp); 4714 HENUM henum = WinBeginEnumWindows(tmp);
4715 HWND child, last = NULLHANDLE; 4715 HWND child, last = NULLHANDLE;
4716 4716
4717 while((child = WinGetNextWindow(henum)) != NULLHANDLE) 4717 while((child = WinGetNextWindow(henum)) != NULLHANDLE)
4718 { 4718 {
4719 WindowData *moreblah = calloc(1, sizeof(WindowData)); 4719 WindowData *moreblah = calloc(1, sizeof(WindowData));
4720 moreblah->oldproc = WinSubclassWindow(child, _comboentryproc); 4720 moreblah->oldproc = WinSubclassWindow(child, _comboentryproc);
4721 WinSetWindowPtr(child, QWP_USER, moreblah); 4721 WinSetWindowPtr(child, QWP_USER, moreblah);
4722 dw_window_set_color(child, DW_CLR_BLACK, DW_CLR_WHITE); 4722 dw_window_set_color(child, DW_CLR_BLACK, DW_CLR_WHITE);
4723 last = child; 4723 last = child;
4724 } 4724 }
4725 WinEndEnumWindows(henum); 4725 WinEndEnumWindows(henum);
4726 blah->oldproc = WinSubclassWindow(tmp, _comboproc); 4726 blah->oldproc = WinSubclassWindow(tmp, _comboproc);
4727 WinSetWindowPtr(tmp, QWP_USER, blah); 4727 WinSetWindowPtr(tmp, QWP_USER, blah);
4728 dw_window_set_font(tmp, DefaultFont); 4728 dw_window_set_font(tmp, DefaultFont);
4729 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE); 4729 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE);
4730 dw_window_set_data(tmp, "_dw_comboentry", (void *)last); 4730 dw_window_set_data(tmp, "_dw_comboentry", (void *)last);
4731 dw_window_set_data(tmp, "_dw_combo_box", (void *)frame); 4731 dw_window_set_data(tmp, "_dw_combo_box", (void *)frame);
4732 WinSetOwner(tmp, frame); 4732 WinSetOwner(tmp, frame);
4733 return tmp; 4733 return tmp;
4734 } 4734 }
4735 4735
4736 /* 4736 /*
4737 * Create a new button window (widget) to be packed. 4737 * Create a new button window (widget) to be packed.
4738 * Parameters: 4738 * Parameters:
4739 * text: The text to be display by the static text widget. 4739 * text: The text to be display by the static text widget.
4740 * id: An ID to be used with dw_window_from_id() or 0L. 4740 * id: An ID to be used with dw_window_from_id() or 0L.
4741 */ 4741 */
4742 HWND API dw_button_new(char *text, ULONG id) 4742 HWND API dw_button_new(char *text, ULONG id)
4743 { 4743 {
4744 BubbleButton *bubble = calloc(sizeof(BubbleButton), 1); 4744 BubbleButton *bubble = calloc(sizeof(BubbleButton), 1);
4745 4745
4746 HWND tmp = WinCreateWindow(HWND_OBJECT, 4746 HWND tmp = WinCreateWindow(HWND_OBJECT,
4747 WC_BUTTON, 4747 WC_BUTTON,
4748 text, 4748 text,
4749 WS_VISIBLE, 4749 WS_VISIBLE,
4750 0,0,2000,1000, 4750 0,0,2000,1000,
4751 NULLHANDLE, 4751 NULLHANDLE,
4752 HWND_TOP, 4752 HWND_TOP,
4753 id, 4753 id,
4754 NULL, 4754 NULL,
4755 NULL); 4755 NULL);
4756 4756
4757 bubble->id = id; 4757 bubble->id = id;
4758 bubble->bubbletext[0] = '\0'; 4758 bubble->bubbletext[0] = '\0';
4759 bubble->pOldProc = WinSubclassWindow(tmp, _BtProc); 4759 bubble->pOldProc = WinSubclassWindow(tmp, _BtProc);
4760 4760
4761 WinSetWindowPtr(tmp, QWP_USER, bubble); 4761 WinSetWindowPtr(tmp, QWP_USER, bubble);
4762 dw_window_set_font(tmp, DefaultFont); 4762 dw_window_set_font(tmp, DefaultFont);
4763 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); 4763 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY);
4764 return tmp; 4764 return tmp;
4765 } 4765 }
4766 4766
4767 /* Function: GenResIDStr 4767 /* Function: GenResIDStr
4768 ** Abstract: Generate string '#nnnn' for a given ID for using with Button 4768 ** Abstract: Generate string '#nnnn' for a given ID for using with Button
4769 ** controls 4769 ** controls
4770 */ 4770 */
4771 4771
4772 void _GenResIDStr(CHAR *buff, ULONG ulID) 4772 void _GenResIDStr(CHAR *buff, ULONG ulID)
4773 { 4773 {
4774 char *str; 4774 char *str;
4775 int slen = 0; 4775 int slen = 0;
4776 4776
4777 *buff++ = '#'; 4777 *buff++ = '#';
4778 4778
4779 str = buff; 4779 str = buff;
4780 4780
4781 do 4781 do
4782 { 4782 {
4783 *str++ = (ulID % 10) + '0'; 4783 *str++ = (ulID % 10) + '0';
4784 ulID /= 10; 4784 ulID /= 10;
4785 slen++; 4785 slen++;
4786 } 4786 }
4787 while(ulID); 4787 while(ulID);
4788 4788
4789 *str-- = 0; 4789 *str-- = 0;
4790 4790
4791 for(; str > buff; str--, buff++) 4791 for(; str > buff; str--, buff++)
4792 { 4792 {
4793 *buff ^= *str; 4793 *buff ^= *str;
4794 *str ^= *buff; 4794 *str ^= *buff;
4795 *buff ^= *str; 4795 *buff ^= *str;
4796 } 4796 }
4797 } 4797 }
4798 4798
4799 4799
4800 /* 4800 /*
4801 * Create a new bitmap button window (widget) to be packed. 4801 * Create a new bitmap button window (widget) to be packed.
4803 * text: Bubble help text to be displayed. 4803 * text: Bubble help text to be displayed.
4804 * id: An ID of a bitmap in the resource file. 4804 * id: An ID of a bitmap in the resource file.
4805 */ 4805 */
4806 HWND API dw_bitmapbutton_new(char *text, ULONG id) 4806 HWND API dw_bitmapbutton_new(char *text, ULONG id)
4807 { 4807 {
4808 char idbuf[256], *name = NULL; 4808 char idbuf[256], *name = NULL;
4809 HWND tmp; 4809 HWND tmp;
4810 BubbleButton *bubble = calloc(sizeof(BubbleButton), 1); 4810 BubbleButton *bubble = calloc(sizeof(BubbleButton), 1);
4811 HPOINTER icon = WinLoadPointer(HWND_DESKTOP, 0L, id); 4811 HPOINTER icon = WinLoadPointer(HWND_DESKTOP, 0L, id);
4812 4812
4813 if(!icon) 4813 if(!icon)
4814 { 4814 {
4815 name = idbuf; 4815 name = idbuf;
4816 _GenResIDStr(idbuf, id); 4816 _GenResIDStr(idbuf, id);
4817 } 4817 }
4818 4818
4819 tmp = WinCreateWindow(HWND_OBJECT, 4819 tmp = WinCreateWindow(HWND_OBJECT,
4820 WC_BUTTON, 4820 WC_BUTTON,
4821 name, 4821 name,
4822 WS_VISIBLE | BS_PUSHBUTTON | 4822 WS_VISIBLE | BS_PUSHBUTTON |
4823 BS_NOPOINTERFOCUS | BS_AUTOSIZE | 4823 BS_NOPOINTERFOCUS | BS_AUTOSIZE |
4824 (icon ? 0 : BS_BITMAP), 4824 (icon ? 0 : BS_BITMAP),
4825 0,0,2000,1000, 4825 0,0,2000,1000,
4826 NULLHANDLE, 4826 NULLHANDLE,
4827 HWND_TOP, 4827 HWND_TOP,
4828 id, 4828 id,
4829 NULL, 4829 NULL,
4830 NULL); 4830 NULL);
4831 4831
4832 bubble->id = id; 4832 bubble->id = id;
4833 strncpy(bubble->bubbletext, text, BUBBLE_HELP_MAX - 1); 4833 strncpy(bubble->bubbletext, text, BUBBLE_HELP_MAX - 1);
4834 bubble->bubbletext[BUBBLE_HELP_MAX - 1] = '\0'; 4834 bubble->bubbletext[BUBBLE_HELP_MAX - 1] = '\0';
4835 bubble->pOldProc = WinSubclassWindow(tmp, _BtProc); 4835 bubble->pOldProc = WinSubclassWindow(tmp, _BtProc);
4836 4836
4837 WinSetWindowPtr(tmp, QWP_USER, bubble); 4837 WinSetWindowPtr(tmp, QWP_USER, bubble);
4838 4838
4839 if(icon) 4839 if(icon)
4840 dw_window_set_data(tmp, "_dw_button_icon", (void *)icon); 4840 dw_window_set_data(tmp, "_dw_button_icon", (void *)icon);
4841 dw_window_set_data(tmp, "_dw_bitmapbutton", (void *)1); 4841 dw_window_set_data(tmp, "_dw_bitmapbutton", (void *)1);
4842 return tmp; 4842 return tmp;
4843 } 4843 }
4844 4844
4845 /* 4845 /*
4846 * Create a new bitmap button window (widget) to be packed from a file. 4846 * Create a new bitmap button window (widget) to be packed from a file.
4847 * Parameters: 4847 * Parameters:
5052 * text: The text to be display by the static text widget. 5052 * text: The text to be display by the static text widget.
5053 * id: An ID to be used with dw_window_from_id() or 0L. 5053 * id: An ID to be used with dw_window_from_id() or 0L.
5054 */ 5054 */
5055 HWND API dw_spinbutton_new(char *text, ULONG id) 5055 HWND API dw_spinbutton_new(char *text, ULONG id)
5056 { 5056 {
5057 WindowData *blah = calloc(sizeof(WindowData), 1); 5057 WindowData *blah = calloc(sizeof(WindowData), 1);
5058 HWND tmp = WinCreateWindow(HWND_OBJECT, 5058 HWND tmp = WinCreateWindow(HWND_OBJECT,
5059 WC_SPINBUTTON, 5059 WC_SPINBUTTON,
5060 text, 5060 text,
5061 WS_VISIBLE | SPBS_MASTER, 5061 WS_VISIBLE | SPBS_MASTER,
5062 0,0,2000,1000, 5062 0,0,2000,1000,
5063 NULLHANDLE, 5063 NULLHANDLE,
5064 HWND_TOP, 5064 HWND_TOP,
5065 id, 5065 id,
5066 NULL, 5066 NULL,
5067 NULL); 5067 NULL);
5068 HWND entry = _find_entryfield(tmp); 5068 HWND entry = _find_entryfield(tmp);
5069 blah->oldproc = WinSubclassWindow(tmp, _entryproc); 5069 blah->oldproc = WinSubclassWindow(tmp, _entryproc);
5070 WinSetWindowPtr(tmp, QWP_USER, blah); 5070 WinSetWindowPtr(tmp, QWP_USER, blah);
5071 blah = calloc(sizeof(WindowData), 1); 5071 blah = calloc(sizeof(WindowData), 1);
5072 blah->oldproc = WinSubclassWindow(entry, _spinentryproc); 5072 blah->oldproc = WinSubclassWindow(entry, _spinentryproc);
5073 WinSetWindowPtr(entry, QWP_USER, blah); 5073 WinSetWindowPtr(entry, QWP_USER, blah);
5074 dw_window_set_font(tmp, DefaultFont); 5074 dw_window_set_font(tmp, DefaultFont);
5075 dw_window_set_color(entry, DW_CLR_BLACK, DW_CLR_WHITE); 5075 dw_window_set_color(entry, DW_CLR_BLACK, DW_CLR_WHITE);
5076 return tmp; 5076 return tmp;
5077 } 5077 }
5078 5078
5079 /* 5079 /*
5080 * Create a new radiobutton window (widget) to be packed. 5080 * Create a new radiobutton window (widget) to be packed.
5081 * Parameters: 5081 * Parameters:
5082 * text: The text to be display by the static text widget. 5082 * text: The text to be display by the static text widget.
5083 * id: An ID to be used with dw_window_from_id() or 0L. 5083 * id: An ID to be used with dw_window_from_id() or 0L.
5084 */ 5084 */
5085 HWND API dw_radiobutton_new(char *text, ULONG id) 5085 HWND API dw_radiobutton_new(char *text, ULONG id)
5086 { 5086 {
5087 WindowData *blah = calloc(sizeof(WindowData), 1); 5087 WindowData *blah = calloc(sizeof(WindowData), 1);
5088 HWND tmp = WinCreateWindow(HWND_OBJECT, 5088 HWND tmp = WinCreateWindow(HWND_OBJECT,
5089 WC_BUTTON, 5089 WC_BUTTON,
5090 text, 5090 text,
5091 WS_VISIBLE | 5091 WS_VISIBLE |
5092 BS_AUTORADIOBUTTON, 5092 BS_AUTORADIOBUTTON,
5093 0,0,2000,1000, 5093 0,0,2000,1000,
5094 NULLHANDLE, 5094 NULLHANDLE,
5095 HWND_TOP, 5095 HWND_TOP,
5096 id, 5096 id,
5097 NULL, 5097 NULL,
5098 NULL); 5098 NULL);
5099 blah->oldproc = WinSubclassWindow(tmp, _entryproc); 5099 blah->oldproc = WinSubclassWindow(tmp, _entryproc);
5100 WinSetWindowPtr(tmp, QWP_USER, blah); 5100 WinSetWindowPtr(tmp, QWP_USER, blah);
5101 dw_window_set_font(tmp, DefaultFont); 5101 dw_window_set_font(tmp, DefaultFont);
5102 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); 5102 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY);
5103 return tmp; 5103 return tmp;
5104 } 5104 }
5105 5105
5106 5106
5107 /* 5107 /*
5108 * Create a new slider window (widget) to be packed. 5108 * Create a new slider window (widget) to be packed.
5111 * increments: Number of increments available. 5111 * increments: Number of increments available.
5112 * id: An ID to be used with dw_window_from_id() or 0L. 5112 * id: An ID to be used with dw_window_from_id() or 0L.
5113 */ 5113 */
5114 HWND API dw_slider_new(int vertical, int increments, ULONG id) 5114 HWND API dw_slider_new(int vertical, int increments, ULONG id)
5115 { 5115 {
5116 WindowData *blah = calloc(1, sizeof(WindowData)); 5116 WindowData *blah = calloc(1, sizeof(WindowData));
5117 SLDCDATA sldcData = { 0, 0, 0, 0, 0 }; 5117 SLDCDATA sldcData = { 0, 0, 0, 0, 0 };
5118 HWND tmp; 5118 HWND tmp;
5119 5119
5120 sldcData.cbSize = sizeof(SLDCDATA); 5120 sldcData.cbSize = sizeof(SLDCDATA);
5121 sldcData.usScale1Increments = increments; 5121 sldcData.usScale1Increments = increments;
5122 5122
5123 tmp = WinCreateWindow(HWND_OBJECT, 5123 tmp = WinCreateWindow(HWND_OBJECT,
5124 WC_SLIDER, 5124 WC_SLIDER,
5125 "", 5125 "",
5126 WS_VISIBLE | SLS_SNAPTOINCREMENT | 5126 WS_VISIBLE | SLS_SNAPTOINCREMENT |
5127 (vertical ? SLS_VERTICAL : SLS_HORIZONTAL), 5127 (vertical ? SLS_VERTICAL : SLS_HORIZONTAL),
5128 0,0,2000,1000, 5128 0,0,2000,1000,
5129 NULLHANDLE, 5129 NULLHANDLE,
5130 HWND_TOP, 5130 HWND_TOP,
5131 id, 5131 id,
5132 &sldcData, 5132 &sldcData,
5133 NULL); 5133 NULL);
5134 5134
5135 blah->oldproc = WinSubclassWindow(tmp, _entryproc); 5135 blah->oldproc = WinSubclassWindow(tmp, _entryproc);
5136 WinSetWindowPtr(tmp, QWP_USER, blah); 5136 WinSetWindowPtr(tmp, QWP_USER, blah);
5137 return tmp; 5137 return tmp;
5138 } 5138 }
5139 5139
5140 /* 5140 /*
5141 * Create a new scrollbar window (widget) to be packed. 5141 * Create a new scrollbar window (widget) to be packed.
5142 * Parameters: 5142 * Parameters:
5144 * increments: Number of increments available. 5144 * increments: Number of increments available.
5145 * id: An ID to be used with dw_window_from_id() or 0L. 5145 * id: An ID to be used with dw_window_from_id() or 0L.
5146 */ 5146 */
5147 HWND API dw_scrollbar_new(int vertical, ULONG id) 5147 HWND API dw_scrollbar_new(int vertical, ULONG id)
5148 { 5148 {
5149 return WinCreateWindow(HWND_OBJECT, 5149 return WinCreateWindow(HWND_OBJECT,
5150 WC_SCROLLBAR, 5150 WC_SCROLLBAR,
5151 "", 5151 "",
5152 WS_VISIBLE | SBS_AUTOTRACK | 5152 WS_VISIBLE | SBS_AUTOTRACK |
5153 (vertical ? SBS_VERT : SBS_HORZ), 5153 (vertical ? SBS_VERT : SBS_HORZ),
5154 0,0,2000,1000, 5154 0,0,2000,1000,
5155 NULLHANDLE, 5155 NULLHANDLE,
5156 HWND_TOP, 5156 HWND_TOP,
5157 id ? id : (GlobalID++), 5157 id ? id : (GlobalID++),
5158 NULL, 5158 NULL,
5159 NULL); 5159 NULL);
5160 } 5160 }
5161 5161
5162 /* 5162 /*
5163 * Create a new percent bar window (widget) to be packed. 5163 * Create a new percent bar window (widget) to be packed.
5164 * Parameters: 5164 * Parameters:
5165 * id: An ID to be used with dw_window_from_id() or 0L. 5165 * id: An ID to be used with dw_window_from_id() or 0L.
5166 */ 5166 */
5167 HWND API dw_percent_new(ULONG id) 5167 HWND API dw_percent_new(ULONG id)
5168 { 5168 {
5169 WindowData *blah = calloc(1, sizeof(WindowData)); 5169 WindowData *blah = calloc(1, sizeof(WindowData));
5170 HWND tmp = WinCreateWindow(HWND_OBJECT, 5170 HWND tmp = WinCreateWindow(HWND_OBJECT,
5171 WC_SLIDER, 5171 WC_SLIDER,
5172 "", 5172 "",
5173 WS_VISIBLE | SLS_READONLY 5173 WS_VISIBLE | SLS_READONLY
5174 | SLS_RIBBONSTRIP, 5174 | SLS_RIBBONSTRIP,
5175 0,0,2000,1000, 5175 0,0,2000,1000,
5176 NULLHANDLE, 5176 NULLHANDLE,
5177 HWND_TOP, 5177 HWND_TOP,
5178 id, 5178 id,
5179 NULL, 5179 NULL,
5180 NULL); 5180 NULL);
5181 blah->oldproc = WinSubclassWindow(tmp, _percentproc); 5181 blah->oldproc = WinSubclassWindow(tmp, _percentproc);
5182 WinSetWindowPtr(tmp, QWP_USER, blah); 5182 WinSetWindowPtr(tmp, QWP_USER, blah);
5183 dw_window_disable(tmp); 5183 dw_window_disable(tmp);
5184 return tmp; 5184 return tmp;
5185 } 5185 }
5186 5186
5187 /* 5187 /*
5188 * Create a new checkbox window (widget) to be packed. 5188 * Create a new checkbox window (widget) to be packed.
5189 * Parameters: 5189 * Parameters:
5190 * text: The text to be display by the static text widget. 5190 * text: The text to be display by the static text widget.
5191 * id: An ID to be used with dw_window_from_id() or 0L. 5191 * id: An ID to be used with dw_window_from_id() or 0L.
5192 */ 5192 */
5193 HWND API dw_checkbox_new(char *text, ULONG id) 5193 HWND API dw_checkbox_new(char *text, ULONG id)
5194 { 5194 {
5195 BubbleButton *bubble = calloc(sizeof(BubbleButton), 1); 5195 BubbleButton *bubble = calloc(sizeof(BubbleButton), 1);
5196 HWND tmp = WinCreateWindow(HWND_OBJECT, 5196 HWND tmp = WinCreateWindow(HWND_OBJECT,
5197 WC_BUTTON, 5197 WC_BUTTON,
5198 text, 5198 text,
5199 WS_VISIBLE | BS_AUTOCHECKBOX, 5199 WS_VISIBLE | BS_AUTOCHECKBOX,
5200 0,0,2000,1000, 5200 0,0,2000,1000,
5201 NULLHANDLE, 5201 NULLHANDLE,
5202 HWND_TOP, 5202 HWND_TOP,
5203 id, 5203 id,
5204 NULL, 5204 NULL,
5205 NULL); 5205 NULL);
5206 bubble->id = id; 5206 bubble->id = id;
5207 bubble->bubbletext[0] = '\0'; 5207 bubble->bubbletext[0] = '\0';
5208 bubble->pOldProc = WinSubclassWindow(tmp, _BtProc); 5208 bubble->pOldProc = WinSubclassWindow(tmp, _BtProc);
5209 WinSetWindowPtr(tmp, QWP_USER, bubble); 5209 WinSetWindowPtr(tmp, QWP_USER, bubble);
5210 dw_window_set_font(tmp, DefaultFont); 5210 dw_window_set_font(tmp, DefaultFont);
5211 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); 5211 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY);
5212 return tmp; 5212 return tmp;
5213 } 5213 }
5214 5214
5215 /* 5215 /*
5216 * Create a new listbox window (widget) to be packed. 5216 * Create a new listbox window (widget) to be packed.
5217 * Parameters: 5217 * Parameters:
5218 * id: An ID to be used with dw_window_from_id() or 0L. 5218 * id: An ID to be used with dw_window_from_id() or 0L.
5219 * multi: Multiple select TRUE or FALSE. 5219 * multi: Multiple select TRUE or FALSE.
5220 */ 5220 */
5221 HWND API dw_listbox_new(ULONG id, int multi) 5221 HWND API dw_listbox_new(ULONG id, int multi)
5222 { 5222 {
5223 WindowData *blah = calloc(sizeof(WindowData), 1); 5223 WindowData *blah = calloc(sizeof(WindowData), 1);
5224 HWND tmp = WinCreateWindow(HWND_OBJECT, 5224 HWND tmp = WinCreateWindow(HWND_OBJECT,
5225 WC_LISTBOX, 5225 WC_LISTBOX,
5226 NULL, 5226 NULL,
5227 WS_VISIBLE | LS_NOADJUSTPOS | 5227 WS_VISIBLE | LS_NOADJUSTPOS |
5228 (multi ? LS_MULTIPLESEL : 0), 5228 (multi ? LS_MULTIPLESEL : 0),
5229 0,0,2000,1000, 5229 0,0,2000,1000,
5230 NULLHANDLE, 5230 NULLHANDLE,
5231 HWND_TOP, 5231 HWND_TOP,
5232 id ? id : (GlobalID++), 5232 id ? id : (GlobalID++),
5233 NULL, 5233 NULL,
5234 NULL); 5234 NULL);
5235 blah->oldproc = WinSubclassWindow(tmp, _entryproc); 5235 blah->oldproc = WinSubclassWindow(tmp, _entryproc);
5236 WinSetWindowPtr(tmp, QWP_USER, blah); 5236 WinSetWindowPtr(tmp, QWP_USER, blah);
5237 dw_window_set_font(tmp, DefaultFont); 5237 dw_window_set_font(tmp, DefaultFont);
5238 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE); 5238 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE);
5239 return tmp; 5239 return tmp;
5240 } 5240 }
5241 5241
5242 /* 5242 /*
5243 * Sets the icon used for a given window. 5243 * Sets the icon used for a given window.
5244 * Parameters: 5244 * Parameters:
5245 * handle: Handle to the window. 5245 * handle: Handle to the window.
5246 * id: An ID to be used to specify the icon. 5246 * id: An ID to be used to specify the icon.
5247 */ 5247 */
5248 void API dw_window_set_icon(HWND handle, ULONG id) 5248 void API dw_window_set_icon(HWND handle, ULONG id)
5249 { 5249 {
5250 HPOINTER icon = id < 65536 ? WinLoadPointer(HWND_DESKTOP,NULLHANDLE,id) : (HPOINTER)id; 5250 HPOINTER icon = id < 65536 ? WinLoadPointer(HWND_DESKTOP,NULLHANDLE,id) : (HPOINTER)id;
5251 WinSendMsg(handle, WM_SETICON, (MPARAM)icon, 0); 5251 WinSendMsg(handle, WM_SETICON, (MPARAM)icon, 0);
5252 } 5252 }
5253 5253
5254 /* Internal function to load a bitmap from a file and return handles 5254 /* Internal function to load a bitmap from a file and return handles
5255 * to the bitmap, presentation space etc. 5255 * to the bitmap, presentation space etc.
5256 */ 5256 */
5257 int _load_bitmap_file(char *file, HWND handle, HBITMAP *hbm, HDC *hdc, HPS *hps, unsigned long *width, unsigned long *height) 5257 int _load_bitmap_file(char *file, HWND handle, HBITMAP *hbm, HDC *hdc, HPS *hps, unsigned long *width, unsigned long *height)
5258 { 5258 {
5259 HFILE BitmapFileHandle = NULLHANDLE; /* handle for the file */ 5259 HFILE BitmapFileHandle = NULLHANDLE; /* handle for the file */
5260 ULONG OpenAction = 0; 5260 ULONG OpenAction = 0;
5261 PBYTE BitmapFileBegin; /* pointer to the first byte of bitmap data */ 5261 PBYTE BitmapFileBegin; /* pointer to the first byte of bitmap data */
5262 FILESTATUS BitmapStatus; 5262 FILESTATUS BitmapStatus;
5263 ULONG cbRead; 5263 ULONG cbRead;
5264 PBITMAPFILEHEADER2 pBitmapFileHeader; 5264 PBITMAPFILEHEADER2 pBitmapFileHeader;
5265 PBITMAPINFOHEADER2 pBitmapInfoHeader; 5265 PBITMAPINFOHEADER2 pBitmapInfoHeader;
5266 ULONG ScanLines, ulFlags; 5266 ULONG ScanLines, ulFlags;
5267 HPS hps1; 5267 HPS hps1;
5268 HDC hdc1; 5268 HDC hdc1;
5269 SIZEL sizl = { 0, 0 }; 5269 SIZEL sizl = { 0, 0 };
5270 5270
5271 /* open bitmap file */ 5271 /* open bitmap file */
5272 DosOpen(file, &BitmapFileHandle, &OpenAction, 0L, 5272 DosOpen(file, &BitmapFileHandle, &OpenAction, 0L,
5273 FILE_ARCHIVED | FILE_NORMAL | FILE_READONLY, 5273 FILE_ARCHIVED | FILE_NORMAL | FILE_READONLY,
5274 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, 5274 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
5275 OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY | 5275 OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY |
5276 OPEN_FLAGS_NOINHERIT, 0L); 5276 OPEN_FLAGS_NOINHERIT, 0L);
5277 5277
5278 if(!BitmapFileHandle) 5278 if(!BitmapFileHandle)
5279 return 0; 5279 return 0;
5280 5280
5281 /* find out how big the file is */ 5281 /* find out how big the file is */
5282 DosQueryFileInfo(BitmapFileHandle, 1, &BitmapStatus, 5282 DosQueryFileInfo(BitmapFileHandle, 1, &BitmapStatus,
5283 sizeof(BitmapStatus)); 5283 sizeof(BitmapStatus));
5284 5284
5285 /* allocate memory to load the bitmap */ 5285 /* allocate memory to load the bitmap */
5286 DosAllocMem((PPVOID)&BitmapFileBegin, (ULONG)BitmapStatus.cbFile, 5286 DosAllocMem((PPVOID)&BitmapFileBegin, (ULONG)BitmapStatus.cbFile,
5287 PAG_READ | PAG_WRITE | PAG_COMMIT); 5287 PAG_READ | PAG_WRITE | PAG_COMMIT);
5288 5288
5289 /* read bitmap file into memory buffer */ 5289 /* read bitmap file into memory buffer */
5290 DosRead(BitmapFileHandle, (PVOID)BitmapFileBegin, 5290 DosRead(BitmapFileHandle, (PVOID)BitmapFileBegin,
5291 BitmapStatus.cbFile, &cbRead); 5291 BitmapStatus.cbFile, &cbRead);
5292 5292
5293 /* access first bytes as bitmap header */ 5293 /* access first bytes as bitmap header */
5294 pBitmapFileHeader = (PBITMAPFILEHEADER2)BitmapFileBegin; 5294 pBitmapFileHeader = (PBITMAPFILEHEADER2)BitmapFileBegin;
5295 5295
5296 /* check if it's a valid bitmap data file */ 5296 /* check if it's a valid bitmap data file */
5297 if((pBitmapFileHeader->usType != BFT_BITMAPARRAY) && 5297 if((pBitmapFileHeader->usType != BFT_BITMAPARRAY) &&
5298 (pBitmapFileHeader->usType != BFT_BMAP)) 5298 (pBitmapFileHeader->usType != BFT_BMAP))
5299 { 5299 {
5300 /* free memory of bitmap file buffer */ 5300 /* free memory of bitmap file buffer */
5301 DosFreeMem(BitmapFileBegin); 5301 DosFreeMem(BitmapFileBegin);
5302 /* close the bitmap file */ 5302 /* close the bitmap file */
5303 DosClose(BitmapFileHandle); 5303 DosClose(BitmapFileHandle);
5304 return 0; 5304 return 0;
5305 } 5305 }
5306 5306
5307 /* check if it's a file with multiple bitmaps */ 5307 /* check if it's a file with multiple bitmaps */
5308 if(pBitmapFileHeader->usType == BFT_BITMAPARRAY) 5308 if(pBitmapFileHeader->usType == BFT_BITMAPARRAY)
5309 { 5309 {
5310 /* we'll just use the first bitmap and ignore the others */ 5310 /* we'll just use the first bitmap and ignore the others */
5311 pBitmapFileHeader = &(((PBITMAPARRAYFILEHEADER2)BitmapFileBegin)->bfh2); 5311 pBitmapFileHeader = &(((PBITMAPARRAYFILEHEADER2)BitmapFileBegin)->bfh2);
5312 } 5312 }
5313 5313
5314 /* set pointer to bitmap information block */ 5314 /* set pointer to bitmap information block */
5315 pBitmapInfoHeader = &pBitmapFileHeader->bmp2; 5315 pBitmapInfoHeader = &pBitmapFileHeader->bmp2;
5316 5316
5317 /* find out if it's the new 2.0 format or the old format */ 5317 /* find out if it's the new 2.0 format or the old format */
5318 /* and query number of lines */ 5318 /* and query number of lines */
5319 if(pBitmapInfoHeader->cbFix == sizeof(BITMAPINFOHEADER)) 5319 if(pBitmapInfoHeader->cbFix == sizeof(BITMAPINFOHEADER))
5320 { 5320 {
5321 *height = ScanLines = (ULONG)((PBITMAPINFOHEADER)pBitmapInfoHeader)->cy; 5321 *height = ScanLines = (ULONG)((PBITMAPINFOHEADER)pBitmapInfoHeader)->cy;
5322 *width = (ULONG)((PBITMAPINFOHEADER)pBitmapInfoHeader)->cx; 5322 *width = (ULONG)((PBITMAPINFOHEADER)pBitmapInfoHeader)->cx;
5323 } 5323 }
5324 else 5324 else
5325 { 5325 {
5326 *height = ScanLines = pBitmapInfoHeader->cy; 5326 *height = ScanLines = pBitmapInfoHeader->cy;
5327 *width = pBitmapInfoHeader->cx; 5327 *width = pBitmapInfoHeader->cx;
5328 } 5328 }
5329 5329
5330 /* now we need a presentation space, get it from static control */ 5330 /* now we need a presentation space, get it from static control */
5331 hps1 = WinGetPS(handle); 5331 hps1 = WinGetPS(handle);
5332 5332
5333 hdc1 = GpiQueryDevice(hps1); 5333 hdc1 = GpiQueryDevice(hps1);
5334 ulFlags = GpiQueryPS(hps1, &sizl); 5334 ulFlags = GpiQueryPS(hps1, &sizl);
5335 5335
5336 *hdc = DevOpenDC(dwhab, OD_MEMORY, "*", 0L, NULL, hdc1); 5336 *hdc = DevOpenDC(dwhab, OD_MEMORY, "*", 0L, NULL, hdc1);
5337 *hps = GpiCreatePS (dwhab, *hdc, &sizl, ulFlags | GPIA_ASSOC); 5337 *hps = GpiCreatePS (dwhab, *hdc, &sizl, ulFlags | GPIA_ASSOC);
5338 5338
5339 /* create bitmap now using the parameters from the info block */ 5339 /* create bitmap now using the parameters from the info block */
5340 *hbm = GpiCreateBitmap(*hps, pBitmapInfoHeader, 0L, NULL, NULL); 5340 *hbm = GpiCreateBitmap(*hps, pBitmapInfoHeader, 0L, NULL, NULL);
5341 5341
5342 /* select the new bitmap into presentation space */ 5342 /* select the new bitmap into presentation space */
5343 GpiSetBitmap(*hps, *hbm); 5343 GpiSetBitmap(*hps, *hbm);
5344 5344
5345 /* now copy the bitmap data into the bitmap */ 5345 /* now copy the bitmap data into the bitmap */
5346 GpiSetBitmapBits(*hps, 0L, ScanLines, 5346 GpiSetBitmapBits(*hps, 0L, ScanLines,
5347 BitmapFileBegin + pBitmapFileHeader->offBits, 5347 BitmapFileBegin + pBitmapFileHeader->offBits,
5348 (PBITMAPINFO2)pBitmapInfoHeader); 5348 (PBITMAPINFO2)pBitmapInfoHeader);
5349 5349
5350 WinReleasePS(hps1); 5350 WinReleasePS(hps1);
5351 5351
5352 /* free memory of bitmap file buffer */ 5352 /* free memory of bitmap file buffer */
5353 DosFreeMem(BitmapFileBegin); 5353 DosFreeMem(BitmapFileBegin);
5354 /* close the bitmap file */ 5354 /* close the bitmap file */
5355 DosClose(BitmapFileHandle); 5355 DosClose(BitmapFileHandle);
5356 return 1; 5356 return 1;
5357 } 5357 }
5358 5358
5359 /* 5359 /*
5360 * Sets the bitmap used for a given static window. 5360 * Sets the bitmap used for a given static window.
5361 * Parameters: 5361 * Parameters:
5494 * handle: Handle to the window. 5494 * handle: Handle to the window.
5495 * text: The text associsated with a given window. 5495 * text: The text associsated with a given window.
5496 */ 5496 */
5497 void API dw_window_set_text(HWND handle, char *text) 5497 void API dw_window_set_text(HWND handle, char *text)
5498 { 5498 {
5499 WinSetWindowText(handle, text); 5499 WinSetWindowText(handle, text);
5500 } 5500 }
5501 5501
5502 /* 5502 /*
5503 * Gets the text used for a given window. 5503 * Gets the text used for a given window.
5504 * Parameters: 5504 * Parameters:
5506 * Returns: 5506 * Returns:
5507 * text: The text associsated with a given window. 5507 * text: The text associsated with a given window.
5508 */ 5508 */
5509 char * API dw_window_get_text(HWND handle) 5509 char * API dw_window_get_text(HWND handle)
5510 { 5510 {
5511 int len = WinQueryWindowTextLength(handle); 5511 int len = WinQueryWindowTextLength(handle);
5512 char *tempbuf = calloc(1, len + 2); 5512 char *tempbuf = calloc(1, len + 2);
5513 5513
5514 WinQueryWindowText(handle, len + 1, tempbuf); 5514 WinQueryWindowText(handle, len + 1, tempbuf);
5515 5515
5516 return tempbuf; 5516 return tempbuf;
5517 } 5517 }
5518 5518
5519 /* 5519 /*
5520 * Disables given window (widget). 5520 * Disables given window (widget).
5521 * Parameters: 5521 * Parameters:
5522 * handle: Handle to the window. 5522 * handle: Handle to the window.
5523 */ 5523 */
5524 void API dw_window_disable(HWND handle) 5524 void API dw_window_disable(HWND handle)
5525 { 5525 {
5526 char tmpbuf[100]; 5526 char tmpbuf[100];
5527 5527
5528 if(dw_window_get_data(handle, "_dw_disabled")) 5528 if(dw_window_get_data(handle, "_dw_disabled"))
5529 return; 5529 return;
5530 5530
5531 WinQueryClassName(handle, 99, tmpbuf); 5531 WinQueryClassName(handle, 99, tmpbuf);
5532 dw_window_set_data(handle, "_dw_disabled", (void *)1); 5532 dw_window_set_data(handle, "_dw_disabled", (void *)1);
5533 5533
5534 if(tmpbuf[0] == '#') 5534 if(tmpbuf[0] == '#')
5535 { 5535 {
5536 int val = atoi(&tmpbuf[1]); 5536 int val = atoi(&tmpbuf[1]);
5537 HWND hwnd; 5537 HWND hwnd;
5538 5538
5539 switch(val) 5539 switch(val)
5540 { 5540 {
5541 case 2: 5541 case 2:
5542 case 6: 5542 case 6:
5543 case 10: 5543 case 10:
5544 case 32: 5544 case 32:
5545 case 7: 5545 case 7:
5546 hwnd = _find_entryfield(handle); 5546 hwnd = _find_entryfield(handle);
5547 _dw_window_set_color(hwnd ? hwnd : handle, DW_CLR_BLACK, DW_CLR_PALEGRAY); 5547 _dw_window_set_color(hwnd ? hwnd : handle, DW_CLR_BLACK, DW_CLR_PALEGRAY);
5548 dw_signal_connect(hwnd ? hwnd : handle, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(_null_key), (void *)100); 5548 dw_signal_connect(hwnd ? hwnd : handle, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(_null_key), (void *)100);
5549 if(val == 2) 5549 if(val == 2)
5550 dw_signal_connect(handle, DW_SIGNAL_BUTTON_PRESS, DW_SIGNAL_FUNC(_null_key), (void *)100); 5550 dw_signal_connect(handle, DW_SIGNAL_BUTTON_PRESS, DW_SIGNAL_FUNC(_null_key), (void *)100);
5551 if(hwnd) 5551 if(hwnd)
5552 dw_window_set_data(hwnd, "_dw_disabled", (void *)1); 5552 dw_window_set_data(hwnd, "_dw_disabled", (void *)1);
5553 return; 5553 return;
5554 case 3: 5554 case 3:
5555 if(dw_window_get_data(handle, "_dw_bitmapbutton") && !dw_window_get_data(handle, "_dw_hpixmap")) 5555 if(dw_window_get_data(handle, "_dw_bitmapbutton") && !dw_window_get_data(handle, "_dw_hpixmap"))
5556 WinEnableWindow(handle, FALSE); 5556 WinEnableWindow(handle, FALSE);
5557 else if(dw_window_get_data(handle, "_dw_bitmapbutton") && dw_window_get_data(handle, "_dw_hpixmap_disabled")) 5557 else if(dw_window_get_data(handle, "_dw_bitmapbutton") && dw_window_get_data(handle, "_dw_hpixmap_disabled"))
5558 WinInvalidateRect(handle, NULL, FALSE); 5558 WinInvalidateRect(handle, NULL, FALSE);
5559 else 5559 else
5560 _dw_window_set_color(handle, DW_CLR_DARKGRAY, DW_CLR_PALEGRAY); 5560 _dw_window_set_color(handle, DW_CLR_DARKGRAY, DW_CLR_PALEGRAY);
5561 dw_signal_connect(handle, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(_null_key), (void *)100); 5561 dw_signal_connect(handle, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(_null_key), (void *)100);
5562 dw_signal_connect(handle, DW_SIGNAL_BUTTON_PRESS, DW_SIGNAL_FUNC(_null_key), (void *)100); 5562 dw_signal_connect(handle, DW_SIGNAL_BUTTON_PRESS, DW_SIGNAL_FUNC(_null_key), (void *)100);
5563 return; 5563 return;
5564 } 5564 }
5565 } 5565 }
5566 WinEnableWindow(handle, FALSE); 5566 WinEnableWindow(handle, FALSE);
5567 } 5567 }
5568 5568
5569 /* 5569 /*
5570 * Enables given window (widget). 5570 * Enables given window (widget).
5571 * Parameters: 5571 * Parameters:
5572 * handle: Handle to the window. 5572 * handle: Handle to the window.
5573 */ 5573 */
5574 void API dw_window_enable(HWND handle) 5574 void API dw_window_enable(HWND handle)
5575 { 5575 {
5576 ULONG fore = (ULONG)dw_window_get_data(handle, "_dw_fore"); 5576 ULONG fore = (ULONG)dw_window_get_data(handle, "_dw_fore");
5577 ULONG back = (ULONG)dw_window_get_data(handle, "_dw_back"); 5577 ULONG back = (ULONG)dw_window_get_data(handle, "_dw_back");
5578 HWND hwnd = _find_entryfield(handle); 5578 HWND hwnd = _find_entryfield(handle);
5579 5579
5580 dw_window_set_data(handle, "_dw_disabled", 0); 5580 dw_window_set_data(handle, "_dw_disabled", 0);
5581 if(hwnd) 5581 if(hwnd)
5582 dw_window_set_data(hwnd, "_dw_disabled", 0); 5582 dw_window_set_data(hwnd, "_dw_disabled", 0);
5583 if(fore && back) 5583 if(fore && back)
5584 _dw_window_set_color(hwnd ? hwnd : handle, fore-1, back-1); 5584 _dw_window_set_color(hwnd ? hwnd : handle, fore-1, back-1);
5585 dw_signal_disconnect_by_data(handle, (void *)100); 5585 dw_signal_disconnect_by_data(handle, (void *)100);
5586 WinEnableWindow(handle, TRUE); 5586 WinEnableWindow(handle, TRUE);
5587 if(dw_window_get_data(handle, "_dw_bitmapbutton") && dw_window_get_data(handle, "_dw_hpixmap_disabled")) 5587 if(dw_window_get_data(handle, "_dw_bitmapbutton") && dw_window_get_data(handle, "_dw_hpixmap_disabled"))
5588 WinInvalidateRect(handle, NULL, FALSE); 5588 WinInvalidateRect(handle, NULL, FALSE);
5589 } 5589 }
5590 5590
5591 /* 5591 /*
5592 * Gets the child window handle with specified ID. 5592 * Gets the child window handle with specified ID.
5593 * Parameters: 5593 * Parameters:
5594 * handle: Handle to the parent window. 5594 * handle: Handle to the parent window.
5595 * id: Integer ID of the child. 5595 * id: Integer ID of the child.
5596 */ 5596 */
5597 HWND API dw_window_from_id(HWND handle, int id) 5597 HWND API dw_window_from_id(HWND handle, int id)
5598 { 5598 {
5599 HENUM henum; 5599 HENUM henum;
5600 HWND child; 5600 HWND child;
5601 char tmpbuf[100]; 5601 char tmpbuf[100];
5602 5602
5603 henum = WinBeginEnumWindows(handle); 5603 henum = WinBeginEnumWindows(handle);
5604 while((child = WinGetNextWindow(henum)) != NULLHANDLE) 5604 while((child = WinGetNextWindow(henum)) != NULLHANDLE)
5605 { 5605 {
5606 int windowid = WinQueryWindowUShort(child, QWS_ID); 5606 int windowid = WinQueryWindowUShort(child, QWS_ID);
5607 HWND found; 5607 HWND found;
5608 5608
5609 WinQueryClassName(child, 99, tmpbuf); 5609 WinQueryClassName(child, 99, tmpbuf);
5610 5610
5611 /* If the child is a box (frame) then recurse into it */ 5611 /* If the child is a box (frame) then recurse into it */
5612 if(strncmp(tmpbuf, "#1", 3)==0) 5612 if(strncmp(tmpbuf, "#1", 3)==0)
5613 if((found = dw_window_from_id(child, id)) != NULLHANDLE) 5613 if((found = dw_window_from_id(child, id)) != NULLHANDLE)
5614 return found; 5614 return found;
5615 5615
5616 if(windowid && windowid == id) 5616 if(windowid && windowid == id)
5617 { 5617 {
5618 WinEndEnumWindows(henum); 5618 WinEndEnumWindows(henum);
5619 return child; 5619 return child;
5620 } 5620 }
5621 } 5621 }
5622 WinEndEnumWindows(henum); 5622 WinEndEnumWindows(henum);
5623 return NULLHANDLE; 5623 return NULLHANDLE;
5624 } 5624 }
5625 5625
5626 /* 5626 /*
5627 * Pack windows (widgets) into a box from the end (or bottom). 5627 * Pack windows (widgets) into a box from the end (or bottom).
5628 * Parameters: 5628 * Parameters:
5634 * vsize: TRUE if the window (widget) should expand vertically to fill space given. 5634 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
5635 * pad: Number of pixels of padding around the item. 5635 * pad: Number of pixels of padding around the item.
5636 */ 5636 */
5637 void API dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) 5637 void API dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
5638 { 5638 {
5639 char *funcname = "dw_box_pack_end()"; 5639 char *funcname = "dw_box_pack_end()";
5640 5640
5641 /* 5641 /*
5642 * If you try and pack an item into itself VERY bad things can happen; like at least an 5642 * If you try and pack an item into itself VERY bad things can happen; like at least an
5643 * infinite loop on GTK! Lets be safe! 5643 * infinite loop on GTK! Lets be safe!
5644 */ 5644 */
5645 if(box == item) 5645 if(box == item)
5646 { 5646 {
5647 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!"); 5647 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!");
5648 return; 5648 return;
5649 } 5649 }
5650 5650
5651 if(WinWindowFromID(box, FID_CLIENT)) 5651 if(WinWindowFromID(box, FID_CLIENT))
5652 { 5652 {
5653 box = WinWindowFromID(box, FID_CLIENT); 5653 box = WinWindowFromID(box, FID_CLIENT);
5654 hsize = TRUE; 5654 hsize = TRUE;
5655 vsize = TRUE; 5655 vsize = TRUE;
5656 } 5656 }
5657 _dw_box_pack_end(box, item, width, height, hsize, vsize, pad, funcname); 5657 _dw_box_pack_end(box, item, width, height, hsize, vsize, pad, funcname);
5658 } 5658 }
5659 5659
5660 void _dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad, char *functionname) 5660 void _dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad, char *functionname)
5661 { 5661 {
5662 Box *thisbox = WinQueryWindowPtr(box, QWP_USER); 5662 Box *thisbox = WinQueryWindowPtr(box, QWP_USER);
5663 5663
5664 if(thisbox) 5664 if(thisbox)
5665 { 5665 {
5666 int z; 5666 int z;
5667 Item *tmpitem, *thisitem = thisbox->items; 5667 Item *tmpitem, *thisitem = thisbox->items;
5668 char tmpbuf[100]; 5668 char tmpbuf[100];
5669 HWND frame = (HWND)dw_window_get_data(item, "_dw_combo_box"); 5669 HWND frame = (HWND)dw_window_get_data(item, "_dw_combo_box");
5670 5670
5671 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); 5671 tmpitem = malloc(sizeof(Item)*(thisbox->count+1));
5672 5672
5673 for(z=0;z<thisbox->count;z++) 5673 for(z=0;z<thisbox->count;z++)
5674 { 5674 {
5675 tmpitem[z+1] = thisitem[z]; 5675 tmpitem[z+1] = thisitem[z];
5676 } 5676 }
5677 5677
5678 WinQueryClassName(item, 99, tmpbuf); 5678 WinQueryClassName(item, 99, tmpbuf);
5679 5679
5680 if(vsize && !height) 5680 if(vsize && !height)
5681 height = 1; 5681 height = 1;
5682 if(hsize && !width) 5682 if(hsize && !width)
5683 width = 1; 5683 width = 1;
5684 5684
5685 if(strncmp(tmpbuf, "#1", 3)==0) 5685 if(strncmp(tmpbuf, "#1", 3)==0)
5686 tmpitem[0].type = TYPEBOX; 5686 tmpitem[0].type = TYPEBOX;
5687 else 5687 else
5688 { 5688 {
5689 if ( width == 0 && hsize == FALSE ) 5689 if ( width == 0 && hsize == FALSE )
5690 dw_messagebox(functionname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item); 5690 dw_messagebox(functionname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item);
5691 if ( height == 0 && vsize == FALSE ) 5691 if ( height == 0 && vsize == FALSE )
5692 dw_messagebox(functionname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item); 5692 dw_messagebox(functionname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item);
5693 5693
5694 tmpitem[0].type = TYPEITEM; 5694 tmpitem[0].type = TYPEITEM;
5695 } 5695 }
5696 5696
5697 tmpitem[0].hwnd = item; 5697 tmpitem[0].hwnd = item;
5698 tmpitem[0].origwidth = tmpitem[0].width = width; 5698 tmpitem[0].origwidth = tmpitem[0].width = width;
5699 tmpitem[0].origheight = tmpitem[0].height = height; 5699 tmpitem[0].origheight = tmpitem[0].height = height;
5700 tmpitem[0].pad = pad; 5700 tmpitem[0].pad = pad;
5701 if(hsize) 5701 if(hsize)
5702 tmpitem[0].hsize = SIZEEXPAND; 5702 tmpitem[0].hsize = SIZEEXPAND;
5703 else 5703 else
5704 tmpitem[0].hsize = SIZESTATIC; 5704 tmpitem[0].hsize = SIZESTATIC;
5705 5705
5706 if(vsize) 5706 if(vsize)
5707 tmpitem[0].vsize = SIZEEXPAND; 5707 tmpitem[0].vsize = SIZEEXPAND;
5708 else 5708 else
5709 tmpitem[0].vsize = SIZESTATIC; 5709 tmpitem[0].vsize = SIZESTATIC;
5710 5710
5711 thisbox->items = tmpitem; 5711 thisbox->items = tmpitem;
5712 5712
5713 if(thisbox->count) 5713 if(thisbox->count)
5714 free(thisitem); 5714 free(thisitem);
5715 5715
5716 thisbox->count++; 5716 thisbox->count++;
5717 5717
5718 WinQueryClassName(item, 99, tmpbuf); 5718 WinQueryClassName(item, 99, tmpbuf);
5719 /* Don't set the ownership if it's an entryfield or spinbutton */ 5719 /* Don't set the ownership if it's an entryfield or spinbutton */
5720 if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 4)!=0 && strncmp(tmpbuf, "#2", 3)!=0) 5720 if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 4)!=0 && strncmp(tmpbuf, "#2", 3)!=0)
5721 WinSetOwner(item, box); 5721 WinSetOwner(item, box);
5722 WinSetParent(frame ? frame : item, box, FALSE); 5722 WinSetParent(frame ? frame : item, box, FALSE);
5723 } 5723 }
5724 } 5724 }
5725 5725
5726 /* 5726 /*
5727 * Sets the size of a given window (widget). 5727 * Sets the size of a given window (widget).
5728 * Parameters: 5728 * Parameters:
5730 * width: New width in pixels. 5730 * width: New width in pixels.
5731 * height: New height in pixels. 5731 * height: New height in pixels.
5732 */ 5732 */
5733 void API dw_window_set_size(HWND handle, ULONG width, ULONG height) 5733 void API dw_window_set_size(HWND handle, ULONG width, ULONG height)
5734 { 5734 {
5735 WinSetWindowPos(handle, NULLHANDLE, 0, 0, width, height, SWP_SHOW | SWP_SIZE); 5735 WinSetWindowPos(handle, NULLHANDLE, 0, 0, width, height, SWP_SHOW | SWP_SIZE);
5736 } 5736 }
5737 5737
5738 /* 5738 /*
5739 * Returns the width of the screen. 5739 * Returns the width of the screen.
5740 */ 5740 */
5741 int API dw_screen_width(void) 5741 int API dw_screen_width(void)
5742 { 5742 {
5743 return WinQuerySysValue(HWND_DESKTOP,SV_CXSCREEN); 5743 return WinQuerySysValue(HWND_DESKTOP,SV_CXSCREEN);
5744 } 5744 }
5745 5745
5746 /* 5746 /*
5747 * Returns the height of the screen. 5747 * Returns the height of the screen.
5748 */ 5748 */
5749 int API dw_screen_height(void) 5749 int API dw_screen_height(void)
5750 { 5750 {
5751 return WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN); 5751 return WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN);
5752 } 5752 }
5753 5753
5754 /* This should return the current color depth */ 5754 /* This should return the current color depth */
5755 unsigned long API dw_color_depth_get(void) 5755 unsigned long API dw_color_depth_get(void)
5756 { 5756 {
5757 HDC hdc = WinOpenWindowDC(HWND_DESKTOP); 5757 HDC hdc = WinOpenWindowDC(HWND_DESKTOP);
5758 long colors; 5758 long colors;
5759 5759
5760 DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, &colors); 5760 DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, &colors);
5761 DevCloseDC(hdc); 5761 DevCloseDC(hdc);
5762 return colors; 5762 return colors;
5763 } 5763 }
5764 5764
5765 5765
5766 /* 5766 /*
5767 * Sets the position of a given window (widget). 5767 * Sets the position of a given window (widget).
5770 * x: X location from the bottom left. 5770 * x: X location from the bottom left.
5771 * y: Y location from the bottom left. 5771 * y: Y location from the bottom left.
5772 */ 5772 */
5773 void API dw_window_set_pos(HWND handle, LONG x, LONG y) 5773 void API dw_window_set_pos(HWND handle, LONG x, LONG y)
5774 { 5774 {
5775 int myy = _get_frame_height(handle) - (y + _get_height(handle)); 5775 int myy = _get_frame_height(handle) - (y + _get_height(handle));
5776 5776
5777 WinSetWindowPos(handle, NULLHANDLE, x, myy, 0, 0, SWP_MOVE); 5777 WinSetWindowPos(handle, NULLHANDLE, x, myy, 0, 0, SWP_MOVE);
5778 } 5778 }
5779 5779
5780 /* 5780 /*
5781 * Sets the position and size of a given window (widget). 5781 * Sets the position and size of a given window (widget).
5782 * Parameters: 5782 * Parameters:
5786 * width: Width of the widget. 5786 * width: Width of the widget.
5787 * height: Height of the widget. 5787 * height: Height of the widget.
5788 */ 5788 */
5789 void API dw_window_set_pos_size(HWND handle, LONG x, LONG y, ULONG width, ULONG height) 5789 void API dw_window_set_pos_size(HWND handle, LONG x, LONG y, ULONG width, ULONG height)
5790 { 5790 {
5791 int myy = _get_frame_height(handle) - (y + height); 5791 int myy = _get_frame_height(handle) - (y + height);
5792 5792
5793 WinSetWindowPos(handle, NULLHANDLE, x, myy, width, height, SWP_MOVE | SWP_SIZE | SWP_SHOW); 5793 WinSetWindowPos(handle, NULLHANDLE, x, myy, width, height, SWP_MOVE | SWP_SIZE | SWP_SHOW);
5794 } 5794 }
5795 5795
5796 /* 5796 /*
5797 * Gets the position and size of a given window (widget). 5797 * Gets the position and size of a given window (widget).
5798 * Parameters: 5798 * Parameters:
5802 * width: Width of the widget. 5802 * width: Width of the widget.
5803 * height: Height of the widget. 5803 * height: Height of the widget.
5804 */ 5804 */
5805 void API dw_window_get_pos_size(HWND handle, LONG *x, LONG *y, ULONG *width, ULONG *height) 5805 void API dw_window_get_pos_size(HWND handle, LONG *x, LONG *y, ULONG *width, ULONG *height)
5806 { 5806 {
5807 SWP swp; 5807 SWP swp;
5808 WinQueryWindowPos(handle, &swp); 5808 WinQueryWindowPos(handle, &swp);
5809 if(x) 5809 if(x)
5810 *x = swp.x; 5810 *x = swp.x;
5811 if(y) 5811 if(y)
5812 *y = _get_frame_height(handle) - (swp.y + swp.cy); 5812 *y = _get_frame_height(handle) - (swp.y + swp.cy);
5813 if(width) 5813 if(width)
5814 *width = swp.cx; 5814 *width = swp.cx;
5815 if(height) 5815 if(height)
5816 *height = swp.cy; 5816 *height = swp.cy;
5817 } 5817 }
5818 5818
5819 /* 5819 /*
5820 * Sets the style of a given window (widget). 5820 * Sets the style of a given window (widget).
5821 * Parameters: 5821 * Parameters:
5823 * width: New width in pixels. 5823 * width: New width in pixels.
5824 * height: New height in pixels. 5824 * height: New height in pixels.
5825 */ 5825 */
5826 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask) 5826 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask)
5827 { 5827 {
5828 WinSetWindowBits(handle, QWL_STYLE, style, mask); 5828 WinSetWindowBits(handle, QWL_STYLE, style, mask);
5829 } 5829 }
5830 5830
5831 /* 5831 /*
5832 * Adds a new page to specified notebook. 5832 * Adds a new page to specified notebook.
5833 * Parameters: 5833 * Parameters:
5835 * flags: Any additional page creation flags. 5835 * flags: Any additional page creation flags.
5836 * front: If TRUE page is added at the beginning. 5836 * front: If TRUE page is added at the beginning.
5837 */ 5837 */
5838 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front) 5838 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front)
5839 { 5839 {
5840 return (ULONG)WinSendMsg(handle, BKM_INSERTPAGE, 0L, 5840 return (ULONG)WinSendMsg(handle, BKM_INSERTPAGE, 0L,
5841 MPFROM2SHORT((BKA_STATUSTEXTON | BKA_AUTOPAGESIZE | BKA_MAJOR | flags), front ? BKA_FIRST : BKA_LAST)); 5841 MPFROM2SHORT((BKA_STATUSTEXTON | BKA_AUTOPAGESIZE | BKA_MAJOR | flags), front ? BKA_FIRST : BKA_LAST));
5842 } 5842 }
5843 5843
5844 /* 5844 /*
5845 * Remove a page from a notebook. 5845 * Remove a page from a notebook.
5846 * Parameters: 5846 * Parameters:
5847 * handle: Handle to the notebook widget. 5847 * handle: Handle to the notebook widget.
5848 * pageid: ID of the page to be destroyed. 5848 * pageid: ID of the page to be destroyed.
5849 */ 5849 */
5850 void API dw_notebook_page_destroy(HWND handle, unsigned int pageid) 5850 void API dw_notebook_page_destroy(HWND handle, unsigned int pageid)
5851 { 5851 {
5852 WinSendMsg(handle, BKM_DELETEPAGE, 5852 WinSendMsg(handle, BKM_DELETEPAGE,
5853 MPFROMLONG(pageid), (MPARAM)BKA_SINGLE); 5853 MPFROMLONG(pageid), (MPARAM)BKA_SINGLE);
5854 } 5854 }
5855 5855
5856 /* 5856 /*
5857 * Queries the currently visible page ID. 5857 * Queries the currently visible page ID.
5858 * Parameters: 5858 * Parameters:
5859 * handle: Handle to the notebook widget. 5859 * handle: Handle to the notebook widget.
5860 */ 5860 */
5861 unsigned long API dw_notebook_page_get(HWND handle) 5861 unsigned long API dw_notebook_page_get(HWND handle)
5862 { 5862 {
5863 return (unsigned long)WinSendMsg(handle, BKM_QUERYPAGEID,0L, MPFROM2SHORT(BKA_TOP, BKA_MAJOR)); 5863 return (unsigned long)WinSendMsg(handle, BKM_QUERYPAGEID,0L, MPFROM2SHORT(BKA_TOP, BKA_MAJOR));
5864 } 5864 }
5865 5865
5866 /* 5866 /*
5867 * Sets the currently visibale page ID. 5867 * Sets the currently visibale page ID.
5868 * Parameters: 5868 * Parameters:
5869 * handle: Handle to the notebook widget. 5869 * handle: Handle to the notebook widget.
5870 * pageid: ID of the page to be made visible. 5870 * pageid: ID of the page to be made visible.
5871 */ 5871 */
5872 void API dw_notebook_page_set(HWND handle, unsigned int pageid) 5872 void API dw_notebook_page_set(HWND handle, unsigned int pageid)
5873 { 5873 {
5874 WinSendMsg(handle, BKM_TURNTOPAGE, MPFROMLONG(pageid), 0L); 5874 WinSendMsg(handle, BKM_TURNTOPAGE, MPFROMLONG(pageid), 0L);
5875 } 5875 }
5876 5876
5877 /* 5877 /*
5878 * Sets the text on the specified notebook tab. 5878 * Sets the text on the specified notebook tab.
5879 * Parameters: 5879 * Parameters:
5881 * pageid: Page ID of the tab to set. 5881 * pageid: Page ID of the tab to set.
5882 * text: Pointer to the text to set. 5882 * text: Pointer to the text to set.
5883 */ 5883 */
5884 void API dw_notebook_page_set_text(HWND handle, ULONG pageid, char *text) 5884 void API dw_notebook_page_set_text(HWND handle, ULONG pageid, char *text)
5885 { 5885 {
5886 WinSendMsg(handle, BKM_SETTABTEXT, 5886 WinSendMsg(handle, BKM_SETTABTEXT,
5887 MPFROMLONG(pageid), MPFROMP(text)); 5887 MPFROMLONG(pageid), MPFROMP(text));
5888 } 5888 }
5889 5889
5890 /* 5890 /*
5891 * Sets the text on the specified notebook tab status area. 5891 * Sets the text on the specified notebook tab status area.
5892 * Parameters: 5892 * Parameters:
5894 * pageid: Page ID of the tab to set. 5894 * pageid: Page ID of the tab to set.
5895 * text: Pointer to the text to set. 5895 * text: Pointer to the text to set.
5896 */ 5896 */
5897 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text) 5897 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text)
5898 { 5898 {
5899 WinSendMsg(handle, BKM_SETSTATUSLINETEXT, 5899 WinSendMsg(handle, BKM_SETSTATUSLINETEXT,
5900 MPFROMLONG(pageid), MPFROMP(text)); 5900 MPFROMLONG(pageid), MPFROMP(text));
5901 } 5901 }
5902 5902
5903 /* 5903 /*
5904 * Packs the specified box into the notebook page. 5904 * Packs the specified box into the notebook page.
5905 * Parameters: 5905 * Parameters:
5907 * pageid: Page ID in the notebook which is being packed. 5907 * pageid: Page ID in the notebook which is being packed.
5908 * page: Box handle to be packed. 5908 * page: Box handle to be packed.
5909 */ 5909 */
5910 void API dw_notebook_pack(HWND handle, ULONG pageid, HWND page) 5910 void API dw_notebook_pack(HWND handle, ULONG pageid, HWND page)
5911 { 5911 {
5912 HWND tmpbox = dw_box_new(DW_VERT, 0); 5912 HWND tmpbox = dw_box_new(DW_VERT, 0);
5913 5913
5914 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0); 5914 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0);
5915 WinSubclassWindow(tmpbox, _wndproc); 5915 WinSubclassWindow(tmpbox, _wndproc);
5916 WinSendMsg(handle, BKM_SETPAGEWINDOWHWND, 5916 WinSendMsg(handle, BKM_SETPAGEWINDOWHWND,
5917 MPFROMLONG(pageid), MPFROMHWND(tmpbox)); 5917 MPFROMLONG(pageid), MPFROMHWND(tmpbox));
5918 } 5918 }
5919 5919
5920 /* 5920 /*
5921 * Appends the specified text to the listbox's (or combobox) entry list. 5921 * Appends the specified text to the listbox's (or combobox) entry list.
5922 * Parameters: 5922 * Parameters:
5923 * handle: Handle to the listbox to be appended to. 5923 * handle: Handle to the listbox to be appended to.
5924 * text: Text to append into listbox. 5924 * text: Text to append into listbox.
5925 */ 5925 */
5926 void API dw_listbox_append(HWND handle, char *text) 5926 void API dw_listbox_append(HWND handle, char *text)
5927 { 5927 {
5928 WinSendMsg(handle, 5928 WinSendMsg(handle,
5929 LM_INSERTITEM, 5929 LM_INSERTITEM,
5930 MPFROMSHORT(LIT_END), 5930 MPFROMSHORT(LIT_END),
5931 MPFROMP(text)); 5931 MPFROMP(text));
5932 }
5933
5934 /*
5935 * Inserts the specified text into the listbox's (or combobox) entry list.
5936 * Parameters:
5937 * handle: Handle to the listbox to be inserted into.
5938 * text: Text to insert into listbox.
5939 * pos: 0-based position to insert text
5940 */
5941 void API dw_listbox_insert(HWND handle, char *text, int pos)
5942 {
5943 WinSendMsg(handle,
5944 LM_INSERTITEM,
5945 MPFROMSHORT(pos),
5946 MPFROMP(text));
5932 } 5947 }
5933 5948
5934 /* 5949 /*
5935 * Appends the specified text items to the listbox's (or combobox) entry list. 5950 * Appends the specified text items to the listbox's (or combobox) entry list.
5936 * Parameters: 5951 * Parameters:
5938 * text: Text strings to append into listbox. 5953 * text: Text strings to append into listbox.
5939 * count: Number of text strings to append 5954 * count: Number of text strings to append
5940 */ 5955 */
5941 void API dw_listbox_list_append(HWND handle, char **text, int count) 5956 void API dw_listbox_list_append(HWND handle, char **text, int count)
5942 { 5957 {
5943 int i; 5958 int i;
5944 for(i=0;i<count;i++) 5959 for(i=0;i<count;i++)
5945 WinSendMsg(handle, 5960 WinSendMsg(handle,
5946 LM_INSERTITEM, 5961 LM_INSERTITEM,
5947 MPFROMSHORT(LIT_END), 5962 MPFROMSHORT(LIT_END),
5948 MPFROMP(text[i])); 5963 MPFROMP(text[i]));
5949 } 5964 }
5950 5965
5951 /* 5966 /*
5952 * Clears the listbox's (or combobox) list of all entries. 5967 * Clears the listbox's (or combobox) list of all entries.
5953 * Parameters: 5968 * Parameters:
5954 * handle: Handle to the listbox to be cleared. 5969 * handle: Handle to the listbox to be cleared.
5955 */ 5970 */
5956 void API dw_listbox_clear(HWND handle) 5971 void API dw_listbox_clear(HWND handle)
5957 { 5972 {
5958 WinSendMsg(handle, 5973 WinSendMsg(handle,
5959 LM_DELETEALL, 0L, 0L); 5974 LM_DELETEALL, 0L, 0L);
5960 } 5975 }
5961 5976
5962 /* 5977 /*
5963 * Returns the listbox's item count. 5978 * Returns the listbox's item count.
5964 * Parameters: 5979 * Parameters:
5965 * handle: Handle to the listbox to be cleared. 5980 * handle: Handle to the listbox to be cleared.
5966 */ 5981 */
5967 int API dw_listbox_count(HWND handle) 5982 int API dw_listbox_count(HWND handle)
5968 { 5983 {
5969 return (int)WinSendMsg(handle, 5984 return (int)WinSendMsg(handle,
5970 LM_QUERYITEMCOUNT,0L, 0L); 5985 LM_QUERYITEMCOUNT,0L, 0L);
5971 } 5986 }
5972 5987
5973 /* 5988 /*
5974 * Sets the topmost item in the viewport. 5989 * Sets the topmost item in the viewport.
5975 * Parameters: 5990 * Parameters:
5976 * handle: Handle to the listbox to be cleared. 5991 * handle: Handle to the listbox to be cleared.
5977 * top: Index to the top item. 5992 * top: Index to the top item.
5978 */ 5993 */
5979 void API dw_listbox_set_top(HWND handle, int top) 5994 void API dw_listbox_set_top(HWND handle, int top)
5980 { 5995 {
5981 WinSendMsg(handle, 5996 WinSendMsg(handle,
5982 LM_SETTOPINDEX, 5997 LM_SETTOPINDEX,
5983 MPFROMSHORT(top), 5998 MPFROMSHORT(top),
5984 0L); 5999 0L);
5985 } 6000 }
5986 6001
5987 /* 6002 /*
5988 * Copies the given index item's text into buffer. 6003 * Copies the given index item's text into buffer.
5989 * Parameters: 6004 * Parameters:
5992 * buffer: Buffer where text will be copied. 6007 * buffer: Buffer where text will be copied.
5993 * length: Length of the buffer (including NULL). 6008 * length: Length of the buffer (including NULL).
5994 */ 6009 */
5995 void API dw_listbox_get_text(HWND handle, unsigned int index, char *buffer, unsigned int length) 6010 void API dw_listbox_get_text(HWND handle, unsigned int index, char *buffer, unsigned int length)
5996 { 6011 {
5997 WinSendMsg(handle, LM_QUERYITEMTEXT, MPFROM2SHORT(index, length), (MPARAM)buffer); 6012 WinSendMsg(handle, LM_QUERYITEMTEXT, MPFROM2SHORT(index, length), (MPARAM)buffer);
5998 } 6013 }
5999 6014
6000 /* 6015 /*
6001 * Sets the text of a given listbox entry. 6016 * Sets the text of a given listbox entry.
6002 * Parameters: 6017 * Parameters:
6004 * index: Index into the list to be queried. 6019 * index: Index into the list to be queried.
6005 * buffer: Buffer where text will be copied. 6020 * buffer: Buffer where text will be copied.
6006 */ 6021 */
6007 void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) 6022 void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer)
6008 { 6023 {
6009 WinSendMsg(handle, LM_SETITEMTEXT, MPFROMSHORT(index), (MPARAM)buffer); 6024 WinSendMsg(handle, LM_SETITEMTEXT, MPFROMSHORT(index), (MPARAM)buffer);
6010 } 6025 }
6011 6026
6012 /* 6027 /*
6013 * Returns the index to the item in the list currently selected. 6028 * Returns the index to the item in the list currently selected.
6014 * Parameters: 6029 * Parameters:
6015 * handle: Handle to the listbox to be queried. 6030 * handle: Handle to the listbox to be queried.
6016 */ 6031 */
6017 unsigned int API dw_listbox_selected(HWND handle) 6032 unsigned int API dw_listbox_selected(HWND handle)
6018 { 6033 {
6019 return (unsigned int)WinSendMsg(handle, 6034 return (unsigned int)WinSendMsg(handle,
6020 LM_QUERYSELECTION, 6035 LM_QUERYSELECTION,
6021 MPFROMSHORT(LIT_CURSOR), 6036 MPFROMSHORT(LIT_CURSOR),
6022 0); 6037 0);
6023 } 6038 }
6024 6039
6025 /* 6040 /*
6026 * Returns the index to the current selected item or -1 when done. 6041 * Returns the index to the current selected item or -1 when done.
6027 * Parameters: 6042 * Parameters:
6028 * handle: Handle to the listbox to be queried. 6043 * handle: Handle to the listbox to be queried.
6029 * where: Either the previous return or -1 to restart. 6044 * where: Either the previous return or -1 to restart.
6030 */ 6045 */
6031 int API dw_listbox_selected_multi(HWND handle, int where) 6046 int API dw_listbox_selected_multi(HWND handle, int where)
6032 { 6047 {
6033 int place = where; 6048 int place = where;
6034 6049
6035 if(where == -1) 6050 if(where == -1)
6036 place = LIT_FIRST; 6051 place = LIT_FIRST;
6037 6052
6038 place = (int)WinSendMsg(handle, 6053 place = (int)WinSendMsg(handle,
6039 LM_QUERYSELECTION, 6054 LM_QUERYSELECTION,
6040 MPFROMSHORT(place),0L); 6055 MPFROMSHORT(place),0L);
6041 if(place == LIT_NONE) 6056 if(place == LIT_NONE)
6042 return -1; 6057 return -1;
6043 return place; 6058 return place;
6044 } 6059 }
6045 6060
6046 /* 6061 /*
6047 * Sets the selection state of a given index. 6062 * Sets the selection state of a given index.
6048 * Parameters: 6063 * Parameters:
6050 * index: Item index. 6065 * index: Item index.
6051 * state: TRUE if selected FALSE if unselected. 6066 * state: TRUE if selected FALSE if unselected.
6052 */ 6067 */
6053 void API dw_listbox_select(HWND handle, int index, int state) 6068 void API dw_listbox_select(HWND handle, int index, int state)
6054 { 6069 {
6055 char tmpbuf[100]; 6070 char tmpbuf[100];
6056 6071
6057 WinSendMsg(handle, LM_SELECTITEM, MPFROMSHORT(index), (MPARAM)state); 6072 WinSendMsg(handle, LM_SELECTITEM, MPFROMSHORT(index), (MPARAM)state);
6058 6073
6059 WinQueryClassName(handle, 99, tmpbuf); 6074 WinQueryClassName(handle, 99, tmpbuf);
6060 6075
6061 /* If we are setting a combobox call the event handler manually */ 6076 /* If we are setting a combobox call the event handler manually */
6062 if(strncmp(tmpbuf, "#6", 3)==0) 6077 if(strncmp(tmpbuf, "#6", 3)==0)
6063 _run_event(handle, WM_CONTROL, MPFROM2SHORT(0, LN_SELECT), (MPARAM)handle); 6078 _run_event(handle, WM_CONTROL, MPFROM2SHORT(0, LN_SELECT), (MPARAM)handle);
6064 } 6079 }
6065 6080
6066 /* 6081 /*
6067 * Deletes the item with given index from the list. 6082 * Deletes the item with given index from the list.
6068 * Parameters: 6083 * Parameters:
6069 * handle: Handle to the listbox to be set. 6084 * handle: Handle to the listbox to be set.
6070 * index: Item index. 6085 * index: Item index.
6071 */ 6086 */
6072 void API dw_listbox_delete(HWND handle, int index) 6087 void API dw_listbox_delete(HWND handle, int index)
6073 { 6088 {
6074 WinSendMsg(handle, LM_DELETEITEM, MPFROMSHORT(index), 0); 6089 WinSendMsg(handle, LM_DELETEITEM, MPFROMSHORT(index), 0);
6075 } 6090 }
6076 6091
6077 /* 6092 /*
6078 * Adds text to an MLE box and returns the current point. 6093 * Adds text to an MLE box and returns the current point.
6079 * Parameters: 6094 * Parameters:
6081 * buffer: Text buffer to be imported. 6096 * buffer: Text buffer to be imported.
6082 * startpoint: Point to start entering text. 6097 * startpoint: Point to start entering text.
6083 */ 6098 */
6084 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint) 6099 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint)
6085 { 6100 {
6086 unsigned long point = startpoint; 6101 unsigned long point = startpoint;
6087 PBYTE mlebuf; 6102 PBYTE mlebuf;
6088 6103
6089 /* Work around 64K limit */ 6104 /* Work around 64K limit */
6090 if(!DosAllocMem((PPVOID) &mlebuf, 65536, PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_TILE)) 6105 if(!DosAllocMem((PPVOID) &mlebuf, 65536, PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_TILE))
6091 { 6106 {
6092 int amount, len = strlen(buffer), written = 0; 6107 int amount, len = strlen(buffer), written = 0;
6093 6108
6094 while(written < len) 6109 while(written < len)
6095 { 6110 {
6096 if((len - written) > 65535) 6111 if((len - written) > 65535)
6097 amount = 65535; 6112 amount = 65535;
6098 else 6113 else
6099 amount = len - written; 6114 amount = len - written;
6100 6115
6101 memcpy(mlebuf, &buffer[written], amount); 6116 memcpy(mlebuf, &buffer[written], amount);
6102 mlebuf[amount] = '\0'; 6117 mlebuf[amount] = '\0';
6103 6118
6104 WinSendMsg(handle, MLM_SETIMPORTEXPORT, MPFROMP(mlebuf), MPFROMLONG(amount+1)); 6119 WinSendMsg(handle, MLM_SETIMPORTEXPORT, MPFROMP(mlebuf), MPFROMLONG(amount+1));
6105 WinSendMsg(handle, MLM_IMPORT, MPFROMP(&point), MPFROMLONG(amount + 1)); 6120 WinSendMsg(handle, MLM_IMPORT, MPFROMP(&point), MPFROMLONG(amount + 1));
6106 dw_mle_delete(handle, point, 1); 6121 dw_mle_delete(handle, point, 1);
6107 6122
6108 written += amount; 6123 written += amount;
6109 } 6124 }
6110 DosFreeMem(mlebuf); 6125 DosFreeMem(mlebuf);
6111 } 6126 }
6112 return point - 1; 6127 return point - 1;
6113 } 6128 }
6114 6129
6115 /* 6130 /*
6116 * Grabs text from an MLE box. 6131 * Grabs text from an MLE box.
6117 * Parameters: 6132 * Parameters:
6120 * startpoint: Point to start grabbing text. 6135 * startpoint: Point to start grabbing text.
6121 * length: Amount of text to be grabbed. 6136 * length: Amount of text to be grabbed.
6122 */ 6137 */
6123 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length) 6138 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
6124 { 6139 {
6125 PBYTE mlebuf; 6140 PBYTE mlebuf;
6126 6141
6127 /* Work around 64K limit */ 6142 /* Work around 64K limit */
6128 if(!DosAllocMem((PPVOID) &mlebuf, 65535, PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_TILE)) 6143 if(!DosAllocMem((PPVOID) &mlebuf, 65535, PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_TILE))
6129 { 6144 {
6130 int amount, copied, written = 0; 6145 int amount, copied, written = 0;
6131 6146
6132 while(written < length) 6147 while(written < length)
6133 { 6148 {
6134 if((length - written) > 65535) 6149 if((length - written) > 65535)
6135 amount = 65535; 6150 amount = 65535;
6136 else 6151 else
6137 amount = length - written; 6152 amount = length - written;
6138 6153
6139 WinSendMsg(handle, MLM_SETIMPORTEXPORT, MPFROMP(mlebuf), MPFROMLONG(amount)); 6154 WinSendMsg(handle, MLM_SETIMPORTEXPORT, MPFROMP(mlebuf), MPFROMLONG(amount));
6140 copied = (int)WinSendMsg(handle, MLM_EXPORT, MPFROMP(&startpoint), MPFROMLONG(&amount)); 6155 copied = (int)WinSendMsg(handle, MLM_EXPORT, MPFROMP(&startpoint), MPFROMLONG(&amount));
6141 6156
6142 if(copied) 6157 if(copied)
6143 { 6158 {
6144 memcpy(&buffer[written], mlebuf, copied); 6159 memcpy(&buffer[written], mlebuf, copied);
6145 6160
6146 written += copied; 6161 written += copied;
6147 } 6162 }
6148 else 6163 else
6149 break; 6164 break;
6150 } 6165 }
6151 DosFreeMem(mlebuf); 6166 DosFreeMem(mlebuf);
6152 } 6167 }
6153 } 6168 }
6154 6169
6155 /* 6170 /*
6156 * Obtains information about an MLE box. 6171 * Obtains information about an MLE box.
6157 * Parameters: 6172 * Parameters:
6159 * bytes: A pointer to a variable to return the total bytes. 6174 * bytes: A pointer to a variable to return the total bytes.
6160 * lines: A pointer to a variable to return the number of lines. 6175 * lines: A pointer to a variable to return the number of lines.
6161 */ 6176 */
6162 void API dw_mle_get_size(HWND handle, unsigned long *bytes, unsigned long *lines) 6177 void API dw_mle_get_size(HWND handle, unsigned long *bytes, unsigned long *lines)
6163 { 6178 {
6164 if(bytes) 6179 if(bytes)
6165 *bytes = (unsigned long)WinSendMsg(handle, MLM_QUERYTEXTLENGTH, 0, 0); 6180 *bytes = (unsigned long)WinSendMsg(handle, MLM_QUERYTEXTLENGTH, 0, 0);
6166 if(lines) 6181 if(lines)
6167 *lines = (unsigned long)WinSendMsg(handle, MLM_QUERYLINECOUNT, 0, 0); 6182 *lines = (unsigned long)WinSendMsg(handle, MLM_QUERYLINECOUNT, 0, 0);
6168 } 6183 }
6169 6184
6170 /* 6185 /*
6171 * Deletes text from an MLE box. 6186 * Deletes text from an MLE box.
6172 * Parameters: 6187 * Parameters:
6174 * startpoint: Point to start deleting text. 6189 * startpoint: Point to start deleting text.
6175 * length: Amount of text to be deleted. 6190 * length: Amount of text to be deleted.
6176 */ 6191 */
6177 void API dw_mle_delete(HWND handle, int startpoint, int length) 6192 void API dw_mle_delete(HWND handle, int startpoint, int length)
6178 { 6193 {
6179 char *buf = malloc(length+1); 6194 char *buf = malloc(length+1);
6180 int z, dellen = length; 6195 int z, dellen = length;
6181 6196
6182 dw_mle_export(handle, buf, startpoint, length); 6197 dw_mle_export(handle, buf, startpoint, length);
6183 6198
6184 for(z=0;z<length-1;z++) 6199 for(z=0;z<length-1;z++)
6185 { 6200 {
6186 if(strncmp(&buf[z], "\r\n", 2) == 0) 6201 if(strncmp(&buf[z], "\r\n", 2) == 0)
6187 dellen--; 6202 dellen--;
6188 } 6203 }
6189 WinSendMsg(handle, MLM_DELETE, MPFROMLONG(startpoint), MPFROMLONG(dellen)); 6204 WinSendMsg(handle, MLM_DELETE, MPFROMLONG(startpoint), MPFROMLONG(dellen));
6190 free(buf); 6205 free(buf);
6191 } 6206 }
6192 6207
6193 /* 6208 /*
6194 * Clears all text from an MLE box. 6209 * Clears all text from an MLE box.
6195 * Parameters: 6210 * Parameters:
6196 * handle: Handle to the MLE to be cleared. 6211 * handle: Handle to the MLE to be cleared.
6197 */ 6212 */
6198 void API dw_mle_clear(HWND handle) 6213 void API dw_mle_clear(HWND handle)
6199 { 6214 {
6200 unsigned long bytes; 6215 unsigned long bytes;
6201 6216
6202 dw_mle_get_size(handle, &bytes, NULL); 6217 dw_mle_get_size(handle, &bytes, NULL);
6203 6218
6204 WinSendMsg(handle, MLM_DELETE, MPFROMLONG(0), MPFROMLONG(bytes)); 6219 WinSendMsg(handle, MLM_DELETE, MPFROMLONG(0), MPFROMLONG(bytes));
6205 } 6220 }
6206 6221
6207 /* 6222 /*
6208 * Sets the visible line of an MLE box. 6223 * Sets the visible line of an MLE box.
6209 * Parameters: 6224 * Parameters:
6210 * handle: Handle to the MLE to be positioned. 6225 * handle: Handle to the MLE to be positioned.
6211 * line: Line to be visible. 6226 * line: Line to be visible.
6212 */ 6227 */
6213 void API dw_mle_set_visible(HWND handle, int line) 6228 void API dw_mle_set_visible(HWND handle, int line)
6214 { 6229 {
6215 int tmppnt = (int)WinSendMsg(handle, MLM_CHARFROMLINE, MPFROMLONG(line), 0); 6230 int tmppnt = (int)WinSendMsg(handle, MLM_CHARFROMLINE, MPFROMLONG(line), 0);
6216 WinSendMsg(handle, MLM_SETSEL, MPFROMLONG(tmppnt), MPFROMLONG(tmppnt)); 6231 WinSendMsg(handle, MLM_SETSEL, MPFROMLONG(tmppnt), MPFROMLONG(tmppnt));
6217 } 6232 }
6218 6233
6219 /* 6234 /*
6220 * Sets the editablity of an MLE box. 6235 * Sets the editablity of an MLE box.
6221 * Parameters: 6236 * Parameters:
6222 * handle: Handle to the MLE. 6237 * handle: Handle to the MLE.
6223 * state: TRUE if it can be edited, FALSE for readonly. 6238 * state: TRUE if it can be edited, FALSE for readonly.
6224 */ 6239 */
6225 void API dw_mle_set_editable(HWND handle, int state) 6240 void API dw_mle_set_editable(HWND handle, int state)
6226 { 6241 {
6227 WinSendMsg(handle, MLM_SETREADONLY, MPFROMLONG(state ? FALSE : TRUE), 0); 6242 WinSendMsg(handle, MLM_SETREADONLY, MPFROMLONG(state ? FALSE : TRUE), 0);
6228 } 6243 }
6229 6244
6230 /* 6245 /*
6231 * Sets the word wrap state of an MLE box. 6246 * Sets the word wrap state of an MLE box.
6232 * Parameters: 6247 * Parameters:
6233 * handle: Handle to the MLE. 6248 * handle: Handle to the MLE.
6234 * state: TRUE if it wraps, FALSE if it doesn't. 6249 * state: TRUE if it wraps, FALSE if it doesn't.
6235 */ 6250 */
6236 void API dw_mle_set_word_wrap(HWND handle, int state) 6251 void API dw_mle_set_word_wrap(HWND handle, int state)
6237 { 6252 {
6238 WinSendMsg(handle, MLM_SETWRAP, MPFROMLONG(state), 0); 6253 WinSendMsg(handle, MLM_SETWRAP, MPFROMLONG(state), 0);
6239 } 6254 }
6240 6255
6241 /* 6256 /*
6242 * Sets the current cursor position of an MLE box. 6257 * Sets the current cursor position of an MLE box.
6243 * Parameters: 6258 * Parameters:
6244 * handle: Handle to the MLE to be positioned. 6259 * handle: Handle to the MLE to be positioned.
6245 * point: Point to position cursor. 6260 * point: Point to position cursor.
6246 */ 6261 */
6247 void API dw_mle_set_cursor(HWND handle, int point) 6262 void API dw_mle_set_cursor(HWND handle, int point)
6248 { 6263 {
6249 WinSendMsg(handle, MLM_SETSEL, MPFROMLONG(point), MPFROMLONG(point)); 6264 WinSendMsg(handle, MLM_SETSEL, MPFROMLONG(point), MPFROMLONG(point));
6250 } 6265 }
6251 6266
6252 /* 6267 /*
6253 * Finds text in an MLE box. 6268 * Finds text in an MLE box.
6254 * Parameters: 6269 * Parameters:
6257 * point: Start point of search. 6272 * point: Start point of search.
6258 * flags: Search specific flags. 6273 * flags: Search specific flags.
6259 */ 6274 */
6260 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags) 6275 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
6261 { 6276 {
6262 MLE_SEARCHDATA msd; 6277 MLE_SEARCHDATA msd;
6263 6278
6264 /* This code breaks with structure packing set to 1 (/Sp1 in VAC) 6279 /* This code breaks with structure packing set to 1 (/Sp1 in VAC)
6265 * if this is needed we need to add a pragma here. 6280 * if this is needed we need to add a pragma here.
6266 */ 6281 */
6267 msd.cb = sizeof(msd); 6282 msd.cb = sizeof(msd);
6268 msd.pchFind = text; 6283 msd.pchFind = text;
6269 msd.pchReplace = NULL; 6284 msd.pchReplace = NULL;
6270 msd.cchFind = strlen(text); 6285 msd.cchFind = strlen(text);
6271 msd.cchReplace = 0; 6286 msd.cchReplace = 0;
6272 msd.iptStart = point; 6287 msd.iptStart = point;
6273 msd.iptStop = -1; 6288 msd.iptStop = -1;
6274 6289
6275 if(WinSendMsg(handle, MLM_SEARCH, MPFROMLONG(MLFSEARCH_SELECTMATCH | flags), (MPARAM)&msd)) 6290 if(WinSendMsg(handle, MLM_SEARCH, MPFROMLONG(MLFSEARCH_SELECTMATCH | flags), (MPARAM)&msd))
6276 return (int)WinSendMsg(handle, MLM_QUERYSEL,(MPARAM)MLFQS_MAXSEL, 0); 6291 return (int)WinSendMsg(handle, MLM_QUERYSEL,(MPARAM)MLFQS_MAXSEL, 0);
6277 return 0; 6292 return 0;
6278 } 6293 }
6279 6294
6280 /* 6295 /*
6281 * Stops redrawing of an MLE box. 6296 * Stops redrawing of an MLE box.
6282 * Parameters: 6297 * Parameters:
6283 * handle: Handle to the MLE to freeze. 6298 * handle: Handle to the MLE to freeze.
6284 */ 6299 */
6285 void API dw_mle_freeze(HWND handle) 6300 void API dw_mle_freeze(HWND handle)
6286 { 6301 {
6287 WinSendMsg(handle, MLM_DISABLEREFRESH, 0, 0); 6302 WinSendMsg(handle, MLM_DISABLEREFRESH, 0, 0);
6288 } 6303 }
6289 6304
6290 /* 6305 /*
6291 * Resumes redrawing of an MLE box. 6306 * Resumes redrawing of an MLE box.
6292 * Parameters: 6307 * Parameters:
6293 * handle: Handle to the MLE to thaw. 6308 * handle: Handle to the MLE to thaw.
6294 */ 6309 */
6295 void API dw_mle_thaw(HWND handle) 6310 void API dw_mle_thaw(HWND handle)
6296 { 6311 {
6297 WinSendMsg(handle, MLM_ENABLEREFRESH, 0, 0); 6312 WinSendMsg(handle, MLM_ENABLEREFRESH, 0, 0);
6298 } 6313 }
6299 6314
6300 /* 6315 /*
6301 * Sets the percent bar position. 6316 * Sets the percent bar position.
6302 * Parameters: 6317 * Parameters:
6303 * handle: Handle to the percent bar to be set. 6318 * handle: Handle to the percent bar to be set.
6304 * position: Position of the percent bar withing the range. 6319 * position: Position of the percent bar withing the range.
6305 */ 6320 */
6306 void API dw_percent_set_pos(HWND handle, unsigned int position) 6321 void API dw_percent_set_pos(HWND handle, unsigned int position)
6307 { 6322 {
6308 int range = _dw_percent_get_range(handle); 6323 int range = _dw_percent_get_range(handle);
6309 int mypos = ((float)position/100)*range; 6324 int mypos = ((float)position/100)*range;
6310 6325
6311 if(range) 6326 if(range)
6312 { 6327 {
6313 _dw_int_set(handle, mypos); 6328 _dw_int_set(handle, mypos);
6314 WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)mypos); 6329 WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)mypos);
6315 } 6330 }
6316 } 6331 }
6317 6332
6318 /* 6333 /*
6319 * Returns the position of the slider. 6334 * Returns the position of the slider.
6320 * Parameters: 6335 * Parameters:
6321 * handle: Handle to the slider to be queried. 6336 * handle: Handle to the slider to be queried.
6322 */ 6337 */
6323 unsigned int API dw_slider_get_pos(HWND handle) 6338 unsigned int API dw_slider_get_pos(HWND handle)
6324 { 6339 {
6325 return (unsigned int)WinSendMsg(handle, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), 0); 6340 return (unsigned int)WinSendMsg(handle, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), 0);
6326 } 6341 }
6327 6342
6328 /* 6343 /*
6329 * Sets the slider position. 6344 * Sets the slider position.
6330 * Parameters: 6345 * Parameters:
6331 * handle: Handle to the slider to be set. 6346 * handle: Handle to the slider to be set.
6332 * position: Position of the slider withing the range. 6347 * position: Position of the slider withing the range.
6333 */ 6348 */
6334 void API dw_slider_set_pos(HWND handle, unsigned int position) 6349 void API dw_slider_set_pos(HWND handle, unsigned int position)
6335 { 6350 {
6336 dw_window_set_data(handle, "_dw_slider_value", (void *)position); 6351 dw_window_set_data(handle, "_dw_slider_value", (void *)position);
6337 WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), (MPARAM)position); 6352 WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), (MPARAM)position);
6338 } 6353 }
6339 6354
6340 /* 6355 /*
6341 * Returns the position of the scrollbar. 6356 * Returns the position of the scrollbar.
6342 * Parameters: 6357 * Parameters:
6343 * handle: Handle to the scrollbar to be queried. 6358 * handle: Handle to the scrollbar to be queried.
6344 */ 6359 */
6345 unsigned int API dw_scrollbar_get_pos(HWND handle) 6360 unsigned int API dw_scrollbar_get_pos(HWND handle)
6346 { 6361 {
6347 return (unsigned int)WinSendMsg(handle, SBM_QUERYPOS, 0, 0); 6362 return (unsigned int)WinSendMsg(handle, SBM_QUERYPOS, 0, 0);
6348 } 6363 }
6349 6364
6350 /* 6365 /*
6351 * Sets the scrollbar position. 6366 * Sets the scrollbar position.
6352 * Parameters: 6367 * Parameters:
6353 * handle: Handle to the scrollbar to be set. 6368 * handle: Handle to the scrollbar to be set.
6354 * position: Position of the scrollbar withing the range. 6369 * position: Position of the scrollbar withing the range.
6355 */ 6370 */
6356 void API dw_scrollbar_set_pos(HWND handle, unsigned int position) 6371 void API dw_scrollbar_set_pos(HWND handle, unsigned int position)
6357 { 6372 {
6358 dw_window_set_data(handle, "_dw_scrollbar_value", (void *)position); 6373 dw_window_set_data(handle, "_dw_scrollbar_value", (void *)position);
6359 WinSendMsg(handle, SBM_SETPOS, (MPARAM)position, 0); 6374 WinSendMsg(handle, SBM_SETPOS, (MPARAM)position, 0);
6360 } 6375 }
6361 6376
6362 /* 6377 /*
6363 * Sets the scrollbar range. 6378 * Sets the scrollbar range.
6364 * Parameters: 6379 * Parameters:
6366 * range: Maximum range value. 6381 * range: Maximum range value.
6367 * visible: Visible area relative to the range. 6382 * visible: Visible area relative to the range.
6368 */ 6383 */
6369 void API dw_scrollbar_set_range(HWND handle, unsigned int range, unsigned int visible) 6384 void API dw_scrollbar_set_range(HWND handle, unsigned int range, unsigned int visible)
6370 { 6385 {
6371 unsigned int pos = (unsigned int)dw_window_get_data(handle, "_dw_scrollbar_value"); 6386 unsigned int pos = (unsigned int)dw_window_get_data(handle, "_dw_scrollbar_value");
6372 WinSendMsg(handle, SBM_SETSCROLLBAR, (MPARAM)pos, MPFROM2SHORT(0, (unsigned short)range - visible)); 6387 WinSendMsg(handle, SBM_SETSCROLLBAR, (MPARAM)pos, MPFROM2SHORT(0, (unsigned short)range - visible));
6373 WinSendMsg(handle, SBM_SETTHUMBSIZE, MPFROM2SHORT((unsigned short)visible, range), 0); 6388 WinSendMsg(handle, SBM_SETTHUMBSIZE, MPFROM2SHORT((unsigned short)visible, range), 0);
6374 dw_window_set_data(handle, "_dw_scrollbar_visible", (void *)visible); 6389 dw_window_set_data(handle, "_dw_scrollbar_visible", (void *)visible);
6375 } 6390 }
6376 6391
6377 /* 6392 /*
6378 * Sets the spinbutton value. 6393 * Sets the spinbutton value.
6379 * Parameters: 6394 * Parameters:
6380 * handle: Handle to the spinbutton to be set. 6395 * handle: Handle to the spinbutton to be set.
6381 * position: Current value of the spinbutton. 6396 * position: Current value of the spinbutton.
6382 */ 6397 */
6383 void API dw_spinbutton_set_pos(HWND handle, long position) 6398 void API dw_spinbutton_set_pos(HWND handle, long position)
6384 { 6399 {
6385 WinSendMsg(handle, SPBM_SETCURRENTVALUE, MPFROMLONG((long)position), 0L); 6400 WinSendMsg(handle, SPBM_SETCURRENTVALUE, MPFROMLONG((long)position), 0L);
6386 } 6401 }
6387 6402
6388 /* 6403 /*
6389 * Sets the spinbutton limits. 6404 * Sets the spinbutton limits.
6390 * Parameters: 6405 * Parameters:
6392 * upper: Upper limit. 6407 * upper: Upper limit.
6393 * lower: Lower limit. 6408 * lower: Lower limit.
6394 */ 6409 */
6395 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower) 6410 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower)
6396 { 6411 {
6397 WinSendMsg(handle, SPBM_SETLIMITS, MPFROMLONG(upper), MPFROMLONG(lower)); 6412 WinSendMsg(handle, SPBM_SETLIMITS, MPFROMLONG(upper), MPFROMLONG(lower));
6398 } 6413 }
6399 6414
6400 /* 6415 /*
6401 * Sets the entryfield character limit. 6416 * Sets the entryfield character limit.
6402 * Parameters: 6417 * Parameters:
6403 * handle: Handle to the spinbutton to be set. 6418 * handle: Handle to the spinbutton to be set.
6404 * limit: Number of characters the entryfield will take. 6419 * limit: Number of characters the entryfield will take.
6405 */ 6420 */
6406 void API dw_entryfield_set_limit(HWND handle, ULONG limit) 6421 void API dw_entryfield_set_limit(HWND handle, ULONG limit)
6407 { 6422 {
6408 WinSendMsg(handle, EM_SETTEXTLIMIT, (MPARAM)limit, (MPARAM)0); 6423 WinSendMsg(handle, EM_SETTEXTLIMIT, (MPARAM)limit, (MPARAM)0);
6409 } 6424 }
6410 6425
6411 6426
6412 /* 6427 /*
6413 * Returns the current value of the spinbutton. 6428 * Returns the current value of the spinbutton.
6414 * Parameters: 6429 * Parameters:
6415 * handle: Handle to the spinbutton to be queried. 6430 * handle: Handle to the spinbutton to be queried.
6416 */ 6431 */
6417 long API dw_spinbutton_get_pos(HWND handle) 6432 long API dw_spinbutton_get_pos(HWND handle)
6418 { 6433 {
6419 long tmpval = 0L; 6434 long tmpval = 0L;
6420 6435
6421 WinSendMsg(handle, SPBM_QUERYVALUE, (MPARAM)&tmpval,0L); 6436 WinSendMsg(handle, SPBM_QUERYVALUE, (MPARAM)&tmpval,0L);
6422 return tmpval; 6437 return tmpval;
6423 } 6438 }
6424 6439
6425 /* 6440 /*
6426 * Returns the state of the checkbox. 6441 * Returns the state of the checkbox.
6427 * Parameters: 6442 * Parameters:
6428 * handle: Handle to the checkbox to be queried. 6443 * handle: Handle to the checkbox to be queried.
6429 */ 6444 */
6430 int API dw_checkbox_get(HWND handle) 6445 int API dw_checkbox_get(HWND handle)
6431 { 6446 {
6432 return (int)WinSendMsg(handle,BM_QUERYCHECK,0,0); 6447 return (int)WinSendMsg(handle,BM_QUERYCHECK,0,0);
6433 } 6448 }
6434 6449
6435 /* 6450 /*
6436 * Sets the state of the checkbox. 6451 * Sets the state of the checkbox.
6437 * Parameters: 6452 * Parameters:
6438 * handle: Handle to the checkbox to be queried. 6453 * handle: Handle to the checkbox to be queried.
6439 * value: TRUE for checked, FALSE for unchecked. 6454 * value: TRUE for checked, FALSE for unchecked.
6440 */ 6455 */
6441 void API dw_checkbox_set(HWND handle, int value) 6456 void API dw_checkbox_set(HWND handle, int value)
6442 { 6457 {
6443 WinSendMsg(handle,BM_SETCHECK,MPFROMSHORT(value),0); 6458 WinSendMsg(handle,BM_SETCHECK,MPFROMSHORT(value),0);
6444 } 6459 }
6445 6460
6446 /* 6461 /*
6447 * Inserts an item into a tree window (widget) after another item. 6462 * Inserts an item into a tree window (widget) after another item.
6448 * Parameters: 6463 * Parameters:
6453 * parent: Parent handle or 0 if root. 6468 * parent: Parent handle or 0 if root.
6454 * itemdata: Item specific data. 6469 * itemdata: Item specific data.
6455 */ 6470 */
6456 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) 6471 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HTREEITEM parent, void *itemdata)
6457 { 6472 {
6458 ULONG cbExtra; 6473 ULONG cbExtra;
6459 PCNRITEM pci; 6474 PCNRITEM pci;
6460 RECORDINSERT ri; 6475 RECORDINSERT ri;
6461 6476
6462 if(!item) 6477 if(!item)
6463 item = (HTREEITEM)CMA_FIRST; 6478 item = (HTREEITEM)CMA_FIRST;
6464 6479
6465 /* Calculate extra bytes needed for each record besides that needed for the 6480 /* Calculate extra bytes needed for each record besides that needed for the
6466 * MINIRECORDCORE structure 6481 * MINIRECORDCORE structure
6467 */ 6482 */
6468 6483
6469 cbExtra = sizeof(CNRITEM) - sizeof(MINIRECORDCORE); 6484 cbExtra = sizeof(CNRITEM) - sizeof(MINIRECORDCORE);
6470 6485
6471 /* Allocate memory for the parent record */ 6486 /* Allocate memory for the parent record */
6472 6487
6473 if((pci = (PCNRITEM)_dw_send_msg(handle, CM_ALLOCRECORD, MPFROMLONG(cbExtra), MPFROMSHORT(1), 0)) == 0) 6488 if((pci = (PCNRITEM)_dw_send_msg(handle, CM_ALLOCRECORD, MPFROMLONG(cbExtra), MPFROMSHORT(1), 0)) == 0)
6474 return 0; 6489 return 0;
6475 6490
6476 /* Fill in the parent record data */ 6491 /* Fill in the parent record data */
6477 6492
6478 pci->rc.cb = sizeof(MINIRECORDCORE); 6493 pci->rc.cb = sizeof(MINIRECORDCORE);
6479 pci->rc.pszIcon = strdup(title); 6494 pci->rc.pszIcon = strdup(title);
6480 pci->rc.hptrIcon = icon; 6495 pci->rc.hptrIcon = icon;
6481 6496
6482 pci->hptrIcon = icon; 6497 pci->hptrIcon = icon;
6483 pci->user = itemdata; 6498 pci->user = itemdata;
6484 pci->parent = parent; 6499 pci->parent = parent;
6485 6500
6486 memset(&ri, 0, sizeof(RECORDINSERT)); 6501 memset(&ri, 0, sizeof(RECORDINSERT));
6487 6502
6488 ri.cb = sizeof(RECORDINSERT); 6503 ri.cb = sizeof(RECORDINSERT);
6489 ri.pRecordOrder = (PRECORDCORE)item; 6504 ri.pRecordOrder = (PRECORDCORE)item;
6490 ri.zOrder = (USHORT)CMA_TOP; 6505 ri.zOrder = (USHORT)CMA_TOP;
6491 ri.cRecordsInsert = 1; 6506 ri.cRecordsInsert = 1;
6492 ri.fInvalidateRecord = TRUE; 6507 ri.fInvalidateRecord = TRUE;
6493 6508
6494 /* We are about to insert the child records. Set the parent record to be 6509 /* We are about to insert the child records. Set the parent record to be
6495 * the one we just inserted. 6510 * the one we just inserted.
6496 */ 6511 */
6497 ri.pRecordParent = (PRECORDCORE)parent; 6512 ri.pRecordParent = (PRECORDCORE)parent;
6498 6513
6499 /* Insert the record */ 6514 /* Insert the record */
6500 WinSendMsg(handle, CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri)); 6515 WinSendMsg(handle, CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri));
6501 6516
6502 return (HTREEITEM)pci; 6517 return (HTREEITEM)pci;
6503 } 6518 }
6504 6519
6505 /* 6520 /*
6506 * Inserts an item into a tree window (widget). 6521 * Inserts an item into a tree window (widget).
6507 * Parameters: 6522 * Parameters:
6511 * parent: Parent handle or 0 if root. 6526 * parent: Parent handle or 0 if root.
6512 * itemdata: Item specific data. 6527 * itemdata: Item specific data.
6513 */ 6528 */
6514 HTREEITEM API dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) 6529 HTREEITEM API dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata)
6515 { 6530 {
6516 return dw_tree_insert_after(handle, (HTREEITEM)CMA_END, title, icon, parent, itemdata); 6531 return dw_tree_insert_after(handle, (HTREEITEM)CMA_END, title, icon, parent, itemdata);
6517 } 6532 }
6518 6533
6519 /* 6534 /*
6520 * Sets the text and icon of an item in a tree window (widget). 6535 * Sets the text and icon of an item in a tree window (widget).
6521 * Parameters: 6536 * Parameters:
6524 * title: The text title of the entry. 6539 * title: The text title of the entry.
6525 * icon: Handle to coresponding icon. 6540 * icon: Handle to coresponding icon.
6526 */ 6541 */
6527 void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, unsigned long icon) 6542 void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, unsigned long icon)
6528 { 6543 {
6529 PCNRITEM pci = (PCNRITEM)item; 6544 PCNRITEM pci = (PCNRITEM)item;
6530 6545
6531 if(!pci) 6546 if(!pci)
6532 return; 6547 return;
6533 6548
6534 if(pci->rc.pszIcon) 6549 if(pci->rc.pszIcon)
6535 free(pci->rc.pszIcon); 6550 free(pci->rc.pszIcon);
6536 6551
6537 pci->rc.pszIcon = strdup(title); 6552 pci->rc.pszIcon = strdup(title);
6538 pci->rc.hptrIcon = icon; 6553 pci->rc.hptrIcon = icon;
6539 6554
6540 pci->hptrIcon = icon; 6555 pci->hptrIcon = icon;
6541 6556
6542 WinSendMsg(handle, CM_INVALIDATERECORD, (MPARAM)&pci, MPFROM2SHORT(1, CMA_TEXTCHANGED)); 6557 WinSendMsg(handle, CM_INVALIDATERECORD, (MPARAM)&pci, MPFROM2SHORT(1, CMA_TEXTCHANGED));
6543 } 6558 }
6544 6559
6545 /* 6560 /*
6546 * Gets the text an item in a tree window (widget). 6561 * Gets the text an item in a tree window (widget).
6547 * Parameters: 6562 * Parameters:
6548 * handle: Handle to the tree containing the item. 6563 * handle: Handle to the tree containing the item.
6549 * item: Handle of the item to be modified. 6564 * item: Handle of the item to be modified.
6550 */ 6565 */
6551 char * API dw_tree_get_title(HWND handle, HTREEITEM item) 6566 char * API dw_tree_get_title(HWND handle, HTREEITEM item)
6552 { 6567 {
6553 PCNRITEM pci = (PCNRITEM)item; 6568 PCNRITEM pci = (PCNRITEM)item;
6554 6569
6555 handle = handle; /* keep compiler happy */ 6570 handle = handle; /* keep compiler happy */
6556 if(pci) 6571 if(pci)
6557 return pci->rc.pszIcon; 6572 return pci->rc.pszIcon;
6558 return NULL; 6573 return NULL;
6559 } 6574 }
6560 6575
6561 /* 6576 /*
6562 * Gets the text an item in a tree window (widget). 6577 * Gets the text an item in a tree window (widget).
6563 * Parameters: 6578 * Parameters:
6564 * handle: Handle to the tree containing the item. 6579 * handle: Handle to the tree containing the item.
6565 * item: Handle of the item to be modified. 6580 * item: Handle of the item to be modified.
6566 */ 6581 */
6567 HTREEITEM API dw_tree_get_parent(HWND handle, HTREEITEM item) 6582 HTREEITEM API dw_tree_get_parent(HWND handle, HTREEITEM item)
6568 { 6583 {
6569 PCNRITEM pci = (PCNRITEM)item; 6584 PCNRITEM pci = (PCNRITEM)item;
6570 6585
6571 handle = handle; /* keep compiler happy */ 6586 handle = handle; /* keep compiler happy */
6572 if(pci) 6587 if(pci)
6573 return pci->parent; 6588 return pci->parent;
6574 return (HTREEITEM)0; 6589 return (HTREEITEM)0;
6575 } 6590 }
6576 6591
6577 /* 6592 /*
6578 * Sets the item data of a tree item. 6593 * Sets the item data of a tree item.
6579 * Parameters: 6594 * Parameters:
6581 * item: Handle of the item to be modified. 6596 * item: Handle of the item to be modified.
6582 * itemdata: User defined data to be associated with item. 6597 * itemdata: User defined data to be associated with item.
6583 */ 6598 */
6584 void API dw_tree_item_set_data(HWND handle, HTREEITEM item, void *itemdata) 6599 void API dw_tree_item_set_data(HWND handle, HTREEITEM item, void *itemdata)
6585 { 6600 {
6586 PCNRITEM pci = (PCNRITEM)item; 6601 PCNRITEM pci = (PCNRITEM)item;
6587 6602
6588 handle = handle; /* keep compiler happy */ 6603 handle = handle; /* keep compiler happy */
6589 if(!pci) 6604 if(!pci)
6590 return; 6605 return;
6591 6606
6592 pci->user = itemdata; 6607 pci->user = itemdata;
6593 } 6608 }
6594 6609
6595 /* 6610 /*
6596 * Gets the item data of a tree item. 6611 * Gets the item data of a tree item.
6597 * Parameters: 6612 * Parameters:
6598 * handle: Handle to the tree containing the item. 6613 * handle: Handle to the tree containing the item.
6599 * item: Handle of the item to be modified. 6614 * item: Handle of the item to be modified.
6600 */ 6615 */
6601 void * API dw_tree_item_get_data(HWND handle, HTREEITEM item) 6616 void * API dw_tree_item_get_data(HWND handle, HTREEITEM item)
6602 { 6617 {
6603 PCNRITEM pci = (PCNRITEM)item; 6618 PCNRITEM pci = (PCNRITEM)item;
6604 6619
6605 handle = handle; /* keep compiler happy */ 6620 handle = handle; /* keep compiler happy */
6606 if(!pci) 6621 if(!pci)
6607 return NULL; 6622 return NULL;
6608 return pci->user; 6623 return pci->user;
6609 } 6624 }
6610 6625
6611 /* 6626 /*
6612 * Sets this item as the active selection. 6627 * Sets this item as the active selection.
6613 * Parameters: 6628 * Parameters:
6614 * handle: Handle to the tree window (widget) to be selected. 6629 * handle: Handle to the tree window (widget) to be selected.
6615 * item: Handle to the item to be selected. 6630 * item: Handle to the item to be selected.
6616 */ 6631 */
6617 void API dw_tree_item_select(HWND handle, HTREEITEM item) 6632 void API dw_tree_item_select(HWND handle, HTREEITEM item)
6618 { 6633 {
6619 PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 6634 PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
6620 6635
6621 while(pCore) 6636 while(pCore)
6622 { 6637 {
6623 if(pCore->flRecordAttr & CRA_SELECTED) 6638 if(pCore->flRecordAttr & CRA_SELECTED)
6624 WinSendMsg(handle, CM_SETRECORDEMPHASIS, (MPARAM)pCore, MPFROM2SHORT(FALSE, CRA_SELECTED | CRA_CURSORED)); 6639 WinSendMsg(handle, CM_SETRECORDEMPHASIS, (MPARAM)pCore, MPFROM2SHORT(FALSE, CRA_SELECTED | CRA_CURSORED));
6625 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 6640 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
6626 } 6641 }
6627 WinSendMsg(handle, CM_SETRECORDEMPHASIS, (MPARAM)item, MPFROM2SHORT(TRUE, CRA_SELECTED | CRA_CURSORED)); 6642 WinSendMsg(handle, CM_SETRECORDEMPHASIS, (MPARAM)item, MPFROM2SHORT(TRUE, CRA_SELECTED | CRA_CURSORED));
6628 lastitem = 0; 6643 lastitem = 0;
6629 lasthcnr = 0; 6644 lasthcnr = 0;
6630 } 6645 }
6631 6646
6632 /* 6647 /*
6633 * Removes all nodes from a tree. 6648 * Removes all nodes from a tree.
6634 * Parameters: 6649 * Parameters:
6635 * handle: Handle to the window (widget) to be cleared. 6650 * handle: Handle to the window (widget) to be cleared.
6636 */ 6651 */
6637 void API dw_tree_clear(HWND handle) 6652 void API dw_tree_clear(HWND handle)
6638 { 6653 {
6639 dw_container_clear(handle, TRUE); 6654 dw_container_clear(handle, TRUE);
6640 } 6655 }
6641 6656
6642 /* 6657 /*
6643 * Expands a node on a tree. 6658 * Expands a node on a tree.
6644 * Parameters: 6659 * Parameters:
6645 * handle: Handle to the tree window (widget). 6660 * handle: Handle to the tree window (widget).
6646 * item: Handle to node to be expanded. 6661 * item: Handle to node to be expanded.
6647 */ 6662 */
6648 void API dw_tree_item_expand(HWND handle, HTREEITEM item) 6663 void API dw_tree_item_expand(HWND handle, HTREEITEM item)
6649 { 6664 {
6650 WinSendMsg(handle, CM_EXPANDTREE, MPFROMP(item), 0); 6665 WinSendMsg(handle, CM_EXPANDTREE, MPFROMP(item), 0);
6651 } 6666 }
6652 6667
6653 /* 6668 /*
6654 * Collapses a node on a tree. 6669 * Collapses a node on a tree.
6655 * Parameters: 6670 * Parameters:
6656 * handle: Handle to the tree window (widget). 6671 * handle: Handle to the tree window (widget).
6657 * item: Handle to node to be collapsed. 6672 * item: Handle to node to be collapsed.
6658 */ 6673 */
6659 void API dw_tree_item_collapse(HWND handle, HTREEITEM item) 6674 void API dw_tree_item_collapse(HWND handle, HTREEITEM item)
6660 { 6675 {
6661 WinSendMsg(handle, CM_COLLAPSETREE, MPFROMP(item), 0); 6676 WinSendMsg(handle, CM_COLLAPSETREE, MPFROMP(item), 0);
6662 } 6677 }
6663 6678
6664 /* 6679 /*
6665 * Removes a node from a tree. 6680 * Removes a node from a tree.
6666 * Parameters: 6681 * Parameters:
6667 * handle: Handle to the window (widget) to be cleared. 6682 * handle: Handle to the window (widget) to be cleared.
6668 * item: Handle to node to be deleted. 6683 * item: Handle to node to be deleted.
6669 */ 6684 */
6670 void API dw_tree_item_delete(HWND handle, HTREEITEM item) 6685 void API dw_tree_item_delete(HWND handle, HTREEITEM item)
6671 { 6686 {
6672 PCNRITEM pci = (PCNRITEM)item; 6687 PCNRITEM pci = (PCNRITEM)item;
6673 6688
6674 if(!item) 6689 if(!item)
6675 return; 6690 return;
6676 6691
6677 if(pci->rc.pszIcon) 6692 if(pci->rc.pszIcon)
6678 { 6693 {
6679 free(pci->rc.pszIcon); 6694 free(pci->rc.pszIcon);
6680 pci->rc.pszIcon = 0; 6695 pci->rc.pszIcon = 0;
6681 } 6696 }
6682 6697
6683 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)&pci, MPFROM2SHORT(1, CMA_INVALIDATE | CMA_FREE)); 6698 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)&pci, MPFROM2SHORT(1, CMA_INVALIDATE | CMA_FREE));
6684 } 6699 }
6685 6700
6686 /* Some OS/2 specific container structs */ 6701 /* Some OS/2 specific container structs */
6687 typedef struct _containerinfo { 6702 typedef struct _containerinfo {
6688 int count; 6703 int count;
6689 void *data; 6704 void *data;
6690 HWND handle; 6705 HWND handle;
6691 } ContainerInfo; 6706 } ContainerInfo;
6692 6707
6693 /* 6708 /*
6694 * Sets up the container columns. 6709 * Sets up the container columns.
6695 * Parameters: 6710 * Parameters:
6700 * separator: The column number that contains the main separator. 6715 * separator: The column number that contains the main separator.
6701 * (this item may only be used in OS/2) 6716 * (this item may only be used in OS/2)
6702 */ 6717 */
6703 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) 6718 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator)
6704 { 6719 {
6705 PFIELDINFO details, first, left = NULL; 6720 PFIELDINFO details, first, left = NULL;
6706 FIELDINFOINSERT detin; 6721 FIELDINFOINSERT detin;
6707 CNRINFO cnri; 6722 CNRINFO cnri;
6708 int z; 6723 int z;
6709 ULONG size = sizeof(RECORDCORE); 6724 ULONG size = sizeof(RECORDCORE);
6710 ULONG *offStruct = malloc(count * sizeof(ULONG)); 6725 ULONG *offStruct = malloc(count * sizeof(ULONG));
6711 ULONG *tempflags = malloc((count+1) * sizeof(ULONG)); 6726 ULONG *tempflags = malloc((count+1) * sizeof(ULONG));
6712 WindowData *blah = (WindowData *)WinQueryWindowPtr(handle, QWP_USER); 6727 WindowData *blah = (WindowData *)WinQueryWindowPtr(handle, QWP_USER);
6713 ULONG *oldflags = blah ? blah->data : 0; 6728 ULONG *oldflags = blah ? blah->data : 0;
6714 6729
6715 if(!offStruct || !tempflags) 6730 if(!offStruct || !tempflags)
6716 return FALSE; 6731 return FALSE;
6717 6732
6718 memcpy(tempflags, flags, count * sizeof(ULONG)); 6733 memcpy(tempflags, flags, count * sizeof(ULONG));
6719 tempflags[count] = 0; 6734 tempflags[count] = 0;
6720 6735
6721 blah->data = tempflags; 6736 blah->data = tempflags;
6722 blah->flags = separator; 6737 blah->flags = separator;
6723 6738
6724 if(oldflags) 6739 if(oldflags)
6725 free(oldflags); 6740 free(oldflags);
6726 6741
6727 while((first = (PFIELDINFO)WinSendMsg(handle, CM_QUERYDETAILFIELDINFO, 0, MPFROMSHORT(CMA_FIRST))) != NULL) 6742 while((first = (PFIELDINFO)WinSendMsg(handle, CM_QUERYDETAILFIELDINFO, 0, MPFROMSHORT(CMA_FIRST))) != NULL)
6728 { 6743 {
6729 WinSendMsg(handle, CM_REMOVEDETAILFIELDINFO, (MPARAM)&first, MPFROM2SHORT(1, CMA_FREE)); 6744 WinSendMsg(handle, CM_REMOVEDETAILFIELDINFO, (MPARAM)&first, MPFROM2SHORT(1, CMA_FREE));
6730 } 6745 }
6731 6746
6732 /* Figure out the offsets to the items in the struct */ 6747 /* Figure out the offsets to the items in the struct */
6733 for(z=0;z<count;z++) 6748 for(z=0;z<count;z++)
6734 { 6749 {
6735 offStruct[z] = size; 6750 offStruct[z] = size;
6736 if(flags[z] & DW_CFA_BITMAPORICON) 6751 if(flags[z] & DW_CFA_BITMAPORICON)
6737 size += sizeof(HPOINTER); 6752 size += sizeof(HPOINTER);
6738 else if(flags[z] & DW_CFA_STRING) 6753 else if(flags[z] & DW_CFA_STRING)
6739 size += sizeof(char *); 6754 size += sizeof(char *);
6740 else if(flags[z] & DW_CFA_ULONG) 6755 else if(flags[z] & DW_CFA_ULONG)
6741 size += sizeof(ULONG); 6756 size += sizeof(ULONG);
6742 else if(flags[z] & DW_CFA_DATE) 6757 else if(flags[z] & DW_CFA_DATE)
6743 size += sizeof(CDATE); 6758 size += sizeof(CDATE);
6744 else if(flags[z] & DW_CFA_TIME) 6759 else if(flags[z] & DW_CFA_TIME)
6745 size += sizeof(CTIME); 6760 size += sizeof(CTIME);
6746 } 6761 }
6747 6762
6748 first = details = (PFIELDINFO)WinSendMsg(handle, CM_ALLOCDETAILFIELDINFO, MPFROMLONG(count), 0L); 6763 first = details = (PFIELDINFO)WinSendMsg(handle, CM_ALLOCDETAILFIELDINFO, MPFROMLONG(count), 0L);
6749 6764
6750 if(!first) 6765 if(!first)
6751 { 6766 {
6752 free(offStruct); 6767 free(offStruct);
6753 return FALSE; 6768 return FALSE;
6754 } 6769 }
6755 6770
6756 for(z=0;z<count;z++) 6771 for(z=0;z<count;z++)
6757 { 6772 {
6758 if(z==separator-1) 6773 if(z==separator-1)
6759 left=details; 6774 left=details;
6760 details->cb = sizeof(FIELDINFO); 6775 details->cb = sizeof(FIELDINFO);
6761 details->flData = flags[z]; 6776 details->flData = flags[z];
6762 details->flTitle = CFA_FITITLEREADONLY; 6777 details->flTitle = CFA_FITITLEREADONLY;
6763 details->pTitleData = titles[z]; 6778 details->pTitleData = titles[z];
6764 details->offStruct = offStruct[z]; 6779 details->offStruct = offStruct[z];
6765 details = details->pNextFieldInfo; 6780 details = details->pNextFieldInfo;
6766 } 6781 }
6767 6782
6768 detin.cb = sizeof(FIELDINFOINSERT); 6783 detin.cb = sizeof(FIELDINFOINSERT);
6769 detin.fInvalidateFieldInfo = FALSE; 6784 detin.fInvalidateFieldInfo = FALSE;
6770 detin.pFieldInfoOrder = (PFIELDINFO) CMA_FIRST; 6785 detin.pFieldInfoOrder = (PFIELDINFO) CMA_FIRST;
6771 detin.cFieldInfoInsert = (ULONG)count; 6786 detin.cFieldInfoInsert = (ULONG)count;
6772 6787
6773 WinSendMsg(handle, CM_INSERTDETAILFIELDINFO, MPFROMP(first), MPFROMP(&detin)); 6788 WinSendMsg(handle, CM_INSERTDETAILFIELDINFO, MPFROMP(first), MPFROMP(&detin));
6774 6789
6775 if(count > separator && separator > 0) 6790 if(count > separator && separator > 0)
6776 { 6791 {
6777 cnri.cb = sizeof(CNRINFO); 6792 cnri.cb = sizeof(CNRINFO);
6778 cnri.pFieldInfoLast = left; 6793 cnri.pFieldInfoLast = left;
6779 cnri.xVertSplitbar = 150; 6794 cnri.xVertSplitbar = 150;
6780 6795
6781 WinSendMsg(handle, CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_PFIELDINFOLAST | CMA_XVERTSPLITBAR)); 6796 WinSendMsg(handle, CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_PFIELDINFOLAST | CMA_XVERTSPLITBAR));
6782 } 6797 }
6783 6798
6784 cnri.flWindowAttr = CV_DETAIL | CV_MINI | CA_DETAILSVIEWTITLES; 6799 cnri.flWindowAttr = CV_DETAIL | CV_MINI | CA_DETAILSVIEWTITLES;
6785 cnri.slBitmapOrIcon.cx = 16; 6800 cnri.slBitmapOrIcon.cx = 16;
6786 cnri.slBitmapOrIcon.cy = 16; 6801 cnri.slBitmapOrIcon.cy = 16;
6787 6802
6788 WinSendMsg(handle, CM_SETCNRINFO, &cnri, MPFROMLONG(CMA_FLWINDOWATTR | CMA_SLBITMAPORICON)); 6803 WinSendMsg(handle, CM_SETCNRINFO, &cnri, MPFROMLONG(CMA_FLWINDOWATTR | CMA_SLBITMAPORICON));
6789 6804
6790 free(offStruct); 6805 free(offStruct);
6791 return TRUE; 6806 return TRUE;
6792 } 6807 }
6793 6808
6794 /* 6809 /*
6795 * Sets up the filesystem columns, note: filesystem always has an icon/filename field. 6810 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
6796 * Parameters: 6811 * Parameters:
6799 * titles: An array of strings with column text titles. 6814 * titles: An array of strings with column text titles.
6800 * count: The number of columns (this should match the arrays). 6815 * count: The number of columns (this should match the arrays).
6801 */ 6816 */
6802 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) 6817 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
6803 { 6818 {
6804 char **newtitles = malloc(sizeof(char *) * (count + 2)); 6819 char **newtitles = malloc(sizeof(char *) * (count + 2));
6805 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); 6820 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2));
6806 6821
6807 newtitles[0] = "Icon"; 6822 newtitles[0] = "Icon";
6808 newtitles[1] = "Filename"; 6823 newtitles[1] = "Filename";
6809 6824
6810 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR; 6825 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR;
6811 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; 6826 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR;
6812 6827
6813 memcpy(&newtitles[2], titles, sizeof(char *) * count); 6828 memcpy(&newtitles[2], titles, sizeof(char *) * count);
6814 memcpy(&newflags[2], flags, sizeof(unsigned long) * count); 6829 memcpy(&newflags[2], flags, sizeof(unsigned long) * count);
6815 6830
6816 dw_container_setup(handle, newflags, newtitles, count + 2, count ? 2 : 0); 6831 dw_container_setup(handle, newflags, newtitles, count + 2, count ? 2 : 0);
6817 6832
6818 free(newtitles); 6833 free(newtitles);
6819 free(newflags); 6834 free(newflags);
6820 return TRUE; 6835 return TRUE;
6821 } 6836 }
6822 6837
6823 /* 6838 /*
6824 * Obtains an icon from a module (or header in GTK). 6839 * Obtains an icon from a module (or header in GTK).
6825 * Parameters: 6840 * Parameters:
6828 * Windows, on GTK this is converted to a pointer 6843 * Windows, on GTK this is converted to a pointer
6829 * to an embedded XPM. 6844 * to an embedded XPM.
6830 */ 6845 */
6831 unsigned long API dw_icon_load(unsigned long module, unsigned long id) 6846 unsigned long API dw_icon_load(unsigned long module, unsigned long id)
6832 { 6847 {
6833 return WinLoadPointer(HWND_DESKTOP,module,id); 6848 return WinLoadPointer(HWND_DESKTOP,module,id);
6834 } 6849 }
6835 6850
6836 /* 6851 /*
6837 * Obtains an icon from a file. 6852 * Obtains an icon from a file.
6838 * Parameters: 6853 * Parameters:
6911 * handle: Handle to the container window (widget). 6926 * handle: Handle to the container window (widget).
6912 * rowcount: The number of items to be populated. 6927 * rowcount: The number of items to be populated.
6913 */ 6928 */
6914 void * API dw_container_alloc(HWND handle, int rowcount) 6929 void * API dw_container_alloc(HWND handle, int rowcount)
6915 { 6930 {
6916 WindowData *wd = (WindowData *)WinQueryWindowPtr(handle, QWP_USER); 6931 WindowData *wd = (WindowData *)WinQueryWindowPtr(handle, QWP_USER);
6917 ULONG *flags = wd ? wd->data : 0; 6932 ULONG *flags = wd ? wd->data : 0;
6918 int z, size = 0, totalsize, count = 0; 6933 int z, size = 0, totalsize, count = 0;
6919 PRECORDCORE temp; 6934 PRECORDCORE temp;
6920 ContainerInfo *ci; 6935 ContainerInfo *ci;
6921 void *blah = NULL; 6936 void *blah = NULL;
6922 6937
6923 if(!flags || rowcount < 1) 6938 if(!flags || rowcount < 1)
6924 return NULL; 6939 return NULL;
6925 6940
6926 while(flags[count]) 6941 while(flags[count])
6927 count++; 6942 count++;
6928 6943
6929 /* Figure out the offsets to the items in the struct */ 6944 /* Figure out the offsets to the items in the struct */
6930 for(z=0;z<count;z++) 6945 for(z=0;z<count;z++)
6931 { 6946 {
6932 if(flags[z] & DW_CFA_BITMAPORICON) 6947 if(flags[z] & DW_CFA_BITMAPORICON)
6933 size += sizeof(HPOINTER); 6948 size += sizeof(HPOINTER);
6934 else if(flags[z] & DW_CFA_STRING) 6949 else if(flags[z] & DW_CFA_STRING)
6935 size += sizeof(char *); 6950 size += sizeof(char *);
6936 else if(flags[z] & DW_CFA_ULONG) 6951 else if(flags[z] & DW_CFA_ULONG)
6937 size += sizeof(ULONG); 6952 size += sizeof(ULONG);
6938 else if(flags[z] & DW_CFA_DATE) 6953 else if(flags[z] & DW_CFA_DATE)
6939 size += sizeof(CDATE); 6954 size += sizeof(CDATE);
6940 else if(flags[z] & DW_CFA_TIME) 6955 else if(flags[z] & DW_CFA_TIME)
6941 size += sizeof(CTIME); 6956 size += sizeof(CTIME);
6942 } 6957 }
6943 6958
6944 totalsize = size + sizeof(RECORDCORE); 6959 totalsize = size + sizeof(RECORDCORE);
6945 6960
6946 z = 0; 6961 z = 0;
6947 6962
6948 if(!(blah = (void *)_dw_send_msg(handle, CM_ALLOCRECORD, MPFROMLONG(size), MPFROMLONG(rowcount), 0))) 6963 if(!(blah = (void *)_dw_send_msg(handle, CM_ALLOCRECORD, MPFROMLONG(size), MPFROMLONG(rowcount), 0)))
6949 return NULL; 6964 return NULL;
6950 6965
6951 temp = (PRECORDCORE)blah; 6966 temp = (PRECORDCORE)blah;
6952 6967
6953 for(z=0;z<rowcount;z++) 6968 for(z=0;z<rowcount;z++)
6954 { 6969 {
6955 temp->cb = totalsize; 6970 temp->cb = totalsize;
6956 temp = temp->preccNextRecord; 6971 temp = temp->preccNextRecord;
6957 } 6972 }
6958 6973
6959 ci = malloc(sizeof(struct _containerinfo)); 6974 ci = malloc(sizeof(struct _containerinfo));
6960 6975
6961 ci->count = rowcount; 6976 ci->count = rowcount;
6962 ci->data = blah; 6977 ci->data = blah;
6963 ci->handle = handle; 6978 ci->handle = handle;
6964 6979
6965 return (void *)ci; 6980 return (void *)ci;
6966 } 6981 }
6967 6982
6968 /* Internal function that does the work for set_item and change_item */ 6983 /* Internal function that does the work for set_item and change_item */
6969 void _dw_container_set_item(HWND handle, PRECORDCORE temp, int column, int row, void *data) 6984 void _dw_container_set_item(HWND handle, PRECORDCORE temp, int column, int row, void *data)
6970 { 6985 {
6971 WindowData *blah = (WindowData *)WinQueryWindowPtr(handle, QWP_USER); 6986 WindowData *blah = (WindowData *)WinQueryWindowPtr(handle, QWP_USER);
6972 ULONG totalsize, size = 0, *flags = blah ? blah->data : 0; 6987 ULONG totalsize, size = 0, *flags = blah ? blah->data : 0;
6973 int z, currentcount; 6988 int z, currentcount;
6974 CNRINFO cnr; 6989 CNRINFO cnr;
6975 void *dest; 6990 void *dest;
6976 6991
6977 if(!flags) 6992 if(!flags)
6978 return; 6993 return;
6979 6994
6980 if(!_dw_send_msg(handle, CM_QUERYCNRINFO, (MPARAM)&cnr, MPFROMSHORT(sizeof(CNRINFO)), 0)) 6995 if(!_dw_send_msg(handle, CM_QUERYCNRINFO, (MPARAM)&cnr, MPFROMSHORT(sizeof(CNRINFO)), 0))
6981 return; 6996 return;
6982 6997
6983 currentcount = cnr.cRecords; 6998 currentcount = cnr.cRecords;
6984 6999
6985 /* Figure out the offsets to the items in the struct */ 7000 /* Figure out the offsets to the items in the struct */
6986 for(z=0;z<column;z++) 7001 for(z=0;z<column;z++)
6987 { 7002 {
6988 if(flags[z] & DW_CFA_BITMAPORICON) 7003 if(flags[z] & DW_CFA_BITMAPORICON)
6989 size += sizeof(HPOINTER); 7004 size += sizeof(HPOINTER);
6990 else if(flags[z] & DW_CFA_STRING) 7005 else if(flags[z] & DW_CFA_STRING)
6991 size += sizeof(char *); 7006 size += sizeof(char *);
6992 else if(flags[z] & DW_CFA_ULONG) 7007 else if(flags[z] & DW_CFA_ULONG)
6993 size += sizeof(ULONG); 7008 size += sizeof(ULONG);
6994 else if(flags[z] & DW_CFA_DATE) 7009 else if(flags[z] & DW_CFA_DATE)
6995 size += sizeof(CDATE); 7010 size += sizeof(CDATE);
6996 else if(flags[z] & DW_CFA_TIME) 7011 else if(flags[z] & DW_CFA_TIME)
6997 size += sizeof(CTIME); 7012 size += sizeof(CTIME);
6998 } 7013 }
6999 7014
7000 totalsize = size + sizeof(RECORDCORE); 7015 totalsize = size + sizeof(RECORDCORE);
7001 7016
7002 for(z=0;z<(row-currentcount);z++) 7017 for(z=0;z<(row-currentcount);z++)
7003 temp = temp->preccNextRecord; 7018 temp = temp->preccNextRecord;
7004 7019
7005 dest = (void *)(((ULONG)temp)+((ULONG)totalsize)); 7020 dest = (void *)(((ULONG)temp)+((ULONG)totalsize));
7006 7021
7007 if(flags[column] & DW_CFA_BITMAPORICON) 7022 if(flags[column] & DW_CFA_BITMAPORICON)
7008 memcpy(dest, data, sizeof(HPOINTER)); 7023 memcpy(dest, data, sizeof(HPOINTER));
7009 else if(flags[column] & DW_CFA_STRING) 7024 else if(flags[column] & DW_CFA_STRING)
7010 { 7025 {
7011 char **newstr = (char **)data, **str = dest; 7026 char **newstr = (char **)data, **str = dest;
7012 7027
7013 if(*str) 7028 if(*str)
7014 free(*str); 7029 free(*str);
7015 7030
7016 if(newstr && *newstr) 7031 if(newstr && *newstr)
7017 *str = strdup(*newstr); 7032 *str = strdup(*newstr);
7018 else 7033 else
7019 *str = NULL; 7034 *str = NULL;
7020 } 7035 }
7021 else if(flags[column] & DW_CFA_ULONG) 7036 else if(flags[column] & DW_CFA_ULONG)
7022 memcpy(dest, data, sizeof(ULONG)); 7037 memcpy(dest, data, sizeof(ULONG));
7023 else if(flags[column] & DW_CFA_DATE) 7038 else if(flags[column] & DW_CFA_DATE)
7024 memcpy(dest, data, sizeof(CDATE)); 7039 memcpy(dest, data, sizeof(CDATE));
7025 else if(flags[column] & DW_CFA_TIME) 7040 else if(flags[column] & DW_CFA_TIME)
7026 memcpy(dest, data, sizeof(CTIME)); 7041 memcpy(dest, data, sizeof(CTIME));
7027 } 7042 }
7028 7043
7029 /* Internal function that free()s any strings allocated for a container item */ 7044 /* Internal function that free()s any strings allocated for a container item */
7030 void _dw_container_free_strings(HWND handle, PRECORDCORE temp) 7045 void _dw_container_free_strings(HWND handle, PRECORDCORE temp)
7031 { 7046 {
7032 WindowData *blah = (WindowData *)WinQueryWindowPtr(handle, QWP_USER); 7047 WindowData *blah = (WindowData *)WinQueryWindowPtr(handle, QWP_USER);
7033 ULONG totalsize, size = 0, *flags = blah ? blah->data : 0; 7048 ULONG totalsize, size = 0, *flags = blah ? blah->data : 0;
7034 int z, count = 0; 7049 int z, count = 0;
7035 7050
7036 if(!flags) 7051 if(!flags)
7037 return; 7052 return;
7038 7053
7039 while(flags[count]) 7054 while(flags[count])
7040 count++; 7055 count++;
7041 7056
7042 /* Figure out the offsets to the items in the struct */ 7057 /* Figure out the offsets to the items in the struct */
7043 for(z=0;z<count;z++) 7058 for(z=0;z<count;z++)
7044 { 7059 {
7045 if(flags[z] & DW_CFA_BITMAPORICON) 7060 if(flags[z] & DW_CFA_BITMAPORICON)
7046 size += sizeof(HPOINTER); 7061 size += sizeof(HPOINTER);
7047 else if(flags[z] & DW_CFA_STRING) 7062 else if(flags[z] & DW_CFA_STRING)
7048 { 7063 {
7049 char **str; 7064 char **str;
7050 7065
7051 totalsize = size + sizeof(RECORDCORE); 7066 totalsize = size + sizeof(RECORDCORE);
7052 7067
7053 str = (char **)(((ULONG)temp)+((ULONG)totalsize)); 7068 str = (char **)(((ULONG)temp)+((ULONG)totalsize));
7054 7069
7055 if(*str) 7070 if(*str)
7056 { 7071 {
7057 free(*str); 7072 free(*str);
7058 *str = NULL; 7073 *str = NULL;
7059 } 7074 }
7060 size += sizeof(char *); 7075 size += sizeof(char *);
7061 } 7076 }
7062 else if(flags[z] & DW_CFA_ULONG) 7077 else if(flags[z] & DW_CFA_ULONG)
7063 size += sizeof(ULONG); 7078 size += sizeof(ULONG);
7064 else if(flags[z] & DW_CFA_DATE) 7079 else if(flags[z] & DW_CFA_DATE)
7065 size += sizeof(CDATE); 7080 size += sizeof(CDATE);
7066 else if(flags[z] & DW_CFA_TIME) 7081 else if(flags[z] & DW_CFA_TIME)
7067 size += sizeof(CTIME); 7082 size += sizeof(CTIME);
7068 } 7083 }
7069 } 7084 }
7070 7085
7071 /* 7086 /*
7072 * Sets an item in specified row and column to the given data. 7087 * Sets an item in specified row and column to the given data.
7073 * Parameters: 7088 * Parameters:
7077 * row: Zero based row of data being set. 7092 * row: Zero based row of data being set.
7078 * data: Pointer to the data to be added. 7093 * data: Pointer to the data to be added.
7079 */ 7094 */
7080 void API dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) 7095 void API dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data)
7081 { 7096 {
7082 ContainerInfo *ci = (ContainerInfo *)pointer; 7097 ContainerInfo *ci = (ContainerInfo *)pointer;
7083 7098
7084 if(!ci) 7099 if(!ci)
7085 return; 7100 return;
7086 7101
7087 _dw_container_set_item(handle, (PRECORDCORE)ci->data, column, row, data); 7102 _dw_container_set_item(handle, (PRECORDCORE)ci->data, column, row, data);
7088 } 7103 }
7089 7104
7090 /* 7105 /*
7091 * Changes an existing item in specified row and column to the given data. 7106 * Changes an existing item in specified row and column to the given data.
7092 * Parameters: 7107 * Parameters:
7095 * row: Zero based row of data being set. 7110 * row: Zero based row of data being set.
7096 * data: Pointer to the data to be added. 7111 * data: Pointer to the data to be added.
7097 */ 7112 */
7098 void API dw_container_change_item(HWND handle, int column, int row, void *data) 7113 void API dw_container_change_item(HWND handle, int column, int row, void *data)
7099 { 7114 {
7100 PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 7115 PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
7101 int count = 0; 7116 int count = 0;
7102 7117
7103 while(pCore) 7118 while(pCore)
7104 { 7119 {
7105 if(count == row) 7120 if(count == row)
7106 { 7121 {
7107 _dw_container_set_item(handle, pCore, column, 0, data); 7122 _dw_container_set_item(handle, pCore, column, 0, data);
7108 WinSendMsg(handle, CM_INVALIDATERECORD, (MPARAM)&pCore, MPFROM2SHORT(1, CMA_NOREPOSITION | CMA_TEXTCHANGED)); 7123 WinSendMsg(handle, CM_INVALIDATERECORD, (MPARAM)&pCore, MPFROM2SHORT(1, CMA_NOREPOSITION | CMA_TEXTCHANGED));
7109 return; 7124 return;
7110 } 7125 }
7111 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 7126 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
7112 count++; 7127 count++;
7113 } 7128 }
7114 } 7129 }
7115 7130
7116 /* 7131 /*
7117 * Changes an existing item in specified row and column to the given data. 7132 * Changes an existing item in specified row and column to the given data.
7118 * Parameters: 7133 * Parameters:
7121 * row: Zero based row of data being set. 7136 * row: Zero based row of data being set.
7122 * data: Pointer to the data to be added. 7137 * data: Pointer to the data to be added.
7123 */ 7138 */
7124 void API dw_filesystem_change_item(HWND handle, int column, int row, void *data) 7139 void API dw_filesystem_change_item(HWND handle, int column, int row, void *data)
7125 { 7140 {
7126 dw_container_change_item(handle, column + 2, row, data); 7141 dw_container_change_item(handle, column + 2, row, data);
7127 } 7142 }
7128 7143
7129 /* 7144 /*
7130 * Changes an item in specified row and column to the given data. 7145 * Changes an item in specified row and column to the given data.
7131 * Parameters: 7146 * Parameters:
7135 * row: Zero based row of data being set. 7150 * row: Zero based row of data being set.
7136 * data: Pointer to the data to be added. 7151 * data: Pointer to the data to be added.
7137 */ 7152 */
7138 void API dw_filesystem_change_file(HWND handle, int row, char *filename, unsigned long icon) 7153 void API dw_filesystem_change_file(HWND handle, int row, char *filename, unsigned long icon)
7139 { 7154 {
7140 dw_container_change_item(handle, 0, row, (void *)&icon); 7155 dw_container_change_item(handle, 0, row, (void *)&icon);
7141 dw_container_change_item(handle, 1, row, (void *)&filename); 7156 dw_container_change_item(handle, 1, row, (void *)&filename);
7142 } 7157 }
7143 7158
7144 /* 7159 /*
7145 * Sets an item in specified row and column to the given data. 7160 * Sets an item in specified row and column to the given data.
7146 * Parameters: 7161 * Parameters:
7150 * row: Zero based row of data being set. 7165 * row: Zero based row of data being set.
7151 * data: Pointer to the data to be added. 7166 * data: Pointer to the data to be added.
7152 */ 7167 */
7153 void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) 7168 void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon)
7154 { 7169 {
7155 dw_container_set_item(handle, pointer, 0, row, (void *)&icon); 7170 dw_container_set_item(handle, pointer, 0, row, (void *)&icon);
7156 dw_container_set_item(handle, pointer, 1, row, (void *)&filename); 7171 dw_container_set_item(handle, pointer, 1, row, (void *)&filename);
7157 } 7172 }
7158 7173
7159 /* 7174 /*
7160 * Sets an item in specified row and column to the given data. 7175 * Sets an item in specified row and column to the given data.
7161 * Parameters: 7176 * Parameters:
7165 * row: Zero based row of data being set. 7180 * row: Zero based row of data being set.
7166 * data: Pointer to the data to be added. 7181 * data: Pointer to the data to be added.
7167 */ 7182 */
7168 void API dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) 7183 void API dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data)
7169 { 7184 {
7170 dw_container_set_item(handle, pointer, column + 2, row, data); 7185 dw_container_set_item(handle, pointer, column + 2, row, data);
7171 } 7186 }
7172 7187
7173 /* 7188 /*
7174 * Gets column type for a container column 7189 * Gets column type for a container column
7175 * Parameters: 7190 * Parameters:
7176 * handle: Handle to the container window (widget). 7191 * handle: Handle to the container window (widget).
7177 * column: Zero based column. 7192 * column: Zero based column.
7178 */ 7193 */
7179 int API dw_container_get_column_type(HWND handle, int column) 7194 int API dw_container_get_column_type(HWND handle, int column)
7180 { 7195 {
7181 WindowData *blah = (WindowData *)WinQueryWindowPtr(handle, QWP_USER); 7196 WindowData *blah = (WindowData *)WinQueryWindowPtr(handle, QWP_USER);
7182 ULONG *flags = blah ? blah->data : 0; 7197 ULONG *flags = blah ? blah->data : 0;
7183 int rc; 7198 int rc;
7184 7199
7185 if(!flags) 7200 if(!flags)
7186 return 0; 7201 return 0;
7187 7202
7188 if(flags[column] & DW_CFA_BITMAPORICON) 7203 if(flags[column] & DW_CFA_BITMAPORICON)
7189 rc = DW_CFA_BITMAPORICON; 7204 rc = DW_CFA_BITMAPORICON;
7190 else if(flags[column] & DW_CFA_STRING) 7205 else if(flags[column] & DW_CFA_STRING)
7191 rc = DW_CFA_STRING; 7206 rc = DW_CFA_STRING;
7192 else if(flags[column] & DW_CFA_ULONG) 7207 else if(flags[column] & DW_CFA_ULONG)
7193 rc = DW_CFA_ULONG; 7208 rc = DW_CFA_ULONG;
7194 else if(flags[column] & DW_CFA_DATE) 7209 else if(flags[column] & DW_CFA_DATE)
7195 rc = DW_CFA_DATE; 7210 rc = DW_CFA_DATE;
7196 else if(flags[column] & DW_CFA_TIME) 7211 else if(flags[column] & DW_CFA_TIME)
7197 rc = DW_CFA_TIME; 7212 rc = DW_CFA_TIME;
7198 else 7213 else
7199 rc = 0; 7214 rc = 0;
7200 return rc; 7215 return rc;
7201 } 7216 }
7202 7217
7203 /* 7218 /*
7204 * Gets column type for a filesystem container column 7219 * Gets column type for a filesystem container column
7205 * Parameters: 7220 * Parameters:
7206 * handle: Handle to the container window (widget). 7221 * handle: Handle to the container window (widget).
7207 * column: Zero based column. 7222 * column: Zero based column.
7208 */ 7223 */
7209 int API dw_filesystem_get_column_type(HWND handle, int column) 7224 int API dw_filesystem_get_column_type(HWND handle, int column)
7210 { 7225 {
7211 return dw_container_get_column_type( handle, column + 2 ); 7226 return dw_container_get_column_type( handle, column + 2 );
7212 } 7227 }
7213 7228
7214 /* 7229 /*
7215 * Sets the width of a column in the container. 7230 * Sets the width of a column in the container.
7216 * Parameters: 7231 * Parameters:
7218 * column: Zero based column of width being set. 7233 * column: Zero based column of width being set.
7219 * width: Width of column in pixels. 7234 * width: Width of column in pixels.
7220 */ 7235 */
7221 void API dw_container_set_column_width(HWND handle, int column, int width) 7236 void API dw_container_set_column_width(HWND handle, int column, int width)
7222 { 7237 {
7223 handle = handle; /* keep compiler happy */ 7238 handle = handle; /* keep compiler happy */
7224 column = column; /* keep compiler happy */ 7239 column = column; /* keep compiler happy */
7225 width = width; /* keep compiler happy */ 7240 width = width; /* keep compiler happy */
7226 } 7241 }
7227 7242
7228 /* 7243 /*
7229 * Sets the title of a row in the container. 7244 * Sets the title of a row in the container.
7230 * Parameters: 7245 * Parameters:
7232 * row: Zero based row of data being set. 7247 * row: Zero based row of data being set.
7233 * title: String title of the item. 7248 * title: String title of the item.
7234 */ 7249 */
7235 void API dw_container_set_row_title(void *pointer, int row, char *title) 7250 void API dw_container_set_row_title(void *pointer, int row, char *title)
7236 { 7251 {
7237 ContainerInfo *ci = (ContainerInfo *)pointer; 7252 ContainerInfo *ci = (ContainerInfo *)pointer;
7238 PRECORDCORE temp; 7253 PRECORDCORE temp;
7239 int z, currentcount; 7254 int z, currentcount;
7240 CNRINFO cnr; 7255 CNRINFO cnr;
7241 7256
7242 if(!ci) 7257 if(!ci)
7243 return; 7258 return;
7244 7259
7245 temp = (PRECORDCORE)ci->data; 7260 temp = (PRECORDCORE)ci->data;
7246 7261
7247 z = 0; 7262 z = 0;
7248 7263
7249 if(!_dw_send_msg(ci->handle, CM_QUERYCNRINFO, (MPARAM)&cnr, MPFROMSHORT(sizeof(CNRINFO)), 0)) 7264 if(!_dw_send_msg(ci->handle, CM_QUERYCNRINFO, (MPARAM)&cnr, MPFROMSHORT(sizeof(CNRINFO)), 0))
7250 return; 7265 return;
7251 7266
7252 currentcount = cnr.cRecords; 7267 currentcount = cnr.cRecords;
7253 7268
7254 for(z=0;z<(row-currentcount);z++) 7269 for(z=0;z<(row-currentcount);z++)
7255 temp = temp->preccNextRecord; 7270 temp = temp->preccNextRecord;
7256 7271
7257 temp->pszIcon = title; 7272 temp->pszIcon = title;
7258 temp->pszName = title; 7273 temp->pszName = title;
7259 temp->pszText = title; 7274 temp->pszText = title;
7260 } 7275 }
7261 7276
7262 /* 7277 /*
7263 * Sets the title of a row in the container. 7278 * Sets the title of a row in the container.
7264 * Parameters: 7279 * Parameters:
7266 * pointer: Pointer to the allocated memory in dw_container_alloc(). 7281 * pointer: Pointer to the allocated memory in dw_container_alloc().
7267 * rowcount: The number of rows to be inserted. 7282 * rowcount: The number of rows to be inserted.
7268 */ 7283 */
7269 void API dw_container_insert(HWND handle, void *pointer, int rowcount) 7284 void API dw_container_insert(HWND handle, void *pointer, int rowcount)
7270 { 7285 {
7271 RECORDINSERT recin; 7286 RECORDINSERT recin;
7272 ContainerInfo *ci = (ContainerInfo *)pointer; 7287 ContainerInfo *ci = (ContainerInfo *)pointer;
7273 7288
7274 if(!ci) 7289 if(!ci)
7275 return; 7290 return;
7276 7291
7277 recin.cb = sizeof(RECORDINSERT); 7292 recin.cb = sizeof(RECORDINSERT);
7278 recin.pRecordOrder = (PRECORDCORE)CMA_END; 7293 recin.pRecordOrder = (PRECORDCORE)CMA_END;
7279 recin.pRecordParent = NULL; 7294 recin.pRecordParent = NULL;
7280 recin.zOrder = CMA_TOP; 7295 recin.zOrder = CMA_TOP;
7281 recin.fInvalidateRecord = TRUE; 7296 recin.fInvalidateRecord = TRUE;
7282 recin.cRecordsInsert = rowcount; 7297 recin.cRecordsInsert = rowcount;
7283 7298
7284 _dw_send_msg(handle, CM_INSERTRECORD, MPFROMP(ci->data), MPFROMP(&recin), 0); 7299 _dw_send_msg(handle, CM_INSERTRECORD, MPFROMP(ci->data), MPFROMP(&recin), 0);
7285 7300
7286 free(ci); 7301 free(ci);
7287 } 7302 }
7288 7303
7289 /* 7304 /*
7290 * Removes all rows from a container. 7305 * Removes all rows from a container.
7291 * Parameters: 7306 * Parameters:
7292 * handle: Handle to the window (widget) to be cleared. 7307 * handle: Handle to the window (widget) to be cleared.
7293 * redraw: TRUE to cause the container to redraw immediately. 7308 * redraw: TRUE to cause the container to redraw immediately.
7294 */ 7309 */
7295 void API dw_container_clear(HWND handle, int redraw) 7310 void API dw_container_clear(HWND handle, int redraw)
7296 { 7311 {
7297 PCNRITEM pCore; 7312 PCNRITEM pCore;
7298 int container = (int)dw_window_get_data(handle, "_dw_container"); 7313 int container = (int)dw_window_get_data(handle, "_dw_container");
7299 7314
7300 if(hwndEmph == handle) 7315 if(hwndEmph == handle)
7301 _clear_emphasis(); 7316 _clear_emphasis();
7302 7317
7303 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 7318 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
7304 7319
7305 while(pCore) 7320 while(pCore)
7306 { 7321 {
7307 if(container) 7322 if(container)
7308 _dw_container_free_strings(handle, (PRECORDCORE)pCore); 7323 _dw_container_free_strings(handle, (PRECORDCORE)pCore);
7309 else 7324 else
7310 { 7325 {
7311 /* Free icon text */ 7326 /* Free icon text */
7312 if(pCore->rc.pszIcon) 7327 if(pCore->rc.pszIcon)
7313 { 7328 {
7314 free(pCore->rc.pszIcon); 7329 free(pCore->rc.pszIcon);
7315 pCore->rc.pszIcon = 0; 7330 pCore->rc.pszIcon = 0;
7316 } 7331 }
7317 } 7332 }
7318 pCore = (PCNRITEM)pCore->rc.preccNextRecord;/*WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));*/ 7333 pCore = (PCNRITEM)pCore->rc.preccNextRecord;/*WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));*/
7319 } 7334 }
7320 _dw_send_msg(handle, CM_REMOVERECORD, (MPARAM)0L, MPFROM2SHORT(0, (redraw ? CMA_INVALIDATE : 0) | CMA_FREE), -1); 7335 _dw_send_msg(handle, CM_REMOVERECORD, (MPARAM)0L, MPFROM2SHORT(0, (redraw ? CMA_INVALIDATE : 0) | CMA_FREE), -1);
7321 } 7336 }
7322 7337
7323 /* 7338 /*
7324 * Removes the first x rows from a container. 7339 * Removes the first x rows from a container.
7325 * Parameters: 7340 * Parameters:
7326 * handle: Handle to the window (widget) to be deleted from. 7341 * handle: Handle to the window (widget) to be deleted from.
7327 * rowcount: The number of rows to be deleted. 7342 * rowcount: The number of rows to be deleted.
7328 */ 7343 */
7329 void API dw_container_delete(HWND handle, int rowcount) 7344 void API dw_container_delete(HWND handle, int rowcount)
7330 { 7345 {
7331 RECORDCORE *last, **prc = malloc(sizeof(RECORDCORE *) * rowcount); 7346 RECORDCORE *last, **prc = malloc(sizeof(RECORDCORE *) * rowcount);
7332 int current = 1; 7347 int current = 1;
7333 7348
7334 prc[0] = last = (RECORDCORE *)WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 7349 prc[0] = last = (RECORDCORE *)WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
7335 7350
7336 while(last && current < rowcount) 7351 while(last && current < rowcount)
7337 { 7352 {
7338 _dw_container_free_strings(handle, last); 7353 _dw_container_free_strings(handle, last);
7339 prc[current] = last = (RECORDCORE *)WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)last, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 7354 prc[current] = last = (RECORDCORE *)WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)last, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
7340 current++; 7355 current++;
7341 } 7356 }
7342 7357
7343 _dw_send_msg(handle, CM_REMOVERECORD, (MPARAM)prc, MPFROM2SHORT(current, CMA_INVALIDATE | CMA_FREE), -1); 7358 _dw_send_msg(handle, CM_REMOVERECORD, (MPARAM)prc, MPFROM2SHORT(current, CMA_INVALIDATE | CMA_FREE), -1);
7344 7359
7345 free(prc); 7360 free(prc);
7346 } 7361 }
7347 7362
7348 /* 7363 /*
7349 * Scrolls container up or down. 7364 * Scrolls container up or down.
7350 * Parameters: 7365 * Parameters:
7353 * DW_SCROLL_BOTTOM. (rows is ignored for last two) 7368 * DW_SCROLL_BOTTOM. (rows is ignored for last two)
7354 * rows: The number of rows to be scrolled. 7369 * rows: The number of rows to be scrolled.
7355 */ 7370 */
7356 void API dw_container_scroll(HWND handle, int direction, long rows) 7371 void API dw_container_scroll(HWND handle, int direction, long rows)
7357 { 7372 {
7358 rows = rows; /* keep compiler happy */ 7373 rows = rows; /* keep compiler happy */
7359 switch(direction) 7374 switch(direction)
7360 { 7375 {
7361 case DW_SCROLL_TOP: 7376 case DW_SCROLL_TOP:
7362 WinSendMsg(handle, CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL), MPFROMLONG(-10000000)); 7377 WinSendMsg(handle, CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL), MPFROMLONG(-10000000));
7363 break; 7378 break;
7364 case DW_SCROLL_BOTTOM: 7379 case DW_SCROLL_BOTTOM:
7365 WinSendMsg(handle, CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL), MPFROMLONG(10000000)); 7380 WinSendMsg(handle, CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL), MPFROMLONG(10000000));
7366 break; 7381 break;
7367 } 7382 }
7368 } 7383 }
7369 7384
7370 /* 7385 /*
7371 * Starts a new query of a container. 7386 * Starts a new query of a container.
7372 * Parameters: 7387 * Parameters:
7375 * return items that are currently selected. Otherwise 7390 * return items that are currently selected. Otherwise
7376 * it will return all records in the container. 7391 * it will return all records in the container.
7377 */ 7392 */
7378 char * API dw_container_query_start(HWND handle, unsigned long flags) 7393 char * API dw_container_query_start(HWND handle, unsigned long flags)
7379 { 7394 {
7380 PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 7395 PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
7381 7396
7382 if(pCore) 7397 if(pCore)
7383 { 7398 {
7384 if(flags) 7399 if(flags)
7385 { 7400 {
7386 while(pCore) 7401 while(pCore)
7387 { 7402 {
7388 if(pCore->flRecordAttr & flags) 7403 if(pCore->flRecordAttr & flags)
7389 { 7404 {
7390 dw_window_set_data(handle, "_dw_pcore", (void *)pCore); 7405 dw_window_set_data(handle, "_dw_pcore", (void *)pCore);
7391 return pCore->pszIcon; 7406 return pCore->pszIcon;
7392 } 7407 }
7393 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 7408 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
7394 } 7409 }
7395 } 7410 }
7396 else 7411 else
7397 { 7412 {
7398 dw_window_set_data(handle, "_dw_pcore", (void *)pCore); 7413 dw_window_set_data(handle, "_dw_pcore", (void *)pCore);
7399 return pCore->pszIcon; 7414 return pCore->pszIcon;
7400 } 7415 }
7401 } 7416 }
7402 return NULL; 7417 return NULL;
7403 } 7418 }
7404 7419
7405 /* 7420 /*
7406 * Continues an existing query of a container. 7421 * Continues an existing query of a container.
7410 * return items that are currently selected. Otherwise 7425 * return items that are currently selected. Otherwise
7411 * it will return all records in the container. 7426 * it will return all records in the container.
7412 */ 7427 */
7413 char * API dw_container_query_next(HWND handle, unsigned long flags) 7428 char * API dw_container_query_next(HWND handle, unsigned long flags)
7414 { 7429 {
7415 PRECORDCORE pCore = (PRECORDCORE)dw_window_get_data(handle, "_dw_pcore"); 7430 PRECORDCORE pCore = (PRECORDCORE)dw_window_get_data(handle, "_dw_pcore");
7416 7431
7417 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 7432 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
7418 7433
7419 if(pCore) 7434 if(pCore)
7420 { 7435 {
7421 if(flags) 7436 if(flags)
7422 { 7437 {
7423 while(pCore) 7438 while(pCore)
7424 { 7439 {
7425 if(pCore->flRecordAttr & flags) 7440 if(pCore->flRecordAttr & flags)
7426 { 7441 {
7427 dw_window_set_data(handle, "_dw_pcore", (void *)pCore); 7442 dw_window_set_data(handle, "_dw_pcore", (void *)pCore);
7428 return pCore->pszIcon; 7443 return pCore->pszIcon;
7429 } 7444 }
7430 7445
7431 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 7446 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
7432 } 7447 }
7433 } 7448 }
7434 else 7449 else
7435 { 7450 {
7436 dw_window_set_data(handle, "_dw_pcore", (void *)pCore); 7451 dw_window_set_data(handle, "_dw_pcore", (void *)pCore);
7437 return pCore->pszIcon; 7452 return pCore->pszIcon;
7438 } 7453 }
7439 } 7454 }
7440 return NULL; 7455 return NULL;
7441 } 7456 }
7442 7457
7443 /* 7458 /*
7444 * Cursors the item with the text speficied, and scrolls to that item. 7459 * Cursors the item with the text speficied, and scrolls to that item.
7446 * handle: Handle to the window (widget) to be queried. 7461 * handle: Handle to the window (widget) to be queried.
7447 * text: Text usually returned by dw_container_query(). 7462 * text: Text usually returned by dw_container_query().
7448 */ 7463 */
7449 void API dw_container_cursor(HWND handle, char *text) 7464 void API dw_container_cursor(HWND handle, char *text)
7450 { 7465 {
7451 RECTL viewport, item; 7466 RECTL viewport, item;
7452 PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 7467 PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
7453 7468
7454 while(pCore) 7469 while(pCore)
7455 { 7470 {
7456 if((char *)pCore->pszIcon == text) 7471 if((char *)pCore->pszIcon == text)
7457 { 7472 {
7458 QUERYRECORDRECT qrr; 7473 QUERYRECORDRECT qrr;
7459 int scrollpixels = 0, midway; 7474 int scrollpixels = 0, midway;
7460 7475
7461 qrr.cb = sizeof(QUERYRECORDRECT); 7476 qrr.cb = sizeof(QUERYRECORDRECT);
7462 qrr.pRecord = pCore; 7477 qrr.pRecord = pCore;
7463 qrr.fRightSplitWindow = 0; 7478 qrr.fRightSplitWindow = 0;
7464 qrr.fsExtent = CMA_TEXT; 7479 qrr.fsExtent = CMA_TEXT;
7465 7480
7466 WinSendMsg(handle, CM_SETRECORDEMPHASIS, (MPARAM)pCore, MPFROM2SHORT(TRUE, CRA_CURSORED)); 7481 WinSendMsg(handle, CM_SETRECORDEMPHASIS, (MPARAM)pCore, MPFROM2SHORT(TRUE, CRA_CURSORED));
7467 WinSendMsg(handle, CM_QUERYVIEWPORTRECT, (MPARAM)&viewport, MPFROM2SHORT(CMA_WORKSPACE, FALSE)); 7482 WinSendMsg(handle, CM_QUERYVIEWPORTRECT, (MPARAM)&viewport, MPFROM2SHORT(CMA_WORKSPACE, FALSE));
7468 WinSendMsg(handle, CM_QUERYRECORDRECT, (MPARAM)&item, (MPARAM)&qrr); 7483 WinSendMsg(handle, CM_QUERYRECORDRECT, (MPARAM)&item, (MPARAM)&qrr);
7469 7484
7470 midway = (viewport.yTop - viewport.yBottom)/2; 7485 midway = (viewport.yTop - viewport.yBottom)/2;
7471 scrollpixels = viewport.yTop - (item.yTop + midway); 7486 scrollpixels = viewport.yTop - (item.yTop + midway);
7472 7487
7473 WinSendMsg(handle, CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL), MPFROMLONG(scrollpixels)); 7488 WinSendMsg(handle, CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL), MPFROMLONG(scrollpixels));
7474 return; 7489 return;
7475 } 7490 }
7476 7491
7477 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 7492 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
7478 } 7493 }
7479 } 7494 }
7480 7495
7481 /* 7496 /*
7482 * Deletes the item with the text speficied. 7497 * Deletes the item with the text speficied.
7483 * Parameters: 7498 * Parameters:
7484 * handle: Handle to the window (widget). 7499 * handle: Handle to the window (widget).
7485 * text: Text usually returned by dw_container_query(). 7500 * text: Text usually returned by dw_container_query().
7486 */ 7501 */
7487 void API dw_container_delete_row(HWND handle, char *text) 7502 void API dw_container_delete_row(HWND handle, char *text)
7488 { 7503 {
7489 PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 7504 PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
7490 7505
7491 while(pCore) 7506 while(pCore)
7492 { 7507 {
7493 if((char *)pCore->pszIcon == text) 7508 if((char *)pCore->pszIcon == text)
7494 { 7509 {
7495 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)&pCore, MPFROM2SHORT(1, CMA_FREE | CMA_INVALIDATE)); 7510 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)&pCore, MPFROM2SHORT(1, CMA_FREE | CMA_INVALIDATE));
7496 return; 7511 return;
7497 } 7512 }
7498 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 7513 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
7499 } 7514 }
7500 } 7515 }
7501 7516
7502 /* 7517 /*
7503 * Optimizes the column widths so that all data is visible. 7518 * Optimizes the column widths so that all data is visible.
7504 * Parameters: 7519 * Parameters:
7505 * handle: Handle to the window (widget) to be optimized. 7520 * handle: Handle to the window (widget) to be optimized.
7506 */ 7521 */
7507 void API dw_container_optimize(HWND handle) 7522 void API dw_container_optimize(HWND handle)
7508 { 7523 {
7509 WindowData *blah = (WindowData *)WinQueryWindowPtr(handle, QWP_USER); 7524 WindowData *blah = (WindowData *)WinQueryWindowPtr(handle, QWP_USER);
7510 RECTL item; 7525 RECTL item;
7511 PRECORDCORE pCore = NULL; 7526 PRECORDCORE pCore = NULL;
7512 int max = 0; 7527 int max = 0;
7513 7528
7514 if(blah && !blah->flags) 7529 if(blah && !blah->flags)
7515 return; 7530 return;
7516 7531
7517 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 7532 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
7518 while(pCore) 7533 while(pCore)
7519 { 7534 {
7520 QUERYRECORDRECT qrr; 7535 QUERYRECORDRECT qrr;
7521 int vector; 7536 int vector;
7522 7537
7523 qrr.cb = sizeof(QUERYRECORDRECT); 7538 qrr.cb = sizeof(QUERYRECORDRECT);
7524 qrr.pRecord = pCore; 7539 qrr.pRecord = pCore;
7525 qrr.fRightSplitWindow = 0; 7540 qrr.fRightSplitWindow = 0;
7526 qrr.fsExtent = CMA_TEXT; 7541 qrr.fsExtent = CMA_TEXT;
7527 7542
7528 WinSendMsg(handle, CM_QUERYRECORDRECT, (MPARAM)&item, (MPARAM)&qrr); 7543 WinSendMsg(handle, CM_QUERYRECORDRECT, (MPARAM)&item, (MPARAM)&qrr);
7529 7544
7530 vector = item.xRight - item.xLeft; 7545 vector = item.xRight - item.xLeft;
7531 7546
7532 if(vector > max) 7547 if(vector > max)
7533 max = vector; 7548 max = vector;
7534 7549
7535 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 7550 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
7536 } 7551 }
7537 7552
7538 if(max) 7553 if(max)
7539 { 7554 {
7540 CNRINFO cnri; 7555 CNRINFO cnri;
7541 7556
7542 cnri.cb = sizeof(CNRINFO); 7557 cnri.cb = sizeof(CNRINFO);
7543 cnri.xVertSplitbar = max; 7558 cnri.xVertSplitbar = max;
7544 7559
7545 WinSendMsg(handle, CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_XVERTSPLITBAR)); 7560 WinSendMsg(handle, CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_XVERTSPLITBAR));
7546 } 7561 }
7547 } 7562 }
7548 7563
7549 /* 7564 /*
7550 * Inserts an icon into the taskbar. 7565 * Inserts an icon into the taskbar.
7551 * Parameters: 7566 * Parameters:
7553 * icon: Icon handle to display in the taskbar. 7568 * icon: Icon handle to display in the taskbar.
7554 * bubbletext: Text to show when the mouse is above the icon. 7569 * bubbletext: Text to show when the mouse is above the icon.
7555 */ 7570 */
7556 void API dw_taskbar_insert(HWND handle, unsigned long icon, char *bubbletext) 7571 void API dw_taskbar_insert(HWND handle, unsigned long icon, char *bubbletext)
7557 { 7572 {
7558 handle = handle; 7573 handle = handle;
7559 icon = icon; 7574 icon = icon;
7560 bubbletext = bubbletext; 7575 bubbletext = bubbletext;
7561 /* TODO */ 7576 /* TODO */
7562 } 7577 }
7563 7578
7564 /* 7579 /*
7565 * Deletes an icon from the taskbar. 7580 * Deletes an icon from the taskbar.
7566 * Parameters: 7581 * Parameters:
7567 * handle: Window handle that was used with dw_taskbar_insert(). 7582 * handle: Window handle that was used with dw_taskbar_insert().
7568 * icon: Icon handle that was used with dw_taskbar_insert(). 7583 * icon: Icon handle that was used with dw_taskbar_insert().
7569 */ 7584 */
7570 void API dw_taskbar_delete(HWND handle, unsigned long icon) 7585 void API dw_taskbar_delete(HWND handle, unsigned long icon)
7571 { 7586 {
7572 handle = handle; 7587 handle = handle;
7573 icon = icon; 7588 icon = icon;
7574 /* TODO */ 7589 /* TODO */
7575 } 7590 }
7576 7591
7577 /* 7592 /*
7578 * Creates a rendering context widget (window) to be packed. 7593 * Creates a rendering context widget (window) to be packed.
7579 * Parameters: 7594 * Parameters:
7581 * Returns: 7596 * Returns:
7582 * A handle to the widget or NULL on failure. 7597 * A handle to the widget or NULL on failure.
7583 */ 7598 */
7584 HWND API dw_render_new(unsigned long id) 7599 HWND API dw_render_new(unsigned long id)
7585 { 7600 {
7586 HWND hwndframe = WinCreateWindow(HWND_OBJECT, 7601 HWND hwndframe = WinCreateWindow(HWND_OBJECT,
7587 WC_FRAME, 7602 WC_FRAME,
7588 NULL, 7603 NULL,
7589 WS_VISIBLE | 7604 WS_VISIBLE |
7590 FS_NOBYTEALIGN, 7605 FS_NOBYTEALIGN,
7591 0,0,2000,1000, 7606 0,0,2000,1000,
7592 NULLHANDLE, 7607 NULLHANDLE,
7593 HWND_TOP, 7608 HWND_TOP,
7594 id, 7609 id,
7595 NULL, 7610 NULL,
7596 NULL); 7611 NULL);
7597 WinSubclassWindow(hwndframe, _RendProc); 7612 WinSubclassWindow(hwndframe, _RendProc);
7598 return hwndframe; 7613 return hwndframe;
7599 } 7614 }
7600 7615
7601 /* Sets the current foreground drawing color. 7616 /* Sets the current foreground drawing color.
7602 * Parameters: 7617 * Parameters:
7603 * red: red value. 7618 * red: red value.
7604 * green: green value. 7619 * green: green value.
7605 * blue: blue value. 7620 * blue: blue value.
7606 */ 7621 */
7607 void API dw_color_foreground_set(unsigned long value) 7622 void API dw_color_foreground_set(unsigned long value)
7608 { 7623 {
7609 _foreground = value; 7624 _foreground = value;
7610 } 7625 }
7611 7626
7612 /* Sets the current background drawing color. 7627 /* Sets the current background drawing color.
7613 * Parameters: 7628 * Parameters:
7614 * red: red value. 7629 * red: red value.
7615 * green: green value. 7630 * green: green value.
7616 * blue: blue value. 7631 * blue: blue value.
7617 */ 7632 */
7618 void API dw_color_background_set(unsigned long value) 7633 void API dw_color_background_set(unsigned long value)
7619 { 7634 {
7620 _background = value; 7635 _background = value;
7621 } 7636 }
7622 7637
7623 int DWSIGNAL _dw_color_cancel_func(HWND window, void *data) 7638 int DWSIGNAL _dw_color_cancel_func(HWND window, void *data)
7624 { 7639 {
7625 DWDialog *dwwait = (DWDialog *)data; 7640 DWDialog *dwwait = (DWDialog *)data;
7626 HMTX mtx = (HMTX)dw_window_get_data((HWND)dwwait->data, "_dw_mutex"); 7641 HMTX mtx = (HMTX)dw_window_get_data((HWND)dwwait->data, "_dw_mutex");
7627 void *val; 7642 void *val;
7628 7643
7629 window = (HWND)dwwait->data; 7644 window = (HWND)dwwait->data;
7630 val = dw_window_get_data(window, "_dw_val"); 7645 val = dw_window_get_data(window, "_dw_val");
7631 7646
7632 dw_mutex_lock(mtx); 7647 dw_mutex_lock(mtx);
7633 dw_mutex_close(mtx); 7648 dw_mutex_close(mtx);
7634 dw_window_destroy(window); 7649 dw_window_destroy(window);
7635 dw_dialog_dismiss((DWDialog *)data, val); 7650 dw_dialog_dismiss((DWDialog *)data, val);
7636 return FALSE; 7651 return FALSE;
7637 } 7652 }
7638 7653
7639 int DWSIGNAL _dw_color_ok_func(HWND window, void *data) 7654 int DWSIGNAL _dw_color_ok_func(HWND window, void *data)
7640 { 7655 {
7641 DWDialog *dwwait = (DWDialog *)data; 7656 DWDialog *dwwait = (DWDialog *)data;
7642 HMTX mtx = (HMTX)dw_window_get_data((HWND)dwwait->data, "_dw_mutex"); 7657 HMTX mtx = (HMTX)dw_window_get_data((HWND)dwwait->data, "_dw_mutex");
7643 unsigned long val; 7658 unsigned long val;
7644 7659
7645 window = (HWND)dwwait->data; 7660 window = (HWND)dwwait->data;
7646 val = _dw_color_spin_get(window); 7661 val = _dw_color_spin_get(window);
7647 7662
7648 dw_mutex_lock(mtx); 7663 dw_mutex_lock(mtx);
7649 dw_mutex_close(mtx); 7664 dw_mutex_close(mtx);
7650 dw_window_destroy(window); 7665 dw_window_destroy(window);
7651 dw_dialog_dismiss((DWDialog *)data, (void *)val); 7666 dw_dialog_dismiss((DWDialog *)data, (void *)val);
7652 return FALSE; 7667 return FALSE;
7653 } 7668 }
7654 7669
7655 /* Allows the user to choose a color using the system's color chooser dialog. 7670 /* Allows the user to choose a color using the system's color chooser dialog.
7656 * Parameters: 7671 * Parameters:
7657 * value: current color 7672 * value: current color
7658 * Returns: 7673 * Returns:
7659 * The selected color or the current color if cancelled. 7674 * The selected color or the current color if cancelled.
7660 */ 7675 */
7661 unsigned long API dw_color_choose(unsigned long value) 7676 unsigned long API dw_color_choose(unsigned long value)
7662 { 7677 {
7663 HWND window, hbox, vbox, col, button, text; 7678 HWND window, hbox, vbox, col, button, text;
7664 DWDialog *dwwait; 7679 DWDialog *dwwait;
7665 HMTX mtx = dw_mutex_new(); 7680 HMTX mtx = dw_mutex_new();
7666 7681
7667 window = dw_window_new( HWND_DESKTOP, "Choose Color", FCF_SHELLPOSITION | FCF_TITLEBAR | FCF_DLGBORDER | FCF_CLOSEBUTTON | FCF_SYSMENU); 7682 window = dw_window_new( HWND_DESKTOP, "Choose Color", FCF_SHELLPOSITION | FCF_TITLEBAR | FCF_DLGBORDER | FCF_CLOSEBUTTON | FCF_SYSMENU);
7668 7683
7669 vbox = dw_box_new(DW_VERT, 5); 7684 vbox = dw_box_new(DW_VERT, 5);
7670 7685
7671 dw_box_pack_start(window, vbox, 0, 0, TRUE, TRUE, 0); 7686 dw_box_pack_start(window, vbox, 0, 0, TRUE, TRUE, 0);
7672 7687
7673 hbox = dw_box_new(DW_HORZ, 0); 7688 hbox = dw_box_new(DW_HORZ, 0);
7674 7689
7675 dw_box_pack_start(vbox, hbox, 0, 0, FALSE, FALSE, 0); 7690 dw_box_pack_start(vbox, hbox, 0, 0, FALSE, FALSE, 0);
7676 dw_window_set_style(hbox, 0, WS_CLIPCHILDREN); 7691 dw_window_set_style(hbox, 0, WS_CLIPCHILDREN);
7677 7692
7678 col = WinCreateWindow(vbox, "ColorSelectClass", "", WS_VISIBLE | WS_GROUP, 0, 0, 390, 300, vbox, HWND_TOP, 266, NULL,NULL); 7693 col = WinCreateWindow(vbox, "ColorSelectClass", "", WS_VISIBLE | WS_GROUP, 0, 0, 390, 300, vbox, HWND_TOP, 266, NULL,NULL);
7679 dw_box_pack_start(hbox, col, 390, 300, FALSE, FALSE, 0); 7694 dw_box_pack_start(hbox, col, 390, 300, FALSE, FALSE, 0);
7680 7695
7681 dw_window_set_data(hbox, "_dw_window", (void *)window); 7696 dw_window_set_data(hbox, "_dw_window", (void *)window);
7682 dw_window_set_data(window, "_dw_mutex", (void *)mtx); 7697 dw_window_set_data(window, "_dw_mutex", (void *)mtx);
7683 dw_window_set_data(window, "_dw_col", (void *)col); 7698 dw_window_set_data(window, "_dw_col", (void *)col);
7684 dw_window_set_data(window, "_dw_val", (void *)value); 7699 dw_window_set_data(window, "_dw_val", (void *)value);
7685 7700
7686 hbox = dw_box_new(DW_HORZ, 0); 7701 hbox = dw_box_new(DW_HORZ, 0);
7687 dw_window_set_data(hbox, "_dw_window", (void *)window); 7702 dw_window_set_data(hbox, "_dw_window", (void *)window);
7688 7703
7689 dw_box_pack_start(vbox, hbox, 0, 0, TRUE, FALSE, 0); 7704 dw_box_pack_start(vbox, hbox, 0, 0, TRUE, FALSE, 0);
7690 7705
7691 text = dw_text_new("Red:", 0); 7706 text = dw_text_new("Red:", 0);
7692 dw_window_set_style(text, DW_DT_VCENTER, DW_DT_VCENTER); 7707 dw_window_set_style(text, DW_DT_VCENTER, DW_DT_VCENTER);
7693 dw_box_pack_start(hbox, text, 30, 20, FALSE, FALSE, 3); 7708 dw_box_pack_start(hbox, text, 30, 20, FALSE, FALSE, 3);
7694 7709
7695 button = dw_spinbutton_new("", 1001L); 7710 button = dw_spinbutton_new("", 1001L);
7696 dw_spinbutton_set_limits(button, 255, 0); 7711 dw_spinbutton_set_limits(button, 255, 0);
7697 dw_box_pack_start(hbox, button, 20, 20, TRUE, FALSE, 3); 7712 dw_box_pack_start(hbox, button, 20, 20, TRUE, FALSE, 3);
7698 WinSetOwner(button, hbox); 7713 WinSetOwner(button, hbox);
7699 dw_window_set_data(window, "_dw_red_spin", (void *)button); 7714 dw_window_set_data(window, "_dw_red_spin", (void *)button);
7700 7715
7701 text = dw_text_new("Green:", 0); 7716 text = dw_text_new("Green:", 0);
7702 dw_window_set_style(text, DW_DT_VCENTER, DW_DT_VCENTER); 7717 dw_window_set_style(text, DW_DT_VCENTER, DW_DT_VCENTER);
7703 dw_box_pack_start(hbox, text, 30, 20, FALSE, FALSE, 3); 7718 dw_box_pack_start(hbox, text, 30, 20, FALSE, FALSE, 3);
7704 7719
7705 button = dw_spinbutton_new("", 1002L); 7720 button = dw_spinbutton_new("", 1002L);
7706 dw_spinbutton_set_limits(button, 255, 0); 7721 dw_spinbutton_set_limits(button, 255, 0);
7707 dw_box_pack_start(hbox, button, 20, 20, TRUE, FALSE, 3); 7722 dw_box_pack_start(hbox, button, 20, 20, TRUE, FALSE, 3);
7708 WinSetOwner(button, hbox); 7723 WinSetOwner(button, hbox);
7709 dw_window_set_data(window, "_dw_green_spin", (void *)button); 7724 dw_window_set_data(window, "_dw_green_spin", (void *)button);
7710 7725
7711 text = dw_text_new("Blue:", 0); 7726 text = dw_text_new("Blue:", 0);
7712 dw_window_set_style(text, DW_DT_VCENTER, DW_DT_VCENTER); 7727 dw_window_set_style(text, DW_DT_VCENTER, DW_DT_VCENTER);
7713 dw_box_pack_start(hbox, text, 30, 20, FALSE, FALSE, 3); 7728 dw_box_pack_start(hbox, text, 30, 20, FALSE, FALSE, 3);
7714 7729
7715 button = dw_spinbutton_new("", 1003L); 7730 button = dw_spinbutton_new("", 1003L);
7716 dw_spinbutton_set_limits(button, 255, 0); 7731 dw_spinbutton_set_limits(button, 255, 0);
7717 dw_box_pack_start(hbox, button, 20, 20, TRUE, FALSE, 3); 7732 dw_box_pack_start(hbox, button, 20, 20, TRUE, FALSE, 3);
7718 WinSetOwner(button, hbox); 7733 WinSetOwner(button, hbox);
7719 dw_window_set_data(window, "_dw_blue_spin", (void *)button); 7734 dw_window_set_data(window, "_dw_blue_spin", (void *)button);
7720 7735
7721 hbox = dw_box_new(DW_HORZ, 0); 7736 hbox = dw_box_new(DW_HORZ, 0);
7722 7737
7723 dw_box_pack_start(vbox, hbox, 0, 0, TRUE, FALSE, 0); 7738 dw_box_pack_start(vbox, hbox, 0, 0, TRUE, FALSE, 0);
7724 dw_box_pack_start(hbox, 0, 100, 1, TRUE, FALSE, 0); 7739 dw_box_pack_start(hbox, 0, 100, 1, TRUE, FALSE, 0);
7725 7740
7726 button = dw_button_new("Ok", 1001L); 7741 button = dw_button_new("Ok", 1001L);
7727 dw_box_pack_start(hbox, button, 50, 30, TRUE, FALSE, 3); 7742 dw_box_pack_start(hbox, button, 50, 30, TRUE, FALSE, 3);
7728 7743
7729 dwwait = dw_dialog_new((void *)window); 7744 dwwait = dw_dialog_new((void *)window);
7730 7745
7731 dw_signal_connect(button, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_color_ok_func), (void *)dwwait); 7746 dw_signal_connect(button, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_color_ok_func), (void *)dwwait);
7732 7747
7733 button = dw_button_new("Cancel", 1002L); 7748 button = dw_button_new("Cancel", 1002L);
7734 dw_box_pack_start(hbox, button, 50, 30, TRUE, FALSE, 3); 7749 dw_box_pack_start(hbox, button, 50, 30, TRUE, FALSE, 3);
7735 7750
7736 dw_signal_connect(button, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_color_cancel_func), (void *)dwwait); 7751 dw_signal_connect(button, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_color_cancel_func), (void *)dwwait);
7737 dw_signal_connect(window, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(_dw_color_cancel_func), (void *)dwwait); 7752 dw_signal_connect(window, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(_dw_color_cancel_func), (void *)dwwait);
7738 7753
7739 dw_window_set_size(window, 400, 400); 7754 dw_window_set_size(window, 400, 400);
7740 7755
7741 _dw_col_set(col, value); 7756 _dw_col_set(col, value);
7742 _dw_color_spin_set(window, value); 7757 _dw_color_spin_set(window, value);
7743 7758
7744 dw_window_show(window); 7759 dw_window_show(window);
7745 7760
7746 return (unsigned long)dw_dialog_wait(dwwait); 7761 return (unsigned long)dw_dialog_wait(dwwait);
7747 } 7762 }
7748 7763
7749 HPS _set_hps(HPS hps) 7764 HPS _set_hps(HPS hps)
7750 { 7765 {
7751 LONG alTable[2]; 7766 LONG alTable[2];
7752 7767
7753 alTable[0] = DW_RED_VALUE(_foreground) << 16 | DW_GREEN_VALUE(_foreground) << 8 | DW_BLUE_VALUE(_foreground); 7768 alTable[0] = DW_RED_VALUE(_foreground) << 16 | DW_GREEN_VALUE(_foreground) << 8 | DW_BLUE_VALUE(_foreground);
7754 alTable[1] = DW_RED_VALUE(_background) << 16 | DW_GREEN_VALUE(_background) << 8 | DW_BLUE_VALUE(_background); 7769 alTable[1] = DW_RED_VALUE(_background) << 16 | DW_GREEN_VALUE(_background) << 8 | DW_BLUE_VALUE(_background);
7755 7770
7756 GpiCreateLogColorTable(hps, 7771 GpiCreateLogColorTable(hps,
7757 LCOL_RESET, 7772 LCOL_RESET,
7758 LCOLF_CONSECRGB, 7773 LCOLF_CONSECRGB,
7759 16, 7774 16,
7760 2, 7775 2,
7761 alTable); 7776 alTable);
7762 if(_foreground & DW_RGB_COLOR) 7777 if(_foreground & DW_RGB_COLOR)
7763 GpiSetColor(hps, 16); 7778 GpiSetColor(hps, 16);
7764 else 7779 else
7765 GpiSetColor(hps, _internal_color(_foreground)); 7780 GpiSetColor(hps, _internal_color(_foreground));
7766 if(_background & DW_RGB_COLOR) 7781 if(_background & DW_RGB_COLOR)
7767 GpiSetBackColor(hps, 17); 7782 GpiSetBackColor(hps, 17);
7768 else 7783 else
7769 GpiSetBackColor(hps, _internal_color(_background)); 7784 GpiSetBackColor(hps, _internal_color(_background));
7770 return hps; 7785 return hps;
7771 } 7786 }
7772 7787
7773 HPS _set_colors(HWND handle) 7788 HPS _set_colors(HWND handle)
7774 { 7789 {
7775 HPS hps = WinGetPS(handle); 7790 HPS hps = WinGetPS(handle);
7776 7791
7777 _set_hps(hps); 7792 _set_hps(hps);
7778 return hps; 7793 return hps;
7779 } 7794 }
7780 7795
7781 /* Draw a point on a window (preferably a render window). 7796 /* Draw a point on a window (preferably a render window).
7782 * Parameters: 7797 * Parameters:
7783 * handle: Handle to the window. 7798 * handle: Handle to the window.
7785 * x: X coordinate. 7800 * x: X coordinate.
7786 * y: Y coordinate. 7801 * y: Y coordinate.
7787 */ 7802 */
7788 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) 7803 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
7789 { 7804 {
7790 HPS hps; 7805 HPS hps;
7791 int height; 7806 int height;
7792 POINTL ptl; 7807 POINTL ptl;
7793 7808
7794 if(handle) 7809 if(handle)
7795 { 7810 {
7796 hps = _set_colors(handle); 7811 hps = _set_colors(handle);
7797 height = _get_height(handle); 7812 height = _get_height(handle);
7798 } 7813 }
7799 else if(pixmap) 7814 else if(pixmap)
7800 { 7815 {
7801 hps = _set_hps(pixmap->hps); 7816 hps = _set_hps(pixmap->hps);
7802 height = pixmap->height; 7817 height = pixmap->height;
7803 } 7818 }
7804 else 7819 else
7805 return; 7820 return;
7806 7821
7807 ptl.x = x; 7822 ptl.x = x;
7808 ptl.y = height - y - 1; 7823 ptl.y = height - y - 1;
7809 7824
7810 GpiSetPel(hps, &ptl); 7825 GpiSetPel(hps, &ptl);
7811 if(!pixmap) 7826 if(!pixmap)
7812 WinReleasePS(hps); 7827 WinReleasePS(hps);
7813 } 7828 }
7814 7829
7815 /* Draw a line on a window (preferably a render window). 7830 /* Draw a line on a window (preferably a render window).
7816 * Parameters: 7831 * Parameters:
7817 * handle: Handle to the window. 7832 * handle: Handle to the window.
7821 * x2: Second X coordinate. 7836 * x2: Second X coordinate.
7822 * y2: Second Y coordinate. 7837 * y2: Second Y coordinate.
7823 */ 7838 */
7824 void API dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) 7839 void API dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2)
7825 { 7840 {
7826 HPS hps; 7841 HPS hps;
7827 int height; 7842 int height;
7828 POINTL ptl[2]; 7843 POINTL ptl[2];
7829 7844
7830 if(handle) 7845 if(handle)
7831 { 7846 {
7832 hps = _set_colors(handle); 7847 hps = _set_colors(handle);
7833 height = _get_height(handle); 7848 height = _get_height(handle);
7834 } 7849 }
7835 else if(pixmap) 7850 else if(pixmap)
7836 { 7851 {
7837 hps = _set_hps(pixmap->hps); 7852 hps = _set_hps(pixmap->hps);
7838 height = pixmap->height; 7853 height = pixmap->height;
7839 } 7854 }
7840 else 7855 else
7841 return; 7856 return;
7842 7857
7843 ptl[0].x = x1; 7858 ptl[0].x = x1;
7844 ptl[0].y = height - y1 - 1; 7859 ptl[0].y = height - y1 - 1;
7845 ptl[1].x = x2; 7860 ptl[1].x = x2;
7846 ptl[1].y = height - y2 - 1; 7861 ptl[1].y = height - y2 - 1;
7847 7862
7848 GpiMove(hps, &ptl[0]); 7863 GpiMove(hps, &ptl[0]);
7849 GpiLine(hps, &ptl[1]); 7864 GpiLine(hps, &ptl[1]);
7850 7865
7851 if(!pixmap) 7866 if(!pixmap)
7852 WinReleasePS(hps); 7867 WinReleasePS(hps);
7853 } 7868 }
7854 7869
7855 7870
7856 void _CopyFontSettings(HPS hpsSrc, HPS hpsDst) 7871 void _CopyFontSettings(HPS hpsSrc, HPS hpsDst)
7857 { 7872 {
7858 FONTMETRICS fm; 7873 FONTMETRICS fm;
7859 FATTRS fat; 7874 FATTRS fat;
7860 SIZEF sizf; 7875 SIZEF sizf;
7861 7876
7862 GpiQueryFontMetrics(hpsSrc, sizeof(FONTMETRICS), &fm); 7877 GpiQueryFontMetrics(hpsSrc, sizeof(FONTMETRICS), &fm);
7863 7878
7864 memset(&fat, 0, sizeof(fat)); 7879 memset(&fat, 0, sizeof(fat));
7865 7880
7866 fat.usRecordLength = sizeof(FATTRS); 7881 fat.usRecordLength = sizeof(FATTRS);
7867 fat.lMatch = fm.lMatch; 7882 fat.lMatch = fm.lMatch;
7868 strcpy(fat.szFacename, fm.szFacename); 7883 strcpy(fat.szFacename, fm.szFacename);
7869 7884
7870 GpiCreateLogFont(hpsDst, 0, 1L, &fat); 7885 GpiCreateLogFont(hpsDst, 0, 1L, &fat);
7871 GpiSetCharSet(hpsDst, 1L); 7886 GpiSetCharSet(hpsDst, 1L);
7872 7887
7873 sizf.cx = MAKEFIXED(fm.lEmInc,0); 7888 sizf.cx = MAKEFIXED(fm.lEmInc,0);
7874 sizf.cy = MAKEFIXED(fm.lMaxBaselineExt,0); 7889 sizf.cy = MAKEFIXED(fm.lMaxBaselineExt,0);
7875 GpiSetCharBox(hpsDst, &sizf ); 7890 GpiSetCharBox(hpsDst, &sizf );
7876 } 7891 }
7877 7892
7878 /* Draw text on a window (preferably a render window). 7893 /* Draw text on a window (preferably a render window).
7879 * Parameters: 7894 * Parameters:
7880 * handle: Handle to the window. 7895 * handle: Handle to the window.
7883 * y: Y coordinate. 7898 * y: Y coordinate.
7884 * text: Text to be displayed. 7899 * text: Text to be displayed.
7885 */ 7900 */
7886 void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) 7901 void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text)
7887 { 7902 {
7888 HPS hps; 7903 HPS hps;
7889 int z, height; 7904 int z, height;
7890 RECTL rcl; 7905 RECTL rcl;
7891 char fontname[128]; 7906 char fontname[128];
7892 POINTL aptl[TXTBOX_COUNT]; 7907 POINTL aptl[TXTBOX_COUNT];
7893 7908
7894 if(handle) 7909 if(handle)
7895 { 7910 {
7896 hps = _set_colors(handle); 7911 hps = _set_colors(handle);
7897 height = _get_height(handle); 7912 height = _get_height(handle);
7898 _GetPPFont(handle, fontname); 7913 _GetPPFont(handle, fontname);
7899 } 7914 }
7900 else if(pixmap) 7915 else if(pixmap)
7901 { 7916 {
7902 HPS pixmaphps = WinGetPS(pixmap->handle); 7917 HPS pixmaphps = WinGetPS(pixmap->handle);
7903 7918
7904 hps = _set_hps(pixmap->hps); 7919 hps = _set_hps(pixmap->hps);
7905 height = pixmap->height; 7920 height = pixmap->height;
7906 _GetPPFont(pixmap->handle, fontname); 7921 _GetPPFont(pixmap->handle, fontname);
7907 _CopyFontSettings(pixmaphps, hps); 7922 _CopyFontSettings(pixmaphps, hps);
7908 WinReleasePS(pixmaphps); 7923 WinReleasePS(pixmaphps);
7909 } 7924 }
7910 else 7925 else
7911 return; 7926 return;
7912 7927
7913 for(z=0;z<strlen(fontname);z++) 7928 for(z=0;z<strlen(fontname);z++)
7914 { 7929 {
7915 if(fontname[z]=='.') 7930 if(fontname[z]=='.')
7916 break; 7931 break;
7917 } 7932 }
7918 7933
7919 GpiQueryTextBox(hps, strlen(text), text, TXTBOX_COUNT, aptl); 7934 GpiQueryTextBox(hps, strlen(text), text, TXTBOX_COUNT, aptl);
7920 7935
7921 rcl.xLeft = x; 7936 rcl.xLeft = x;
7922 rcl.yTop = height - y; 7937 rcl.yTop = height - y;
7923 rcl.yBottom = rcl.yTop - (aptl[TXTBOX_TOPLEFT].y - aptl[TXTBOX_BOTTOMLEFT].y); 7938 rcl.yBottom = rcl.yTop - (aptl[TXTBOX_TOPLEFT].y - aptl[TXTBOX_BOTTOMLEFT].y);
7924 rcl.xRight = rcl.xLeft + (aptl[TXTBOX_TOPRIGHT].x - aptl[TXTBOX_TOPLEFT].x); 7939 rcl.xRight = rcl.xLeft + (aptl[TXTBOX_TOPRIGHT].x - aptl[TXTBOX_TOPLEFT].x);
7925 7940
7926 if(_background == DW_CLR_DEFAULT) 7941 if(_background == DW_CLR_DEFAULT)
7927 WinDrawText(hps, -1, text, &rcl, DT_TEXTATTRS, DT_TEXTATTRS, DT_VCENTER | DT_LEFT | DT_TEXTATTRS); 7942 WinDrawText(hps, -1, text, &rcl, DT_TEXTATTRS, DT_TEXTATTRS, DT_VCENTER | DT_LEFT | DT_TEXTATTRS);
7928 else 7943 else
7929 WinDrawText(hps, -1, text, &rcl, _internal_color(_foreground), _internal_color(_background), DT_VCENTER | DT_LEFT | DT_ERASERECT); 7944 WinDrawText(hps, -1, text, &rcl, _internal_color(_foreground), _internal_color(_background), DT_VCENTER | DT_LEFT | DT_ERASERECT);
7930 7945
7931 if(!pixmap) 7946 if(!pixmap)
7932 WinReleasePS(hps); 7947 WinReleasePS(hps);
7933 } 7948 }
7934 7949
7935 /* Query the width and height of a text string. 7950 /* Query the width and height of a text string.
7936 * Parameters: 7951 * Parameters:
7937 * handle: Handle to the window. 7952 * handle: Handle to the window.
7940 * width: Pointer to a variable to be filled in with the width. 7955 * width: Pointer to a variable to be filled in with the width.
7941 * height Pointer to a variable to be filled in with the height. 7956 * height Pointer to a variable to be filled in with the height.
7942 */ 7957 */
7943 void API dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height) 7958 void API dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height)
7944 { 7959 {
7945 HPS hps; 7960 HPS hps;
7946 POINTL aptl[TXTBOX_COUNT]; 7961 POINTL aptl[TXTBOX_COUNT];
7947 7962
7948 if(handle) 7963 if(handle)
7949 { 7964 {
7950 hps = _set_colors(handle); 7965 hps = _set_colors(handle);
7951 } 7966 }
7952 else if(pixmap) 7967 else if(pixmap)
7953 { 7968 {
7954 HPS pixmaphps = WinGetPS(pixmap->handle); 7969 HPS pixmaphps = WinGetPS(pixmap->handle);
7955 7970
7956 hps = _set_hps(pixmap->hps); 7971 hps = _set_hps(pixmap->hps);
7957 _CopyFontSettings(pixmaphps, hps); 7972 _CopyFontSettings(pixmaphps, hps);
7958 WinReleasePS(pixmaphps); 7973 WinReleasePS(pixmaphps);
7959 } 7974 }
7960 else 7975 else
7961 return; 7976 return;
7962 7977
7963 GpiQueryTextBox(hps, strlen(text), text, TXTBOX_COUNT, aptl); 7978 GpiQueryTextBox(hps, strlen(text), text, TXTBOX_COUNT, aptl);
7964 7979
7965 if(width) 7980 if(width)
7966 *width = aptl[TXTBOX_TOPRIGHT].x - aptl[TXTBOX_TOPLEFT].x; 7981 *width = aptl[TXTBOX_TOPRIGHT].x - aptl[TXTBOX_TOPLEFT].x;
7967 7982
7968 if(height) 7983 if(height)
7969 *height = aptl[TXTBOX_TOPLEFT].y - aptl[TXTBOX_BOTTOMLEFT].y; 7984 *height = aptl[TXTBOX_TOPLEFT].y - aptl[TXTBOX_BOTTOMLEFT].y;
7970 7985
7971 if(!pixmap) 7986 if(!pixmap)
7972 WinReleasePS(hps); 7987 WinReleasePS(hps);
7973 } 7988 }
7974 7989
7975 /* Draw a polygon on a window (preferably a render window). 7990 /* Draw a polygon on a window (preferably a render window).
7976 * Parameters: 7991 * Parameters:
7977 * handle: Handle to the window. 7992 * handle: Handle to the window.
8048 * width: Width of rectangle. 8063 * width: Width of rectangle.
8049 * height: Height of rectangle. 8064 * height: Height of rectangle.
8050 */ 8065 */
8051 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) 8066 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height)
8052 { 8067 {
8053 HPS hps; 8068 HPS hps;
8054 int thisheight; 8069 int thisheight;
8055 POINTL ptl[2]; 8070 POINTL ptl[2];
8056 8071
8057 if(handle) 8072 if(handle)
8058 { 8073 {
8059 hps = _set_colors(handle); 8074 hps = _set_colors(handle);
8060 thisheight = _get_height(handle); 8075 thisheight = _get_height(handle);
8061 } 8076 }
8062 else if(pixmap) 8077 else if(pixmap)
8063 { 8078 {
8064 hps = _set_hps(pixmap->hps); 8079 hps = _set_hps(pixmap->hps);
8065 thisheight = pixmap->height; 8080 thisheight = pixmap->height;
8066 } 8081 }
8067 else 8082 else
8068 return; 8083 return;
8069 8084
8070 ptl[0].x = x; 8085 ptl[0].x = x;
8071 ptl[0].y = thisheight - y - 1; 8086 ptl[0].y = thisheight - y - 1;
8072 ptl[1].x = x + width - 1; 8087 ptl[1].x = x + width - 1;
8073 ptl[1].y = thisheight - y - height; 8088 ptl[1].y = thisheight - y - height;
8074 8089
8075 GpiMove(hps, &ptl[0]); 8090 GpiMove(hps, &ptl[0]);
8076 GpiBox(hps, fill ? DRO_OUTLINEFILL : DRO_OUTLINE, &ptl[1], 0, 0); 8091 GpiBox(hps, fill ? DRO_OUTLINEFILL : DRO_OUTLINE, &ptl[1], 0, 0);
8077 8092
8078 if(!pixmap) 8093 if(!pixmap)
8079 WinReleasePS(hps); 8094 WinReleasePS(hps);
8080 } 8095 }
8081 8096
8082 /* Call this after drawing to the screen to make sure 8097 /* Call this after drawing to the screen to make sure
8083 * anything you have drawn is visible. 8098 * anything you have drawn is visible.
8084 */ 8099 */
8096 * Returns: 8111 * Returns:
8097 * A handle to a pixmap or NULL on failure. 8112 * A handle to a pixmap or NULL on failure.
8098 */ 8113 */
8099 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) 8114 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth)
8100 { 8115 {
8101 BITMAPINFOHEADER bmih; 8116 BITMAPINFOHEADER bmih;
8102 SIZEL sizl = { 0, 0 }; 8117 SIZEL sizl = { 0, 0 };
8103 HPIXMAP pixmap; 8118 HPIXMAP pixmap;
8104 HDC hdc; 8119 HDC hdc;
8105 HPS hps; 8120 HPS hps;
8106 ULONG ulFlags; 8121 ULONG ulFlags;
8107 LONG cPlanes, cBitCount; 8122 LONG cPlanes, cBitCount;
8108 8123
8109 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) 8124 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
8110 return NULL; 8125 return NULL;
8111 8126
8112 hps = WinGetPS(handle); 8127 hps = WinGetPS(handle);
8113 8128
8114 hdc = GpiQueryDevice(hps); 8129 hdc = GpiQueryDevice(hps);
8115 ulFlags = GpiQueryPS(hps, &sizl); 8130 ulFlags = GpiQueryPS(hps, &sizl);
8116 8131
8117 pixmap->handle = handle; 8132 pixmap->handle = handle;
8118 pixmap->hdc = DevOpenDC(dwhab, OD_MEMORY, "*", 0L, NULL, hdc); 8133 pixmap->hdc = DevOpenDC(dwhab, OD_MEMORY, "*", 0L, NULL, hdc);
8119 pixmap->hps = GpiCreatePS (dwhab, pixmap->hdc, &sizl, ulFlags | GPIA_ASSOC); 8134 pixmap->hps = GpiCreatePS (dwhab, pixmap->hdc, &sizl, ulFlags | GPIA_ASSOC);
8120 8135
8121 DevQueryCaps(hdc, CAPS_COLOR_PLANES , 1L, &cPlanes); 8136 DevQueryCaps(hdc, CAPS_COLOR_PLANES , 1L, &cPlanes);
8122 if (!depth) 8137 if (!depth)
8123 { 8138 {
8124 DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1L, &cBitCount); 8139 DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1L, &cBitCount);
8125 depth = cBitCount; 8140 depth = cBitCount;
8126 } 8141 }
8127 8142
8128 memset(&bmih, 0, sizeof(BITMAPINFOHEADER)); 8143 memset(&bmih, 0, sizeof(BITMAPINFOHEADER));
8129 bmih.cbFix = sizeof(BITMAPINFOHEADER); 8144 bmih.cbFix = sizeof(BITMAPINFOHEADER);
8130 bmih.cx = (SHORT)width; 8145 bmih.cx = (SHORT)width;
8131 bmih.cy = (SHORT)height; 8146 bmih.cy = (SHORT)height;
8132 bmih.cPlanes = (SHORT)cPlanes; 8147 bmih.cPlanes = (SHORT)cPlanes;
8133 bmih.cBitCount = (SHORT)depth; 8148 bmih.cBitCount = (SHORT)depth;
8134 8149
8135 pixmap->width = width; pixmap->height = height; 8150 pixmap->width = width; pixmap->height = height;
8136 8151
8137 pixmap->hbm = GpiCreateBitmap(pixmap->hps, (PBITMAPINFOHEADER2)&bmih, 0L, NULL, NULL); 8152 pixmap->hbm = GpiCreateBitmap(pixmap->hps, (PBITMAPINFOHEADER2)&bmih, 0L, NULL, NULL);
8138 8153
8139 GpiSetBitmap(pixmap->hps, pixmap->hbm); 8154 GpiSetBitmap(pixmap->hps, pixmap->hbm);
8140 8155
8141 if (depth>8) 8156 if (depth>8)
8142 GpiCreateLogColorTable(pixmap->hps, LCOL_PURECOLOR, LCOLF_RGB, 0, 0, NULL ); 8157 GpiCreateLogColorTable(pixmap->hps, LCOL_PURECOLOR, LCOLF_RGB, 0, 0, NULL );
8143 8158
8144 WinReleasePS(hps); 8159 WinReleasePS(hps);
8145 8160
8146 return pixmap; 8161 return pixmap;
8147 } 8162 }
8148 8163
8149 /* 8164 /*
8150 * Creates a pixmap from a file. 8165 * Creates a pixmap from a file.
8151 * Parameters: 8166 * Parameters:
8267 * Returns: 8282 * Returns:
8268 * A handle to a pixmap or NULL on failure. 8283 * A handle to a pixmap or NULL on failure.
8269 */ 8284 */
8270 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG id) 8285 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG id)
8271 { 8286 {
8272 BITMAPINFOHEADER bmih; 8287 BITMAPINFOHEADER bmih;
8273 SIZEL sizl = { 0, 0 }; 8288 SIZEL sizl = { 0, 0 };
8274 HPIXMAP pixmap; 8289 HPIXMAP pixmap;
8275 HDC hdc; 8290 HDC hdc;
8276 HPS hps; 8291 HPS hps;
8277 ULONG ulFlags; 8292 ULONG ulFlags;
8278 8293
8279 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) 8294 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
8280 return NULL; 8295 return NULL;
8281 8296
8282 hps = WinGetPS(handle); 8297 hps = WinGetPS(handle);
8283 8298
8284 hdc = GpiQueryDevice(hps); 8299 hdc = GpiQueryDevice(hps);
8285 ulFlags = GpiQueryPS(hps, &sizl); 8300 ulFlags = GpiQueryPS(hps, &sizl);
8286 8301
8287 pixmap->hdc = DevOpenDC(dwhab, OD_MEMORY, "*", 0L, NULL, hdc); 8302 pixmap->hdc = DevOpenDC(dwhab, OD_MEMORY, "*", 0L, NULL, hdc);
8288 pixmap->hps = GpiCreatePS (dwhab, pixmap->hdc, &sizl, ulFlags | GPIA_ASSOC); 8303 pixmap->hps = GpiCreatePS (dwhab, pixmap->hdc, &sizl, ulFlags | GPIA_ASSOC);
8289 8304
8290 pixmap->hbm = GpiLoadBitmap(pixmap->hps, NULLHANDLE, id, 0, 0); 8305 pixmap->hbm = GpiLoadBitmap(pixmap->hps, NULLHANDLE, id, 0, 0);
8291 8306
8292 GpiQueryBitmapParameters(pixmap->hbm, &bmih); 8307 GpiQueryBitmapParameters(pixmap->hbm, &bmih);
8293 8308
8294 GpiSetBitmap(pixmap->hps, pixmap->hbm); 8309 GpiSetBitmap(pixmap->hps, pixmap->hbm);
8295 8310
8296 pixmap->width = bmih.cx; pixmap->height = bmih.cy; 8311 pixmap->width = bmih.cx; pixmap->height = bmih.cy;
8297 8312
8298 WinReleasePS(hps); 8313 WinReleasePS(hps);
8299 8314
8300 return pixmap; 8315 return pixmap;
8301 } 8316 }
8302 8317
8303 /* 8318 /*
8304 * Destroys an allocated pixmap. 8319 * Destroys an allocated pixmap.
8305 * Parameters: 8320 * Parameters:
8306 * pixmap: Handle to a pixmap returned by 8321 * pixmap: Handle to a pixmap returned by
8307 * dw_pixmap_new.. 8322 * dw_pixmap_new..
8308 */ 8323 */
8309 void API dw_pixmap_destroy(HPIXMAP pixmap) 8324 void API dw_pixmap_destroy(HPIXMAP pixmap)
8310 { 8325 {
8311 GpiSetBitmap(pixmap->hps, NULLHANDLE); 8326 GpiSetBitmap(pixmap->hps, NULLHANDLE);
8312 GpiDeleteBitmap(pixmap->hbm); 8327 GpiDeleteBitmap(pixmap->hbm);
8313 GpiAssociate(pixmap->hps, NULLHANDLE); 8328 GpiAssociate(pixmap->hps, NULLHANDLE);
8314 GpiDestroyPS(pixmap->hps); 8329 GpiDestroyPS(pixmap->hps);
8315 DevCloseDC(pixmap->hdc); 8330 DevCloseDC(pixmap->hdc);
8316 free(pixmap); 8331 free(pixmap);
8317 } 8332 }
8318 8333
8319 /* 8334 /*
8320 * Copies from one item to another. 8335 * Copies from one item to another.
8321 * Parameters: 8336 * Parameters:
8330 * xsrc: X coordinate of source. 8345 * xsrc: X coordinate of source.
8331 * ysrc: Y coordinate of source. 8346 * ysrc: Y coordinate of source.
8332 */ 8347 */
8333 void API dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) 8348 void API dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc)
8334 { 8349 {
8335 HPS hpsdest; 8350 HPS hpsdest;
8336 HPS hpssrc; 8351 HPS hpssrc;
8337 POINTL ptl[4]; 8352 POINTL ptl[4];
8338 int destheight, srcheight; 8353 int destheight, srcheight;
8339 8354
8340 if(dest) 8355 if(dest)
8341 { 8356 {
8342 hpsdest = WinGetPS(dest); 8357 hpsdest = WinGetPS(dest);
8343 destheight = _get_height(dest); 8358 destheight = _get_height(dest);
8344 } 8359 }
8345 else if(destp) 8360 else if(destp)
8346 { 8361 {
8347 hpsdest = destp->hps; 8362 hpsdest = destp->hps;
8348 destheight = destp->height; 8363 destheight = destp->height;
8349 } 8364 }
8350 else 8365 else
8351 return; 8366 return;
8352 8367
8353 if(src) 8368 if(src)
8354 { 8369 {
8355 hpssrc = WinGetPS(src); 8370 hpssrc = WinGetPS(src);
8356 srcheight = _get_height(src); 8371 srcheight = _get_height(src);
8357 } 8372 }
8358 else if(srcp) 8373 else if(srcp)
8359 { 8374 {
8360 hpssrc = srcp->hps; 8375 hpssrc = srcp->hps;
8361 srcheight = srcp->height; 8376 srcheight = srcp->height;
8362 } 8377 }
8363 else 8378 else
8364 { 8379 {
8365 if(!destp) 8380 if(!destp)
8366 WinReleasePS(hpsdest); 8381 WinReleasePS(hpsdest);
8367 return; 8382 return;
8368 } 8383 }
8369 8384
8370 ptl[0].x = xdest; 8385 ptl[0].x = xdest;
8371 ptl[0].y = (destheight - ydest) - height; 8386 ptl[0].y = (destheight - ydest) - height;
8372 ptl[1].x = ptl[0].x + width; 8387 ptl[1].x = ptl[0].x + width;
8373 ptl[1].y = destheight - ydest; 8388 ptl[1].y = destheight - ydest;
8374 ptl[2].x = xsrc; 8389 ptl[2].x = xsrc;
8375 ptl[2].y = srcheight - (ysrc + height); 8390 ptl[2].y = srcheight - (ysrc + height);
8376 ptl[3].x = ptl[2].x + width; 8391 ptl[3].x = ptl[2].x + width;
8377 ptl[3].y = ptl[2].y + height; 8392 ptl[3].y = ptl[2].y + height;
8378 8393
8379 GpiBitBlt(hpsdest, hpssrc, 4, ptl, ROP_SRCCOPY, BBO_IGNORE); 8394 GpiBitBlt(hpsdest, hpssrc, 4, ptl, ROP_SRCCOPY, BBO_IGNORE);
8380 8395
8381 if(!destp) 8396 if(!destp)
8382 WinReleasePS(hpsdest); 8397 WinReleasePS(hpsdest);
8383 if(!srcp) 8398 if(!srcp)
8384 WinReleasePS(hpssrc); 8399 WinReleasePS(hpssrc);
8385 } 8400 }
8386 8401
8387 /* Run DosBeep() in a separate thread so it doesn't block */ 8402 /* Run DosBeep() in a separate thread so it doesn't block */
8388 void _beepthread(void *data) 8403 void _beepthread(void *data)
8389 { 8404 {
8390 int *info = (int *)data; 8405 int *info = (int *)data;
8391 8406
8392 if(data) 8407 if(data)
8393 { 8408 {
8394 DosBeep(info[0], info[1]); 8409 DosBeep(info[0], info[1]);
8395 free(data); 8410 free(data);
8396 } 8411 }
8397 } 8412 }
8398 8413
8399 /* 8414 /*
8400 * Emits a beep. 8415 * Emits a beep.
8401 * Parameters: 8416 * Parameters:
8402 * freq: Frequency. 8417 * freq: Frequency.
8403 * dur: Duration. 8418 * dur: Duration.
8404 */ 8419 */
8405 void API dw_beep(int freq, int dur) 8420 void API dw_beep(int freq, int dur)
8406 { 8421 {
8407 int *info = malloc(sizeof(int) * 2); 8422 int *info = malloc(sizeof(int) * 2);
8408 8423
8409 if(info) 8424 if(info)
8410 { 8425 {
8411 info[0] = freq; 8426 info[0] = freq;
8412 info[1] = dur; 8427 info[1] = dur;
8413 8428
8414 _beginthread(_beepthread, NULL, 100, (void *)info); 8429 _beginthread(_beepthread, NULL, 100, (void *)info);
8415 } 8430 }
8416 } 8431 }
8417 8432
8418 /* Open a shared library and return a handle. 8433 /* Open a shared library and return a handle.
8419 * Parameters: 8434 * Parameters:
8420 * name: Base name of the shared library. 8435 * name: Base name of the shared library.
8421 * handle: Pointer to a module handle, 8436 * handle: Pointer to a module handle,
8422 * will be filled in with the handle. 8437 * will be filled in with the handle.
8423 */ 8438 */
8424 int API dw_module_load(char *name, HMOD *handle) 8439 int API dw_module_load(char *name, HMOD *handle)
8425 { 8440 {
8426 char objnamebuf[300] = ""; 8441 char objnamebuf[300] = "";
8427 8442
8428 return DosLoadModule(objnamebuf, sizeof(objnamebuf), name, handle); 8443 return DosLoadModule(objnamebuf, sizeof(objnamebuf), name, handle);
8429 } 8444 }
8430 8445
8431 /* Queries the address of a symbol within open handle. 8446 /* Queries the address of a symbol within open handle.
8432 * Parameters: 8447 * Parameters:
8433 * handle: Module handle returned by dw_module_load() 8448 * handle: Module handle returned by dw_module_load()
8435 * func: A pointer to a function pointer, to obtain 8450 * func: A pointer to a function pointer, to obtain
8436 * the address. 8451 * the address.
8437 */ 8452 */
8438 int API dw_module_symbol(HMOD handle, char *name, void**func) 8453 int API dw_module_symbol(HMOD handle, char *name, void**func)
8439 { 8454 {
8440 return DosQueryProcAddr(handle, 0, name, (PFN*)func); 8455 return DosQueryProcAddr(handle, 0, name, (PFN*)func);
8441 } 8456 }
8442 8457
8443 /* Frees the shared library previously opened. 8458 /* Frees the shared library previously opened.
8444 * Parameters: 8459 * Parameters:
8445 * handle: Module handle returned by dw_module_load() 8460 * handle: Module handle returned by dw_module_load()
8446 */ 8461 */
8447 int API dw_module_close(HMOD handle) 8462 int API dw_module_close(HMOD handle)
8448 { 8463 {
8449 DosFreeModule(handle); 8464 DosFreeModule(handle);
8450 return 0; 8465 return 0;
8451 } 8466 }
8452 8467
8453 /* 8468 /*
8454 * Returns the handle to an unnamed mutex semaphore. 8469 * Returns the handle to an unnamed mutex semaphore.
8455 */ 8470 */
8456 HMTX API dw_mutex_new(void) 8471 HMTX API dw_mutex_new(void)
8457 { 8472 {
8458 HMTX mutex; 8473 HMTX mutex;
8459 8474
8460 DosCreateMutexSem(NULL, &mutex, 0, FALSE); 8475 DosCreateMutexSem(NULL, &mutex, 0, FALSE);
8461 return mutex; 8476 return mutex;
8462 } 8477 }
8463 8478
8464 /* 8479 /*
8465 * Closes a semaphore created by dw_mutex_new(). 8480 * Closes a semaphore created by dw_mutex_new().
8466 * Parameters: 8481 * Parameters:
8467 * mutex: The handle to the mutex returned by dw_mutex_new(). 8482 * mutex: The handle to the mutex returned by dw_mutex_new().
8468 */ 8483 */
8469 void API dw_mutex_close(HMTX mutex) 8484 void API dw_mutex_close(HMTX mutex)
8470 { 8485 {
8471 DosCloseMutexSem(mutex); 8486 DosCloseMutexSem(mutex);
8472 } 8487 }
8473 8488
8474 /* 8489 /*
8475 * Tries to gain access to the semaphore, if it can't it blocks. 8490 * Tries to gain access to the semaphore, if it can't it blocks.
8476 * If we are in a callback we must keep the message loop running 8491 * If we are in a callback we must keep the message loop running
8478 * Parameters: 8493 * Parameters:
8479 * mutex: The handle to the mutex returned by dw_mutex_new(). 8494 * mutex: The handle to the mutex returned by dw_mutex_new().
8480 */ 8495 */
8481 void API dw_mutex_lock(HMTX mutex) 8496 void API dw_mutex_lock(HMTX mutex)
8482 { 8497 {
8483 if(_dwtid == dw_thread_id()) 8498 if(_dwtid == dw_thread_id())
8484 { 8499 {
8485 int rc = DosRequestMutexSem(mutex, SEM_IMMEDIATE_RETURN); 8500 int rc = DosRequestMutexSem(mutex, SEM_IMMEDIATE_RETURN);
8486 8501
8487 while(rc == ERROR_TIMEOUT) 8502 while(rc == ERROR_TIMEOUT)
8488 { 8503 {
8489 dw_main_sleep(10); 8504 dw_main_sleep(10);
8490 rc = DosRequestMutexSem(mutex, SEM_IMMEDIATE_RETURN); 8505 rc = DosRequestMutexSem(mutex, SEM_IMMEDIATE_RETURN);
8491 } 8506 }
8492 } 8507 }
8493 else 8508 else
8494 DosRequestMutexSem(mutex, SEM_INDEFINITE_WAIT); 8509 DosRequestMutexSem(mutex, SEM_INDEFINITE_WAIT);
8495 } 8510 }
8496 8511
8497 /* 8512 /*
8498 * Reliquishes the access to the semaphore. 8513 * Reliquishes the access to the semaphore.
8499 * Parameters: 8514 * Parameters:
8500 * mutex: The handle to the mutex returned by dw_mutex_new(). 8515 * mutex: The handle to the mutex returned by dw_mutex_new().
8501 */ 8516 */
8502 void API dw_mutex_unlock(HMTX mutex) 8517 void API dw_mutex_unlock(HMTX mutex)
8503 { 8518 {
8504 DosReleaseMutexSem(mutex); 8519 DosReleaseMutexSem(mutex);
8505 } 8520 }
8506 8521
8507 /* 8522 /*
8508 * Returns the handle to an unnamed event semaphore. 8523 * Returns the handle to an unnamed event semaphore.
8509 */ 8524 */
8510 HEV API dw_event_new(void) 8525 HEV API dw_event_new(void)
8511 { 8526 {
8512 HEV blah; 8527 HEV blah;
8513 8528
8514 if(DosCreateEventSem (NULL, &blah, 0L, FALSE)) 8529 if(DosCreateEventSem (NULL, &blah, 0L, FALSE))
8515 return 0; 8530 return 0;
8516 8531
8517 return blah; 8532 return blah;
8518 } 8533 }
8519 8534
8520 /* 8535 /*
8521 * Resets a semaphore created by dw_event_new(). 8536 * Resets a semaphore created by dw_event_new().
8522 * Parameters: 8537 * Parameters:
8523 * eve: The handle to the event returned by dw_event_new(). 8538 * eve: The handle to the event returned by dw_event_new().
8524 */ 8539 */
8525 int API dw_event_reset(HEV eve) 8540 int API dw_event_reset(HEV eve)
8526 { 8541 {
8527 ULONG count; 8542 ULONG count;
8528 8543
8529 if(DosResetEventSem(eve, &count)) 8544 if(DosResetEventSem(eve, &count))
8530 return FALSE; 8545 return FALSE;
8531 return TRUE; 8546 return TRUE;
8532 } 8547 }
8533 8548
8534 /* 8549 /*
8535 * Posts a semaphore created by dw_event_new(). Causing all threads 8550 * Posts a semaphore created by dw_event_new(). Causing all threads
8536 * waiting on this event in dw_event_wait to continue. 8551 * waiting on this event in dw_event_wait to continue.
8537 * Parameters: 8552 * Parameters:
8538 * eve: The handle to the event returned by dw_event_new(). 8553 * eve: The handle to the event returned by dw_event_new().
8539 */ 8554 */
8540 int API dw_event_post(HEV eve) 8555 int API dw_event_post(HEV eve)
8541 { 8556 {
8542 if(DosPostEventSem(eve)) 8557 if(DosPostEventSem(eve))
8543 return FALSE; 8558 return FALSE;
8544 return TRUE; 8559 return TRUE;
8545 } 8560 }
8546 8561
8547 8562
8548 /* 8563 /*
8549 * Waits on a semaphore created by dw_event_new(), until the 8564 * Waits on a semaphore created by dw_event_new(), until the
8551 * Parameters: 8566 * Parameters:
8552 * eve: The handle to the event returned by dw_event_new(). 8567 * eve: The handle to the event returned by dw_event_new().
8553 */ 8568 */
8554 int API dw_event_wait(HEV eve, unsigned long timeout) 8569 int API dw_event_wait(HEV eve, unsigned long timeout)
8555 { 8570 {
8556 int rc = DosWaitEventSem(eve, timeout); 8571 int rc = DosWaitEventSem(eve, timeout);
8557 if(!rc) 8572 if(!rc)
8558 return 1; 8573 return 1;
8559 if(rc == ERROR_TIMEOUT) 8574 if(rc == ERROR_TIMEOUT)
8560 return -1; 8575 return -1;
8561 return 0; 8576 return 0;
8562 } 8577 }
8563 8578
8564 /* 8579 /*
8565 * Closes a semaphore created by dw_event_new(). 8580 * Closes a semaphore created by dw_event_new().
8566 * Parameters: 8581 * Parameters:
8567 * eve: The handle to the event returned by dw_event_new(). 8582 * eve: The handle to the event returned by dw_event_new().
8568 */ 8583 */
8569 int API dw_event_close(HEV *eve) 8584 int API dw_event_close(HEV *eve)
8570 { 8585 {
8571 if(!eve || ~DosCloseEventSem(*eve)) 8586 if(!eve || ~DosCloseEventSem(*eve))
8572 return FALSE; 8587 return FALSE;
8573 return TRUE; 8588 return TRUE;
8574 } 8589 }
8575 8590
8576 /* Create a named event semaphore which can be 8591 /* Create a named event semaphore which can be
8577 * opened from other processes. 8592 * opened from other processes.
8578 * Parameters: 8593 * Parameters:
8580 * name: Name given to semaphore which can be opened 8595 * name: Name given to semaphore which can be opened
8581 * by other processes. 8596 * by other processes.
8582 */ 8597 */
8583 HEV API dw_named_event_new(char *name) 8598 HEV API dw_named_event_new(char *name)
8584 { 8599 {
8585 char *semname = malloc(strlen(name)+8); 8600 char *semname = malloc(strlen(name)+8);
8586 HEV ev = 0; 8601 HEV ev = 0;
8587 8602
8588 if(!semname) 8603 if(!semname)
8589 return 0; 8604 return 0;
8590 8605
8591 strcpy(semname, "\\sem32\\"); 8606 strcpy(semname, "\\sem32\\");
8592 strcat(semname, name); 8607 strcat(semname, name);
8593 8608
8594 DosCreateEventSem(semname, &ev, 0L, FALSE); 8609 DosCreateEventSem(semname, &ev, 0L, FALSE);
8595 8610
8596 free(semname); 8611 free(semname);
8597 return ev; 8612 return ev;
8598 } 8613 }
8599 8614
8600 /* Open an already existing named event semaphore. 8615 /* Open an already existing named event semaphore.
8601 * Parameters: 8616 * Parameters:
8602 * eve: Pointer to an event handle to receive handle. 8617 * eve: Pointer to an event handle to receive handle.
8603 * name: Name given to semaphore which can be opened 8618 * name: Name given to semaphore which can be opened
8604 * by other processes. 8619 * by other processes.
8605 */ 8620 */
8606 HEV API dw_named_event_get(char *name) 8621 HEV API dw_named_event_get(char *name)
8607 { 8622 {
8608 char *semname = malloc(strlen(name)+8); 8623 char *semname = malloc(strlen(name)+8);
8609 HEV ev; 8624 HEV ev;
8610 8625
8611 if(!semname) 8626 if(!semname)
8612 return 0; 8627 return 0;
8613 8628
8614 strcpy(semname, "\\sem32\\"); 8629 strcpy(semname, "\\sem32\\");
8615 strcat(semname, name); 8630 strcat(semname, name);
8616 8631
8617 DosOpenEventSem(semname, &ev); 8632 DosOpenEventSem(semname, &ev);
8618 8633
8619 free(semname); 8634 free(semname);
8620 return ev; 8635 return ev;
8621 } 8636 }
8622 8637
8623 /* Resets the event semaphore so threads who call wait 8638 /* Resets the event semaphore so threads who call wait
8624 * on this semaphore will block. 8639 * on this semaphore will block.
8625 * Parameters: 8640 * Parameters:
8626 * eve: Handle to the semaphore obtained by 8641 * eve: Handle to the semaphore obtained by
8627 * an open or create call. 8642 * an open or create call.
8628 */ 8643 */
8629 int API dw_named_event_reset(HEV eve) 8644 int API dw_named_event_reset(HEV eve)
8630 { 8645 {
8631 ULONG count; 8646 ULONG count;
8632 8647
8633 return DosResetEventSem(eve, &count); 8648 return DosResetEventSem(eve, &count);
8634 } 8649 }
8635 8650
8636 /* Sets the posted state of an event semaphore, any threads 8651 /* Sets the posted state of an event semaphore, any threads
8637 * waiting on the semaphore will no longer block. 8652 * waiting on the semaphore will no longer block.
8638 * Parameters: 8653 * Parameters:
8639 * eve: Handle to the semaphore obtained by 8654 * eve: Handle to the semaphore obtained by
8640 * an open or create call. 8655 * an open or create call.
8641 */ 8656 */
8642 int API dw_named_event_post(HEV eve) 8657 int API dw_named_event_post(HEV eve)
8643 { 8658 {
8644 return DosPostEventSem(eve); 8659 return DosPostEventSem(eve);
8645 } 8660 }
8646 8661
8647 8662
8648 /* Waits on the specified semaphore until it becomes 8663 /* Waits on the specified semaphore until it becomes
8649 * posted, or returns immediately if it already is posted. 8664 * posted, or returns immediately if it already is posted.
8653 * timeout: Number of milliseconds before timing out 8668 * timeout: Number of milliseconds before timing out
8654 * or -1 if indefinite. 8669 * or -1 if indefinite.
8655 */ 8670 */
8656 int API dw_named_event_wait(HEV eve, unsigned long timeout) 8671 int API dw_named_event_wait(HEV eve, unsigned long timeout)
8657 { 8672 {
8658 int rc; 8673 int rc;
8659 8674
8660 rc = DosWaitEventSem(eve, timeout); 8675 rc = DosWaitEventSem(eve, timeout);
8661 switch (rc) 8676 switch (rc)
8662 { 8677 {
8663 case ERROR_INVALID_HANDLE: 8678 case ERROR_INVALID_HANDLE:
8664 rc = DW_ERROR_NON_INIT; 8679 rc = DW_ERROR_NON_INIT;
8665 break; 8680 break;
8666 case ERROR_NOT_ENOUGH_MEMORY: 8681 case ERROR_NOT_ENOUGH_MEMORY:
8667 rc = DW_ERROR_NO_MEM; 8682 rc = DW_ERROR_NO_MEM;
8668 break; 8683 break;
8669 case ERROR_INTERRUPT: 8684 case ERROR_INTERRUPT:
8670 rc = DW_ERROR_INTERRUPT; 8685 rc = DW_ERROR_INTERRUPT;
8671 break; 8686 break;
8672 case ERROR_TIMEOUT: 8687 case ERROR_TIMEOUT:
8673 rc = DW_ERROR_TIMEOUT; 8688 rc = DW_ERROR_TIMEOUT;
8674 break; 8689 break;
8675 } 8690 }
8676 8691
8677 return rc; 8692 return rc;
8678 } 8693 }
8679 8694
8680 /* Release this semaphore, if there are no more open 8695 /* Release this semaphore, if there are no more open
8681 * handles on this semaphore the semaphore will be destroyed. 8696 * handles on this semaphore the semaphore will be destroyed.
8682 * Parameters: 8697 * Parameters:
8683 * eve: Handle to the semaphore obtained by 8698 * eve: Handle to the semaphore obtained by
8684 * an open or create call. 8699 * an open or create call.
8685 */ 8700 */
8686 int API dw_named_event_close(HEV eve) 8701 int API dw_named_event_close(HEV eve)
8687 { 8702 {
8688 int rc; 8703 int rc;
8689 8704
8690 rc = DosCloseEventSem(eve); 8705 rc = DosCloseEventSem(eve);
8691 switch (rc) 8706 switch (rc)
8692 { 8707 {
8693 case ERROR_INVALID_HANDLE: 8708 case ERROR_INVALID_HANDLE:
8694 rc = DW_ERROR_NON_INIT; 8709 rc = DW_ERROR_NON_INIT;
8695 break; 8710 break;
8696 8711
8697 case ERROR_SEM_BUSY: 8712 case ERROR_SEM_BUSY:
8698 rc = DW_ERROR_INTERRUPT; 8713 rc = DW_ERROR_INTERRUPT;
8699 break; 8714 break;
8700 } 8715 }
8701 8716
8702 return rc; 8717 return rc;
8703 } 8718 }
8704 8719
8705 /* 8720 /*
8706 * Allocates a shared memory region with a name. 8721 * Allocates a shared memory region with a name.
8707 * Parameters: 8722 * Parameters:
8710 * size: Size in bytes of the shared memory region to allocate. 8725 * size: Size in bytes of the shared memory region to allocate.
8711 * name: A string pointer to a unique memory name. 8726 * name: A string pointer to a unique memory name.
8712 */ 8727 */
8713 HSHM API dw_named_memory_new(void **dest, int size, char *name) 8728 HSHM API dw_named_memory_new(void **dest, int size, char *name)
8714 { 8729 {
8715 char namebuf[1024]; 8730 char namebuf[1024];
8716 8731
8717 sprintf(namebuf, "\\sharemem\\%s", name); 8732 sprintf(namebuf, "\\sharemem\\%s", name);
8718 8733
8719 if(DosAllocSharedMem((void *)dest, namebuf, size, PAG_COMMIT | PAG_WRITE | PAG_READ) != NO_ERROR) 8734 if(DosAllocSharedMem((void *)dest, namebuf, size, PAG_COMMIT | PAG_WRITE | PAG_READ) != NO_ERROR)
8720 return 0; 8735 return 0;
8721 8736
8722 return 1; 8737 return 1;
8723 } 8738 }
8724 8739
8725 /* 8740 /*
8726 * Aquires shared memory region with a name. 8741 * Aquires shared memory region with a name.
8727 * Parameters: 8742 * Parameters:
8729 * size: Size in bytes of the shared memory region to requested. 8744 * size: Size in bytes of the shared memory region to requested.
8730 * name: A string pointer to a unique memory name. 8745 * name: A string pointer to a unique memory name.
8731 */ 8746 */
8732 HSHM API dw_named_memory_get(void **dest, int size, char *name) 8747 HSHM API dw_named_memory_get(void **dest, int size, char *name)
8733 { 8748 {
8734 char namebuf[1024]; 8749 char namebuf[1024];
8735 8750
8736 size = size; 8751 size = size;
8737 sprintf(namebuf, "\\sharemem\\%s", name); 8752 sprintf(namebuf, "\\sharemem\\%s", name);
8738 8753
8739 if(DosGetNamedSharedMem((void *)dest, namebuf, PAG_READ | PAG_WRITE) != NO_ERROR) 8754 if(DosGetNamedSharedMem((void *)dest, namebuf, PAG_READ | PAG_WRITE) != NO_ERROR)
8740 return 0; 8755 return 0;
8741 8756
8742 return 1; 8757 return 1;
8743 } 8758 }
8744 8759
8745 /* 8760 /*
8746 * Frees a shared memory region previously allocated. 8761 * Frees a shared memory region previously allocated.
8747 * Parameters: 8762 * Parameters:
8748 * handle: Handle obtained from DB_named_memory_allocate. 8763 * handle: Handle obtained from DB_named_memory_allocate.
8749 * ptr: The memory address aquired with DB_named_memory_allocate. 8764 * ptr: The memory address aquired with DB_named_memory_allocate.
8750 */ 8765 */
8751 int API dw_named_memory_free(HSHM handle, void *ptr) 8766 int API dw_named_memory_free(HSHM handle, void *ptr)
8752 { 8767 {
8753 handle = handle; 8768 handle = handle;
8754 8769
8755 if(DosFreeMem(ptr) != NO_ERROR) 8770 if(DosFreeMem(ptr) != NO_ERROR)
8756 return -1; 8771 return -1;
8757 return 0; 8772 return 0;
8758 } 8773 }
8759 8774
8760 /* 8775 /*
8761 * Encapsulate the message queues on OS/2. 8776 * Encapsulate the message queues on OS/2.
8762 */ 8777 */
8763 void _dwthreadstart(void *data) 8778 void _dwthreadstart(void *data)
8764 { 8779 {
8765 HAB thishab = WinInitialize(0); 8780 HAB thishab = WinInitialize(0);
8766 HMQ thishmq = WinCreateMsgQueue(dwhab, 0); 8781 HMQ thishmq = WinCreateMsgQueue(dwhab, 0);
8767 void (* API threadfunc)(void *) = NULL; 8782 void (* API threadfunc)(void *) = NULL;
8768 void **tmp = (void **)data; 8783 void **tmp = (void **)data;
8769 8784
8770 threadfunc = (void (* API)(void *))tmp[0]; 8785 threadfunc = (void (* API)(void *))tmp[0];
8771 threadfunc(tmp[1]); 8786 threadfunc(tmp[1]);
8772 8787
8773 free(tmp); 8788 free(tmp);
8774 8789
8775 WinDestroyMsgQueue(thishmq); 8790 WinDestroyMsgQueue(thishmq);
8776 WinTerminate(thishab); 8791 WinTerminate(thishab);
8777 } 8792 }
8778 8793
8779 /* 8794 /*
8780 * Creates a new thread with a starting point of func. 8795 * Creates a new thread with a starting point of func.
8781 * Parameters: 8796 * Parameters:
8783 * data: Parameter(s) passed to the function. 8798 * data: Parameter(s) passed to the function.
8784 * stack: Stack size of new thread (OS/2 and Windows only). 8799 * stack: Stack size of new thread (OS/2 and Windows only).
8785 */ 8800 */
8786 DWTID API dw_thread_new(void *func, void *data, int stack) 8801 DWTID API dw_thread_new(void *func, void *data, int stack)
8787 { 8802 {
8788 void **tmp = malloc(sizeof(void *) * 2); 8803 void **tmp = malloc(sizeof(void *) * 2);
8789 8804
8790 tmp[0] = func; 8805 tmp[0] = func;
8791 tmp[1] = data; 8806 tmp[1] = data;
8792 8807
8793 return (DWTID)_beginthread((void (*)(void *))_dwthreadstart, NULL, stack, (void *)tmp); 8808 return (DWTID)_beginthread((void (*)(void *))_dwthreadstart, NULL, stack, (void *)tmp);
8794 } 8809 }
8795 8810
8796 /* 8811 /*
8797 * Ends execution of current thread immediately. 8812 * Ends execution of current thread immediately.
8798 */ 8813 */
8799 void API dw_thread_end(void) 8814 void API dw_thread_end(void)
8800 { 8815 {
8801 _endthread(); 8816 _endthread();
8802 } 8817 }
8803 8818
8804 /* 8819 /*
8805 * Returns the current thread's ID. 8820 * Returns the current thread's ID.
8806 */ 8821 */
8807 DWTID API dw_thread_id(void) 8822 DWTID API dw_thread_id(void)
8808 { 8823 {
8809 return (DWTID)_threadid; 8824 return (DWTID)_threadid;
8810 } 8825 }
8811 8826
8812 /* 8827 /*
8813 * Cleanly terminates a DW session, should be signal handler safe. 8828 * Cleanly terminates a DW session, should be signal handler safe.
8814 * Parameters: 8829 * Parameters:
8815 * exitcode: Exit code reported to the operating system. 8830 * exitcode: Exit code reported to the operating system.
8816 */ 8831 */
8817 void API dw_exit(int exitcode) 8832 void API dw_exit(int exitcode)
8818 { 8833 {
8819 /* Destroy the menu message window */ 8834 /* Destroy the menu message window */
8820 dw_window_destroy(hwndApp); 8835 dw_window_destroy(hwndApp);
8821 8836
8822 /* In case we are in a signal handler, don't 8837 /* In case we are in a signal handler, don't
8823 * try to free memory that could possibly be 8838 * try to free memory that could possibly be
8824 * free()'d by the runtime already. 8839 * free()'d by the runtime already.
8825 */ 8840 */
8826 Root = NULL; 8841 Root = NULL;
8827 8842
8828 DosFreeModule(wpconfig); 8843 DosFreeModule(wpconfig);
8829 exit(exitcode); 8844 exit(exitcode);
8830 } 8845 }
8831 8846
8832 /* 8847 /*
8833 * Creates a splitbar window (widget) with given parameters. 8848 * Creates a splitbar window (widget) with given parameters.
8834 * Parameters: 8849 * Parameters:
8838 * Returns: 8853 * Returns:
8839 * A handle to a splitbar window or NULL on failure. 8854 * A handle to a splitbar window or NULL on failure.
8840 */ 8855 */
8841 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id) 8856 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id)
8842 { 8857 {
8843 HWND tmp = WinCreateWindow(HWND_OBJECT, 8858 HWND tmp = WinCreateWindow(HWND_OBJECT,
8844 SplitbarClassName, 8859 SplitbarClassName,
8845 NULL, 8860 NULL,
8846 WS_VISIBLE | WS_CLIPCHILDREN, 8861 WS_VISIBLE | WS_CLIPCHILDREN,
8847 0,0,2000,1000, 8862 0,0,2000,1000,
8848 NULLHANDLE, 8863 NULLHANDLE,
8849 HWND_TOP, 8864 HWND_TOP,
8850 id, 8865 id,
8851 NULL, 8866 NULL,
8852 NULL); 8867 NULL);
8853 if(tmp) 8868 if(tmp)
8854 { 8869 {
8855 HWND tmpbox = dw_box_new(DW_VERT, 0); 8870 HWND tmpbox = dw_box_new(DW_VERT, 0);
8856 float *percent = malloc(sizeof(float)); 8871 float *percent = malloc(sizeof(float));
8857 8872
8858 dw_box_pack_start(tmpbox, topleft, 1, 1, TRUE, TRUE, 0); 8873 dw_box_pack_start(tmpbox, topleft, 1, 1, TRUE, TRUE, 0);
8859 WinSetParent(tmpbox, tmp, FALSE); 8874 WinSetParent(tmpbox, tmp, FALSE);
8860 dw_window_set_data(tmp, "_dw_topleft", (void *)tmpbox); 8875 dw_window_set_data(tmp, "_dw_topleft", (void *)tmpbox);
8861 8876
8862 tmpbox = dw_box_new(DW_VERT, 0); 8877 tmpbox = dw_box_new(DW_VERT, 0);
8863 dw_box_pack_start(tmpbox, bottomright, 1, 1, TRUE, TRUE, 0); 8878 dw_box_pack_start(tmpbox, bottomright, 1, 1, TRUE, TRUE, 0);
8864 WinSetParent(tmpbox, tmp, FALSE); 8879 WinSetParent(tmpbox, tmp, FALSE);
8865 *percent = 50.0; 8880 *percent = 50.0;
8866 dw_window_set_data(tmp, "_dw_bottomright", (void *)tmpbox); 8881 dw_window_set_data(tmp, "_dw_bottomright", (void *)tmpbox);
8867 dw_window_set_data(tmp, "_dw_percent", (void *)percent); 8882 dw_window_set_data(tmp, "_dw_percent", (void *)percent);
8868 dw_window_set_data(tmp, "_dw_type", (void *)type); 8883 dw_window_set_data(tmp, "_dw_type", (void *)type);
8869 } 8884 }
8870 return tmp; 8885 return tmp;
8871 } 8886 }
8872 8887
8873 /* 8888 /*
8874 * Sets the position of a splitbar (pecentage). 8889 * Sets the position of a splitbar (pecentage).
8875 * Parameters: 8890 * Parameters:
8876 * handle: The handle to the splitbar returned by dw_splitbar_new(). 8891 * handle: The handle to the splitbar returned by dw_splitbar_new().
8877 */ 8892 */
8878 void API dw_splitbar_set(HWND handle, float percent) 8893 void API dw_splitbar_set(HWND handle, float percent)
8879 { 8894 {
8880 float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent"); 8895 float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent");
8881 int type = (int)dw_window_get_data(handle, "_dw_type"); 8896 int type = (int)dw_window_get_data(handle, "_dw_type");
8882 unsigned long width, height; 8897 unsigned long width, height;
8883 8898
8884 if(mypercent) 8899 if(mypercent)
8885 *mypercent = percent; 8900 *mypercent = percent;
8886 8901
8887 dw_window_get_pos_size(handle, NULL, NULL, &width, &height); 8902 dw_window_get_pos_size(handle, NULL, NULL, &width, &height);
8888 8903
8889 _handle_splitbar_resize(handle, percent, type, width, height); 8904 _handle_splitbar_resize(handle, percent, type, width, height);
8890 } 8905 }
8891 8906
8892 /* 8907 /*
8893 * Gets the position of a splitbar (pecentage). 8908 * Gets the position of a splitbar (pecentage).
8894 * Parameters: 8909 * Parameters:
8895 * handle: The handle to the splitbar returned by dw_splitbar_new(). 8910 * handle: The handle to the splitbar returned by dw_splitbar_new().
8896 */ 8911 */
8897 float API dw_splitbar_get(HWND handle) 8912 float API dw_splitbar_get(HWND handle)
8898 { 8913 {
8899 float *percent = (float *)dw_window_get_data(handle, "_dw_percent"); 8914 float *percent = (float *)dw_window_get_data(handle, "_dw_percent");
8900 8915
8901 if(percent) 8916 if(percent)
8902 return *percent; 8917 return *percent;
8903 return 0.0; 8918 return 0.0;
8904 } 8919 }
8905 8920
8906 /* 8921 /*
8907 * Pack windows (widgets) into a box from the start (or top). 8922 * Pack windows (widgets) into a box from the start (or top).
8908 * Parameters: 8923 * Parameters:
8914 * vsize: TRUE if the window (widget) should expand vertically to fill space given. 8929 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
8915 * pad: Number of pixels of padding around the item. 8930 * pad: Number of pixels of padding around the item.
8916 */ 8931 */
8917 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) 8932 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
8918 { 8933 {
8919 char *funcname = "dw_box_pack_start()"; 8934 char *funcname = "dw_box_pack_start()";
8920 8935
8921 /* 8936 /*
8922 * If you try and pack an item into itself VERY bad things can happen; like at least an 8937 * If you try and pack an item into itself VERY bad things can happen; like at least an
8923 * infinite loop on GTK! Lets be safe! 8938 * infinite loop on GTK! Lets be safe!
8924 */ 8939 */
8925 if(box == item) 8940 if(box == item)
8926 { 8941 {
8927 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!"); 8942 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!");
8928 return; 8943 return;
8929 } 8944 }
8930 8945
8931 if(WinWindowFromID(box, FID_CLIENT)) 8946 if(WinWindowFromID(box, FID_CLIENT))
8932 { 8947 {
8933 box = WinWindowFromID(box, FID_CLIENT); 8948 box = WinWindowFromID(box, FID_CLIENT);
8934 hsize = TRUE; 8949 hsize = TRUE;
8935 vsize = TRUE; 8950 vsize = TRUE;
8936 } 8951 }
8937 _dw_box_pack_start(box, item, width, height, hsize, vsize, pad, funcname); 8952 _dw_box_pack_start(box, item, width, height, hsize, vsize, pad, funcname);
8938 } 8953 }
8939 8954
8940 void _dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad, char *functionname) 8955 void _dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad, char *functionname)
8941 { 8956 {
8942 Box *thisbox = WinQueryWindowPtr(box, QWP_USER); 8957 Box *thisbox = WinQueryWindowPtr(box, QWP_USER);
8943 8958
8944 if(thisbox) 8959 if(thisbox)
8945 { 8960 {
8946 int z; 8961 int z;
8947 Item *tmpitem, *thisitem = thisbox->items; 8962 Item *tmpitem, *thisitem = thisbox->items;
8948 char tmpbuf[100]; 8963 char tmpbuf[100];
8949 HWND frame = (HWND)dw_window_get_data(item, "_dw_combo_box"); 8964 HWND frame = (HWND)dw_window_get_data(item, "_dw_combo_box");
8950 8965
8951 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); 8966 tmpitem = malloc(sizeof(Item)*(thisbox->count+1));
8952 8967
8953 for(z=0;z<thisbox->count;z++) 8968 for(z=0;z<thisbox->count;z++)
8954 { 8969 {
8955 tmpitem[z] = thisitem[z]; 8970 tmpitem[z] = thisitem[z];
8956 } 8971 }
8957 8972
8958 WinQueryClassName(item, 99, tmpbuf); 8973 WinQueryClassName(item, 99, tmpbuf);
8959 8974
8960 if(vsize && !height) 8975 if(vsize && !height)
8961 height = 1; 8976 height = 1;
8962 if(hsize && !width) 8977 if(hsize && !width)
8963 width = 1; 8978 width = 1;
8964 8979
8965 if(strncmp(tmpbuf, "#1", 3)==0) 8980 if(strncmp(tmpbuf, "#1", 3)==0)
8966 tmpitem[thisbox->count].type = TYPEBOX; 8981 tmpitem[thisbox->count].type = TYPEBOX;
8967 else 8982 else
8968 { 8983 {
8969 if ( width == 0 && hsize == FALSE ) 8984 if ( width == 0 && hsize == FALSE )
8970 dw_messagebox(functionname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item); 8985 dw_messagebox(functionname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item);
8971 if ( height == 0 && vsize == FALSE ) 8986 if ( height == 0 && vsize == FALSE )
8972 dw_messagebox(functionname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item); 8987 dw_messagebox(functionname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item);
8973 8988
8974 tmpitem[thisbox->count].type = TYPEITEM; 8989 tmpitem[thisbox->count].type = TYPEITEM;
8975 } 8990 }
8976 8991
8977 tmpitem[thisbox->count].hwnd = item; 8992 tmpitem[thisbox->count].hwnd = item;
8978 tmpitem[thisbox->count].origwidth = tmpitem[thisbox->count].width = width; 8993 tmpitem[thisbox->count].origwidth = tmpitem[thisbox->count].width = width;
8979 tmpitem[thisbox->count].origheight = tmpitem[thisbox->count].height = height; 8994 tmpitem[thisbox->count].origheight = tmpitem[thisbox->count].height = height;
8980 tmpitem[thisbox->count].pad = pad; 8995 tmpitem[thisbox->count].pad = pad;
8981 if(hsize) 8996 if(hsize)
8982 tmpitem[thisbox->count].hsize = SIZEEXPAND; 8997 tmpitem[thisbox->count].hsize = SIZEEXPAND;
8983 else 8998 else
8984 tmpitem[thisbox->count].hsize = SIZESTATIC; 8999 tmpitem[thisbox->count].hsize = SIZESTATIC;
8985 9000
8986 if(vsize) 9001 if(vsize)
8987 tmpitem[thisbox->count].vsize = SIZEEXPAND; 9002 tmpitem[thisbox->count].vsize = SIZEEXPAND;
8988 else 9003 else
8989 tmpitem[thisbox->count].vsize = SIZESTATIC; 9004 tmpitem[thisbox->count].vsize = SIZESTATIC;
8990 9005
8991 thisbox->items = tmpitem; 9006 thisbox->items = tmpitem;
8992 9007
8993 if(thisbox->count) 9008 if(thisbox->count)
8994 free(thisitem); 9009 free(thisitem);
8995 9010
8996 thisbox->count++; 9011 thisbox->count++;
8997 9012
8998 /* Don't set the ownership if it's an entryfield or spinbutton */ 9013 /* Don't set the ownership if it's an entryfield or spinbutton */
8999 WinQueryClassName(item, 99, tmpbuf); 9014 WinQueryClassName(item, 99, tmpbuf);
9000 if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 4)!=0 && strncmp(tmpbuf, "#2", 3)!=0) 9015 if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 4)!=0 && strncmp(tmpbuf, "#2", 3)!=0)
9001 WinSetOwner(item, box); 9016 WinSetOwner(item, box);
9002 WinSetParent(frame ? frame : item, box, FALSE); 9017 WinSetParent(frame ? frame : item, box, FALSE);
9003 } 9018 }
9004 } 9019 }
9005 9020
9006 /* The following two functions graciously contributed by Peter Nielsen. */ 9021 /* The following two functions graciously contributed by Peter Nielsen. */
9007 static ULONG _ParseBuildLevel (char* pchBuffer, ULONG ulSize) { 9022 static ULONG _ParseBuildLevel (char* pchBuffer, ULONG ulSize) {
9008 char* pchStart = pchBuffer; 9023 char* pchStart = pchBuffer;
9009 char* pchEnd = pchStart + ulSize - 2; 9024 char* pchEnd = pchStart + ulSize - 2;
9010 9025
9011 while (pchEnd >= pchStart) 9026 while (pchEnd >= pchStart)
9012 { 9027 {
9013 if ((pchEnd[0] == '#') && (pchEnd[1] == '@')) 9028 if ((pchEnd[0] == '#') && (pchEnd[1] == '@'))
9014 { 9029 {
9015 *pchEnd-- = '\0'; 9030 *pchEnd-- = '\0';
9016 while (pchEnd >= pchStart) 9031 while (pchEnd >= pchStart)
9017 { 9032 {
9018 if ((pchEnd[0] == '@') && (pchEnd[1] == '#')) 9033 if ((pchEnd[0] == '@') && (pchEnd[1] == '#'))
9019 { 9034 {
9020 ULONG ulMajor = 0; 9035 ULONG ulMajor = 0;
9021 ULONG ulMinor = 0; 9036 ULONG ulMinor = 0;
9022 9037
9023 char* pch = pchEnd + 2; 9038 char* pch = pchEnd + 2;
9024 while (!isdigit ((int)*pch) && *pch) 9039 while (!isdigit ((int)*pch) && *pch)
9025 pch++; 9040 pch++;
9026 9041
9027 while (isdigit ((int)*pch)) 9042 while (isdigit ((int)*pch))
9028 ulMajor = ulMajor * 10 + *pch++ - '0'; 9043 ulMajor = ulMajor * 10 + *pch++ - '0';
9029 9044
9030 if (*pch == '.') 9045 if (*pch == '.')
9031 { 9046 {
9032 while (isdigit ((int)*++pch)) 9047 while (isdigit ((int)*++pch))
9033 ulMinor = ulMinor * 10 + *pch - '0'; 9048 ulMinor = ulMinor * 10 + *pch - '0';
9034 } 9049 }
9035 return ((ulMajor << 16) | ulMinor); 9050 return ((ulMajor << 16) | ulMinor);
9036 } 9051 }
9037 pchEnd--; 9052 pchEnd--;
9038 } 9053 }
9039 } 9054 }
9040 pchEnd--; 9055 pchEnd--;
9041 } 9056 }
9042 return (0); 9057 return (0);
9043 } 9058 }
9044 9059
9045 ULONG _GetSystemBuildLevel(void) { 9060 ULONG _GetSystemBuildLevel(void) {
9046 /* The build level info is normally available in the end of the OS2KRNL file. However, this is not the case in some beta versions of OS/2. 9061 /* The build level info is normally available in the end of the OS2KRNL file. However, this is not the case in some beta versions of OS/2.
9047 * We first try to find the info in the 256 last bytes of the file. If that fails, we load the entire file and search it completely. 9062 * We first try to find the info in the 256 last bytes of the file. If that fails, we load the entire file and search it completely.
9048 */ 9063 */
9049 ULONG ulBootDrive = 0; 9064 ULONG ulBootDrive = 0;
9050 ULONG ulBuild = 0; 9065 ULONG ulBuild = 0;
9051 if (DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive, sizeof (ulBootDrive)) == NO_ERROR) 9066 if (DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive, sizeof (ulBootDrive)) == NO_ERROR)
9052 { 9067 {
9053 char achFileName[11] = "C:\\OS2KRNL"; 9068 char achFileName[11] = "C:\\OS2KRNL";
9054 HFILE hfile; 9069 HFILE hfile;
9055 ULONG ulResult; 9070 ULONG ulResult;
9056 9071
9057 achFileName[0] = (char)('A'+ulBootDrive-1); 9072 achFileName[0] = (char)('A'+ulBootDrive-1);
9058 9073
9059 if (DosOpen (achFileName, &hfile, &ulResult, 0, 0, OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL) == NO_ERROR) 9074 if (DosOpen (achFileName, &hfile, &ulResult, 0, 0, OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL) == NO_ERROR)
9060 { 9075 {
9061 ULONG ulFileSize = 0; 9076 ULONG ulFileSize = 0;
9062 if (DosSetFilePtr (hfile, 0, FILE_END, &ulFileSize) == NO_ERROR) 9077 if (DosSetFilePtr (hfile, 0, FILE_END, &ulFileSize) == NO_ERROR)
9063 { 9078 {
9064 const ULONG ulFirstTry = min (256, ulFileSize); 9079 const ULONG ulFirstTry = min (256, ulFileSize);
9065 if (DosSetFilePtr (hfile, -(LONG)ulFirstTry, FILE_END, &ulResult) == NO_ERROR) 9080 if (DosSetFilePtr (hfile, -(LONG)ulFirstTry, FILE_END, &ulResult) == NO_ERROR)
9066 { 9081 {
9067 char *pchBuffer = malloc(ulFirstTry); 9082 char *pchBuffer = malloc(ulFirstTry);
9068 if (DosRead (hfile, pchBuffer, ulFirstTry, &ulResult) == NO_ERROR) 9083 if (DosRead (hfile, pchBuffer, ulFirstTry, &ulResult) == NO_ERROR)
9069 { 9084 {
9070 ulBuild = _ParseBuildLevel (pchBuffer, ulFirstTry); 9085 ulBuild = _ParseBuildLevel (pchBuffer, ulFirstTry);
9071 if (ulBuild == 0) 9086 if (ulBuild == 0)
9072 { 9087 {
9073 if (DosSetFilePtr (hfile, 0, FILE_BEGIN, &ulResult) == NO_ERROR) 9088 if (DosSetFilePtr (hfile, 0, FILE_BEGIN, &ulResult) == NO_ERROR)
9074 { 9089 {
9075 free(pchBuffer); 9090 free(pchBuffer);
9076 pchBuffer = malloc(ulFileSize); 9091 pchBuffer = malloc(ulFileSize);
9077 9092
9078 if (DosRead (hfile, pchBuffer, ulFileSize, &ulResult) == NO_ERROR) 9093 if (DosRead (hfile, pchBuffer, ulFileSize, &ulResult) == NO_ERROR)
9079 ulBuild = _ParseBuildLevel (pchBuffer, ulFileSize); 9094 ulBuild = _ParseBuildLevel (pchBuffer, ulFileSize);
9080 } 9095 }
9081 } 9096 }
9082 } 9097 }
9083 free(pchBuffer); 9098 free(pchBuffer);
9084 } 9099 }
9085 } 9100 }
9086 DosClose (hfile); 9101 DosClose (hfile);
9087 } 9102 }
9088 } 9103 }
9089 return (ulBuild); 9104 return (ulBuild);
9090 } 9105 }
9091 9106
9092 /* 9107 /*
9093 * Sets the default focus item for a window/dialog. 9108 * Sets the default focus item for a window/dialog.
9094 * Parameters: 9109 * Parameters:
9095 * window: Toplevel window or dialog. 9110 * window: Toplevel window or dialog.
9096 * defaultitem: Handle to the dialog item to be default. 9111 * defaultitem: Handle to the dialog item to be default.
9097 */ 9112 */
9098 void API dw_window_default(HWND window, HWND defaultitem) 9113 void API dw_window_default(HWND window, HWND defaultitem)
9099 { 9114 {
9100 Box *thisbox = NULL; 9115 Box *thisbox = NULL;
9101 HWND box; 9116 HWND box;
9102 9117
9103 box = WinWindowFromID(window, FID_CLIENT); 9118 box = WinWindowFromID(window, FID_CLIENT);
9104 if(box) 9119 if(box)
9105 thisbox = WinQueryWindowPtr(box, QWP_USER); 9120 thisbox = WinQueryWindowPtr(box, QWP_USER);
9106 9121
9107 if(thisbox) 9122 if(thisbox)
9108 thisbox->defaultitem = defaultitem; 9123 thisbox->defaultitem = defaultitem;
9109 } 9124 }
9110 9125
9111 /* 9126 /*
9112 * Sets window to click the default dialog item when an ENTER is pressed. 9127 * Sets window to click the default dialog item when an ENTER is pressed.
9113 * Parameters: 9128 * Parameters:
9114 * window: Window (widget) to look for the ENTER press. 9129 * window: Window (widget) to look for the ENTER press.
9115 * next: Window (widget) to move to next (or click) 9130 * next: Window (widget) to move to next (or click)
9116 */ 9131 */
9117 void API dw_window_click_default(HWND window, HWND next) 9132 void API dw_window_click_default(HWND window, HWND next)
9118 { 9133 {
9119 WindowData *blah = (WindowData *)WinQueryWindowPtr(window, QWP_USER); 9134 WindowData *blah = (WindowData *)WinQueryWindowPtr(window, QWP_USER);
9120 9135
9121 if(blah) 9136 if(blah)
9122 blah->clickdefault = next; 9137 blah->clickdefault = next;
9123 } 9138 }
9124 9139
9125 /* 9140 /*
9126 * Gets the contents of the default clipboard as text. 9141 * Gets the contents of the default clipboard as text.
9127 * INCOMPLETE 9142 * INCOMPLETE
9152 * Parameters: 9167 * Parameters:
9153 * env: Pointer to a DWEnv struct. 9168 * env: Pointer to a DWEnv struct.
9154 */ 9169 */
9155 void API dw_environment_query(DWEnv *env) 9170 void API dw_environment_query(DWEnv *env)
9156 { 9171 {
9157 ULONG Build; 9172 ULONG Build;
9158 9173
9159 if(!env) 9174 if(!env)
9160 return; 9175 return;
9161 9176
9162 /* The default is OS/2 2.0 */ 9177 /* The default is OS/2 2.0 */
9163 strcpy(env->osName,"OS/2"); 9178 strcpy(env->osName,"OS/2");
9164 env->MajorVersion = 2; 9179 env->MajorVersion = 2;
9165 env->MinorVersion = 0; 9180 env->MinorVersion = 0;
9166 9181
9167 Build = _GetSystemBuildLevel(); 9182 Build = _GetSystemBuildLevel();
9168 env->MinorBuild = Build & 0xFFFF; 9183 env->MinorBuild = Build & 0xFFFF;
9169 env->MajorBuild = Build >> 16; 9184 env->MajorBuild = Build >> 16;
9170 9185
9171 if (aulBuffer[0] == 20) 9186 if (aulBuffer[0] == 20)
9172 { 9187 {
9173 int i = (unsigned int)aulBuffer[1]; 9188 int i = (unsigned int)aulBuffer[1];
9174 if (i > 20) 9189 if (i > 20)
9175 { 9190 {
9176 strcpy(env->osName,"Warp"); 9191 strcpy(env->osName,"Warp");
9177 env->MajorVersion = (int)i/10; 9192 env->MajorVersion = (int)i/10;
9178 env->MinorVersion = i-(((int)i/10)*10); 9193 env->MinorVersion = i-(((int)i/10)*10);
9179 } 9194 }
9180 else if (i == 10) 9195 else if (i == 10)
9181 env->MinorVersion = 1; 9196 env->MinorVersion = 1;
9182 } 9197 }
9183 strcpy(env->buildDate, __DATE__); 9198 strcpy(env->buildDate, __DATE__);
9184 strcpy(env->buildTime, __TIME__); 9199 strcpy(env->buildTime, __TIME__);
9185 env->DWMajorVersion = DW_MAJOR_VERSION; 9200 env->DWMajorVersion = DW_MAJOR_VERSION;
9186 env->DWMinorVersion = DW_MINOR_VERSION; 9201 env->DWMinorVersion = DW_MINOR_VERSION;
9187 env->DWSubVersion = DW_SUB_VERSION; 9202 env->DWSubVersion = DW_SUB_VERSION;
9188 } 9203 }
9189 9204
9190 /* The next few functions are support functions for the OS/2 folder browser */ 9205 /* The next few functions are support functions for the OS/2 folder browser */
9191 void _populate_directory(HWND tree, HTREEITEM parent, char *path) 9206 void _populate_directory(HWND tree, HTREEITEM parent, char *path)
9192 { 9207 {
9193 FILEFINDBUF3 ffbuf; 9208 FILEFINDBUF3 ffbuf;
9194 HTREEITEM item; 9209 HTREEITEM item;
9195 ULONG count = 1; 9210 ULONG count = 1;
9196 HDIR hdir = HDIR_CREATE; 9211 HDIR hdir = HDIR_CREATE;
9197 9212
9198 if(DosFindFirst(path, &hdir, FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_ARCHIVED | MUST_HAVE_DIRECTORY, 9213 if(DosFindFirst(path, &hdir, FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_ARCHIVED | MUST_HAVE_DIRECTORY,
9199 &ffbuf, sizeof(FILEFINDBUF3), &count, FIL_STANDARD) == NO_ERROR) 9214 &ffbuf, sizeof(FILEFINDBUF3), &count, FIL_STANDARD) == NO_ERROR)
9200 { 9215 {
9201 while(DosFindNext(hdir, &ffbuf, sizeof(FILEFINDBUF3), &count) == NO_ERROR) 9216 while(DosFindNext(hdir, &ffbuf, sizeof(FILEFINDBUF3), &count) == NO_ERROR)
9202 { 9217 {
9203 if(strcmp(ffbuf.achName, ".") && strcmp(ffbuf.achName, "..")) 9218 if(strcmp(ffbuf.achName, ".") && strcmp(ffbuf.achName, ".."))
9204 { 9219 {
9205 int len = strlen(path); 9220 int len = strlen(path);
9206 char *folder = malloc(len + ffbuf.cchName + 2); 9221 char *folder = malloc(len + ffbuf.cchName + 2);
9207 HTREEITEM tempitem; 9222 HTREEITEM tempitem;
9208 9223
9209 strcpy(folder, path); 9224 strcpy(folder, path);
9210 strcpy(&folder[len-1], ffbuf.achName); 9225 strcpy(&folder[len-1], ffbuf.achName);
9211 9226
9212 item = dw_tree_insert(tree, ffbuf.achName, WinLoadFileIcon(folder, TRUE), parent, (void *)parent); 9227 item = dw_tree_insert(tree, ffbuf.achName, WinLoadFileIcon(folder, TRUE), parent, (void *)parent);
9213 tempitem = dw_tree_insert(tree, "", 0, item, 0); 9228 tempitem = dw_tree_insert(tree, "", 0, item, 0);
9214 dw_tree_item_set_data(tree, item, (void *)tempitem); 9229 dw_tree_item_set_data(tree, item, (void *)tempitem);
9215 } 9230 }
9216 } 9231 }
9217 DosFindClose(hdir); 9232 DosFindClose(hdir);
9218 } 9233 }
9219 } 9234 }
9220 9235
9221 void _populate_tree_thread(void *data) 9236 void _populate_tree_thread(void *data)
9222 { 9237 {
9223 HWND window = (HWND)data, tree = (HWND)dw_window_get_data(window, "_dw_tree"); 9238 HWND window = (HWND)data, tree = (HWND)dw_window_get_data(window, "_dw_tree");
9224 HMTX mtx = (HMTX)dw_window_get_data(window, "_dw_mutex"); 9239 HMTX mtx = (HMTX)dw_window_get_data(window, "_dw_mutex");
9225 int drive; 9240 int drive;
9226 HTREEITEM items[26]; 9241 HTREEITEM items[26];
9227 FSINFO volinfo; 9242 FSINFO volinfo;
9228 9243
9229 DosError(FERR_DISABLEHARDERR); 9244 DosError(FERR_DISABLEHARDERR);
9230 9245
9231 dw_mutex_lock(mtx); 9246 dw_mutex_lock(mtx);
9232 for(drive=0;drive<26;drive++) 9247 for(drive=0;drive<26;drive++)
9233 { 9248 {
9234 if(DosQueryFSInfo(drive+1, FSIL_VOLSER,(PVOID)&volinfo, sizeof(FSINFO)) == NO_ERROR) 9249 if(DosQueryFSInfo(drive+1, FSIL_VOLSER,(PVOID)&volinfo, sizeof(FSINFO)) == NO_ERROR)
9235 { 9250 {
9236 char folder[5] = "C:\\", name[9] = "Drive C:"; 9251 char folder[5] = "C:\\", name[9] = "Drive C:";
9237 HTREEITEM tempitem; 9252 HTREEITEM tempitem;
9238 9253
9239 folder[0] = name[6] = 'A' + drive; 9254 folder[0] = name[6] = 'A' + drive;
9240 9255
9241 items[drive] = dw_tree_insert(tree, name, WinLoadFileIcon(folder, TRUE), NULL, 0); 9256 items[drive] = dw_tree_insert(tree, name, WinLoadFileIcon(folder, TRUE), NULL, 0);
9242 tempitem = dw_tree_insert(tree, "", 0, items[drive], 0); 9257 tempitem = dw_tree_insert(tree, "", 0, items[drive], 0);
9243 dw_tree_item_set_data(tree, items[drive], (void *)tempitem); 9258 dw_tree_item_set_data(tree, items[drive], (void *)tempitem);
9244 } 9259 }
9245 else 9260 else
9246 items[drive] = 0; 9261 items[drive] = 0;
9247 } 9262 }
9248 dw_mutex_unlock(mtx); 9263 dw_mutex_unlock(mtx);
9249 9264
9250 DosError(FERR_ENABLEHARDERR); 9265 DosError(FERR_ENABLEHARDERR);
9251 } 9266 }
9252 9267
9253 int DWSIGNAL _dw_ok_func(HWND window, void *data) 9268 int DWSIGNAL _dw_ok_func(HWND window, void *data)
9254 { 9269 {
9255 DWDialog *dwwait = (DWDialog *)data; 9270 DWDialog *dwwait = (DWDialog *)data;
9256 HMTX mtx = (HMTX)dw_window_get_data((HWND)dwwait->data, "_dw_mutex"); 9271 HMTX mtx = (HMTX)dw_window_get_data((HWND)dwwait->data, "_dw_mutex");
9257 void *treedata; 9272 void *treedata;
9258 9273
9259 window = window; 9274 window = window;
9260 if(!dwwait) 9275 if(!dwwait)
9261 return FALSE; 9276 return FALSE;
9262 9277
9263 dw_mutex_lock(mtx); 9278 dw_mutex_lock(mtx);
9264 treedata = dw_window_get_data((HWND)dwwait->data, "_dw_tree_selected"); 9279 treedata = dw_window_get_data((HWND)dwwait->data, "_dw_tree_selected");
9265 dw_mutex_close(mtx); 9280 dw_mutex_close(mtx);
9266 dw_window_destroy((HWND)dwwait->data); 9281 dw_window_destroy((HWND)dwwait->data);
9267 dw_dialog_dismiss((DWDialog *)data, treedata); 9282 dw_dialog_dismiss((DWDialog *)data, treedata);
9268 return FALSE; 9283 return FALSE;
9269 } 9284 }
9270 9285
9271 int DWSIGNAL _dw_cancel_func(HWND window, void *data) 9286 int DWSIGNAL _dw_cancel_func(HWND window, void *data)
9272 { 9287 {
9273 DWDialog *dwwait = (DWDialog *)data; 9288 DWDialog *dwwait = (DWDialog *)data;
9274 HMTX mtx = (HMTX)dw_window_get_data((HWND)dwwait->data, "_dw_mutex"); 9289 HMTX mtx = (HMTX)dw_window_get_data((HWND)dwwait->data, "_dw_mutex");
9275 9290
9276 window = window; 9291 window = window;
9277 if(!dwwait) 9292 if(!dwwait)
9278 return FALSE; 9293 return FALSE;
9279 9294
9280 dw_mutex_lock(mtx); 9295 dw_mutex_lock(mtx);
9281 dw_mutex_close(mtx); 9296 dw_mutex_close(mtx);
9282 dw_window_destroy((HWND)dwwait->data); 9297 dw_window_destroy((HWND)dwwait->data);
9283 dw_dialog_dismiss((DWDialog *)data, NULL); 9298 dw_dialog_dismiss((DWDialog *)data, NULL);
9284 return FALSE; 9299 return FALSE;
9285 } 9300 }
9286 9301
9287 char *_tree_folder(HWND tree, HTREEITEM item) 9302 char *_tree_folder(HWND tree, HTREEITEM item)
9288 { 9303 {
9289 char *folder=strdup(""); 9304 char *folder=strdup("");
9290 HTREEITEM parent = item; 9305 HTREEITEM parent = item;
9291 9306
9292 while(parent) 9307 while(parent)
9293 { 9308 {
9294 char *temp, *text = dw_tree_get_title(tree, parent); 9309 char *temp, *text = dw_tree_get_title(tree, parent);
9295 9310
9296 if(text) 9311 if(text)
9297 { 9312 {
9298 if(strncmp(text, "Drive ", 6) == 0) 9313 if(strncmp(text, "Drive ", 6) == 0)
9299 text = &text[6]; 9314 text = &text[6];
9300 9315
9301 temp = malloc(strlen(text) + strlen(folder) + 3); 9316 temp = malloc(strlen(text) + strlen(folder) + 3);
9302 strcpy(temp, text); 9317 strcpy(temp, text);
9303 strcat(temp, "\\"); 9318 strcat(temp, "\\");
9304 strcat(temp, folder); 9319 strcat(temp, folder);
9305 free(folder); 9320 free(folder);
9306 folder = temp; 9321 folder = temp;
9307 } 9322 }
9308 parent = dw_tree_get_parent(tree, parent); 9323 parent = dw_tree_get_parent(tree, parent);
9309 } 9324 }
9310 return folder; 9325 return folder;
9311 } 9326 }
9312 9327
9313 int DWSIGNAL _item_select(HWND window, HTREEITEM item, char *text, void *data, void *itemdata) 9328 int DWSIGNAL _item_select(HWND window, HTREEITEM item, char *text, void *data, void *itemdata)
9314 { 9329 {
9315 DWDialog *dwwait = (DWDialog *)data; 9330 DWDialog *dwwait = (DWDialog *)data;
9316 char *treedata = (char *)dw_window_get_data((HWND)dwwait->data, "_dw_tree_selected"); 9331 char *treedata = (char *)dw_window_get_data((HWND)dwwait->data, "_dw_tree_selected");
9317 9332
9318 text = text; itemdata = itemdata; 9333 text = text; itemdata = itemdata;
9319 if(treedata) 9334 if(treedata)
9320 free(treedata); 9335 free(treedata);
9321 9336
9322 treedata = _tree_folder(window, item); 9337 treedata = _tree_folder(window, item);
9323 dw_window_set_data((HWND)dwwait->data, "_dw_tree_selected", (void *)treedata); 9338 dw_window_set_data((HWND)dwwait->data, "_dw_tree_selected", (void *)treedata);
9324 9339
9325 return FALSE; 9340 return FALSE;
9326 } 9341 }
9327 9342
9328 int DWSIGNAL _tree_expand(HWND window, HTREEITEM item, void *data) 9343 int DWSIGNAL _tree_expand(HWND window, HTREEITEM item, void *data)
9329 { 9344 {
9330 HTREEITEM tempitem = (HTREEITEM)dw_tree_item_get_data(window, item); 9345 HTREEITEM tempitem = (HTREEITEM)dw_tree_item_get_data(window, item);
9331 9346
9332 data = data; 9347 data = data;
9333 if(tempitem) 9348 if(tempitem)
9334 { 9349 {
9335 char *folder = _tree_folder(window, item); 9350 char *folder = _tree_folder(window, item);
9336 9351
9337 dw_tree_item_set_data(window, item, 0); 9352 dw_tree_item_set_data(window, item, 0);
9338 dw_tree_item_delete(window, tempitem); 9353 dw_tree_item_delete(window, tempitem);
9339 9354
9340 if(*folder) 9355 if(*folder)
9341 { 9356 {
9342 strcat(folder, "*"); 9357 strcat(folder, "*");
9343 _populate_directory(window, item, folder); 9358 _populate_directory(window, item, folder);
9344 } 9359 }
9345 free(folder); 9360 free(folder);
9346 } 9361 }
9347 9362
9348 return FALSE; 9363 return FALSE;
9349 } 9364 }
9350 9365
9351 /* 9366 /*
9352 * Opens a file dialog and queries user selection. 9367 * Opens a file dialog and queries user selection.
9353 * Parameters: 9368 * Parameters:
9360 * the file path on success. 9375 * the file path on success.
9361 * 9376 *
9362 */ 9377 */
9363 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags) 9378 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags)
9364 { 9379 {
9365 if(flags == DW_DIRECTORY_OPEN) 9380 if(flags == DW_DIRECTORY_OPEN)
9366 { 9381 {
9367 HWND window, hbox, vbox, tree, button; 9382 HWND window, hbox, vbox, tree, button;
9368 DWDialog *dwwait; 9383 DWDialog *dwwait;
9369 HMTX mtx = dw_mutex_new(); 9384 HMTX mtx = dw_mutex_new();
9370 9385
9371 window = dw_window_new( HWND_DESKTOP, title, FCF_SHELLPOSITION | FCF_TITLEBAR | FCF_SIZEBORDER | FCF_MINMAX); 9386 window = dw_window_new( HWND_DESKTOP, title, FCF_SHELLPOSITION | FCF_TITLEBAR | FCF_SIZEBORDER | FCF_MINMAX);
9372 9387
9373 vbox = dw_box_new(DW_VERT, 5); 9388 vbox = dw_box_new(DW_VERT, 5);
9374 9389
9375 dw_box_pack_start(window, vbox, 0, 0, TRUE, TRUE, 0); 9390 dw_box_pack_start(window, vbox, 0, 0, TRUE, TRUE, 0);
9376 9391
9377 tree = dw_tree_new(60); 9392 tree = dw_tree_new(60);
9378 9393
9379 dw_box_pack_start(vbox, tree, 1, 1, TRUE, TRUE, 0); 9394 dw_box_pack_start(vbox, tree, 1, 1, TRUE, TRUE, 0);
9380 dw_window_set_data(window, "_dw_mutex", (void *)mtx); 9395 dw_window_set_data(window, "_dw_mutex", (void *)mtx);
9381 dw_window_set_data(window, "_dw_tree", (void *)tree); 9396 dw_window_set_data(window, "_dw_tree", (void *)tree);
9382 9397
9383 hbox = dw_box_new(DW_HORZ, 0); 9398 hbox = dw_box_new(DW_HORZ, 0);
9384 9399
9385 dw_box_pack_start(vbox, hbox, 0, 0, TRUE, FALSE, 0); 9400 dw_box_pack_start(vbox, hbox, 0, 0, TRUE, FALSE, 0);
9386 9401
9387 dwwait = dw_dialog_new((void *)window); 9402 dwwait = dw_dialog_new((void *)window);
9388 9403
9389 dw_signal_connect(tree, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(_item_select), (void *)dwwait); 9404 dw_signal_connect(tree, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(_item_select), (void *)dwwait);
9390 dw_signal_connect(tree, DW_SIGNAL_TREE_EXPAND, DW_SIGNAL_FUNC(_tree_expand), (void *)dwwait); 9405 dw_signal_connect(tree, DW_SIGNAL_TREE_EXPAND, DW_SIGNAL_FUNC(_tree_expand), (void *)dwwait);
9391 9406
9392 button = dw_button_new("Ok", 1001L); 9407 button = dw_button_new("Ok", 1001L);
9393 dw_box_pack_start(hbox, button, 50, 30, TRUE, FALSE, 3); 9408 dw_box_pack_start(hbox, button, 50, 30, TRUE, FALSE, 3);
9394 dw_signal_connect(button, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_ok_func), (void *)dwwait); 9409 dw_signal_connect(button, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_ok_func), (void *)dwwait);
9395 9410
9396 button = dw_button_new("Cancel", 1002L); 9411 button = dw_button_new("Cancel", 1002L);
9397 dw_box_pack_start(hbox, button, 50, 30, TRUE, FALSE, 3); 9412 dw_box_pack_start(hbox, button, 50, 30, TRUE, FALSE, 3);
9398 dw_signal_connect(button, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_cancel_func), (void *)dwwait); 9413 dw_signal_connect(button, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_cancel_func), (void *)dwwait);
9399 dw_signal_connect(window, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(_dw_cancel_func), (void *)dwwait); 9414 dw_signal_connect(window, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(_dw_cancel_func), (void *)dwwait);
9400 9415
9401 dw_window_set_size(window, 225, 300); 9416 dw_window_set_size(window, 225, 300);
9402 dw_window_show(window); 9417 dw_window_show(window);
9403 9418
9404 dw_thread_new((void *)_populate_tree_thread, (void *)window, 0xff); 9419 dw_thread_new((void *)_populate_tree_thread, (void *)window, 0xff);
9405 return (char *)dw_dialog_wait(dwwait); 9420 return (char *)dw_dialog_wait(dwwait);
9406 } 9421 }
9407 else 9422 else
9408 { 9423 {
9409 FILEDLG fild; 9424 FILEDLG fild;
9410 HWND hwndFile; 9425 HWND hwndFile;
9411 int len; 9426 int len;
9412 9427
9413 if(defpath) 9428 if(defpath)
9414 strcpy(fild.szFullFile, defpath); 9429 strcpy(fild.szFullFile, defpath);
9415 else 9430 else
9416 strcpy(fild.szFullFile, ""); 9431 strcpy(fild.szFullFile, "");
9417 9432
9418 len = strlen(fild.szFullFile); 9433 len = strlen(fild.szFullFile);
9419 9434
9420 if(len) 9435 if(len)
9421 { 9436 {
9422 if(fild.szFullFile[len-1] != '\\') 9437 if(fild.szFullFile[len-1] != '\\')
9423 strcat(fild.szFullFile, "\\"); 9438 strcat(fild.szFullFile, "\\");
9424 } 9439 }
9425 strcat(fild.szFullFile, "*"); 9440 strcat(fild.szFullFile, "*");
9426 9441
9427 if(ext) 9442 if(ext)
9428 { 9443 {
9429 strcat(fild.szFullFile, "."); 9444 strcat(fild.szFullFile, ".");
9430 strcat(fild.szFullFile, ext); 9445 strcat(fild.szFullFile, ext);
9431 } 9446 }
9432 9447
9433 memset(&fild, 0, sizeof(FILEDLG)); 9448 memset(&fild, 0, sizeof(FILEDLG));
9434 fild.cbSize = sizeof(FILEDLG); 9449 fild.cbSize = sizeof(FILEDLG);
9435 fild.fl = FDS_CENTER | FDS_OPEN_DIALOG; 9450 fild.fl = FDS_CENTER | FDS_OPEN_DIALOG;
9436 fild.pszTitle = title; 9451 fild.pszTitle = title;
9437 fild.pszOKButton = ((flags & DW_FILE_SAVE) ? "Save" : "Open"); 9452 fild.pszOKButton = ((flags & DW_FILE_SAVE) ? "Save" : "Open");
9438 fild.pfnDlgProc = (PFNWP)WinDefFileDlgProc; 9453 fild.pfnDlgProc = (PFNWP)WinDefFileDlgProc;
9439 9454
9440 hwndFile = WinFileDlg(HWND_DESKTOP, HWND_DESKTOP, &fild); 9455 hwndFile = WinFileDlg(HWND_DESKTOP, HWND_DESKTOP, &fild);
9441 if(hwndFile) 9456 if(hwndFile)
9442 { 9457 {
9443 switch(fild.lReturn) 9458 switch(fild.lReturn)
9444 { 9459 {
9445 case DID_OK: 9460 case DID_OK:
9446 return strdup(fild.szFullFile); 9461 return strdup(fild.szFullFile);
9447 case DID_CANCEL: 9462 case DID_CANCEL:
9448 return NULL; 9463 return NULL;
9449 } 9464 }
9450 } 9465 }
9451 } 9466 }
9452 return NULL; 9467 return NULL;
9453 } 9468 }
9454 9469
9455 /* Internal function to set drive and directory */ 9470 /* Internal function to set drive and directory */
9456 int _SetPath(char *path) 9471 int _SetPath(char *path)
9457 { 9472 {
9458 #ifndef __WATCOMC__ 9473 #ifndef __WATCOMC__
9459 if(strlen(path) > 2) 9474 if(strlen(path) > 2)
9460 { 9475 {
9461 if(path[1] == ':') 9476 if(path[1] == ':')
9462 { 9477 {
9463 char drive = toupper(path[0]); 9478 char drive = toupper(path[0]);
9464 _chdrive((drive - 'A')+1); 9479 _chdrive((drive - 'A')+1);
9465 } 9480 }
9466 } 9481 }
9467 #endif 9482 #endif
9468 return chdir(path); 9483 return chdir(path);
9469 } 9484 }
9470 9485
9471 /* 9486 /*
9472 * Execute and external program in a seperate session. 9487 * Execute and external program in a seperate session.
9473 * Parameters: 9488 * Parameters:
9477 * Returns: 9492 * Returns:
9478 * -1 on error. 9493 * -1 on error.
9479 */ 9494 */
9480 int API dw_exec(char *program, int type, char **params) 9495 int API dw_exec(char *program, int type, char **params)
9481 { 9496 {
9482 type = type; /* keep compiler happy */ 9497 type = type; /* keep compiler happy */
9483 return spawnvp(P_NOWAIT, program, (const char **)params); 9498 return spawnvp(P_NOWAIT, program, (const char **)params);
9484 } 9499 }
9485 9500
9486 /* 9501 /*
9487 * Loads a web browser pointed at the given URL. 9502 * Loads a web browser pointed at the given URL.
9488 * Parameters: 9503 * Parameters:
9489 * url: Uniform resource locator. 9504 * url: Uniform resource locator.
9490 */ 9505 */
9491 int API dw_browse(char *url) 9506 int API dw_browse(char *url)
9492 { 9507 {
9493 char *execargs[3], browser[1024], *olddir, *newurl = NULL; 9508 char *execargs[3], browser[1024], *olddir, *newurl = NULL;
9494 int len, ret; 9509 int len, ret;
9495 9510
9496 olddir = _getcwd(NULL, 1024); 9511 olddir = _getcwd(NULL, 1024);
9497 9512
9498 PrfQueryProfileString(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS", 9513 PrfQueryProfileString(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS",
9499 "DefaultWorkingDir", NULL, browser, 1024); 9514 "DefaultWorkingDir", NULL, browser, 1024);
9500 9515
9501 if(browser[0]) 9516 if(browser[0])
9502 _SetPath(browser); 9517 _SetPath(browser);
9503 9518
9504 PrfQueryProfileString(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS", 9519 PrfQueryProfileString(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS",
9505 "DefaultBrowserExe", NULL, browser, 1024); 9520 "DefaultBrowserExe", NULL, browser, 1024);
9506 9521
9507 len = strlen(browser) - strlen("explore.exe"); 9522 len = strlen(browser) - strlen("explore.exe");
9508 9523
9509 execargs[0] = browser; 9524 execargs[0] = browser;
9510 execargs[1] = url; 9525 execargs[1] = url;
9511 execargs[2] = NULL; 9526 execargs[2] = NULL;
9512 9527
9513 /* Special case for Web Explorer, it requires file:/// instead 9528 /* Special case for Web Explorer, it requires file:/// instead
9514 * of file:// so I am handling it here. 9529 * of file:// so I am handling it here.
9515 */ 9530 */
9516 if(len > 0) 9531 if(len > 0)
9517 { 9532 {
9518 if(stricmp(&browser[len], "explore.exe") == 0 && stricmp(url, "file://") == 0) 9533 if(stricmp(&browser[len], "explore.exe") == 0 && stricmp(url, "file://") == 0)
9519 { 9534 {
9520 int newlen, z; 9535 int newlen, z;
9521 newurl = malloc(strlen(url) + 2); 9536 newurl = malloc(strlen(url) + 2);
9522 sprintf(newurl, "file:///%s", &url[7]); 9537 sprintf(newurl, "file:///%s", &url[7]);
9523 newlen = strlen(newurl); 9538 newlen = strlen(newurl);
9524 for(z=8;z<(newlen-8);z++) 9539 for(z=8;z<(newlen-8);z++)
9525 { 9540 {
9526 if(newurl[z] == '|') 9541 if(newurl[z] == '|')
9527 newurl[z] = ':'; 9542 newurl[z] = ':';
9528 if(newurl[z] == '/') 9543 if(newurl[z] == '/')
9529 newurl[z] = '\\'; 9544 newurl[z] = '\\';
9530 } 9545 }
9531 execargs[1] = newurl; 9546 execargs[1] = newurl;
9532 } 9547 }
9533 } 9548 }
9534 9549
9535 ret = dw_exec(browser, DW_EXEC_GUI, execargs); 9550 ret = dw_exec(browser, DW_EXEC_GUI, execargs);
9536 9551
9537 if(olddir) 9552 if(olddir)
9538 { 9553 {
9539 _SetPath(olddir); 9554 _SetPath(olddir);
9540 free(olddir); 9555 free(olddir);
9541 } 9556 }
9542 if(newurl) 9557 if(newurl)
9543 free(newurl); 9558 free(newurl);
9544 return ret; 9559 return ret;
9545 } 9560 }
9546 9561
9547 /* 9562 /*
9548 * Causes the embedded HTML widget to take action. 9563 * Causes the embedded HTML widget to take action.
9549 * Parameters: 9564 * Parameters:
9550 * handle: Handle to the window. 9565 * handle: Handle to the window.
9551 * action: One of the DW_HTML_* constants. 9566 * action: One of the DW_HTML_* constants.
9552 */ 9567 */
9553 void API dw_html_action(HWND handle, int action) 9568 void API dw_html_action(HWND handle, int action)
9554 { 9569 {
9555 handle = handle; 9570 handle = handle;
9556 action = action; 9571 action = action;
9557 } 9572 }
9558 9573
9559 /* 9574 /*
9560 * Render raw HTML code in the embedded HTML widget.. 9575 * Render raw HTML code in the embedded HTML widget..
9561 * Parameters: 9576 * Parameters:
9565 * Returns: 9580 * Returns:
9566 * 0 on success. 9581 * 0 on success.
9567 */ 9582 */
9568 int API dw_html_raw(HWND handle, char *string) 9583 int API dw_html_raw(HWND handle, char *string)
9569 { 9584 {
9570 handle = handle; 9585 handle = handle;
9571 string = string; 9586 string = string;
9572 return -1; 9587 return -1;
9573 } 9588 }
9574 9589
9575 /* 9590 /*
9576 * Render file or web page in the embedded HTML widget.. 9591 * Render file or web page in the embedded HTML widget..
9577 * Parameters: 9592 * Parameters:
9581 * Returns: 9596 * Returns:
9582 * 0 on success. 9597 * 0 on success.
9583 */ 9598 */
9584 int API dw_html_url(HWND handle, char *url) 9599 int API dw_html_url(HWND handle, char *url)
9585 { 9600 {
9586 handle = handle; 9601 handle = handle;
9587 url = url; 9602 url = url;
9588 return -1; 9603 return -1;
9589 } 9604 }
9590 9605
9591 /* 9606 /*
9592 * Create a new Entryfield window (widget) to be packed. 9607 * Create a new HTML window (widget) to be packed.
9608 * Not available under OS/2, eCS
9593 * Parameters: 9609 * Parameters:
9594 * text: The default text to be in the entryfield widget. 9610 * text: The default text to be in the entryfield widget.
9595 * id: An ID to be used with dw_window_from_id() or 0L. 9611 * id: An ID to be used with dw_window_from_id() or 0L.
9596 */ 9612 */
9597 HWND API dw_html_new(unsigned long id) 9613 HWND API dw_html_new(unsigned long id)
9598 { 9614 {
9599 id = id; 9615 id = id;
9600 return dw_box_new(DW_HORZ, 0); 9616 return dw_box_new(DW_HORZ, 0);
9601 } 9617 }
9602 9618
9603 /* 9619 /*
9604 * Returns a pointer to a static buffer which containes the 9620 * Returns a pointer to a static buffer which containes the
9605 * current user directory. Or the root directory (C:\ on 9621 * current user directory. Or the root directory (C:\ on
9606 * OS/2 and Windows). 9622 * OS/2 and Windows).
9607 */ 9623 */
9608 char * API dw_user_dir(void) 9624 char * API dw_user_dir(void)
9609 { 9625 {
9610 static char _user_dir[1024] = ""; 9626 static char _user_dir[1024] = "";
9611 9627
9612 if(!_user_dir[0]) 9628 if(!_user_dir[0])
9613 { 9629 {
9614 char *home = getenv("HOME"); 9630 char *home = getenv("HOME");
9615 9631
9616 if(home) 9632 if(home)
9617 strcpy(_user_dir, home); 9633 strcpy(_user_dir, home);
9618 else 9634 else
9619 strcpy(_user_dir, "C:\\"); 9635 strcpy(_user_dir, "C:\\");
9620 } 9636 }
9621 return _user_dir; 9637 return _user_dir;
9622 } 9638 }
9623 9639
9624 /* 9640 /*
9625 * Call a function from the window (widget)'s context. 9641 * Call a function from the window (widget)'s context.
9626 * Parameters: 9642 * Parameters:
9628 * function: Function pointer to be called. 9644 * function: Function pointer to be called.
9629 * data: Pointer to the data to be passed to the function. 9645 * data: Pointer to the data to be passed to the function.
9630 */ 9646 */
9631 void API dw_window_function(HWND handle, void *function, void *data) 9647 void API dw_window_function(HWND handle, void *function, void *data)
9632 { 9648 {
9633 WinSendMsg(handle, WM_USER, (MPARAM)function, (MPARAM)data); 9649 WinSendMsg(handle, WM_USER, (MPARAM)function, (MPARAM)data);
9634 } 9650 }
9635 9651
9636 /* Functions for managing the user data lists that are associated with 9652 /* Functions for managing the user data lists that are associated with
9637 * a given window handle. Used in dw_window_set_data() and 9653 * a given window handle. Used in dw_window_set_data() and
9638 * dw_window_get_data(). 9654 * dw_window_get_data().
9639 */ 9655 */
9640 UserData *_find_userdata(UserData **root, char *varname) 9656 UserData *_find_userdata(UserData **root, char *varname)
9641 { 9657 {
9642 UserData *tmp = *root; 9658 UserData *tmp = *root;
9643 9659
9644 while(tmp) 9660 while(tmp)
9645 { 9661 {
9646 if(stricmp(tmp->varname, varname) == 0) 9662 if(stricmp(tmp->varname, varname) == 0)
9647 return tmp; 9663 return tmp;
9648 tmp = tmp->next; 9664 tmp = tmp->next;
9649 } 9665 }
9650 return NULL; 9666 return NULL;
9651 } 9667 }
9652 9668
9653 int _new_userdata(UserData **root, char *varname, void *data) 9669 int _new_userdata(UserData **root, char *varname, void *data)
9654 { 9670 {
9655 UserData *new = _find_userdata(root, varname); 9671 UserData *new = _find_userdata(root, varname);
9656 9672
9657 if(new) 9673 if(new)
9658 { 9674 {
9659 new->data = data; 9675 new->data = data;
9660 return TRUE; 9676 return TRUE;
9661 } 9677 }
9662 else 9678 else
9663 { 9679 {
9664 new = malloc(sizeof(UserData)); 9680 new = malloc(sizeof(UserData));
9665 if(new) 9681 if(new)
9666 { 9682 {
9667 new->varname = strdup(varname); 9683 new->varname = strdup(varname);
9668 new->data = data; 9684 new->data = data;
9669 9685
9670 new->next = NULL; 9686 new->next = NULL;
9671 9687
9672 if (!*root) 9688 if (!*root)
9673 *root = new; 9689 *root = new;
9674 else 9690 else
9675 { 9691 {
9676 UserData *prev = NULL, *tmp = *root; 9692 UserData *prev = NULL, *tmp = *root;
9677 while(tmp) 9693 while(tmp)
9678 { 9694 {
9679 prev = tmp; 9695 prev = tmp;
9680 tmp = tmp->next; 9696 tmp = tmp->next;
9681 } 9697 }
9682 if(prev) 9698 if(prev)
9683 prev->next = new; 9699 prev->next = new;
9684 else 9700 else
9685 *root = new; 9701 *root = new;
9686 } 9702 }
9687 return TRUE; 9703 return TRUE;
9688 } 9704 }
9689 } 9705 }
9690 return FALSE; 9706 return FALSE;
9691 } 9707 }
9692 9708
9693 int _remove_userdata(UserData **root, char *varname, int all) 9709 int _remove_userdata(UserData **root, char *varname, int all)
9694 { 9710 {
9695 UserData *prev = NULL, *tmp = *root; 9711 UserData *prev = NULL, *tmp = *root;
9696 9712
9697 while(tmp) 9713 while(tmp)
9698 { 9714 {
9699 if(all || stricmp(tmp->varname, varname) == 0) 9715 if(all || stricmp(tmp->varname, varname) == 0)
9700 { 9716 {
9701 if(!prev) 9717 if(!prev)
9702 { 9718 {
9703 *root = tmp->next; 9719 *root = tmp->next;
9704 free(tmp->varname); 9720 free(tmp->varname);
9705 free(tmp); 9721 free(tmp);
9706 if(!all) 9722 if(!all)
9707 return 0; 9723 return 0;
9708 tmp = *root; 9724 tmp = *root;
9709 } 9725 }
9710 else 9726 else
9711 { 9727 {
9712 /* If all is true we should 9728 /* If all is true we should
9713 * never get here. 9729 * never get here.
9714 */ 9730 */
9715 prev->next = tmp->next; 9731 prev->next = tmp->next;
9716 free(tmp->varname); 9732 free(tmp->varname);
9717 free(tmp); 9733 free(tmp);
9718 return 0; 9734 return 0;
9719 } 9735 }
9720 } 9736 }
9721 else 9737 else
9722 { 9738 {
9723 prev = tmp; 9739 prev = tmp;
9724 tmp = tmp->next; 9740 tmp = tmp->next;
9725 } 9741 }
9726 } 9742 }
9727 return 0; 9743 return 0;
9728 } 9744 }
9729 9745
9730 /* 9746 /*
9731 * Add a named user data item to a window handle. 9747 * Add a named user data item to a window handle.
9732 * Parameters: 9748 * Parameters:
9734 * dataname: A string pointer identifying which signal to be hooked. 9750 * dataname: A string pointer identifying which signal to be hooked.
9735 * data: User data to be passed to the handler function. 9751 * data: User data to be passed to the handler function.
9736 */ 9752 */
9737 void API dw_window_set_data(HWND window, char *dataname, void *data) 9753 void API dw_window_set_data(HWND window, char *dataname, void *data)
9738 { 9754 {
9739 WindowData *blah = (WindowData *)WinQueryWindowPtr(window, QWP_USER); 9755 WindowData *blah = (WindowData *)WinQueryWindowPtr(window, QWP_USER);
9740 9756
9741 if(!blah) 9757 if(!blah)
9742 { 9758 {
9743 if(!dataname) 9759 if(!dataname)
9744 return; 9760 return;
9745 9761
9746 blah = calloc(1, sizeof(WindowData)); 9762 blah = calloc(1, sizeof(WindowData));
9747 WinSetWindowPtr(window, QWP_USER, blah); 9763 WinSetWindowPtr(window, QWP_USER, blah);
9748 } 9764 }
9749 9765
9750 if(data) 9766 if(data)
9751 _new_userdata(&(blah->root), dataname, data); 9767 _new_userdata(&(blah->root), dataname, data);
9752 else 9768 else
9753 { 9769 {
9754 if(dataname) 9770 if(dataname)
9755 _remove_userdata(&(blah->root), dataname, FALSE); 9771 _remove_userdata(&(blah->root), dataname, FALSE);
9756 else 9772 else
9757 _remove_userdata(&(blah->root), NULL, TRUE); 9773 _remove_userdata(&(blah->root), NULL, TRUE);
9758 } 9774 }
9759 } 9775 }
9760 9776
9761 /* 9777 /*
9762 * Gets a named user data item to a window handle. 9778 * Gets a named user data item to a window handle.
9763 * Parameters: 9779 * Parameters:
9765 * dataname: A string pointer identifying which signal to be hooked. 9781 * dataname: A string pointer identifying which signal to be hooked.
9766 * data: User data to be passed to the handler function. 9782 * data: User data to be passed to the handler function.
9767 */ 9783 */
9768 void * API dw_window_get_data(HWND window, char *dataname) 9784 void * API dw_window_get_data(HWND window, char *dataname)
9769 { 9785 {
9770 WindowData *blah = (WindowData *)WinQueryWindowPtr(window, QWP_USER); 9786 WindowData *blah = (WindowData *)WinQueryWindowPtr(window, QWP_USER);
9771 9787
9772 if(blah && blah->root && dataname) 9788 if(blah && blah->root && dataname)
9773 { 9789 {
9774 UserData *ud = _find_userdata(&(blah->root), dataname); 9790 UserData *ud = _find_userdata(&(blah->root), dataname);
9775 if(ud) 9791 if(ud)
9776 return ud->data; 9792 return ud->data;
9777 } 9793 }
9778 return NULL; 9794 return NULL;
9779 } 9795 }
9780 9796
9781 /* 9797 /*
9782 * Add a callback to a timer event. 9798 * Add a callback to a timer event.
9783 * Parameters: 9799 * Parameters:
9787 * Returns: 9803 * Returns:
9788 * Timer ID for use with dw_timer_disconnect(), 0 on error. 9804 * Timer ID for use with dw_timer_disconnect(), 0 on error.
9789 */ 9805 */
9790 int API dw_timer_connect(int interval, void *sigfunc, void *data) 9806 int API dw_timer_connect(int interval, void *sigfunc, void *data)
9791 { 9807 {
9792 if(sigfunc) 9808 if(sigfunc)
9793 { 9809 {
9794 int timerid = WinStartTimer(dwhab, NULLHANDLE, 0, interval); 9810 int timerid = WinStartTimer(dwhab, NULLHANDLE, 0, interval);
9795 9811
9796 if(timerid) 9812 if(timerid)
9797 { 9813 {
9798 _new_signal(WM_TIMER, NULLHANDLE, timerid, sigfunc, data); 9814 _new_signal(WM_TIMER, NULLHANDLE, timerid, sigfunc, data);
9799 return timerid; 9815 return timerid;
9800 } 9816 }
9801 } 9817 }
9802 return 0; 9818 return 0;
9803 } 9819 }
9804 9820
9805 /* 9821 /*
9806 * Removes timer callback. 9822 * Removes timer callback.
9807 * Parameters: 9823 * Parameters:
9808 * id: Timer ID returned by dw_timer_connect(). 9824 * id: Timer ID returned by dw_timer_connect().
9809 */ 9825 */
9810 void API dw_timer_disconnect(int id) 9826 void API dw_timer_disconnect(int id)
9811 { 9827 {
9812 SignalHandler *prev = NULL, *tmp = Root; 9828 SignalHandler *prev = NULL, *tmp = Root;
9813 9829
9814 /* 0 is an invalid timer ID */ 9830 /* 0 is an invalid timer ID */
9815 if(!id) 9831 if(!id)
9816 return; 9832 return;
9817 9833
9818 WinStopTimer(dwhab, NULLHANDLE, id); 9834 WinStopTimer(dwhab, NULLHANDLE, id);
9819 9835
9820 while(tmp) 9836 while(tmp)
9821 { 9837 {
9822 if(tmp->id == id) 9838 if(tmp->id == id)
9823 { 9839 {
9824 if(prev) 9840 if(prev)
9825 { 9841 {
9826 prev->next = tmp->next; 9842 prev->next = tmp->next;
9827 free(tmp); 9843 free(tmp);
9828 tmp = prev->next; 9844 tmp = prev->next;
9829 } 9845 }
9830 else 9846 else
9831 { 9847 {
9832 Root = tmp->next; 9848 Root = tmp->next;
9833 free(tmp); 9849 free(tmp);
9834 tmp = Root; 9850 tmp = Root;
9835 } 9851 }
9836 } 9852 }
9837 else 9853 else
9838 { 9854 {
9839 prev = tmp; 9855 prev = tmp;
9840 tmp = tmp->next; 9856 tmp = tmp->next;
9841 } 9857 }
9842 } 9858 }
9843 } 9859 }
9844 9860
9845 /* 9861 /*
9846 * Add a callback to a window event. 9862 * Add a callback to a window event.
9847 * Parameters: 9863 * Parameters:
9850 * sigfunc: The pointer to the function to be used as the callback. 9866 * sigfunc: The pointer to the function to be used as the callback.
9851 * data: User data to be passed to the handler function. 9867 * data: User data to be passed to the handler function.
9852 */ 9868 */
9853 void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) 9869 void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data)
9854 { 9870 {
9855 ULONG message = 0, id = 0; 9871 ULONG message = 0, id = 0;
9856 9872
9857 if(window && signame && sigfunc) 9873 if(window && signame && sigfunc)
9858 { 9874 {
9859 if((message = _findsigmessage(signame)) != 0) 9875 if((message = _findsigmessage(signame)) != 0)
9860 { 9876 {
9861 /* Handle special case of the menu item */ 9877 /* Handle special case of the menu item */
9862 if(message == WM_COMMAND && window < 65536) 9878 if(message == WM_COMMAND && window < 65536)
9863 { 9879 {
9864 char buffer[15]; 9880 char buffer[15];
9865 HWND owner; 9881 HWND owner;
9866 9882
9867 sprintf(buffer, "_dw_id%d", (int)window); 9883 sprintf(buffer, "_dw_id%d", (int)window);
9868 owner = (HWND)dw_window_get_data(hwndApp, buffer); 9884 owner = (HWND)dw_window_get_data(hwndApp, buffer);
9869 9885
9870 if(owner) 9886 if(owner)
9871 { 9887 {
9872 id = window; 9888 id = window;
9873 window = owner; 9889 window = owner;
9874 dw_window_set_data(hwndApp, buffer, 0); 9890 dw_window_set_data(hwndApp, buffer, 0);
9875 } 9891 }
9876 else 9892 else
9877 { 9893 {
9878 /* If it is a popup menu clear all entries */ 9894 /* If it is a popup menu clear all entries */
9879 dw_signal_disconnect_by_window(window); 9895 dw_signal_disconnect_by_window(window);
9880 } 9896 }
9881 } 9897 }
9882 _new_signal(message, window, id, sigfunc, data); 9898 _new_signal(message, window, id, sigfunc, data);
9883 } 9899 }
9884 } 9900 }
9885 } 9901 }
9886 9902
9887 /* 9903 /*
9888 * Removes callbacks for a given window with given name. 9904 * Removes callbacks for a given window with given name.
9889 * Parameters: 9905 * Parameters:
9890 * window: Window handle of callback to be removed. 9906 * window: Window handle of callback to be removed.
9891 */ 9907 */
9892 void API dw_signal_disconnect_by_name(HWND window, char *signame) 9908 void API dw_signal_disconnect_by_name(HWND window, char *signame)
9893 { 9909 {
9894 SignalHandler *prev = NULL, *tmp = Root; 9910 SignalHandler *prev = NULL, *tmp = Root;
9895 ULONG message; 9911 ULONG message;
9896 9912
9897 if(!window || !signame || (message = _findsigmessage(signame)) == 0) 9913 if(!window || !signame || (message = _findsigmessage(signame)) == 0)
9898 return; 9914 return;
9899 9915
9900 while(tmp) 9916 while(tmp)
9901 { 9917 {
9902 if(tmp->window == window && tmp->message == message) 9918 if(tmp->window == window && tmp->message == message)
9903 { 9919 {
9904 if(prev) 9920 if(prev)
9905 { 9921 {
9906 prev->next = tmp->next; 9922 prev->next = tmp->next;
9907 free(tmp); 9923 free(tmp);
9908 tmp = prev->next; 9924 tmp = prev->next;
9909 } 9925 }
9910 else 9926 else
9911 { 9927 {
9912 Root = tmp->next; 9928 Root = tmp->next;
9913 free(tmp); 9929 free(tmp);
9914 tmp = Root; 9930 tmp = Root;
9915 } 9931 }
9916 } 9932 }
9917 else 9933 else
9918 { 9934 {
9919 prev = tmp; 9935 prev = tmp;
9920 tmp = tmp->next; 9936 tmp = tmp->next;
9921 } 9937 }
9922 } 9938 }
9923 } 9939 }
9924 9940
9925 /* 9941 /*
9926 * Removes all callbacks for a given window. 9942 * Removes all callbacks for a given window.
9927 * Parameters: 9943 * Parameters:
9928 * window: Window handle of callback to be removed. 9944 * window: Window handle of callback to be removed.
9929 */ 9945 */
9930 void API dw_signal_disconnect_by_window(HWND window) 9946 void API dw_signal_disconnect_by_window(HWND window)
9931 { 9947 {
9932 SignalHandler *prev = NULL, *tmp = Root; 9948 SignalHandler *prev = NULL, *tmp = Root;
9933 9949
9934 while(tmp) 9950 while(tmp)
9935 { 9951 {
9936 if(tmp->window == window) 9952 if(tmp->window == window)
9937 { 9953 {
9938 if(prev) 9954 if(prev)
9939 { 9955 {
9940 prev->next = tmp->next; 9956 prev->next = tmp->next;
9941 free(tmp); 9957 free(tmp);
9942 tmp = prev->next; 9958 tmp = prev->next;
9943 } 9959 }
9944 else 9960 else
9945 { 9961 {
9946 Root = tmp->next; 9962 Root = tmp->next;
9947 free(tmp); 9963 free(tmp);
9948 tmp = Root; 9964 tmp = Root;
9949 } 9965 }
9950 } 9966 }
9951 else 9967 else
9952 { 9968 {
9953 prev = tmp; 9969 prev = tmp;
9954 tmp = tmp->next; 9970 tmp = tmp->next;
9955 } 9971 }
9956 } 9972 }
9957 } 9973 }
9958 9974
9959 /* 9975 /*
9960 * Removes all callbacks for a given window with specified data. 9976 * Removes all callbacks for a given window with specified data.
9961 * Parameters: 9977 * Parameters:
9962 * window: Window handle of callback to be removed. 9978 * window: Window handle of callback to be removed.
9963 * data: Pointer to the data to be compared against. 9979 * data: Pointer to the data to be compared against.
9964 */ 9980 */
9965 void API dw_signal_disconnect_by_data(HWND window, void *data) 9981 void API dw_signal_disconnect_by_data(HWND window, void *data)
9966 { 9982 {
9967 SignalHandler *prev = NULL, *tmp = Root; 9983 SignalHandler *prev = NULL, *tmp = Root;
9968 9984
9969 while(tmp) 9985 while(tmp)
9970 { 9986 {
9971 if(tmp->window == window && tmp->data == data) 9987 if(tmp->window == window && tmp->data == data)
9972 { 9988 {
9973 if(prev) 9989 if(prev)
9974 { 9990 {
9975 prev->next = tmp->next; 9991 prev->next = tmp->next;
9976 free(tmp); 9992 free(tmp);
9977 tmp = prev->next; 9993 tmp = prev->next;
9978 } 9994 }
9979 else 9995 else
9980 { 9996 {
9981 Root = tmp->next; 9997 Root = tmp->next;
9982 free(tmp); 9998 free(tmp);
9983 tmp = Root; 9999 tmp = Root;
9984 } 10000 }
9985 } 10001 }
9986 else 10002 else
9987 { 10003 {
9988 prev = tmp; 10004 prev = tmp;
9989 tmp = tmp->next; 10005 tmp = tmp->next;
9990 } 10006 }
9991 } 10007 }
9992 } 10008 }
9993 10009
9994 10010
9995 10011
9996 /* 10012 /*
9997 * Create a new static text window (widget) to be packed. 10013 * Create a new static text window (widget) to be packed.
9998 * **** temporary calendar ***** 10014 * Not available under OS/2, eCS
9999 * Parameters: 10015 * Parameters:
10000 * text: The text to be display by the static text widget. 10016 * text: The text to be display by the static text widget.
10001 * id: An ID to be used with dw_window_from_id() or 0L. 10017 * id: An ID to be used with dw_window_from_id() or 0L.
10002 */ 10018 */
10003 HWND API dw_calendar_new(ULONG id) 10019 HWND API dw_calendar_new(ULONG id)
10004 { 10020 {
10005 char *text = "dummy calendar"; 10021 char *text = "dummy calendar";
10006 WindowData *blah = calloc(sizeof(WindowData), 1); 10022 WindowData *blah = calloc(sizeof(WindowData), 1);
10007 HWND tmp = WinCreateWindow(HWND_OBJECT, 10023 HWND tmp = WinCreateWindow(HWND_OBJECT,
10008 WC_STATIC, 10024 WC_STATIC,
10009 text, 10025 text,
10010 WS_VISIBLE | SS_TEXT, 10026 WS_VISIBLE | SS_TEXT,
10011 0,0,2000,1000, 10027 0,0,2000,1000,
10012 NULLHANDLE, 10028 NULLHANDLE,
10013 HWND_TOP, 10029 HWND_TOP,
10014 id, 10030 id,
10015 NULL, 10031 NULL,
10016 NULL); 10032 NULL);
10017 blah->oldproc = WinSubclassWindow(tmp, _textproc); 10033 blah->oldproc = WinSubclassWindow(tmp, _textproc);
10018 WinSetWindowPtr(tmp, QWP_USER, blah); 10034 WinSetWindowPtr(tmp, QWP_USER, blah);
10019 dw_window_set_font(tmp, DefaultFont); 10035 dw_window_set_font(tmp, DefaultFont);
10020 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); 10036 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY);
10021 WinSetWindowText(tmp, text); 10037 WinSetWindowText(tmp, text);
10022 return tmp; 10038 return tmp;
10023 } 10039 }
10024 10040
10025 /* 10041 /*
10026 * The following are stubs 10042 * The following are stubs
10027 */ 10043 */
10028 void API dw_calendar_set_date( HWND window, unsigned int year, unsigned int month, unsigned int day ) 10044 void API dw_calendar_set_date( HWND window, unsigned int year, unsigned int month, unsigned int day )
10029 { 10045 {
10030 char tmp[30]; 10046 char tmp[30];
10031 sprintf( tmp, "%4.4d-%2.2d-%2.2d", year, month, day); 10047 sprintf( tmp, "%4.4d-%2.2d-%2.2d", year, month, day);
10032 WinSetWindowText(window, tmp); 10048 WinSetWindowText(window, tmp);
10033 } 10049 }
10034 10050
10035 void API dw_calendar_get_date( HWND window, unsigned int *year, unsigned int *month, unsigned int *day ) 10051 void API dw_calendar_get_date( HWND window, unsigned int *year, unsigned int *month, unsigned int *day )
10036 { 10052 {
10037 *year = *month = *day = 0; 10053 *year = *month = *day = 0;