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