Mercurial > dwindows
annotate os2/dw.c @ 23:2932f9d2c7d5
New OS/2 code from FX changes.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 04 Aug 2001 19:36:21 +0000 |
parents | 6a246b3bb14f |
children | d9e87e8bcf1d |
rev | line source |
---|---|
3 | 1 /* |
2 * Dynamic Windows: | |
3 * A GTK like implementation of the PM GUI | |
4 * | |
5 * (C) 2000,2001 Brian Smith <dbsoft@technologist.com> | |
6 * (C) 2000 Achim Hasenmueller <achimha@innotek.de> | |
7 * (C) 2000 Peter Nielsen <peter@pmview.com> | |
8 * (C) 1998 Sergey I. Yevtushenko (some code borrowed from cell toolkit) | |
9 * | |
10 */ | |
11 #define INCL_DOS | |
12 #define INCL_DOSERRORS | |
13 #define INCL_WIN | |
14 #define INCL_GPI | |
15 | |
16 #include <os2.h> | |
17 #include <stdlib.h> | |
18 #include <string.h> | |
19 #include <stdio.h> | |
20 #include <stdarg.h> | |
21 #include <stddef.h> | |
22 #include <ctype.h> | |
23 #include <process.h> | |
24 #include "dw.h" | |
25 | |
26 #define QWP_USER 0 | |
27 | |
28 char ClassName[] = "dynamicwindows"; | |
29 char SplitbarClassName[] = "dwsplitbar"; | |
30 char DefaultFont[] = "9.WarpSans"; | |
31 | |
32 /* this is the callback handle for the window procedure | |
33 * make sure you always match the calling convention! | |
34 */ | |
35 int (* EXPENTRY filterfunc)(HWND, ULONG, MPARAM, MPARAM) = 0L; | |
36 | |
37 HAB dwhab = 0; | |
38 HMQ dwhmq = 0; | |
39 DWTID _dwtid = 0; | |
40 LONG _foreground = 0xAAAAAA, _background = 0; | |
41 | |
42 HWND hwndBubble = NULLHANDLE, hwndBubbleLast = NULLHANDLE; | |
43 PRECORDCORE pCore = NULL; | |
20
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
44 ULONG aulBuffer[4]; |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
45 |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
46 #define IS_WARP4() (aulBuffer[0] == 20 && aulBuffer[1] >= 40) |
3 | 47 |
48 #ifndef min | |
49 #define min(a, b) (((a < b) ? a : b)) | |
50 #endif | |
51 | |
52 #ifdef DWDEBUG | |
53 FILE *f; | |
54 | |
55 void reopen(void) | |
56 { | |
57 fclose(f); | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
58 f = fopen("dw.log", "a+"); |
3 | 59 } |
60 #endif | |
61 | |
62 static LONG lColor[SPLITBAR_WIDTH] = | |
63 { | |
64 DW_CLR_BLACK, | |
65 DW_CLR_PALEGRAY, | |
66 DW_CLR_WHITE | |
67 }; | |
68 | |
69 #ifdef NO_SIGNALS | |
70 #define USE_FILTER | |
71 #else | |
72 typedef struct _sighandler | |
73 { | |
74 struct _sighandler *next; | |
75 ULONG message; | |
76 HWND window; | |
77 void *signalfunction; | |
78 void *data; | |
79 | |
80 } SignalHandler; | |
81 | |
82 SignalHandler *Root = NULL; | |
83 | |
84 typedef struct | |
85 { | |
86 ULONG message; | |
87 char name[30]; | |
88 | |
89 } SignalList; | |
90 | |
91 /* List of signals and their equivilent OS/2 message */ | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
92 #define SIGNALMAX 12 |
3 | 93 |
94 SignalList SignalTranslate[SIGNALMAX] = { | |
95 { WM_SIZE, "configure_event" }, | |
96 { WM_CHAR, "key_press_event" }, | |
97 { WM_BUTTON1DOWN, "button_press_event" }, | |
98 { WM_BUTTON1UP, "button_release_event"}, | |
99 { WM_MOUSEMOVE, "motion_notify_event" }, | |
100 { WM_CLOSE, "delete_event" }, | |
101 { WM_PAINT, "expose_event" }, | |
102 { WM_COMMAND, "clicked" }, | |
103 { CN_ENTER, "container-select" }, | |
104 { CN_CONTEXTMENU, "container-context" }, | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
105 { LN_SELECT, "item-select" }, |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
106 { WM_SETFOCUS, "set-focus" } |
3 | 107 }; |
108 | |
109 /* This function adds a signal handler callback into the linked list. | |
110 */ | |
111 void _new_signal(ULONG message, HWND window, void *signalfunction, void *data) | |
112 { | |
113 SignalHandler *new = malloc(sizeof(SignalHandler)); | |
114 | |
115 new->message = message; | |
116 new->window = window; | |
117 new->signalfunction = signalfunction; | |
118 new->data = data; | |
119 new->next = NULL; | |
120 | |
121 if (!Root) | |
122 Root = new; | |
123 else | |
124 { | |
125 SignalHandler *prev = NULL, *tmp = Root; | |
126 while(tmp) | |
127 { | |
128 prev = tmp; | |
129 tmp = tmp->next; | |
130 } | |
131 if(prev) | |
132 prev->next = new; | |
133 else | |
134 Root = new; | |
135 } | |
136 } | |
137 | |
138 /* Finds the message number for a given signal name */ | |
139 ULONG _findsigmessage(char *signame) | |
140 { | |
141 int z; | |
142 | |
143 for(z=0;z<SIGNALMAX;z++) | |
144 { | |
145 if(stricmp(signame, SignalTranslate[z].name) == 0) | |
146 return SignalTranslate[z].message; | |
147 } | |
148 return 0L; | |
149 } | |
150 #endif | |
151 | |
152 /* This function removes and handlers on windows and frees | |
153 * the user memory allocated to it. | |
154 */ | |
155 void _free_window_memory(HWND handle) | |
156 { | |
157 HENUM henum; | |
158 HWND child; | |
159 | |
160 #ifndef NO_SIGNALS | |
161 dw_signal_disconnect_by_window(handle); | |
162 #endif | |
163 | |
164 henum = WinBeginEnumWindows(handle); | |
165 while((child = WinGetNextWindow(henum)) != NULLHANDLE) | |
166 { | |
167 void *ptr = (void *)WinQueryWindowPtr(handle, QWP_USER); | |
168 | |
169 if(ptr) | |
170 { | |
171 WinSetWindowPtr(handle, QWP_USER, 0); | |
172 free(ptr); | |
173 } | |
174 | |
175 _free_window_memory(child); | |
176 } | |
177 WinEndEnumWindows(henum); | |
178 return; | |
179 } | |
180 | |
181 /* This function returns 1 if the window (widget) handle | |
182 * passed to it is a valid window that can gain input focus. | |
183 */ | |
184 int _validate_focus(HWND handle) | |
185 { | |
186 char tmpbuf[100]; | |
187 | |
188 if(!handle) | |
189 return 0; | |
190 | |
191 WinQueryClassName(handle, 99, tmpbuf); | |
192 | |
193 /* These are the window classes which can | |
194 * obtain input focus. | |
195 */ | |
196 if(strncmp(tmpbuf, "#2", 2)==0 || /* Entryfield */ | |
197 strncmp(tmpbuf, "#3", 2)==0 || /* Button */ | |
198 strncmp(tmpbuf, "#6", 2)==0 || /* Combobox */ | |
199 strncmp(tmpbuf, "#7", 2)==0 || /* List box */ | |
200 strncmp(tmpbuf, "#10", 3)==0 || /* MLE */ | |
201 strncmp(tmpbuf, "#32", 3)==0 || /* Spinbutton */ | |
202 strncmp(tmpbuf, "#37", 3)== 0) /* Container */ | |
203 return 1; | |
204 return 0; | |
205 } | |
206 | |
207 int _focus_check_box(Box *box, HWND handle, int start) | |
208 { | |
209 int z; | |
210 static HWND lasthwnd, firsthwnd; | |
211 static int finish_searching; | |
212 | |
213 /* Start is 2 when we have cycled completely and | |
214 * need to set the focus to the last widget we found | |
215 * that was valid. | |
216 */ | |
217 if(start == 2) | |
218 { | |
219 if(lasthwnd) | |
220 WinSetFocus(HWND_DESKTOP, lasthwnd); | |
221 return 0; | |
222 } | |
223 | |
224 /* Start is 1 when we are entering the function | |
225 * for the first time, it is zero when entering | |
226 * the function recursively. | |
227 */ | |
228 if(start == 1) | |
229 { | |
230 lasthwnd = handle; | |
231 finish_searching = 0; | |
232 firsthwnd = 0; | |
233 } | |
234 | |
235 /* Vertical boxes are inverted on OS/2 */ | |
236 if(box->type == BOXVERT) | |
237 { | |
238 for(z=0;z<box->count;z++) | |
239 { | |
240 if(box->items[z].type == TYPEBOX) | |
241 { | |
242 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER); | |
243 | |
244 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0)) | |
245 return 1; | |
246 } | |
247 else | |
248 { | |
249 if(box->items[z].hwnd == handle) | |
250 { | |
251 if(lasthwnd == handle && firsthwnd) | |
252 WinSetFocus(HWND_DESKTOP, firsthwnd); | |
253 else if(lasthwnd == handle && !firsthwnd) | |
254 finish_searching = 1; | |
255 else | |
256 WinSetFocus(HWND_DESKTOP, lasthwnd); | |
257 | |
258 /* If we aren't looking for the last handle, | |
259 * return immediately. | |
260 */ | |
261 if(!finish_searching) | |
262 return 1; | |
263 } | |
264 if(_validate_focus(box->items[z].hwnd)) | |
265 { | |
266 /* Start is 3 when we are looking for the | |
267 * first valid item in the layout. | |
268 */ | |
269 if(start == 3) | |
270 { | |
271 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd); | |
272 return 1; | |
273 } | |
274 | |
275 if(!firsthwnd) | |
276 firsthwnd = box->items[z].hwnd; | |
277 | |
278 lasthwnd = box->items[z].hwnd; | |
279 } | |
280 else | |
281 { | |
282 char tmpbuf[100] = ""; | |
283 | |
284 WinQueryClassName(box->items[z].hwnd, 99, tmpbuf); | |
285 if(strncmp(tmpbuf, "#40", 3)==0) /* Notebook */ | |
286 { | |
287 Box *notebox; | |
288 HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND, | |
289 (MPARAM)dw_notebook_page_query(box->items[z].hwnd), 0); | |
290 | |
291 if(page) | |
292 { | |
293 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER); | |
294 | |
295 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0)) | |
296 return 1; | |
297 } | |
298 } | |
299 } | |
300 } | |
301 } | |
302 } | |
303 else | |
304 { | |
305 for(z=box->count-1;z>-1;z--) | |
306 { | |
307 if(box->items[z].type == TYPEBOX) | |
308 { | |
309 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER); | |
310 | |
311 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0)) | |
312 return 1; | |
313 } | |
314 else | |
315 { | |
316 if(box->items[z].hwnd == handle) | |
317 { | |
318 if(lasthwnd == handle && firsthwnd) | |
319 WinSetFocus(HWND_DESKTOP, firsthwnd); | |
320 else if(lasthwnd == handle && !firsthwnd) | |
321 finish_searching = 1; | |
322 else | |
323 WinSetFocus(HWND_DESKTOP, lasthwnd); | |
324 | |
325 /* If we aren't looking for the last handle, | |
326 * return immediately. | |
327 */ | |
328 if(!finish_searching) | |
329 return 1; | |
330 } | |
331 if(_validate_focus(box->items[z].hwnd)) | |
332 { | |
333 /* Start is 3 when we are looking for the | |
334 * first valid item in the layout. | |
335 */ | |
336 if(start == 3) | |
337 { | |
338 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd); | |
339 return 1; | |
340 } | |
341 | |
342 if(!firsthwnd) | |
343 firsthwnd = box->items[z].hwnd; | |
344 | |
345 lasthwnd = box->items[z].hwnd; | |
346 } | |
347 else | |
348 { | |
349 char tmpbuf[100] = ""; | |
350 | |
351 WinQueryClassName(box->items[z].hwnd, 99, tmpbuf); | |
352 if(strncmp(tmpbuf, "#40", 3)==0) /* Notebook */ | |
353 { | |
354 Box *notebox; | |
355 HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND, | |
356 (MPARAM)dw_notebook_page_query(box->items[z].hwnd), 0); | |
357 | |
358 if(page) | |
359 { | |
360 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER); | |
361 | |
362 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0)) | |
363 return 1; | |
364 } | |
365 } | |
366 } | |
367 } | |
368 } | |
369 } | |
370 return 0; | |
371 } | |
372 | |
373 /* This function finds the first widget in the | |
374 * layout and moves the current focus to it. | |
375 */ | |
376 void _initial_focus(HWND handle) | |
377 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
378 Box *thisbox = NULL; |
3 | 379 HWND box; |
380 | |
381 box = WinWindowFromID(handle, FID_CLIENT); | |
382 if(box) | |
383 thisbox = WinQueryWindowPtr(box, QWP_USER); | |
384 | |
385 if(thisbox) | |
386 { | |
387 _focus_check_box(thisbox, handle, 3); | |
388 } | |
389 } | |
390 | |
391 /* This function finds the current widget in the | |
392 * layout and moves the current focus to the next item. | |
393 */ | |
394 void _shift_focus(HWND handle) | |
395 { | |
396 Box *thisbox; | |
397 HWND box, lastbox = WinQueryWindow(handle, QW_PARENT); | |
398 | |
399 /* Find the toplevel window */ | |
400 while((box = WinQueryWindow(lastbox, QW_PARENT)) > 0x80000001) | |
401 { | |
402 lastbox = box; | |
403 } | |
404 | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
405 box = WinWindowFromID(lastbox, FID_CLIENT); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
406 if(box) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
407 thisbox = WinQueryWindowPtr(box, QWP_USER); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
408 else |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
409 thisbox = WinQueryWindowPtr(lastbox, QWP_USER); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
410 |
3 | 411 if(thisbox) |
412 { | |
413 if(_focus_check_box(thisbox, handle, 1) == 0) | |
414 _focus_check_box(thisbox, handle, 2); | |
415 } | |
416 } | |
417 | |
418 /* ResetWindow: | |
419 * Resizes window to the exact same size to trigger | |
420 * recalculation of frame. | |
421 */ | |
422 void _ResetWindow(HWND hwndFrame) | |
423 { | |
424 SWP swp; | |
425 | |
426 WinQueryWindowPos(hwndFrame, &swp); | |
427 WinSetWindowPos(hwndFrame, HWND_TOP, 0, 0, swp.cx, swp.cy-1, SWP_SIZE); | |
428 WinSetWindowPos(hwndFrame, HWND_TOP, 0, 0, swp.cx, swp.cy, SWP_SIZE); | |
429 } | |
430 | |
431 /* This function will recursively search a box and add up the total height of it */ | |
432 void _count_size(HWND box, int type, int *xsize, int *xorigsize) | |
433 { | |
434 int size = 0, origsize = 0, z; | |
435 Box *tmp = WinQueryWindowPtr(box, QWP_USER); | |
436 | |
437 if(!tmp) | |
438 { | |
439 *xsize = *xorigsize = 0; | |
440 return; | |
441 } | |
442 | |
443 if(type == tmp->type) | |
444 { | |
445 /* If the box is going in the direction we want, then we | |
446 * return the entire sum of the items. | |
447 */ | |
448 for(z=0;z<tmp->count;z++) | |
449 { | |
450 if(tmp->items[z].type == TYPEBOX) | |
451 { | |
452 int s, os; | |
453 | |
454 _count_size(tmp->items[z].hwnd, type, &s, &os); | |
455 size += s; | |
456 origsize += os; | |
457 } | |
458 else | |
459 { | |
460 size += (type == BOXHORZ ? tmp->items[z].width : tmp->items[z].height); | |
461 origsize += (type == BOXHORZ ? tmp->items[z].origwidth : tmp->items[z].origheight); | |
462 } | |
463 } | |
464 } | |
465 else | |
466 { | |
467 /* If the box is not going in the direction we want, then we only | |
468 * want to return the maximum value. | |
469 */ | |
470 int tmpsize = 0, tmporigsize = 0; | |
471 | |
472 for(z=0;z<tmp->count;z++) | |
473 { | |
474 if(tmp->items[z].type == TYPEBOX) | |
475 _count_size(tmp->items[z].hwnd, type, &tmpsize, &tmporigsize); | |
476 else | |
477 { | |
478 tmpsize = (type == BOXHORZ ? tmp->items[z].width : tmp->items[z].height); | |
479 tmporigsize = (type == BOXHORZ ? tmp->items[z].origwidth : tmp->items[z].origheight); | |
480 } | |
481 | |
482 if(tmpsize > size) | |
483 size = tmpsize; | |
484 } | |
485 } | |
486 | |
487 *xsize = size; | |
488 *xorigsize = origsize; | |
489 } | |
490 | |
491 | |
492 /* Function: TrackRectangle | |
493 * Abstract: Tracks given rectangle. | |
494 * | |
495 * If rclBounds is NULL, then track rectangle on entire desktop. | |
496 * rclTrack is in window coorditates and will be mapped to | |
497 * desktop. | |
498 */ | |
499 | |
500 BOOL _TrackRectangle(HWND hwndBase, RECTL* rclTrack, RECTL* rclBounds) | |
501 { | |
502 TRACKINFO track; | |
503 APIRET rc; | |
504 | |
505 track.cxBorder = 1; | |
506 track.cyBorder = 1; | |
507 track.cxGrid = 1; | |
508 track.cyGrid = 1; | |
509 track.cxKeyboard = 8; | |
510 track.cyKeyboard = 8; | |
511 | |
512 if(!rclTrack) | |
513 return FALSE; | |
514 | |
515 if(rclBounds) | |
516 { | |
517 track.rclBoundary = *rclBounds; | |
518 } | |
519 else | |
520 { | |
521 track.rclBoundary.yTop = | |
522 track.rclBoundary.xRight = 3000; | |
523 track.rclBoundary.yBottom = | |
524 track.rclBoundary.xLeft = -3000; | |
525 } | |
526 | |
527 track.rclTrack = *rclTrack; | |
528 | |
529 WinMapWindowPoints(hwndBase, | |
530 HWND_DESKTOP, | |
531 (PPOINTL)&track.rclTrack, | |
532 2); | |
533 | |
534 track.ptlMinTrackSize.x = track.rclTrack.xRight | |
535 - track.rclTrack.xLeft; | |
536 track.ptlMinTrackSize.y = track.rclTrack.yTop | |
537 - track.rclTrack.yBottom; | |
538 track.ptlMaxTrackSize.x = track.rclTrack.xRight | |
539 - track.rclTrack.xLeft; | |
540 track.ptlMaxTrackSize.y = track.rclTrack.yTop | |
541 - track.rclTrack.yBottom; | |
542 | |
543 track.fs = TF_MOVE | TF_ALLINBOUNDARY; | |
544 | |
545 rc = WinTrackRect(HWND_DESKTOP, 0, &track); | |
546 | |
547 if(rc) | |
548 *rclTrack = track.rclTrack; | |
549 | |
550 return rc; | |
551 } | |
552 | |
553 /* This function calculates how much space the widgets and boxes require | |
554 * and does expansion as necessary. | |
555 */ | |
556 int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy, | |
557 int pass, int *usedpadx, int *usedpady) | |
558 { | |
559 int z, currentx = 0, currenty = 0; | |
560 int vectorx = 0, vectory = 0; | |
561 int uymax = 0, uxmax = 0; | |
562 int upymax = 0, upxmax = 0; | |
563 /* Used for the SIZEEXPAND */ | |
564 int nux = *usedx, nuy = *usedy; | |
565 int nupx = *usedpadx, nupy = *usedpady; | |
566 | |
567 (*usedx) += (thisbox->pad * 2); | |
568 (*usedy) += (thisbox->pad * 2); | |
569 | |
570 for(z=0;z<thisbox->count;z++) | |
571 { | |
572 if(thisbox->items[z].type == TYPEBOX) | |
573 { | |
574 int initialx, initialy; | |
575 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); | |
576 | |
577 initialx = x - (*usedx); | |
578 initialy = y - (*usedy); | |
579 | |
580 if(tmp) | |
581 { | |
582 int newx, newy; | |
583 int nux = *usedx, nuy = *usedy; | |
584 int upx = *usedpadx + (tmp->pad*2), upy = *usedpady + (tmp->pad*2); | |
585 | |
586 /* On the second pass we know how big the box needs to be and how | |
587 * much space we have, so we can calculate a ratio for the new box. | |
588 */ | |
589 if(pass == 2) | |
590 { | |
591 int deep = *depth + 1; | |
592 | |
593 _resize_box(tmp, &deep, x, y, &nux, &nuy, 1, &upx, &upy); | |
594 | |
595 tmp->upx = upx - *usedpadx; | |
596 tmp->upy = upy - *usedpady; | |
597 | |
598 newx = x - nux; | |
599 newy = y - nuy; | |
600 | |
601 tmp->width = thisbox->items[z].width = initialx - newx; | |
602 tmp->height = thisbox->items[z].height = initialy - newy; | |
603 | |
604 tmp->parentxratio = thisbox->xratio; | |
605 tmp->parentyratio = thisbox->yratio; | |
606 | |
607 tmp->parentpad = tmp->pad; | |
608 | |
609 /* Just in case */ | |
610 tmp->xratio = thisbox->xratio; | |
611 tmp->yratio = thisbox->yratio; | |
612 | |
613 #ifdef DWDEBUG | |
614 if(pass > 1) | |
615 { | |
616 fprintf(f, "FARK! depth %d\r\nwidth = %d, height = %d, nux = %d, nuy = %d, upx = %d, upy = %d xratio = %f, yratio = %f\r\n\r\n", | |
617 *depth, thisbox->items[z].width, thisbox->items[z].height, nux, nuy, tmp->upx, tmp->upy, tmp->xratio, tmp->yratio); | |
618 reopen(); | |
619 } | |
620 #endif | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
621 |
3 | 622 if(thisbox->type == BOXVERT) |
623 { | |
624 if((thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) | |
625 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))); | |
626 } | |
627 else | |
628 { | |
629 if((thisbox->items[z].width-tmp->upx)!=0) | |
630 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx)); | |
631 } | |
632 if(thisbox->type == BOXHORZ) | |
633 { | |
634 if((thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) | |
635 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))); | |
636 } | |
637 else | |
638 { | |
639 if((thisbox->items[z].height-tmp->upy)!=0) | |
640 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy)); | |
641 } | |
642 | |
643 nux = *usedx; nuy = *usedy; | |
644 upx = *usedpadx + (tmp->pad*2); upy = *usedpady + (tmp->pad*2); | |
645 } | |
646 | |
647 (*depth)++; | |
648 | |
649 #ifdef DWDEBUG | |
650 if(pass > 1) | |
651 { | |
652 fprintf(f, "Before Resize Box depth %d\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d xratio = %f, yratio = %f\r\n\r\n", | |
653 *depth, x, y, *usedx, *usedy, *usedpadx, *usedpady, tmp->xratio, tmp->yratio); | |
654 reopen(); | |
655 } | |
656 #endif | |
657 | |
658 _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &upx, &upy); | |
659 | |
660 (*depth)--; | |
661 | |
662 newx = x - nux; | |
663 newy = y - nuy; | |
664 | |
665 tmp->minwidth = thisbox->items[z].width = initialx - newx; | |
666 tmp->minheight = thisbox->items[z].height = initialy - newy; | |
667 | |
668 #ifdef DWDEBUG | |
669 if(pass > 1) | |
670 { | |
671 fprintf(f, "After Resize Box depth %d\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d width = %d, height = %d\r\n\r\n", | |
672 *depth, x, y, *usedx, *usedy, *usedpadx, *usedpady, thisbox->items[z].width, thisbox->items[z].height); | |
673 reopen(); | |
674 } | |
675 #endif | |
676 } | |
677 } | |
678 | |
679 if(pass > 1 && *depth > 0) | |
680 { | |
681 if(thisbox->type == BOXVERT) | |
682 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2)))); | |
683 else | |
684 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx)); | |
685 | |
686 if(thisbox->type == BOXHORZ) | |
687 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2)))); | |
688 else | |
689 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy)); | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
690 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
691 if(thisbox->items[z].type == TYPEBOX) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
692 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
693 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
694 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
695 if(tmp) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
696 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
697 tmp->parentxratio = thisbox->items[z].xratio; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
698 tmp->parentyratio = thisbox->items[z].yratio; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
699 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
700 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
701 |
3 | 702 #ifdef DWDEBUG |
703 fprintf(f, "RATIO- xratio = %f, yratio = %f, width = %d, height = %d, pad = %d, box xratio = %f, box yratio = %f, parent xratio = %f, parent yratio = %f, minwidth = %d, minheight = %d, width = %d, height = %d, upx = %d, upy = %d\r\n\r\n", | |
704 thisbox->items[z].xratio, thisbox->items[z].yratio, thisbox->items[z].width, thisbox->items[z].height, thisbox->items[z].pad, thisbox->xratio, thisbox->yratio, thisbox->parentxratio, thisbox->parentyratio, thisbox->minwidth, thisbox->minheight, thisbox->width, thisbox->height, thisbox->upx, thisbox->upy); | |
705 reopen(); | |
706 #endif | |
707 } | |
708 else | |
709 { | |
710 thisbox->items[z].xratio = thisbox->xratio; | |
711 thisbox->items[z].yratio = thisbox->yratio; | |
712 } | |
713 | |
714 if(thisbox->type == BOXVERT) | |
715 { | |
716 if((thisbox->items[z].width + (thisbox->items[z].pad*2)) > uxmax) | |
717 uxmax = (thisbox->items[z].width + (thisbox->items[z].pad*2)); | |
718 if(thisbox->items[z].hsize != SIZEEXPAND) | |
719 { | |
720 if(((thisbox->items[z].pad*2) + thisbox->items[z].width) > upxmax) | |
721 upxmax = (thisbox->items[z].pad*2) + thisbox->items[z].width; | |
722 } | |
723 else | |
724 { | |
725 if(thisbox->items[z].pad*2 > upxmax) | |
726 upxmax = thisbox->items[z].pad*2; | |
727 } | |
728 } | |
729 else | |
730 { | |
731 if(thisbox->items[z].width == -1) | |
732 { | |
733 /* figure out how much space this item requires */ | |
734 /* thisbox->items[z].width = */ | |
735 } | |
736 else | |
737 { | |
738 (*usedx) += thisbox->items[z].width + (thisbox->items[z].pad*2); | |
739 if(thisbox->items[z].hsize != SIZEEXPAND) | |
740 (*usedpadx) += (thisbox->items[z].pad*2) + thisbox->items[z].width; | |
741 else | |
742 (*usedpadx) += thisbox->items[z].pad*2; | |
743 } | |
744 } | |
745 if(thisbox->type == BOXHORZ) | |
746 { | |
747 if((thisbox->items[z].height + (thisbox->items[z].pad*2)) > uymax) | |
748 uymax = (thisbox->items[z].height + (thisbox->items[z].pad*2)); | |
749 if(thisbox->items[z].vsize != SIZEEXPAND) | |
750 { | |
751 if(((thisbox->items[z].pad*2) + thisbox->items[z].height) > upymax) | |
752 upymax = (thisbox->items[z].pad*2) + thisbox->items[z].height; | |
753 } | |
754 else | |
755 { | |
756 if(thisbox->items[z].pad*2 > upymax) | |
757 upymax = thisbox->items[z].pad*2; | |
758 } | |
759 } | |
760 else | |
761 { | |
762 if(thisbox->items[z].height == -1) | |
763 { | |
764 /* figure out how much space this item requires */ | |
765 /* thisbox->items[z].height = */ | |
766 } | |
767 else | |
768 { | |
769 (*usedy) += thisbox->items[z].height + (thisbox->items[z].pad*2); | |
770 if(thisbox->items[z].vsize != SIZEEXPAND) | |
771 (*usedpady) += (thisbox->items[z].pad*2) + thisbox->items[z].height; | |
772 else | |
773 (*usedpady) += thisbox->items[z].pad*2; | |
774 } | |
775 } | |
776 } | |
777 | |
778 (*usedx) += uxmax; | |
779 (*usedy) += uymax; | |
780 (*usedpadx) += upxmax; | |
781 (*usedpady) += upymax; | |
782 | |
783 currentx += thisbox->pad; | |
784 currenty += thisbox->pad; | |
785 | |
786 #ifdef DWDEBUG | |
787 fprintf(f, "Done Calc depth %d\r\nusedx = %d, usedy = %d, usedpadx = %d, usedpady = %d, currentx = %d, currenty = %d, uxmax = %d, uymax = %d\r\n\r\n", | |
788 *depth, *usedx, *usedy, *usedpadx, *usedpady, currentx, currenty, uxmax, uymax); | |
789 reopen(); | |
790 #endif | |
791 | |
792 /* The second pass is for expansion and actual placement. */ | |
793 if(pass > 1) | |
794 { | |
795 /* Any SIZEEXPAND items should be set to uxmax/uymax */ | |
796 for(z=0;z<thisbox->count;z++) | |
797 { | |
798 if(thisbox->items[z].hsize == SIZEEXPAND && thisbox->type == BOXVERT) | |
799 thisbox->items[z].width = uxmax-(thisbox->items[z].pad*2); | |
800 if(thisbox->items[z].vsize == SIZEEXPAND && thisbox->type == BOXHORZ) | |
801 thisbox->items[z].height = uymax-(thisbox->items[z].pad*2); | |
802 /* Run this code segment again to finalize the sized after setting uxmax/uymax values. */ | |
803 if(thisbox->items[z].type == TYPEBOX) | |
804 { | |
805 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); | |
806 | |
807 if(tmp) | |
808 { | |
809 if(*depth > 0) | |
810 { | |
811 if(thisbox->type == BOXVERT) | |
812 { | |
813 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/((float)(tmp->minwidth-((thisbox->items[z].pad*2)+(thisbox->pad*2)))); | |
814 tmp->width = thisbox->items[z].width; | |
815 } | |
816 if(thisbox->type == BOXHORZ) | |
817 { | |
818 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/((float)(tmp->minheight-((thisbox->items[z].pad*2)+(thisbox->pad*2)))); | |
819 tmp->height = thisbox->items[z].height; | |
820 } | |
821 } | |
822 | |
823 (*depth)++; | |
824 | |
825 /*tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx) )/((float)(tmp->minwidth-tmp->upx)); | |
826 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(tmp->minheight-tmp->upy));*/ | |
827 | |
828 #ifdef DWDEBUG | |
829 fprintf(f, "2- Resize Box depth %d\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d xratio = %f, yratio = %f,\r\nupx = %d, upy = %d, width = %d, height = %d, minwidth = %d, minheight = %d, box xratio = %f, box yratio = %f\r\n\r\n", | |
830 *depth, x, y, *usedx, *usedy, *usedpadx, *usedpady, tmp->xratio, tmp->yratio, tmp->upx, tmp->upy, thisbox->items[z].width, thisbox->items[z].height, tmp->minwidth, tmp->minheight, thisbox->xratio, thisbox->yratio); | |
831 reopen(); | |
832 #endif | |
833 | |
834 _resize_box(tmp, depth, x, y, &nux, &nuy, 3, &nupx, &nupy); | |
835 | |
836 (*depth)--; | |
837 | |
838 } | |
839 } | |
840 } | |
841 | |
842 for(z=0;z<(thisbox->count);z++) | |
843 { | |
844 int height = thisbox->items[z].height; | |
845 int width = thisbox->items[z].width; | |
846 int pad = thisbox->items[z].pad; | |
847 HWND handle = thisbox->items[z].hwnd; | |
848 | |
849 /* When upxmax != pad*2 then ratios are incorrect. */ | |
850 vectorx = (int)((width*thisbox->items[z].xratio)-width); | |
851 vectory = (int)((height*thisbox->items[z].yratio)-height); | |
852 | |
853 if(width > 0 && height > 0) | |
854 { | |
855 char tmpbuf[100]; | |
856 /* This is a hack to fix rounding of the sizing */ | |
857 if(*depth == 0) | |
858 { | |
859 vectorx++; | |
860 vectory++; | |
861 } | |
862 | |
863 /* If this item isn't going to expand... reset the vectors to 0 */ | |
864 if(thisbox->items[z].vsize != SIZEEXPAND) | |
865 vectory = 0; | |
866 if(thisbox->items[z].hsize != SIZEEXPAND) | |
867 vectorx = 0; | |
868 | |
869 WinQueryClassName(handle, 99, tmpbuf); | |
870 | |
871 if(strncmp(tmpbuf, "#2", 2)==0) | |
872 { | |
873 /* Make the combobox big enough to drop down. :) */ | |
874 WinSetWindowPos(handle, HWND_TOP, currentx + pad, (currenty + pad) - 100, | |
875 width + vectorx, (height + vectory) + 100, SWP_MOVE | SWP_SIZE | SWP_ZORDER); | |
876 } | |
877 else if(strncmp(tmpbuf, "#6", 2)==0) | |
878 { | |
879 /* Entryfields on OS/2 have a thick border that isn't on Windows and GTK */ | |
880 WinSetWindowPos(handle, HWND_TOP, (currentx + pad) + 3, (currenty + pad) + 3, | |
881 (width + vectorx) - 6, (height + vectory) - 6, SWP_MOVE | SWP_SIZE | SWP_ZORDER); | |
882 } | |
883 else | |
884 { | |
885 WinSetWindowPos(handle, HWND_TOP, currentx + pad, currenty + pad, | |
886 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER); | |
887 if(thisbox->items[z].type == TYPEBOX) | |
888 { | |
889 Box *boxinfo = WinQueryWindowPtr(handle, QWP_USER); | |
890 | |
891 if(boxinfo && boxinfo->grouphwnd) | |
892 WinSetWindowPos(boxinfo->grouphwnd, HWND_TOP, 0, 0, | |
893 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER); | |
894 | |
895 } | |
896 | |
897 } | |
898 | |
899 #ifdef DWDEBUG | |
900 fprintf(f, "Window Pos depth %d\r\ncurrentx = %d, currenty = %d, pad = %d, width = %d, height = %d, vectorx = %d, vectory = %d, Box type = %s\r\n\r\n", | |
901 *depth, currentx, currenty, pad, width, height, vectorx, vectory,thisbox->type == BOXHORZ ? "Horizontal" : "Vertical"); | |
902 reopen(); | |
903 #endif | |
904 | |
905 if(thisbox->type == BOXHORZ) | |
906 currentx += width + vectorx + (pad * 2); | |
907 if(thisbox->type == BOXVERT) | |
908 currenty += height + vectory + (pad * 2); | |
909 } | |
910 } | |
911 } | |
912 return 0; | |
913 } | |
914 | |
915 void _do_resize(Box *thisbox, int x, int y) | |
916 { | |
917 if(x != 0 && y != 0) { | |
918 if(thisbox) | |
919 { | |
920 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0; | |
921 | |
922 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady); | |
923 | |
924 if(usedx-usedpadx == 0 || usedy-usedpady == 0) | |
925 return; | |
926 | |
927 thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx)); | |
928 thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady)); | |
929 | |
930 #ifdef DWDEBUG | |
931 fprintf(f, "WM_SIZE Resize Box Pass 1\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d xratio = %f, yratio = %f\r\n\r\n", | |
932 x, y, usedx, usedy, usedpadx, usedpady, thisbox->xratio, thisbox->yratio); | |
933 reopen(); | |
934 #endif | |
935 | |
936 usedx = usedy = usedpadx = usedpady = depth = 0; | |
937 | |
938 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady); | |
939 #ifdef DWDEBUG | |
940 fprintf(f, "WM_SIZE Resize Box Pass 2\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d\r\n", | |
941 x, y, usedx, usedy, usedpadx, usedpady); | |
942 reopen(); | |
943 #endif | |
944 } | |
945 } | |
946 } | |
947 | |
948 /* This procedure handles WM_QUERYTRACKINFO requests from the frame */ | |
949 MRESULT EXPENTRY _sizeproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) | |
950 { | |
951 PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER); | |
952 | |
953 switch(msg) | |
954 { | |
955 case WM_QUERYTRACKINFO: | |
956 { | |
957 if(blah && *blah) | |
958 { | |
959 PTRACKINFO ptInfo; | |
960 int res; | |
961 PFNWP myfunc = *blah; | |
962 res = (int)myfunc(hWnd, msg, mp1, mp2); | |
963 | |
964 ptInfo = (PTRACKINFO)(mp2); | |
965 | |
966 ptInfo->ptlMinTrackSize.y = 8; | |
967 ptInfo->ptlMinTrackSize.x = 8; | |
968 | |
969 return (MRESULT)res; | |
970 } | |
971 } | |
972 } | |
973 if(blah && *blah) | |
974 { | |
975 PFNWP myfunc = *blah; | |
976 return myfunc(hWnd, msg, mp1, mp2); | |
977 } | |
978 | |
979 return WinDefWindowProc(hWnd, msg, mp1, mp2); | |
980 } | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
981 /* This procedure handles drawing of a status border */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
982 MRESULT EXPENTRY _statusproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
983 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
984 PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
985 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
986 if(blah && *blah) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
987 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
988 PFNWP myfunc = *blah; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
989 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
990 switch(msg) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
991 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
992 case WM_PAINT: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
993 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
994 HPS hpsPaint; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
995 RECTL rclPaint; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
996 POINTL ptl1, ptl2; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
997 char buf[1024]; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
998 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
999 hpsPaint = WinBeginPaint(hWnd, 0, 0); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1000 WinQueryWindowRect(hWnd, &rclPaint); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1001 WinFillRect(hpsPaint, &rclPaint, CLR_PALEGRAY); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1002 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1003 GpiSetColor(hpsPaint, CLR_DARKGRAY); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1004 ptl1.x = 0; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1005 ptl2.y = ptl1.y = rclPaint.yTop - rclPaint.yBottom; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1006 ptl2.x = rclPaint.xRight - rclPaint.xLeft; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1007 GpiMove(hpsPaint, &ptl1); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1008 GpiLine(hpsPaint, &ptl2); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1009 ptl2.y = ptl2.x = 0; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1010 GpiMove(hpsPaint, &ptl1); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1011 GpiLine(hpsPaint, &ptl2); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1012 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1013 GpiSetColor(hpsPaint, CLR_WHITE); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1014 ptl2.x = ptl1.x = rclPaint.xRight - rclPaint.xLeft; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1015 ptl1.y = 0; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1016 ptl2.y = rclPaint.yTop - rclPaint.yBottom; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1017 GpiMove(hpsPaint, &ptl1); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1018 GpiLine(hpsPaint, &ptl2); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1019 ptl2.y = ptl2.x = 0; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1020 GpiMove(hpsPaint, &ptl1); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1021 GpiLine(hpsPaint, &ptl2); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1022 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1023 WinQueryWindowText(hWnd, 1024, buf); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1024 rclPaint.xLeft += 3; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1025 rclPaint.xRight--; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1026 rclPaint.yTop--; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1027 rclPaint.yBottom++; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1028 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1029 GpiSetColor(hpsPaint, CLR_BLACK); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1030 WinDrawText(hpsPaint, -1, buf, &rclPaint, DT_TEXTATTRS, DT_TEXTATTRS, DT_VCENTER | DT_LEFT | DT_TEXTATTRS); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1031 WinEndPaint(hpsPaint); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1032 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1033 return (MRESULT)TRUE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1034 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1035 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1036 return myfunc(hWnd, msg, mp1, mp2); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1037 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1038 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1039 return WinDefWindowProc(hWnd, msg, mp1, mp2); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1040 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1041 |
3 | 1042 /* Originally just intended for entryfields, it now serves as a generic |
1043 * procedure for handling TAB presses to change input focus on controls. | |
1044 */ | |
1045 MRESULT EXPENTRY _entryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) | |
1046 { | |
1047 PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER); | |
1048 | |
1049 switch(msg) | |
1050 { | |
1051 case WM_CHAR: | |
1052 if(SHORT1FROMMP(mp2) == '\t') | |
1053 { | |
1054 _shift_focus(hWnd); | |
1055 return FALSE; | |
1056 } | |
1057 break; | |
1058 } | |
1059 if(blah && *blah) | |
1060 { | |
1061 PFNWP myfunc = *blah; | |
1062 return myfunc(hWnd, msg, mp1, mp2); | |
1063 } | |
1064 | |
1065 return WinDefWindowProc(hWnd, msg, mp1, mp2); | |
1066 } | |
1067 | |
1068 /* Handle correct painting of a combobox with the WS_CLIPCHILDREN | |
1069 * flag enabled, and also handle TABs to switch input focus. | |
1070 */ | |
1071 MRESULT EXPENTRY _comboproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) | |
1072 { | |
1073 PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER); | |
1074 | |
1075 switch(msg) | |
1076 { | |
1077 case WM_CHAR: | |
1078 if(SHORT1FROMMP(mp2) == '\t') | |
1079 { | |
1080 _shift_focus(hWnd); | |
1081 return FALSE; | |
1082 } | |
1083 break; | |
1084 case WM_PAINT: | |
1085 { | |
1086 HWND parent = WinQueryWindow(hWnd, QW_PARENT); | |
1087 ULONG bcol, av[32]; | |
1088 HPS hpsPaint; | |
1089 POINTL ptl; /* Add 6 because it has a thick border like the entryfield */ | |
1090 unsigned long width, height, thumbheight = WinQuerySysValue(HWND_DESKTOP, SV_CYVSCROLLARROW) + 6; | |
1091 | |
1092 WinQueryPresParam(parent, PP_BACKGROUNDCOLORINDEX, 0, &bcol, sizeof(ULONG), &av, QPF_ID1COLORINDEX | QPF_NOINHERIT); | |
1093 dw_window_get_pos_size(hWnd, 0, 0, &width, &height); | |
1094 | |
1095 hpsPaint = WinGetPS(hWnd); | |
1096 GpiSetColor(hpsPaint, CLR_PALEGRAY); | |
1097 | |
1098 ptl.x = 0; | |
1099 ptl.y = 99; | |
1100 GpiMove(hpsPaint, &ptl); | |
1101 | |
1102 ptl.x = width; | |
1103 ptl.y = height - thumbheight; | |
1104 GpiBox(hpsPaint, DRO_FILL, &ptl, 0, 0); | |
1105 | |
1106 WinReleasePS(hpsPaint); | |
1107 } | |
1108 break; | |
1109 } | |
1110 if(blah && *blah) | |
1111 { | |
1112 PFNWP myfunc = *blah; | |
1113 return myfunc(hWnd, msg, mp1, mp2); | |
1114 } | |
1115 | |
1116 return WinDefWindowProc(hWnd, msg, mp1, mp2); | |
1117 } | |
1118 | |
1119 void _GetPPFont(HWND hwnd, char *buff) | |
1120 { | |
1121 ULONG AttrFound; | |
1122 BYTE AttrValue[128]; | |
1123 ULONG cbRetLen; | |
1124 | |
1125 cbRetLen = WinQueryPresParam(hwnd, | |
1126 PP_FONTNAMESIZE, | |
1127 0, | |
1128 &AttrFound, | |
1129 sizeof(AttrValue), | |
1130 &AttrValue, | |
1131 QPF_NOINHERIT); | |
1132 | |
1133 if(PP_FONTNAMESIZE == AttrFound && cbRetLen) | |
1134 { | |
1135 memcpy(buff, AttrValue, cbRetLen); | |
1136 } | |
1137 } | |
1138 | |
1139 /* Returns height of specified window. */ | |
1140 int _get_height(HWND handle) | |
1141 { | |
1142 unsigned long height; | |
1143 dw_window_get_pos_size(handle, NULL, NULL, NULL, &height); | |
1144 return (int)height; | |
1145 } | |
1146 | |
1147 /* Find the height of the frame a desktop style window is sitting on */ | |
1148 int _get_frame_height(HWND handle) | |
1149 { | |
1150 while(handle) | |
1151 { | |
1152 HWND client; | |
1153 if((client = WinWindowFromID(handle, FID_CLIENT)) != NULLHANDLE) | |
1154 { | |
1155 return _get_height(WinQueryWindow(handle, QW_PARENT)); | |
1156 } | |
1157 handle = WinQueryWindow(handle, QW_PARENT); | |
1158 } | |
1159 return dw_screen_height(); | |
1160 } | |
1161 | |
1162 #ifndef NO_SIGNALS | |
1163 MRESULT EXPENTRY _run_event(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) | |
1164 { | |
1165 int result = -1; | |
1166 SignalHandler *tmp = Root; | |
1167 ULONG origmsg = msg; | |
1168 | |
1169 if(msg == WM_BUTTON2DOWN || msg == WM_BUTTON3DOWN) | |
1170 msg = WM_BUTTON1DOWN; | |
1171 if(msg == WM_BUTTON2UP || msg == WM_BUTTON3UP) | |
1172 msg = WM_BUTTON1UP; | |
1173 | |
1174 /* Find any callbacks for this function */ | |
1175 while(tmp) | |
1176 { | |
1177 if(tmp->message == msg || msg == WM_CONTROL) | |
1178 { | |
1179 switch(msg) | |
1180 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1181 case WM_SETFOCUS: |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1182 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1183 if(mp2) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1184 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1185 int (*setfocusfunc)(HWND, void *) = (int (*)(HWND, void *))tmp->signalfunction; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1186 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1187 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1188 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1189 result = setfocusfunc(tmp->window, tmp->data); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1190 tmp = NULL; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1191 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1192 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1193 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1194 break; |
3 | 1195 case WM_SIZE: |
1196 { | |
1197 int (*sizefunc)(HWND, int, int, void *) = (int (*)(HWND, int, int, void *))tmp->signalfunction; | |
1198 | |
1199 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd) | |
1200 { | |
1201 result = sizefunc(tmp->window, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), tmp->data); | |
1202 tmp = NULL; | |
1203 } | |
1204 } | |
1205 break; | |
1206 case WM_BUTTON1DOWN: | |
1207 { | |
1208 POINTS pts = (*((POINTS*)&mp1)); | |
1209 int (*buttonfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction; | |
1210 | |
1211 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window) | |
1212 { | |
1213 int button; | |
1214 | |
1215 switch(origmsg) | |
1216 { | |
1217 case WM_BUTTON1DOWN: | |
1218 button = 1; | |
1219 break; | |
1220 case WM_BUTTON2DOWN: | |
1221 button = 2; | |
1222 break; | |
1223 case WM_BUTTON3DOWN: | |
1224 button = 3; | |
1225 break; | |
1226 } | |
1227 | |
1228 result = buttonfunc(tmp->window, pts.x, _get_frame_height(tmp->window) - pts.y, button, tmp->data); | |
1229 tmp = NULL; | |
1230 } | |
1231 } | |
1232 break; | |
1233 case WM_BUTTON1UP: | |
1234 { | |
1235 POINTS pts = (*((POINTS*)&mp1)); | |
1236 int (*buttonfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction; | |
1237 | |
1238 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window) | |
1239 { | |
1240 int button; | |
1241 | |
1242 switch(origmsg) | |
1243 { | |
1244 case WM_BUTTON1UP: | |
1245 button = 1; | |
1246 break; | |
1247 case WM_BUTTON2UP: | |
1248 button = 2; | |
1249 break; | |
1250 case WM_BUTTON3UP: | |
1251 button = 3; | |
1252 break; | |
1253 } | |
1254 | |
1255 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); | |
1256 tmp = NULL; | |
1257 } | |
1258 } | |
1259 break; | |
1260 case WM_MOUSEMOVE: | |
1261 { | |
1262 int (*motionfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction; | |
1263 | |
1264 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window) | |
1265 { | |
1266 int keys = 0; | |
1267 SHORT x = SHORT1FROMMP(mp1), y = SHORT2FROMMP(mp1); | |
1268 | |
1269 if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000) | |
1270 keys = DW_BUTTON1_MASK; | |
1271 if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) & 0x8000) | |
1272 keys |= DW_BUTTON2_MASK; | |
1273 if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) & 0x8000) | |
1274 keys |= DW_BUTTON3_MASK; | |
1275 | |
1276 result = motionfunc(tmp->window, x, _get_frame_height(tmp->window) - y, keys, tmp->data); | |
1277 tmp = NULL; | |
1278 } | |
1279 } | |
1280 break; | |
1281 case WM_CHAR: | |
1282 { | |
1283 int (*keypressfunc)(HWND, int, void *) = (int (*)(HWND, int, void *))tmp->signalfunction; | |
1284 | |
1285 if(hWnd == tmp->window) | |
1286 { | |
1287 result = keypressfunc(tmp->window, SHORT1FROMMP(mp2), tmp->data); | |
1288 tmp = NULL; | |
1289 } | |
1290 } | |
1291 break; | |
1292 case WM_CLOSE: | |
1293 { | |
1294 int (*closefunc)(HWND, void *) = (int (*)(HWND, void *))tmp->signalfunction; | |
1295 | |
1296 if(hWnd == tmp->window || hWnd == WinWindowFromID(tmp->window, FID_CLIENT)) | |
1297 { | |
1298 result = closefunc(tmp->window, tmp->data); | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
1299 if(result) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
1300 result = FALSE; |
3 | 1301 tmp = NULL; |
1302 } | |
1303 } | |
1304 break; | |
1305 case WM_PAINT: | |
1306 { | |
1307 HPS hps; | |
1308 DWExpose exp; | |
1309 int (*exposefunc)(HWND, DWExpose *, void *) = (int (*)(HWND, DWExpose *, void *))tmp->signalfunction; | |
1310 RECTL rc; | |
1311 | |
1312 if(hWnd == tmp->window) | |
1313 { | |
1314 int height = _get_height(hWnd); | |
1315 | |
1316 hps = WinBeginPaint(hWnd, 0L, &rc); | |
1317 exp.x = rc.xLeft; | |
1318 exp.y = height - rc.yTop - 1; | |
1319 exp.width = rc.xRight - rc. xLeft; | |
1320 exp.height = rc.yTop - rc.yBottom; | |
1321 result = exposefunc(hWnd, &exp, tmp->data); | |
1322 WinEndPaint(hps); | |
1323 } | |
1324 } | |
1325 break; | |
1326 case WM_COMMAND: | |
1327 { | |
1328 int (*clickfunc)(HWND, void *) = (int (*)(HWND, void *))tmp->signalfunction; | |
1329 ULONG command = COMMANDMSG(&msg)->cmd; | |
1330 | |
1331 if(tmp->window < 65536 && command == tmp->window) | |
1332 { | |
1333 result = clickfunc(tmp->window, tmp->data); | |
1334 tmp = NULL; | |
1335 } | |
1336 } | |
1337 break; | |
1338 case WM_CONTROL: | |
1339 if(tmp->message == SHORT2FROMMP(mp1)) | |
1340 { | |
1341 switch(SHORT2FROMMP(mp1)) | |
1342 { | |
1343 case CN_ENTER: | |
1344 { | |
1345 int (*containerselectfunc)(HWND, char *, void *) = (int (*)(HWND, char *, void *))tmp->signalfunction; | |
1346 int id = SHORT1FROMMP(mp1); | |
1347 HWND conthwnd = dw_window_from_id(hWnd, id); | |
1348 char *text = NULL; | |
1349 | |
1350 if(mp2) | |
1351 { | |
1352 PRECORDCORE pre; | |
1353 | |
1354 pre = ((PNOTIFYRECORDENTER)mp2)->pRecord; | |
1355 if(pre) | |
1356 text = pre->pszIcon; | |
1357 } | |
1358 | |
1359 if(tmp->window == conthwnd) | |
1360 { | |
1361 result = containerselectfunc(tmp->window, text, tmp->data); | |
1362 tmp = NULL; | |
1363 } | |
1364 } | |
1365 break; | |
1366 case CN_CONTEXTMENU: | |
1367 { | |
1368 int (*containercontextfunc)(HWND, char *, int, int, void *) = (int (*)(HWND, char *, int, int, void *))tmp->signalfunction; | |
1369 int id = SHORT1FROMMP(mp1); | |
1370 HWND conthwnd = dw_window_from_id(hWnd, id); | |
1371 char *text = NULL; | |
1372 LONG x,y; | |
1373 | |
1374 if(mp2) | |
1375 { | |
1376 PRECORDCORE pre; | |
1377 | |
1378 pre = (PRECORDCORE)mp2; | |
1379 text = pre->pszIcon; | |
1380 } | |
1381 | |
1382 | |
1383 dw_pointer_query_pos(&x, &y); | |
1384 | |
1385 if(tmp->window == conthwnd) | |
1386 { | |
1387 result = containercontextfunc(tmp->window, text, x, y, tmp->data); | |
1388 tmp = NULL; | |
1389 } | |
1390 } | |
1391 break; | |
1392 case LN_SELECT: | |
1393 { | |
1394 int (*listboxselectfunc)(HWND, int, void *) = (int (*)(HWND, int, void *))tmp->signalfunction; | |
1395 int id = SHORT1FROMMP(mp1); | |
1396 HWND conthwnd = dw_window_from_id(hWnd, id); | |
1397 | |
1398 if(tmp->window == conthwnd || (!id && tmp->window == (HWND)mp2)) | |
1399 { | |
1400 char buf1[500], classbuf[100]; | |
1401 unsigned int index = dw_listbox_selected(tmp->window); | |
1402 | |
1403 dw_listbox_query_text(tmp->window, index, buf1, 500); | |
1404 | |
1405 WinQueryClassName(tmp->window, 99, classbuf); | |
1406 | |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
1407 if(id && strncmp(classbuf, "#2", 2)==0) |
3 | 1408 { |
1409 char *buf2; | |
1410 | |
1411 buf2 = dw_window_get_text(tmp->window); | |
1412 | |
1413 /* This is to make sure the listboxselect function doesn't | |
1414 * get called if the user is modifying the entry text. | |
1415 */ | |
1416 if(buf2 && *buf2 && *buf1 && strncmp(buf1, buf2, 500) == 0) | |
1417 result = listboxselectfunc(tmp->window, index, tmp->data); | |
1418 | |
1419 if(buf2) | |
1420 free(buf2); | |
1421 } | |
1422 else | |
1423 result = listboxselectfunc(tmp->window, index, tmp->data); | |
1424 | |
1425 tmp = NULL; | |
1426 } | |
1427 } | |
1428 break; | |
1429 } | |
1430 } | |
1431 break; | |
1432 } | |
1433 } | |
1434 if(tmp) | |
1435 tmp = tmp->next; | |
1436 | |
1437 } | |
1438 | |
1439 return (MRESULT)result; | |
1440 } | |
1441 #endif | |
1442 | |
1443 /* Handles control messages sent to the box (owner). */ | |
1444 MRESULT EXPENTRY _controlproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) | |
1445 { | |
1446 Box *blah = WinQueryWindowPtr(hWnd, QWP_USER); | |
1447 | |
1448 switch(msg) | |
1449 { | |
1450 case WM_CONTROL: | |
1451 _run_event(hWnd, msg, mp1, mp2); | |
1452 break; | |
1453 } | |
1454 if(blah && blah->oldproc) | |
1455 { | |
1456 return blah->oldproc(hWnd, msg, mp1, mp2); | |
1457 } | |
1458 | |
1459 return WinDefWindowProc(hWnd, msg, mp1, mp2); | |
1460 } | |
1461 | |
1462 /* The main window procedure for Dynamic Windows, all the resizing code is done here. */ | |
1463 MRESULT EXPENTRY _wndproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) | |
1464 { | |
1465 int result = -1; | |
1466 static int command_active = 0; | |
1467 void (* windowfunc)(PVOID) = 0L; | |
1468 | |
1469 if(filterfunc) | |
1470 result = filterfunc(hWnd, msg, mp1, mp2); | |
1471 | |
1472 #ifndef NO_SIGNALS | |
1473 if(result == -1 && !command_active) | |
1474 { | |
1475 /* Make sure we don't end up in infinite recursion */ | |
1476 command_active = 1; | |
1477 | |
1478 result = (int)_run_event(hWnd, msg, mp1, mp2); | |
1479 | |
1480 command_active = 0; | |
1481 } | |
1482 #endif | |
1483 | |
1484 /* Now that any handlers are done... do normal processing */ | |
1485 switch( msg ) | |
1486 { | |
1487 case WM_ERASEBACKGROUND: | |
1488 return 0; | |
1489 | |
1490 case WM_PAINT: | |
1491 { | |
1492 HPS hps; | |
1493 RECTL rc; | |
1494 | |
1495 hps = WinBeginPaint( hWnd, 0L, &rc ); | |
1496 WinEndPaint( hps ); | |
1497 break; | |
1498 } | |
1499 | |
1500 case WM_SIZE: | |
1501 { | |
1502 Box *mybox = (Box *)WinQueryWindowPtr(hWnd, QWP_USER); | |
1503 | |
1504 if(!SHORT1FROMMP(mp2) && !SHORT2FROMMP(mp2)) | |
1505 return (MPARAM)TRUE; | |
1506 | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1507 if(mybox && mybox->flags != DW_MINIMIZED) |
3 | 1508 { |
1509 /* Hide the window when recalculating to reduce | |
1510 * CPU load. | |
1511 */ | |
1512 WinShowWindow(hWnd, FALSE); | |
1513 | |
1514 _do_resize(mybox, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2)); | |
1515 | |
1516 WinShowWindow(hWnd, TRUE); | |
1517 } | |
1518 } | |
1519 break; | |
1520 case WM_MINMAXFRAME: | |
1521 { | |
1522 Box *mybox = (Box *)WinQueryWindowPtr(hWnd, QWP_USER); | |
1523 SWP *swp = (SWP *)mp1; | |
1524 | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1525 if(mybox && (swp->fl & SWP_MINIMIZE)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1526 mybox->flags = DW_MINIMIZED; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1527 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1528 if(mybox && (swp->fl & SWP_RESTORE)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1529 mybox->flags = 0; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1530 |
3 | 1531 if(mybox && (swp->fl & SWP_MAXIMIZE)) |
1532 { | |
1533 int z; | |
1534 | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1535 mybox->flags = 0; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1536 |
3 | 1537 /* Hide the window when recalculating to reduce |
1538 * CPU load. | |
1539 */ | |
1540 WinShowWindow(hWnd, FALSE); | |
1541 | |
1542 _do_resize(mybox, swp->cx, swp->cy); | |
1543 | |
1544 if(mybox->count == 1 && mybox->items[0].type == TYPEBOX) | |
1545 { | |
1546 mybox = (Box *)WinQueryWindowPtr(mybox->items[0].hwnd, QWP_USER); | |
1547 | |
1548 for(z=0;z<mybox->count;z++) | |
1549 { | |
1550 char tmpbuf[100]; | |
1551 | |
1552 WinQueryClassName(mybox->items[z].hwnd, 99, tmpbuf); | |
1553 | |
1554 /* If we have a notebook we resize the page again. */ | |
1555 if(strncmp(tmpbuf, "#40", 3)==0) | |
1556 { | |
1557 unsigned long x, y, width, height; | |
1558 int page = dw_notebook_page_query(mybox->items[z].hwnd); | |
1559 HWND pagehwnd = (HWND)WinSendMsg(mybox->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND, MPFROMLONG(page), 0); | |
1560 RECTL rc; | |
1561 | |
1562 Box *pagebox = (Box *)WinQueryWindowPtr(pagehwnd, QWP_USER); | |
1563 if(pagebox) | |
1564 { | |
1565 dw_window_get_pos_size(mybox->items[z].hwnd, &x, &y, &width, &height); | |
1566 | |
1567 rc.xLeft = x; | |
1568 rc.yBottom = y; | |
1569 rc.xRight = x + width; | |
1570 rc.yTop = y + height; | |
1571 | |
1572 WinSendMsg(mybox->items[z].hwnd, BKM_CALCPAGERECT, (MPARAM)&rc, (MPARAM)TRUE); | |
1573 | |
1574 _do_resize(pagebox, rc.xRight - rc.xLeft, rc.yTop - rc.yBottom); | |
1575 } | |
1576 | |
1577 } | |
1578 } | |
1579 | |
1580 } | |
1581 | |
1582 WinShowWindow(hWnd, TRUE); | |
1583 } | |
1584 } | |
1585 break; | |
20
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1586 case WM_CONTROL: |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1587 switch(SHORT2FROMMP(mp1)) |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1588 { |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1589 case BKN_PAGESELECTEDPENDING: |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1590 { |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1591 PAGESELECTNOTIFY *psn = (PAGESELECTNOTIFY *)mp2; |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1592 HWND pagehwnd = (HWND)WinSendMsg(psn->hwndBook, BKM_QUERYPAGEWINDOWHWND, MPFROMLONG(psn->ulPageIdNew), 0); |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1593 Box *pagebox = (Box *)WinQueryWindowPtr(pagehwnd, QWP_USER); |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1594 unsigned long x, y, width, height; |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1595 RECTL rc; |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1596 |
21
c6e76b796b28
Stopped unnecessary redrawing when switching to the same page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
20
diff
changeset
|
1597 if(pagebox && psn->ulPageIdNew != psn->ulPageIdCur) |
20
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1598 { |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1599 dw_window_get_pos_size(psn->hwndBook, &x, &y, &width, &height); |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1600 |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1601 rc.xLeft = x; |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1602 rc.yBottom = y; |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1603 rc.xRight = x + width; |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1604 rc.yTop = y + height; |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1605 |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1606 WinSendMsg(psn->hwndBook, BKM_CALCPAGERECT, (MPARAM)&rc, (MPARAM)TRUE); |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1607 |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1608 _do_resize(pagebox, rc.xRight - rc.xLeft, rc.yTop - rc.yBottom); |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1609 } |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1610 } |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1611 break; |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1612 } |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
1613 break; |
3 | 1614 case WM_CLOSE: |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
1615 if(result == -1) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
1616 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
1617 dw_window_destroy(WinQueryWindow(hWnd, QW_PARENT)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
1618 return (MRESULT)TRUE; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
1619 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
1620 break; |
3 | 1621 case WM_USER: |
1622 windowfunc = (void (*)(void *))mp1; | |
1623 | |
1624 if(windowfunc) | |
1625 windowfunc((void *)mp2); | |
1626 break; | |
1627 case WM_CHAR: | |
1628 if(SHORT1FROMMP(mp2) == '\t') | |
1629 { | |
1630 _shift_focus(hWnd); | |
1631 return FALSE; | |
1632 } | |
1633 break; | |
1634 case WM_DESTROY: | |
1635 /* Free memory before destroying */ | |
1636 _free_window_memory(hWnd); | |
1637 break; | |
1638 } | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
1639 if(result != -1) |
3 | 1640 return (MRESULT)result; |
1641 else | |
1642 return WinDefWindowProc(hWnd, msg, mp1, mp2); | |
1643 } | |
1644 | |
1645 void _changebox(Box *thisbox, int percent, int type) | |
1646 { | |
1647 int z; | |
1648 | |
1649 for(z=0;z<thisbox->count;z++) | |
1650 { | |
1651 if(thisbox->items[z].type == TYPEBOX) | |
1652 { | |
1653 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); | |
1654 _changebox(tmp, percent, type); | |
1655 } | |
1656 else | |
1657 { | |
1658 if(type == BOXHORZ) | |
1659 { | |
1660 if(thisbox->items[z].hsize == SIZEEXPAND) | |
1661 thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0))); | |
1662 } | |
1663 else | |
1664 { | |
1665 if(thisbox->items[z].vsize == SIZEEXPAND) | |
1666 thisbox->items[z].height = (int)(((float)thisbox->items[z].origheight) * (((float)percent)/((float)100.0))); | |
1667 } | |
1668 } | |
1669 } | |
1670 } | |
1671 | |
1672 /* This handles any activity on the splitbars (sizers) */ | |
1673 MRESULT EXPENTRY _splitwndproc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | |
1674 { | |
1675 HWND hwndFrame = 0; | |
1676 Box *thisbox = 0; | |
1677 | |
1678 hwndFrame = WinQueryWindow(hwnd, QW_PARENT); | |
1679 if(hwndFrame) | |
1680 thisbox = WinQueryWindowPtr(hwndFrame, QWL_USER); | |
1681 | |
1682 switch (msg) | |
1683 { | |
1684 case WM_ACTIVATE: | |
1685 case WM_SETFOCUS: | |
1686 return (MRESULT)(FALSE); | |
1687 | |
1688 case WM_PAINT: | |
1689 { | |
1690 HPS hpsPaint; | |
1691 RECTL rclPaint; | |
1692 POINTL ptlStart[SPLITBAR_WIDTH]; | |
1693 POINTL ptlEnd[SPLITBAR_WIDTH]; | |
1694 USHORT i; | |
1695 | |
1696 hpsPaint = WinBeginPaint(hwnd, 0, 0); | |
1697 WinQueryWindowRect(hwnd, &rclPaint); | |
1698 | |
1699 if(thisbox->type == BOXHORZ) | |
1700 { | |
1701 for(i = 0; i < SPLITBAR_WIDTH; i++) | |
1702 { | |
1703 ptlStart[i].x = rclPaint.xLeft + i; | |
1704 ptlStart[i].y = rclPaint.yTop; | |
1705 | |
1706 ptlEnd[i].x = rclPaint.xLeft + i; | |
1707 ptlEnd[i].y = rclPaint.yBottom; | |
1708 } | |
1709 } | |
1710 else | |
1711 { | |
1712 for(i = 0; i < SPLITBAR_WIDTH; i++) | |
1713 { | |
1714 ptlStart[i].x = rclPaint.xLeft; | |
1715 ptlStart[i].y = rclPaint.yBottom + i; | |
1716 | |
1717 ptlEnd[i].x = rclPaint.xRight; | |
1718 ptlEnd[i].y = rclPaint.yBottom + i; | |
1719 } | |
1720 } | |
1721 | |
1722 for(i = 0; i < SPLITBAR_WIDTH; i++) | |
1723 { | |
1724 GpiSetColor( hpsPaint, lColor[i]); | |
1725 GpiMove(hpsPaint, &ptlStart[i]); | |
1726 GpiLine(hpsPaint, &ptlEnd[i]); | |
1727 } | |
1728 WinEndPaint(hpsPaint); | |
1729 } | |
1730 return MRFROMSHORT(FALSE); | |
1731 | |
1732 case WM_MOUSEMOVE: | |
1733 { | |
1734 if(thisbox->type == BOXHORZ) | |
1735 WinSetPointer(HWND_DESKTOP, | |
1736 WinQuerySysPointer(HWND_DESKTOP, | |
1737 SPTR_SIZEWE, | |
1738 FALSE)); | |
1739 else | |
1740 WinSetPointer(HWND_DESKTOP, | |
1741 WinQuerySysPointer(HWND_DESKTOP, | |
1742 SPTR_SIZENS, | |
1743 FALSE)); | |
1744 } | |
1745 return MRFROMSHORT(FALSE); | |
1746 case WM_BUTTON1DOWN: | |
1747 { | |
1748 APIRET rc; | |
1749 RECTL rclFrame; | |
1750 RECTL rclBounds; | |
1751 RECTL rclStart; | |
1752 USHORT startSize, orig, actual; | |
1753 | |
1754 WinQueryWindowRect(hwnd, &rclFrame); | |
1755 WinQueryWindowRect(hwnd, &rclStart); | |
1756 | |
1757 WinQueryWindowRect(hwndFrame, &rclBounds); | |
1758 | |
1759 WinMapWindowPoints(hwndFrame, HWND_DESKTOP, | |
1760 (PPOINTL)&rclBounds, 2); | |
1761 WinMapWindowPoints(hwnd, HWND_DESKTOP, | |
1762 (PPOINTL)&rclStart, 2); | |
1763 | |
1764 { | |
1765 int z, pastsplitbar = FALSE, found = FALSE; | |
1766 orig = actual = 0; | |
1767 | |
1768 for(z=0;z<thisbox->count;z++) | |
1769 { | |
1770 if(thisbox->items[z].hwnd == hwnd) | |
1771 pastsplitbar = TRUE; | |
1772 else | |
1773 { | |
1774 if(thisbox->type == BOXHORZ) | |
1775 { | |
1776 int tmpwidth, tmporigwidth; | |
1777 | |
1778 if(thisbox->items[z].type == TYPEBOX) | |
1779 _count_size(thisbox->items[z].hwnd, BOXHORZ, &tmpwidth, &tmporigwidth); | |
1780 else | |
1781 { | |
1782 tmpwidth = thisbox->items[z].width; | |
1783 tmporigwidth = thisbox->items[z].origwidth; | |
1784 } | |
1785 | |
1786 if(thisbox->items[z].hsize != SIZESTATIC && tmpwidth > actual && tmporigwidth) | |
1787 { | |
1788 found = pastsplitbar; | |
1789 orig = tmporigwidth; | |
1790 actual = tmpwidth; | |
1791 } | |
1792 } | |
1793 else | |
1794 { | |
1795 int tmpheight, tmporigheight; | |
1796 | |
1797 if(thisbox->items[z].type == TYPEBOX) | |
1798 _count_size(thisbox->items[z].hwnd, BOXVERT, &tmpheight, &tmporigheight); | |
1799 else | |
1800 { | |
1801 tmpheight = thisbox->items[z].height; | |
1802 tmporigheight = thisbox->items[z].origheight; | |
1803 } | |
1804 | |
1805 if(thisbox->items[z].vsize != SIZESTATIC && tmpheight > actual && tmporigheight) | |
1806 { | |
1807 found = pastsplitbar; | |
1808 orig = tmporigheight; | |
1809 actual = tmpheight; | |
1810 } | |
1811 } | |
1812 } | |
1813 } | |
1814 | |
1815 /* If we couldn't determine a valid scale... then abort */ | |
1816 if(!orig || !actual) | |
1817 return MRFROMSHORT(FALSE); | |
1818 | |
1819 if(thisbox->type == BOXHORZ) | |
1820 { | |
1821 if(found) | |
1822 startSize = (rclStart.xLeft - rclBounds.xLeft) | |
1823 * (((float)actual)/((float)orig)); | |
1824 else | |
1825 startSize = (rclStart.xLeft - rclBounds.xLeft) | |
1826 * (((float)orig)/((float)actual)); | |
1827 } | |
1828 else | |
1829 { | |
1830 if(found) | |
1831 startSize = (rclStart.yBottom - rclBounds.yBottom) | |
1832 * (((float)actual)/((float)orig)); | |
1833 else | |
1834 startSize = (rclStart.yBottom - rclBounds.yBottom) | |
1835 * (((float)orig)/((float)actual)); | |
1836 } | |
1837 } | |
1838 | |
1839 rc = _TrackRectangle(hwnd, &rclFrame, &rclBounds); | |
1840 | |
1841 if(rc == TRUE) | |
1842 { | |
1843 USHORT usNewRB; | |
1844 USHORT percent; | |
1845 int z; | |
1846 | |
1847 if(thisbox->type == BOXHORZ) | |
1848 { | |
1849 usNewRB = rclFrame.xLeft | |
1850 - rclBounds.xLeft; | |
1851 } | |
1852 else | |
1853 { | |
1854 usNewRB = rclFrame.yBottom | |
1855 - rclBounds.yBottom; | |
1856 } | |
1857 | |
1858 /* We don't want the item to disappear completely */ | |
1859 if(!usNewRB) | |
1860 usNewRB++; | |
1861 | |
1862 if(!startSize) | |
1863 startSize++; | |
1864 | |
1865 percent = (usNewRB*100)/startSize; | |
1866 | |
1867 for(z=0;z<thisbox->count;z++) | |
1868 { | |
1869 if(thisbox->items[z].type == TYPEBOX) | |
1870 { | |
1871 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
1872 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
1873 if(tmp) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
1874 _changebox(tmp, percent, thisbox->type); |
3 | 1875 } |
1876 else | |
1877 { | |
1878 if(thisbox->items[z].hwnd == hwnd) | |
1879 percent = (startSize*100)/usNewRB; | |
1880 | |
1881 if(thisbox->type == BOXHORZ) | |
1882 { | |
1883 if(thisbox->items[z].hsize == SIZEEXPAND) | |
1884 thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0))); | |
1885 } | |
1886 else | |
1887 { | |
1888 if(thisbox->items[z].vsize == SIZEEXPAND) | |
1889 thisbox->items[z].height = (int)(((float)thisbox->items[z].origheight) * (((float)percent)/((float)100.0))); | |
1890 } | |
1891 } | |
1892 } | |
1893 | |
1894 _ResetWindow(WinQueryWindow(hwnd, QW_OWNER)); | |
1895 } | |
1896 } | |
1897 return MRFROMSHORT(FALSE); | |
1898 } | |
1899 return WinDefWindowProc(hwnd, msg, mp1, mp2); | |
1900 } | |
1901 | |
1902 /* Function: BubbleProc | |
1903 * Abstract: Subclass procedure for bubble help | |
1904 */ | |
1905 MRESULT EXPENTRY _BubbleProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | |
1906 { | |
1907 MRESULT res; | |
1908 PFNWP proc = (PFNWP)WinQueryWindowPtr(hwnd, QWL_USER); | |
1909 | |
1910 if(proc) | |
1911 res = proc(hwnd, msg, mp1, mp2); | |
1912 else | |
1913 res = WinDefWindowProc(hwnd, msg, mp1, mp2); | |
1914 | |
1915 if(msg == WM_PAINT) | |
1916 { | |
1917 POINTL ptl; | |
1918 HPS hpsTemp; | |
1919 RECTL rcl; | |
1920 int height, width; | |
1921 | |
1922 WinQueryWindowRect(hwnd, &rcl); | |
1923 height = rcl.yTop - rcl.yBottom - 1; | |
1924 width = rcl.xRight - rcl.xLeft - 1; | |
1925 | |
1926 /* Draw a border around the bubble help */ | |
1927 hpsTemp = WinGetPS(hwnd); | |
1928 GpiSetColor(hpsTemp, DW_CLR_BLACK); | |
1929 ptl.x = ptl.y = 0; | |
1930 GpiMove(hpsTemp, &ptl); | |
1931 ptl.x = 0; | |
1932 ptl.y = height; | |
1933 GpiLine(hpsTemp, &ptl); | |
1934 ptl.x = ptl.y = 0; | |
1935 GpiMove(hpsTemp, &ptl); | |
1936 ptl.y = 0; | |
1937 ptl.x = width; | |
1938 GpiLine(hpsTemp, &ptl); | |
1939 ptl.x = width; | |
1940 ptl.y = height; | |
1941 GpiMove(hpsTemp, &ptl); | |
1942 ptl.x = 0; | |
1943 ptl.y = height; | |
1944 GpiLine(hpsTemp, &ptl); | |
1945 ptl.x = width; | |
1946 ptl.y = height; | |
1947 GpiMove(hpsTemp, &ptl); | |
1948 ptl.y = 0; | |
1949 ptl.x = width; | |
1950 GpiLine(hpsTemp, &ptl); | |
1951 WinReleasePS(hpsTemp); | |
1952 } | |
1953 return res; | |
1954 } | |
1955 | |
1956 /* Function: BtProc | |
1957 * Abstract: Subclass procedure for buttons | |
1958 */ | |
1959 | |
1960 MRESULT EXPENTRY _BtProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | |
1961 { | |
1962 BubbleButton *bubble; | |
1963 | |
1964 bubble = (BubbleButton *)WinQueryWindowPtr(hwnd, QWL_USER); | |
1965 | |
1966 if(!bubble) | |
1967 return WinDefWindowProc(hwnd, msg, mp1, mp2); | |
1968 | |
1969 switch(msg) | |
1970 { | |
1971 #ifndef NO_SIGNALS | |
1972 case WM_BUTTON1UP: | |
1973 { | |
1974 SignalHandler *tmp = Root; | |
1975 | |
1976 if(WinIsWindowEnabled(hwnd)) | |
1977 { | |
1978 /* Find any callbacks for this function */ | |
1979 while(tmp) | |
1980 { | |
1981 if(tmp->message == WM_COMMAND) | |
1982 { | |
1983 /* Make sure it's the right window, and the right ID */ | |
1984 if(tmp->window == hwnd) | |
1985 { | |
1986 /* Due to the fact that if we run the function | |
1987 * here, finishing actions on the button will occur | |
1988 * after we run the signal handler. So we post the | |
1989 * message so the button can finish what it needs to | |
1990 * do before we run our handler. | |
1991 */ | |
1992 WinPostMsg(hwnd, WM_USER, (MPARAM)tmp, 0); | |
1993 tmp = NULL; | |
1994 } | |
1995 } | |
1996 if(tmp) | |
1997 tmp= tmp->next; | |
1998 } | |
1999 } | |
2000 } | |
2001 break; | |
2002 case WM_USER: | |
2003 { | |
2004 SignalHandler *tmp = (SignalHandler *)mp1; | |
2005 int (*clickfunc)(HWND, void *) = NULL; | |
2006 | |
2007 if(tmp) | |
2008 { | |
2009 clickfunc = (int (*)(HWND, void *))tmp->signalfunction; | |
2010 | |
2011 clickfunc(tmp->window, tmp->data); | |
2012 } | |
2013 } | |
2014 break; | |
2015 #endif | |
2016 case WM_CHAR: | |
2017 { | |
2018 #ifndef NO_SIGNALS | |
2019 /* A button press should also occur for an ENTER or SPACE press | |
2020 * while the button has the active input focus. | |
2021 */ | |
2022 if(SHORT1FROMMP(mp2) == '\r' || SHORT1FROMMP(mp2) == ' ') | |
2023 { | |
2024 SignalHandler *tmp = Root; | |
2025 | |
2026 /* Find any callbacks for this function */ | |
2027 while(tmp) | |
2028 { | |
2029 if(tmp->message == WM_COMMAND) | |
2030 { | |
2031 /* Make sure it's the right window, and the right ID */ | |
2032 if(tmp->window == hwnd) | |
2033 { | |
2034 WinPostMsg(hwnd, WM_USER, (MPARAM)tmp, 0); | |
2035 tmp = NULL; | |
2036 } | |
2037 } | |
2038 if(tmp) | |
2039 tmp= tmp->next; | |
2040 } | |
2041 } | |
2042 #endif | |
2043 if(SHORT1FROMMP(mp2) == '\t') | |
2044 { | |
2045 _shift_focus(hwnd); | |
2046 return FALSE; | |
2047 } | |
2048 } | |
2049 break; | |
2050 case 0x041f: | |
2051 if (hwndBubble) | |
2052 { | |
2053 WinDestroyWindow(hwndBubble); | |
2054 hwndBubble = 0; | |
2055 } | |
2056 break; | |
2057 | |
2058 case 0x041e: | |
2059 | |
2060 if(!*bubble->bubbletext) | |
2061 break; | |
2062 | |
2063 | |
2064 if(hwndBubble) | |
2065 { | |
2066 WinDestroyWindow(hwndBubble); | |
2067 hwndBubble = 0; | |
2068 } | |
2069 | |
2070 if(!hwndBubble) | |
2071 { | |
2072 HPS hpsTemp = 0; | |
2073 LONG lHight; | |
2074 LONG lWidth; | |
2075 POINTL txtPointl[TXTBOX_COUNT]; | |
2076 POINTL ptlWork = {0,0}; | |
2077 ULONG ulColor = DW_CLR_YELLOW; | |
2078 void *blah; | |
2079 | |
2080 hwndBubbleLast = hwnd; | |
2081 hwndBubble = WinCreateWindow(HWND_DESKTOP, | |
2082 WC_STATIC, | |
2083 "", | |
2084 SS_TEXT | | |
2085 DT_CENTER | | |
2086 DT_VCENTER, | |
2087 0,0,0,0, | |
2088 HWND_DESKTOP, | |
2089 HWND_TOP, | |
2090 0, | |
2091 NULL, | |
2092 NULL); | |
2093 | |
2094 WinSetPresParam(hwndBubble, | |
2095 PP_FONTNAMESIZE, | |
2096 sizeof(DefaultFont), | |
2097 DefaultFont); | |
2098 | |
2099 | |
2100 WinSetPresParam(hwndBubble, | |
2101 PP_BACKGROUNDCOLORINDEX, | |
2102 sizeof(ulColor), | |
2103 &ulColor); | |
2104 | |
2105 WinSetWindowText(hwndBubble, | |
2106 bubble->bubbletext); | |
2107 | |
2108 WinMapWindowPoints(hwnd, HWND_DESKTOP, &ptlWork, 1); | |
2109 | |
2110 hpsTemp = WinGetPS(hwndBubble); | |
2111 GpiQueryTextBox(hpsTemp, | |
2112 strlen(bubble->bubbletext), | |
2113 bubble->bubbletext, | |
2114 TXTBOX_COUNT, | |
2115 txtPointl); | |
2116 WinReleasePS(hpsTemp); | |
2117 | |
2118 lWidth = txtPointl[TXTBOX_TOPRIGHT].x - | |
2119 txtPointl[TXTBOX_TOPLEFT ].x + 8; | |
2120 | |
2121 lHight = txtPointl[TXTBOX_TOPLEFT].y - | |
2122 txtPointl[TXTBOX_BOTTOMLEFT].y + 8; | |
2123 | |
2124 ptlWork.y -= lHight; | |
2125 | |
2126 blah = (void *)WinSubclassWindow(hwndBubble, _BubbleProc); | |
2127 | |
2128 if(blah) | |
2129 WinSetWindowPtr(hwndBubble, QWP_USER, blah); | |
2130 | |
2131 WinSetWindowPos(hwndBubble, | |
2132 HWND_TOP, | |
2133 ptlWork.x, | |
2134 ptlWork.y, | |
2135 lWidth, | |
2136 lHight, | |
2137 SWP_SIZE | SWP_MOVE | SWP_SHOW); | |
2138 } | |
2139 break; | |
2140 } | |
2141 | |
2142 if(!bubble->pOldProc) | |
2143 return WinDefWindowProc(hwnd, msg, mp1, mp2); | |
2144 return bubble->pOldProc(hwnd, msg, mp1, mp2); | |
2145 } | |
2146 | |
2147 MRESULT EXPENTRY _RendProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | |
2148 { | |
2149 int res = 0; | |
2150 #ifndef NO_SIGNALS | |
2151 res = (int)_run_event(hwnd, msg, mp1, mp2); | |
2152 #endif | |
2153 switch(msg) | |
2154 { | |
2155 case WM_BUTTON1DOWN: | |
2156 case WM_BUTTON2DOWN: | |
2157 case WM_BUTTON3DOWN: | |
2158 if(!res) | |
2159 WinSetFocus(HWND_DESKTOP, hwnd); | |
2160 return (MPARAM)TRUE; | |
2161 } | |
2162 return WinDefWindowProc(hwnd, msg, mp1, mp2); | |
2163 } | |
2164 | |
2165 /* | |
2166 * Initializes the Dynamic Windows engine. | |
2167 * Parameters: | |
2168 * newthread: True if this is the only thread. | |
2169 * False if there is already a message loop running. | |
2170 */ | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2171 int dw_init(int newthread, int argc, char *argv[]) |
3 | 2172 { |
2173 APIRET rc; | |
2174 | |
2175 if(newthread) | |
2176 { | |
2177 dwhab = WinInitialize(0); | |
2178 dwhmq = WinCreateMsgQueue(dwhab, 0); | |
2179 } | |
2180 | |
2181 rc = WinRegisterClass(dwhab, ClassName, _wndproc, CS_SIZEREDRAW | CS_CLIPCHILDREN, 32); | |
2182 rc = WinRegisterClass(dwhab, SplitbarClassName, _splitwndproc, 0L, 32); | |
2183 | |
20
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
2184 /* Get the OS/2 version. */ |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
2185 DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_MS_COUNT,(void *)aulBuffer, 4*sizeof(ULONG)); |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
2186 |
3 | 2187 #ifdef DWDEBUG |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2188 f = fopen("dw.log", "w"); |
3 | 2189 #endif |
2190 return rc; | |
2191 } | |
2192 | |
2193 /* | |
2194 * Runs a message loop for Dynamic Windows. | |
2195 * Parameters: | |
2196 * currenthab: The handle to the current anchor block | |
2197 * or NULL if this DW is handling the message loop. | |
2198 * func: Function pointer to the message filter function. | |
2199 */ | |
2200 void dw_main(HAB currenthab, void *func) | |
2201 { | |
2202 QMSG qmsg; | |
2203 HAB habtouse; | |
2204 | |
2205 if(!currenthab) | |
2206 habtouse = dwhab; | |
2207 else | |
2208 habtouse = currenthab; | |
2209 | |
2210 /* Setup the filter function */ | |
2211 filterfunc = (int (* EXPENTRY)(HWND, ULONG, MPARAM, MPARAM))func; | |
2212 | |
2213 _dwtid = dw_thread_id(); | |
2214 | |
2215 while (WinGetMsg(habtouse, &qmsg, 0, 0, 0)) | |
2216 WinDispatchMsg(habtouse, &qmsg); | |
2217 | |
2218 #ifdef DWDEBUG | |
2219 fclose(f); | |
2220 #endif | |
2221 | |
2222 if(!currenthab) | |
2223 { | |
2224 WinDestroyMsgQueue(dwhmq); | |
2225 WinTerminate(dwhab); | |
2226 } | |
2227 } | |
2228 | |
2229 /* | |
2230 * Free's memory allocated by dynamic windows. | |
2231 * Parameters: | |
2232 * ptr: Pointer to dynamic windows allocated | |
2233 * memory to be free()'d. | |
2234 */ | |
2235 void dw_free(void *ptr) | |
2236 { | |
2237 free(ptr); | |
2238 } | |
2239 | |
2240 /* | |
2241 * Allocates and initializes a dialog struct. | |
2242 * Parameters: | |
2243 * data: User defined data to be passed to functions. | |
2244 */ | |
2245 DWDialog *dw_dialog_new(void *data) | |
2246 { | |
2247 DWDialog *tmp = malloc(sizeof(DWDialog)); | |
2248 | |
2249 tmp->eve = dw_event_new(); | |
2250 dw_event_reset(tmp->eve); | |
2251 tmp->data = data; | |
2252 tmp->done = FALSE; | |
2253 tmp->result = NULL; | |
2254 | |
2255 return tmp; | |
2256 } | |
2257 | |
2258 /* | |
2259 * Accepts a dialog struct and returns the given data to the | |
2260 * initial called of dw_dialog_wait(). | |
2261 * Parameters: | |
2262 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | |
2263 * result: Data to be returned by dw_dialog_wait(). | |
2264 */ | |
2265 int dw_dialog_dismiss(DWDialog *dialog, void *result) | |
2266 { | |
2267 dialog->result = result; | |
2268 dw_event_post(dialog->eve); | |
2269 dialog->done = TRUE; | |
2270 return 0; | |
2271 } | |
2272 | |
2273 /* | |
2274 * Accepts a dialog struct waits for dw_dialog_dismiss() to be | |
2275 * called by a signal handler with the given dialog struct. | |
2276 * Parameters: | |
2277 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | |
2278 */ | |
2279 void *dw_dialog_wait(DWDialog *dialog) | |
2280 { | |
2281 QMSG qmsg; | |
2282 void *tmp; | |
2283 | |
2284 while (WinGetMsg(dwhab, &qmsg, 0, 0, 0)) | |
2285 { | |
2286 WinDispatchMsg(dwhab, &qmsg); | |
2287 if(dialog->done) | |
2288 break; | |
2289 } | |
2290 dw_event_close(&dialog->eve); | |
2291 tmp = dialog->result; | |
2292 free(dialog); | |
2293 return tmp; | |
2294 } | |
2295 | |
2296 | |
2297 /* | |
2298 * Displays a Message Box with given text and title.. | |
2299 * Parameters: | |
2300 * title: The title of the message box. | |
2301 * format: printf style format string. | |
2302 * ...: Additional variables for use in the format. | |
2303 */ | |
2304 int dw_messagebox(char *title, char *format, ...) | |
2305 { | |
2306 va_list args; | |
2307 char outbuf[1024]; | |
2308 | |
2309 va_start(args, format); | |
2310 vsprintf(outbuf, format, args); | |
2311 va_end(args); | |
2312 | |
2313 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, outbuf, title, 0, MB_OK | MB_INFORMATION | MB_MOVEABLE); | |
2314 | |
2315 return strlen(outbuf); | |
2316 } | |
2317 | |
2318 /* | |
2319 * Displays a Message Box with given text and title.. | |
2320 * Parameters: | |
2321 * title: The title of the message box. | |
2322 * text: The text to display in the box. | |
2323 * Returns: | |
2324 * True if YES False of NO. | |
2325 */ | |
2326 int dw_yesno(char *title, char *text) | |
2327 { | |
2328 if(WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, title, 0, MB_YESNO | MB_INFORMATION | MB_MOVEABLE | MB_SYSTEMMODAL)==MBID_YES) | |
2329 return TRUE; | |
2330 return FALSE; | |
2331 } | |
2332 | |
2333 /* | |
2334 * Makes the window visible. | |
2335 * Parameters: | |
2336 * handle: The window handle to make visible. | |
2337 */ | |
2338 int dw_window_show(HWND handle) | |
2339 { | |
2340 int rc = WinSetWindowPos(handle, NULLHANDLE, 0, 0, 0, 0, SWP_SHOW); | |
2341 HSWITCH hswitch; | |
2342 SWCNTRL swcntrl; | |
2343 | |
2344 WinSetFocus(HWND_DESKTOP, handle); | |
2345 _initial_focus(handle); | |
2346 | |
2347 /* If this window has a switch list entry make sure it is visible */ | |
2348 hswitch = WinQuerySwitchHandle(handle, 0); | |
2349 if(hswitch) | |
2350 { | |
2351 WinQuerySwitchEntry(hswitch, &swcntrl); | |
2352 swcntrl.uchVisibility = SWL_VISIBLE; | |
2353 WinChangeSwitchEntry(hswitch, &swcntrl); | |
2354 } | |
2355 return rc; | |
2356 | |
2357 } | |
2358 | |
2359 /* | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2360 * Minimizes or Iconifies a top-level window. |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2361 * Parameters: |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2362 * handle: The window handle to minimize. |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2363 */ |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2364 int dw_window_minimize(HWND handle) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2365 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2366 return WinSetWindowPos(handle, NULLHANDLE, 0, 0, 0, 0, SWP_MINIMIZE); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2367 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2368 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2369 /* |
3 | 2370 * Makes the window invisible. |
2371 * Parameters: | |
2372 * handle: The window handle to make visible. | |
2373 */ | |
2374 int dw_window_hide(HWND handle) | |
2375 { | |
2376 HSWITCH hswitch; | |
2377 SWCNTRL swcntrl; | |
2378 | |
2379 /* If this window has a switch list entry make sure it is invisible */ | |
2380 hswitch = WinQuerySwitchHandle(handle, 0); | |
2381 if(hswitch) | |
2382 { | |
2383 WinQuerySwitchEntry(hswitch, &swcntrl); | |
2384 swcntrl.uchVisibility = SWL_INVISIBLE; | |
2385 WinChangeSwitchEntry(hswitch, &swcntrl); | |
2386 } | |
2387 return WinShowWindow(handle, FALSE); | |
2388 } | |
2389 | |
2390 /* | |
2391 * Destroys a window and all of it's children. | |
2392 * Parameters: | |
2393 * handle: The window handle to destroy. | |
2394 */ | |
2395 int dw_window_destroy(HWND handle) | |
2396 { | |
2397 return WinDestroyWindow(handle); | |
2398 } | |
2399 | |
2400 /* | |
2401 * Changes a window's parent to newparent. | |
2402 * Parameters: | |
2403 * handle: The window handle to destroy. | |
2404 * newparent: The window's new parent window. | |
2405 */ | |
2406 void dw_window_reparent(HWND handle, HWND newparent) | |
2407 { | |
2408 HWND blah = WinWindowFromID(newparent, FID_CLIENT); | |
2409 WinSetParent(handle, blah ? blah : newparent, TRUE); | |
2410 } | |
2411 | |
2412 /* | |
2413 * Sets the font used by a specified window (widget) handle. | |
2414 * Parameters: | |
2415 * handle: The window (widget) handle. | |
2416 * fontname: Name and size of the font in the form "size.fontname" | |
2417 */ | |
2418 int dw_window_set_font(HWND handle, char *fontname) | |
2419 { | |
2420 return WinSetPresParam(handle, PP_FONTNAMESIZE, strlen(fontname)+1, fontname); | |
2421 } | |
2422 | |
2423 /* | |
2424 * Sets the colors used by a specified window (widget) handle. | |
2425 * Parameters: | |
2426 * handle: The window (widget) handle. | |
2427 * fore: Foreground color in DW_RGB format or a default color index. | |
2428 * back: Background color in DW_RGB format or a default color index. | |
2429 */ | |
2430 int dw_window_set_color(HWND handle, ULONG fore, ULONG back) | |
2431 { | |
2432 if((fore & DW_RGB_COLOR) == DW_RGB_COLOR) | |
2433 { | |
2434 RGB2 rgb2; | |
2435 | |
2436 rgb2.bBlue = DW_BLUE_VALUE(fore); | |
2437 rgb2.bGreen = DW_GREEN_VALUE(fore); | |
2438 rgb2.bRed = DW_RED_VALUE(fore); | |
2439 rgb2.fcOptions = 0; | |
2440 | |
2441 WinSetPresParam(handle, PP_FOREGROUNDCOLOR, sizeof(RGB2), &rgb2); | |
2442 | |
2443 } | |
2444 if((back & DW_RGB_COLOR) == DW_RGB_COLOR) | |
2445 { | |
2446 RGB2 rgb2; | |
2447 | |
2448 rgb2.bBlue = DW_BLUE_VALUE(back); | |
2449 rgb2.bGreen = DW_GREEN_VALUE(back); | |
2450 rgb2.bRed = DW_RED_VALUE(back); | |
2451 rgb2.fcOptions = 0; | |
2452 | |
2453 WinSetPresParam(handle, PP_BACKGROUNDCOLOR, sizeof(RGB2), &rgb2); | |
2454 return 0; | |
2455 } | |
2456 if((fore & DW_RGB_COLOR) == DW_RGB_COLOR) | |
2457 return 0; | |
2458 | |
2459 /* Slight conversion */ | |
2460 if(fore == DW_CLR_BLACK) | |
2461 fore = CLR_BLACK; | |
2462 if(fore == DW_CLR_WHITE) | |
2463 fore = CLR_WHITE; | |
2464 | |
2465 if(back == DW_CLR_BLACK) | |
2466 back = CLR_BLACK; | |
2467 if(back == DW_CLR_WHITE) | |
2468 back = CLR_WHITE; | |
2469 | |
2470 return (WinSetPresParam(handle, PP_FOREGROUNDCOLORINDEX, sizeof(ULONG), &fore) | | |
2471 WinSetPresParam(handle, PP_BACKGROUNDCOLORINDEX, sizeof(ULONG), &back)); | |
2472 } | |
2473 | |
2474 /* | |
2475 * Sets the font used by a specified window (widget) handle. | |
2476 * Parameters: | |
2477 * handle: The window (widget) handle. | |
2478 * border: Size of the window border in pixels. | |
2479 */ | |
2480 int dw_window_set_border(HWND handle, int border) | |
2481 { | |
2482 WinSendMsg(handle, WM_SETBORDERSIZE, MPFROMSHORT(border), MPFROMSHORT(border)); | |
2483 return 0; | |
2484 } | |
2485 | |
2486 /* | |
2487 * Captures the mouse input to this window. | |
2488 * Parameters: | |
2489 * handle: Handle to receive mouse input. | |
2490 */ | |
2491 void dw_window_capture(HWND handle) | |
2492 { | |
2493 WinSetCapture(HWND_DESKTOP, handle); | |
2494 } | |
2495 | |
2496 /* | |
2497 * Releases previous mouse capture. | |
2498 */ | |
2499 void dw_window_release(void) | |
2500 { | |
2501 WinSetCapture(HWND_DESKTOP, NULLHANDLE); | |
2502 } | |
2503 | |
2504 /* | |
2505 * Tracks this window movement. | |
2506 * Parameters: | |
2507 * handle: Handle to frame to be tracked. | |
2508 */ | |
2509 void dw_window_track(HWND handle) | |
2510 { | |
2511 WinSendMsg(handle, WM_TRACKFRAME, MPFROMSHORT(TF_MOVE), 0); | |
2512 } | |
2513 | |
2514 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2515 * Changes the appearance of the mouse pointer. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2516 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2517 * handle: Handle to widget for which to change. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2518 * cursortype: ID of the pointer you want. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2519 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2520 void dw_window_pointer(HWND handle, int pointertype) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2521 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2522 WinSetPointer(handle, |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2523 WinQuerySysPointer(HWND_DESKTOP, |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2524 pointertype, |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2525 FALSE)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2526 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2527 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2528 /* |
3 | 2529 * Create a new Window Frame. |
2530 * Parameters: | |
2531 * owner: The Owner's window handle or HWND_DESKTOP. | |
2532 * title: The Window title. | |
2533 * flStyle: Style flags, see the PM reference. | |
2534 */ | |
2535 HWND dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) | |
2536 { | |
2537 HWND hwndclient = 0, hwndframe; | |
8
e22584460709
Switched allocating the box structs with calloc instead of malloc so
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2538 Box *newbox = calloc(1, sizeof(Box)); |
3 | 2539 PFNWP *blah = malloc(sizeof(PFNWP)); |
2540 | |
2541 newbox->pad = 0; | |
2542 newbox->type = BOXVERT; | |
2543 newbox->count = 0; | |
2544 | |
2545 flStyle |= FCF_NOBYTEALIGN; | |
2546 | |
2547 hwndframe = WinCreateStdWindow(hwndOwner, 0L, &flStyle, ClassName, title, 0L, NULLHANDLE, 0L, &hwndclient); | |
2548 *blah = WinSubclassWindow(hwndframe, _sizeproc); | |
2549 WinSetWindowPtr(hwndframe, QWP_USER, blah); | |
2550 WinSetWindowPtr(hwndclient, QWP_USER, newbox); | |
2551 | |
2552 return hwndframe; | |
2553 } | |
2554 | |
2555 /* | |
2556 * Create a new Box to be packed. | |
2557 * Parameters: | |
2558 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). | |
2559 * pad: Number of pixels to pad around the box. | |
2560 */ | |
2561 HWND dw_box_new(int type, int pad) | |
2562 { | |
8
e22584460709
Switched allocating the box structs with calloc instead of malloc so
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2563 Box *newbox = calloc(1, sizeof(Box)); |
3 | 2564 HWND hwndframe; |
2565 | |
2566 newbox->pad = pad; | |
2567 newbox->type = type; | |
2568 newbox->count = 0; | |
2569 newbox->grouphwnd = NULLHANDLE; | |
2570 | |
2571 hwndframe = WinCreateWindow(HWND_OBJECT, | |
2572 WC_FRAME, | |
2573 NULL, | |
2574 WS_VISIBLE | WS_CLIPCHILDREN, | |
2575 0,0,2000,1000, | |
2576 NULLHANDLE, | |
2577 HWND_TOP, | |
2578 0L, | |
2579 NULL, | |
2580 NULL); | |
2581 | |
2582 newbox->oldproc = WinSubclassWindow(hwndframe, _controlproc); | |
2583 WinSetWindowPtr(hwndframe, QWP_USER, newbox); | |
2584 dw_window_set_color(hwndframe, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); | |
2585 return hwndframe; | |
2586 } | |
2587 | |
2588 /* | |
2589 * Create a new Group Box to be packed. | |
2590 * Parameters: | |
2591 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). | |
2592 * pad: Number of pixels to pad around the box. | |
2593 * title: Text to be displayined in the group outline. | |
2594 */ | |
2595 HWND dw_groupbox_new(int type, int pad, char *title) | |
2596 { | |
8
e22584460709
Switched allocating the box structs with calloc instead of malloc so
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2597 Box *newbox = calloc(1, sizeof(Box)); |
3 | 2598 HWND hwndframe; |
2599 | |
2600 newbox->pad = pad; | |
2601 newbox->type = type; | |
2602 newbox->count = 0; | |
2603 | |
2604 hwndframe = WinCreateWindow(HWND_OBJECT, | |
2605 WC_FRAME, | |
2606 NULL, | |
2607 WS_VISIBLE, | |
2608 0,0,2000,1000, | |
2609 NULLHANDLE, | |
2610 HWND_TOP, | |
2611 0L, | |
2612 NULL, | |
2613 NULL); | |
2614 | |
2615 newbox->grouphwnd = WinCreateWindow(hwndframe, | |
2616 WC_STATIC, | |
2617 title, | |
2618 WS_VISIBLE | SS_GROUPBOX | | |
2619 WS_GROUP, | |
2620 0,0,2000,1000, | |
2621 NULLHANDLE, | |
2622 HWND_TOP, | |
2623 0L, | |
2624 NULL, | |
2625 NULL); | |
2626 | |
2627 WinSetWindowPtr(hwndframe, QWP_USER, newbox); | |
2628 dw_window_set_color(hwndframe, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); | |
2629 dw_window_set_color(newbox->grouphwnd, DW_CLR_BLACK, DW_CLR_PALEGRAY); | |
2630 dw_window_set_font(newbox->grouphwnd, DefaultFont); | |
2631 return hwndframe; | |
2632 } | |
2633 | |
2634 /* | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2635 * Create a new MDI Frame to be packed. |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2636 * Parameters: |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2637 * id: An ID to be used with dw_window_from_id or 0L. |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2638 */ |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2639 HWND dw_mdi_new(unsigned long id) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2640 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2641 HWND hwndframe; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2642 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2643 hwndframe = WinCreateWindow(HWND_OBJECT, |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2644 WC_FRAME, |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2645 NULL, |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2646 WS_VISIBLE | WS_CLIPCHILDREN, |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2647 0,0,2000,1000, |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2648 NULLHANDLE, |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2649 HWND_TOP, |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2650 0L, |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2651 NULL, |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2652 NULL); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2653 return hwndframe; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2654 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2655 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2656 /* |
3 | 2657 * Create a bitmap object to be packed. |
2658 * Parameters: | |
2659 * id: An ID to be used with WinWindowFromID() or 0L. | |
2660 */ | |
2661 HWND dw_bitmap_new(ULONG id) | |
2662 { | |
2663 return WinCreateWindow(HWND_OBJECT, | |
2664 WC_STATIC, | |
2665 NULL, | |
2666 WS_VISIBLE | SS_TEXT, | |
2667 0,0,2000,1000, | |
2668 NULLHANDLE, | |
2669 HWND_TOP, | |
2670 id, | |
2671 NULL, | |
2672 NULL); | |
2673 } | |
2674 | |
2675 /* | |
2676 * Create a notebook object to be packed. | |
2677 * Parameters: | |
2678 * id: An ID to be used for getting the resource from the | |
2679 * resource file. | |
2680 */ | |
2681 HWND dw_notebook_new(ULONG id, int top) | |
2682 { | |
2683 ULONG flags; | |
2684 HWND tmp; | |
2685 | |
2686 if(top) | |
2687 flags = BKS_MAJORTABTOP; | |
2688 else | |
2689 flags = BKS_MAJORTABBOTTOM; | |
2690 | |
2691 tmp = WinCreateWindow(HWND_OBJECT, | |
2692 WC_NOTEBOOK, | |
2693 NULL, | |
2694 WS_VISIBLE | | |
2695 BKS_TABBEDDIALOG | | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2696 flags, |
3 | 2697 0,0,2000,1000, |
2698 NULLHANDLE, | |
2699 HWND_TOP, | |
2700 id, | |
2701 NULL, | |
2702 NULL); | |
2703 | |
20
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
2704 /* Fix tab sizes on Warp 3 */ |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
2705 if(!IS_WARP4()) |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
2706 { |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
2707 /* best sizes to be determined by trial and error */ |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
2708 WinSendMsg(tmp, BKM_SETDIMENSIONS,MPFROM2SHORT(102, 28), MPFROMSHORT( BKA_MAJORTAB)); |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
2709 } |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
2710 |
3 | 2711 dw_window_set_font(tmp, DefaultFont); |
2712 return tmp; | |
2713 } | |
2714 | |
2715 /* | |
2716 * Create a menu object to be popped up. | |
2717 * Parameters: | |
2718 * id: An ID to be used for getting the resource from the | |
2719 * resource file. | |
2720 */ | |
2721 HMENUI dw_menu_new(ULONG id) | |
2722 { | |
2723 HMENUI tmp = malloc(sizeof(struct _hmenui)); | |
2724 | |
2725 if(!tmp) | |
2726 return NULL; | |
2727 | |
2728 tmp->menu = WinCreateWindow(HWND_OBJECT, | |
2729 WC_MENU, | |
2730 NULL, | |
2731 WS_VISIBLE, | |
2732 0,0,2000,1000, | |
2733 NULLHANDLE, | |
2734 HWND_TOP, | |
2735 id, | |
2736 NULL, | |
2737 NULL); | |
2738 return tmp; | |
2739 } | |
2740 | |
2741 /* | |
2742 * Create a menubar on a window. | |
2743 * Parameters: | |
2744 * location: Handle of a window frame to be attached to. | |
2745 */ | |
2746 HMENUI dw_menubar_new(HWND location) | |
2747 { | |
2748 HMENUI tmp = malloc(sizeof(struct _hmenui)); | |
2749 | |
2750 if(!tmp) | |
2751 return NULL; | |
2752 | |
2753 tmp->menu = WinCreateWindow(location, | |
2754 WC_MENU, | |
2755 NULL, | |
2756 WS_VISIBLE | MS_ACTIONBAR, | |
2757 0,0,2000,1000, | |
2758 location, | |
2759 HWND_TOP, | |
2760 FID_MENU, | |
2761 NULL, | |
2762 NULL); | |
2763 return tmp; | |
2764 } | |
2765 | |
2766 /* | |
2767 * Destroys a menu created with dw_menubar_new or dw_menu_new. | |
2768 * Parameters: | |
2769 * menu: Handle of a menu. | |
2770 */ | |
2771 void dw_menu_destroy(HMENUI *menu) | |
2772 { | |
2773 if(menu && *menu) | |
2774 { | |
2775 WinDestroyWindow((*menu)->menu); | |
2776 free(*menu); | |
2777 *menu = NULL; | |
2778 } | |
2779 } | |
2780 | |
2781 /* | |
2782 * Adds a menuitem or submenu to an existing menu. | |
2783 * Parameters: | |
2784 * menu: The handle the the existing menu. | |
2785 * title: The title text on the menu item to be added. | |
2786 * id: An ID to be used for message passing. | |
2787 * flags: Extended attributes to set on the menu. | |
2788 * end: If TRUE memu is positioned at the end of the menu. | |
2789 * check: If TRUE menu is "check"able. | |
2790 * submenu: Handle to an existing menu to be a submenu or NULL. | |
2791 */ | |
2792 HWND dw_menu_append_item(HMENUI menux, char *title, ULONG id, ULONG flags, int end, int check, HMENUI submenu) | |
2793 { | |
2794 MENUITEM miSubMenu; | |
2795 HWND menu; | |
2796 | |
2797 if(!menux) | |
2798 return NULLHANDLE; | |
2799 | |
2800 menu = menux->menu; | |
2801 | |
2802 if(end) | |
2803 miSubMenu.iPosition=MIT_END; | |
2804 else | |
2805 miSubMenu.iPosition=0; | |
2806 | |
2807 if(strlen(title) == 0) | |
2808 miSubMenu.afStyle=MIS_SEPARATOR | flags; | |
2809 else | |
2810 miSubMenu.afStyle=MIS_TEXT | flags; | |
2811 miSubMenu.afAttribute=0; | |
2812 miSubMenu.id=id; | |
2813 miSubMenu.hwndSubMenu = submenu ? submenu->menu : 0; | |
2814 miSubMenu.hItem=NULLHANDLE; | |
2815 | |
2816 WinSendMsg(menu, | |
2817 MM_INSERTITEM, | |
2818 MPFROMP(&miSubMenu), | |
2819 MPFROMP(title)); | |
2820 return (HWND)id; | |
2821 } | |
2822 | |
2823 /* | |
2824 * Sets the state of a menu item check. | |
2825 * Parameters: | |
2826 * menu: The handle the the existing menu. | |
2827 * id: Menuitem id. | |
2828 * check: TRUE for checked FALSE for not checked. | |
2829 */ | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
9
diff
changeset
|
2830 void dw_menu_item_set_check(HMENUI menux, unsigned long id, int check) |
3 | 2831 { |
2832 HWND menu; | |
2833 | |
2834 if(!menux) | |
2835 return; | |
2836 | |
2837 menu = menux->menu; | |
2838 | |
2839 if(check) | |
2840 WinSendMsg(menu, MM_SETITEMATTR, MPFROM2SHORT(id, TRUE), | |
2841 MPFROM2SHORT(MIA_CHECKED, MIA_CHECKED)); | |
2842 else | |
2843 WinSendMsg(menu, MM_SETITEMATTR, MPFROM2SHORT(id, TRUE), | |
2844 MPFROM2SHORT(MIA_CHECKED, 0)); | |
2845 } | |
2846 | |
2847 /* | |
2848 * Pops up a context menu at given x and y coordinates. | |
2849 * Parameters: | |
2850 * menu: The handle the the existing menu. | |
2851 * parent: Handle to the window initiating the popup. | |
2852 * x: X coordinate. | |
2853 * y: Y coordinate. | |
2854 */ | |
2855 void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) | |
2856 { | |
2857 if(menu && *menu) | |
2858 { | |
2859 WinPopupMenu(HWND_DESKTOP, parent, (*menu)->menu, x, dw_screen_height() - y, 0, PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_VCONSTRAIN | PU_HCONSTRAIN); | |
2860 free(*menu); | |
2861 *menu = NULL; | |
2862 } | |
2863 } | |
2864 | |
2865 /* | |
2866 * Returns the current X and Y coordinates of the mouse pointer. | |
2867 * Parameters: | |
2868 * x: Pointer to variable to store X coordinate. | |
2869 * y: Pointer to variable to store Y coordinate. | |
2870 */ | |
2871 void dw_pointer_query_pos(long *x, long *y) | |
2872 { | |
2873 POINTL ptl; | |
2874 | |
2875 WinQueryPointerPos(HWND_DESKTOP, &ptl); | |
2876 if(x && y) | |
2877 { | |
2878 *x = ptl.x; | |
2879 *y = dw_screen_height() - ptl.y; | |
2880 } | |
2881 } | |
2882 | |
2883 /* | |
2884 * Sets the X and Y coordinates of the mouse pointer. | |
2885 * Parameters: | |
2886 * x: X coordinate. | |
2887 * y: Y coordinate. | |
2888 */ | |
2889 void dw_pointer_set_pos(long x, long y) | |
2890 { | |
2891 WinSetPointerPos(HWND_DESKTOP, x, dw_screen_height() - y); | |
2892 } | |
2893 | |
2894 /* | |
2895 * Create a container object to be packed. | |
2896 * Parameters: | |
2897 * id: An ID to be used for getting the resource from the | |
2898 * resource file. | |
2899 */ | |
2900 HWND dw_container_new(ULONG id) | |
2901 { | |
2902 HWND tmp = WinCreateWindow(HWND_OBJECT, | |
2903 WC_CONTAINER, | |
2904 NULL, | |
2905 WS_VISIBLE | CCS_READONLY | | |
2906 CCS_SINGLESEL | CCS_AUTOPOSITION, | |
2907 0,0,2000,1000, | |
2908 NULLHANDLE, | |
2909 HWND_TOP, | |
2910 id, | |
2911 NULL, | |
2912 NULL); | |
2913 dw_window_set_font(tmp, DefaultFont); | |
2914 return tmp; | |
2915 } | |
2916 | |
2917 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2918 * Create a tree object to be packed. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2919 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2920 * id: An ID to be used for getting the resource from the |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2921 * resource file. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2922 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2923 HWND dw_tree_new(ULONG id) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2924 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2925 CNRINFO cnrinfo; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2926 HWND tmp = WinCreateWindow(HWND_OBJECT, |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2927 WC_CONTAINER, |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2928 NULL, |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2929 WS_VISIBLE | CCS_READONLY | |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2930 CCS_SINGLESEL | CCS_AUTOPOSITION, |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2931 0,0,2000,1000, |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2932 NULLHANDLE, |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2933 HWND_TOP, |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2934 id, |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2935 NULL, |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2936 NULL); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2937 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2938 cnrinfo.flWindowAttr = CV_TREE | CA_TREELINE; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2939 cnrinfo.slBitmapOrIcon.cx = 16; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2940 cnrinfo.slBitmapOrIcon.cy = 16; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2941 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2942 WinSendMsg(tmp, CM_SETCNRINFO, &cnrinfo, MPFROMLONG(CMA_FLWINDOWATTR | CMA_SLBITMAPORICON)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2943 dw_window_set_font(tmp, DefaultFont); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2944 return tmp; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2945 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2946 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
2947 /* |
3 | 2948 * Create a new static text window (widget) to be packed. |
2949 * Parameters: | |
2950 * text: The text to be display by the static text widget. | |
2951 * id: An ID to be used with WinWindowFromID() or 0L. | |
2952 */ | |
2953 HWND dw_text_new(char *text, ULONG id) | |
2954 { | |
2955 HWND tmp = WinCreateWindow(HWND_OBJECT, | |
2956 WC_STATIC, | |
2957 text, | |
2958 WS_VISIBLE | SS_TEXT, | |
2959 0,0,2000,1000, | |
2960 NULLHANDLE, | |
2961 HWND_TOP, | |
2962 id, | |
2963 NULL, | |
2964 NULL); | |
2965 dw_window_set_font(tmp, DefaultFont); | |
2966 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); | |
2967 return tmp; | |
2968 } | |
2969 | |
2970 /* | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2971 * Create a new status text window (widget) to be packed. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2972 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2973 * text: The text to be display by the static text widget. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2974 * id: An ID to be used with WinWindowFromID() or 0L. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2975 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2976 HWND dw_status_text_new(char *text, ULONG id) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2977 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2978 PFNWP *blah = malloc(sizeof(PFNWP)); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2979 HWND tmp = WinCreateWindow(HWND_OBJECT, |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2980 WC_STATIC, |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2981 text, |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2982 WS_VISIBLE | SS_TEXT, |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2983 0,0,2000,1000, |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2984 NULLHANDLE, |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2985 HWND_TOP, |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2986 id, |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2987 NULL, |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2988 NULL); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2989 dw_window_set_font(tmp, DefaultFont); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2990 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2991 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2992 *blah = WinSubclassWindow(tmp, _statusproc); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2993 WinSetWindowPtr(tmp, QWP_USER, blah); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2994 return tmp; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2995 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2996 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2997 /* |
3 | 2998 * Create a new Multiline Editbox window (widget) to be packed. |
2999 * Parameters: | |
3000 * id: An ID to be used with WinWindowFromID() or 0L. | |
3001 */ | |
3002 HWND dw_mle_new(ULONG id) | |
3003 { | |
3004 HWND tmp = WinCreateWindow(HWND_OBJECT, | |
3005 WC_MLE, | |
3006 "", | |
3007 WS_VISIBLE | | |
3008 MLS_BORDER | MLS_IGNORETAB | | |
3009 MLS_READONLY | MLS_VSCROLL, | |
3010 0,0,2000,1000, | |
3011 NULLHANDLE, | |
3012 HWND_TOP, | |
3013 id, | |
3014 NULL, | |
3015 NULL); | |
3016 dw_window_set_font(tmp, DefaultFont); | |
3017 dw_window_set_font(tmp, DefaultFont); | |
3018 return tmp; | |
3019 } | |
3020 | |
3021 /* | |
3022 * Create a new Entryfield window (widget) to be packed. | |
3023 * Parameters: | |
3024 * text: The default text to be in the entryfield widget. | |
3025 * id: An ID to be used with WinWindowFromID() or 0L. | |
3026 */ | |
3027 HWND dw_entryfield_new(char *text, ULONG id) | |
3028 { | |
3029 PFNWP *blah = malloc(sizeof(PFNWP)); | |
3030 HWND tmp = WinCreateWindow(HWND_OBJECT, | |
3031 WC_ENTRYFIELD, | |
3032 text, | |
3033 WS_VISIBLE | ES_MARGIN | | |
3034 ES_AUTOSCROLL | WS_TABSTOP, | |
3035 0,0,2000,1000, | |
3036 NULLHANDLE, | |
3037 HWND_TOP, | |
3038 id, | |
3039 NULL, | |
3040 NULL); | |
3041 dw_window_set_font(tmp, DefaultFont); | |
3042 *blah = WinSubclassWindow(tmp, _entryproc); | |
3043 WinSetWindowPtr(tmp, QWP_USER, blah); | |
3044 return tmp; | |
3045 } | |
3046 | |
3047 /* | |
3048 * Create a new Entryfield (password) window (widget) to be packed. | |
3049 * Parameters: | |
3050 * text: The default text to be in the entryfield widget. | |
3051 * id: An ID to be used with WinWindowFromID() or 0L. | |
3052 */ | |
3053 HWND dw_entryfield_password_new(char *text, ULONG id) | |
3054 { | |
3055 PFNWP *blah = malloc(sizeof(PFNWP)); | |
3056 HWND tmp = WinCreateWindow(HWND_OBJECT, | |
3057 WC_ENTRYFIELD, | |
3058 text, | |
3059 WS_VISIBLE | ES_MARGIN | ES_UNREADABLE | | |
3060 ES_AUTOSCROLL | WS_TABSTOP, | |
3061 0,0,2000,1000, | |
3062 NULLHANDLE, | |
3063 HWND_TOP, | |
3064 id, | |
3065 NULL, | |
3066 NULL); | |
3067 dw_window_set_font(tmp, DefaultFont); | |
3068 *blah = WinSubclassWindow(tmp, _entryproc); | |
3069 WinSetWindowPtr(tmp, QWP_USER, blah); | |
3070 return tmp; | |
3071 } | |
3072 | |
3073 /* | |
3074 * Create a new Combobox window (widget) to be packed. | |
3075 * Parameters: | |
3076 * text: The default text to be in the combpbox widget. | |
3077 * id: An ID to be used with WinWindowFromID() or 0L. | |
3078 */ | |
3079 HWND dw_combobox_new(char *text, ULONG id) | |
3080 { | |
3081 PFNWP *blah = malloc(sizeof(PFNWP)); | |
3082 HWND tmp = WinCreateWindow(HWND_OBJECT, | |
3083 WC_COMBOBOX, | |
3084 text, | |
3085 WS_VISIBLE | CBS_DROPDOWN | WS_GROUP, | |
3086 0,0,2000,1000, | |
3087 NULLHANDLE, | |
3088 HWND_TOP, | |
3089 id, | |
3090 NULL, | |
3091 NULL); | |
3092 dw_window_set_font(tmp, DefaultFont); | |
3093 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE); | |
3094 *blah = WinSubclassWindow(tmp, _comboproc); | |
3095 WinSetWindowPtr(tmp, QWP_USER, blah); | |
3096 return tmp; | |
3097 } | |
3098 | |
3099 /* | |
3100 * Create a new button window (widget) to be packed. | |
3101 * Parameters: | |
3102 * text: The text to be display by the static text widget. | |
3103 * id: An ID to be used with WinWindowFromID() or 0L. | |
3104 */ | |
3105 HWND dw_button_new(char *text, ULONG id) | |
3106 { | |
3107 BubbleButton *bubble = malloc(sizeof(BubbleButton)); | |
3108 | |
3109 HWND tmp = WinCreateWindow(HWND_OBJECT, | |
3110 WC_BUTTON, | |
3111 text, | |
3112 WS_VISIBLE, | |
3113 0,0,2000,1000, | |
3114 NULLHANDLE, | |
3115 HWND_TOP, | |
3116 id, | |
3117 NULL, | |
3118 NULL); | |
3119 | |
3120 bubble->id = id; | |
3121 bubble->bubbletext[0] = '\0'; | |
3122 bubble->pOldProc = WinSubclassWindow(tmp, _BtProc); | |
3123 | |
3124 WinSetWindowPtr(tmp, QWP_USER, bubble); | |
3125 dw_window_set_font(tmp, DefaultFont); | |
3126 return tmp; | |
3127 } | |
3128 | |
3129 /* Function: GenResIDStr | |
3130 ** Abstract: Generate string '#nnnn' for a given ID for using with Button | |
3131 ** controls | |
3132 */ | |
3133 | |
3134 void _GenResIDStr(CHAR *buff, ULONG ulID) | |
3135 { | |
3136 char *str; | |
3137 int slen = 0; | |
3138 | |
3139 *buff++ = '#'; | |
3140 | |
3141 str = buff; | |
3142 | |
3143 do | |
3144 { | |
3145 *str++ = (ulID % 10) + '0'; | |
3146 ulID /= 10; | |
3147 slen++; | |
3148 } | |
3149 while(ulID); | |
3150 | |
3151 *str-- = 0; | |
3152 | |
3153 for(; str > buff; str--, buff++) | |
3154 { | |
3155 *buff ^= *str; | |
3156 *str ^= *buff; | |
3157 *buff ^= *str; | |
3158 } | |
3159 } | |
3160 | |
3161 | |
3162 /* | |
3163 * Create a new bitmap button window (widget) to be packed. | |
3164 * Parameters: | |
3165 * text: Bubble help text to be displayed. | |
3166 * id: An ID of a bitmap in the resource file. | |
3167 */ | |
3168 HWND dw_bitmapbutton_new(char *text, ULONG id) | |
3169 { | |
3170 char idbuf[256]; | |
3171 HWND tmp; | |
3172 BubbleButton *bubble = malloc(sizeof(BubbleButton)); | |
3173 | |
3174 _GenResIDStr(idbuf, id); | |
3175 | |
3176 tmp = WinCreateWindow(HWND_OBJECT, | |
3177 WC_BUTTON, | |
3178 idbuf, | |
3179 WS_VISIBLE | BS_PUSHBUTTON | | |
3180 BS_BITMAP | BS_AUTOSIZE | | |
3181 BS_NOPOINTERFOCUS, | |
3182 0,0,2000,1000, | |
3183 NULLHANDLE, | |
3184 HWND_TOP, | |
3185 id, | |
3186 NULL, | |
3187 NULL); | |
3188 | |
3189 bubble->id = id; | |
3190 strncpy(bubble->bubbletext, text, BUBBLE_HELP_MAX - 1); | |
3191 bubble->bubbletext[BUBBLE_HELP_MAX - 1] = '\0'; | |
3192 bubble->pOldProc = WinSubclassWindow(tmp, _BtProc); | |
3193 | |
3194 WinSetWindowPtr(tmp, QWP_USER, bubble); | |
3195 return tmp; | |
3196 } | |
3197 | |
3198 /* | |
3199 * Create a new spinbutton window (widget) to be packed. | |
3200 * Parameters: | |
3201 * text: The text to be display by the static text widget. | |
3202 * id: An ID to be used with WinWindowFromID() or 0L. | |
3203 */ | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3204 HWND dw_spinbutton_new(char *text, ULONG id) |
3 | 3205 { |
3206 PFNWP *blah = malloc(sizeof(PFNWP)); | |
3207 HWND tmp = WinCreateWindow(HWND_OBJECT, | |
3208 WC_SPINBUTTON, | |
3209 text, | |
3210 WS_VISIBLE | SPBS_MASTER, | |
3211 0,0,2000,1000, | |
3212 NULLHANDLE, | |
3213 HWND_TOP, | |
3214 id, | |
3215 NULL, | |
3216 NULL); | |
3217 dw_window_set_font(tmp, DefaultFont); | |
3218 *blah = WinSubclassWindow(tmp, _entryproc); | |
3219 WinSetWindowPtr(tmp, QWP_USER, blah); | |
3220 return tmp; | |
3221 } | |
3222 | |
3223 /* | |
3224 * Create a new radiobutton window (widget) to be packed. | |
3225 * Parameters: | |
3226 * text: The text to be display by the static text widget. | |
3227 * id: An ID to be used with WinWindowFromID() or 0L. | |
3228 */ | |
3229 HWND dw_radiobutton_new(char *text, ULONG id) | |
3230 { | |
3231 PFNWP *blah = malloc(sizeof(PFNWP)); | |
3232 HWND tmp = WinCreateWindow(HWND_OBJECT, | |
3233 WC_BUTTON, | |
3234 text, | |
3235 WS_VISIBLE | | |
3236 BS_AUTORADIOBUTTON, | |
3237 0,0,2000,1000, | |
3238 NULLHANDLE, | |
3239 HWND_TOP, | |
3240 id, | |
3241 NULL, | |
3242 NULL); | |
3243 dw_window_set_font(tmp, DefaultFont); | |
3244 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); | |
3245 *blah = WinSubclassWindow(tmp, _entryproc); | |
3246 WinSetWindowPtr(tmp, QWP_USER, blah); | |
3247 return tmp; | |
3248 } | |
3249 | |
3250 /* | |
3251 * Create a new slider window (widget) to be packed. | |
3252 * Parameters: | |
3253 * id: An ID to be used with WinWindowFromID() or 0L. | |
3254 */ | |
3255 HWND dw_slider_new(ULONG id) | |
3256 { | |
3257 return WinCreateWindow(HWND_OBJECT, | |
3258 WC_SLIDER, | |
3259 NULL, | |
3260 WS_VISIBLE, | |
3261 0,0,2000,1000, | |
3262 NULLHANDLE, | |
3263 HWND_TOP, | |
3264 id, | |
3265 NULL, | |
3266 NULL); | |
3267 } | |
3268 | |
3269 /* | |
3270 * Create a new checkbox window (widget) to be packed. | |
3271 * Parameters: | |
3272 * text: The text to be display by the static text widget. | |
3273 * id: An ID to be used with WinWindowFromID() or 0L. | |
3274 */ | |
3275 HWND dw_checkbox_new(char *text, ULONG id) | |
3276 { | |
3277 PFNWP *blah = malloc(sizeof(PFNWP)); | |
3278 HWND tmp = WinCreateWindow(HWND_OBJECT, | |
3279 WC_BUTTON, | |
3280 text, | |
3281 WS_VISIBLE | BS_AUTOCHECKBOX, | |
3282 0,0,2000,1000, | |
3283 NULLHANDLE, | |
3284 HWND_TOP, | |
3285 id, | |
3286 NULL, | |
3287 NULL); | |
3288 dw_window_set_font(tmp, DefaultFont); | |
3289 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); | |
3290 *blah = WinSubclassWindow(tmp, _entryproc); | |
3291 WinSetWindowPtr(tmp, QWP_USER, blah); | |
3292 return tmp; | |
3293 } | |
3294 | |
3295 /* | |
3296 * Create a new listbox window (widget) to be packed. | |
3297 * Parameters: | |
3298 * id: An ID to be used with WinWindowFromID() or 0L. | |
3299 * multi: Multiple select TRUE or FALSE. | |
3300 */ | |
3301 HWND dw_listbox_new(ULONG id, int multi) | |
3302 { | |
3303 PFNWP *blah = malloc(sizeof(PFNWP)); | |
3304 HWND tmp = WinCreateWindow(HWND_OBJECT, | |
3305 WC_LISTBOX, | |
3306 NULL, | |
3307 WS_VISIBLE | LS_NOADJUSTPOS | | |
3308 (multi ? LS_MULTIPLESEL : 0), | |
3309 0,0,2000,1000, | |
3310 NULLHANDLE, | |
3311 HWND_TOP, | |
3312 id, | |
3313 NULL, | |
3314 NULL); | |
3315 dw_window_set_font(tmp, DefaultFont); | |
3316 *blah = WinSubclassWindow(tmp, _entryproc); | |
3317 WinSetWindowPtr(tmp, QWP_USER, blah); | |
3318 return tmp; | |
3319 } | |
3320 | |
3321 /* | |
3322 * Sets the icon used for a given window. | |
3323 * Parameters: | |
3324 * handle: Handle to the window. | |
3325 * id: An ID to be used to specify the icon. | |
3326 */ | |
3327 void dw_window_set_icon(HWND handle, ULONG id) | |
3328 { | |
3329 HPOINTER icon; | |
3330 | |
3331 icon = WinLoadPointer(HWND_DESKTOP,NULLHANDLE,id); | |
3332 WinSendMsg(handle, WM_SETICON, (MPARAM)icon, 0); | |
3333 } | |
3334 | |
3335 /* | |
3336 * Sets the bitmap used for a given static window. | |
3337 * Parameters: | |
3338 * handle: Handle to the window. | |
3339 * id: An ID to be used to specify the icon. | |
3340 */ | |
3341 void dw_window_set_bitmap(HWND handle, ULONG id) | |
3342 { | |
3343 HBITMAP hbm; | |
3344 HPS hps = WinGetPS(handle); | |
3345 | |
3346 hbm = GpiLoadBitmap(hps, NULLHANDLE, id, 0, 0); | |
3347 WinSetWindowBits(handle,QWL_STYLE,SS_BITMAP,SS_BITMAP | 0x7f); | |
3348 WinSendMsg( handle, SM_SETHANDLE, MPFROMP(hbm), NULL ); | |
3349 /*WinSetWindowULong( hwndDlg, QWL_USER, (ULONG) hbm );*/ | |
3350 WinReleasePS(hps); | |
3351 } | |
3352 | |
3353 /* | |
3354 * Sets the text used for a given window. | |
3355 * Parameters: | |
3356 * handle: Handle to the window. | |
3357 * text: The text associsated with a given window. | |
3358 */ | |
3359 void dw_window_set_text(HWND handle, char *text) | |
3360 { | |
3361 WinSetWindowText(handle, text); | |
3362 } | |
3363 | |
3364 /* | |
3365 * Gets the text used for a given window. | |
3366 * Parameters: | |
3367 * handle: Handle to the window. | |
3368 * Returns: | |
3369 * text: The text associsated with a given window. | |
3370 */ | |
3371 char *dw_window_get_text(HWND handle) | |
3372 { | |
3373 char tempbuf[4096] = ""; | |
3374 | |
3375 WinQueryWindowText(handle, 4095, tempbuf); | |
3376 tempbuf[4095] = 0; | |
3377 | |
3378 return strdup(tempbuf); | |
3379 } | |
3380 | |
3381 /* | |
3382 * Disables given window (widget). | |
3383 * Parameters: | |
3384 * handle: Handle to the window. | |
3385 */ | |
3386 void dw_window_disable(HWND handle) | |
3387 { | |
3388 WinEnableWindow(handle, FALSE); | |
3389 } | |
3390 | |
3391 /* | |
3392 * Enables given window (widget). | |
3393 * Parameters: | |
3394 * handle: Handle to the window. | |
3395 */ | |
3396 void dw_window_enable(HWND handle) | |
3397 { | |
3398 WinEnableWindow(handle, TRUE); | |
3399 } | |
3400 | |
3401 /* | |
3402 * Gets the child window handle with specified ID. | |
3403 * Parameters: | |
3404 * handle: Handle to the parent window. | |
3405 * id: Integer ID of the child. | |
3406 */ | |
3407 HWND dw_window_from_id(HWND handle, int id) | |
3408 { | |
3409 HENUM henum; | |
3410 HWND child; | |
3411 char tmpbuf[100]; | |
3412 | |
3413 henum = WinBeginEnumWindows(handle); | |
3414 while((child = WinGetNextWindow(henum)) != NULLHANDLE) | |
3415 { | |
3416 int windowid = WinQueryWindowUShort(child, QWS_ID); | |
3417 HWND found; | |
3418 | |
3419 WinQueryClassName(child, 99, tmpbuf); | |
3420 | |
3421 /* If the child is a box (frame) then recurse into it */ | |
3422 if(strncmp(tmpbuf, "#1", 2)==0) | |
3423 if((found = dw_window_from_id(child, id)) != NULLHANDLE) | |
3424 return found; | |
3425 | |
3426 if(windowid && windowid == id) | |
3427 { | |
3428 WinEndEnumWindows(henum); | |
3429 return child; | |
3430 } | |
3431 } | |
3432 WinEndEnumWindows(henum); | |
3433 return NULLHANDLE; | |
3434 } | |
3435 | |
3436 /* | |
3437 * Pack windows (widgets) into a box from the end (or bottom). | |
3438 * Parameters: | |
3439 * box: Window handle of the box to be packed into. | |
3440 * item: Window handle of the item to be back. | |
3441 * width: Width in pixels of the item or -1 to be self determined. | |
3442 * height: Height in pixels of the item or -1 to be self determined. | |
3443 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
3444 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
3445 * pad: Number of pixels of padding around the item. | |
3446 */ | |
3447 void dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
3448 { | |
3449 Box *thisbox; | |
3450 | |
3451 if(WinWindowFromID(box, FID_CLIENT)) | |
3452 { | |
3453 box = WinWindowFromID(box, FID_CLIENT); | |
3454 thisbox = WinQueryWindowPtr(box, QWP_USER); | |
3455 } | |
3456 else | |
3457 thisbox = WinQueryWindowPtr(box, QWP_USER); | |
3458 if(thisbox) | |
3459 { | |
3460 if(thisbox->type == BOXHORZ) | |
3461 dw_box_pack_start_stub(box, item, width, height, hsize, vsize, pad); | |
3462 else | |
3463 dw_box_pack_end_stub(box, item, width, height, hsize, vsize, pad); | |
3464 } | |
3465 } | |
3466 | |
3467 void dw_box_pack_end_stub(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
3468 { | |
3469 HWND boxowner = NULLHANDLE; | |
3470 Box *thisbox; | |
3471 | |
3472 if(WinWindowFromID(box, FID_CLIENT)) | |
3473 { | |
3474 box = WinWindowFromID(box, FID_CLIENT); | |
3475 thisbox = WinQueryWindowPtr(box, QWP_USER); | |
3476 hsize = TRUE; | |
3477 vsize = TRUE; | |
3478 } | |
3479 else | |
3480 thisbox = WinQueryWindowPtr(box, QWP_USER); | |
3481 if(!thisbox) | |
3482 { | |
3483 box = WinWindowFromID(box, FID_CLIENT); | |
3484 if(box) | |
3485 { | |
3486 thisbox = WinQueryWindowPtr(box, QWP_USER); | |
3487 hsize = TRUE; | |
3488 vsize = TRUE; | |
3489 } | |
3490 } | |
3491 if(thisbox) | |
3492 { | |
3493 int z; | |
3494 Item *tmpitem, *thisitem = thisbox->items; | |
3495 char tmpbuf[100]; | |
3496 | |
3497 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); | |
3498 | |
3499 for(z=0;z<thisbox->count;z++) | |
3500 { | |
3501 tmpitem[z] = thisitem[z]; | |
3502 } | |
3503 | |
3504 WinQueryClassName(item, 99, tmpbuf); | |
3505 | |
3506 if(strncmp(tmpbuf, "#1", 2)==0) | |
3507 tmpitem[thisbox->count].type = TYPEBOX; | |
3508 else | |
3509 tmpitem[thisbox->count].type = TYPEITEM; | |
3510 | |
3511 tmpitem[thisbox->count].hwnd = item; | |
3512 tmpitem[thisbox->count].origwidth = tmpitem[thisbox->count].width = width; | |
3513 tmpitem[thisbox->count].origheight = tmpitem[thisbox->count].height = height; | |
3514 tmpitem[thisbox->count].pad = pad; | |
3515 if(hsize) | |
3516 tmpitem[thisbox->count].hsize = SIZEEXPAND; | |
3517 else | |
3518 tmpitem[thisbox->count].hsize = SIZESTATIC; | |
3519 | |
3520 if(vsize) | |
3521 tmpitem[thisbox->count].vsize = SIZEEXPAND; | |
3522 else | |
3523 tmpitem[thisbox->count].vsize = SIZESTATIC; | |
3524 | |
3525 thisbox->items = tmpitem; | |
3526 | |
3527 if(thisbox->count) | |
3528 free(thisitem); | |
3529 | |
3530 thisbox->count++; | |
3531 | |
3532 /* Don't set the ownership if it's an entryfield or combobox */ | |
3533 WinQueryClassName(item, 99, tmpbuf); | |
3534 if(strncmp(tmpbuf, "#6", 2)!=0 /*&& strncmp(tmpbuf, "#2", 2)!=0*/) | |
3535 { | |
3536 if((boxowner = WinQueryWindow(box, QW_OWNER)) != 0) | |
3537 WinSetOwner(item, boxowner); | |
3538 else | |
3539 WinSetOwner(item, box); | |
3540 } | |
3541 WinSetParent(item, box, FALSE); | |
3542 } | |
3543 } | |
3544 | |
3545 /* | |
3546 * Sets the size of a given window (widget). | |
3547 * Parameters: | |
3548 * handle: Window (widget) handle. | |
3549 * width: New width in pixels. | |
3550 * height: New height in pixels. | |
3551 */ | |
3552 void dw_window_set_usize(HWND handle, ULONG width, ULONG height) | |
3553 { | |
3554 WinSetWindowPos(handle, NULLHANDLE, 0, 0, width, height, SWP_SHOW | SWP_SIZE); | |
3555 } | |
3556 | |
3557 /* | |
3558 * Returns the width of the screen. | |
3559 */ | |
3560 int dw_screen_width(void) | |
3561 { | |
3562 return WinQuerySysValue(HWND_DESKTOP,SV_CXSCREEN); | |
3563 } | |
3564 | |
3565 /* | |
3566 * Returns the height of the screen. | |
3567 */ | |
3568 int dw_screen_height(void) | |
3569 { | |
3570 return WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN); | |
3571 } | |
3572 | |
3573 /* This should return the current color depth */ | |
3574 unsigned long dw_color_depth(void) | |
3575 { | |
3576 HDC hdc = WinOpenWindowDC(HWND_DESKTOP); | |
3577 long colors; | |
3578 | |
3579 DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, &colors); | |
3580 DevCloseDC(hdc); | |
3581 return colors; | |
3582 } | |
3583 | |
3584 | |
3585 /* | |
3586 * Sets the position of a given window (widget). | |
3587 * Parameters: | |
3588 * handle: Window (widget) handle. | |
3589 * x: X location from the bottom left. | |
3590 * y: Y location from the bottom left. | |
3591 */ | |
3592 void dw_window_set_pos(HWND handle, ULONG x, ULONG y) | |
3593 { | |
3594 int myy = _get_frame_height(handle) - (y + _get_height(handle)); | |
3595 | |
3596 WinSetWindowPos(handle, NULLHANDLE, x, myy, 0, 0, SWP_MOVE); | |
3597 } | |
3598 | |
3599 /* | |
3600 * Sets the position and size of a given window (widget). | |
3601 * Parameters: | |
3602 * handle: Window (widget) handle. | |
3603 * x: X location from the bottom left. | |
3604 * y: Y location from the bottom left. | |
3605 * width: Width of the widget. | |
3606 * height: Height of the widget. | |
3607 */ | |
3608 void dw_window_set_pos_size(HWND handle, ULONG x, ULONG y, ULONG width, ULONG height) | |
3609 { | |
3610 int myy = _get_frame_height(handle) - (y + height); | |
3611 | |
3612 WinSetWindowPos(handle, NULLHANDLE, x, myy, width, height, SWP_MOVE | SWP_SIZE | SWP_SHOW); | |
3613 } | |
3614 | |
3615 /* | |
3616 * Gets the position and size of a given window (widget). | |
3617 * Parameters: | |
3618 * handle: Window (widget) handle. | |
3619 * x: X location from the bottom left. | |
3620 * y: Y location from the bottom left. | |
3621 * width: Width of the widget. | |
3622 * height: Height of the widget. | |
3623 */ | |
3624 void dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height) | |
3625 { | |
3626 SWP swp; | |
3627 WinQueryWindowPos(handle, &swp); | |
3628 if(x) | |
3629 *x = swp.x; | |
3630 if(y) | |
3631 *y = _get_frame_height(handle) - (swp.y + swp.cy); | |
3632 if(width) | |
3633 *width = swp.cx; | |
3634 if(height) | |
3635 *height = swp.cy; | |
3636 } | |
3637 | |
3638 /* | |
3639 * Sets the style of a given window (widget). | |
3640 * Parameters: | |
3641 * handle: Window (widget) handle. | |
3642 * width: New width in pixels. | |
3643 * height: New height in pixels. | |
3644 */ | |
3645 void dw_window_set_style(HWND handle, ULONG style, ULONG mask) | |
3646 { | |
3647 WinSetWindowBits(handle, QWL_STYLE, style, mask); | |
3648 } | |
3649 | |
3650 /* | |
3651 * Adds a new page to specified notebook. | |
3652 * Parameters: | |
3653 * handle: Window (widget) handle. | |
3654 * flags: Any additional page creation flags. | |
3655 * front: If TRUE page is added at the beginning. | |
3656 */ | |
3657 ULONG dw_notebook_page_new(HWND handle, ULONG flags, int front) | |
3658 { | |
3659 if(front) | |
3660 return (ULONG)WinSendMsg(handle, BKM_INSERTPAGE, 0L, | |
3661 MPFROM2SHORT((BKA_STATUSTEXTON | BKA_AUTOPAGESIZE | BKA_MAJOR | flags), BKA_FIRST)); | |
3662 return (ULONG)WinSendMsg(handle, BKM_INSERTPAGE, 0L, | |
3663 MPFROM2SHORT((BKA_STATUSTEXTON | BKA_AUTOPAGESIZE | BKA_MAJOR | flags), BKA_LAST)); | |
3664 } | |
3665 | |
3666 /* | |
3667 * Remove a page from a notebook. | |
3668 * Parameters: | |
3669 * handle: Handle to the notebook widget. | |
3670 * pageid: ID of the page to be destroyed. | |
3671 */ | |
3672 void dw_notebook_page_destroy(HWND handle, unsigned int pageid) | |
3673 { | |
3674 WinSendMsg(handle, BKM_DELETEPAGE, | |
3675 MPFROMLONG(pageid), (MPARAM)BKA_SINGLE); | |
3676 } | |
3677 | |
3678 /* | |
3679 * Queries the currently visible page ID. | |
3680 * Parameters: | |
3681 * handle: Handle to the notebook widget. | |
3682 */ | |
3683 unsigned int dw_notebook_page_query(HWND handle) | |
3684 { | |
3685 return (int)WinSendMsg(handle, BKM_QUERYPAGEID,0L, MPFROM2SHORT(BKA_TOP, BKA_MAJOR)); | |
3686 } | |
3687 | |
3688 /* | |
3689 * Sets the currently visibale page ID. | |
3690 * Parameters: | |
3691 * handle: Handle to the notebook widget. | |
3692 * pageid: ID of the page to be made visible. | |
3693 */ | |
3694 void dw_notebook_page_set(HWND handle, unsigned int pageid) | |
3695 { | |
3696 WinSendMsg(handle, BKM_TURNTOPAGE, MPFROMLONG(pageid), 0L); | |
3697 } | |
3698 | |
3699 /* | |
3700 * Sets the text on the specified notebook tab. | |
3701 * Parameters: | |
3702 * handle: Notebook handle. | |
3703 * pageid: Page ID of the tab to set. | |
3704 * text: Pointer to the text to set. | |
3705 */ | |
3706 void dw_notebook_page_set_text(HWND handle, ULONG pageid, char *text) | |
3707 { | |
3708 WinSendMsg(handle, BKM_SETTABTEXT, | |
3709 MPFROMLONG(pageid), MPFROMP(text)); | |
3710 } | |
3711 | |
3712 /* | |
3713 * Sets the text on the specified notebook tab status area. | |
3714 * Parameters: | |
3715 * handle: Notebook handle. | |
3716 * pageid: Page ID of the tab to set. | |
3717 * text: Pointer to the text to set. | |
3718 */ | |
3719 void dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text) | |
3720 { | |
3721 WinSendMsg(handle, BKM_SETSTATUSLINETEXT, | |
3722 MPFROMLONG(pageid), MPFROMP(text)); | |
3723 } | |
3724 | |
3725 /* | |
3726 * Packs the specified box into the notebook page. | |
3727 * Parameters: | |
3728 * handle: Handle to the notebook to be packed. | |
3729 * pageid: Page ID in the notebook which is being packed. | |
3730 * page: Box handle to be packed. | |
3731 */ | |
3732 void dw_notebook_pack(HWND handle, ULONG pageid, HWND page) | |
3733 { | |
3734 HWND tmpbox = dw_box_new(BOXVERT, 0); | |
3735 | |
3736 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0); | |
3737 WinSubclassWindow(tmpbox, _wndproc); | |
3738 WinSendMsg(handle, BKM_SETPAGEWINDOWHWND, | |
3739 MPFROMLONG(pageid), MPFROMHWND(tmpbox)); | |
3740 } | |
3741 | |
3742 /* | |
3743 * Appends the specified text to the listbox's (or combobox) entry list. | |
3744 * Parameters: | |
3745 * handle: Handle to the listbox to be appended to. | |
3746 * text: Text to append into listbox. | |
3747 */ | |
3748 void dw_listbox_append(HWND handle, char *text) | |
3749 { | |
3750 WinSendMsg(handle, | |
3751 LM_INSERTITEM, | |
3752 MPFROMSHORT(LIT_END), | |
3753 MPFROMP(text)); | |
3754 } | |
3755 | |
3756 /* | |
3757 * Clears the listbox's (or combobox) list of all entries. | |
3758 * Parameters: | |
3759 * handle: Handle to the listbox to be cleared. | |
3760 */ | |
3761 void dw_listbox_clear(HWND handle) | |
3762 { | |
3763 WinSendMsg(handle, | |
3764 LM_DELETEALL, 0L, 0L); | |
3765 } | |
3766 | |
3767 /* | |
3768 * Returns the listbox's item count. | |
3769 * Parameters: | |
3770 * handle: Handle to the listbox to be cleared. | |
3771 */ | |
3772 int dw_listbox_count(HWND handle) | |
3773 { | |
3774 return (int)WinSendMsg(handle, | |
3775 LM_QUERYITEMCOUNT,0L, 0L); | |
3776 } | |
3777 | |
3778 /* | |
3779 * Sets the topmost item in the viewport. | |
3780 * Parameters: | |
3781 * handle: Handle to the listbox to be cleared. | |
3782 * top: Index to the top item. | |
3783 */ | |
3784 void dw_listbox_set_top(HWND handle, int top) | |
3785 { | |
3786 WinSendMsg(handle, | |
3787 LM_SETTOPINDEX, | |
3788 MPFROMSHORT(top), | |
3789 0L); | |
3790 } | |
3791 | |
3792 /* | |
3793 * Copies the given index item's text into buffer. | |
3794 * Parameters: | |
3795 * handle: Handle to the listbox to be queried. | |
3796 * index: Index into the list to be queried. | |
3797 * buffer: Buffer where text will be copied. | |
3798 * length: Length of the buffer (including NULL). | |
3799 */ | |
3800 void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length) | |
3801 { | |
3802 WinSendMsg(handle, LM_QUERYITEMTEXT, MPFROM2SHORT(index, length), (MPARAM)buffer); | |
3803 } | |
3804 | |
3805 /* | |
3806 * Sets the text of a given listbox entry. | |
3807 * Parameters: | |
3808 * handle: Handle to the listbox to be queried. | |
3809 * index: Index into the list to be queried. | |
3810 * buffer: Buffer where text will be copied. | |
3811 */ | |
3812 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) | |
3813 { | |
3814 WinSendMsg(handle, LM_SETITEMTEXT, MPFROMSHORT(index), (MPARAM)buffer); | |
3815 } | |
3816 | |
3817 /* | |
3818 * Returns the index to the item in the list currently selected. | |
3819 * Parameters: | |
3820 * handle: Handle to the listbox to be queried. | |
3821 */ | |
3822 unsigned int dw_listbox_selected(HWND handle) | |
3823 { | |
3824 return (unsigned int)WinSendMsg(handle, | |
18
f1002d51d959
Fixed a container problem on OS/2 with separator set to 0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
16
diff
changeset
|
3825 LM_QUERYSELECTION, |
f1002d51d959
Fixed a container problem on OS/2 with separator set to 0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
16
diff
changeset
|
3826 MPFROMSHORT(LIT_CURSOR), |
f1002d51d959
Fixed a container problem on OS/2 with separator set to 0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
16
diff
changeset
|
3827 0); |
3 | 3828 } |
3829 | |
3830 /* | |
3831 * Returns the index to the current selected item or -1 when done. | |
3832 * Parameters: | |
3833 * handle: Handle to the listbox to be queried. | |
3834 * where: Either the previous return or -1 to restart. | |
3835 */ | |
3836 int dw_listbox_selected_multi(HWND handle, int where) | |
3837 { | |
3838 int place = where; | |
3839 | |
3840 if(where == -1) | |
3841 place = LIT_FIRST; | |
3842 | |
3843 place = (int)WinSendMsg(handle, | |
3844 LM_QUERYSELECTION, | |
3845 MPFROMSHORT(place),0L); | |
3846 if(place == LIT_NONE) | |
3847 return -1; | |
3848 return place; | |
3849 } | |
3850 | |
3851 /* | |
3852 * Sets the selection state of a given index. | |
3853 * Parameters: | |
3854 * handle: Handle to the listbox to be set. | |
3855 * index: Item index. | |
3856 * state: TRUE if selected FALSE if unselected. | |
3857 */ | |
3858 void dw_listbox_select(HWND handle, int index, int state) | |
3859 { | |
3860 WinSendMsg(handle, LM_SELECTITEM, MPFROMSHORT(index), (MPARAM)state); | |
3861 _run_event(handle, WM_CONTROL, MPFROM2SHORT(0, LN_SELECT), (MPARAM)handle); | |
3862 } | |
3863 | |
3864 /* | |
3865 * Deletes the item with given index from the list. | |
3866 * Parameters: | |
3867 * handle: Handle to the listbox to be set. | |
3868 * index: Item index. | |
3869 */ | |
3870 void dw_listbox_delete(HWND handle, int index) | |
3871 { | |
3872 WinSendMsg(handle, LM_DELETEITEM, MPFROMSHORT(index), 0); | |
3873 } | |
3874 | |
3875 /* | |
3876 * Adds text to an MLE box and returns the current point. | |
3877 * Parameters: | |
3878 * handle: Handle to the MLE to be queried. | |
3879 * buffer: Text buffer to be imported. | |
3880 * startpoint: Point to start entering text. | |
3881 */ | |
3882 unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint) | |
3883 { | |
3884 unsigned long point = startpoint; | |
3885 PBYTE mlebuf; | |
3886 | |
3887 /* Work around 64K limit */ | |
3888 if(!DosAllocMem((PPVOID) &mlebuf, 65536, PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_TILE)) | |
3889 { | |
3890 int amount, len = strlen(buffer), written = 0; | |
3891 | |
3892 while(written < len) | |
3893 { | |
3894 if((len - written) > 65535) | |
3895 amount = 65535; | |
3896 else | |
3897 amount = len - written; | |
3898 | |
3899 memcpy(mlebuf, &buffer[written], amount); | |
3900 mlebuf[amount] = '\0'; | |
3901 | |
3902 WinSendMsg(handle, MLM_SETIMPORTEXPORT, MPFROMP(mlebuf), MPFROMLONG(amount+1)); | |
3903 WinSendMsg(handle, MLM_IMPORT, MPFROMP(&point), MPFROMLONG(amount + 1)); | |
3904 dw_mle_delete(handle, point, 1); | |
3905 | |
3906 written += amount; | |
3907 } | |
3908 DosFreeMem(mlebuf); | |
3909 } | |
3910 return point - 1; | |
3911 } | |
3912 | |
3913 /* | |
3914 * Grabs text from an MLE box. | |
3915 * Parameters: | |
3916 * handle: Handle to the MLE to be queried. | |
3917 * buffer: Text buffer to be exported. | |
3918 * startpoint: Point to start grabbing text. | |
3919 * length: Amount of text to be grabbed. | |
3920 */ | |
3921 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length) | |
3922 { | |
3923 PBYTE mlebuf; | |
3924 | |
3925 /* Work around 64K limit */ | |
3926 if(!DosAllocMem((PPVOID) &mlebuf, 65535, PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_TILE)) | |
3927 { | |
3928 int amount, copied, written = 0; | |
3929 | |
3930 while(written < length) | |
3931 { | |
3932 if((length - written) > 65535) | |
3933 amount = 65535; | |
3934 else | |
3935 amount = length - written; | |
3936 | |
3937 WinSendMsg(handle, MLM_SETIMPORTEXPORT, MPFROMP(mlebuf), MPFROMLONG(amount)); | |
3938 copied = (int)WinSendMsg(handle, MLM_EXPORT, MPFROMP(&startpoint), MPFROMLONG(&amount)); | |
3939 | |
3940 if(copied) | |
3941 { | |
3942 memcpy(&buffer[written], mlebuf, copied); | |
3943 | |
3944 written += copied; | |
3945 } | |
3946 else | |
3947 break; | |
3948 } | |
3949 DosFreeMem(mlebuf); | |
3950 } | |
3951 } | |
3952 | |
3953 /* | |
3954 * Obtains information about an MLE box. | |
3955 * Parameters: | |
3956 * handle: Handle to the MLE to be queried. | |
3957 * bytes: A pointer to a variable to return the total bytes. | |
3958 * lines: A pointer to a variable to return the number of lines. | |
3959 */ | |
3960 void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines) | |
3961 { | |
3962 if(bytes) | |
3963 *bytes = (unsigned long)WinSendMsg(handle, MLM_QUERYTEXTLENGTH, 0, 0); | |
3964 if(lines) | |
3965 *lines = (unsigned long)WinSendMsg(handle, MLM_QUERYLINECOUNT, 0, 0); | |
3966 } | |
3967 | |
3968 /* | |
3969 * Deletes text from an MLE box. | |
3970 * Parameters: | |
3971 * handle: Handle to the MLE to be deleted from. | |
3972 * startpoint: Point to start deleting text. | |
3973 * length: Amount of text to be deleted. | |
3974 */ | |
3975 void dw_mle_delete(HWND handle, int startpoint, int length) | |
3976 { | |
3977 char *buf = malloc(length+1); | |
3978 int z, dellen = length; | |
3979 | |
3980 dw_mle_export(handle, buf, startpoint, length); | |
3981 | |
3982 for(z=0;z<length-1;z++) | |
3983 { | |
3984 if(strncmp(&buf[z], "\r\n", 2) == 0) | |
3985 dellen--; | |
3986 } | |
3987 WinSendMsg(handle, MLM_DELETE, MPFROMLONG(startpoint), MPFROMLONG(dellen)); | |
3988 free(buf); | |
3989 } | |
3990 | |
3991 /* | |
3992 * Clears all text from an MLE box. | |
3993 * Parameters: | |
3994 * handle: Handle to the MLE to be cleared. | |
3995 */ | |
3996 void dw_mle_clear(HWND handle) | |
3997 { | |
3998 unsigned long bytes; | |
3999 | |
4000 dw_mle_query(handle, &bytes, NULL); | |
4001 | |
4002 WinSendMsg(handle, MLM_DELETE, MPFROMLONG(0), MPFROMLONG(bytes)); | |
4003 } | |
4004 | |
4005 /* | |
4006 * Sets the visible line of an MLE box. | |
4007 * Parameters: | |
4008 * handle: Handle to the MLE to be positioned. | |
4009 * line: Line to be visible. | |
4010 */ | |
4011 void dw_mle_set_visible(HWND handle, int line) | |
4012 { | |
4013 int tmppnt; | |
4014 | |
4015 if(line > 10) | |
4016 { | |
4017 tmppnt = (int)WinSendMsg(handle, MLM_CHARFROMLINE, MPFROMLONG(line - 10), 0); | |
4018 WinSendMsg(handle, MLM_SETFIRSTCHAR, MPFROMLONG(tmppnt), 0); | |
4019 } | |
4020 } | |
4021 | |
4022 /* | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4023 * Sets the editablity of an MLE box. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4024 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4025 * handle: Handle to the MLE. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4026 * state: TRUE if it can be edited, FALSE for readonly. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4027 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4028 void dw_mle_set_editable(HWND handle, int state) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4029 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4030 WinSendMsg(handle, MLM_SETREADONLY, MPFROMLONG(state ? FALSE : TRUE), 0); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4031 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4032 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4033 /* |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4034 * Sets the word wrap state of an MLE box. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4035 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4036 * handle: Handle to the MLE. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4037 * state: TRUE if it wraps, FALSE if it doesn't. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4038 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4039 void dw_mle_set_word_wrap(HWND handle, int state) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4040 { |
16
ca7a8215487a
Removed structure packing option to fix a crash in dw_mle_search() when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
15
diff
changeset
|
4041 WinSendMsg(handle, MLM_SETWRAP, MPFROMLONG(state), 0); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4042 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4043 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
4044 /* |
3 | 4045 * Sets the current cursor position of an MLE box. |
4046 * Parameters: | |
4047 * handle: Handle to the MLE to be positioned. | |
4048 * point: Point to position cursor. | |
4049 */ | |
4050 void dw_mle_set(HWND handle, int point) | |
4051 { | |
4052 WinSendMsg(handle, MLM_SETSEL, MPFROMLONG(point), MPFROMLONG(point)); | |
4053 } | |
4054 | |
4055 /* | |
4056 * Finds text in an MLE box. | |
4057 * Parameters: | |
4058 * handle: Handle to the MLE to be cleared. | |
4059 * text: Text to search for. | |
4060 * point: Start point of search. | |
4061 * flags: Search specific flags. | |
4062 */ | |
4063 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags) | |
4064 { | |
4065 MLE_SEARCHDATA msd; | |
4066 | |
16
ca7a8215487a
Removed structure packing option to fix a crash in dw_mle_search() when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
15
diff
changeset
|
4067 /* This code breaks with structure packing set to 1 (/Sp1 in VAC) |
ca7a8215487a
Removed structure packing option to fix a crash in dw_mle_search() when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
15
diff
changeset
|
4068 * if this is needed we need to add a pragma here. |
ca7a8215487a
Removed structure packing option to fix a crash in dw_mle_search() when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
15
diff
changeset
|
4069 */ |
3 | 4070 msd.cb = sizeof(msd); |
4071 msd.pchFind = text; | |
4072 msd.pchReplace = NULL; | |
4073 msd.cchFind = strlen(text); | |
4074 msd.cchReplace = 0; | |
4075 msd.iptStart = point; | |
4076 msd.iptStop = -1; | |
4077 | |
4078 if(WinSendMsg(handle, MLM_SEARCH, MPFROMLONG(MLFSEARCH_SELECTMATCH | flags), (MPARAM)&msd)) | |
4079 return (int)WinSendMsg(handle, MLM_QUERYSEL,(MPARAM)MLFQS_MAXSEL, 0); | |
4080 return 0; | |
4081 } | |
4082 | |
4083 /* | |
4084 * Stops redrawing of an MLE box. | |
4085 * Parameters: | |
4086 * handle: Handle to the MLE to freeze. | |
4087 */ | |
4088 void dw_mle_freeze(HWND handle) | |
4089 { | |
4090 WinSendMsg(handle, MLM_DISABLEREFRESH, 0, 0); | |
4091 } | |
4092 | |
4093 /* | |
4094 * Resumes redrawing of an MLE box. | |
4095 * Parameters: | |
4096 * handle: Handle to the MLE to thaw. | |
4097 */ | |
4098 void dw_mle_thaw(HWND handle) | |
4099 { | |
4100 WinSendMsg(handle, MLM_ENABLEREFRESH, 0, 0); | |
4101 } | |
4102 | |
4103 /* | |
4104 * Returns the range of the slider. | |
4105 * Parameters: | |
4106 * handle: Handle to the slider to be queried. | |
4107 */ | |
4108 unsigned int dw_slider_query_range(HWND handle) | |
4109 { | |
4110 return SHORT2FROMMP(WinSendMsg(handle, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), 0)); | |
4111 } | |
4112 | |
4113 /* | |
4114 * Sets the slider position. | |
4115 * Parameters: | |
4116 * handle: Handle to the slider to be set. | |
4117 * position: Position of the slider withing the range. | |
4118 */ | |
4119 void dw_slider_set_pos(HWND handle, unsigned int position) | |
4120 { | |
4121 WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)position); | |
4122 } | |
4123 | |
4124 /* | |
4125 * Sets the spinbutton value. | |
4126 * Parameters: | |
4127 * handle: Handle to the spinbutton to be set. | |
4128 * position: Current value of the spinbutton. | |
4129 */ | |
4130 void dw_spinbutton_set_pos(HWND handle, long position) | |
4131 { | |
4132 WinSendMsg(handle, SPBM_SETCURRENTVALUE, MPFROMLONG((long)position), 0L); | |
4133 } | |
4134 | |
4135 /* | |
4136 * Sets the spinbutton limits. | |
4137 * Parameters: | |
4138 * handle: Handle to the spinbutton to be set. | |
4139 * upper: Upper limit. | |
4140 * lower: Lower limit. | |
4141 */ | |
4142 void dw_spinbutton_set_limits(HWND handle, long upper, long lower) | |
4143 { | |
4144 WinSendMsg(handle, SPBM_SETLIMITS, MPFROMLONG(upper), MPFROMLONG(lower)); | |
4145 } | |
4146 | |
4147 /* | |
4148 * Sets the entryfield character limit. | |
4149 * Parameters: | |
4150 * handle: Handle to the spinbutton to be set. | |
4151 * limit: Number of characters the entryfield will take. | |
4152 */ | |
4153 void dw_entryfield_set_limit(HWND handle, ULONG limit) | |
4154 { | |
4155 WinSendMsg(handle, EM_SETTEXTLIMIT, (MPARAM)limit, (MPARAM)0); | |
4156 } | |
4157 | |
4158 | |
4159 /* | |
4160 * Returns the current value of the spinbutton. | |
4161 * Parameters: | |
4162 * handle: Handle to the spinbutton to be queried. | |
4163 */ | |
4164 long dw_spinbutton_query(HWND handle) | |
4165 { | |
4166 long tmpval = 0L; | |
4167 | |
4168 WinSendMsg(handle, SPBM_QUERYVALUE, (MPARAM)&tmpval,0L); | |
4169 return tmpval; | |
4170 } | |
4171 | |
4172 /* | |
4173 * Returns the state of the checkbox. | |
4174 * Parameters: | |
4175 * handle: Handle to the checkbox to be queried. | |
4176 */ | |
4177 int dw_checkbox_query(HWND handle) | |
4178 { | |
4179 return (int)WinSendMsg(handle,BM_QUERYCHECK,0,0); | |
4180 } | |
4181 | |
4182 /* | |
4183 * Sets the state of the checkbox. | |
4184 * Parameters: | |
4185 * handle: Handle to the checkbox to be queried. | |
4186 * value: TRUE for checked, FALSE for unchecked. | |
4187 */ | |
4188 void dw_checkbox_set(HWND handle, int value) | |
4189 { | |
4190 WinSendMsg(handle,BM_SETCHECK,MPFROMSHORT(value),0); | |
4191 } | |
4192 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4193 typedef struct _CNRITEM |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4194 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4195 MINIRECORDCORE rc; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4196 HPOINTER hptrIcon; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4197 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4198 } CNRITEM, *PCNRITEM; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4199 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4200 /* |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4201 * Inserts an item into a tree window (widget). |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4202 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4203 * handle: Handle to the tree to be inserted. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4204 * title: The text title of the entry. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4205 * icon: Handle to coresponding icon. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4206 * parent: Parent handle or 0 if root. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4207 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4208 HWND dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND parent) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4209 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4210 ULONG cbExtra; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4211 PCNRITEM pci; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4212 RECORDINSERT ri; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4213 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4214 /* Calculate extra bytes needed for each record besides that needed for the |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4215 * MINIRECORDCORE structure |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4216 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4217 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4218 cbExtra = sizeof(CNRITEM) - sizeof(MINIRECORDCORE); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4219 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4220 /* Allocate memory for the parent record */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4221 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4222 pci = WinSendMsg(handle, CM_ALLOCRECORD, MPFROMLONG(cbExtra), MPFROMSHORT(1)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4223 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4224 /* Fill in the parent record data */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4225 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4226 pci->rc.cb = sizeof(MINIRECORDCORE); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4227 pci->rc.pszIcon = title; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4228 pci->rc.hptrIcon = icon; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4229 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4230 pci->hptrIcon = icon; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4231 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4232 memset(&ri, 0, sizeof(RECORDINSERT)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4233 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4234 ri.cb = sizeof(RECORDINSERT); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4235 ri.pRecordOrder = (PRECORDCORE)CMA_END; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4236 ri.pRecordParent = (PRECORDCORE)NULL; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4237 ri.zOrder = (USHORT)CMA_TOP; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4238 ri.cRecordsInsert = 1; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4239 ri.fInvalidateRecord = TRUE; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4240 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4241 /* We are about to insert the child records. Set the parent record to be |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4242 * the one we just inserted. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4243 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4244 ri.pRecordParent = (PRECORDCORE)parent; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4245 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4246 /* Insert the record */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4247 WinSendMsg(handle, CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4248 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4249 return (HWND)pci; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4250 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4251 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4252 /* Some OS/2 specific container structs */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4253 typedef struct _containerinfo { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4254 int count; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4255 void *data; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4256 HWND handle; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4257 } ContainerInfo; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4258 |
3 | 4259 /* |
4260 * Sets up the container columns. | |
4261 * Parameters: | |
4262 * handle: Handle to the container to be configured. | |
4263 * flags: An array of unsigned longs with column flags. | |
4264 * titles: An array of strings with column text titles. | |
4265 * count: The number of columns (this should match the arrays). | |
4266 * separator: The column number that contains the main separator. | |
4267 * (this item may only be used in OS/2) | |
4268 */ | |
4269 int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) | |
4270 { | |
4271 PFIELDINFO details, first, left = NULL; | |
4272 FIELDINFOINSERT detin; | |
4273 CNRINFO cnri; | |
4274 int z; | |
4275 ULONG size = sizeof(RECORDCORE); | |
4276 ULONG *offStruct = malloc(count * sizeof(ULONG)); | |
4277 ULONG *tempflags = malloc((count+1) * sizeof(ULONG)); | |
4278 ULONG *oldflags = (ULONG *)WinQueryWindowPtr(handle, 0); | |
4279 | |
4280 if(!offStruct || !tempflags) | |
4281 return FALSE; | |
4282 | |
4283 memcpy(tempflags, flags, count * sizeof(ULONG)); | |
4284 tempflags[count] = 0; | |
4285 | |
4286 WinSetWindowPtr(handle, 0, tempflags); | |
4287 | |
4288 if(oldflags) | |
4289 free(oldflags); | |
4290 | |
4291 while((first = (PFIELDINFO)WinSendMsg(handle, CM_QUERYDETAILFIELDINFO, 0, MPFROMSHORT(CMA_FIRST))) != NULL) | |
4292 { | |
4293 WinSendMsg(handle, CM_REMOVEDETAILFIELDINFO, (MPARAM)&first, MPFROM2SHORT(1, CMA_FREE)); | |
4294 } | |
4295 | |
4296 /* Figure out the offsets to the items in the struct */ | |
4297 for(z=0;z<count;z++) | |
4298 { | |
4299 offStruct[z] = size; | |
4300 if(flags[z] & DW_CFA_BITMAPORICON) | |
4301 size += sizeof(HPOINTER); | |
4302 else if(flags[z] & DW_CFA_STRING) | |
4303 size += sizeof(char *); | |
4304 else if(flags[z] & DW_CFA_ULONG) | |
4305 size += sizeof(ULONG); | |
4306 else if(flags[z] & DW_CFA_DATE) | |
4307 size += sizeof(CDATE); | |
4308 else if(flags[z] & DW_CFA_TIME) | |
4309 size += sizeof(CTIME); | |
4310 } | |
4311 | |
4312 first = details = (PFIELDINFO)WinSendMsg(handle, CM_ALLOCDETAILFIELDINFO, MPFROMLONG(count), 0L); | |
4313 | |
4314 if(!first) | |
4315 { | |
4316 free(offStruct); | |
4317 return FALSE; | |
4318 } | |
4319 | |
4320 for(z=0;z<count;z++) | |
4321 { | |
4322 if(z==separator-1) | |
4323 left=details; | |
4324 details->cb = sizeof(FIELDINFO); | |
4325 details->flData = flags[z]; | |
4326 details->flTitle = CFA_FITITLEREADONLY; | |
4327 details->pTitleData = titles[z]; | |
4328 details->offStruct = offStruct[z]; | |
4329 details = details->pNextFieldInfo; | |
4330 } | |
4331 | |
4332 detin.cb = sizeof(FIELDINFOINSERT); | |
4333 detin.fInvalidateFieldInfo = FALSE; | |
4334 detin.pFieldInfoOrder = (PFIELDINFO) CMA_FIRST; | |
4335 detin.cFieldInfoInsert = (ULONG)count; | |
4336 | |
4337 WinSendMsg(handle, CM_INSERTDETAILFIELDINFO, MPFROMP(first), MPFROMP(&detin)); | |
4338 | |
18
f1002d51d959
Fixed a container problem on OS/2 with separator set to 0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
16
diff
changeset
|
4339 if(count > separator && separator > 0) |
3 | 4340 { |
4341 cnri.cb = sizeof(CNRINFO); | |
4342 cnri.pFieldInfoLast = left; | |
4343 cnri.xVertSplitbar = 150; | |
4344 | |
4345 WinSendMsg(handle, CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_PFIELDINFOLAST | CMA_XVERTSPLITBAR)); | |
4346 } | |
4347 | |
4348 free(offStruct); | |
4349 return TRUE; | |
4350 } | |
4351 | |
4352 /* | |
4353 * Sets up the filesystem columns, note: filesystem always has an icon/filename field. | |
4354 * Parameters: | |
4355 * handle: Handle to the container to be configured. | |
4356 * flags: An array of unsigned longs with column flags. | |
4357 * titles: An array of strings with column text titles. | |
4358 * count: The number of columns (this should match the arrays). | |
4359 */ | |
4360 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) | |
4361 { | |
4362 char **newtitles = malloc(sizeof(char *) * (count + 2)); | |
4363 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); | |
4364 | |
4365 newtitles[0] = "Icon"; | |
4366 newtitles[1] = "Filename"; | |
4367 | |
4368 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR; | |
4369 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; | |
4370 | |
4371 memcpy(&newtitles[2], titles, sizeof(char *) * count); | |
4372 memcpy(&newflags[2], flags, sizeof(unsigned long) * count); | |
4373 | |
4374 dw_container_setup(handle, newflags, newtitles, count + 2, 2); | |
4375 | |
4376 free(newtitles); | |
4377 free(newflags); | |
4378 return TRUE; | |
4379 } | |
4380 | |
4381 /* | |
4382 * Obtains an icon from a module (or header in GTK). | |
4383 * Parameters: | |
4384 * module: Handle to module (DLL) in OS/2 and Windows. | |
4385 * id: A unsigned long id int the resources on OS/2 and | |
4386 * Windows, on GTK this is converted to a pointer | |
4387 * to an embedded XPM. | |
4388 */ | |
4389 unsigned long dw_icon_load(unsigned long module, unsigned long id) | |
4390 { | |
4391 return WinLoadPointer(HWND_DESKTOP,module,id); | |
4392 } | |
4393 | |
4394 /* | |
4395 * Frees a loaded resource in OS/2 and Windows. | |
4396 * Parameters: | |
4397 * handle: Handle to icon returned by dw_icon_load(). | |
4398 */ | |
4399 void dw_icon_free(unsigned long handle) | |
4400 { | |
4401 WinDestroyPointer(handle); | |
4402 } | |
4403 | |
4404 /* | |
4405 * Allocates memory used to populate a container. | |
4406 * Parameters: | |
4407 * handle: Handle to the container window (widget). | |
4408 * rowcount: The number of items to be populated. | |
4409 */ | |
4410 void *dw_container_alloc(HWND handle, int rowcount) | |
4411 { | |
4412 ULONG *flags = (ULONG *)WinQueryWindowPtr(handle, 0); | |
4413 int z, size = 0, totalsize, count = 0; | |
4414 PRECORDCORE temp; | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4415 ContainerInfo *ci; |
3 | 4416 void *blah; |
4417 | |
4418 if(!flags) | |
4419 return NULL; | |
4420 | |
4421 while(flags[count]) | |
4422 count++; | |
4423 | |
4424 /* Figure out the offsets to the items in the struct */ | |
4425 for(z=0;z<count;z++) | |
4426 { | |
4427 if(flags[z] & DW_CFA_BITMAPORICON) | |
4428 size += sizeof(HPOINTER); | |
4429 else if(flags[z] & DW_CFA_STRING) | |
4430 size += sizeof(char *); | |
4431 else if(flags[z] & DW_CFA_ULONG) | |
4432 size += sizeof(ULONG); | |
4433 else if(flags[z] & DW_CFA_DATE) | |
4434 size += sizeof(CDATE); | |
4435 else if(flags[z] & DW_CFA_TIME) | |
4436 size += sizeof(CTIME); | |
4437 } | |
4438 | |
4439 totalsize = size + sizeof(RECORDCORE); | |
4440 | |
4441 blah = (void *)WinSendMsg(handle, CM_ALLOCRECORD, MPFROMLONG(size), MPFROMLONG(rowcount)); | |
4442 | |
4443 if(!blah) | |
4444 return NULL; | |
4445 | |
4446 temp = (PRECORDCORE)blah; | |
4447 | |
4448 for(z=0;z<rowcount;z++) | |
4449 { | |
4450 temp->cb = totalsize; | |
4451 temp = temp->preccNextRecord; | |
4452 } | |
4453 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4454 ci = malloc(sizeof(struct _containerinfo)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4455 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4456 ci->count = rowcount; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4457 ci->data = blah; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4458 ci->handle = handle; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4459 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4460 return (void *)ci; |
3 | 4461 } |
4462 | |
4463 /* | |
4464 * Sets an item in specified row and column to the given data. | |
4465 * Parameters: | |
4466 * handle: Handle to the container window (widget). | |
4467 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4468 * column: Zero based column of data being set. | |
4469 * row: Zero based row of data being set. | |
4470 * data: Pointer to the data to be added. | |
4471 */ | |
4472 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
4473 { | |
4474 ULONG totalsize, size = 0, *flags = (ULONG *)WinQueryWindowPtr(handle, 0); | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4475 int z, currentcount; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4476 ContainerInfo *ci = (ContainerInfo *)pointer; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4477 PRECORDCORE temp; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4478 CNRINFO cnr; |
3 | 4479 void *dest; |
4480 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4481 if(!ci) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4482 return; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4483 |
3 | 4484 if(!flags) |
4485 return; | |
4486 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4487 temp = (PRECORDCORE)ci->data; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4488 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4489 WinSendMsg(handle, CM_QUERYCNRINFO, (MPARAM)&cnr, MPFROMSHORT(sizeof(CNRINFO))); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4490 currentcount = cnr.cRecords; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4491 |
3 | 4492 /* Figure out the offsets to the items in the struct */ |
4493 for(z=0;z<column;z++) | |
4494 { | |
4495 if(flags[z] & DW_CFA_BITMAPORICON) | |
4496 size += sizeof(HPOINTER); | |
4497 else if(flags[z] & DW_CFA_STRING) | |
4498 size += sizeof(char *); | |
4499 else if(flags[z] & DW_CFA_ULONG) | |
4500 size += sizeof(ULONG); | |
4501 else if(flags[z] & DW_CFA_DATE) | |
4502 size += sizeof(CDATE); | |
4503 else if(flags[z] & DW_CFA_TIME) | |
4504 size += sizeof(CTIME); | |
4505 } | |
4506 | |
4507 totalsize = size + sizeof(RECORDCORE); | |
4508 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4509 for(z=0;z<(row-currentcount);z++) |
3 | 4510 temp = temp->preccNextRecord; |
4511 | |
4512 dest = (void *)(((ULONG)temp)+((ULONG)totalsize)); | |
4513 | |
4514 if(flags[column] & DW_CFA_BITMAPORICON) | |
4515 memcpy(dest, data, sizeof(HPOINTER)); | |
4516 else if(flags[column] & DW_CFA_STRING) | |
4517 memcpy(dest, data, sizeof(char *)); | |
4518 else if(flags[column] & DW_CFA_ULONG) | |
4519 memcpy(dest, data, sizeof(ULONG)); | |
4520 else if(flags[column] & DW_CFA_DATE) | |
4521 memcpy(dest, data, sizeof(CDATE)); | |
4522 else if(flags[column] & DW_CFA_TIME) | |
4523 memcpy(dest, data, sizeof(CTIME)); | |
4524 } | |
4525 | |
4526 /* | |
4527 * Sets an item in specified row and column to the given data. | |
4528 * Parameters: | |
4529 * handle: Handle to the container window (widget). | |
4530 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4531 * column: Zero based column of data being set. | |
4532 * row: Zero based row of data being set. | |
4533 * data: Pointer to the data to be added. | |
4534 */ | |
4535 void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) | |
4536 { | |
4537 dw_container_set_item(handle, pointer, 0, row, (void *)&icon); | |
4538 dw_container_set_item(handle, pointer, 1, row, (void *)&filename); | |
4539 } | |
4540 | |
4541 /* | |
4542 * Sets an item in specified row and column to the given data. | |
4543 * Parameters: | |
4544 * handle: Handle to the container window (widget). | |
4545 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4546 * column: Zero based column of data being set. | |
4547 * row: Zero based row of data being set. | |
4548 * data: Pointer to the data to be added. | |
4549 */ | |
4550 void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
4551 { | |
4552 dw_container_set_item(handle, pointer, column + 2, row, data); | |
4553 } | |
4554 | |
4555 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4556 * Sets the width of a column in the container. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4557 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4558 * handle: Handle to window (widget) of container. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4559 * column: Zero based column of width being set. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4560 * width: Width of column in pixels. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4561 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4562 void dw_container_set_column_width(HWND handle, int column, int width) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4563 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4564 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4565 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4566 /* |
3 | 4567 * Sets the title of a row in the container. |
4568 * Parameters: | |
4569 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4570 * row: Zero based row of data being set. | |
4571 * title: String title of the item. | |
4572 */ | |
4573 void dw_container_set_row_title(void *pointer, int row, char *title) | |
4574 { | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4575 ContainerInfo *ci = (ContainerInfo *)pointer; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4576 PRECORDCORE temp = (PRECORDCORE)ci->data; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4577 int z, currentcount; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4578 CNRINFO cnr; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4579 |
23
2932f9d2c7d5
New OS/2 code from FX changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4580 if(!ci) |
2932f9d2c7d5
New OS/2 code from FX changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4581 return; |
2932f9d2c7d5
New OS/2 code from FX changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4582 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4583 WinSendMsg(ci->handle, CM_QUERYCNRINFO, (MPARAM)&cnr, MPFROMSHORT(sizeof(CNRINFO))); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4584 currentcount = cnr.cRecords; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4585 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4586 for(z=0;z<(row-currentcount);z++) |
3 | 4587 temp = temp->preccNextRecord; |
4588 | |
4589 temp->pszIcon = title; | |
4590 temp->pszName = title; | |
4591 temp->pszText = title; | |
4592 } | |
4593 | |
4594 /* | |
4595 * Sets the title of a row in the container. | |
4596 * Parameters: | |
4597 * handle: Handle to the container window (widget). | |
4598 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4599 * rowcount: The number of rows to be inserted. | |
4600 */ | |
4601 void dw_container_insert(HWND handle, void *pointer, int rowcount) | |
4602 { | |
4603 RECORDINSERT recin; | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4604 ContainerInfo *ci = (ContainerInfo *)pointer; |
3 | 4605 |
23
2932f9d2c7d5
New OS/2 code from FX changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4606 if(!ci) |
2932f9d2c7d5
New OS/2 code from FX changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4607 return; |
2932f9d2c7d5
New OS/2 code from FX changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4608 |
3 | 4609 recin.cb = sizeof(RECORDINSERT); |
4610 recin.pRecordOrder = (PRECORDCORE)CMA_END; | |
4611 recin.pRecordParent = NULL; | |
4612 recin.zOrder = CMA_TOP; | |
4613 recin.fInvalidateRecord = TRUE; | |
4614 recin.cRecordsInsert = rowcount; | |
4615 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4616 WinSendMsg(handle, CM_INSERTRECORD, MPFROMP(ci->data), MPFROMP(&recin)); |
3 | 4617 } |
4618 | |
4619 /* | |
4620 * Removes all rows from a container. | |
4621 * Parameters: | |
4622 * handle: Handle to the window (widget) to be cleared. | |
4623 */ | |
4624 void dw_container_clear(HWND handle) | |
4625 { | |
4626 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)0L, MPFROM2SHORT(0, CMA_INVALIDATE | CMA_FREE)); | |
4627 } | |
4628 | |
4629 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4630 * Removes the first x rows from a container. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4631 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4632 * handle: Handle to the window (widget) to be deleted from. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4633 * rowcount: The number of rows to be deleted. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4634 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4635 void dw_container_delete(HWND handle, int rowcount) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4636 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4637 RECORDCORE *last, **prc = malloc(sizeof(RECORDCORE *) * rowcount); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4638 int current = 1; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4639 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4640 prc[0] = last = (RECORDCORE *)WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4641 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4642 while(last && current < rowcount) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4643 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4644 prc[current] = last = (RECORDCORE *)WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)last, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4645 current++; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4646 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4647 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)prc, MPFROM2SHORT(current, CMA_INVALIDATE | CMA_FREE)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4648 free(prc); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4649 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4650 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4651 /* |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4652 * Scrolls container up or down. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4653 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4654 * handle: Handle to the window (widget) to be scrolled. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4655 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4656 * DW_SCROLL_BOTTOM. (rows is ignored for last two) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4657 * rows: The number of rows to be scrolled. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4658 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4659 void dw_container_scroll(HWND handle, int direction, long rows) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4660 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4661 switch(direction) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4662 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4663 case DW_SCROLL_TOP: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4664 WinSendMsg(handle, CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL), MPFROMLONG(-10000000)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4665 break; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4666 case DW_SCROLL_BOTTOM: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4667 WinSendMsg(handle, CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL), MPFROMLONG(10000000)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4668 break; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4669 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4670 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4671 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
21
diff
changeset
|
4672 /* |
3 | 4673 * Removes all rows from a container. |
4674 * Parameters: | |
4675 * handle: Handle to the window (widget) to be cleared. | |
4676 */ | |
4677 void dw_container_set_view(HWND handle, unsigned long flags, int iconwidth, int iconheight) | |
4678 { | |
4679 CNRINFO cnrinfo; | |
4680 | |
4681 cnrinfo.flWindowAttr = flags; | |
4682 cnrinfo.slBitmapOrIcon.cx = iconwidth; | |
4683 cnrinfo.slBitmapOrIcon.cy = iconheight; | |
4684 | |
4685 WinSendMsg(handle, CM_SETCNRINFO, &cnrinfo, MPFROMLONG(CMA_FLWINDOWATTR | CMA_SLBITMAPORICON)); | |
4686 } | |
4687 | |
4688 /* | |
4689 * Starts a new query of a container. | |
4690 * Parameters: | |
4691 * handle: Handle to the window (widget) to be queried. | |
4692 * flags: If this parameter is DW_CRA_SELECTED it will only | |
4693 * return items that are currently selected. Otherwise | |
4694 * it will return all records in the container. | |
4695 */ | |
4696 char *dw_container_query_start(HWND handle, unsigned long flags) | |
4697 { | |
4698 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); | |
4699 if(pCore) | |
4700 { | |
4701 if(flags) | |
4702 { | |
4703 while(pCore) | |
4704 { | |
4705 if(pCore->flRecordAttr & CRA_SELECTED) | |
4706 return pCore->pszIcon; | |
4707 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); | |
4708 } | |
4709 } | |
4710 else | |
4711 return pCore->pszIcon; | |
4712 } | |
4713 return NULL; | |
4714 } | |
4715 | |
4716 /* | |
4717 * Continues an existing query of a container. | |
4718 * Parameters: | |
4719 * handle: Handle to the window (widget) to be queried. | |
4720 * flags: If this parameter is DW_CRA_SELECTED it will only | |
4721 * return items that are currently selected. Otherwise | |
4722 * it will return all records in the container. | |
4723 */ | |
4724 char *dw_container_query_next(HWND handle, unsigned long flags) | |
4725 { | |
4726 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); | |
4727 if(pCore) | |
4728 { | |
4729 if(flags) | |
4730 { | |
4731 while(pCore) | |
4732 { | |
4733 if(pCore->flRecordAttr & CRA_SELECTED) | |
4734 return pCore->pszIcon; | |
4735 | |
4736 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); | |
4737 } | |
4738 } | |
4739 else | |
4740 return pCore->pszIcon; | |
4741 } | |
4742 return NULL; | |
4743 } | |
4744 | |
4745 /* | |
4746 * Creates a rendering context widget (window) to be packed. | |
4747 * Parameters: | |
4748 * id: An id to be used with dw_window_from_id. | |
4749 * Returns: | |
4750 * A handle to the widget or NULL on failure. | |
4751 */ | |
4752 HWND dw_render_new(unsigned long id) | |
4753 { | |
4754 HWND hwndframe = WinCreateWindow(HWND_OBJECT, | |
4755 WC_FRAME, | |
4756 NULL, | |
4757 WS_VISIBLE, | |
4758 0,0,2000,1000, | |
4759 NULLHANDLE, | |
4760 HWND_TOP, | |
4761 id, | |
4762 NULL, | |
4763 NULL); | |
4764 WinSubclassWindow(hwndframe, _RendProc); | |
4765 return hwndframe; | |
4766 } | |
4767 | |
4768 /* Sets the current foreground drawing color. | |
4769 * Parameters: | |
4770 * red: red value. | |
4771 * green: green value. | |
4772 * blue: blue value. | |
4773 */ | |
4774 void dw_color_foreground_set(unsigned long value) | |
4775 { | |
4776 _foreground = DW_RED_VALUE(value) << 16 | DW_GREEN_VALUE(value) << 8 | DW_BLUE_VALUE(value); | |
4777 } | |
4778 | |
4779 /* Sets the current background drawing color. | |
4780 * Parameters: | |
4781 * red: red value. | |
4782 * green: green value. | |
4783 * blue: blue value. | |
4784 */ | |
4785 void dw_color_background_set(unsigned long value) | |
4786 { | |
4787 _background = DW_RED_VALUE(value) << 16 | DW_GREEN_VALUE(value) << 8 | DW_BLUE_VALUE(value); | |
4788 } | |
4789 | |
4790 HPS _set_hps(HPS hps) | |
4791 { | |
4792 LONG alTable[18]; | |
4793 | |
4794 GpiQueryLogColorTable(hps, 0L, 0L, 18L, alTable); | |
4795 | |
4796 alTable[16] = _foreground; | |
4797 alTable[17] = _background; | |
4798 | |
4799 GpiCreateLogColorTable(hps, | |
4800 0L, | |
4801 LCOLF_CONSECRGB, | |
4802 0L, | |
4803 18, | |
4804 alTable); | |
4805 GpiSetColor(hps, 16); | |
4806 GpiSetBackColor(hps, 17); | |
4807 return hps; | |
4808 } | |
4809 | |
4810 HPS _set_colors(HWND handle) | |
4811 { | |
4812 HPS hps = WinGetPS(handle); | |
4813 | |
4814 _set_hps(hps); | |
4815 return hps; | |
4816 } | |
4817 | |
4818 /* Draw a point on a window (preferably a render window). | |
4819 * Parameters: | |
4820 * handle: Handle to the window. | |
4821 * pixmap: Handle to the pixmap. (choose only one of these) | |
4822 * x: X coordinate. | |
4823 * y: Y coordinate. | |
4824 */ | |
4825 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) | |
4826 { | |
4827 HPS hps; | |
4828 int height; | |
4829 POINTL ptl; | |
4830 | |
4831 if(handle) | |
4832 { | |
4833 hps = _set_colors(handle); | |
4834 height = _get_height(handle); | |
4835 } | |
4836 else if(pixmap) | |
4837 { | |
4838 hps = _set_hps(pixmap->hps); | |
4839 height = pixmap->height; | |
4840 } | |
4841 else | |
4842 return; | |
4843 | |
4844 ptl.x = x; | |
4845 ptl.y = height - y - 1; | |
4846 | |
4847 GpiSetPel(hps, &ptl); | |
4848 if(!pixmap) | |
4849 WinReleasePS(hps); | |
4850 } | |
4851 | |
4852 /* Draw a line on a window (preferably a render window). | |
4853 * Parameters: | |
4854 * handle: Handle to the window. | |
4855 * pixmap: Handle to the pixmap. (choose only one of these) | |
4856 * x1: First X coordinate. | |
4857 * y1: First Y coordinate. | |
4858 * x2: Second X coordinate. | |
4859 * y2: Second Y coordinate. | |
4860 */ | |
4861 void dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) | |
4862 { | |
4863 HPS hps; | |
4864 int height; | |
4865 POINTL ptl[2]; | |
4866 | |
4867 if(handle) | |
4868 { | |
4869 hps = _set_colors(handle); | |
4870 height = _get_height(handle); | |
4871 } | |
4872 else if(pixmap) | |
4873 { | |
4874 hps = _set_hps(pixmap->hps); | |
4875 height = pixmap->height; | |
4876 } | |
4877 else | |
4878 return; | |
4879 | |
4880 ptl[0].x = x1; | |
4881 ptl[0].y = height - y1 - 1; | |
4882 ptl[1].x = x2; | |
4883 ptl[1].y = height - y2 - 1; | |
4884 | |
4885 GpiMove(hps, &ptl[0]); | |
4886 GpiLine(hps, &ptl[1]); | |
4887 | |
4888 if(!pixmap) | |
4889 WinReleasePS(hps); | |
4890 } | |
4891 | |
4892 | |
9
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4893 void _CopyFontSettings(HPS hpsSrc, HPS hpsDst) |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4894 { |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4895 FONTMETRICS fm; |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4896 FATTRS fat; |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4897 SIZEF sizf; |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4898 |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4899 GpiQueryFontMetrics(hpsSrc, sizeof(FONTMETRICS), &fm); |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4900 |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4901 memset(&fat, 0, sizeof(fat)); |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4902 |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4903 fat.usRecordLength = sizeof(FATTRS); |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4904 fat.lMatch = fm.lMatch; |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4905 strcpy(fat.szFacename, fm.szFacename); |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4906 |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4907 GpiCreateLogFont(hpsDst, 0, 1L, &fat); |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4908 GpiSetCharSet(hpsDst, 1L); |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4909 |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4910 sizf.cx = MAKEFIXED(fm.lEmInc,0); |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4911 sizf.cy = MAKEFIXED(fm.lMaxBaselineExt,0); |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4912 GpiSetCharBox(hpsDst, &sizf ); |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4913 } |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4914 |
3 | 4915 /* Draw text on a window (preferably a render window). |
4916 * Parameters: | |
4917 * handle: Handle to the window. | |
4918 * pixmap: Handle to the pixmap. (choose only one of these) | |
4919 * x: X coordinate. | |
4920 * y: Y coordinate. | |
4921 * text: Text to be displayed. | |
4922 */ | |
4923 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) | |
4924 { | |
4925 HPS hps; | |
9
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4926 int size = 9, z, height; |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4927 RECTL rcl; |
3 | 4928 char fontname[128]; |
4929 | |
4930 if(handle) | |
4931 { | |
4932 hps = _set_colors(handle); | |
4933 height = _get_height(handle); | |
4934 _GetPPFont(handle, fontname); | |
4935 } | |
4936 else if(pixmap) | |
4937 { | |
9
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4938 HPS pixmaphps = WinGetPS(pixmap->handle); |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4939 |
3 | 4940 hps = _set_hps(pixmap->hps); |
4941 height = pixmap->height; | |
4942 _GetPPFont(pixmap->handle, fontname); | |
9
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4943 _CopyFontSettings(pixmaphps, hps); |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4944 WinReleasePS(pixmaphps); |
3 | 4945 } |
4946 else | |
4947 return; | |
4948 | |
4949 for(z=0;z<strlen(fontname);z++) | |
4950 { | |
4951 if(fontname[z]=='.') | |
4952 break; | |
4953 } | |
4954 size = atoi(fontname); | |
4955 | |
9
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4956 rcl.xLeft = x; |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4957 rcl.yTop = height - y; |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4958 rcl.yBottom = rcl.yTop - (size*2); |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4959 rcl.xRight = rcl.xLeft + (size * strlen(text)); |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4960 |
3383ed751a7e
New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
8
diff
changeset
|
4961 WinDrawText(hps, -1, text, &rcl, DT_TEXTATTRS, DT_TEXTATTRS, DT_VCENTER | DT_LEFT | DT_TEXTATTRS); |
3 | 4962 |
4963 if(!pixmap) | |
4964 WinReleasePS(hps); | |
4965 } | |
4966 | |
4967 | |
4968 | |
4969 | |
4970 /* Draw a rectangle on a window (preferably a render window). | |
4971 * Parameters: | |
4972 * handle: Handle to the window. | |
4973 * pixmap: Handle to the pixmap. (choose only one of these) | |
4974 * fill: Fill box TRUE or FALSE. | |
4975 * x: X coordinate. | |
4976 * y: Y coordinate. | |
4977 * width: Width of rectangle. | |
4978 * height: Height of rectangle. | |
4979 */ | |
4980 void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) | |
4981 { | |
4982 HPS hps; | |
4983 int thisheight; | |
4984 POINTL ptl[2]; | |
4985 | |
4986 if(handle) | |
4987 { | |
4988 hps = _set_colors(handle); | |
4989 thisheight = _get_height(handle); | |
4990 } | |
4991 else if(pixmap) | |
4992 { | |
4993 hps = _set_hps(pixmap->hps); | |
4994 thisheight = pixmap->height; | |
4995 } | |
4996 else | |
4997 return; | |
4998 | |
4999 ptl[0].x = x; | |
5000 ptl[0].y = thisheight - y - 1; | |
5001 ptl[1].x = x + width - 1; | |
5002 ptl[1].y = thisheight - y - height; | |
5003 | |
5004 GpiMove(hps, &ptl[0]); | |
5005 GpiBox(hps, fill ? DRO_OUTLINEFILL : DRO_OUTLINE, &ptl[1], 0, 0); | |
5006 | |
5007 if(!pixmap) | |
5008 WinReleasePS(hps); | |
5009 } | |
5010 | |
5011 /* Call this after drawing to the screen to make sure | |
5012 * anything you have drawn is visible. | |
5013 */ | |
5014 void dw_flush(void) | |
5015 { | |
5016 } | |
5017 | |
5018 /* | |
5019 * Creates a pixmap with given parameters. | |
5020 * Parameters: | |
5021 * handle: Window handle the pixmap is associated with. | |
5022 * width: Width of the pixmap in pixels. | |
5023 * height: Height of the pixmap in pixels. | |
5024 * depth: Color depth of the pixmap. | |
5025 * Returns: | |
5026 * A handle to a pixmap or NULL on failure. | |
5027 */ | |
5028 HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) | |
5029 { | |
5030 BITMAPINFOHEADER bmih; | |
5031 SIZEL sizl = { 0, 0 }; | |
5032 HPIXMAP pixmap; | |
5033 HDC hdc; | |
5034 HPS hps; | |
5035 ULONG ulFlags; | |
5036 LONG cPlanes, cBitCount; | |
5037 | |
5038 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) | |
5039 return NULL; | |
5040 | |
5041 hps = WinGetPS(handle); | |
5042 | |
5043 hdc = GpiQueryDevice(hps); | |
5044 ulFlags = GpiQueryPS(hps, &sizl); | |
5045 | |
5046 pixmap->handle = handle; | |
5047 pixmap->hdc = DevOpenDC(dwhab, OD_MEMORY, "*", 0L, NULL, hdc); | |
5048 pixmap->hps = GpiCreatePS (dwhab, pixmap->hdc, &sizl, ulFlags | GPIA_ASSOC); | |
5049 | |
5050 DevQueryCaps(hdc, CAPS_COLOR_PLANES , 1L, &cPlanes); | |
5051 if (!depth) | |
5052 { | |
5053 DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1L, &cBitCount); | |
5054 depth = cBitCount; | |
5055 } | |
5056 | |
5057 memset(&bmih, 0, sizeof(BITMAPINFOHEADER)); | |
5058 bmih.cbFix = sizeof(BITMAPINFOHEADER); | |
5059 bmih.cx = (SHORT)width; | |
5060 bmih.cy = (SHORT)height; | |
5061 bmih.cPlanes = (SHORT)cPlanes; | |
5062 bmih.cBitCount = (SHORT)depth; | |
5063 | |
5064 pixmap->width = width; pixmap->height = height; | |
5065 | |
5066 pixmap->hbm = GpiCreateBitmap(pixmap->hps, (PBITMAPINFOHEADER2)&bmih, 0L, NULL, NULL); | |
5067 | |
5068 GpiSetBitmap(pixmap->hps, pixmap->hbm); | |
5069 | |
5070 if (depth>8) | |
5071 GpiCreateLogColorTable(pixmap->hps, LCOL_PURECOLOR, LCOLF_RGB, 0, 0, NULL ); | |
5072 | |
5073 WinReleasePS(hps); | |
5074 | |
5075 return pixmap; | |
5076 } | |
5077 | |
5078 /* | |
5079 * Creates a pixmap from internal resource graphic specified by id. | |
5080 * Parameters: | |
5081 * handle: Window handle the pixmap is associated with. | |
5082 * id: Resource ID associated with requested pixmap. | |
5083 * Returns: | |
5084 * A handle to a pixmap or NULL on failure. | |
5085 */ | |
5086 HPIXMAP dw_pixmap_grab(HWND handle, ULONG id) | |
5087 { | |
5088 BITMAPINFOHEADER bmih; | |
5089 SIZEL sizl = { 0, 0 }; | |
5090 HPIXMAP pixmap; | |
5091 HDC hdc; | |
5092 HPS hps; | |
5093 ULONG ulFlags; | |
5094 | |
5095 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) | |
5096 return NULL; | |
5097 | |
5098 hps = WinGetPS(handle); | |
5099 | |
5100 hdc = GpiQueryDevice(hps); | |
5101 ulFlags = GpiQueryPS(hps, &sizl); | |
5102 | |
5103 pixmap->hdc = DevOpenDC(dwhab, OD_MEMORY, "*", 0L, NULL, hdc); | |
5104 pixmap->hps = GpiCreatePS (dwhab, pixmap->hdc, &sizl, ulFlags | GPIA_ASSOC); | |
5105 | |
5106 pixmap->hbm = GpiLoadBitmap(pixmap->hps, NULLHANDLE, id, 0, 0); | |
5107 | |
5108 GpiQueryBitmapParameters(pixmap->hbm, &bmih); | |
5109 | |
5110 GpiSetBitmap(pixmap->hps, pixmap->hbm); | |
5111 | |
5112 pixmap->width = bmih.cx; pixmap->height = bmih.cy; | |
5113 | |
5114 WinReleasePS(hps); | |
5115 | |
5116 return pixmap; | |
5117 } | |
5118 | |
5119 /* | |
5120 * Destroys an allocated pixmap. | |
5121 * Parameters: | |
5122 * pixmap: Handle to a pixmap returned by | |
5123 * dw_pixmap_new.. | |
5124 */ | |
5125 void dw_pixmap_destroy(HPIXMAP pixmap) | |
5126 { | |
5127 GpiSetBitmap(pixmap->hps, NULLHANDLE); | |
5128 GpiDeleteBitmap(pixmap->hbm); | |
5129 GpiAssociate(pixmap->hps, NULLHANDLE); | |
5130 GpiDestroyPS(pixmap->hps); | |
5131 DevCloseDC(pixmap->hdc); | |
5132 free(pixmap); | |
5133 } | |
5134 | |
5135 /* | |
5136 * Copies from one item to another. | |
5137 * Parameters: | |
5138 * dest: Destination window handle. | |
5139 * destp: Destination pixmap. (choose only one). | |
5140 * xdest: X coordinate of destination. | |
5141 * ydest: Y coordinate of destination. | |
5142 * width: Width of area to copy. | |
5143 * height: Height of area to copy. | |
5144 * src: Source window handle. | |
5145 * srcp: Source pixmap. (choose only one). | |
5146 * xsrc: X coordinate of source. | |
5147 * ysrc: Y coordinate of source. | |
5148 */ | |
5149 void dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) | |
5150 { | |
5151 HPS hpsdest; | |
5152 HPS hpssrc; | |
5153 POINTL ptl[4]; | |
5154 int destheight, srcheight; | |
5155 | |
5156 if(dest) | |
5157 { | |
5158 hpsdest = WinGetPS(dest); | |
5159 destheight = _get_height(dest); | |
5160 } | |
5161 else if(destp) | |
5162 { | |
5163 hpsdest = destp->hps; | |
5164 destheight = destp->height; | |
5165 } | |
5166 else | |
5167 return; | |
5168 | |
5169 if(src) | |
5170 { | |
5171 hpssrc = WinGetPS(src); | |
5172 srcheight = _get_height(src); | |
5173 } | |
5174 else if(srcp) | |
5175 { | |
5176 hpssrc = srcp->hps; | |
5177 srcheight = srcp->height; | |
5178 } | |
5179 else | |
5180 { | |
5181 if(!destp) | |
5182 WinReleasePS(hpsdest); | |
5183 return; | |
5184 } | |
5185 | |
5186 ptl[0].x = xdest; | |
5187 ptl[0].y = (destheight - ydest) - height; | |
5188 ptl[1].x = ptl[0].x + width; | |
5189 ptl[1].y = destheight - ydest; | |
5190 ptl[2].x = xsrc; | |
5191 ptl[2].y = srcheight - (ysrc + height); | |
5192 ptl[3].x = ptl[2].x + width; | |
5193 ptl[3].y = ptl[2].y + height; | |
5194 | |
5195 GpiBitBlt(hpsdest, hpssrc, 4, ptl, ROP_SRCCOPY, BBO_IGNORE); | |
5196 | |
5197 if(!destp) | |
5198 WinReleasePS(hpsdest); | |
5199 if(!srcp) | |
5200 WinReleasePS(hpssrc); | |
5201 } | |
5202 | |
5203 /* | |
5204 * Emits a beep. | |
5205 * Parameters: | |
5206 * freq: Frequency. | |
5207 * dur: Duration. | |
5208 */ | |
5209 void dw_beep(int freq, int dur) | |
5210 { | |
5211 DosBeep(freq, dur); | |
5212 } | |
5213 | |
5214 /* | |
5215 * Returns the handle to an unnamed mutex semaphore. | |
5216 */ | |
5217 HMTX dw_mutex_new(void) | |
5218 { | |
5219 HMTX mutex; | |
5220 | |
5221 DosCreateMutexSem(NULL, &mutex, 0, FALSE); | |
5222 return mutex; | |
5223 } | |
5224 | |
5225 /* | |
5226 * Closes a semaphore created by dw_mutex_new(). | |
5227 * Parameters: | |
5228 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
5229 */ | |
5230 void dw_mutex_close(HMTX mutex) | |
5231 { | |
5232 DosCloseMutexSem(mutex); | |
5233 } | |
5234 | |
5235 /* | |
5236 * Tries to gain access to the semaphore, if it can't it blocks. | |
5237 * Parameters: | |
5238 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
5239 */ | |
5240 void dw_mutex_lock(HMTX mutex) | |
5241 { | |
5242 DosRequestMutexSem(mutex, SEM_INDEFINITE_WAIT); | |
5243 } | |
5244 | |
5245 /* | |
5246 * Reliquishes the access to the semaphore. | |
5247 * Parameters: | |
5248 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
5249 */ | |
5250 void dw_mutex_unlock(HMTX mutex) | |
5251 { | |
5252 DosReleaseMutexSem(mutex); | |
5253 } | |
5254 | |
5255 /* | |
5256 * Returns the handle to an unnamed event semaphore. | |
5257 */ | |
5258 HEV dw_event_new(void) | |
5259 { | |
5260 HEV blah; | |
5261 | |
5262 if(DosCreateEventSem (NULL, &blah, 0L, FALSE)) | |
5263 return 0; | |
5264 | |
5265 return blah; | |
5266 } | |
5267 | |
5268 /* | |
5269 * Resets a semaphore created by dw_event_new(). | |
5270 * Parameters: | |
5271 * eve: The handle to the event returned by dw_event_new(). | |
5272 */ | |
5273 int dw_event_reset(HEV eve) | |
5274 { | |
5275 ULONG count; | |
5276 | |
5277 if(DosResetEventSem(eve, &count)) | |
5278 return FALSE; | |
5279 return TRUE; | |
5280 } | |
5281 | |
5282 /* | |
5283 * Posts a semaphore created by dw_event_new(). Causing all threads | |
5284 * waiting on this event in dw_event_wait to continue. | |
5285 * Parameters: | |
5286 * eve: The handle to the event returned by dw_event_new(). | |
5287 */ | |
5288 int dw_event_post(HEV eve) | |
5289 { | |
5290 if(DosPostEventSem(eve)) | |
5291 return FALSE; | |
5292 return TRUE; | |
5293 } | |
5294 | |
5295 | |
5296 /* | |
5297 * Waits on a semaphore created by dw_event_new(), until the | |
5298 * event gets posted or until the timeout expires. | |
5299 * Parameters: | |
5300 * eve: The handle to the event returned by dw_event_new(). | |
5301 */ | |
5302 int dw_event_wait(HEV eve, unsigned long timeout) | |
5303 { | |
5304 int rc = DosWaitEventSem(eve, timeout); | |
5305 if(!rc) | |
5306 return 1; | |
5307 if(rc == ERROR_TIMEOUT) | |
5308 return -1; | |
5309 return 0; | |
5310 } | |
5311 | |
5312 /* | |
5313 * Closes a semaphore created by dw_event_new(). | |
5314 * Parameters: | |
5315 * eve: The handle to the event returned by dw_event_new(). | |
5316 */ | |
5317 int dw_event_close(HEV *eve) | |
5318 { | |
5319 if(!eve || ~DosCloseEventSem(*eve)) | |
5320 return FALSE; | |
5321 return TRUE; | |
5322 } | |
5323 | |
5324 /* | |
5325 * Encapsulate the message queues on OS/2. | |
5326 */ | |
5327 void _dwthreadstart(void *data) | |
5328 { | |
5329 HAB thishab = WinInitialize(0); | |
5330 HMQ thishmq = WinCreateMsgQueue(dwhab, 0); | |
5331 void (*threadfunc)(void *) = NULL; | |
5332 void **tmp = (void **)data; | |
5333 | |
5334 threadfunc = (void (*)(void *))tmp[0]; | |
5335 threadfunc(tmp[1]); | |
5336 | |
5337 free(tmp); | |
5338 | |
5339 WinDestroyMsgQueue(thishmq); | |
5340 WinTerminate(thishab); | |
5341 } | |
5342 | |
5343 /* | |
5344 * Creates a new thread with a starting point of func. | |
5345 * Parameters: | |
5346 * func: Function which will be run in the new thread. | |
5347 * data: Parameter(s) passed to the function. | |
5348 * stack: Stack size of new thread (OS/2 and Windows only). | |
5349 */ | |
5350 DWTID dw_thread_new(void *func, void *data, int stack) | |
5351 { | |
5352 void **tmp = malloc(sizeof(void *) * 2); | |
5353 | |
5354 tmp[0] = func; | |
5355 tmp[1] = data; | |
5356 | |
5357 return (DWTID)_beginthread((void (*)(void *))_dwthreadstart, NULL, stack, (void *)tmp); | |
5358 } | |
5359 | |
5360 /* | |
5361 * Ends execution of current thread immediately. | |
5362 */ | |
5363 void dw_thread_end(void) | |
5364 { | |
5365 _endthread(); | |
5366 } | |
5367 | |
5368 /* | |
5369 * Returns the current thread's ID. | |
5370 */ | |
5371 DWTID dw_thread_id(void) | |
5372 { | |
5373 return (DWTID)_threadid; | |
5374 } | |
5375 | |
5376 /* | |
5377 * Cleanly terminates a DW session, should be signal handler safe. | |
5378 * Parameters: | |
5379 * exitcode: Exit code reported to the operating system. | |
5380 */ | |
5381 void dw_exit(int exitcode) | |
5382 { | |
5383 /* In case we are in a signal handler, don't | |
5384 * try to free memory that could possibly be | |
5385 * free()'d by the runtime already. | |
5386 */ | |
5387 #ifndef NO_SIGNALS | |
5388 Root = NULL; | |
5389 #endif | |
5390 exit(exitcode); | |
5391 } | |
5392 | |
5393 /* | |
5394 * Pack a splitbar (sizer) into the specified box from the start. | |
5395 * Parameters: | |
5396 * box: Window handle of the box to be packed into. | |
5397 */ | |
5398 void dw_box_pack_splitbar_start(HWND box) | |
5399 { | |
5400 Box *thisbox; | |
5401 | |
5402 if(WinWindowFromID(box, FID_CLIENT)) | |
5403 { | |
5404 box = WinWindowFromID(box, FID_CLIENT); | |
5405 thisbox = WinQueryWindowPtr(box, QWP_USER); | |
5406 } | |
5407 else | |
5408 thisbox = WinQueryWindowPtr(box, QWP_USER); | |
5409 if(thisbox) | |
5410 { | |
5411 HWND tmp = WinCreateWindow(HWND_OBJECT, | |
5412 SplitbarClassName, | |
5413 NULL, | |
5414 WS_VISIBLE, | |
5415 0,0,2000,1000, | |
5416 NULLHANDLE, | |
5417 HWND_TOP, | |
5418 0L, | |
5419 NULL, | |
5420 NULL); | |
5421 if(thisbox->type == BOXVERT) | |
5422 dw_box_pack_start(box, tmp, 1, SPLITBAR_WIDTH, TRUE, FALSE, 0); | |
5423 else | |
5424 dw_box_pack_start(box, tmp, SPLITBAR_WIDTH, 1, FALSE, TRUE, 0); | |
5425 | |
5426 } | |
5427 } | |
5428 | |
5429 /* | |
5430 * Pack a splitbar (sizer) into the specified box from the end. | |
5431 * Parameters: | |
5432 * box: Window handle of the box to be packed into. | |
5433 */ | |
5434 void dw_box_pack_splitbar_end(HWND box) | |
5435 { | |
5436 Box *thisbox; | |
5437 | |
5438 if(WinWindowFromID(box, FID_CLIENT)) | |
5439 { | |
5440 box = WinWindowFromID(box, FID_CLIENT); | |
5441 thisbox = WinQueryWindowPtr(box, QWP_USER); | |
5442 } | |
5443 else | |
5444 thisbox = WinQueryWindowPtr(box, QWP_USER); | |
5445 if(thisbox) | |
5446 { | |
5447 HWND tmp = WinCreateWindow(HWND_OBJECT, | |
5448 SplitbarClassName, | |
5449 NULL, | |
5450 WS_VISIBLE, | |
5451 0,0,2000,1000, | |
5452 NULLHANDLE, | |
5453 HWND_TOP, | |
5454 0L, | |
5455 NULL, | |
5456 NULL); | |
5457 if(thisbox->type == BOXVERT) | |
5458 dw_box_pack_end(box, tmp, 1, SPLITBAR_WIDTH, TRUE, FALSE, 0); | |
5459 else | |
5460 dw_box_pack_end(box, tmp, SPLITBAR_WIDTH, 1, FALSE, TRUE, 0); | |
5461 | |
5462 } | |
5463 } | |
5464 | |
5465 /* | |
5466 * Pack windows (widgets) into a box from the start (or top). | |
5467 * Parameters: | |
5468 * box: Window handle of the box to be packed into. | |
5469 * item: Window handle of the item to be back. | |
5470 * width: Width in pixels of the item or -1 to be self determined. | |
5471 * height: Height in pixels of the item or -1 to be self determined. | |
5472 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
5473 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
5474 * pad: Number of pixels of padding around the item. | |
5475 */ | |
5476 void dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
5477 { | |
5478 Box *thisbox; | |
5479 | |
5480 if(WinWindowFromID(box, FID_CLIENT)) | |
5481 { | |
5482 box = WinWindowFromID(box, FID_CLIENT); | |
5483 thisbox = WinQueryWindowPtr(box, QWP_USER); | |
5484 } | |
5485 else | |
5486 thisbox = WinQueryWindowPtr(box, QWP_USER); | |
5487 if(thisbox) | |
5488 { | |
5489 if(thisbox->type == BOXHORZ) | |
5490 dw_box_pack_end_stub(box, item, width, height, hsize, vsize, pad); | |
5491 else | |
5492 dw_box_pack_start_stub(box, item, width, height, hsize, vsize, pad); | |
5493 } | |
5494 } | |
5495 | |
5496 void dw_box_pack_start_stub(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
5497 { | |
5498 HWND boxowner = NULLHANDLE; | |
5499 Box *thisbox; | |
5500 | |
5501 if(WinWindowFromID(box, FID_CLIENT)) | |
5502 { | |
5503 box = WinWindowFromID(box, FID_CLIENT); | |
5504 thisbox = WinQueryWindowPtr(box, QWP_USER); | |
5505 hsize = TRUE; | |
5506 vsize = TRUE; | |
5507 } | |
5508 else | |
5509 thisbox = WinQueryWindowPtr(box, QWP_USER); | |
5510 if(thisbox) | |
5511 { | |
5512 int z; | |
5513 Item *tmpitem, *thisitem = thisbox->items; | |
5514 char tmpbuf[100]; | |
5515 | |
5516 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); | |
5517 | |
5518 for(z=0;z<thisbox->count;z++) | |
5519 { | |
5520 tmpitem[z+1] = thisitem[z]; | |
5521 } | |
5522 | |
5523 WinQueryClassName(item, 99, tmpbuf); | |
5524 | |
5525 if(strncmp(tmpbuf, "#1", 2)==0) | |
5526 tmpitem[0].type = TYPEBOX; | |
5527 else | |
5528 tmpitem[0].type = TYPEITEM; | |
5529 | |
5530 tmpitem[0].hwnd = item; | |
5531 tmpitem[0].origwidth = tmpitem[0].width = width; | |
5532 tmpitem[0].origheight = tmpitem[0].height = height; | |
5533 tmpitem[0].pad = pad; | |
5534 if(hsize) | |
5535 tmpitem[0].hsize = SIZEEXPAND; | |
5536 else | |
5537 tmpitem[0].hsize = SIZESTATIC; | |
5538 | |
5539 if(vsize) | |
5540 tmpitem[0].vsize = SIZEEXPAND; | |
5541 else | |
5542 tmpitem[0].vsize = SIZESTATIC; | |
5543 | |
5544 thisbox->items = tmpitem; | |
5545 | |
5546 if(thisbox->count) | |
5547 free(thisitem); | |
5548 | |
5549 thisbox->count++; | |
5550 | |
5551 WinQueryClassName(item, 99, tmpbuf); | |
5552 /* Don't set the ownership if it's an entryfield or combobox */ | |
5553 if(strncmp(tmpbuf, "#6", 2)!=0 /*&& strncmp(tmpbuf, "#2", 2)!=0*/) | |
5554 { | |
5555 if((boxowner = WinQueryWindow(box, QW_OWNER)) != 0) | |
5556 WinSetOwner(item, boxowner); | |
5557 else | |
5558 WinSetOwner(item, box); | |
5559 } | |
5560 WinSetParent(item, box, FALSE); | |
5561 } | |
5562 } | |
5563 | |
5564 /* The following two functions graciously contributed by Peter Nielsen. */ | |
5565 static ULONG _ParseBuildLevel (char* pchBuffer, ULONG ulSize) { | |
5566 char* pchStart = pchBuffer; | |
5567 char* pchEnd = pchStart + ulSize - 2; | |
5568 | |
5569 while (pchEnd >= pchStart) | |
5570 { | |
5571 if ((pchEnd[0] == '#') && (pchEnd[1] == '@')) | |
5572 { | |
5573 *pchEnd-- = '\0'; | |
5574 while (pchEnd >= pchStart) | |
5575 { | |
5576 if ((pchEnd[0] == '@') && (pchEnd[1] == '#')) | |
5577 { | |
5578 ULONG ulMajor = 0; | |
5579 ULONG ulMinor = 0; | |
5580 | |
5581 char* pch = pchEnd + 2; | |
5582 while (!isdigit (*pch) && *pch) | |
5583 pch++; | |
5584 | |
5585 while (isdigit (*pch)) | |
5586 ulMajor = ulMajor * 10 + *pch++ - '0'; | |
5587 | |
5588 if (*pch == '.') | |
5589 { | |
5590 while (isdigit (*++pch)) | |
5591 ulMinor = ulMinor * 10 + *pch - '0'; | |
5592 } | |
5593 return ((ulMajor << 16) | ulMinor); | |
5594 } | |
5595 pchEnd--; | |
5596 } | |
5597 } | |
5598 pchEnd--; | |
5599 } | |
5600 return (0); | |
5601 } | |
5602 | |
5603 ULONG _GetSystemBuildLevel(void) { | |
5604 /* 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. | |
5605 * 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. | |
5606 */ | |
5607 ULONG ulBootDrive = 0; | |
5608 ULONG ulBuild = 0; | |
5609 if (DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive, sizeof (ulBootDrive)) == NO_ERROR) | |
5610 { | |
5611 char achFileName[11] = { (char)('A'+ulBootDrive-1),':','\\','O','S','2','K','R','N','L','\0' }; | |
5612 HFILE hfile; | |
5613 ULONG ulResult; | |
5614 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) | |
5615 { | |
5616 ULONG ulFileSize = 0; | |
5617 if (DosSetFilePtr (hfile, 0, FILE_END, &ulFileSize) == NO_ERROR) | |
5618 { | |
5619 const ULONG ulFirstTry = min (256, ulFileSize); | |
5620 if (DosSetFilePtr (hfile, -(LONG)ulFirstTry, FILE_END, &ulResult) == NO_ERROR) | |
5621 { | |
5622 char *pchBuffer = malloc(ulFirstTry); | |
5623 if (DosRead (hfile, pchBuffer, ulFirstTry, &ulResult) == NO_ERROR) | |
5624 { | |
5625 ulBuild = _ParseBuildLevel (pchBuffer, ulFirstTry); | |
5626 if (ulBuild == 0) | |
5627 { | |
5628 if (DosSetFilePtr (hfile, 0, FILE_BEGIN, &ulResult) == NO_ERROR) | |
5629 { | |
5630 free(pchBuffer); | |
5631 pchBuffer = malloc(ulFileSize); | |
5632 | |
5633 if (DosRead (hfile, pchBuffer, ulFileSize, &ulResult) == NO_ERROR) | |
5634 ulBuild = _ParseBuildLevel (pchBuffer, ulFileSize); | |
5635 } | |
5636 } | |
5637 } | |
5638 free(pchBuffer); | |
5639 } | |
5640 } | |
5641 DosClose (hfile); | |
5642 } | |
5643 } | |
5644 return (ulBuild); | |
5645 } | |
5646 | |
5647 | |
5648 /* | |
5649 * Returns some information about the current operating environment. | |
5650 * Parameters: | |
5651 * env: Pointer to a DWEnv struct. | |
5652 */ | |
5653 void dw_environment_query(DWEnv *env) | |
5654 { | |
5655 ULONG Build; | |
5656 | |
5657 if(!env) | |
5658 return; | |
5659 | |
5660 /* The default is OS/2 2.0 */ | |
5661 strcpy(env->osName,"OS/2"); | |
5662 env->MajorVersion = 2; | |
5663 env->MinorVersion = 0; | |
5664 | |
5665 Build = _GetSystemBuildLevel(); | |
5666 env->MinorBuild = Build & 0xFFFF; | |
5667 env->MajorBuild = Build >> 16; | |
5668 | |
5669 if (aulBuffer[0] == 20) | |
5670 { | |
5671 int i = (unsigned int)aulBuffer[1]; | |
5672 if (i > 20) | |
5673 { | |
5674 strcpy(env->osName,"Warp"); | |
5675 env->MajorVersion = (int)i/10; | |
5676 env->MinorVersion = i-(((int)i/10)*10); | |
5677 } | |
5678 else if (i == 10) | |
5679 env->MinorVersion = 1; | |
5680 } | |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
5681 strcpy(env->buildDate, __DATE__); |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
5682 strcpy(env->buildTime, __TIME__); |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
5683 env->DWMajorVersion = DW_MAJOR_VERSION; |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
5684 env->DWMinorVersion = DW_MINOR_VERSION; |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
5685 env->DWSubVersion = DW_SUB_VERSION; |
3 | 5686 } |
5687 | |
5688 /* | |
5689 * Opens a file dialog and queries user selection. | |
5690 * Parameters: | |
5691 * title: Title bar text for dialog. | |
5692 * defpath: The default path of the open dialog. | |
5693 * ext: Default file extention. | |
5694 * flags: DW_FILE_OPEN or DW_FILE_SAVE. | |
5695 * Returns: | |
5696 * NULL on error. A malloced buffer containing | |
5697 * the file path on success. | |
5698 * | |
5699 */ | |
5700 char *dw_file_browse(char *title, char *defpath, char *ext, int flags) | |
5701 { | |
5702 FILEDLG fild; | |
5703 HWND hwndFile; | |
5704 int len; | |
5705 | |
5706 if(defpath) | |
5707 strcpy(fild.szFullFile, defpath); | |
5708 else | |
5709 strcpy(fild.szFullFile, ""); | |
5710 | |
5711 len = strlen(fild.szFullFile); | |
5712 | |
5713 if(len) | |
5714 { | |
5715 if(fild.szFullFile[len-1] != '\\') | |
5716 strcat(fild.szFullFile, "\\"); | |
5717 } | |
5718 strcat(fild.szFullFile, "*"); | |
5719 | |
5720 if(ext) | |
5721 { | |
5722 strcat(fild.szFullFile, "."); | |
5723 strcat(fild.szFullFile, ext); | |
5724 } | |
5725 | |
5726 fild.cbSize = sizeof(FILEDLG); | |
5727 fild.fl = /*FDS_HELPBUTTON |*/ FDS_CENTER | FDS_OPEN_DIALOG; | |
5728 fild.pszTitle = title; | |
5729 fild.pszOKButton = ((flags & DW_FILE_SAVE) ? "Save" : "Open"); | |
5730 fild.ulUser = 0L; | |
5731 fild.pfnDlgProc = (PFNWP)WinDefFileDlgProc; | |
5732 fild.lReturn = 0L; | |
5733 fild.lSRC = 0L; | |
5734 fild.hMod = 0; | |
5735 fild.x = 0; | |
5736 fild.y = 0; | |
5737 fild.pszIType = (PSZ)NULL; | |
5738 fild.papszITypeList = (PAPSZ)NULL; | |
5739 fild.pszIDrive = (PSZ)NULL; | |
5740 fild.papszIDriveList= (PAPSZ)NULL; | |
5741 fild.sEAType = (SHORT)0; | |
5742 fild.papszFQFilename= (PAPSZ)NULL; | |
5743 fild.ulFQFCount = 0L; | |
5744 | |
5745 hwndFile = WinFileDlg(HWND_DESKTOP, HWND_DESKTOP, &fild); | |
5746 if(hwndFile) | |
5747 { | |
5748 switch(fild.lReturn) | |
5749 { | |
5750 case DID_OK: | |
5751 return strdup(fild.szFullFile); | |
5752 case DID_CANCEL: | |
5753 return NULL; | |
5754 } | |
5755 } | |
5756 return NULL; | |
5757 } | |
5758 | |
5759 /* | |
5760 * Execute and external program in a seperate session. | |
5761 * Parameters: | |
5762 * program: Program name with optional path. | |
5763 * type: Either DW_EXEC_CON or DW_EXEC_GUI. | |
5764 * params: An array of pointers to string arguements. | |
5765 * Returns: | |
5766 * -1 on error. | |
5767 */ | |
5768 int dw_exec(char *program, int type, char **params) | |
5769 { | |
5770 return spawnvp(P_NOWAIT, program, params); | |
5771 } | |
5772 | |
5773 /* | |
5774 * Loads a web browser pointed at the given URL. | |
5775 * Parameters: | |
5776 * url: Uniform resource locator. | |
5777 */ | |
5778 int dw_browse(char *url) | |
5779 { | |
5780 /* Is there a way to find the webbrowser in Unix? */ | |
20
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5781 char *execargs[3], browser[1024], *newurl = NULL; |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5782 int len; |
3 | 5783 |
5784 PrfQueryProfileString(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS", | |
5785 "DefaultBrowserExe", NULL, browser, 1024); | |
5786 | |
20
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5787 len = strlen(browser) - strlen("explore.exe"); |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5788 |
3 | 5789 execargs[0] = browser; |
5790 execargs[1] = url; | |
5791 execargs[2] = NULL; | |
5792 | |
20
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5793 /* Special case for Web Explorer, it requires file:/// instead |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5794 * of file:// so I am handling it here. |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5795 */ |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5796 if(len > 0) |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5797 { |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5798 if(stricmp(&browser[len], "explore.exe") == 0) |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5799 { |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5800 int newlen, z; |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5801 newurl = alloca(strlen(url) + 2); |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5802 sprintf(newurl, "file:///%s", &url[7]); |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5803 newlen = strlen(newurl); |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5804 for(z=8;z<(newlen-8);z++) |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5805 { |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5806 if(newurl[z] == '|') |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5807 newurl[z] = ':'; |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5808 if(newurl[z] == '/') |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5809 newurl[z] = '\\'; |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5810 } |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5811 execargs[1] = newurl; |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5812 } |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5813 } |
38295c8d06d5
Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
18
diff
changeset
|
5814 |
3 | 5815 return dw_exec(browser, DW_EXEC_GUI, execargs); |
5816 } | |
5817 | |
5818 /* | |
5819 * Returns a pointer to a static buffer which containes the | |
5820 * current user directory. Or the root directory (C:\ on | |
5821 * OS/2 and Windows). | |
5822 */ | |
5823 char *dw_user_dir(void) | |
5824 { | |
5825 static char _user_dir[1024] = ""; | |
5826 | |
5827 if(!_user_dir[0]) | |
5828 { | |
5829 char *home = getenv("HOME"); | |
5830 | |
5831 if(home) | |
5832 strcpy(_user_dir, home); | |
5833 else | |
5834 strcpy(_user_dir, "C:\\"); | |
5835 } | |
5836 return _user_dir; | |
5837 } | |
5838 | |
5839 /* | |
5840 * Call a function from the window (widget)'s context. | |
5841 * Parameters: | |
5842 * handle: Window handle of the widget. | |
5843 * function: Function pointer to be called. | |
5844 * data: Pointer to the data to be passed to the function. | |
5845 */ | |
5846 void dw_window_function(HWND handle, void *function, void *data) | |
5847 { | |
5848 WinSendMsg(handle, WM_USER, (MPARAM)function, (MPARAM)data); | |
5849 } | |
5850 | |
5851 #ifndef NO_SIGNALS | |
5852 /* | |
5853 * Add a callback to a window event. | |
5854 * Parameters: | |
5855 * window: Window handle of signal to be called back. | |
5856 * signame: A string pointer identifying which signal to be hooked. | |
5857 * sigfunc: The pointer to the function to be used as the callback. | |
5858 * data: User data to be passed to the handler function. | |
5859 */ | |
5860 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) | |
5861 { | |
5862 ULONG message = 0L; | |
5863 | |
5864 if(window && signame && sigfunc) | |
5865 { | |
5866 if((message = _findsigmessage(signame)) != 0) | |
5867 _new_signal(message, window, sigfunc, data); | |
5868 } | |
5869 } | |
5870 | |
5871 /* | |
5872 * Removes callbacks for a given window with given name. | |
5873 * Parameters: | |
5874 * window: Window handle of callback to be removed. | |
5875 */ | |
5876 void dw_signal_disconnect_by_name(HWND window, char *signame) | |
5877 { | |
5878 SignalHandler *prev = NULL, *tmp = Root; | |
5879 ULONG message; | |
5880 | |
5881 if(!window || !signame || (message = _findsigmessage(signame)) == 0) | |
5882 return; | |
5883 | |
5884 while(tmp) | |
5885 { | |
5886 if(tmp->window == window && tmp->message == message) | |
5887 { | |
5888 if(prev) | |
5889 { | |
5890 prev->next = tmp->next; | |
5891 free(tmp); | |
5892 tmp = prev->next; | |
5893 } | |
5894 else | |
5895 { | |
5896 Root = tmp->next; | |
5897 free(tmp); | |
5898 tmp = Root; | |
5899 } | |
5900 } | |
5901 else | |
5902 { | |
5903 prev = tmp; | |
5904 tmp = tmp->next; | |
5905 } | |
5906 } | |
5907 } | |
5908 | |
5909 /* | |
5910 * Removes all callbacks for a given window. | |
5911 * Parameters: | |
5912 * window: Window handle of callback to be removed. | |
5913 */ | |
5914 void dw_signal_disconnect_by_window(HWND window) | |
5915 { | |
5916 SignalHandler *prev = NULL, *tmp = Root; | |
5917 | |
5918 while(tmp) | |
5919 { | |
5920 if(tmp->window == window) | |
5921 { | |
5922 if(prev) | |
5923 { | |
5924 prev->next = tmp->next; | |
5925 free(tmp); | |
5926 tmp = prev->next; | |
5927 } | |
5928 else | |
5929 { | |
5930 Root = tmp->next; | |
5931 free(tmp); | |
5932 tmp = Root; | |
5933 } | |
5934 } | |
5935 else | |
5936 { | |
5937 prev = tmp; | |
5938 tmp = tmp->next; | |
5939 } | |
5940 } | |
5941 } | |
5942 | |
5943 /* | |
5944 * Removes all callbacks for a given window with specified data. | |
5945 * Parameters: | |
5946 * window: Window handle of callback to be removed. | |
5947 * data: Pointer to the data to be compared against. | |
5948 */ | |
5949 void dw_signal_disconnect_by_data(HWND window, void *data) | |
5950 { | |
5951 SignalHandler *prev = NULL, *tmp = Root; | |
5952 | |
5953 while(tmp) | |
5954 { | |
5955 if(tmp->window == window && tmp->data == data) | |
5956 { | |
5957 if(prev) | |
5958 { | |
5959 prev->next = tmp->next; | |
5960 free(tmp); | |
5961 tmp = prev->next; | |
5962 } | |
5963 else | |
5964 { | |
5965 Root = tmp->next; | |
5966 free(tmp); | |
5967 tmp = Root; | |
5968 } | |
5969 } | |
5970 else | |
5971 { | |
5972 prev = tmp; | |
5973 tmp = tmp->next; | |
5974 } | |
5975 } | |
5976 } | |
5977 #endif | |
5978 | |
5979 #ifdef TEST | |
5980 HWND mainwindow, | |
5981 listbox, | |
5982 okbutton, | |
5983 cancelbutton, | |
5984 lbbox, | |
5985 stext, | |
5986 buttonbox, | |
5987 testwindow, | |
5988 testbox, | |
5989 testok, | |
5990 testcancel, | |
5991 testbox2, | |
5992 testok2, | |
5993 testcancel2, | |
5994 notebook; | |
5995 int count = 2; | |
5996 | |
5997 #ifdef USE_FILTER | |
5998 /* Do any handling you need in the filter function */ | |
5999 LONG testfilter(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | |
6000 { | |
6001 switch(msg) | |
6002 { | |
6003 case WM_COMMAND: | |
6004 switch (COMMANDMSG(&msg)->cmd) | |
6005 { | |
6006 case 1001L: | |
6007 case 1002L: | |
6008 dw_window_destroy(mainwindow);; | |
6009 count--; | |
6010 break; | |
6011 case 1003L: | |
6012 case 1004L: | |
6013 dw_window_destroy(testwindow);; | |
6014 count--; | |
6015 break; | |
6016 } | |
6017 if(!count) | |
6018 exit(0); | |
6019 break; | |
6020 } | |
6021 /* Return -1 to allow the default handlers to return. */ | |
6022 return TRUE; | |
6023 } | |
6024 #else | |
6025 int test_callback(HWND window, void *data) | |
6026 { | |
6027 dw_window_destroy((HWND)data); | |
6028 /* Return -1 to allow the default handlers to return. */ | |
6029 count--; | |
6030 if(!count) | |
6031 exit(0); | |
6032 return -1; | |
6033 } | |
6034 #endif | |
6035 | |
6036 /* | |
6037 * Let's demonstrate the functionality of this library. :) | |
6038 */ | |
6039 int main(void) | |
6040 { | |
6041 ULONG flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | | |
6042 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; | |
6043 int pageid; | |
6044 | |
6045 dw_init(TRUE); | |
6046 | |
6047 /* Try a little server dialog. :) */ | |
6048 mainwindow = dw_window_new(HWND_DESKTOP, "Server", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX); | |
6049 | |
6050 lbbox = dw_box_new(BOXVERT, 10); | |
6051 | |
6052 dw_box_pack_start(mainwindow, lbbox, 0, 0, TRUE, TRUE, 0); | |
6053 | |
6054 stext = dw_text_new("Choose a server:", 0); | |
6055 | |
6056 dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER); | |
6057 | |
6058 dw_box_pack_start(lbbox, stext, 130, 15, FALSE, FALSE, 10); | |
6059 | |
6060 listbox = dw_listbox_new(100L, FALSE); | |
6061 | |
6062 dw_box_pack_start(lbbox, listbox, 130, 200, TRUE, TRUE, 10); | |
6063 | |
6064 buttonbox = dw_box_new(BOXHORZ, 0); | |
6065 | |
6066 dw_box_pack_start(lbbox, buttonbox, 0, 0, TRUE, TRUE, 0); | |
6067 | |
6068 okbutton = dw_button_new("Ok", 1001L); | |
6069 | |
6070 dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, TRUE, 5); | |
6071 | |
6072 cancelbutton = dw_button_new("Cancel", 1002L); | |
6073 | |
6074 dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, TRUE, 5); | |
6075 | |
6076 /* Set some nice fonts and colors */ | |
6077 dw_window_set_color(lbbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); | |
6078 dw_window_set_color(buttonbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); | |
6079 dw_window_set_font(stext, "9.WarpSans"); | |
6080 dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY); | |
6081 dw_window_set_font(listbox, "9.WarpSans"); | |
6082 dw_window_set_font(okbutton, "9.WarpSans"); | |
6083 dw_window_set_font(cancelbutton, "9.WarpSans"); | |
6084 | |
6085 dw_window_show(mainwindow); | |
6086 | |
6087 dw_window_set_usize(mainwindow, 170, 340); | |
6088 | |
6089 /* Another small example */ | |
6090 flStyle |= FCF_MINMAX | FCF_SIZEBORDER; | |
6091 | |
6092 testwindow = dw_window_new(HWND_DESKTOP, "Wow a test dialog! :) yay!", flStyle); | |
6093 | |
6094 testbox = dw_box_new(BOXVERT, 0); | |
6095 | |
6096 dw_box_pack_start(testwindow, testbox, 0, 0, TRUE, TRUE, 0); | |
6097 | |
6098 notebook = dw_notebook_new(1010L, TRUE); | |
6099 | |
6100 dw_box_pack_start(testbox, notebook, 100, 100, TRUE, TRUE, 0); | |
6101 | |
6102 testbox = dw_box_new(BOXVERT, 10); | |
6103 | |
6104 pageid = dw_notebook_page_new(notebook, 0L, FALSE); | |
6105 | |
6106 dw_notebook_page_set_text(notebook, pageid, "Test page"); | |
6107 dw_notebook_page_set_status_text(notebook, pageid, "Test page"); | |
6108 | |
6109 dw_notebook_pack(notebook, pageid, testbox); | |
6110 | |
6111 testok = dw_button_new("Ok", 1003L); | |
6112 | |
6113 dw_box_pack_start(testbox, testok, 60, 40, TRUE, TRUE, 10); | |
6114 | |
6115 testcancel = dw_button_new("Cancel", 1004L); | |
6116 | |
6117 dw_box_pack_start(testbox, testcancel, 60, 40, TRUE, TRUE, 10); | |
6118 | |
6119 testbox2 = dw_box_new(BOXHORZ, 0); | |
6120 | |
6121 dw_box_pack_start(testbox, testbox2, 0, 0, TRUE, TRUE, 0); | |
6122 | |
6123 testok2 = dw_button_new("Ok", 1003L); | |
6124 | |
6125 dw_box_pack_start(testbox2, testok2, 60, 40, TRUE, TRUE, 10); | |
6126 | |
6127 dw_box_pack_splitbar_start(testbox2); | |
6128 | |
6129 testcancel2 = dw_button_new("Cancel", 1004L); | |
6130 | |
6131 dw_box_pack_start(testbox2, testcancel2, 60, 40, TRUE, TRUE, 10); | |
6132 | |
6133 /* Set some nice fonts and colors */ | |
6134 dw_window_set_color(testbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); | |
6135 dw_window_set_color(testbox2, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); | |
6136 dw_window_set_font(testok, "9.WarpSans"); | |
6137 dw_window_set_font(testcancel, "9.WarpSans"); | |
6138 dw_window_set_font(testok2, "9.WarpSans"); | |
6139 dw_window_set_font(testcancel2, "9.WarpSans"); | |
6140 | |
6141 dw_window_show(testwindow); | |
6142 | |
6143 #ifdef USE_FILTER | |
6144 dw_main(0L, (void *)testfilter); | |
6145 #else | |
6146 /* Setup the function callbacks */ | |
6147 dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); | |
6148 dw_signal_connect(cancelbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); | |
6149 dw_signal_connect(testok, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
6150 dw_signal_connect(testcancel, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
6151 dw_signal_connect(testok2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
6152 dw_signal_connect(testcancel2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
6153 dw_signal_connect(mainwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); | |
6154 dw_signal_connect(testwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); | |
6155 | |
6156 dw_main(0L, NULL); | |
6157 #endif | |
6158 | |
6159 return 0; | |
6160 } | |
6161 #endif |