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