comparison mac/dw.c @ 639:06be879f5137

Support for building with GTK+ on Mac OSX
author mhessling@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 12 Apr 2009 01:12:04 +0000
parents c5e5671dec8f
children
comparison
equal deleted inserted replaced
638:3ce487327afd 639:06be879f5137
9 9
10 static void _do_resize(Box *thisbox, int x, int y); 10 static void _do_resize(Box *thisbox, int x, int y);
11 11
12 typedef struct _sighandler 12 typedef struct _sighandler
13 { 13 {
14 struct _sighandler *next; 14 struct _sighandler *next;
15 ULONG message; 15 ULONG message;
16 HWND window; 16 HWND window;
17 int id; 17 int id;
18 void *signalfunction; 18 void *signalfunction;
19 void *data; 19 void *data;
20 20
21 } SignalHandler; 21 } SignalHandler;
22 22
23 SignalHandler *Root = NULL; 23 SignalHandler *Root = NULL;
24 24
25 typedef struct 25 typedef struct
26 { 26 {
27 ULONG message; 27 ULONG message;
28 char name[30]; 28 char name[30];
29 29
30 } SignalList; 30 } SignalList;
31 31
32 const Rect CreationRect = { 0, 0, 2000, 1000 }; 32 const Rect CreationRect = { 0, 0, 2000, 1000 };
33 WindowRef CreationWindow = 0; 33 WindowRef CreationWindow = 0;
36 36
37 /* List of signals and their equivilent MacOS event */ 37 /* List of signals and their equivilent MacOS event */
38 #define SIGNALMAX 15 38 #define SIGNALMAX 15
39 39
40 SignalList SignalTranslate[SIGNALMAX] = { 40 SignalList SignalTranslate[SIGNALMAX] = {
41 { nullEvent, DW_SIGNAL_CONFIGURE }, 41 { nullEvent, DW_SIGNAL_CONFIGURE },
42 { keyUp, DW_SIGNAL_KEY_PRESS }, 42 { keyUp, DW_SIGNAL_KEY_PRESS },
43 { mouseDown, DW_SIGNAL_BUTTON_PRESS }, 43 { mouseDown, DW_SIGNAL_BUTTON_PRESS },
44 { mouseUp, DW_SIGNAL_BUTTON_RELEASE }, 44 { mouseUp, DW_SIGNAL_BUTTON_RELEASE },
45 { nullEvent, DW_SIGNAL_MOTION_NOTIFY }, 45 { nullEvent, DW_SIGNAL_MOTION_NOTIFY },
46 { nullEvent, DW_SIGNAL_DELETE }, 46 { nullEvent, DW_SIGNAL_DELETE },
47 { updateEvt, DW_SIGNAL_EXPOSE }, 47 { updateEvt, DW_SIGNAL_EXPOSE },
48 { nullEvent, DW_SIGNAL_CLICKED }, 48 { nullEvent, DW_SIGNAL_CLICKED },
49 { nullEvent, DW_SIGNAL_ITEM_ENTER }, 49 { nullEvent, DW_SIGNAL_ITEM_ENTER },
50 { nullEvent, DW_SIGNAL_ITEM_CONTEXT }, 50 { nullEvent, DW_SIGNAL_ITEM_CONTEXT },
51 { nullEvent, DW_SIGNAL_LIST_SELECT }, 51 { nullEvent, DW_SIGNAL_LIST_SELECT },
52 { nullEvent, DW_SIGNAL_ITEM_SELECT }, 52 { nullEvent, DW_SIGNAL_ITEM_SELECT },
53 { activateEvt, DW_SIGNAL_SET_FOCUS }, 53 { activateEvt, DW_SIGNAL_SET_FOCUS },
54 { nullEvent, DW_SIGNAL_VALUE_CHANGED }, 54 { nullEvent, DW_SIGNAL_VALUE_CHANGED },
55 { nullEvent, DW_SIGNAL_SWITCH_PAGE } 55 { nullEvent, DW_SIGNAL_SWITCH_PAGE }
56 }; 56 };
57 57
58 /* This function adds a signal handler callback into the linked list. 58 /* This function adds a signal handler callback into the linked list.
59 */ 59 */
60 void _new_signal(ULONG message, HWND window, int id, void *signalfunction, void *data) 60 void _new_signal(ULONG message, HWND window, int id, void *signalfunction, void *data)
61 { 61 {
62 SignalHandler *new = malloc(sizeof(SignalHandler)); 62 SignalHandler *new = malloc(sizeof(SignalHandler));
63 63
64 new->message = message; 64 new->message = message;
65 new->window = window; 65 new->window = window;
66 new->id = id; 66 new->id = id;
67 new->signalfunction = signalfunction; 67 new->signalfunction = signalfunction;
68 new->data = data; 68 new->data = data;
69 new->next = NULL; 69 new->next = NULL;
70 70
71 if (!Root) 71 if (!Root)
72 Root = new; 72 Root = new;
73 else 73 else
74 { 74 {
75 SignalHandler *prev = NULL, *tmp = Root; 75 SignalHandler *prev = NULL, *tmp = Root;
76 while(tmp) 76 while(tmp)
77 { 77 {
78 if(tmp->message == message && 78 if(tmp->message == message &&
79 tmp->window == window && 79 tmp->window == window &&
80 tmp->signalfunction == signalfunction) 80 tmp->signalfunction == signalfunction)
81 { 81 {
82 tmp->data = data; 82 tmp->data = data;
83 free(new); 83 free(new);
84 return; 84 return;
85 } 85 }
86 prev = tmp; 86 prev = tmp;
87 tmp = tmp->next; 87 tmp = tmp->next;
88 } 88 }
89 if(prev) 89 if(prev)
90 prev->next = new; 90 prev->next = new;
91 else 91 else
92 Root = new; 92 Root = new;
93 } 93 }
94 } 94 }
95 95
96 /* Finds the message number for a given signal name */ 96 /* Finds the message number for a given signal name */
97 static ULONG _findsigmessage(char *signame) 97 static ULONG _findsigmessage(char *signame)
98 { 98 {
99 int z; 99 int z;
100 100
101 for(z=0;z<SIGNALMAX;z++) 101 for(z=0;z<SIGNALMAX;z++)
102 { 102 {
103 if(strcasecmp(signame, SignalTranslate[z].name) == 0) 103 if(strcasecmp(signame, SignalTranslate[z].name) == 0)
104 return SignalTranslate[z].message; 104 return SignalTranslate[z].message;
105 } 105 }
106 return 0L; 106 return 0L;
107 } 107 }
108 108
109 /* Creates a Pascal string from a C string */ 109 /* Creates a Pascal string from a C string */
110 char *_CToPascal(unsigned char *ptr, char *cstring) 110 char *_CToPascal(unsigned char *ptr, char *cstring)
111 { 111 {
112 unsigned char len = (char)strlen(cstring); 112 unsigned char len = (char)strlen(cstring);
113 113
114 ptr[0] = len; 114 ptr[0] = len;
115 memcpy(&ptr[1], cstring, len+1); 115 memcpy(&ptr[1], cstring, len+1);
116 return (char *)ptr; 116 return (char *)ptr;
117 } 117 }
118 118
119 #define CToPascal(a) _CToPascal(alloca(strlen(a)+2), a) 119 #define CToPascal(a) _CToPascal(alloca(strlen(a)+2), a)
120 120
121 static void *_get_window_pointer(HWND handle) 121 static void *_get_window_pointer(HWND handle)
122 { 122 {
123 void *ret = NULL; 123 void *ret = NULL;
124 124
125 if(IsValidWindowRef((WindowRef)handle)) 125 if(IsValidWindowRef((WindowRef)handle))
126 GetWindowProperty((WindowRef)handle, 0, 'user', sizeof(void *), NULL, &ret); 126 GetWindowProperty((WindowRef)handle, 0, 'user', sizeof(void *), NULL, &ret);
127 else 127 else
128 GetControlProperty(handle, 0, 'user', sizeof(void *), NULL, &ret); 128 GetControlProperty(handle, 0, 'user', sizeof(void *), NULL, &ret);
129 return ret; 129 return ret;
130 } 130 }
131 131
132 static void _set_window_pointer(HWND handle, void *pointer) 132 static void _set_window_pointer(HWND handle, void *pointer)
133 { 133 {
134 if(IsValidWindowRef((WindowRef)handle)) 134 if(IsValidWindowRef((WindowRef)handle))
135 SetWindowProperty((WindowRef)handle, 0, 'user', sizeof(void *), &pointer); 135 SetWindowProperty((WindowRef)handle, 0, 'user', sizeof(void *), &pointer);
136 else 136 else
137 SetControlProperty(handle, 0, 'user', sizeof(void *), &pointer); 137 SetControlProperty(handle, 0, 'user', sizeof(void *), &pointer);
138 } 138 }
139 139
140 /* This function will recursively search a box and add up the total height of it */ 140 /* This function will recursively search a box and add up the total height of it */
141 static void _count_size(HWND box, int type, int *xsize, int *xorigsize) 141 static void _count_size(HWND box, int type, int *xsize, int *xorigsize)
142 { 142 {
143 int size = 0, origsize = 0, z; 143 int size = 0, origsize = 0, z;
144 Box *tmp = _get_window_pointer(box); 144 Box *tmp = _get_window_pointer(box);
145 145
146 if(!tmp) 146 if(!tmp)
147 { 147 {
148 *xsize = *xorigsize = 0; 148 *xsize = *xorigsize = 0;
149 return; 149 return;
150 } 150 }
151 151
152 if(type == tmp->type) 152 if(type == tmp->type)
153 { 153 {
154 /* If the box is going in the direction we want, then we 154 /* If the box is going in the direction we want, then we
155 * return the entire sum of the items. 155 * return the entire sum of the items.
156 */ 156 */
157 for(z=0;z<tmp->count;z++) 157 for(z=0;z<tmp->count;z++)
158 { 158 {
159 if(tmp->items[z].type == TYPEBOX) 159 if(tmp->items[z].type == TYPEBOX)
160 { 160 {
161 int s, os; 161 int s, os;
162 162
163 _count_size(tmp->items[z].hwnd, type, &s, &os); 163 _count_size(tmp->items[z].hwnd, type, &s, &os);
164 size += s; 164 size += s;
165 origsize += os; 165 origsize += os;
166 } 166 }
167 else 167 else
168 { 168 {
169 size += (type == DW_HORZ ? tmp->items[z].width : tmp->items[z].height); 169 size += (type == DW_HORZ ? tmp->items[z].width : tmp->items[z].height);
170 origsize += (type == DW_HORZ ? tmp->items[z].origwidth : tmp->items[z].origheight); 170 origsize += (type == DW_HORZ ? tmp->items[z].origwidth : tmp->items[z].origheight);
171 } 171 }
172 } 172 }
173 } 173 }
174 else 174 else
175 { 175 {
176 /* If the box is not going in the direction we want, then we only 176 /* If the box is not going in the direction we want, then we only
177 * want to return the maximum value. 177 * want to return the maximum value.
178 */ 178 */
179 int tmpsize = 0, tmporigsize = 0; 179 int tmpsize = 0, tmporigsize = 0;
180 180
181 for(z=0;z<tmp->count;z++) 181 for(z=0;z<tmp->count;z++)
182 { 182 {
183 if(tmp->items[z].type == TYPEBOX) 183 if(tmp->items[z].type == TYPEBOX)
184 _count_size(tmp->items[z].hwnd, type, &tmpsize, &tmporigsize); 184 _count_size(tmp->items[z].hwnd, type, &tmpsize, &tmporigsize);
185 else 185 else
186 { 186 {
187 tmpsize = (type == DW_HORZ ? tmp->items[z].width : tmp->items[z].height); 187 tmpsize = (type == DW_HORZ ? tmp->items[z].width : tmp->items[z].height);
188 tmporigsize = (type == DW_HORZ ? tmp->items[z].origwidth : tmp->items[z].origheight); 188 tmporigsize = (type == DW_HORZ ? tmp->items[z].origwidth : tmp->items[z].origheight);
189 } 189 }
190 190
191 if(tmpsize > size) 191 if(tmpsize > size)
192 size = tmpsize; 192 size = tmpsize;
193 } 193 }
194 } 194 }
195 195
196 *xsize = size; 196 *xsize = size;
197 *xorigsize = origsize; 197 *xorigsize = origsize;
198 } 198 }
199 199
200 /* This function calculates how much space the widgets and boxes require 200 /* This function calculates how much space the widgets and boxes require
201 * and does expansion as necessary. 201 * and does expansion as necessary.
202 */ 202 */
203 static int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy, 203 static int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy,
204 int pass, int *usedpadx, int *usedpady) 204 int pass, int *usedpadx, int *usedpady)
205 { 205 {
206 int z, currentx = 0, currenty = 0; 206 int z, currentx = 0, currenty = 0;
207 int uymax = 0, uxmax = 0; 207 int uymax = 0, uxmax = 0;
208 int upymax = 0, upxmax = 0; 208 int upymax = 0, upxmax = 0;
209 /* Used for the SIZEEXPAND */ 209 /* Used for the SIZEEXPAND */
210 int nux = *usedx, nuy = *usedy; 210 int nux = *usedx, nuy = *usedy;
211 int nupx = *usedpadx, nupy = *usedpady; 211 int nupx = *usedpadx, nupy = *usedpady;
212 212
213 (*usedx) += (thisbox->pad * 2); 213 (*usedx) += (thisbox->pad * 2);
214 (*usedy) += (thisbox->pad * 2); 214 (*usedy) += (thisbox->pad * 2);
215 215
216 for(z=0;z<thisbox->count;z++) 216 for(z=0;z<thisbox->count;z++)
217 { 217 {
218 if(thisbox->items[z].type == TYPEBOX) 218 if(thisbox->items[z].type == TYPEBOX)
219 { 219 {
220 int initialx, initialy; 220 int initialx, initialy;
221 Box *tmp = _get_window_pointer(thisbox->items[z].hwnd); 221 Box *tmp = _get_window_pointer(thisbox->items[z].hwnd);
222 222
223 initialx = x - (*usedx); 223 initialx = x - (*usedx);
224 initialy = y - (*usedy); 224 initialy = y - (*usedy);
225 225
226 if(tmp) 226 if(tmp)
227 { 227 {
228 int newx, newy; 228 int newx, newy;
229 int nux = *usedx, nuy = *usedy; 229 int nux = *usedx, nuy = *usedy;
230 int upx = *usedpadx + (tmp->pad*2), upy = *usedpady + (tmp->pad*2); 230 int upx = *usedpadx + (tmp->pad*2), upy = *usedpady + (tmp->pad*2);
231 231
232 /* On the second pass we know how big the box needs to be and how 232 /* On the second pass we know how big the box needs to be and how
233 * much space we have, so we can calculate a ratio for the new box. 233 * much space we have, so we can calculate a ratio for the new box.
234 */ 234 */
235 if(pass == 2) 235 if(pass == 2)
236 { 236 {
237 int deep = *depth + 1; 237 int deep = *depth + 1;
238 238
239 _resize_box(tmp, &deep, x, y, &nux, &nuy, 1, &upx, &upy); 239 _resize_box(tmp, &deep, x, y, &nux, &nuy, 1, &upx, &upy);
240 240
241 tmp->upx = upx - *usedpadx; 241 tmp->upx = upx - *usedpadx;
242 tmp->upy = upy - *usedpady; 242 tmp->upy = upy - *usedpady;
243 243
244 newx = x - nux; 244 newx = x - nux;
245 newy = y - nuy; 245 newy = y - nuy;
246 246
247 tmp->width = thisbox->items[z].width = initialx - newx; 247 tmp->width = thisbox->items[z].width = initialx - newx;
248 tmp->height = thisbox->items[z].height = initialy - newy; 248 tmp->height = thisbox->items[z].height = initialy - newy;
249 249
250 tmp->parentxratio = thisbox->xratio; 250 tmp->parentxratio = thisbox->xratio;
251 tmp->parentyratio = thisbox->yratio; 251 tmp->parentyratio = thisbox->yratio;
252 252
253 tmp->parentpad = tmp->pad; 253 tmp->parentpad = tmp->pad;
254 254
255 /* Just in case */ 255 /* Just in case */
256 tmp->xratio = thisbox->xratio; 256 tmp->xratio = thisbox->xratio;
257 tmp->yratio = thisbox->yratio; 257 tmp->yratio = thisbox->yratio;
258 258
259 if(thisbox->type == DW_VERT) 259 if(thisbox->type == DW_VERT)
260 { 260 {
261 if((thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) 261 if((thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0)
262 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)))); 262 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))));
263 } 263 }
264 else 264 else
265 { 265 {
266 if((thisbox->items[z].width-tmp->upx)!=0) 266 if((thisbox->items[z].width-tmp->upx)!=0)
267 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx)); 267 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx));
268 } 268 }
269 if(thisbox->type == DW_HORZ) 269 if(thisbox->type == DW_HORZ)
270 { 270 {
271 if((thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) 271 if((thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0)
272 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)))); 272 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))));
273 } 273 }
274 else 274 else
275 { 275 {
276 if((thisbox->items[z].height-tmp->upy)!=0) 276 if((thisbox->items[z].height-tmp->upy)!=0)
277 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy)); 277 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy));
278 } 278 }
279 279
280 nux = *usedx; nuy = *usedy; 280 nux = *usedx; nuy = *usedy;
281 upx = *usedpadx + (tmp->pad*2); upy = *usedpady + (tmp->pad*2); 281 upx = *usedpadx + (tmp->pad*2); upy = *usedpady + (tmp->pad*2);
282 } 282 }
283 283
284 (*depth)++; 284 (*depth)++;
285 285
286 _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &upx, &upy); 286 _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &upx, &upy);
287 287
288 (*depth)--; 288 (*depth)--;
289 289
290 newx = x - nux; 290 newx = x - nux;
291 newy = y - nuy; 291 newy = y - nuy;
292 292
293 tmp->minwidth = thisbox->items[z].width = initialx - newx; 293 tmp->minwidth = thisbox->items[z].width = initialx - newx;
294 tmp->minheight = thisbox->items[z].height = initialy - newy; 294 tmp->minheight = thisbox->items[z].height = initialy - newy;
295 } 295 }
296 } 296 }
297 297
298 if(pass > 1 && *depth > 0) 298 if(pass > 1 && *depth > 0)
299 { 299 {
300 if(thisbox->type == DW_VERT) 300 if(thisbox->type == DW_VERT)
301 { 301 {
302 if((thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0) 302 if((thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0)
303 thisbox->items[z].xratio = 1.0; 303 thisbox->items[z].xratio = 1.0;
304 else 304 else
305 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)))); 305 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))));
306 } 306 }
307 else 307 else
308 { 308 {
309 if(thisbox->minwidth-thisbox->upx == 0) 309 if(thisbox->minwidth-thisbox->upx == 0)
310 thisbox->items[z].xratio = 1.0; 310 thisbox->items[z].xratio = 1.0;
311 else 311 else
312 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx)); 312 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx));
313 } 313 }
314 314
315 if(thisbox->type == DW_HORZ) 315 if(thisbox->type == DW_HORZ)
316 { 316 {
317 if((thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0) 317 if((thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0)
318 thisbox->items[z].yratio = 1.0; 318 thisbox->items[z].yratio = 1.0;
319 else 319 else
320 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)))); 320 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))));
321 } 321 }
322 else 322 else
323 { 323 {
324 if(thisbox->minheight-thisbox->upy == 0) 324 if(thisbox->minheight-thisbox->upy == 0)
325 thisbox->items[z].yratio = 1.0; 325 thisbox->items[z].yratio = 1.0;
326 else 326 else
327 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy)); 327 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy));
328 } 328 }
329 329
330 if(thisbox->items[z].type == TYPEBOX) 330 if(thisbox->items[z].type == TYPEBOX)
331 { 331 {
332 Box *tmp = _get_window_pointer(thisbox->items[z].hwnd); 332 Box *tmp = _get_window_pointer(thisbox->items[z].hwnd);
333 333
334 if(tmp) 334 if(tmp)
335 { 335 {
336 tmp->parentxratio = thisbox->items[z].xratio; 336 tmp->parentxratio = thisbox->items[z].xratio;
337 tmp->parentyratio = thisbox->items[z].yratio; 337 tmp->parentyratio = thisbox->items[z].yratio;
338 } 338 }
339 } 339 }
340 } 340 }
341 else 341 else
342 { 342 {
343 thisbox->items[z].xratio = thisbox->xratio; 343 thisbox->items[z].xratio = thisbox->xratio;
344 thisbox->items[z].yratio = thisbox->yratio; 344 thisbox->items[z].yratio = thisbox->yratio;
345 } 345 }
346 346
347 if(thisbox->type == DW_VERT) 347 if(thisbox->type == DW_VERT)
348 { 348 {
349 if((thisbox->items[z].width + (thisbox->items[z].pad*2)) > uxmax) 349 if((thisbox->items[z].width + (thisbox->items[z].pad*2)) > uxmax)
350 uxmax = (thisbox->items[z].width + (thisbox->items[z].pad*2)); 350 uxmax = (thisbox->items[z].width + (thisbox->items[z].pad*2));
351 if(thisbox->items[z].hsize != SIZEEXPAND) 351 if(thisbox->items[z].hsize != SIZEEXPAND)
352 { 352 {
353 if(((thisbox->items[z].pad*2) + thisbox->items[z].width) > upxmax) 353 if(((thisbox->items[z].pad*2) + thisbox->items[z].width) > upxmax)
354 upxmax = (thisbox->items[z].pad*2) + thisbox->items[z].width; 354 upxmax = (thisbox->items[z].pad*2) + thisbox->items[z].width;
355 } 355 }
356 else 356 else
357 { 357 {
358 if(thisbox->items[z].pad*2 > upxmax) 358 if(thisbox->items[z].pad*2 > upxmax)
359 upxmax = thisbox->items[z].pad*2; 359 upxmax = thisbox->items[z].pad*2;
360 } 360 }
361 } 361 }
362 else 362 else
363 { 363 {
364 if(thisbox->items[z].width == -1) 364 if(thisbox->items[z].width == -1)
365 { 365 {
366 /* figure out how much space this item requires */ 366 /* figure out how much space this item requires */
367 /* thisbox->items[z].width = */ 367 /* thisbox->items[z].width = */
368 } 368 }
369 else 369 else
370 { 370 {
371 (*usedx) += thisbox->items[z].width + (thisbox->items[z].pad*2); 371 (*usedx) += thisbox->items[z].width + (thisbox->items[z].pad*2);
372 if(thisbox->items[z].hsize != SIZEEXPAND) 372 if(thisbox->items[z].hsize != SIZEEXPAND)
373 (*usedpadx) += (thisbox->items[z].pad*2) + thisbox->items[z].width; 373 (*usedpadx) += (thisbox->items[z].pad*2) + thisbox->items[z].width;
374 else 374 else
375 (*usedpadx) += thisbox->items[z].pad*2; 375 (*usedpadx) += thisbox->items[z].pad*2;
376 } 376 }
377 } 377 }
378 if(thisbox->type == DW_HORZ) 378 if(thisbox->type == DW_HORZ)
379 { 379 {
380 if((thisbox->items[z].height + (thisbox->items[z].pad*2)) > uymax) 380 if((thisbox->items[z].height + (thisbox->items[z].pad*2)) > uymax)
381 uymax = (thisbox->items[z].height + (thisbox->items[z].pad*2)); 381 uymax = (thisbox->items[z].height + (thisbox->items[z].pad*2));
382 if(thisbox->items[z].vsize != SIZEEXPAND) 382 if(thisbox->items[z].vsize != SIZEEXPAND)
383 { 383 {
384 if(((thisbox->items[z].pad*2) + thisbox->items[z].height) > upymax) 384 if(((thisbox->items[z].pad*2) + thisbox->items[z].height) > upymax)
385 upymax = (thisbox->items[z].pad*2) + thisbox->items[z].height; 385 upymax = (thisbox->items[z].pad*2) + thisbox->items[z].height;
386 } 386 }
387 else 387 else
388 { 388 {
389 if(thisbox->items[z].pad*2 > upymax) 389 if(thisbox->items[z].pad*2 > upymax)
390 upymax = thisbox->items[z].pad*2; 390 upymax = thisbox->items[z].pad*2;
391 } 391 }
392 } 392 }
393 else 393 else
394 { 394 {
395 if(thisbox->items[z].height == -1) 395 if(thisbox->items[z].height == -1)
396 { 396 {
397 /* figure out how much space this item requires */ 397 /* figure out how much space this item requires */
398 /* thisbox->items[z].height = */ 398 /* thisbox->items[z].height = */
399 } 399 }
400 else 400 else
401 { 401 {
402 (*usedy) += thisbox->items[z].height + (thisbox->items[z].pad*2); 402 (*usedy) += thisbox->items[z].height + (thisbox->items[z].pad*2);
403 if(thisbox->items[z].vsize != SIZEEXPAND) 403 if(thisbox->items[z].vsize != SIZEEXPAND)
404 (*usedpady) += (thisbox->items[z].pad*2) + thisbox->items[z].height; 404 (*usedpady) += (thisbox->items[z].pad*2) + thisbox->items[z].height;
405 else 405 else
406 (*usedpady) += thisbox->items[z].pad*2; 406 (*usedpady) += thisbox->items[z].pad*2;
407 } 407 }
408 } 408 }
409 } 409 }
410 410
411 (*usedx) += uxmax; 411 (*usedx) += uxmax;
412 (*usedy) += uymax; 412 (*usedy) += uymax;
413 (*usedpadx) += upxmax; 413 (*usedpadx) += upxmax;
414 (*usedpady) += upymax; 414 (*usedpady) += upymax;
415 415
416 currentx += thisbox->pad; 416 currentx += thisbox->pad;
417 currenty += thisbox->pad; 417 currenty += thisbox->pad;
418 418
419 /* The second pass is for expansion and actual placement. */ 419 /* The second pass is for expansion and actual placement. */
420 if(pass > 1) 420 if(pass > 1)
421 { 421 {
422 /* Any SIZEEXPAND items should be set to uxmax/uymax */ 422 /* Any SIZEEXPAND items should be set to uxmax/uymax */
423 for(z=0;z<thisbox->count;z++) 423 for(z=0;z<thisbox->count;z++)
424 { 424 {
425 if(thisbox->items[z].hsize == SIZEEXPAND && thisbox->type == DW_VERT) 425 if(thisbox->items[z].hsize == SIZEEXPAND && thisbox->type == DW_VERT)
426 thisbox->items[z].width = uxmax-(thisbox->items[z].pad*2); 426 thisbox->items[z].width = uxmax-(thisbox->items[z].pad*2);
427 if(thisbox->items[z].vsize == SIZEEXPAND && thisbox->type == DW_HORZ) 427 if(thisbox->items[z].vsize == SIZEEXPAND && thisbox->type == DW_HORZ)
428 thisbox->items[z].height = uymax-(thisbox->items[z].pad*2); 428 thisbox->items[z].height = uymax-(thisbox->items[z].pad*2);
429 /* Run this code segment again to finalize the sized after setting uxmax/uymax values. */ 429 /* Run this code segment again to finalize the sized after setting uxmax/uymax values. */
430 if(thisbox->items[z].type == TYPEBOX) 430 if(thisbox->items[z].type == TYPEBOX)
431 { 431 {
432 Box *tmp = _get_window_pointer(thisbox->items[z].hwnd); 432 Box *tmp = _get_window_pointer(thisbox->items[z].hwnd);
433 433
434 if(tmp) 434 if(tmp)
435 { 435 {
436 if(*depth > 0) 436 if(*depth > 0)
437 { 437 {
438 float calcval; 438 float calcval;
439 439
440 if(thisbox->type == DW_VERT) 440 if(thisbox->type == DW_VERT)
441 { 441 {
442 calcval = (float)(tmp->minwidth-((thisbox->items[z].pad*2)+(thisbox->pad*2))); 442 calcval = (float)(tmp->minwidth-((thisbox->items[z].pad*2)+(thisbox->pad*2)));
443 if(calcval == 0.0) 443 if(calcval == 0.0)
444 tmp->xratio = thisbox->xratio; 444 tmp->xratio = thisbox->xratio;
445 else 445 else
446 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/calcval; 446 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/calcval;
447 tmp->width = thisbox->items[z].width; 447 tmp->width = thisbox->items[z].width;
448 } 448 }
449 if(thisbox->type == DW_HORZ) 449 if(thisbox->type == DW_HORZ)
450 { 450 {
451 calcval = (float)(tmp->minheight-((thisbox->items[z].pad*2)+(thisbox->pad*2))); 451 calcval = (float)(tmp->minheight-((thisbox->items[z].pad*2)+(thisbox->pad*2)));
452 if(calcval == 0.0) 452 if(calcval == 0.0)
453 tmp->yratio = thisbox->yratio; 453 tmp->yratio = thisbox->yratio;
454 else 454 else
455 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/calcval; 455 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/calcval;
456 tmp->height = thisbox->items[z].height; 456 tmp->height = thisbox->items[z].height;
457 } 457 }
458 } 458 }
459 459
460 (*depth)++; 460 (*depth)++;
461 461
462 _resize_box(tmp, depth, x, y, &nux, &nuy, 3, &nupx, &nupy); 462 _resize_box(tmp, depth, x, y, &nux, &nuy, 3, &nupx, &nupy);
463 463
464 (*depth)--; 464 (*depth)--;
465 465
466 } 466 }
467 } 467 }
468 } 468 }
469 469
470 for(z=0;z<(thisbox->count);z++) 470 for(z=0;z<(thisbox->count);z++)
471 { 471 {
472 int height = thisbox->items[z].height; 472 int height = thisbox->items[z].height;
473 int width = thisbox->items[z].width; 473 int width = thisbox->items[z].width;
474 int pad = thisbox->items[z].pad; 474 int pad = thisbox->items[z].pad;
475 HWND handle = thisbox->items[z].hwnd; 475 HWND handle = thisbox->items[z].hwnd;
476 int vectorx, vectory; 476 int vectorx, vectory;
477 477
478 /* When upxmax != pad*2 then ratios are incorrect. */ 478 /* When upxmax != pad*2 then ratios are incorrect. */
479 vectorx = (int)((width*thisbox->items[z].xratio)-width); 479 vectorx = (int)((width*thisbox->items[z].xratio)-width);
480 vectory = (int)((height*thisbox->items[z].yratio)-height); 480 vectory = (int)((height*thisbox->items[z].yratio)-height);
481 481
482 if(width > 0 && height > 0) 482 if(width > 0 && height > 0)
483 { 483 {
484 /* This is a hack to fix rounding of the sizing */ 484 /* This is a hack to fix rounding of the sizing */
485 if(*depth == 0) 485 if(*depth == 0)
486 { 486 {
487 vectorx++; 487 vectorx++;
488 vectory++; 488 vectory++;
489 } 489 }
490 490
491 /* If this item isn't going to expand... reset the vectors to 0 */ 491 /* If this item isn't going to expand... reset the vectors to 0 */
492 if(thisbox->items[z].vsize != SIZEEXPAND) 492 if(thisbox->items[z].vsize != SIZEEXPAND)
493 vectory = 0; 493 vectory = 0;
494 if(thisbox->items[z].hsize != SIZEEXPAND) 494 if(thisbox->items[z].hsize != SIZEEXPAND)
495 vectorx = 0; 495 vectorx = 0;
496 496
497 MoveControl(handle, currentx + pad, currenty + pad); 497 MoveControl(handle, currentx + pad, currenty + pad);
498 SizeControl(handle, width + vectorx, height + vectory); 498 SizeControl(handle, width + vectorx, height + vectory);
499 499
500 if(thisbox->type == DW_HORZ) 500 if(thisbox->type == DW_HORZ)
501 currentx += width + vectorx + (pad * 2); 501 currentx += width + vectorx + (pad * 2);
502 if(thisbox->type == DW_VERT) 502 if(thisbox->type == DW_VERT)
503 currenty += height + vectory + (pad * 2); 503 currenty += height + vectory + (pad * 2);
504 } 504 }
505 } 505 }
506 } 506 }
507 return 0; 507 return 0;
508 } 508 }
509 509
510 static void _do_resize(Box *thisbox, int x, int y) 510 static void _do_resize(Box *thisbox, int x, int y)
511 { 511 {
512 if(x != 0 && y != 0) 512 if(x != 0 && y != 0)
513 { 513 {
514 if(thisbox) 514 if(thisbox)
515 { 515 {
516 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0; 516 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0;
517 517
518 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady); 518 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady);
519 519
520 if(usedx-usedpadx == 0 || usedy-usedpady == 0) 520 if(usedx-usedpadx == 0 || usedy-usedpady == 0)
521 return; 521 return;
522 522
523 thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx)); 523 thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx));
524 thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady)); 524 thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady));
525 525
526 usedx = usedy = usedpadx = usedpady = depth = 0; 526 usedx = usedy = usedpadx = usedpady = depth = 0;
527 527
528 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady); 528 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady);
529 } 529 }
530 } 530 }
531 } 531 }
532 532
533 static void _changebox(Box *thisbox, int percent, int type) 533 static void _changebox(Box *thisbox, int percent, int type)
534 { 534 {
535 int z; 535 int z;
536 536
537 for(z=0;z<thisbox->count;z++) 537 for(z=0;z<thisbox->count;z++)
538 { 538 {
539 if(thisbox->items[z].type == TYPEBOX) 539 if(thisbox->items[z].type == TYPEBOX)
540 { 540 {
541 Box *tmp = _get_window_pointer(thisbox->items[z].hwnd); 541 Box *tmp = _get_window_pointer(thisbox->items[z].hwnd);
542 _changebox(tmp, percent, type); 542 _changebox(tmp, percent, type);
543 } 543 }
544 else 544 else
545 { 545 {
546 if(type == DW_HORZ) 546 if(type == DW_HORZ)
547 { 547 {
548 if(thisbox->items[z].hsize == SIZEEXPAND) 548 if(thisbox->items[z].hsize == SIZEEXPAND)
549 thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0))); 549 thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0)));
550 } 550 }
551 else 551 else
552 { 552 {
553 if(thisbox->items[z].vsize == SIZEEXPAND) 553 if(thisbox->items[z].vsize == SIZEEXPAND)
554 thisbox->items[z].height = (int)(((float)thisbox->items[z].origheight) * (((float)percent)/((float)100.0))); 554 thisbox->items[z].height = (int)(((float)thisbox->items[z].origheight) * (((float)percent)/((float)100.0)));
555 } 555 }
556 } 556 }
557 } 557 }
558 } 558 }
559 559
560 static pascal OSErr QuitAppleEventHandler(const AppleEvent *appleEvt, AppleEvent* reply, UInt32 refcon) 560 static pascal OSErr QuitAppleEventHandler(const AppleEvent *appleEvt, AppleEvent* reply, UInt32 refcon)
561 { 561 {
562 ExitToShell(); 562 ExitToShell();
563 } 563 }
564 564
565 /* 565 /*
566 * Initializes the Dynamic Windows engine. 566 * Initializes the Dynamic Windows engine.
567 * Parameters: 567 * Parameters:
568 * newthread: True if this is the only thread. 568 * newthread: True if this is the only thread.
569 * False if there is already a message loop running. 569 * False if there is already a message loop running.
570 */ 570 */
571 int API dw_init(int newthread, int argc, char *argv[]) 571 int API dw_init(int newthread, int argc, char *argv[])
572 { 572 {
573 GDHandle gd = GetMainDevice(); 573 GDHandle gd = GetMainDevice();
574 574
575 FlushEvents(everyEvent, 0); 575 FlushEvents(everyEvent, 0);
576 InitCursor(); 576 InitCursor();
577 CreateNewWindow (kDocumentWindowClass, kWindowOpaqueForEventsAttribute, 577 CreateNewWindow (kDocumentWindowClass, kWindowOpaqueForEventsAttribute,
578 &CreationRect, &CreationWindow); 578 &CreationRect, &CreationWindow);
579 CreateRootControl(CreationWindow, &RootControl); 579 CreateRootControl(CreationWindow, &RootControl);
580 HideWindow(CreationWindow); 580 HideWindow(CreationWindow);
581 if(AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, NewAEEventHandlerUPP(QuitAppleEventHandler), 0, false) != noErr) 581 if(AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, NewAEEventHandlerUPP(QuitAppleEventHandler), 0, false) != noErr)
582 ExitToShell(); 582 ExitToShell();
583 583
584 /* Save the height, width and color depth */ 584 /* Save the height, width and color depth */
585 _dw_screen_height = (*gd)->gdRect.bottom - (*gd)->gdRect.top; 585 _dw_screen_height = (*gd)->gdRect.bottom - (*gd)->gdRect.top;
586 _dw_screen_width = (*gd)->gdRect.right - (*gd)->gdRect.left; 586 _dw_screen_width = (*gd)->gdRect.right - (*gd)->gdRect.left;
587 _dw_color_depth = (*(*gd)->gdPMap)->cmpSize * (*(*gd)->gdPMap)->cmpCount; 587 _dw_color_depth = (*(*gd)->gdPMap)->cmpSize * (*(*gd)->gdPMap)->cmpCount;
588 return 0; 588 return 0;
589 } 589 }
590 590
591 /* 591 /*
592 * Runs a message loop for Dynamic Windows. 592 * Runs a message loop for Dynamic Windows.
593 */ 593 */
594 void API dw_main(void) 594 void API dw_main(void)
595 { 595 {
596 RunApplicationEventLoop(); 596 RunApplicationEventLoop();
597 } 597 }
598 598
599 /* 599 /*
600 * Runs a message loop for Dynamic Windows, for a period of milliseconds. 600 * Runs a message loop for Dynamic Windows, for a period of milliseconds.
601 * Parameters: 601 * Parameters:
602 * milliseconds: Number of milliseconds to run the loop for. 602 * milliseconds: Number of milliseconds to run the loop for.
603 */ 603 */
604 void API dw_main_sleep(int milliseconds) 604 void API dw_main_sleep(int milliseconds)
605 { 605 {
606 double start = (double)clock(); 606 double start = (double)clock();
607 607
608 while(((((clock() - start) / CLOCKS_PER_SEC)/1000)) <= milliseconds) 608 while(((((clock() - start) / CLOCKS_PER_SEC)/1000)) <= milliseconds)
609 { 609 {
610 RunCurrentEventLoop(1); 610 RunCurrentEventLoop(1);
611 } 611 }
612 } 612 }
613 613
614 /* 614 /*
615 * Processes a single message iteration and returns. 615 * Processes a single message iteration and returns.
616 */ 616 */
617 void API dw_main_iteration(void) 617 void API dw_main_iteration(void)
618 { 618 {
619 EventRecord eventStructure; 619 EventRecord eventStructure;
620 620
621 if(WaitNextEvent(everyEvent, &eventStructure, 0, 0)) 621 if(WaitNextEvent(everyEvent, &eventStructure, 0, 0))
622 RunCurrentEventLoop(0); 622 RunCurrentEventLoop(0);
623 } 623 }
624 624
625 /* 625 /*
626 * Free's memory allocated by dynamic windows. 626 * Free's memory allocated by dynamic windows.
627 * Parameters: 627 * Parameters:
628 * ptr: Pointer to dynamic windows allocated 628 * ptr: Pointer to dynamic windows allocated
629 * memory to be free()'d. 629 * memory to be free()'d.
630 */ 630 */
631 void API dw_free(void *ptr) 631 void API dw_free(void *ptr)
632 { 632 {
633 free(ptr); 633 free(ptr);
634 } 634 }
635 635
636 /* 636 /*
637 * Allocates and initializes a dialog struct. 637 * Allocates and initializes a dialog struct.
638 * Parameters: 638 * Parameters:
639 * data: User defined data to be passed to functions. 639 * data: User defined data to be passed to functions.
640 */ 640 */
641 DWDialog * API dw_dialog_new(void *data) 641 DWDialog * API dw_dialog_new(void *data)
642 { 642 {
643 DWDialog *tmp = malloc(sizeof(DWDialog)); 643 DWDialog *tmp = malloc(sizeof(DWDialog));
644 644
645 tmp->eve = dw_event_new(); 645 tmp->eve = dw_event_new();
646 dw_event_reset(tmp->eve); 646 dw_event_reset(tmp->eve);
647 tmp->data = data; 647 tmp->data = data;
648 tmp->done = FALSE; 648 tmp->done = FALSE;
649 tmp->result = NULL; 649 tmp->result = NULL;
650 650
651 return tmp; 651 return tmp;
652 } 652 }
653 653
654 /* 654 /*
655 * Accepts a dialog struct and returns the given data to the 655 * Accepts a dialog struct and returns the given data to the
656 * initial called of dw_dialog_wait(). 656 * initial called of dw_dialog_wait().
658 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). 658 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
659 * result: Data to be returned by dw_dialog_wait(). 659 * result: Data to be returned by dw_dialog_wait().
660 */ 660 */
661 int API dw_dialog_dismiss(DWDialog *dialog, void *result) 661 int API dw_dialog_dismiss(DWDialog *dialog, void *result)
662 { 662 {
663 dialog->result = result; 663 dialog->result = result;
664 dw_event_post(dialog->eve); 664 dw_event_post(dialog->eve);
665 dialog->done = TRUE; 665 dialog->done = TRUE;
666 return 0; 666 return 0;
667 } 667 }
668 668
669 /* 669 /*
670 * Accepts a dialog struct waits for dw_dialog_dismiss() to be 670 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
671 * called by a signal handler with the given dialog struct. 671 * called by a signal handler with the given dialog struct.
672 * Parameters: 672 * Parameters:
673 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). 673 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
674 */ 674 */
675 void * API dw_dialog_wait(DWDialog *dialog) 675 void * API dw_dialog_wait(DWDialog *dialog)
676 { 676 {
677 void *tmp; 677 void *tmp;
678 678
679 while(!dialog->done) 679 while(!dialog->done)
680 { 680 {
681 RunCurrentEventLoop(180); 681 RunCurrentEventLoop(180);
682 } 682 }
683 dw_event_close(&dialog->eve); 683 dw_event_close(&dialog->eve);
684 tmp = dialog->result; 684 tmp = dialog->result;
685 free(dialog); 685 free(dialog);
686 return tmp; 686 return tmp;
687 } 687 }
688 688
689 689
690 /* 690 /*
691 * Displays a Message Box with given text and title.. 691 * Displays a Message Box with given text and title..
694 * format: printf style format string. 694 * format: printf style format string.
695 * ...: Additional variables for use in the format. 695 * ...: Additional variables for use in the format.
696 */ 696 */
697 int API dw_messagebox(char *title, int flags, char *format, ...) 697 int API dw_messagebox(char *title, int flags, char *format, ...)
698 { 698 {
699 va_list args; 699 va_list args;
700 char outbuf[1024]; 700 char outbuf[1024];
701 AlertStdCFStringAlertParamRec param; 701 AlertStdCFStringAlertParamRec param;
702 DialogRef dialog; 702 DialogRef dialog;
703 CFStringRef cftext, cftitle; 703 CFStringRef cftext, cftitle;
704 DialogItemIndex item; 704 DialogItemIndex item;
705 int ret = DW_MB_RETURN_OK; 705 int ret = DW_MB_RETURN_OK;
706 AlertType alert = kAlertPlainAlert; 706 AlertType alert = kAlertPlainAlert;
707 707
708 va_start(args, format); 708 va_start(args, format);
709 vsprintf(outbuf, format, args); 709 vsprintf(outbuf, format, args);
710 va_end(args); 710 va_end(args);
711 711
712 GetStandardAlertDefaultParams(&param, kStdCFStringAlertVersionOne); 712 GetStandardAlertDefaultParams(&param, kStdCFStringAlertVersionOne);
713 param.movable = TRUE; 713 param.movable = TRUE;
714 param.helpButton = FALSE; 714 param.helpButton = FALSE;
715 if(flags & DW_MB_INFORMATION) 715 if(flags & DW_MB_INFORMATION)
716 alert = kAlertNoteAlert; 716 alert = kAlertNoteAlert;
717 else if(flags & DW_MB_ERROR) 717 else if(flags & DW_MB_ERROR)
718 alert = kAlertStopAlert; 718 alert = kAlertStopAlert;
719 else if(flags & DW_MB_WARNING) 719 else if(flags & DW_MB_WARNING)
720 alert = kAlertCautionAlert; 720 alert = kAlertCautionAlert;
721 721
722 if(flags & DW_MB_OK || flags & DW_MB_OKCANCEL) 722 if(flags & DW_MB_OK || flags & DW_MB_OKCANCEL)
723 { 723 {
724 param.defaultText = CFSTR("Ok"); 724 param.defaultText = CFSTR("Ok");
725 param.cancelText = flags & DW_MB_OK ? 0 : CFSTR("Cancel"); 725 param.cancelText = flags & DW_MB_OK ? 0 : CFSTR("Cancel");
726 } 726 }
727 else 727 else
728 { 728 {
729 param.defaultText = CFSTR("Yes"); 729 param.defaultText = CFSTR("Yes");
730 param.cancelText = CFSTR("No"); 730 param.cancelText = CFSTR("No");
731 param.otherText = CFSTR("Cancel"); 731 param.otherText = CFSTR("Cancel");
732 } 732 }
733 cftext = CFStringCreateWithCString(NULL, outbuf, kCFStringEncodingDOSLatinUS); 733 cftext = CFStringCreateWithCString(NULL, outbuf, kCFStringEncodingDOSLatinUS);
734 cftitle = CFStringCreateWithCString(NULL, title, kCFStringEncodingDOSLatinUS); 734 cftitle = CFStringCreateWithCString(NULL, title, kCFStringEncodingDOSLatinUS);
735 if(CreateStandardAlert(alert, cftext, cftitle, &param, &dialog) == noErr) 735 if(CreateStandardAlert(alert, cftext, cftitle, &param, &dialog) == noErr)
736 { 736 {
737 if(RunStandardAlert(dialog, NULL, &item) == noErr) 737 if(RunStandardAlert(dialog, NULL, &item) == noErr)
738 { 738 {
739 if(item == kAlertStdAlertOtherButton) 739 if(item == kAlertStdAlertOtherButton)
740 ret = DW_MB_RETURN_CANCEL; 740 ret = DW_MB_RETURN_CANCEL;
741 else if(item == kAlertStdAlertCancelButton) 741 else if(item == kAlertStdAlertCancelButton)
742 { 742 {
743 if(flags & DW_MB_OK || flags & DW_MB_OKCANCEL) 743 if(flags & DW_MB_OK || flags & DW_MB_OKCANCEL)
744 ret = DW_MB_RETURN_CANCEL; 744 ret = DW_MB_RETURN_CANCEL;
745 else 745 else
746 ret = DW_MB_RETURN_NO; 746 ret = DW_MB_RETURN_NO;
747 } 747 }
748 else if(item == kAlertStdAlertOKButton) 748 else if(item == kAlertStdAlertOKButton)
749 { 749 {
750 if(flags & DW_MB_YESNO || flags & DW_MB_YESNOCANCEL) 750 if(flags & DW_MB_YESNO || flags & DW_MB_YESNOCANCEL)
751 ret = DW_MB_RETURN_YES; 751 ret = DW_MB_RETURN_YES;
752 } 752 }
753 } 753 }
754 } 754 }
755 CFRelease(cftext); 755 CFRelease(cftext);
756 CFRelease(cftitle); 756 CFRelease(cftitle);
757 return ret; 757 return ret;
758 } 758 }
759 759
760 /* 760 /*
761 * Makes the window topmost. 761 * Makes the window topmost.
762 * Parameters: 762 * Parameters:
763 * handle: The window handle to make topmost. 763 * handle: The window handle to make topmost.
764 */ 764 */
765 int API dw_window_raise(HWND handle) 765 int API dw_window_raise(HWND handle)
766 { 766 {
767 BringToFront((WindowRef)handle); 767 BringToFront((WindowRef)handle);
768 return 0; 768 return 0;
769 } 769 }
770 770
771 /* 771 /*
772 * Makes the window bottommost. 772 * Makes the window bottommost.
773 * Parameters: 773 * Parameters:
774 * handle: The window handle to make bottommost. 774 * handle: The window handle to make bottommost.
775 */ 775 */
776 int API dw_window_lower(HWND handle) 776 int API dw_window_lower(HWND handle)
777 { 777 {
778 return 0; 778 return 0;
779 } 779 }
780 780
781 /* 781 /*
782 * Makes the window visible. 782 * Makes the window visible.
783 * Parameters: 783 * Parameters:
784 * handle: The window handle to make visible. 784 * handle: The window handle to make visible.
785 */ 785 */
786 int API dw_window_show(HWND handle) 786 int API dw_window_show(HWND handle)
787 { 787 {
788 ShowWindow((WindowRef)handle); 788 ShowWindow((WindowRef)handle);
789 return 0; 789 return 0;
790 } 790 }
791 791
792 /* 792 /*
793 * Minimizes or Iconifies a top-level window. 793 * Minimizes or Iconifies a top-level window.
794 * Parameters: 794 * Parameters:
795 * handle: The window handle to minimize. 795 * handle: The window handle to minimize.
796 */ 796 */
797 int API dw_window_minimize(HWND handle) 797 int API dw_window_minimize(HWND handle)
798 { 798 {
799 return 0; 799 return 0;
800 } 800 }
801 801
802 /* 802 /*
803 * Makes the window invisible. 803 * Makes the window invisible.
804 * Parameters: 804 * Parameters:
805 * handle: The window handle to make visible. 805 * handle: The window handle to make visible.
806 */ 806 */
807 int API dw_window_hide(HWND handle) 807 int API dw_window_hide(HWND handle)
808 { 808 {
809 HideWindow((WindowRef)handle); 809 HideWindow((WindowRef)handle);
810 return 0; 810 return 0;
811 } 811 }
812 812
813 /* 813 /*
814 * Destroys a window and all of it's children. 814 * Destroys a window and all of it's children.
815 * Parameters: 815 * Parameters:
816 * handle: The window handle to destroy. 816 * handle: The window handle to destroy.
817 */ 817 */
818 int API dw_window_destroy(HWND handle) 818 int API dw_window_destroy(HWND handle)
819 { 819 {
820 DisposeWindow((WindowRef)handle); 820 DisposeWindow((WindowRef)handle);
821 return 0; 821 return 0;
822 } 822 }
823 823
824 /* Causes entire window to be invalidated and redrawn. 824 /* Causes entire window to be invalidated and redrawn.
825 * Parameters: 825 * Parameters:
826 * handle: Toplevel window handle to be redrawn. 826 * handle: Toplevel window handle to be redrawn.
845 * handle: The window (widget) handle. 845 * handle: The window (widget) handle.
846 * fontname: Name and size of the font in the form "size.fontname" 846 * fontname: Name and size of the font in the form "size.fontname"
847 */ 847 */
848 int API dw_window_set_font(HWND handle, char *fontname) 848 int API dw_window_set_font(HWND handle, char *fontname)
849 { 849 {
850 return 0; 850 return 0;
851 } 851 }
852 852
853 /* 853 /*
854 * Sets the colors used by a specified window (widget) handle. 854 * Sets the colors used by a specified window (widget) handle.
855 * Parameters: 855 * Parameters:
857 * fore: Foreground color in DW_RGB format or a default color index. 857 * fore: Foreground color in DW_RGB format or a default color index.
858 * back: Background color in DW_RGB format or a default color index. 858 * back: Background color in DW_RGB format or a default color index.
859 */ 859 */
860 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back) 860 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back)
861 { 861 {
862 return 0; 862 return 0;
863 } 863 }
864 864
865 /* 865 /*
866 * Sets the font used by a specified window (widget) handle. 866 * Sets the font used by a specified window (widget) handle.
867 * Parameters: 867 * Parameters:
868 * handle: The window (widget) handle. 868 * handle: The window (widget) handle.
869 * border: Size of the window border in pixels. 869 * border: Size of the window border in pixels.
870 */ 870 */
871 int API dw_window_set_border(HWND handle, int border) 871 int API dw_window_set_border(HWND handle, int border)
872 { 872 {
873 return 0; 873 return 0;
874 } 874 }
875 875
876 /* 876 /*
877 * Captures the mouse input to this window. 877 * Captures the mouse input to this window.
878 * Parameters: 878 * Parameters:
904 * handle: Handle to widget for which to change. 904 * handle: Handle to widget for which to change.
905 * cursortype: ID of the pointer you want. 905 * cursortype: ID of the pointer you want.
906 */ 906 */
907 void API dw_window_set_pointer(HWND handle, int pointertype) 907 void API dw_window_set_pointer(HWND handle, int pointertype)
908 { 908 {
909 SetCursor(*GetCursor(pointertype)); 909 SetCursor(*GetCursor(pointertype));
910 } 910 }
911 911
912 /* 912 /*
913 * Create a new Window Frame. 913 * Create a new Window Frame.
914 * Parameters: 914 * Parameters:
916 * title: The Window title. 916 * title: The Window title.
917 * flStyle: Style flags, see the PM reference. 917 * flStyle: Style flags, see the PM reference.
918 */ 918 */
919 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) 919 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle)
920 { 920 {
921 WindowRef hwnd = 0; 921 WindowRef hwnd = 0;
922 ControlRef rootcontrol = 0; 922 ControlRef rootcontrol = 0;
923 923
924 CreateNewWindow (kDocumentWindowClass, flStyle | kWindowStandardHandlerAttribute, 924 CreateNewWindow (kDocumentWindowClass, flStyle | kWindowStandardHandlerAttribute,
925 &CreationRect, &hwnd); 925 &CreationRect, &hwnd);
926 CreateRootControl(hwnd, &rootcontrol); 926 CreateRootControl(hwnd, &rootcontrol);
927 dw_window_set_text((HWND)hwnd, title); 927 dw_window_set_text((HWND)hwnd, title);
928 return (HWND)hwnd; 928 return (HWND)hwnd;
929 } 929 }
930 930
931 /* 931 /*
932 * Create a new Box to be packed. 932 * Create a new Box to be packed.
933 * Parameters: 933 * Parameters:
949 * pad: Number of pixels to pad around the box. 949 * pad: Number of pixels to pad around the box.
950 * title: Text to be displayined in the group outline. 950 * title: Text to be displayined in the group outline.
951 */ 951 */
952 HWND API dw_groupbox_new(int type, int pad, char *title) 952 HWND API dw_groupbox_new(int type, int pad, char *title)
953 { 953 {
954 HWND hwnd = 0; 954 HWND hwnd = 0;
955 CreateRadioGroupControl(CreationWindow, &CreationRect, &hwnd); 955 CreateRadioGroupControl(CreationWindow, &CreationRect, &hwnd);
956 return hwnd; 956 return hwnd;
957 } 957 }
958 958
959 /* 959 /*
960 * Create a new MDI Frame to be packed. 960 * Create a new MDI Frame to be packed.
961 * Parameters: 961 * Parameters:
962 * id: An ID to be used with dw_window_from_id or 0L. 962 * id: An ID to be used with dw_window_from_id or 0L.
963 */ 963 */
964 HWND API dw_mdi_new(unsigned long id) 964 HWND API dw_mdi_new(unsigned long id)
965 { 965 {
966 return 0; 966 return 0;
967 } 967 }
968 968
969 /* 969 /*
970 * Create a bitmap object to be packed. 970 * Create a bitmap object to be packed.
971 * Parameters: 971 * Parameters:
972 * id: An ID to be used with dw_window_from_id() or 0L. 972 * id: An ID to be used with dw_window_from_id() or 0L.
973 */ 973 */
974 HWND API dw_bitmap_new(ULONG id) 974 HWND API dw_bitmap_new(ULONG id)
975 { 975 {
976 HWND hwnd = 0; 976 HWND hwnd = 0;
977 CreateImageWellControl(CreationWindow, &CreationRect, NULL, &hwnd); 977 CreateImageWellControl(CreationWindow, &CreationRect, NULL, &hwnd);
978 return hwnd; 978 return hwnd;
979 } 979 }
980 980
981 /* 981 /*
982 * Create a notebook object to be packed. 982 * Create a notebook object to be packed.
983 * Parameters: 983 * Parameters:
984 * id: An ID to be used for getting the resource from the 984 * id: An ID to be used for getting the resource from the
985 * resource file. 985 * resource file.
986 */ 986 */
987 HWND API dw_notebook_new(ULONG id, int top) 987 HWND API dw_notebook_new(ULONG id, int top)
988 { 988 {
989 HWND hwnd = 0; 989 HWND hwnd = 0;
990 CreateTabsControl(CreationWindow, &CreationRect, kControlTabSizeSmall, kControlTabDirectionNorth, 1, NULL, &hwnd); 990 CreateTabsControl(CreationWindow, &CreationRect, kControlTabSizeSmall, kControlTabDirectionNorth, 1, NULL, &hwnd);
991 return hwnd; 991 return hwnd;
992 } 992 }
993 993
994 char _removetilde(char *dest, char *src) 994 char _removetilde(char *dest, char *src)
995 { 995 {
996 int z, cur=0; 996 int z, cur=0;
997 char accel = '\0'; 997 char accel = '\0';
998 998
999 for(z=0;z<strlen(src);z++) 999 for(z=0;z<strlen(src);z++)
1000 { 1000 {
1001 if(src[z] != '~') 1001 if(src[z] != '~')
1002 { 1002 {
1003 dest[cur] = src[z]; 1003 dest[cur] = src[z];
1004 cur++; 1004 cur++;
1005 } 1005 }
1006 else 1006 else
1007 accel = src[z+1]; 1007 accel = src[z+1];
1008 } 1008 }
1009 dest[cur] = 0; 1009 dest[cur] = 0;
1010 return accel; 1010 return accel;
1011 } 1011 }
1012 1012
1013 /* 1013 /*
1014 * Create a menu object to be popped up. 1014 * Create a menu object to be popped up.
1015 * Parameters: 1015 * Parameters:
1016 * id: An ID to be used for getting the resource from the 1016 * id: An ID to be used for getting the resource from the
1017 * resource file. 1017 * resource file.
1018 */ 1018 */
1019 HMENUI API dw_menu_new(ULONG id) 1019 HMENUI API dw_menu_new(ULONG id)
1020 { 1020 {
1021 return NewMenu(id % 256, ""); 1021 return NewMenu(id % 256, "");
1022 } 1022 }
1023 1023
1024 /* 1024 /*
1025 * Create a menubar on a window. 1025 * Create a menubar on a window.
1026 * Parameters: 1026 * Parameters:
1027 * location: Handle of a window frame to be attached to. 1027 * location: Handle of a window frame to be attached to.
1028 */ 1028 */
1029 HMENUI API dw_menubar_new(HWND location) 1029 HMENUI API dw_menubar_new(HWND location)
1030 { 1030 {
1031 return (HMENUI)-1; 1031 return (HMENUI)-1;
1032 } 1032 }
1033 1033
1034 /* 1034 /*
1035 * Destroys a menu created with dw_menubar_new or dw_menu_new. 1035 * Destroys a menu created with dw_menubar_new or dw_menu_new.
1036 * Parameters: 1036 * Parameters:
1037 * menu: Handle of a menu. 1037 * menu: Handle of a menu.
1038 */ 1038 */
1039 void API dw_menu_destroy(HMENUI *menu) 1039 void API dw_menu_destroy(HMENUI *menu)
1040 { 1040 {
1041 DisposeMenu(*menu); 1041 DisposeMenu(*menu);
1042 } 1042 }
1043 1043
1044 /* 1044 /*
1045 * Adds a menuitem or submenu to an existing menu. 1045 * Adds a menuitem or submenu to an existing menu.
1046 * Parameters: 1046 * Parameters:
1052 * check: If TRUE menu is "check"able. 1052 * check: If TRUE menu is "check"able.
1053 * submenu: Handle to an existing menu to be a submenu or NULL. 1053 * submenu: Handle to an existing menu to be a submenu or NULL.
1054 */ 1054 */
1055 HWND API dw_menu_append_item(HMENUI menux, char *title, ULONG id, ULONG flags, int end, int check, HMENUI submenu) 1055 HWND API dw_menu_append_item(HMENUI menux, char *title, ULONG id, ULONG flags, int end, int check, HMENUI submenu)
1056 { 1056 {
1057 char accel, *buf, *tempbuf = alloca(strlen(title)+1); 1057 char accel, *buf, *tempbuf = alloca(strlen(title)+1);
1058 1058
1059 accel = _removetilde(tempbuf, title); 1059 accel = _removetilde(tempbuf, title);
1060 buf = CToPascal(tempbuf); 1060 buf = CToPascal(tempbuf);
1061 1061
1062 if(menux == (HMENUI)-1) 1062 if(menux == (HMENUI)-1)
1063 { 1063 {
1064 SetMenuTitle(submenu, buf); 1064 SetMenuTitle(submenu, buf);
1065 InsertMenu(submenu, 0); 1065 InsertMenu(submenu, 0);
1066 } 1066 }
1067 else 1067 else
1068 { 1068 {
1069 /* Add a separator if requested */ 1069 /* Add a separator if requested */
1070 if(!title || !*title) 1070 if(!title || !*title)
1071 AppendMenu(menux, "\001-"); 1071 AppendMenu(menux, "\001-");
1072 else 1072 else
1073 { 1073 {
1074 MenuItemIndex item; 1074 MenuItemIndex item;
1075 CFStringRef cftext = CFStringCreateWithCString(NULL, tempbuf, kCFStringEncodingDOSLatinUS); 1075 CFStringRef cftext = CFStringCreateWithCString(NULL, tempbuf, kCFStringEncodingDOSLatinUS);
1076 1076
1077 AppendMenuItemTextWithCFString(menux, cftext, 0, 0, &item); 1077 AppendMenuItemTextWithCFString(menux, cftext, 0, 0, &item);
1078 CFRelease(cftext); 1078 CFRelease(cftext);
1079 1079
1080 id = item; 1080 id = item;
1081 if(accel) 1081 if(accel)
1082 { 1082 {
1083 SetItemCmd(menux, item, accel); 1083 SetItemCmd(menux, item, accel);
1084 SetMenuItemModifiers(menux, item, kMenuOptionModifier); 1084 SetMenuItemModifiers(menux, item, kMenuOptionModifier);
1085 } 1085 }
1086 } 1086 }
1087 } 1087 }
1088 DrawMenuBar(); 1088 DrawMenuBar();
1089 return (HWND)id; 1089 return (HWND)id;
1090 } 1090 }
1091 1091
1092 /* 1092 /*
1093 * Sets the state of a menu item check. 1093 * Sets the state of a menu item check.
1094 * Parameters: 1094 * Parameters:
1096 * id: Menuitem id. 1096 * id: Menuitem id.
1097 * check: TRUE for checked FALSE for not checked. 1097 * check: TRUE for checked FALSE for not checked.
1098 */ 1098 */
1099 void API dw_menu_item_set_check(HMENUI menux, unsigned long id, int check) 1099 void API dw_menu_item_set_check(HMENUI menux, unsigned long id, int check)
1100 { 1100 {
1101 CheckMenuItem(menux, id, check); 1101 CheckMenuItem(menux, id, check);
1102 } 1102 }
1103 1103
1104 /* 1104 /*
1105 * Pops up a context menu at given x and y coordinates. 1105 * Pops up a context menu at given x and y coordinates.
1106 * Parameters: 1106 * Parameters:
1140 * id: An ID to be used for getting the resource from the 1140 * id: An ID to be used for getting the resource from the
1141 * resource file. 1141 * resource file.
1142 */ 1142 */
1143 HWND API dw_container_new(ULONG id, int multi) 1143 HWND API dw_container_new(ULONG id, int multi)
1144 { 1144 {
1145 ListHandle hwnd = 0; 1145 ListHandle hwnd = 0;
1146 Point CellSize; 1146 Point CellSize;
1147 ListDefSpec def; 1147 ListDefSpec def;
1148 1148
1149 SetPt(&CellSize, 52, 52); 1149 SetPt(&CellSize, 52, 52);
1150 /*def.u.userProc = listDefinitionFunctionUPP;*/ 1150 /*def.u.userProc = listDefinitionFunctionUPP;*/
1151 1151
1152 CreateCustomList(&CreationRect, &CreationRect, CellSize, &def, CreationWindow, TRUE, TRUE, TRUE, TRUE, &hwnd); 1152 CreateCustomList(&CreationRect, &CreationRect, CellSize, &def, CreationWindow, TRUE, TRUE, TRUE, TRUE, &hwnd);
1153 return (HWND)hwnd; 1153 return (HWND)hwnd;
1154 } 1154 }
1155 1155
1156 /* 1156 /*
1157 * Create a tree object to be packed. 1157 * Create a tree object to be packed.
1158 * Parameters: 1158 * Parameters:
1159 * id: An ID to be used for getting the resource from the 1159 * id: An ID to be used for getting the resource from the
1160 * resource file. 1160 * resource file.
1161 */ 1161 */
1162 HWND API dw_tree_new(ULONG id) 1162 HWND API dw_tree_new(ULONG id)
1163 { 1163 {
1164 return dw_container_new(id, FALSE); 1164 return dw_container_new(id, FALSE);
1165 } 1165 }
1166 1166
1167 /* 1167 /*
1168 * Create a new static text window (widget) to be packed. 1168 * Create a new static text window (widget) to be packed.
1169 * Parameters: 1169 * Parameters:
1170 * text: The text to be display by the static text widget. 1170 * text: The text to be display by the static text widget.
1171 * id: An ID to be used with dw_window_from_id() or 0L. 1171 * id: An ID to be used with dw_window_from_id() or 0L.
1172 */ 1172 */
1173 HWND API dw_text_new(char *text, ULONG id) 1173 HWND API dw_text_new(char *text, ULONG id)
1174 { 1174 {
1175 HWND hwnd = 0; 1175 HWND hwnd = 0;
1176 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS); 1176 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
1177 CreateStaticTextControl (CreationWindow, &CreationRect, cftext, NULL, &hwnd); 1177 CreateStaticTextControl (CreationWindow, &CreationRect, cftext, NULL, &hwnd);
1178 CFRelease(cftext); 1178 CFRelease(cftext);
1179 return hwnd; 1179 return hwnd;
1180 } 1180 }
1181 1181
1182 /* 1182 /*
1183 * Create a new status text window (widget) to be packed. 1183 * Create a new status text window (widget) to be packed.
1184 * Parameters: 1184 * Parameters:
1185 * text: The text to be display by the static text widget. 1185 * text: The text to be display by the static text widget.
1186 * id: An ID to be used with dw_window_from_id() or 0L. 1186 * id: An ID to be used with dw_window_from_id() or 0L.
1187 */ 1187 */
1188 HWND API dw_status_text_new(char *text, ULONG id) 1188 HWND API dw_status_text_new(char *text, ULONG id)
1189 { 1189 {
1190 HWND hwnd = 0; 1190 HWND hwnd = 0;
1191 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS); 1191 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
1192 CreateStaticTextControl (CreationWindow, &CreationRect, cftext, NULL, &hwnd); 1192 CreateStaticTextControl (CreationWindow, &CreationRect, cftext, NULL, &hwnd);
1193 CFRelease(cftext); 1193 CFRelease(cftext);
1194 return hwnd; 1194 return hwnd;
1195 } 1195 }
1196 1196
1197 /* 1197 /*
1198 * Create a new Multiline Editbox window (widget) to be packed. 1198 * Create a new Multiline Editbox window (widget) to be packed.
1199 * Parameters: 1199 * Parameters:
1200 * id: An ID to be used with dw_window_from_id() or 0L. 1200 * id: An ID to be used with dw_window_from_id() or 0L.
1201 */ 1201 */
1202 HWND API dw_mle_new(ULONG id) 1202 HWND API dw_mle_new(ULONG id)
1203 { 1203 {
1204 HWND hwnd = 0; 1204 HWND hwnd = 0;
1205 CreateScrollingTextBoxControl(CreationWindow, &CreationRect, id, FALSE, 0, 0, 0, &hwnd); 1205 CreateScrollingTextBoxControl(CreationWindow, &CreationRect, id, FALSE, 0, 0, 0, &hwnd);
1206 return hwnd; 1206 return hwnd;
1207 } 1207 }
1208 1208
1209 /* 1209 /*
1210 * Create a new Entryfield window (widget) to be packed. 1210 * Create a new Entryfield window (widget) to be packed.
1211 * Parameters: 1211 * Parameters:
1212 * text: The default text to be in the entryfield widget. 1212 * text: The default text to be in the entryfield widget.
1213 * id: An ID to be used with dw_window_from_id() or 0L. 1213 * id: An ID to be used with dw_window_from_id() or 0L.
1214 */ 1214 */
1215 HWND API dw_entryfield_new(char *text, ULONG id) 1215 HWND API dw_entryfield_new(char *text, ULONG id)
1216 { 1216 {
1217 HWND hwnd = 0; 1217 HWND hwnd = 0;
1218 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS); 1218 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
1219 CreateEditTextControl(CreationWindow, &CreationRect, cftext, FALSE, FALSE, NULL, &hwnd); 1219 CreateEditTextControl(CreationWindow, &CreationRect, cftext, FALSE, FALSE, NULL, &hwnd);
1220 CFRelease(cftext); 1220 CFRelease(cftext);
1221 return hwnd; 1221 return hwnd;
1222 } 1222 }
1223 1223
1224 /* 1224 /*
1225 * Create a new Entryfield (password) window (widget) to be packed. 1225 * Create a new Entryfield (password) window (widget) to be packed.
1226 * Parameters: 1226 * Parameters:
1227 * text: The default text to be in the entryfield widget. 1227 * text: The default text to be in the entryfield widget.
1228 * id: An ID to be used with dw_window_from_id() or 0L. 1228 * id: An ID to be used with dw_window_from_id() or 0L.
1229 */ 1229 */
1230 HWND API dw_entryfield_password_new(char *text, ULONG id) 1230 HWND API dw_entryfield_password_new(char *text, ULONG id)
1231 { 1231 {
1232 HWND hwnd = 0; 1232 HWND hwnd = 0;
1233 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS); 1233 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
1234 CreateEditTextControl(CreationWindow, &CreationRect, cftext, TRUE, FALSE, NULL, &hwnd); 1234 CreateEditTextControl(CreationWindow, &CreationRect, cftext, TRUE, FALSE, NULL, &hwnd);
1235 CFRelease(cftext); 1235 CFRelease(cftext);
1236 return hwnd; 1236 return hwnd;
1237 } 1237 }
1238 1238
1239 /* 1239 /*
1240 * Create a new Combobox window (widget) to be packed. 1240 * Create a new Combobox window (widget) to be packed.
1241 * Parameters: 1241 * Parameters:
1242 * text: The default text to be in the combpbox widget. 1242 * text: The default text to be in the combpbox widget.
1243 * id: An ID to be used with dw_window_from_id() or 0L. 1243 * id: An ID to be used with dw_window_from_id() or 0L.
1244 */ 1244 */
1245 HWND API dw_combobox_new(char *text, ULONG id) 1245 HWND API dw_combobox_new(char *text, ULONG id)
1246 { 1246 {
1247 return 0; 1247 return 0;
1248 } 1248 }
1249 1249
1250 /* 1250 /*
1251 * Create a new button window (widget) to be packed. 1251 * Create a new button window (widget) to be packed.
1252 * Parameters: 1252 * Parameters:
1253 * text: The text to be display by the static text widget. 1253 * text: The text to be display by the static text widget.
1254 * id: An ID to be used with dw_window_from_id() or 0L. 1254 * id: An ID to be used with dw_window_from_id() or 0L.
1255 */ 1255 */
1256 HWND API dw_button_new(char *text, ULONG id) 1256 HWND API dw_button_new(char *text, ULONG id)
1257 { 1257 {
1258 HWND hwnd = 0; 1258 HWND hwnd = 0;
1259 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS); 1259 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
1260 CreatePushButtonControl(CreationWindow, &CreationRect, cftext, &hwnd); 1260 CreatePushButtonControl(CreationWindow, &CreationRect, cftext, &hwnd);
1261 CFRelease(cftext); 1261 CFRelease(cftext);
1262 return hwnd; 1262 return hwnd;
1263 } 1263 }
1264 1264
1265 /* 1265 /*
1266 * Create a new bitmap button window (widget) to be packed. 1266 * Create a new bitmap button window (widget) to be packed.
1267 * Parameters: 1267 * Parameters:
1268 * text: Bubble help text to be displayed. 1268 * text: Bubble help text to be displayed.
1269 * id: An ID of a bitmap in the resource file. 1269 * id: An ID of a bitmap in the resource file.
1270 */ 1270 */
1271 HWND API dw_bitmapbutton_new(char *text, ULONG id) 1271 HWND API dw_bitmapbutton_new(char *text, ULONG id)
1272 { 1272 {
1273 HWND hwnd = 0; 1273 HWND hwnd = 0;
1274 CreatePushButtonWithIconControl(CreationWindow, &CreationRect, 0, NULL, kControlPushButtonIconOnLeft, &hwnd); 1274 CreatePushButtonWithIconControl(CreationWindow, &CreationRect, 0, NULL, kControlPushButtonIconOnLeft, &hwnd);
1275 return hwnd; 1275 return hwnd;
1276 } 1276 }
1277 1277
1278 /* 1278 /*
1279 * Create a new bitmap button window (widget) to be packed from a file. 1279 * Create a new bitmap button window (widget) to be packed from a file.
1280 * Parameters: 1280 * Parameters:
1284 * DW pick the appropriate file extension. 1284 * DW pick the appropriate file extension.
1285 * (BMP on OS/2 or Windows, XPM on Unix) 1285 * (BMP on OS/2 or Windows, XPM on Unix)
1286 */ 1286 */
1287 HWND dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename) 1287 HWND dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename)
1288 { 1288 {
1289 return 0; 1289 return 0;
1290 } 1290 }
1291 1291
1292 /* 1292 /*
1293 * Create a new bitmap button window (widget) to be packed from data. 1293 * Create a new bitmap button window (widget) to be packed from data.
1294 * Parameters: 1294 * Parameters:
1298 * (BMP on OS/2 or Windows, XPM on Unix) 1298 * (BMP on OS/2 or Windows, XPM on Unix)
1299 * len: Length of raw data 1299 * len: Length of raw data
1300 */ 1300 */
1301 HWND dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *data, int len) 1301 HWND dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *data, int len)
1302 { 1302 {
1303 return 0; 1303 return 0;
1304 } 1304 }
1305 1305
1306 /* 1306 /*
1307 * Create a new spinbutton window (widget) to be packed. 1307 * Create a new spinbutton window (widget) to be packed.
1308 * Parameters: 1308 * Parameters:
1309 * text: The text to be display by the static text widget. 1309 * text: The text to be display by the static text widget.
1310 * id: An ID to be used with dw_window_from_id() or 0L. 1310 * id: An ID to be used with dw_window_from_id() or 0L.
1311 */ 1311 */
1312 HWND API dw_spinbutton_new(char *text, ULONG id) 1312 HWND API dw_spinbutton_new(char *text, ULONG id)
1313 { 1313 {
1314 return 0; 1314 return 0;
1315 } 1315 }
1316 1316
1317 /* 1317 /*
1318 * Create a new radiobutton window (widget) to be packed. 1318 * Create a new radiobutton window (widget) to be packed.
1319 * Parameters: 1319 * Parameters:
1320 * text: The text to be display by the static text widget. 1320 * text: The text to be display by the static text widget.
1321 * id: An ID to be used with dw_window_from_id() or 0L. 1321 * id: An ID to be used with dw_window_from_id() or 0L.
1322 */ 1322 */
1323 HWND API dw_radiobutton_new(char *text, ULONG id) 1323 HWND API dw_radiobutton_new(char *text, ULONG id)
1324 { 1324 {
1325 HWND hwnd = 0; 1325 HWND hwnd = 0;
1326 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS); 1326 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
1327 CreateRadioButtonControl(CreationWindow, &CreationRect, cftext, 0, FALSE, &hwnd); 1327 CreateRadioButtonControl(CreationWindow, &CreationRect, cftext, 0, FALSE, &hwnd);
1328 CFRelease(cftext); 1328 CFRelease(cftext);
1329 return hwnd; 1329 return hwnd;
1330 } 1330 }
1331 1331
1332 1332
1333 /* 1333 /*
1334 * Create a new slider window (widget) to be packed. 1334 * Create a new slider window (widget) to be packed.
1337 * increments: Number of increments available. 1337 * increments: Number of increments available.
1338 * id: An ID to be used with dw_window_from_id() or 0L. 1338 * id: An ID to be used with dw_window_from_id() or 0L.
1339 */ 1339 */
1340 HWND API dw_slider_new(int vertical, int increments, ULONG id) 1340 HWND API dw_slider_new(int vertical, int increments, ULONG id)
1341 { 1341 {
1342 HWND hwnd = 0; 1342 HWND hwnd = 0;
1343 CreateSliderControl(CreationWindow, &CreationRect, 0, 0, increments, kControlSliderDoesNotPoint, 0, FALSE, 0, &hwnd); 1343 CreateSliderControl(CreationWindow, &CreationRect, 0, 0, increments, kControlSliderDoesNotPoint, 0, FALSE, 0, &hwnd);
1344 return hwnd; 1344 return hwnd;
1345 } 1345 }
1346 1346
1347 /* 1347 /*
1348 * Create a new scrollbar window (widget) to be packed. 1348 * Create a new scrollbar window (widget) to be packed.
1349 * Parameters: 1349 * Parameters:
1351 * increments: Number of increments available. 1351 * increments: Number of increments available.
1352 * id: An ID to be used with dw_window_from_id() or 0L. 1352 * id: An ID to be used with dw_window_from_id() or 0L.
1353 */ 1353 */
1354 HWND API dw_scrollbar_new(int vertical, ULONG id) 1354 HWND API dw_scrollbar_new(int vertical, ULONG id)
1355 { 1355 {
1356 HWND hwnd; 1356 HWND hwnd;
1357 CreateScrollBarControl(CreationWindow, &CreationRect, 0, 0, 100, 100, FALSE, 0, &hwnd); 1357 CreateScrollBarControl(CreationWindow, &CreationRect, 0, 0, 100, 100, FALSE, 0, &hwnd);
1358 return hwnd; 1358 return hwnd;
1359 } 1359 }
1360 1360
1361 /* 1361 /*
1362 * Create a new percent bar window (widget) to be packed. 1362 * Create a new percent bar window (widget) to be packed.
1363 * Parameters: 1363 * Parameters:
1364 * id: An ID to be used with dw_window_from_id() or 0L. 1364 * id: An ID to be used with dw_window_from_id() or 0L.
1365 */ 1365 */
1366 HWND API dw_percent_new(ULONG id) 1366 HWND API dw_percent_new(ULONG id)
1367 { 1367 {
1368 HWND hwnd = 0; 1368 HWND hwnd = 0;
1369 CreateProgressBarControl(CreationWindow, &CreationRect, 0, 0, 100, FALSE, &hwnd); 1369 CreateProgressBarControl(CreationWindow, &CreationRect, 0, 0, 100, FALSE, &hwnd);
1370 return hwnd; 1370 return hwnd;
1371 } 1371 }
1372 1372
1373 /* 1373 /*
1374 * Create a new checkbox window (widget) to be packed. 1374 * Create a new checkbox window (widget) to be packed.
1375 * Parameters: 1375 * Parameters:
1376 * text: The text to be display by the static text widget. 1376 * text: The text to be display by the static text widget.
1377 * id: An ID to be used with dw_window_from_id() or 0L. 1377 * id: An ID to be used with dw_window_from_id() or 0L.
1378 */ 1378 */
1379 HWND API dw_checkbox_new(char *text, ULONG id) 1379 HWND API dw_checkbox_new(char *text, ULONG id)
1380 { 1380 {
1381 HWND hwnd = 0; 1381 HWND hwnd = 0;
1382 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS); 1382 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
1383 CreateCheckBoxControl(CreationWindow, &CreationRect, cftext, 0, TRUE, &hwnd); 1383 CreateCheckBoxControl(CreationWindow, &CreationRect, cftext, 0, TRUE, &hwnd);
1384 CFRelease(cftext); 1384 CFRelease(cftext);
1385 return hwnd; 1385 return hwnd;
1386 } 1386 }
1387 1387
1388 /* 1388 /*
1389 * Create a new listbox window (widget) to be packed. 1389 * Create a new listbox window (widget) to be packed.
1390 * Parameters: 1390 * Parameters:
1391 * id: An ID to be used with dw_window_from_id() or 0L. 1391 * id: An ID to be used with dw_window_from_id() or 0L.
1392 * multi: Multiple select TRUE or FALSE. 1392 * multi: Multiple select TRUE or FALSE.
1393 */ 1393 */
1394 HWND API dw_listbox_new(ULONG id, int multi) 1394 HWND API dw_listbox_new(ULONG id, int multi)
1395 { 1395 {
1396 HWND hwnd = 0; 1396 HWND hwnd = 0;
1397 CreateListBoxControl(CreationWindow, &CreationRect, TRUE, 0, 1, FALSE, TRUE, 50, 50, TRUE, NULL, &hwnd); 1397 CreateListBoxControl(CreationWindow, &CreationRect, TRUE, 0, 1, FALSE, TRUE, 50, 50, TRUE, NULL, &hwnd);
1398 return hwnd; 1398 return hwnd;
1399 } 1399 }
1400 1400
1401 /* 1401 /*
1402 * Sets the icon used for a given window. 1402 * Sets the icon used for a given window.
1403 * Parameters: 1403 * Parameters:
1443 * handle: Handle to the window. 1443 * handle: Handle to the window.
1444 * text: The text associsated with a given window. 1444 * text: The text associsated with a given window.
1445 */ 1445 */
1446 void API dw_window_set_text(HWND handle, char *text) 1446 void API dw_window_set_text(HWND handle, char *text)
1447 { 1447 {
1448 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS); 1448 CFStringRef cftext = CFStringCreateWithCString(NULL, text, kCFStringEncodingDOSLatinUS);
1449 if(IsValidWindowRef((WindowRef)handle)) 1449 if(IsValidWindowRef((WindowRef)handle))
1450 SetWindowTitleWithCFString((WindowRef)handle, cftext); 1450 SetWindowTitleWithCFString((WindowRef)handle, cftext);
1451 else 1451 else
1452 SetControlTitleWithCFString(handle, cftext); 1452 SetControlTitleWithCFString(handle, cftext);
1453 CFRelease(cftext); 1453 CFRelease(cftext);
1454 } 1454 }
1455 1455
1456 /* 1456 /*
1457 * Gets the text used for a given window. 1457 * Gets the text used for a given window.
1458 * Parameters: 1458 * Parameters:
1460 * Returns: 1460 * Returns:
1461 * text: The text associsated with a given window. 1461 * text: The text associsated with a given window.
1462 */ 1462 */
1463 char * API dw_window_get_text(HWND handle) 1463 char * API dw_window_get_text(HWND handle)
1464 { 1464 {
1465 CFStringRef cftext; 1465 CFStringRef cftext;
1466 char *ret = NULL; 1466 char *ret = NULL;
1467 1467
1468 if(IsValidWindowRef((WindowRef)handle)) 1468 if(IsValidWindowRef((WindowRef)handle))
1469 CopyWindowTitleAsCFString((WindowRef)handle, &cftext); 1469 CopyWindowTitleAsCFString((WindowRef)handle, &cftext);
1470 else 1470 else
1471 { 1471 {
1472 Str255 str; 1472 Str255 str;
1473 1473
1474 GetControlTitle(handle, str); 1474 GetControlTitle(handle, str);
1475 cftext = CFStringCreateWithPascalString(NULL, str, CFStringGetSystemEncoding()); 1475 cftext = CFStringCreateWithPascalString(NULL, str, CFStringGetSystemEncoding());
1476 } 1476 }
1477 1477
1478 if(cftext) 1478 if(cftext)
1479 { 1479 {
1480 int length = CFStringGetLength(cftext) + 1; 1480 int length = CFStringGetLength(cftext) + 1;
1481 char *ret = malloc(length); 1481 char *ret = malloc(length);
1482 CFStringGetCString(cftext, ret, length, kCFStringEncodingDOSLatinUS); 1482 CFStringGetCString(cftext, ret, length, kCFStringEncodingDOSLatinUS);
1483 CFRelease(cftext); 1483 CFRelease(cftext);
1484 } 1484 }
1485 return ret; 1485 return ret;
1486 } 1486 }
1487 1487
1488 /* 1488 /*
1489 * Disables given window (widget). 1489 * Disables given window (widget).
1490 * Parameters: 1490 * Parameters:
1491 * handle: Handle to the window. 1491 * handle: Handle to the window.
1492 */ 1492 */
1493 void API dw_window_disable(HWND handle) 1493 void API dw_window_disable(HWND handle)
1494 { 1494 {
1495 DisableControl(handle); 1495 DisableControl(handle);
1496 } 1496 }
1497 1497
1498 /* 1498 /*
1499 * Enables given window (widget). 1499 * Enables given window (widget).
1500 * Parameters: 1500 * Parameters:
1501 * handle: Handle to the window. 1501 * handle: Handle to the window.
1502 */ 1502 */
1503 void API dw_window_enable(HWND handle) 1503 void API dw_window_enable(HWND handle)
1504 { 1504 {
1505 EnableControl(handle); 1505 EnableControl(handle);
1506 } 1506 }
1507 1507
1508 /* 1508 /*
1509 * Gets the child window handle with specified ID. 1509 * Gets the child window handle with specified ID.
1510 * Parameters: 1510 * Parameters:
1511 * handle: Handle to the parent window. 1511 * handle: Handle to the parent window.
1512 * id: Integer ID of the child. 1512 * id: Integer ID of the child.
1513 */ 1513 */
1514 HWND API dw_window_from_id(HWND handle, int id) 1514 HWND API dw_window_from_id(HWND handle, int id)
1515 { 1515 {
1516 HWND ret = 0; 1516 HWND ret = 0;
1517 1517
1518 #if 0 1518 #if 0
1519 ControlID cid = (ControlID)id; 1519 ControlID cid = (ControlID)id;
1520 GetControlByID((WindowRef)handle, &cid, &ret); 1520 GetControlByID((WindowRef)handle, &cid, &ret);
1521 #endif 1521 #endif
1522 return ret; 1522 return ret;
1523 } 1523 }
1524 1524
1525 /* 1525 /*
1526 * Pack windows (widgets) into a box from the end (or bottom). 1526 * Pack windows (widgets) into a box from the end (or bottom).
1527 * Parameters: 1527 * Parameters:
1552 /* 1552 /*
1553 * Returns the width of the screen. 1553 * Returns the width of the screen.
1554 */ 1554 */
1555 int API dw_screen_width(void) 1555 int API dw_screen_width(void)
1556 { 1556 {
1557 return _dw_screen_width; 1557 return _dw_screen_width;
1558 } 1558 }
1559 1559
1560 /* 1560 /*
1561 * Returns the height of the screen. 1561 * Returns the height of the screen.
1562 */ 1562 */
1563 int API dw_screen_height(void) 1563 int API dw_screen_height(void)
1564 { 1564 {
1565 return _dw_screen_height; 1565 return _dw_screen_height;
1566 } 1566 }
1567 1567
1568 /* This should return the current color depth */ 1568 /* This should return the current color depth */
1569 unsigned long API dw_color_depth_get(void) 1569 unsigned long API dw_color_depth_get(void)
1570 { 1570 {
1571 return _dw_color_depth; 1571 return _dw_color_depth;
1572 } 1572 }
1573 1573
1574 1574
1575 /* 1575 /*
1576 * Sets the position of a given window (widget). 1576 * Sets the position of a given window (widget).
1577 * Parameters: 1577 * Parameters:
1578 * handle: Window (widget) handle. 1578 * handle: Window (widget) handle.
1579 * x: X location from the bottom left. 1579 * x: X location from the bottom left.
1580 * y: Y location from the bottom left. 1580 * y: Y location from the bottom left.
1581 */ 1581 */
1582 void API dw_window_set_pos(HWND handle, ULONG x, ULONG y) 1582 void API dw_window_set_pos(HWND handle, LONG x, LONG y)
1583 { 1583 {
1584 MoveWindow((WindowRef)handle, (short)x, (short)y, FALSE); 1584 MoveWindow((WindowRef)handle, (short)x, (short)y, FALSE);
1585 } 1585 }
1586 1586
1587 /* 1587 /*
1588 * Sets the position and size of a given window (widget). 1588 * Sets the position and size of a given window (widget).
1589 * Parameters: 1589 * Parameters:
1591 * x: X location from the bottom left. 1591 * x: X location from the bottom left.
1592 * y: Y location from the bottom left. 1592 * y: Y location from the bottom left.
1593 * width: Width of the widget. 1593 * width: Width of the widget.
1594 * height: Height of the widget. 1594 * height: Height of the widget.
1595 */ 1595 */
1596 void API dw_window_set_pos_size(HWND handle, ULONG x, ULONG y, ULONG width, ULONG height) 1596 void API dw_window_set_pos_size(HWND handle, LONG x, LONG y, ULONG width, ULONG height)
1597 { 1597 {
1598 dw_window_set_pos(handle, x, y); 1598 dw_window_set_pos(handle, x, y);
1599 dw_window_set_size(handle, width, height); 1599 dw_window_set_size(handle, width, height);
1600 } 1600 }
1601 1601
1602 /* 1602 /*
1603 * Gets the position and size of a given window (widget). 1603 * Gets the position and size of a given window (widget).
1604 * Parameters: 1604 * Parameters:
1606 * x: X location from the bottom left. 1606 * x: X location from the bottom left.
1607 * y: Y location from the bottom left. 1607 * y: Y location from the bottom left.
1608 * width: Width of the widget. 1608 * width: Width of the widget.
1609 * height: Height of the widget. 1609 * height: Height of the widget.
1610 */ 1610 */
1611 void API dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height) 1611 void API dw_window_get_pos_size(HWND handle, LONG *x, LONG *y, ULONG *width, ULONG *height)
1612 { 1612 {
1613 } 1613 }
1614 1614
1615 /* 1615 /*
1616 * Sets the style of a given window (widget). 1616 * Sets the style of a given window (widget).
1630 * flags: Any additional page creation flags. 1630 * flags: Any additional page creation flags.
1631 * front: If TRUE page is added at the beginning. 1631 * front: If TRUE page is added at the beginning.
1632 */ 1632 */
1633 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front) 1633 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front)
1634 { 1634 {
1635 return 0; 1635 return 0;
1636 } 1636 }
1637 1637
1638 /* 1638 /*
1639 * Remove a page from a notebook. 1639 * Remove a page from a notebook.
1640 * Parameters: 1640 * Parameters:
1650 * Parameters: 1650 * Parameters:
1651 * handle: Handle to the notebook widget. 1651 * handle: Handle to the notebook widget.
1652 */ 1652 */
1653 unsigned long API dw_notebook_page_get(HWND handle) 1653 unsigned long API dw_notebook_page_get(HWND handle)
1654 { 1654 {
1655 return 0; 1655 return 0;
1656 } 1656 }
1657 1657
1658 /* 1658 /*
1659 * Sets the currently visibale page ID. 1659 * Sets the currently visibale page ID.
1660 * Parameters: 1660 * Parameters:
1733 * Parameters: 1733 * Parameters:
1734 * handle: Handle to the listbox to be cleared. 1734 * handle: Handle to the listbox to be cleared.
1735 */ 1735 */
1736 int API dw_listbox_count(HWND handle) 1736 int API dw_listbox_count(HWND handle)
1737 { 1737 {
1738 return 0; 1738 return 0;
1739 } 1739 }
1740 1740
1741 /* 1741 /*
1742 * Sets the topmost item in the viewport. 1742 * Sets the topmost item in the viewport.
1743 * Parameters: 1743 * Parameters:
1787 * handle: Handle to the listbox to be queried. 1787 * handle: Handle to the listbox to be queried.
1788 * where: Either the previous return or -1 to restart. 1788 * where: Either the previous return or -1 to restart.
1789 */ 1789 */
1790 int API dw_listbox_selected_multi(HWND handle, int where) 1790 int API dw_listbox_selected_multi(HWND handle, int where)
1791 { 1791 {
1792 return -1; 1792 return -1;
1793 } 1793 }
1794 1794
1795 /* 1795 /*
1796 * Sets the selection state of a given index. 1796 * Sets the selection state of a given index.
1797 * Parameters: 1797 * Parameters:
1916 * point: Start point of search. 1916 * point: Start point of search.
1917 * flags: Search specific flags. 1917 * flags: Search specific flags.
1918 */ 1918 */
1919 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags) 1919 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
1920 { 1920 {
1921 return 0; 1921 return 0;
1922 } 1922 }
1923 1923
1924 /* 1924 /*
1925 * Stops redrawing of an MLE box. 1925 * Stops redrawing of an MLE box.
1926 * Parameters: 1926 * Parameters:
1954 * Parameters: 1954 * Parameters:
1955 * handle: Handle to the slider to be queried. 1955 * handle: Handle to the slider to be queried.
1956 */ 1956 */
1957 unsigned int API dw_slider_get_pos(HWND handle) 1957 unsigned int API dw_slider_get_pos(HWND handle)
1958 { 1958 {
1959 return 0; 1959 return 0;
1960 } 1960 }
1961 1961
1962 /* 1962 /*
1963 * Sets the slider position. 1963 * Sets the slider position.
1964 * Parameters: 1964 * Parameters:
1974 * Parameters: 1974 * Parameters:
1975 * handle: Handle to the scrollbar to be queried. 1975 * handle: Handle to the scrollbar to be queried.
1976 */ 1976 */
1977 unsigned int API dw_scrollbar_get_pos(HWND handle) 1977 unsigned int API dw_scrollbar_get_pos(HWND handle)
1978 { 1978 {
1979 return 0; 1979 return 0;
1980 } 1980 }
1981 1981
1982 /* 1982 /*
1983 * Sets the scrollbar position. 1983 * Sets the scrollbar position.
1984 * Parameters: 1984 * Parameters:
2047 * Parameters: 2047 * Parameters:
2048 * handle: Handle to the checkbox to be queried. 2048 * handle: Handle to the checkbox to be queried.
2049 */ 2049 */
2050 int API dw_checkbox_get(HWND handle) 2050 int API dw_checkbox_get(HWND handle)
2051 { 2051 {
2052 return 0; 2052 return 0;
2053 } 2053 }
2054 2054
2055 /* 2055 /*
2056 * Sets the state of the checkbox. 2056 * Sets the state of the checkbox.
2057 * Parameters: 2057 * Parameters:
2072 * parent: Parent handle or 0 if root. 2072 * parent: Parent handle or 0 if root.
2073 * itemdata: Item specific data. 2073 * itemdata: Item specific data.
2074 */ 2074 */
2075 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) 2075 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HTREEITEM parent, void *itemdata)
2076 { 2076 {
2077 return 0; 2077 return 0;
2078 } 2078 }
2079 2079
2080 /* 2080 /*
2081 * Inserts an item into a tree window (widget). 2081 * Inserts an item into a tree window (widget).
2082 * Parameters: 2082 * Parameters:
2086 * parent: Parent handle or 0 if root. 2086 * parent: Parent handle or 0 if root.
2087 * itemdata: Item specific data. 2087 * itemdata: Item specific data.
2088 */ 2088 */
2089 HTREEITEM API dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) 2089 HTREEITEM API dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata)
2090 { 2090 {
2091 return 0; 2091 return 0;
2092 } 2092 }
2093 2093
2094 /* 2094 /*
2095 * Sets the text and icon of an item in a tree window (widget). 2095 * Sets the text and icon of an item in a tree window (widget).
2096 * Parameters: 2096 * Parameters:
2120 * handle: Handle to the tree containing the item. 2120 * handle: Handle to the tree containing the item.
2121 * item: Handle of the item to be modified. 2121 * item: Handle of the item to be modified.
2122 */ 2122 */
2123 void * API dw_tree_item_get_data(HWND handle, HTREEITEM item) 2123 void * API dw_tree_item_get_data(HWND handle, HTREEITEM item)
2124 { 2124 {
2125 return NULL; 2125 return NULL;
2126 } 2126 }
2127 2127
2128 /* 2128 /*
2129 * Sets this item as the active selection. 2129 * Sets this item as the active selection.
2130 * Parameters: 2130 * Parameters:
2184 * separator: The column number that contains the main separator. 2184 * separator: The column number that contains the main separator.
2185 * (this item may only be used in OS/2) 2185 * (this item may only be used in OS/2)
2186 */ 2186 */
2187 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) 2187 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator)
2188 { 2188 {
2189 return TRUE; 2189 return TRUE;
2190 } 2190 }
2191 2191
2192 /* 2192 /*
2193 * Sets up the filesystem columns, note: filesystem always has an icon/filename field. 2193 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
2194 * Parameters: 2194 * Parameters:
2197 * titles: An array of strings with column text titles. 2197 * titles: An array of strings with column text titles.
2198 * count: The number of columns (this should match the arrays). 2198 * count: The number of columns (this should match the arrays).
2199 */ 2199 */
2200 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) 2200 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
2201 { 2201 {
2202 char **newtitles = malloc(sizeof(char *) * (count + 2)); 2202 char **newtitles = malloc(sizeof(char *) * (count + 2));
2203 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); 2203 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2));
2204 2204
2205 newtitles[0] = "Icon"; 2205 newtitles[0] = "Icon";
2206 newtitles[1] = "Filename"; 2206 newtitles[1] = "Filename";
2207 2207
2208 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR; 2208 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR;
2209 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; 2209 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR;
2210 2210
2211 memcpy(&newtitles[2], titles, sizeof(char *) * count); 2211 memcpy(&newtitles[2], titles, sizeof(char *) * count);
2212 memcpy(&newflags[2], flags, sizeof(unsigned long) * count); 2212 memcpy(&newflags[2], flags, sizeof(unsigned long) * count);
2213 2213
2214 dw_container_setup(handle, newflags, newtitles, count + 2, count ? 2 : 0); 2214 dw_container_setup(handle, newflags, newtitles, count + 2, count ? 2 : 0);
2215 2215
2216 free(newtitles); 2216 free(newtitles);
2217 free(newflags); 2217 free(newflags);
2218 return TRUE; 2218 return TRUE;
2219 } 2219 }
2220 2220
2221 /* 2221 /*
2222 * Obtains an icon from a module (or header in GTK). 2222 * Obtains an icon from a module (or header in GTK).
2223 * Parameters: 2223 * Parameters:
2226 * Windows, on GTK this is converted to a pointer 2226 * Windows, on GTK this is converted to a pointer
2227 * to an embedded XPM. 2227 * to an embedded XPM.
2228 */ 2228 */
2229 unsigned long API dw_icon_load(unsigned long module, unsigned long id) 2229 unsigned long API dw_icon_load(unsigned long module, unsigned long id)
2230 { 2230 {
2231 return 0; 2231 return 0;
2232 } 2232 }
2233 2233
2234 /* 2234 /*
2235 * Obtains an icon from a file. 2235 * Obtains an icon from a file.
2236 * Parameters: 2236 * Parameters:
2238 * DW pick the appropriate file extension. 2238 * DW pick the appropriate file extension.
2239 * (ICO on OS/2 or Windows, XPM on Unix) 2239 * (ICO on OS/2 or Windows, XPM on Unix)
2240 */ 2240 */
2241 unsigned long API dw_icon_load_from_file(char *filename) 2241 unsigned long API dw_icon_load_from_file(char *filename)
2242 { 2242 {
2243 return 0; 2243 return 0;
2244 } 2244 }
2245 2245
2246 /* 2246 /*
2247 * Obtains an icon from data. 2247 * Obtains an icon from data.
2248 * Parameters: 2248 * Parameters:
2249 * data: Source of data for image. 2249 * data: Source of data for image.
2250 * len: length of data 2250 * len: length of data
2251 */ 2251 */
2252 unsigned long API dw_icon_load_from_data(char *data, int len) 2252 unsigned long API dw_icon_load_from_data(char *data, int len)
2253 { 2253 {
2254 return 0; 2254 return 0;
2255 } 2255 }
2256 2256
2257 /* 2257 /*
2258 * Frees a loaded resource in OS/2 and Windows. 2258 * Frees a loaded resource in OS/2 and Windows.
2259 * Parameters: 2259 * Parameters:
2269 * handle: Handle to the container window (widget). 2269 * handle: Handle to the container window (widget).
2270 * rowcount: The number of items to be populated. 2270 * rowcount: The number of items to be populated.
2271 */ 2271 */
2272 void * API dw_container_alloc(HWND handle, int rowcount) 2272 void * API dw_container_alloc(HWND handle, int rowcount)
2273 { 2273 {
2274 return NULL; 2274 return NULL;
2275 } 2275 }
2276 2276
2277 /* 2277 /*
2278 * Sets an item in specified row and column to the given data. 2278 * Sets an item in specified row and column to the given data.
2279 * Parameters: 2279 * Parameters:
2307 * row: Zero based row of data being set. 2307 * row: Zero based row of data being set.
2308 * data: Pointer to the data to be added. 2308 * data: Pointer to the data to be added.
2309 */ 2309 */
2310 void API dw_filesystem_change_item(HWND handle, int column, int row, void *data) 2310 void API dw_filesystem_change_item(HWND handle, int column, int row, void *data)
2311 { 2311 {
2312 dw_filesystem_set_item(handle, NULL, column, row, data); 2312 dw_filesystem_set_item(handle, NULL, column, row, data);
2313 } 2313 }
2314 2314
2315 /* 2315 /*
2316 * Changes an item in specified row and column to the given data. 2316 * Changes an item in specified row and column to the given data.
2317 * Parameters: 2317 * Parameters:
2321 * row: Zero based row of data being set. 2321 * row: Zero based row of data being set.
2322 * data: Pointer to the data to be added. 2322 * data: Pointer to the data to be added.
2323 */ 2323 */
2324 void API dw_filesystem_change_file(HWND handle, int row, char *filename, unsigned long icon) 2324 void API dw_filesystem_change_file(HWND handle, int row, char *filename, unsigned long icon)
2325 { 2325 {
2326 dw_filesystem_set_file(handle, NULL, row, filename, icon); 2326 dw_filesystem_set_file(handle, NULL, row, filename, icon);
2327 } 2327 }
2328 2328
2329 /* 2329 /*
2330 * Sets an item in specified row and column to the given data. 2330 * Sets an item in specified row and column to the given data.
2331 * Parameters: 2331 * Parameters:
2335 * row: Zero based row of data being set. 2335 * row: Zero based row of data being set.
2336 * data: Pointer to the data to be added. 2336 * data: Pointer to the data to be added.
2337 */ 2337 */
2338 void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) 2338 void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon)
2339 { 2339 {
2340 dw_container_set_item(handle, pointer, 0, row, (void *)&icon); 2340 dw_container_set_item(handle, pointer, 0, row, (void *)&icon);
2341 dw_container_set_item(handle, pointer, 1, row, (void *)&filename); 2341 dw_container_set_item(handle, pointer, 1, row, (void *)&filename);
2342 } 2342 }
2343 2343
2344 /* 2344 /*
2345 * Sets an item in specified row and column to the given data. 2345 * Sets an item in specified row and column to the given data.
2346 * Parameters: 2346 * Parameters:
2350 * row: Zero based row of data being set. 2350 * row: Zero based row of data being set.
2351 * data: Pointer to the data to be added. 2351 * data: Pointer to the data to be added.
2352 */ 2352 */
2353 void API dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) 2353 void API dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data)
2354 { 2354 {
2355 dw_container_set_item(handle, pointer, column + 2, row, data); 2355 dw_container_set_item(handle, pointer, column + 2, row, data);
2356 } 2356 }
2357 2357
2358 /* 2358 /*
2359 * Gets column type for a container column 2359 * Gets column type for a container column
2360 * Parameters: 2360 * Parameters:
2361 * handle: Handle to the container window (widget). 2361 * handle: Handle to the container window (widget).
2362 * column: Zero based column. 2362 * column: Zero based column.
2363 */ 2363 */
2364 int API dw_container_get_column_type(HWND handle, int column) 2364 int API dw_container_get_column_type(HWND handle, int column)
2365 { 2365 {
2366 return 0; 2366 return 0;
2367 } 2367 }
2368 2368
2369 /* 2369 /*
2370 * Gets column type for a filesystem container column 2370 * Gets column type for a filesystem container column
2371 * Parameters: 2371 * Parameters:
2372 * handle: Handle to the container window (widget). 2372 * handle: Handle to the container window (widget).
2373 * column: Zero based column. 2373 * column: Zero based column.
2374 */ 2374 */
2375 int API dw_filesystem_get_column_type(HWND handle, int column) 2375 int API dw_filesystem_get_column_type(HWND handle, int column)
2376 { 2376 {
2377 return dw_container_get_column_type( handle, column + 1 ); 2377 return dw_container_get_column_type( handle, column + 1 );
2378 } 2378 }
2379 2379
2380 /* 2380 /*
2381 * Sets the width of a column in the container. 2381 * Sets the width of a column in the container.
2382 * Parameters: 2382 * Parameters:
2525 * Returns: 2525 * Returns:
2526 * A handle to the widget or NULL on failure. 2526 * A handle to the widget or NULL on failure.
2527 */ 2527 */
2528 HWND API dw_render_new(unsigned long id) 2528 HWND API dw_render_new(unsigned long id)
2529 { 2529 {
2530 return 0; 2530 return 0;
2531 } 2531 }
2532 2532
2533 /* Sets the current foreground drawing color. 2533 /* Sets the current foreground drawing color.
2534 * Parameters: 2534 * Parameters:
2535 * red: red value. 2535 * red: red value.
2556 * Returns: 2556 * Returns:
2557 * The selected color or the current color if cancelled. 2557 * The selected color or the current color if cancelled.
2558 */ 2558 */
2559 unsigned long API dw_color_choose(unsigned long value) 2559 unsigned long API dw_color_choose(unsigned long value)
2560 { 2560 {
2561 dw_messagebox("Not implemented", DW_MB_OK|DW_MB_INFORMATION, "This feature not yet supported."); 2561 dw_messagebox("Not implemented", DW_MB_OK|DW_MB_INFORMATION, "This feature not yet supported.");
2562 return value; 2562 return value;
2563 } 2563 }
2564 2564
2565 /* Draw a point on a window (preferably a render window). 2565 /* Draw a point on a window (preferably a render window).
2566 * Parameters: 2566 * Parameters:
2567 * handle: Handle to the window. 2567 * handle: Handle to the window.
2641 * Returns: 2641 * Returns:
2642 * A handle to a pixmap or NULL on failure. 2642 * A handle to a pixmap or NULL on failure.
2643 */ 2643 */
2644 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) 2644 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth)
2645 { 2645 {
2646 return 0; 2646 return 0;
2647 } 2647 }
2648 2648
2649 /* 2649 /*
2650 * Creates a pixmap from a file. 2650 * Creates a pixmap from a file.
2651 * Parameters: 2651 * Parameters:
2656 * Returns: 2656 * Returns:
2657 * A handle to a pixmap or NULL on failure. 2657 * A handle to a pixmap or NULL on failure.
2658 */ 2658 */
2659 HPIXMAP API dw_pixmap_new_from_file(HWND handle, char *filename) 2659 HPIXMAP API dw_pixmap_new_from_file(HWND handle, char *filename)
2660 { 2660 {
2661 return 0; 2661 return 0;
2662 } 2662 }
2663 2663
2664 /* 2664 /*
2665 * Creates a pixmap from data 2665 * Creates a pixmap from data
2666 * Parameters: 2666 * Parameters:
2671 * Returns: 2671 * Returns:
2672 * A handle to a pixmap or NULL on failure. 2672 * A handle to a pixmap or NULL on failure.
2673 */ 2673 */
2674 HPIXMAP API dw_pixmap_new_from_data(HWND handle, char *data, int len) 2674 HPIXMAP API dw_pixmap_new_from_data(HWND handle, char *data, int len)
2675 { 2675 {
2676 return 0; 2676 return 0;
2677 } 2677 }
2678 2678
2679 /* 2679 /*
2680 * Creates a pixmap from internal resource graphic specified by id. 2680 * Creates a pixmap from internal resource graphic specified by id.
2681 * Parameters: 2681 * Parameters:
2684 * Returns: 2684 * Returns:
2685 * A handle to a pixmap or NULL on failure. 2685 * A handle to a pixmap or NULL on failure.
2686 */ 2686 */
2687 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG id) 2687 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG id)
2688 { 2688 {
2689 return 0; 2689 return 0;
2690 } 2690 }
2691 2691
2692 /* 2692 /*
2693 * Destroys an allocated pixmap. 2693 * Destroys an allocated pixmap.
2694 * Parameters: 2694 * Parameters:
2723 * freq: Frequency. 2723 * freq: Frequency.
2724 * dur: Duration. 2724 * dur: Duration.
2725 */ 2725 */
2726 void API dw_beep(int freq, int dur) 2726 void API dw_beep(int freq, int dur)
2727 { 2727 {
2728 SysBeep(dur); 2728 SysBeep(dur);
2729 } 2729 }
2730 2730
2731 /* Open a shared library and return a handle. 2731 /* Open a shared library and return a handle.
2732 * Parameters: 2732 * Parameters:
2733 * name: Base name of the shared library. 2733 * name: Base name of the shared library.
2734 * handle: Pointer to a module handle, 2734 * handle: Pointer to a module handle,
2735 * will be filled in with the handle. 2735 * will be filled in with the handle.
2736 */ 2736 */
2737 int API dw_module_load(char *name, HMOD *handle) 2737 int API dw_module_load(char *name, HMOD *handle)
2738 { 2738 {
2739 return 0; 2739 return 0;
2740 } 2740 }
2741 2741
2742 /* Queries the address of a symbol within open handle. 2742 /* Queries the address of a symbol within open handle.
2743 * Parameters: 2743 * Parameters:
2744 * handle: Module handle returned by dw_module_load() 2744 * handle: Module handle returned by dw_module_load()
2746 * func: A pointer to a function pointer, to obtain 2746 * func: A pointer to a function pointer, to obtain
2747 * the address. 2747 * the address.
2748 */ 2748 */
2749 int API dw_module_symbol(HMOD handle, char *name, void**func) 2749 int API dw_module_symbol(HMOD handle, char *name, void**func)
2750 { 2750 {
2751 return 0; 2751 return 0;
2752 } 2752 }
2753 2753
2754 /* Frees the shared library previously opened. 2754 /* Frees the shared library previously opened.
2755 * Parameters: 2755 * Parameters:
2756 * handle: Module handle returned by dw_module_load() 2756 * handle: Module handle returned by dw_module_load()
2757 */ 2757 */
2758 int API dw_module_close(HMOD handle) 2758 int API dw_module_close(HMOD handle)
2759 { 2759 {
2760 return 0; 2760 return 0;
2761 } 2761 }
2762 2762
2763 /* 2763 /*
2764 * Returns the handle to an unnamed mutex semaphore. 2764 * Returns the handle to an unnamed mutex semaphore.
2765 */ 2765 */
2766 HMTX API dw_mutex_new(void) 2766 HMTX API dw_mutex_new(void)
2767 { 2767 {
2768 return 0; 2768 return 0;
2769 } 2769 }
2770 2770
2771 /* 2771 /*
2772 * Closes a semaphore created by dw_mutex_new(). 2772 * Closes a semaphore created by dw_mutex_new().
2773 * Parameters: 2773 * Parameters:
2800 /* 2800 /*
2801 * Returns the handle to an unnamed event semaphore. 2801 * Returns the handle to an unnamed event semaphore.
2802 */ 2802 */
2803 HEV API dw_event_new(void) 2803 HEV API dw_event_new(void)
2804 { 2804 {
2805 return 0; 2805 return 0;
2806 } 2806 }
2807 2807
2808 /* 2808 /*
2809 * Resets a semaphore created by dw_event_new(). 2809 * Resets a semaphore created by dw_event_new().
2810 * Parameters: 2810 * Parameters:
2811 * eve: The handle to the event returned by dw_event_new(). 2811 * eve: The handle to the event returned by dw_event_new().
2812 */ 2812 */
2813 int API dw_event_reset(HEV eve) 2813 int API dw_event_reset(HEV eve)
2814 { 2814 {
2815 return TRUE; 2815 return TRUE;
2816 } 2816 }
2817 2817
2818 /* 2818 /*
2819 * Posts a semaphore created by dw_event_new(). Causing all threads 2819 * Posts a semaphore created by dw_event_new(). Causing all threads
2820 * waiting on this event in dw_event_wait to continue. 2820 * waiting on this event in dw_event_wait to continue.
2821 * Parameters: 2821 * Parameters:
2822 * eve: The handle to the event returned by dw_event_new(). 2822 * eve: The handle to the event returned by dw_event_new().
2823 */ 2823 */
2824 int API dw_event_post(HEV eve) 2824 int API dw_event_post(HEV eve)
2825 { 2825 {
2826 return TRUE; 2826 return TRUE;
2827 } 2827 }
2828 2828
2829 2829
2830 /* 2830 /*
2831 * Waits on a semaphore created by dw_event_new(), until the 2831 * Waits on a semaphore created by dw_event_new(), until the
2833 * Parameters: 2833 * Parameters:
2834 * eve: The handle to the event returned by dw_event_new(). 2834 * eve: The handle to the event returned by dw_event_new().
2835 */ 2835 */
2836 int API dw_event_wait(HEV eve, unsigned long timeout) 2836 int API dw_event_wait(HEV eve, unsigned long timeout)
2837 { 2837 {
2838 return TRUE; 2838 return TRUE;
2839 } 2839 }
2840 2840
2841 /* 2841 /*
2842 * Closes a semaphore created by dw_event_new(). 2842 * Closes a semaphore created by dw_event_new().
2843 * Parameters: 2843 * Parameters:
2844 * eve: The handle to the event returned by dw_event_new(). 2844 * eve: The handle to the event returned by dw_event_new().
2845 */ 2845 */
2846 int API dw_event_close(HEV *eve) 2846 int API dw_event_close(HEV *eve)
2847 { 2847 {
2848 return TRUE; 2848 return TRUE;
2849 } 2849 }
2850 2850
2851 /* Create a named event semaphore which can be 2851 /* Create a named event semaphore which can be
2852 * opened from other processes. 2852 * opened from other processes.
2853 * Parameters: 2853 * Parameters:
2855 * name: Name given to semaphore which can be opened 2855 * name: Name given to semaphore which can be opened
2856 * by other processes. 2856 * by other processes.
2857 */ 2857 */
2858 HEV API dw_named_event_new(char *name) 2858 HEV API dw_named_event_new(char *name)
2859 { 2859 {
2860 return 0; 2860 return 0;
2861 } 2861 }
2862 2862
2863 /* Open an already existing named event semaphore. 2863 /* Open an already existing named event semaphore.
2864 * Parameters: 2864 * Parameters:
2865 * eve: Pointer to an event handle to receive handle. 2865 * eve: Pointer to an event handle to receive handle.
2866 * name: Name given to semaphore which can be opened 2866 * name: Name given to semaphore which can be opened
2867 * by other processes. 2867 * by other processes.
2868 */ 2868 */
2869 HEV API dw_named_event_get(char *name) 2869 HEV API dw_named_event_get(char *name)
2870 { 2870 {
2871 return 0; 2871 return 0;
2872 } 2872 }
2873 2873
2874 /* Resets the event semaphore so threads who call wait 2874 /* Resets the event semaphore so threads who call wait
2875 * on this semaphore will block. 2875 * on this semaphore will block.
2876 * Parameters: 2876 * Parameters:
2877 * eve: Handle to the semaphore obtained by 2877 * eve: Handle to the semaphore obtained by
2878 * an open or create call. 2878 * an open or create call.
2879 */ 2879 */
2880 int API dw_named_event_reset(HEV eve) 2880 int API dw_named_event_reset(HEV eve)
2881 { 2881 {
2882 return 0; 2882 return 0;
2883 } 2883 }
2884 2884
2885 /* Sets the posted state of an event semaphore, any threads 2885 /* Sets the posted state of an event semaphore, any threads
2886 * waiting on the semaphore will no longer block. 2886 * waiting on the semaphore will no longer block.
2887 * Parameters: 2887 * Parameters:
2888 * eve: Handle to the semaphore obtained by 2888 * eve: Handle to the semaphore obtained by
2889 * an open or create call. 2889 * an open or create call.
2890 */ 2890 */
2891 int API dw_named_event_post(HEV eve) 2891 int API dw_named_event_post(HEV eve)
2892 { 2892 {
2893 return 0; 2893 return 0;
2894 } 2894 }
2895 2895
2896 2896
2897 /* Waits on the specified semaphore until it becomes 2897 /* Waits on the specified semaphore until it becomes
2898 * posted, or returns immediately if it already is posted. 2898 * posted, or returns immediately if it already is posted.
2902 * timeout: Number of milliseconds before timing out 2902 * timeout: Number of milliseconds before timing out
2903 * or -1 if indefinite. 2903 * or -1 if indefinite.
2904 */ 2904 */
2905 int API dw_named_event_wait(HEV eve, unsigned long timeout) 2905 int API dw_named_event_wait(HEV eve, unsigned long timeout)
2906 { 2906 {
2907 return 0; 2907 return 0;
2908 } 2908 }
2909 2909
2910 /* Release this semaphore, if there are no more open 2910 /* Release this semaphore, if there are no more open
2911 * handles on this semaphore the semaphore will be destroyed. 2911 * handles on this semaphore the semaphore will be destroyed.
2912 * Parameters: 2912 * Parameters:
2913 * eve: Handle to the semaphore obtained by 2913 * eve: Handle to the semaphore obtained by
2914 * an open or create call. 2914 * an open or create call.
2915 */ 2915 */
2916 int API dw_named_event_close(HEV eve) 2916 int API dw_named_event_close(HEV eve)
2917 { 2917 {
2918 return 0; 2918 return 0;
2919 } 2919 }
2920 2920
2921 /* 2921 /*
2922 * Allocates a shared memory region with a name. 2922 * Allocates a shared memory region with a name.
2923 * Parameters: 2923 * Parameters:
2926 * size: Size in bytes of the shared memory region to allocate. 2926 * size: Size in bytes of the shared memory region to allocate.
2927 * name: A string pointer to a unique memory name. 2927 * name: A string pointer to a unique memory name.
2928 */ 2928 */
2929 HSHM API dw_named_memory_new(void **dest, int size, char *name) 2929 HSHM API dw_named_memory_new(void **dest, int size, char *name)
2930 { 2930 {
2931 return 0; 2931 return 0;
2932 } 2932 }
2933 2933
2934 /* 2934 /*
2935 * Aquires shared memory region with a name. 2935 * Aquires shared memory region with a name.
2936 * Parameters: 2936 * Parameters:
2938 * size: Size in bytes of the shared memory region to requested. 2938 * size: Size in bytes of the shared memory region to requested.
2939 * name: A string pointer to a unique memory name. 2939 * name: A string pointer to a unique memory name.
2940 */ 2940 */
2941 HSHM API dw_named_memory_get(void **dest, int size, char *name) 2941 HSHM API dw_named_memory_get(void **dest, int size, char *name)
2942 { 2942 {
2943 return 0; 2943 return 0;
2944 } 2944 }
2945 2945
2946 /* 2946 /*
2947 * Frees a shared memory region previously allocated. 2947 * Frees a shared memory region previously allocated.
2948 * Parameters: 2948 * Parameters:
2950 * ptr: The memory address aquired with DB_named_memory_allocate. 2950 * ptr: The memory address aquired with DB_named_memory_allocate.
2951 */ 2951 */
2952 int API dw_named_memory_free(HSHM handle, void *ptr) 2952 int API dw_named_memory_free(HSHM handle, void *ptr)
2953 { 2953 {
2954 2954
2955 return 0; 2955 return 0;
2956 } 2956 }
2957 2957
2958 /* 2958 /*
2959 * Creates a new thread with a starting point of func. 2959 * Creates a new thread with a starting point of func.
2960 * Parameters: 2960 * Parameters:
2962 * data: Parameter(s) passed to the function. 2962 * data: Parameter(s) passed to the function.
2963 * stack: Stack size of new thread (OS/2 and Windows only). 2963 * stack: Stack size of new thread (OS/2 and Windows only).
2964 */ 2964 */
2965 DWTID API dw_thread_new(void *func, void *data, int stack) 2965 DWTID API dw_thread_new(void *func, void *data, int stack)
2966 { 2966 {
2967 return (DWTID)-1; 2967 return (DWTID)-1;
2968 } 2968 }
2969 2969
2970 /* 2970 /*
2971 * Ends execution of current thread immediately. 2971 * Ends execution of current thread immediately.
2972 */ 2972 */
2977 /* 2977 /*
2978 * Returns the current thread's ID. 2978 * Returns the current thread's ID.
2979 */ 2979 */
2980 DWTID API dw_thread_id(void) 2980 DWTID API dw_thread_id(void)
2981 { 2981 {
2982 return 0; 2982 return 0;
2983 } 2983 }
2984 2984
2985 /* 2985 /*
2986 * Cleanly terminates a DW session, should be signal handler safe. 2986 * Cleanly terminates a DW session, should be signal handler safe.
2987 * Parameters: 2987 * Parameters:
2988 * exitcode: Exit code reported to the operating system. 2988 * exitcode: Exit code reported to the operating system.
2989 */ 2989 */
2990 void API dw_exit(int exitcode) 2990 void API dw_exit(int exitcode)
2991 { 2991 {
2992 exit(exitcode); 2992 exit(exitcode);
2993 } 2993 }
2994 2994
2995 /* 2995 /*
2996 * Creates a splitbar window (widget) with given parameters. 2996 * Creates a splitbar window (widget) with given parameters.
2997 * Parameters: 2997 * Parameters:
3001 * Returns: 3001 * Returns:
3002 * A handle to a splitbar window or NULL on failure. 3002 * A handle to a splitbar window or NULL on failure.
3003 */ 3003 */
3004 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id) 3004 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id)
3005 { 3005 {
3006 return 0; 3006 return 0;
3007 } 3007 }
3008 3008
3009 /* 3009 /*
3010 * Sets the position of a splitbar (pecentage). 3010 * Sets the position of a splitbar (pecentage).
3011 * Parameters: 3011 * Parameters:
3020 * Parameters: 3020 * Parameters:
3021 * handle: The handle to the splitbar returned by dw_splitbar_new(). 3021 * handle: The handle to the splitbar returned by dw_splitbar_new().
3022 */ 3022 */
3023 float API dw_splitbar_get(HWND handle) 3023 float API dw_splitbar_get(HWND handle)
3024 { 3024 {
3025 return 0.0; 3025 return 0.0;
3026 } 3026 }
3027 3027
3028 /* 3028 /*
3029 * Creates a calendar window (widget) with given parameters. 3029 * Creates a calendar window (widget) with given parameters.
3030 * Parameters: 3030 * Parameters:
3032 * Returns: 3032 * Returns:
3033 * A handle to a calendar window or NULL on failure. 3033 * A handle to a calendar window or NULL on failure.
3034 */ 3034 */
3035 HWND dw_calendar_new(unsigned long id) 3035 HWND dw_calendar_new(unsigned long id)
3036 { 3036 {
3037 return 0; 3037 return 0;
3038 } 3038 }
3039 3039
3040 /* 3040 /*
3041 * Sets the current date of a calendar 3041 * Sets the current date of a calendar
3042 * Parameters: 3042 * Parameters:
3043 * handle: The handle to the calendar returned by dw_calendar_new(). 3043 * handle: The handle to the calendar returned by dw_calendar_new().
3044 * year... 3044 * year...
3045 */ 3045 */
3046 void dw_calendar_set_date(HWND handle, unsigned int year, unsigned int month, unsigned int day) 3046 void dw_calendar_set_date(HWND handle, unsigned int year, unsigned int month, unsigned int day)
3047 { 3047 {
3048 return; 3048 return;
3049 } 3049 }
3050 3050
3051 /* 3051 /*
3052 * Gets the position of a splitbar (pecentage). 3052 * Gets the position of a splitbar (pecentage).
3053 * Parameters: 3053 * Parameters:
3054 * handle: The handle to the splitbar returned by dw_splitbar_new(). 3054 * handle: The handle to the splitbar returned by dw_splitbar_new().
3055 */ 3055 */
3056 void dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day) 3056 void dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day)
3057 { 3057 {
3058 return; 3058 return;
3059 } 3059 }
3060 3060
3061 /* 3061 /*
3062 * Pack windows (widgets) into a box from the start (or top). 3062 * Pack windows (widgets) into a box from the start (or top).
3063 * Parameters: 3063 * Parameters:
3098 * Parameters: 3098 * Parameters:
3099 * env: Pointer to a DWEnv struct. 3099 * env: Pointer to a DWEnv struct.
3100 */ 3100 */
3101 void API dw_environment_query(DWEnv *env) 3101 void API dw_environment_query(DWEnv *env)
3102 { 3102 {
3103 ULONG Build; 3103 ULONG Build;
3104 char verbuf[10]; 3104 char verbuf[10];
3105 3105
3106 if(!env) 3106 if(!env)
3107 return; 3107 return;
3108 3108
3109 Gestalt(gestaltSystemVersion, &Build); 3109 Gestalt(gestaltSystemVersion, &Build);
3110 3110
3111 sprintf(verbuf, "%04x", (int)Build); 3111 sprintf(verbuf, "%04x", (int)Build);
3112 3112
3113 strcpy(env->osName,"MacOS"); 3113 strcpy(env->osName,"MacOS");
3114 env->MajorBuild = atoi(&verbuf[3]); 3114 env->MajorBuild = atoi(&verbuf[3]);
3115 verbuf[3] = 0; 3115 verbuf[3] = 0;
3116 env->MinorVersion = atoi(&verbuf[2]); 3116 env->MinorVersion = atoi(&verbuf[2]);
3117 verbuf[2] = 0; 3117 verbuf[2] = 0;
3118 env->MajorVersion = atoi(verbuf); 3118 env->MajorVersion = atoi(verbuf);
3119 3119
3120 env->MinorBuild = 0; 3120 env->MinorBuild = 0;
3121 3121
3122 strcpy(env->buildDate, __DATE__); 3122 strcpy(env->buildDate, __DATE__);
3123 strcpy(env->buildTime, __TIME__); 3123 strcpy(env->buildTime, __TIME__);
3124 env->DWMajorVersion = DW_MAJOR_VERSION; 3124 env->DWMajorVersion = DW_MAJOR_VERSION;
3125 env->DWMinorVersion = DW_MINOR_VERSION; 3125 env->DWMinorVersion = DW_MINOR_VERSION;
3126 env->DWSubVersion = DW_SUB_VERSION; 3126 env->DWSubVersion = DW_SUB_VERSION;
3127 } 3127 }
3128 3128
3129 /* 3129 /*
3130 * Opens a file dialog and queries user selection. 3130 * Opens a file dialog and queries user selection.
3131 * Parameters: 3131 * Parameters:
3138 * the file path on success. 3138 * the file path on success.
3139 * 3139 *
3140 */ 3140 */
3141 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags) 3141 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags)
3142 { 3142 {
3143 return NULL; 3143 return NULL;
3144 } 3144 }
3145 3145
3146 /* 3146 /*
3147 * Execute and external program in a seperate session. 3147 * Execute and external program in a seperate session.
3148 * Parameters: 3148 * Parameters:
3152 * Returns: 3152 * Returns:
3153 * -1 on error. 3153 * -1 on error.
3154 */ 3154 */
3155 int API dw_exec(char *program, int type, char **params) 3155 int API dw_exec(char *program, int type, char **params)
3156 { 3156 {
3157 return -1; 3157 return -1;
3158 } 3158 }
3159 3159
3160 /* 3160 /*
3161 * Loads a web browser pointed at the given URL. 3161 * Loads a web browser pointed at the given URL.
3162 * Parameters: 3162 * Parameters:
3163 * url: Uniform resource locator. 3163 * url: Uniform resource locator.
3164 */ 3164 */
3165 int API dw_browse(char *url) 3165 int API dw_browse(char *url)
3166 { 3166 {
3167 return -1; 3167 return -1;
3168 } 3168 }
3169 3169
3170 /* 3170 /*
3171 * Returns a pointer to a static buffer which containes the 3171 * Returns a pointer to a static buffer which containes the
3172 * current user directory. Or the root directory (C:\ on 3172 * current user directory. Or the root directory (C:\ on
3173 * OS/2 and Windows). 3173 * OS/2 and Windows).
3174 */ 3174 */
3175 char * API dw_user_dir(void) 3175 char * API dw_user_dir(void)
3176 { 3176 {
3177 static char _user_dir[1024] = ""; 3177 static char _user_dir[1024] = "";
3178 3178
3179 if(!_user_dir[0]) 3179 if(!_user_dir[0])
3180 { 3180 {
3181 char *home = getenv("HOME"); 3181 char *home = getenv("HOME");
3182 3182
3183 if(home) 3183 if(home)
3184 strcpy(_user_dir, home); 3184 strcpy(_user_dir, home);
3185 else 3185 else
3186 strcpy(_user_dir, "/"); 3186 strcpy(_user_dir, "/");
3187 } 3187 }
3188 return _user_dir; 3188 return _user_dir;
3189 } 3189 }
3190 3190
3191 /* 3191 /*
3192 * Call a function from the window (widget)'s context. 3192 * Call a function from the window (widget)'s context.
3193 * Parameters: 3193 * Parameters:
3203 * a given window handle. Used in dw_window_set_data() and 3203 * a given window handle. Used in dw_window_set_data() and
3204 * dw_window_get_data(). 3204 * dw_window_get_data().
3205 */ 3205 */
3206 static UserData *_find_userdata(UserData **root, char *varname) 3206 static UserData *_find_userdata(UserData **root, char *varname)
3207 { 3207 {
3208 UserData *tmp = *root; 3208 UserData *tmp = *root;
3209 3209
3210 while(tmp) 3210 while(tmp)
3211 { 3211 {
3212 if(strcasecmp(tmp->varname, varname) == 0) 3212 if(strcasecmp(tmp->varname, varname) == 0)
3213 return tmp; 3213 return tmp;
3214 tmp = tmp->next; 3214 tmp = tmp->next;
3215 } 3215 }
3216 return NULL; 3216 return NULL;
3217 } 3217 }
3218 3218
3219 static int _new_userdata(UserData **root, char *varname, void *data) 3219 static int _new_userdata(UserData **root, char *varname, void *data)
3220 { 3220 {
3221 UserData *new = _find_userdata(root, varname); 3221 UserData *new = _find_userdata(root, varname);
3222 3222
3223 if(new) 3223 if(new)
3224 { 3224 {
3225 new->data = data; 3225 new->data = data;
3226 return TRUE; 3226 return TRUE;
3227 } 3227 }
3228 else 3228 else
3229 { 3229 {
3230 new = malloc(sizeof(UserData)); 3230 new = malloc(sizeof(UserData));
3231 if(new) 3231 if(new)
3232 { 3232 {
3233 new->varname = strdup(varname); 3233 new->varname = strdup(varname);
3234 new->data = data; 3234 new->data = data;
3235 3235
3236 new->next = NULL; 3236 new->next = NULL;
3237 3237
3238 if (!*root) 3238 if (!*root)
3239 *root = new; 3239 *root = new;
3240 else 3240 else
3241 { 3241 {
3242 UserData *prev = NULL, *tmp = *root; 3242 UserData *prev = NULL, *tmp = *root;
3243 while(tmp) 3243 while(tmp)
3244 { 3244 {
3245 prev = tmp; 3245 prev = tmp;
3246 tmp = tmp->next; 3246 tmp = tmp->next;
3247 } 3247 }
3248 if(prev) 3248 if(prev)
3249 prev->next = new; 3249 prev->next = new;
3250 else 3250 else
3251 *root = new; 3251 *root = new;
3252 } 3252 }
3253 return TRUE; 3253 return TRUE;
3254 } 3254 }
3255 } 3255 }
3256 return FALSE; 3256 return FALSE;
3257 } 3257 }
3258 3258
3259 static int _remove_userdata(UserData **root, char *varname, int all) 3259 static int _remove_userdata(UserData **root, char *varname, int all)
3260 { 3260 {
3261 UserData *prev = NULL, *tmp = *root; 3261 UserData *prev = NULL, *tmp = *root;
3262 3262
3263 while(tmp) 3263 while(tmp)
3264 { 3264 {
3265 if(all || strcasecmp(tmp->varname, varname) == 0) 3265 if(all || strcasecmp(tmp->varname, varname) == 0)
3266 { 3266 {
3267 if(!prev) 3267 if(!prev)
3268 { 3268 {
3269 *root = tmp->next; 3269 *root = tmp->next;
3270 free(tmp->varname); 3270 free(tmp->varname);
3271 free(tmp); 3271 free(tmp);
3272 if(!all) 3272 if(!all)
3273 return 0; 3273 return 0;
3274 tmp = *root; 3274 tmp = *root;
3275 } 3275 }
3276 else 3276 else
3277 { 3277 {
3278 /* If all is true we should 3278 /* If all is true we should
3279 * never get here. 3279 * never get here.
3280 */ 3280 */
3281 prev->next = tmp->next; 3281 prev->next = tmp->next;
3282 free(tmp->varname); 3282 free(tmp->varname);
3283 free(tmp); 3283 free(tmp);
3284 return 0; 3284 return 0;
3285 } 3285 }
3286 } 3286 }
3287 else 3287 else
3288 { 3288 {
3289 prev = tmp; 3289 prev = tmp;
3290 tmp = tmp->next; 3290 tmp = tmp->next;
3291 } 3291 }
3292 } 3292 }
3293 return 0; 3293 return 0;
3294 } 3294 }
3295 3295
3296 /* 3296 /*
3297 * Add a named user data item to a window handle. 3297 * Add a named user data item to a window handle.
3298 * Parameters: 3298 * Parameters:
3300 * dataname: A string pointer identifying which signal to be hooked. 3300 * dataname: A string pointer identifying which signal to be hooked.
3301 * data: User data to be passed to the handler function. 3301 * data: User data to be passed to the handler function.
3302 */ 3302 */
3303 void API dw_window_set_data(HWND window, char *dataname, void *data) 3303 void API dw_window_set_data(HWND window, char *dataname, void *data)
3304 { 3304 {
3305 WindowData *blah = (WindowData *)_get_window_pointer(window); 3305 WindowData *blah = (WindowData *)_get_window_pointer(window);
3306 3306
3307 if(!blah) 3307 if(!blah)
3308 { 3308 {
3309 if(!dataname) 3309 if(!dataname)
3310 return; 3310 return;
3311 3311
3312 blah = calloc(1, sizeof(WindowData)); 3312 blah = calloc(1, sizeof(WindowData));
3313 _set_window_pointer(window, blah); 3313 _set_window_pointer(window, blah);
3314 } 3314 }
3315 3315
3316 if(data) 3316 if(data)
3317 _new_userdata(&(blah->root), dataname, data); 3317 _new_userdata(&(blah->root), dataname, data);
3318 else 3318 else
3319 { 3319 {
3320 if(dataname) 3320 if(dataname)
3321 _remove_userdata(&(blah->root), dataname, FALSE); 3321 _remove_userdata(&(blah->root), dataname, FALSE);
3322 else 3322 else
3323 _remove_userdata(&(blah->root), NULL, TRUE); 3323 _remove_userdata(&(blah->root), NULL, TRUE);
3324 } 3324 }
3325 } 3325 }
3326 3326
3327 /* 3327 /*
3328 * Gets a named user data item to a window handle. 3328 * Gets a named user data item to a window handle.
3329 * Parameters: 3329 * Parameters:
3331 * dataname: A string pointer identifying which signal to be hooked. 3331 * dataname: A string pointer identifying which signal to be hooked.
3332 * data: User data to be passed to the handler function. 3332 * data: User data to be passed to the handler function.
3333 */ 3333 */
3334 void *dw_window_get_data(HWND window, char *dataname) 3334 void *dw_window_get_data(HWND window, char *dataname)
3335 { 3335 {
3336 WindowData *blah = (WindowData *)_get_window_pointer(window); 3336 WindowData *blah = (WindowData *)_get_window_pointer(window);
3337 3337
3338 if(blah && blah->root && dataname) 3338 if(blah && blah->root && dataname)
3339 { 3339 {
3340 UserData *ud = _find_userdata(&(blah->root), dataname); 3340 UserData *ud = _find_userdata(&(blah->root), dataname);
3341 if(ud) 3341 if(ud)
3342 return ud->data; 3342 return ud->data;
3343 } 3343 }
3344 return NULL; 3344 return NULL;
3345 } 3345 }
3346 3346
3347 /* 3347 /*
3348 * Add a callback to a timer event. 3348 * Add a callback to a timer event.
3349 * Parameters: 3349 * Parameters:
3353 * Returns: 3353 * Returns:
3354 * Timer ID for use with dw_timer_disconnect(), 0 on error. 3354 * Timer ID for use with dw_timer_disconnect(), 0 on error.
3355 */ 3355 */
3356 int API dw_timer_connect(int interval, void *sigfunc, void *data) 3356 int API dw_timer_connect(int interval, void *sigfunc, void *data)
3357 { 3357 {
3358 return 0; 3358 return 0;
3359 } 3359 }
3360 3360
3361 /* 3361 /*
3362 * Removes timer callback. 3362 * Removes timer callback.
3363 * Parameters: 3363 * Parameters:
3364 * id: Timer ID returned by dw_timer_connect(). 3364 * id: Timer ID returned by dw_timer_connect().
3365 */ 3365 */
3366 void API dw_timer_disconnect(int id) 3366 void API dw_timer_disconnect(int id)
3367 { 3367 {
3368 SignalHandler *prev = NULL, *tmp = Root; 3368 SignalHandler *prev = NULL, *tmp = Root;
3369 3369
3370 /* 0 is an invalid timer ID */ 3370 /* 0 is an invalid timer ID */
3371 if(!id) 3371 if(!id)
3372 return; 3372 return;
3373 3373
3374 while(tmp) 3374 while(tmp)
3375 { 3375 {
3376 if(tmp->id == id) 3376 if(tmp->id == id)
3377 { 3377 {
3378 if(prev) 3378 if(prev)
3379 { 3379 {
3380 prev->next = tmp->next; 3380 prev->next = tmp->next;
3381 free(tmp); 3381 free(tmp);
3382 tmp = prev->next; 3382 tmp = prev->next;
3383 } 3383 }
3384 else 3384 else
3385 { 3385 {
3386 Root = tmp->next; 3386 Root = tmp->next;
3387 free(tmp); 3387 free(tmp);
3388 tmp = Root; 3388 tmp = Root;
3389 } 3389 }
3390 } 3390 }
3391 else 3391 else
3392 { 3392 {
3393 prev = tmp; 3393 prev = tmp;
3394 tmp = tmp->next; 3394 tmp = tmp->next;
3395 } 3395 }
3396 } 3396 }
3397 } 3397 }
3398 3398
3399 /* 3399 /*
3400 * Add a callback to a window event. 3400 * Add a callback to a window event.
3401 * Parameters: 3401 * Parameters:
3404 * sigfunc: The pointer to the function to be used as the callback. 3404 * sigfunc: The pointer to the function to be used as the callback.
3405 * data: User data to be passed to the handler function. 3405 * data: User data to be passed to the handler function.
3406 */ 3406 */
3407 void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) 3407 void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data)
3408 { 3408 {
3409 ULONG message = 0L; 3409 ULONG message = 0L;
3410 3410
3411 if(window && signame && sigfunc) 3411 if(window && signame && sigfunc)
3412 { 3412 {
3413 if((message = _findsigmessage(signame)) != 0) 3413 if((message = _findsigmessage(signame)) != 0)
3414 _new_signal(message, window, 0, sigfunc, data); 3414 _new_signal(message, window, 0, sigfunc, data);
3415 } 3415 }
3416 } 3416 }
3417 3417
3418 /* 3418 /*
3419 * Removes callbacks for a given window with given name. 3419 * Removes callbacks for a given window with given name.
3420 * Parameters: 3420 * Parameters:
3421 * window: Window handle of callback to be removed. 3421 * window: Window handle of callback to be removed.
3422 */ 3422 */
3423 void API dw_signal_disconnect_by_name(HWND window, char *signame) 3423 void API dw_signal_disconnect_by_name(HWND window, char *signame)
3424 { 3424 {
3425 SignalHandler *prev = NULL, *tmp = Root; 3425 SignalHandler *prev = NULL, *tmp = Root;
3426 ULONG message; 3426 ULONG message;
3427 3427
3428 if(!window || !signame || (message = _findsigmessage(signame)) == 0) 3428 if(!window || !signame || (message = _findsigmessage(signame)) == 0)
3429 return; 3429 return;
3430 3430
3431 while(tmp) 3431 while(tmp)
3432 { 3432 {
3433 if(tmp->window == window && tmp->message == message) 3433 if(tmp->window == window && tmp->message == message)
3434 { 3434 {
3435 if(prev) 3435 if(prev)
3436 { 3436 {
3437 prev->next = tmp->next; 3437 prev->next = tmp->next;
3438 free(tmp); 3438 free(tmp);
3439 tmp = prev->next; 3439 tmp = prev->next;
3440 } 3440 }
3441 else 3441 else
3442 { 3442 {
3443 Root = tmp->next; 3443 Root = tmp->next;
3444 free(tmp); 3444 free(tmp);
3445 tmp = Root; 3445 tmp = Root;
3446 } 3446 }
3447 } 3447 }
3448 else 3448 else
3449 { 3449 {
3450 prev = tmp; 3450 prev = tmp;
3451 tmp = tmp->next; 3451 tmp = tmp->next;
3452 } 3452 }
3453 } 3453 }
3454 } 3454 }
3455 3455
3456 /* 3456 /*
3457 * Removes all callbacks for a given window. 3457 * Removes all callbacks for a given window.
3458 * Parameters: 3458 * Parameters:
3459 * window: Window handle of callback to be removed. 3459 * window: Window handle of callback to be removed.
3460 */ 3460 */
3461 void API dw_signal_disconnect_by_window(HWND window) 3461 void API dw_signal_disconnect_by_window(HWND window)
3462 { 3462 {
3463 SignalHandler *prev = NULL, *tmp = Root; 3463 SignalHandler *prev = NULL, *tmp = Root;
3464 3464
3465 while(tmp) 3465 while(tmp)
3466 { 3466 {
3467 if(tmp->window == window) 3467 if(tmp->window == window)
3468 { 3468 {
3469 if(prev) 3469 if(prev)
3470 { 3470 {
3471 prev->next = tmp->next; 3471 prev->next = tmp->next;
3472 free(tmp); 3472 free(tmp);
3473 tmp = prev->next; 3473 tmp = prev->next;
3474 } 3474 }
3475 else 3475 else
3476 { 3476 {
3477 Root = tmp->next; 3477 Root = tmp->next;
3478 free(tmp); 3478 free(tmp);
3479 tmp = Root; 3479 tmp = Root;
3480 } 3480 }
3481 } 3481 }
3482 else 3482 else
3483 { 3483 {
3484 prev = tmp; 3484 prev = tmp;
3485 tmp = tmp->next; 3485 tmp = tmp->next;
3486 } 3486 }
3487 } 3487 }
3488 } 3488 }
3489 3489
3490 /* 3490 /*
3491 * Removes all callbacks for a given window with specified data. 3491 * Removes all callbacks for a given window with specified data.
3492 * Parameters: 3492 * Parameters:
3493 * window: Window handle of callback to be removed. 3493 * window: Window handle of callback to be removed.
3494 * data: Pointer to the data to be compared against. 3494 * data: Pointer to the data to be compared against.
3495 */ 3495 */
3496 void API dw_signal_disconnect_by_data(HWND window, void *data) 3496 void API dw_signal_disconnect_by_data(HWND window, void *data)
3497 { 3497 {
3498 SignalHandler *prev = NULL, *tmp = Root; 3498 SignalHandler *prev = NULL, *tmp = Root;
3499 3499
3500 while(tmp) 3500 while(tmp)
3501 { 3501 {
3502 if(tmp->window == window && tmp->data == data) 3502 if(tmp->window == window && tmp->data == data)
3503 { 3503 {
3504 if(prev) 3504 if(prev)
3505 { 3505 {
3506 prev->next = tmp->next; 3506 prev->next = tmp->next;
3507 free(tmp); 3507 free(tmp);
3508 tmp = prev->next; 3508 tmp = prev->next;
3509 } 3509 }
3510 else 3510 else
3511 { 3511 {
3512 Root = tmp->next; 3512 Root = tmp->next;
3513 free(tmp); 3513 free(tmp);
3514 tmp = Root; 3514 tmp = Root;
3515 } 3515 }
3516 } 3516 }
3517 else 3517 else
3518 { 3518 {
3519 prev = tmp; 3519 prev = tmp;
3520 tmp = tmp->next; 3520 tmp = tmp->next;
3521 } 3521 }
3522 } 3522 }
3523 } 3523 }
3524 3524
3525 3525