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