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