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