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