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