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