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