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