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