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