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