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