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