Mercurial > dwindows
comparison mac/dw.c @ 387:456c13a6e332
A basically empty DW source file, if we ever port to another platform
this may be a decent starting point, assuming too much doesn't get added
in the meantime. Meanwhile this will become the MacOS port.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 06 May 2003 10:31:53 +0000 |
parents | |
children | 2e6c28ee4794 |
comparison
equal
deleted
inserted
replaced
386:5326544ab2ec | 387:456c13a6e332 |
---|---|
1 /* | |
2 * Dynamic Windows: | |
3 * A GTK like implementation of the MacOS GUI | |
4 * | |
5 * (C) 2003 Brian Smith <dbsoft@technologist.com> | |
6 * | |
7 */ | |
8 #include "dw.h" | |
9 | |
10 void _do_resize(Box *thisbox, int x, int y); | |
11 | |
12 typedef struct _sighandler | |
13 { | |
14 struct _sighandler *next; | |
15 ULONG message; | |
16 HWND window; | |
17 int id; | |
18 void *signalfunction; | |
19 void *data; | |
20 | |
21 } SignalHandler; | |
22 | |
23 SignalHandler *Root = NULL; | |
24 | |
25 typedef struct | |
26 { | |
27 ULONG message; | |
28 char name[30]; | |
29 | |
30 } SignalList; | |
31 | |
32 /* List of signals and their equivilent MacOS event */ | |
33 #define SIGNALMAX 15 | |
34 | |
35 SignalList SignalTranslate[SIGNALMAX] = { | |
36 { nullEvent, DW_SIGNAL_CONFIGURE }, | |
37 { keyUp, DW_SIGNAL_KEY_PRESS }, | |
38 { mouseDown, DW_SIGNAL_BUTTON_PRESS }, | |
39 { mouseUp, DW_SIGNAL_BUTTON_RELEASE }, | |
40 { nullEvent, DW_SIGNAL_MOTION_NOTIFY }, | |
41 { nullEvent, DW_SIGNAL_DELETE }, | |
42 { updateEvt, DW_SIGNAL_EXPOSE }, | |
43 { nullEvent, DW_SIGNAL_CLICKED }, | |
44 { nullEVent, DW_SIGNAL_ITEM_ENTER }, | |
45 { nullEvent, DW_SIGNAL_ITEM_CONTEXT }, | |
46 { nullEvent, DW_SIGNAL_LIST_SELECT }, | |
47 { nullEVent, DW_SIGNAL_ITEM_SELECT }, | |
48 { activateEvt, DW_SIGNAL_SET_FOCUS }, | |
49 { nullEvent, DW_SIGNAL_VALUE_CHANGED }, | |
50 { nullEvent, DW_SIGNAL_SWITCH_PAGE } | |
51 }; | |
52 | |
53 /* This function adds a signal handler callback into the linked list. | |
54 */ | |
55 void _new_signal(ULONG message, HWND window, int id, void *signalfunction, void *data) | |
56 { | |
57 SignalHandler *new = malloc(sizeof(SignalHandler)); | |
58 | |
59 new->message = message; | |
60 new->window = window; | |
61 new->id = id; | |
62 new->signalfunction = signalfunction; | |
63 new->data = data; | |
64 new->next = NULL; | |
65 | |
66 if (!Root) | |
67 Root = new; | |
68 else | |
69 { | |
70 SignalHandler *prev = NULL, *tmp = Root; | |
71 while(tmp) | |
72 { | |
73 if(tmp->message == message && | |
74 tmp->window == window && | |
75 tmp->signalfunction == signalfunction) | |
76 { | |
77 tmp->data = data; | |
78 free(new); | |
79 return; | |
80 } | |
81 prev = tmp; | |
82 tmp = tmp->next; | |
83 } | |
84 if(prev) | |
85 prev->next = new; | |
86 else | |
87 Root = new; | |
88 } | |
89 } | |
90 | |
91 /* Finds the message number for a given signal name */ | |
92 ULONG _findsigmessage(char *signame) | |
93 { | |
94 int z; | |
95 | |
96 for(z=0;z<SIGNALMAX;z++) | |
97 { | |
98 if(stricmp(signame, SignalTranslate[z].name) == 0) | |
99 return SignalTranslate[z].message; | |
100 } | |
101 return 0L; | |
102 } | |
103 | |
104 void *_get_window_pointer(HWND handle) | |
105 { | |
106 } | |
107 | |
108 /* This function will recursively search a box and add up the total height of it */ | |
109 void _count_size(HWND box, int type, int *xsize, int *xorigsize) | |
110 { | |
111 int size = 0, origsize = 0, z; | |
112 Box *tmp = _get_window_pointer(box); | |
113 | |
114 if(!tmp) | |
115 { | |
116 *xsize = *xorigsize = 0; | |
117 return; | |
118 } | |
119 | |
120 if(type == tmp->type) | |
121 { | |
122 /* If the box is going in the direction we want, then we | |
123 * return the entire sum of the items. | |
124 */ | |
125 for(z=0;z<tmp->count;z++) | |
126 { | |
127 if(tmp->items[z].type == TYPEBOX) | |
128 { | |
129 int s, os; | |
130 | |
131 _count_size(tmp->items[z].hwnd, type, &s, &os); | |
132 size += s; | |
133 origsize += os; | |
134 } | |
135 else | |
136 { | |
137 size += (type == DW_HORZ ? tmp->items[z].width : tmp->items[z].height); | |
138 origsize += (type == DW_HORZ ? tmp->items[z].origwidth : tmp->items[z].origheight); | |
139 } | |
140 } | |
141 } | |
142 else | |
143 { | |
144 /* If the box is not going in the direction we want, then we only | |
145 * want to return the maximum value. | |
146 */ | |
147 int tmpsize = 0, tmporigsize = 0; | |
148 | |
149 for(z=0;z<tmp->count;z++) | |
150 { | |
151 if(tmp->items[z].type == TYPEBOX) | |
152 _count_size(tmp->items[z].hwnd, type, &tmpsize, &tmporigsize); | |
153 else | |
154 { | |
155 tmpsize = (type == DW_HORZ ? tmp->items[z].width : tmp->items[z].height); | |
156 tmporigsize = (type == DW_HORZ ? tmp->items[z].origwidth : tmp->items[z].origheight); | |
157 } | |
158 | |
159 if(tmpsize > size) | |
160 size = tmpsize; | |
161 } | |
162 } | |
163 | |
164 *xsize = size; | |
165 *xorigsize = origsize; | |
166 } | |
167 | |
168 /* This function calculates how much space the widgets and boxes require | |
169 * and does expansion as necessary. | |
170 */ | |
171 int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy, | |
172 int pass, int *usedpadx, int *usedpady) | |
173 { | |
174 int z, currentx = 0, currenty = 0; | |
175 int uymax = 0, uxmax = 0; | |
176 int upymax = 0, upxmax = 0; | |
177 /* Used for the SIZEEXPAND */ | |
178 int nux = *usedx, nuy = *usedy; | |
179 int nupx = *usedpadx, nupy = *usedpady; | |
180 | |
181 (*usedx) += (thisbox->pad * 2); | |
182 (*usedy) += (thisbox->pad * 2); | |
183 | |
184 for(z=0;z<thisbox->count;z++) | |
185 { | |
186 if(thisbox->items[z].type == TYPEBOX) | |
187 { | |
188 int initialx, initialy; | |
189 Box *tmp = _get_window_pointer(thisbox->items[z].hwnd); | |
190 | |
191 initialx = x - (*usedx); | |
192 initialy = y - (*usedy); | |
193 | |
194 if(tmp) | |
195 { | |
196 int newx, newy; | |
197 int nux = *usedx, nuy = *usedy; | |
198 int upx = *usedpadx + (tmp->pad*2), upy = *usedpady + (tmp->pad*2); | |
199 | |
200 /* On the second pass we know how big the box needs to be and how | |
201 * much space we have, so we can calculate a ratio for the new box. | |
202 */ | |
203 if(pass == 2) | |
204 { | |
205 int deep = *depth + 1; | |
206 | |
207 _resize_box(tmp, &deep, x, y, &nux, &nuy, 1, &upx, &upy); | |
208 | |
209 tmp->upx = upx - *usedpadx; | |
210 tmp->upy = upy - *usedpady; | |
211 | |
212 newx = x - nux; | |
213 newy = y - nuy; | |
214 | |
215 tmp->width = thisbox->items[z].width = initialx - newx; | |
216 tmp->height = thisbox->items[z].height = initialy - newy; | |
217 | |
218 tmp->parentxratio = thisbox->xratio; | |
219 tmp->parentyratio = thisbox->yratio; | |
220 | |
221 tmp->parentpad = tmp->pad; | |
222 | |
223 /* Just in case */ | |
224 tmp->xratio = thisbox->xratio; | |
225 tmp->yratio = thisbox->yratio; | |
226 | |
227 if(thisbox->type == DW_VERT) | |
228 { | |
229 if((thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) | |
230 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)))); | |
231 } | |
232 else | |
233 { | |
234 if((thisbox->items[z].width-tmp->upx)!=0) | |
235 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx)); | |
236 } | |
237 if(thisbox->type == DW_HORZ) | |
238 { | |
239 if((thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) | |
240 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)))); | |
241 } | |
242 else | |
243 { | |
244 if((thisbox->items[z].height-tmp->upy)!=0) | |
245 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy)); | |
246 } | |
247 | |
248 nux = *usedx; nuy = *usedy; | |
249 upx = *usedpadx + (tmp->pad*2); upy = *usedpady + (tmp->pad*2); | |
250 } | |
251 | |
252 (*depth)++; | |
253 | |
254 _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &upx, &upy); | |
255 | |
256 (*depth)--; | |
257 | |
258 newx = x - nux; | |
259 newy = y - nuy; | |
260 | |
261 tmp->minwidth = thisbox->items[z].width = initialx - newx; | |
262 tmp->minheight = thisbox->items[z].height = initialy - newy; | |
263 } | |
264 } | |
265 | |
266 if(pass > 1 && *depth > 0) | |
267 { | |
268 if(thisbox->type == DW_VERT) | |
269 { | |
270 if((thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0) | |
271 thisbox->items[z].xratio = 1.0; | |
272 else | |
273 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)))); | |
274 } | |
275 else | |
276 { | |
277 if(thisbox->minwidth-thisbox->upx == 0) | |
278 thisbox->items[z].xratio = 1.0; | |
279 else | |
280 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx)); | |
281 } | |
282 | |
283 if(thisbox->type == DW_HORZ) | |
284 { | |
285 if((thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0) | |
286 thisbox->items[z].yratio = 1.0; | |
287 else | |
288 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)))); | |
289 } | |
290 else | |
291 { | |
292 if(thisbox->minheight-thisbox->upy == 0) | |
293 thisbox->items[z].yratio = 1.0; | |
294 else | |
295 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy)); | |
296 } | |
297 | |
298 if(thisbox->items[z].type == TYPEBOX) | |
299 { | |
300 Box *tmp = _get_window_pointer(thisbox->items[z].hwnd); | |
301 | |
302 if(tmp) | |
303 { | |
304 tmp->parentxratio = thisbox->items[z].xratio; | |
305 tmp->parentyratio = thisbox->items[z].yratio; | |
306 } | |
307 } | |
308 } | |
309 else | |
310 { | |
311 thisbox->items[z].xratio = thisbox->xratio; | |
312 thisbox->items[z].yratio = thisbox->yratio; | |
313 } | |
314 | |
315 if(thisbox->type == DW_VERT) | |
316 { | |
317 if((thisbox->items[z].width + (thisbox->items[z].pad*2)) > uxmax) | |
318 uxmax = (thisbox->items[z].width + (thisbox->items[z].pad*2)); | |
319 if(thisbox->items[z].hsize != SIZEEXPAND) | |
320 { | |
321 if(((thisbox->items[z].pad*2) + thisbox->items[z].width) > upxmax) | |
322 upxmax = (thisbox->items[z].pad*2) + thisbox->items[z].width; | |
323 } | |
324 else | |
325 { | |
326 if(thisbox->items[z].pad*2 > upxmax) | |
327 upxmax = thisbox->items[z].pad*2; | |
328 } | |
329 } | |
330 else | |
331 { | |
332 if(thisbox->items[z].width == -1) | |
333 { | |
334 /* figure out how much space this item requires */ | |
335 /* thisbox->items[z].width = */ | |
336 } | |
337 else | |
338 { | |
339 (*usedx) += thisbox->items[z].width + (thisbox->items[z].pad*2); | |
340 if(thisbox->items[z].hsize != SIZEEXPAND) | |
341 (*usedpadx) += (thisbox->items[z].pad*2) + thisbox->items[z].width; | |
342 else | |
343 (*usedpadx) += thisbox->items[z].pad*2; | |
344 } | |
345 } | |
346 if(thisbox->type == DW_HORZ) | |
347 { | |
348 if((thisbox->items[z].height + (thisbox->items[z].pad*2)) > uymax) | |
349 uymax = (thisbox->items[z].height + (thisbox->items[z].pad*2)); | |
350 if(thisbox->items[z].vsize != SIZEEXPAND) | |
351 { | |
352 if(((thisbox->items[z].pad*2) + thisbox->items[z].height) > upymax) | |
353 upymax = (thisbox->items[z].pad*2) + thisbox->items[z].height; | |
354 } | |
355 else | |
356 { | |
357 if(thisbox->items[z].pad*2 > upymax) | |
358 upymax = thisbox->items[z].pad*2; | |
359 } | |
360 } | |
361 else | |
362 { | |
363 if(thisbox->items[z].height == -1) | |
364 { | |
365 /* figure out how much space this item requires */ | |
366 /* thisbox->items[z].height = */ | |
367 } | |
368 else | |
369 { | |
370 (*usedy) += thisbox->items[z].height + (thisbox->items[z].pad*2); | |
371 if(thisbox->items[z].vsize != SIZEEXPAND) | |
372 (*usedpady) += (thisbox->items[z].pad*2) + thisbox->items[z].height; | |
373 else | |
374 (*usedpady) += thisbox->items[z].pad*2; | |
375 } | |
376 } | |
377 } | |
378 | |
379 (*usedx) += uxmax; | |
380 (*usedy) += uymax; | |
381 (*usedpadx) += upxmax; | |
382 (*usedpady) += upymax; | |
383 | |
384 currentx += thisbox->pad; | |
385 currenty += thisbox->pad; | |
386 | |
387 /* The second pass is for expansion and actual placement. */ | |
388 if(pass > 1) | |
389 { | |
390 /* Any SIZEEXPAND items should be set to uxmax/uymax */ | |
391 for(z=0;z<thisbox->count;z++) | |
392 { | |
393 if(thisbox->items[z].hsize == SIZEEXPAND && thisbox->type == DW_VERT) | |
394 thisbox->items[z].width = uxmax-(thisbox->items[z].pad*2); | |
395 if(thisbox->items[z].vsize == SIZEEXPAND && thisbox->type == DW_HORZ) | |
396 thisbox->items[z].height = uymax-(thisbox->items[z].pad*2); | |
397 /* Run this code segment again to finalize the sized after setting uxmax/uymax values. */ | |
398 if(thisbox->items[z].type == TYPEBOX) | |
399 { | |
400 Box *tmp = _get_window_pointer(thisbox->items[z].hwnd); | |
401 | |
402 if(tmp) | |
403 { | |
404 if(*depth > 0) | |
405 { | |
406 if(thisbox->type == DW_VERT) | |
407 { | |
408 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/((float)(tmp->minwidth-((thisbox->items[z].pad*2)+(thisbox->pad*2)))); | |
409 tmp->width = thisbox->items[z].width; | |
410 } | |
411 if(thisbox->type == DW_HORZ) | |
412 { | |
413 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/((float)(tmp->minheight-((thisbox->items[z].pad*2)+(thisbox->pad*2)))); | |
414 tmp->height = thisbox->items[z].height; | |
415 } | |
416 } | |
417 | |
418 (*depth)++; | |
419 | |
420 _resize_box(tmp, depth, x, y, &nux, &nuy, 3, &nupx, &nupy); | |
421 | |
422 (*depth)--; | |
423 | |
424 } | |
425 } | |
426 } | |
427 | |
428 for(z=0;z<(thisbox->count);z++) | |
429 { | |
430 int height = thisbox->items[z].height; | |
431 int width = thisbox->items[z].width; | |
432 int pad = thisbox->items[z].pad; | |
433 HWND handle = thisbox->items[z].hwnd; | |
434 int vectorx, vectory; | |
435 | |
436 /* When upxmax != pad*2 then ratios are incorrect. */ | |
437 vectorx = (int)((width*thisbox->items[z].xratio)-width); | |
438 vectory = (int)((height*thisbox->items[z].yratio)-height); | |
439 | |
440 if(width > 0 && height > 0) | |
441 { | |
442 /* This is a hack to fix rounding of the sizing */ | |
443 if(*depth == 0) | |
444 { | |
445 vectorx++; | |
446 vectory++; | |
447 } | |
448 | |
449 /* If this item isn't going to expand... reset the vectors to 0 */ | |
450 if(thisbox->items[z].vsize != SIZEEXPAND) | |
451 vectory = 0; | |
452 if(thisbox->items[z].hsize != SIZEEXPAND) | |
453 vectorx = 0; | |
454 | |
455 #if 0 | |
456 WinSetWindowPos(handle, HWND_TOP, currentx + pad, currenty + pad, | |
457 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER); | |
458 #endif | |
459 | |
460 if(thisbox->type == DW_HORZ) | |
461 currentx += width + vectorx + (pad * 2); | |
462 if(thisbox->type == DW_VERT) | |
463 currenty += height + vectory + (pad * 2); | |
464 } | |
465 } | |
466 } | |
467 return 0; | |
468 } | |
469 | |
470 void _do_resize(Box *thisbox, int x, int y) | |
471 { | |
472 if(x != 0 && y != 0) | |
473 { | |
474 if(thisbox) | |
475 { | |
476 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0; | |
477 | |
478 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady); | |
479 | |
480 if(usedx-usedpadx == 0 || usedy-usedpady == 0) | |
481 return; | |
482 | |
483 thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx)); | |
484 thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady)); | |
485 | |
486 usedx = usedy = usedpadx = usedpady = depth = 0; | |
487 | |
488 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady); | |
489 } | |
490 } | |
491 } | |
492 | |
493 int _dw_int_pos(HWND hwnd) | |
494 { | |
495 int pos = (int)dw_window_get_data(hwnd, "_dw_percent_value"); | |
496 int range = dw_percent_query_range(hwnd); | |
497 float fpos = (float)pos; | |
498 float frange = (float)range; | |
499 float fnew = (fpos/1000.0)*frange; | |
500 return (int)fnew; | |
501 } | |
502 | |
503 void _dw_int_set(HWND hwnd, int pos) | |
504 { | |
505 int inew, range = dw_percent_query_range(hwnd); | |
506 if(range) | |
507 { | |
508 float fpos = (float)pos; | |
509 float frange = (float)range; | |
510 float fnew = (fpos/frange)*1000.0; | |
511 inew = (int)fnew; | |
512 dw_window_set_data(hwnd, "_dw_percent_value", (void *)inew); | |
513 } | |
514 } | |
515 | |
516 void _changebox(Box *thisbox, int percent, int type) | |
517 { | |
518 int z; | |
519 | |
520 for(z=0;z<thisbox->count;z++) | |
521 { | |
522 if(thisbox->items[z].type == TYPEBOX) | |
523 { | |
524 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); | |
525 _changebox(tmp, percent, type); | |
526 } | |
527 else | |
528 { | |
529 if(type == DW_HORZ) | |
530 { | |
531 if(thisbox->items[z].hsize == SIZEEXPAND) | |
532 thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0))); | |
533 } | |
534 else | |
535 { | |
536 if(thisbox->items[z].vsize == SIZEEXPAND) | |
537 thisbox->items[z].height = (int)(((float)thisbox->items[z].origheight) * (((float)percent)/((float)100.0))); | |
538 } | |
539 } | |
540 } | |
541 } | |
542 | |
543 /* | |
544 * Initializes the Dynamic Windows engine. | |
545 * Parameters: | |
546 * newthread: True if this is the only thread. | |
547 * False if there is already a message loop running. | |
548 */ | |
549 int API dw_init(int newthread, int argc, char *argv[]) | |
550 { | |
551 return 0; | |
552 } | |
553 | |
554 /* | |
555 * Runs a message loop for Dynamic Windows. | |
556 */ | |
557 void API dw_main(void) | |
558 { | |
559 } | |
560 | |
561 /* | |
562 * Runs a message loop for Dynamic Windows, for a period of milliseconds. | |
563 * Parameters: | |
564 * milliseconds: Number of milliseconds to run the loop for. | |
565 */ | |
566 void API dw_main_sleep(int milliseconds) | |
567 { | |
568 } | |
569 | |
570 /* | |
571 * Processes a single message iteration and returns. | |
572 */ | |
573 void API dw_main_iteration(void) | |
574 { | |
575 } | |
576 | |
577 /* | |
578 * Free's memory allocated by dynamic windows. | |
579 * Parameters: | |
580 * ptr: Pointer to dynamic windows allocated | |
581 * memory to be free()'d. | |
582 */ | |
583 void API dw_free(void *ptr) | |
584 { | |
585 free(ptr); | |
586 } | |
587 | |
588 /* | |
589 * Allocates and initializes a dialog struct. | |
590 * Parameters: | |
591 * data: User defined data to be passed to functions. | |
592 */ | |
593 DWDialog * API dw_dialog_new(void *data) | |
594 { | |
595 DWDialog *tmp = malloc(sizeof(DWDialog)); | |
596 | |
597 tmp->eve = dw_event_new(); | |
598 dw_event_reset(tmp->eve); | |
599 tmp->data = data; | |
600 tmp->done = FALSE; | |
601 tmp->result = NULL; | |
602 | |
603 return tmp; | |
604 } | |
605 | |
606 /* | |
607 * Accepts a dialog struct and returns the given data to the | |
608 * initial called of dw_dialog_wait(). | |
609 * Parameters: | |
610 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | |
611 * result: Data to be returned by dw_dialog_wait(). | |
612 */ | |
613 int API dw_dialog_dismiss(DWDialog *dialog, void *result) | |
614 { | |
615 dialog->result = result; | |
616 dw_event_post(dialog->eve); | |
617 dialog->done = TRUE; | |
618 return 0; | |
619 } | |
620 | |
621 /* | |
622 * Accepts a dialog struct waits for dw_dialog_dismiss() to be | |
623 * called by a signal handler with the given dialog struct. | |
624 * Parameters: | |
625 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | |
626 */ | |
627 void * API dw_dialog_wait(DWDialog *dialog) | |
628 { | |
629 void *tmp; | |
630 | |
631 #if 0 | |
632 while (WinGetMsg(dwhab, &qmsg, 0, 0, 0)) | |
633 { | |
634 WinDispatchMsg(dwhab, &qmsg); | |
635 if(dialog->done) | |
636 break; | |
637 } | |
638 #endif | |
639 dw_event_close(&dialog->eve); | |
640 tmp = dialog->result; | |
641 free(dialog); | |
642 return tmp; | |
643 } | |
644 | |
645 | |
646 /* | |
647 * Displays a Message Box with given text and title.. | |
648 * Parameters: | |
649 * title: The title of the message box. | |
650 * format: printf style format string. | |
651 * ...: Additional variables for use in the format. | |
652 */ | |
653 int API dw_messagebox(char *title, char *format, ...) | |
654 { | |
655 va_list args; | |
656 char outbuf[1024]; | |
657 | |
658 va_start(args, format); | |
659 vsprintf(outbuf, format, args); | |
660 va_end(args); | |
661 | |
662 #if 0 | |
663 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, outbuf, title, 0, MB_OK | MB_INFORMATION | MB_MOVEABLE); | |
664 #endif | |
665 | |
666 return strlen(outbuf); | |
667 } | |
668 | |
669 /* | |
670 * Displays a Message Box with given text and title.. | |
671 * Parameters: | |
672 * title: The title of the message box. | |
673 * text: The text to display in the box. | |
674 * Returns: | |
675 * True if YES False of NO. | |
676 */ | |
677 int API dw_yesno(char *title, char *text) | |
678 { | |
679 return FALSE; | |
680 } | |
681 | |
682 /* | |
683 * Makes the window topmost. | |
684 * Parameters: | |
685 * handle: The window handle to make topmost. | |
686 */ | |
687 int API dw_window_raise(HWND handle) | |
688 { | |
689 return 0; | |
690 } | |
691 | |
692 /* | |
693 * Makes the window bottommost. | |
694 * Parameters: | |
695 * handle: The window handle to make bottommost. | |
696 */ | |
697 int API dw_window_lower(HWND handle) | |
698 { | |
699 return 0; | |
700 } | |
701 | |
702 /* | |
703 * Makes the window visible. | |
704 * Parameters: | |
705 * handle: The window handle to make visible. | |
706 */ | |
707 int API dw_window_show(HWND handle) | |
708 { | |
709 return 0; | |
710 } | |
711 | |
712 /* | |
713 * Minimizes or Iconifies a top-level window. | |
714 * Parameters: | |
715 * handle: The window handle to minimize. | |
716 */ | |
717 int API dw_window_minimize(HWND handle) | |
718 { | |
719 return 0; | |
720 } | |
721 | |
722 /* | |
723 * Makes the window invisible. | |
724 * Parameters: | |
725 * handle: The window handle to make visible. | |
726 */ | |
727 int API dw_window_hide(HWND handle) | |
728 { | |
729 return 0; | |
730 } | |
731 | |
732 /* | |
733 * Destroys a window and all of it's children. | |
734 * Parameters: | |
735 * handle: The window handle to destroy. | |
736 */ | |
737 int API dw_window_destroy(HWND handle) | |
738 { | |
739 return 0; | |
740 } | |
741 | |
742 /* Causes entire window to be invalidated and redrawn. | |
743 * Parameters: | |
744 * handle: Toplevel window handle to be redrawn. | |
745 */ | |
746 void API dw_window_redraw(HWND handle) | |
747 { | |
748 } | |
749 | |
750 /* | |
751 * Changes a window's parent to newparent. | |
752 * Parameters: | |
753 * handle: The window handle to destroy. | |
754 * newparent: The window's new parent window. | |
755 */ | |
756 void API dw_window_reparent(HWND handle, HWND newparent) | |
757 { | |
758 } | |
759 | |
760 /* | |
761 * Sets the font used by a specified window (widget) handle. | |
762 * Parameters: | |
763 * handle: The window (widget) handle. | |
764 * fontname: Name and size of the font in the form "size.fontname" | |
765 */ | |
766 int API dw_window_set_font(HWND handle, char *fontname) | |
767 { | |
768 return 0; | |
769 } | |
770 | |
771 /* | |
772 * Sets the colors used by a specified window (widget) handle. | |
773 * Parameters: | |
774 * handle: The window (widget) handle. | |
775 * fore: Foreground color in DW_RGB format or a default color index. | |
776 * back: Background color in DW_RGB format or a default color index. | |
777 */ | |
778 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back) | |
779 { | |
780 return 0; | |
781 } | |
782 | |
783 /* | |
784 * Sets the font used by a specified window (widget) handle. | |
785 * Parameters: | |
786 * handle: The window (widget) handle. | |
787 * border: Size of the window border in pixels. | |
788 */ | |
789 int API dw_window_set_border(HWND handle, int border) | |
790 { | |
791 return 0; | |
792 } | |
793 | |
794 /* | |
795 * Captures the mouse input to this window. | |
796 * Parameters: | |
797 * handle: Handle to receive mouse input. | |
798 */ | |
799 void API dw_window_capture(HWND handle) | |
800 { | |
801 } | |
802 | |
803 /* | |
804 * Releases previous mouse capture. | |
805 */ | |
806 void API dw_window_release(void) | |
807 { | |
808 } | |
809 | |
810 /* | |
811 * Tracks this window movement. | |
812 * Parameters: | |
813 * handle: Handle to frame to be tracked. | |
814 */ | |
815 void API dw_window_track(HWND handle) | |
816 { | |
817 } | |
818 | |
819 /* | |
820 * Changes the appearance of the mouse pointer. | |
821 * Parameters: | |
822 * handle: Handle to widget for which to change. | |
823 * cursortype: ID of the pointer you want. | |
824 */ | |
825 void API dw_window_pointer(HWND handle, int pointertype) | |
826 { | |
827 } | |
828 | |
829 /* | |
830 * Create a new Window Frame. | |
831 * Parameters: | |
832 * owner: The Owner's window handle or HWND_DESKTOP. | |
833 * title: The Window title. | |
834 * flStyle: Style flags, see the PM reference. | |
835 */ | |
836 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) | |
837 { | |
838 HWND hwnd = 0; | |
839 | |
840 return hwnd; | |
841 } | |
842 | |
843 /* | |
844 * Create a new Box to be packed. | |
845 * Parameters: | |
846 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). | |
847 * pad: Number of pixels to pad around the box. | |
848 */ | |
849 HWND API dw_box_new(int type, int pad) | |
850 { | |
851 return 0; | |
852 } | |
853 | |
854 /* | |
855 * Create a new Group Box to be packed. | |
856 * Parameters: | |
857 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). | |
858 * pad: Number of pixels to pad around the box. | |
859 * title: Text to be displayined in the group outline. | |
860 */ | |
861 HWND API dw_groupbox_new(int type, int pad, char *title) | |
862 { | |
863 return 0; | |
864 } | |
865 | |
866 /* | |
867 * Create a new MDI Frame to be packed. | |
868 * Parameters: | |
869 * id: An ID to be used with dw_window_from_id or 0L. | |
870 */ | |
871 HWND API dw_mdi_new(unsigned long id) | |
872 { | |
873 return 0; | |
874 } | |
875 | |
876 /* | |
877 * Create a bitmap object to be packed. | |
878 * Parameters: | |
879 * id: An ID to be used with dw_window_from_id() or 0L. | |
880 */ | |
881 HWND API dw_bitmap_new(ULONG id) | |
882 { | |
883 return 0; | |
884 } | |
885 | |
886 /* | |
887 * Create a notebook object to be packed. | |
888 * Parameters: | |
889 * id: An ID to be used for getting the resource from the | |
890 * resource file. | |
891 */ | |
892 HWND API dw_notebook_new(ULONG id, int top) | |
893 { | |
894 return 0; | |
895 } | |
896 | |
897 /* | |
898 * Create a menu object to be popped up. | |
899 * Parameters: | |
900 * id: An ID to be used for getting the resource from the | |
901 * resource file. | |
902 */ | |
903 HMENUI API dw_menu_new(ULONG id) | |
904 { | |
905 return 0; | |
906 } | |
907 | |
908 /* | |
909 * Create a menubar on a window. | |
910 * Parameters: | |
911 * location: Handle of a window frame to be attached to. | |
912 */ | |
913 HMENUI API dw_menubar_new(HWND location) | |
914 { | |
915 return 0; | |
916 } | |
917 | |
918 /* | |
919 * Destroys a menu created with dw_menubar_new or dw_menu_new. | |
920 * Parameters: | |
921 * menu: Handle of a menu. | |
922 */ | |
923 void API dw_menu_destroy(HMENUI *menu) | |
924 { | |
925 } | |
926 | |
927 /* | |
928 * Adds a menuitem or submenu to an existing menu. | |
929 * Parameters: | |
930 * menu: The handle the the existing menu. | |
931 * title: The title text on the menu item to be added. | |
932 * id: An ID to be used for message passing. | |
933 * flags: Extended attributes to set on the menu. | |
934 * end: If TRUE memu is positioned at the end of the menu. | |
935 * check: If TRUE menu is "check"able. | |
936 * submenu: Handle to an existing menu to be a submenu or NULL. | |
937 */ | |
938 HWND API dw_menu_append_item(HMENUI menux, char *title, ULONG id, ULONG flags, int end, int check, HMENUI submenu) | |
939 { | |
940 return 0; | |
941 } | |
942 | |
943 /* | |
944 * Sets the state of a menu item check. | |
945 * Parameters: | |
946 * menu: The handle the the existing menu. | |
947 * id: Menuitem id. | |
948 * check: TRUE for checked FALSE for not checked. | |
949 */ | |
950 void API dw_menu_item_set_check(HMENUI menux, unsigned long id, int check) | |
951 { | |
952 } | |
953 | |
954 /* | |
955 * Pops up a context menu at given x and y coordinates. | |
956 * Parameters: | |
957 * menu: The handle the the existing menu. | |
958 * parent: Handle to the window initiating the popup. | |
959 * x: X coordinate. | |
960 * y: Y coordinate. | |
961 */ | |
962 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) | |
963 { | |
964 } | |
965 | |
966 /* | |
967 * Returns the current X and Y coordinates of the mouse pointer. | |
968 * Parameters: | |
969 * x: Pointer to variable to store X coordinate. | |
970 * y: Pointer to variable to store Y coordinate. | |
971 */ | |
972 void API dw_pointer_query_pos(long *x, long *y) | |
973 { | |
974 } | |
975 | |
976 /* | |
977 * Sets the X and Y coordinates of the mouse pointer. | |
978 * Parameters: | |
979 * x: X coordinate. | |
980 * y: Y coordinate. | |
981 */ | |
982 void API dw_pointer_set_pos(long x, long y) | |
983 { | |
984 } | |
985 | |
986 | |
987 /* | |
988 * Create a container object to be packed. | |
989 * Parameters: | |
990 * id: An ID to be used for getting the resource from the | |
991 * resource file. | |
992 */ | |
993 HWND API dw_container_new(ULONG id, int multi) | |
994 { | |
995 return 0; | |
996 } | |
997 | |
998 /* | |
999 * Create a tree object to be packed. | |
1000 * Parameters: | |
1001 * id: An ID to be used for getting the resource from the | |
1002 * resource file. | |
1003 */ | |
1004 HWND API dw_tree_new(ULONG id) | |
1005 { | |
1006 return 0; | |
1007 } | |
1008 | |
1009 /* | |
1010 * Create a new static text window (widget) to be packed. | |
1011 * Parameters: | |
1012 * text: The text to be display by the static text widget. | |
1013 * id: An ID to be used with dw_window_from_id() or 0L. | |
1014 */ | |
1015 HWND API dw_text_new(char *text, ULONG id) | |
1016 { | |
1017 return 0; | |
1018 } | |
1019 | |
1020 /* | |
1021 * Create a new status text window (widget) to be packed. | |
1022 * Parameters: | |
1023 * text: The text to be display by the static text widget. | |
1024 * id: An ID to be used with dw_window_from_id() or 0L. | |
1025 */ | |
1026 HWND API dw_status_text_new(char *text, ULONG id) | |
1027 { | |
1028 return 0; | |
1029 } | |
1030 | |
1031 /* | |
1032 * Create a new Multiline Editbox window (widget) to be packed. | |
1033 * Parameters: | |
1034 * id: An ID to be used with dw_window_from_id() or 0L. | |
1035 */ | |
1036 HWND API dw_mle_new(ULONG id) | |
1037 { | |
1038 return 0; | |
1039 } | |
1040 | |
1041 /* | |
1042 * Create a new Entryfield window (widget) to be packed. | |
1043 * Parameters: | |
1044 * text: The default text to be in the entryfield widget. | |
1045 * id: An ID to be used with dw_window_from_id() or 0L. | |
1046 */ | |
1047 HWND API dw_entryfield_new(char *text, ULONG id) | |
1048 { | |
1049 | |
1050 return 0; | |
1051 } | |
1052 | |
1053 /* | |
1054 * Create a new Entryfield (password) window (widget) to be packed. | |
1055 * Parameters: | |
1056 * text: The default text to be in the entryfield widget. | |
1057 * id: An ID to be used with dw_window_from_id() or 0L. | |
1058 */ | |
1059 HWND API dw_entryfield_password_new(char *text, ULONG id) | |
1060 { | |
1061 return 0; | |
1062 } | |
1063 | |
1064 /* | |
1065 * Create a new Combobox window (widget) to be packed. | |
1066 * Parameters: | |
1067 * text: The default text to be in the combpbox widget. | |
1068 * id: An ID to be used with dw_window_from_id() or 0L. | |
1069 */ | |
1070 HWND API dw_combobox_new(char *text, ULONG id) | |
1071 { | |
1072 return 0; | |
1073 } | |
1074 | |
1075 /* | |
1076 * Create a new button window (widget) to be packed. | |
1077 * Parameters: | |
1078 * text: The text to be display by the static text widget. | |
1079 * id: An ID to be used with dw_window_from_id() or 0L. | |
1080 */ | |
1081 HWND API dw_button_new(char *text, ULONG id) | |
1082 { | |
1083 return 0; | |
1084 } | |
1085 | |
1086 /* | |
1087 * Create a new bitmap button window (widget) to be packed. | |
1088 * Parameters: | |
1089 * text: Bubble help text to be displayed. | |
1090 * id: An ID of a bitmap in the resource file. | |
1091 */ | |
1092 HWND API dw_bitmapbutton_new(char *text, ULONG id) | |
1093 { | |
1094 return 0; | |
1095 } | |
1096 | |
1097 /* | |
1098 * Create a new bitmap button window (widget) to be packed from a file. | |
1099 * Parameters: | |
1100 * text: Bubble help text to be displayed. | |
1101 * id: An ID to be used with dw_window_from_id() or 0L. | |
1102 * filename: Name of the file, omit extention to have | |
1103 * DW pick the appropriate file extension. | |
1104 * (BMP on OS/2 or Windows, XPM on Unix) | |
1105 */ | |
1106 HWND dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename) | |
1107 { | |
1108 return 0; | |
1109 } | |
1110 | |
1111 /* | |
1112 * Create a new spinbutton window (widget) to be packed. | |
1113 * Parameters: | |
1114 * text: The text to be display by the static text widget. | |
1115 * id: An ID to be used with dw_window_from_id() or 0L. | |
1116 */ | |
1117 HWND API dw_spinbutton_new(char *text, ULONG id) | |
1118 { | |
1119 return 0; | |
1120 } | |
1121 | |
1122 /* | |
1123 * Create a new radiobutton window (widget) to be packed. | |
1124 * Parameters: | |
1125 * text: The text to be display by the static text widget. | |
1126 * id: An ID to be used with dw_window_from_id() or 0L. | |
1127 */ | |
1128 HWND API dw_radiobutton_new(char *text, ULONG id) | |
1129 { | |
1130 return 0; | |
1131 } | |
1132 | |
1133 | |
1134 /* | |
1135 * Create a new slider window (widget) to be packed. | |
1136 * Parameters: | |
1137 * vertical: TRUE or FALSE if slider is vertical. | |
1138 * increments: Number of increments available. | |
1139 * id: An ID to be used with dw_window_from_id() or 0L. | |
1140 */ | |
1141 HWND API dw_slider_new(int vertical, int increments, ULONG id) | |
1142 { | |
1143 return 0; | |
1144 } | |
1145 | |
1146 /* | |
1147 * Create a new scrollbar window (widget) to be packed. | |
1148 * Parameters: | |
1149 * vertical: TRUE or FALSE if scrollbar is vertical. | |
1150 * increments: Number of increments available. | |
1151 * id: An ID to be used with dw_window_from_id() or 0L. | |
1152 */ | |
1153 HWND API dw_scrollbar_new(int vertical, int increments, ULONG id) | |
1154 { | |
1155 return 0; | |
1156 } | |
1157 | |
1158 /* | |
1159 * Create a new percent bar window (widget) to be packed. | |
1160 * Parameters: | |
1161 * id: An ID to be used with dw_window_from_id() or 0L. | |
1162 */ | |
1163 HWND API dw_percent_new(ULONG id) | |
1164 { | |
1165 return 0; | |
1166 } | |
1167 | |
1168 /* | |
1169 * Create a new checkbox window (widget) to be packed. | |
1170 * Parameters: | |
1171 * text: The text to be display by the static text widget. | |
1172 * id: An ID to be used with dw_window_from_id() or 0L. | |
1173 */ | |
1174 HWND API dw_checkbox_new(char *text, ULONG id) | |
1175 { | |
1176 return 0; | |
1177 } | |
1178 | |
1179 /* | |
1180 * Create a new listbox window (widget) to be packed. | |
1181 * Parameters: | |
1182 * id: An ID to be used with dw_window_from_id() or 0L. | |
1183 * multi: Multiple select TRUE or FALSE. | |
1184 */ | |
1185 HWND API dw_listbox_new(ULONG id, int multi) | |
1186 { | |
1187 return 0; | |
1188 } | |
1189 | |
1190 /* | |
1191 * Sets the icon used for a given window. | |
1192 * Parameters: | |
1193 * handle: Handle to the window. | |
1194 * id: An ID to be used to specify the icon. | |
1195 */ | |
1196 void API dw_window_set_icon(HWND handle, ULONG id) | |
1197 { | |
1198 } | |
1199 | |
1200 /* | |
1201 * Sets the bitmap used for a given static window. | |
1202 * Parameters: | |
1203 * handle: Handle to the window. | |
1204 * id: An ID to be used to specify the icon, | |
1205 * (pass 0 if you use the filename param) | |
1206 * filename: a path to a file (Bitmap on OS/2 or | |
1207 * Windows and a pixmap on Unix, pass | |
1208 * NULL if you use the id param) | |
1209 */ | |
1210 void API dw_window_set_bitmap(HWND handle, unsigned long id, char *filename) | |
1211 { | |
1212 } | |
1213 | |
1214 /* | |
1215 * Sets the text used for a given window. | |
1216 * Parameters: | |
1217 * handle: Handle to the window. | |
1218 * text: The text associsated with a given window. | |
1219 */ | |
1220 void API dw_window_set_text(HWND handle, char *text) | |
1221 { | |
1222 } | |
1223 | |
1224 /* | |
1225 * Gets the text used for a given window. | |
1226 * Parameters: | |
1227 * handle: Handle to the window. | |
1228 * Returns: | |
1229 * text: The text associsated with a given window. | |
1230 */ | |
1231 char * API dw_window_get_text(HWND handle) | |
1232 { | |
1233 return NULL; | |
1234 } | |
1235 | |
1236 /* | |
1237 * Disables given window (widget). | |
1238 * Parameters: | |
1239 * handle: Handle to the window. | |
1240 */ | |
1241 void API dw_window_disable(HWND handle) | |
1242 { | |
1243 } | |
1244 | |
1245 /* | |
1246 * Enables given window (widget). | |
1247 * Parameters: | |
1248 * handle: Handle to the window. | |
1249 */ | |
1250 void API dw_window_enable(HWND handle) | |
1251 { | |
1252 } | |
1253 | |
1254 /* | |
1255 * Gets the child window handle with specified ID. | |
1256 * Parameters: | |
1257 * handle: Handle to the parent window. | |
1258 * id: Integer ID of the child. | |
1259 */ | |
1260 HWND API dw_window_from_id(HWND handle, int id) | |
1261 { | |
1262 return 0; | |
1263 } | |
1264 | |
1265 /* | |
1266 * Pack windows (widgets) into a box from the end (or bottom). | |
1267 * Parameters: | |
1268 * box: Window handle of the box to be packed into. | |
1269 * item: Window handle of the item to be back. | |
1270 * width: Width in pixels of the item or -1 to be self determined. | |
1271 * height: Height in pixels of the item or -1 to be self determined. | |
1272 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
1273 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
1274 * pad: Number of pixels of padding around the item. | |
1275 */ | |
1276 void API dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
1277 { | |
1278 } | |
1279 | |
1280 /* | |
1281 * Sets the size of a given window (widget). | |
1282 * Parameters: | |
1283 * handle: Window (widget) handle. | |
1284 * width: New width in pixels. | |
1285 * height: New height in pixels. | |
1286 */ | |
1287 void API dw_window_set_usize(HWND handle, ULONG width, ULONG height) | |
1288 { | |
1289 } | |
1290 | |
1291 /* | |
1292 * Returns the width of the screen. | |
1293 */ | |
1294 int API dw_screen_width(void) | |
1295 { | |
1296 return 0; | |
1297 } | |
1298 | |
1299 /* | |
1300 * Returns the height of the screen. | |
1301 */ | |
1302 int API dw_screen_height(void) | |
1303 { | |
1304 return 0; | |
1305 } | |
1306 | |
1307 /* This should return the current color depth */ | |
1308 unsigned long API dw_color_depth(void) | |
1309 { | |
1310 return 0; | |
1311 } | |
1312 | |
1313 | |
1314 /* | |
1315 * Sets the position of a given window (widget). | |
1316 * Parameters: | |
1317 * handle: Window (widget) handle. | |
1318 * x: X location from the bottom left. | |
1319 * y: Y location from the bottom left. | |
1320 */ | |
1321 void API dw_window_set_pos(HWND handle, ULONG x, ULONG y) | |
1322 { | |
1323 } | |
1324 | |
1325 /* | |
1326 * Sets the position and size of a given window (widget). | |
1327 * Parameters: | |
1328 * handle: Window (widget) handle. | |
1329 * x: X location from the bottom left. | |
1330 * y: Y location from the bottom left. | |
1331 * width: Width of the widget. | |
1332 * height: Height of the widget. | |
1333 */ | |
1334 void API dw_window_set_pos_size(HWND handle, ULONG x, ULONG y, ULONG width, ULONG height) | |
1335 { | |
1336 } | |
1337 | |
1338 /* | |
1339 * Gets the position and size of a given window (widget). | |
1340 * Parameters: | |
1341 * handle: Window (widget) handle. | |
1342 * x: X location from the bottom left. | |
1343 * y: Y location from the bottom left. | |
1344 * width: Width of the widget. | |
1345 * height: Height of the widget. | |
1346 */ | |
1347 void API dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height) | |
1348 { | |
1349 } | |
1350 | |
1351 /* | |
1352 * Sets the style of a given window (widget). | |
1353 * Parameters: | |
1354 * handle: Window (widget) handle. | |
1355 * width: New width in pixels. | |
1356 * height: New height in pixels. | |
1357 */ | |
1358 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask) | |
1359 { | |
1360 } | |
1361 | |
1362 /* | |
1363 * Adds a new page to specified notebook. | |
1364 * Parameters: | |
1365 * handle: Window (widget) handle. | |
1366 * flags: Any additional page creation flags. | |
1367 * front: If TRUE page is added at the beginning. | |
1368 */ | |
1369 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front) | |
1370 { | |
1371 return 0; | |
1372 } | |
1373 | |
1374 /* | |
1375 * Remove a page from a notebook. | |
1376 * Parameters: | |
1377 * handle: Handle to the notebook widget. | |
1378 * pageid: ID of the page to be destroyed. | |
1379 */ | |
1380 void API dw_notebook_page_destroy(HWND handle, unsigned int pageid) | |
1381 { | |
1382 } | |
1383 | |
1384 /* | |
1385 * Queries the currently visible page ID. | |
1386 * Parameters: | |
1387 * handle: Handle to the notebook widget. | |
1388 */ | |
1389 unsigned long API dw_notebook_page_query(HWND handle) | |
1390 { | |
1391 return 0; | |
1392 } | |
1393 | |
1394 /* | |
1395 * Sets the currently visibale page ID. | |
1396 * Parameters: | |
1397 * handle: Handle to the notebook widget. | |
1398 * pageid: ID of the page to be made visible. | |
1399 */ | |
1400 void API dw_notebook_page_set(HWND handle, unsigned int pageid) | |
1401 { | |
1402 } | |
1403 | |
1404 /* | |
1405 * Sets the text on the specified notebook tab. | |
1406 * Parameters: | |
1407 * handle: Notebook handle. | |
1408 * pageid: Page ID of the tab to set. | |
1409 * text: Pointer to the text to set. | |
1410 */ | |
1411 void API dw_notebook_page_set_text(HWND handle, ULONG pageid, char *text) | |
1412 { | |
1413 } | |
1414 | |
1415 /* | |
1416 * Sets the text on the specified notebook tab status area. | |
1417 * Parameters: | |
1418 * handle: Notebook handle. | |
1419 * pageid: Page ID of the tab to set. | |
1420 * text: Pointer to the text to set. | |
1421 */ | |
1422 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text) | |
1423 { | |
1424 } | |
1425 | |
1426 /* | |
1427 * Packs the specified box into the notebook page. | |
1428 * Parameters: | |
1429 * handle: Handle to the notebook to be packed. | |
1430 * pageid: Page ID in the notebook which is being packed. | |
1431 * page: Box handle to be packed. | |
1432 */ | |
1433 void API dw_notebook_pack(HWND handle, ULONG pageid, HWND page) | |
1434 { | |
1435 } | |
1436 | |
1437 /* | |
1438 * Appends the specified text to the listbox's (or combobox) entry list. | |
1439 * Parameters: | |
1440 * handle: Handle to the listbox to be appended to. | |
1441 * text: Text to append into listbox. | |
1442 */ | |
1443 void API dw_listbox_append(HWND handle, char *text) | |
1444 { | |
1445 } | |
1446 | |
1447 /* | |
1448 * Clears the listbox's (or combobox) list of all entries. | |
1449 * Parameters: | |
1450 * handle: Handle to the listbox to be cleared. | |
1451 */ | |
1452 void API dw_listbox_clear(HWND handle) | |
1453 { | |
1454 } | |
1455 | |
1456 /* | |
1457 * Returns the listbox's item count. | |
1458 * Parameters: | |
1459 * handle: Handle to the listbox to be cleared. | |
1460 */ | |
1461 int API dw_listbox_count(HWND handle) | |
1462 { | |
1463 return 0; | |
1464 } | |
1465 | |
1466 /* | |
1467 * Sets the topmost item in the viewport. | |
1468 * Parameters: | |
1469 * handle: Handle to the listbox to be cleared. | |
1470 * top: Index to the top item. | |
1471 */ | |
1472 void API dw_listbox_set_top(HWND handle, int top) | |
1473 { | |
1474 } | |
1475 | |
1476 /* | |
1477 * Copies the given index item's text into buffer. | |
1478 * Parameters: | |
1479 * handle: Handle to the listbox to be queried. | |
1480 * index: Index into the list to be queried. | |
1481 * buffer: Buffer where text will be copied. | |
1482 * length: Length of the buffer (including NULL). | |
1483 */ | |
1484 void API dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length) | |
1485 { | |
1486 } | |
1487 | |
1488 /* | |
1489 * Sets the text of a given listbox entry. | |
1490 * Parameters: | |
1491 * handle: Handle to the listbox to be queried. | |
1492 * index: Index into the list to be queried. | |
1493 * buffer: Buffer where text will be copied. | |
1494 */ | |
1495 void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) | |
1496 { | |
1497 } | |
1498 | |
1499 /* | |
1500 * Returns the index to the item in the list currently selected. | |
1501 * Parameters: | |
1502 * handle: Handle to the listbox to be queried. | |
1503 */ | |
1504 unsigned int API dw_listbox_selected(HWND handle) | |
1505 { | |
1506 return 0; | |
1507 } | |
1508 | |
1509 /* | |
1510 * Returns the index to the current selected item or -1 when done. | |
1511 * Parameters: | |
1512 * handle: Handle to the listbox to be queried. | |
1513 * where: Either the previous return or -1 to restart. | |
1514 */ | |
1515 int API dw_listbox_selected_multi(HWND handle, int where) | |
1516 { | |
1517 return -1; | |
1518 } | |
1519 | |
1520 /* | |
1521 * Sets the selection state of a given index. | |
1522 * Parameters: | |
1523 * handle: Handle to the listbox to be set. | |
1524 * index: Item index. | |
1525 * state: TRUE if selected FALSE if unselected. | |
1526 */ | |
1527 void API dw_listbox_select(HWND handle, int index, int state) | |
1528 { | |
1529 } | |
1530 | |
1531 /* | |
1532 * Deletes the item with given index from the list. | |
1533 * Parameters: | |
1534 * handle: Handle to the listbox to be set. | |
1535 * index: Item index. | |
1536 */ | |
1537 void API dw_listbox_delete(HWND handle, int index) | |
1538 { | |
1539 } | |
1540 | |
1541 /* | |
1542 * Adds text to an MLE box and returns the current point. | |
1543 * Parameters: | |
1544 * handle: Handle to the MLE to be queried. | |
1545 * buffer: Text buffer to be imported. | |
1546 * startpoint: Point to start entering text. | |
1547 */ | |
1548 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint) | |
1549 { | |
1550 return 0; | |
1551 } | |
1552 | |
1553 /* | |
1554 * Grabs text from an MLE box. | |
1555 * Parameters: | |
1556 * handle: Handle to the MLE to be queried. | |
1557 * buffer: Text buffer to be exported. | |
1558 * startpoint: Point to start grabbing text. | |
1559 * length: Amount of text to be grabbed. | |
1560 */ | |
1561 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length) | |
1562 { | |
1563 } | |
1564 | |
1565 /* | |
1566 * Obtains information about an MLE box. | |
1567 * Parameters: | |
1568 * handle: Handle to the MLE to be queried. | |
1569 * bytes: A pointer to a variable to return the total bytes. | |
1570 * lines: A pointer to a variable to return the number of lines. | |
1571 */ | |
1572 void API dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines) | |
1573 { | |
1574 } | |
1575 | |
1576 /* | |
1577 * Deletes text from an MLE box. | |
1578 * Parameters: | |
1579 * handle: Handle to the MLE to be deleted from. | |
1580 * startpoint: Point to start deleting text. | |
1581 * length: Amount of text to be deleted. | |
1582 */ | |
1583 void API dw_mle_delete(HWND handle, int startpoint, int length) | |
1584 { | |
1585 } | |
1586 | |
1587 /* | |
1588 * Clears all text from an MLE box. | |
1589 * Parameters: | |
1590 * handle: Handle to the MLE to be cleared. | |
1591 */ | |
1592 void API dw_mle_clear(HWND handle) | |
1593 { | |
1594 } | |
1595 | |
1596 /* | |
1597 * Sets the visible line of an MLE box. | |
1598 * Parameters: | |
1599 * handle: Handle to the MLE to be positioned. | |
1600 * line: Line to be visible. | |
1601 */ | |
1602 void API dw_mle_set_visible(HWND handle, int line) | |
1603 { | |
1604 } | |
1605 | |
1606 /* | |
1607 * Sets the editablity of an MLE box. | |
1608 * Parameters: | |
1609 * handle: Handle to the MLE. | |
1610 * state: TRUE if it can be edited, FALSE for readonly. | |
1611 */ | |
1612 void API dw_mle_set_editable(HWND handle, int state) | |
1613 { | |
1614 } | |
1615 | |
1616 /* | |
1617 * Sets the word wrap state of an MLE box. | |
1618 * Parameters: | |
1619 * handle: Handle to the MLE. | |
1620 * state: TRUE if it wraps, FALSE if it doesn't. | |
1621 */ | |
1622 void API dw_mle_set_word_wrap(HWND handle, int state) | |
1623 { | |
1624 } | |
1625 | |
1626 /* | |
1627 * Sets the current cursor position of an MLE box. | |
1628 * Parameters: | |
1629 * handle: Handle to the MLE to be positioned. | |
1630 * point: Point to position cursor. | |
1631 */ | |
1632 void API dw_mle_set(HWND handle, int point) | |
1633 { | |
1634 } | |
1635 | |
1636 /* | |
1637 * Finds text in an MLE box. | |
1638 * Parameters: | |
1639 * handle: Handle to the MLE to be cleared. | |
1640 * text: Text to search for. | |
1641 * point: Start point of search. | |
1642 * flags: Search specific flags. | |
1643 */ | |
1644 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags) | |
1645 { | |
1646 return 0; | |
1647 } | |
1648 | |
1649 /* | |
1650 * Stops redrawing of an MLE box. | |
1651 * Parameters: | |
1652 * handle: Handle to the MLE to freeze. | |
1653 */ | |
1654 void API dw_mle_freeze(HWND handle) | |
1655 { | |
1656 } | |
1657 | |
1658 /* | |
1659 * Resumes redrawing of an MLE box. | |
1660 * Parameters: | |
1661 * handle: Handle to the MLE to thaw. | |
1662 */ | |
1663 void API dw_mle_thaw(HWND handle) | |
1664 { | |
1665 } | |
1666 | |
1667 /* | |
1668 * Returns the range of the percent bar. | |
1669 * Parameters: | |
1670 * handle: Handle to the percent bar to be queried. | |
1671 */ | |
1672 unsigned int API dw_percent_query_range(HWND handle) | |
1673 { | |
1674 return 0; | |
1675 } | |
1676 | |
1677 /* | |
1678 * Sets the percent bar position. | |
1679 * Parameters: | |
1680 * handle: Handle to the percent bar to be set. | |
1681 * position: Position of the percent bar withing the range. | |
1682 */ | |
1683 void API dw_percent_set_pos(HWND handle, unsigned int position) | |
1684 { | |
1685 } | |
1686 | |
1687 /* | |
1688 * Returns the position of the slider. | |
1689 * Parameters: | |
1690 * handle: Handle to the slider to be queried. | |
1691 */ | |
1692 unsigned int API dw_slider_query_pos(HWND handle) | |
1693 { | |
1694 return 0; | |
1695 } | |
1696 | |
1697 /* | |
1698 * Sets the slider position. | |
1699 * Parameters: | |
1700 * handle: Handle to the slider to be set. | |
1701 * position: Position of the slider withing the range. | |
1702 */ | |
1703 void API dw_slider_set_pos(HWND handle, unsigned int position) | |
1704 { | |
1705 } | |
1706 | |
1707 /* | |
1708 * Returns the position of the scrollbar. | |
1709 * Parameters: | |
1710 * handle: Handle to the scrollbar to be queried. | |
1711 */ | |
1712 unsigned int API dw_scrollbar_query_pos(HWND handle) | |
1713 { | |
1714 return 0; | |
1715 } | |
1716 | |
1717 /* | |
1718 * Sets the scrollbar position. | |
1719 * Parameters: | |
1720 * handle: Handle to the scrollbar to be set. | |
1721 * position: Position of the scrollbar withing the range. | |
1722 */ | |
1723 void API dw_scrollbar_set_pos(HWND handle, unsigned int position) | |
1724 { | |
1725 } | |
1726 | |
1727 /* | |
1728 * Sets the scrollbar range. | |
1729 * Parameters: | |
1730 * handle: Handle to the scrollbar to be set. | |
1731 * range: Maximum range value. | |
1732 * visible: Visible area relative to the range. | |
1733 */ | |
1734 void API dw_scrollbar_set_range(HWND handle, unsigned int range, unsigned int visible) | |
1735 { | |
1736 } | |
1737 | |
1738 /* | |
1739 * Sets the spinbutton value. | |
1740 * Parameters: | |
1741 * handle: Handle to the spinbutton to be set. | |
1742 * position: Current value of the spinbutton. | |
1743 */ | |
1744 void API dw_spinbutton_set_pos(HWND handle, long position) | |
1745 { | |
1746 } | |
1747 | |
1748 /* | |
1749 * Sets the spinbutton limits. | |
1750 * Parameters: | |
1751 * handle: Handle to the spinbutton to be set. | |
1752 * upper: Upper limit. | |
1753 * lower: Lower limit. | |
1754 */ | |
1755 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower) | |
1756 { | |
1757 } | |
1758 | |
1759 /* | |
1760 * Sets the entryfield character limit. | |
1761 * Parameters: | |
1762 * handle: Handle to the spinbutton to be set. | |
1763 * limit: Number of characters the entryfield will take. | |
1764 */ | |
1765 void API dw_entryfield_set_limit(HWND handle, ULONG limit) | |
1766 { | |
1767 } | |
1768 | |
1769 | |
1770 /* | |
1771 * Returns the current value of the spinbutton. | |
1772 * Parameters: | |
1773 * handle: Handle to the spinbutton to be queried. | |
1774 */ | |
1775 long API dw_spinbutton_query(HWND handle) | |
1776 { | |
1777 return 0; | |
1778 } | |
1779 | |
1780 /* | |
1781 * Returns the state of the checkbox. | |
1782 * Parameters: | |
1783 * handle: Handle to the checkbox to be queried. | |
1784 */ | |
1785 int API dw_checkbox_query(HWND handle) | |
1786 { | |
1787 return 0; | |
1788 } | |
1789 | |
1790 /* | |
1791 * Sets the state of the checkbox. | |
1792 * Parameters: | |
1793 * handle: Handle to the checkbox to be queried. | |
1794 * value: TRUE for checked, FALSE for unchecked. | |
1795 */ | |
1796 void API dw_checkbox_set(HWND handle, int value) | |
1797 { | |
1798 } | |
1799 | |
1800 /* | |
1801 * Inserts an item into a tree window (widget) after another item. | |
1802 * Parameters: | |
1803 * handle: Handle to the tree to be inserted. | |
1804 * item: Handle to the item to be positioned after. | |
1805 * title: The text title of the entry. | |
1806 * icon: Handle to coresponding icon. | |
1807 * parent: Parent handle or 0 if root. | |
1808 * itemdata: Item specific data. | |
1809 */ | |
1810 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) | |
1811 { | |
1812 return 0; | |
1813 } | |
1814 | |
1815 /* | |
1816 * Inserts an item into a tree window (widget). | |
1817 * Parameters: | |
1818 * handle: Handle to the tree to be inserted. | |
1819 * title: The text title of the entry. | |
1820 * icon: Handle to coresponding icon. | |
1821 * parent: Parent handle or 0 if root. | |
1822 * itemdata: Item specific data. | |
1823 */ | |
1824 HTREEITEM API dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) | |
1825 { | |
1826 return 0; | |
1827 } | |
1828 | |
1829 /* | |
1830 * Sets the text and icon of an item in a tree window (widget). | |
1831 * Parameters: | |
1832 * handle: Handle to the tree containing the item. | |
1833 * item: Handle of the item to be modified. | |
1834 * title: The text title of the entry. | |
1835 * icon: Handle to coresponding icon. | |
1836 */ | |
1837 void API dw_tree_set(HWND handle, HTREEITEM item, char *title, unsigned long icon) | |
1838 { | |
1839 } | |
1840 | |
1841 /* | |
1842 * Sets the item data of a tree item. | |
1843 * Parameters: | |
1844 * handle: Handle to the tree containing the item. | |
1845 * item: Handle of the item to be modified. | |
1846 * itemdata: User defined data to be associated with item. | |
1847 */ | |
1848 void API dw_tree_set_data(HWND handle, HTREEITEM item, void *itemdata) | |
1849 { | |
1850 } | |
1851 | |
1852 /* | |
1853 * Gets the item data of a tree item. | |
1854 * Parameters: | |
1855 * handle: Handle to the tree containing the item. | |
1856 * item: Handle of the item to be modified. | |
1857 */ | |
1858 void * API dw_tree_get_data(HWND handle, HTREEITEM item) | |
1859 { | |
1860 return NULL; | |
1861 } | |
1862 | |
1863 /* | |
1864 * Sets this item as the active selection. | |
1865 * Parameters: | |
1866 * handle: Handle to the tree window (widget) to be selected. | |
1867 * item: Handle to the item to be selected. | |
1868 */ | |
1869 void API dw_tree_item_select(HWND handle, HTREEITEM item) | |
1870 { | |
1871 } | |
1872 | |
1873 /* | |
1874 * Removes all nodes from a tree. | |
1875 * Parameters: | |
1876 * handle: Handle to the window (widget) to be cleared. | |
1877 */ | |
1878 void API dw_tree_clear(HWND handle) | |
1879 { | |
1880 } | |
1881 | |
1882 /* | |
1883 * Expands a node on a tree. | |
1884 * Parameters: | |
1885 * handle: Handle to the tree window (widget). | |
1886 * item: Handle to node to be expanded. | |
1887 */ | |
1888 void API dw_tree_expand(HWND handle, HTREEITEM item) | |
1889 { | |
1890 } | |
1891 | |
1892 /* | |
1893 * Collapses a node on a tree. | |
1894 * Parameters: | |
1895 * handle: Handle to the tree window (widget). | |
1896 * item: Handle to node to be collapsed. | |
1897 */ | |
1898 void API dw_tree_collapse(HWND handle, HTREEITEM item) | |
1899 { | |
1900 } | |
1901 | |
1902 /* | |
1903 * Removes a node from a tree. | |
1904 * Parameters: | |
1905 * handle: Handle to the window (widget) to be cleared. | |
1906 * item: Handle to node to be deleted. | |
1907 */ | |
1908 void API dw_tree_delete(HWND handle, HTREEITEM item) | |
1909 { | |
1910 } | |
1911 | |
1912 /* | |
1913 * Sets up the container columns. | |
1914 * Parameters: | |
1915 * handle: Handle to the container to be configured. | |
1916 * flags: An array of unsigned longs with column flags. | |
1917 * titles: An array of strings with column text titles. | |
1918 * count: The number of columns (this should match the arrays). | |
1919 * separator: The column number that contains the main separator. | |
1920 * (this item may only be used in OS/2) | |
1921 */ | |
1922 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) | |
1923 { | |
1924 return TRUE; | |
1925 } | |
1926 | |
1927 /* | |
1928 * Sets up the filesystem columns, note: filesystem always has an icon/filename field. | |
1929 * Parameters: | |
1930 * handle: Handle to the container to be configured. | |
1931 * flags: An array of unsigned longs with column flags. | |
1932 * titles: An array of strings with column text titles. | |
1933 * count: The number of columns (this should match the arrays). | |
1934 */ | |
1935 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) | |
1936 { | |
1937 char **newtitles = malloc(sizeof(char *) * (count + 2)); | |
1938 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); | |
1939 | |
1940 newtitles[0] = "Icon"; | |
1941 newtitles[1] = "Filename"; | |
1942 | |
1943 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR; | |
1944 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; | |
1945 | |
1946 memcpy(&newtitles[2], titles, sizeof(char *) * count); | |
1947 memcpy(&newflags[2], flags, sizeof(unsigned long) * count); | |
1948 | |
1949 dw_container_setup(handle, newflags, newtitles, count + 2, count ? 2 : 0); | |
1950 | |
1951 free(newtitles); | |
1952 free(newflags); | |
1953 return TRUE; | |
1954 } | |
1955 | |
1956 /* | |
1957 * Obtains an icon from a module (or header in GTK). | |
1958 * Parameters: | |
1959 * module: Handle to module (DLL) in OS/2 and Windows. | |
1960 * id: A unsigned long id int the resources on OS/2 and | |
1961 * Windows, on GTK this is converted to a pointer | |
1962 * to an embedded XPM. | |
1963 */ | |
1964 unsigned long API dw_icon_load(unsigned long module, unsigned long id) | |
1965 { | |
1966 return 0; | |
1967 } | |
1968 | |
1969 /* | |
1970 * Obtains an icon from a file. | |
1971 * Parameters: | |
1972 * filename: Name of the file, omit extention to have | |
1973 * DW pick the appropriate file extension. | |
1974 * (ICO on OS/2 or Windows, XPM on Unix) | |
1975 */ | |
1976 unsigned long API dw_icon_load_from_file(char *filename) | |
1977 { | |
1978 return 0; | |
1979 } | |
1980 | |
1981 /* | |
1982 * Frees a loaded resource in OS/2 and Windows. | |
1983 * Parameters: | |
1984 * handle: Handle to icon returned by dw_icon_load(). | |
1985 */ | |
1986 void API dw_icon_free(unsigned long handle) | |
1987 { | |
1988 } | |
1989 | |
1990 /* | |
1991 * Allocates memory used to populate a container. | |
1992 * Parameters: | |
1993 * handle: Handle to the container window (widget). | |
1994 * rowcount: The number of items to be populated. | |
1995 */ | |
1996 void * API dw_container_alloc(HWND handle, int rowcount) | |
1997 { | |
1998 return NULL; | |
1999 } | |
2000 | |
2001 /* | |
2002 * Sets an item in specified row and column to the given data. | |
2003 * Parameters: | |
2004 * handle: Handle to the container window (widget). | |
2005 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
2006 * column: Zero based column of data being set. | |
2007 * row: Zero based row of data being set. | |
2008 * data: Pointer to the data to be added. | |
2009 */ | |
2010 void API dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
2011 { | |
2012 } | |
2013 | |
2014 /* | |
2015 * Changes an existing item in specified row and column to the given data. | |
2016 * Parameters: | |
2017 * handle: Handle to the container window (widget). | |
2018 * column: Zero based column of data being set. | |
2019 * row: Zero based row of data being set. | |
2020 * data: Pointer to the data to be added. | |
2021 */ | |
2022 void API dw_container_change_item(HWND handle, int column, int row, void *data) | |
2023 { | |
2024 } | |
2025 | |
2026 /* | |
2027 * Sets an item in specified row and column to the given data. | |
2028 * Parameters: | |
2029 * handle: Handle to the container window (widget). | |
2030 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
2031 * column: Zero based column of data being set. | |
2032 * row: Zero based row of data being set. | |
2033 * data: Pointer to the data to be added. | |
2034 */ | |
2035 void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) | |
2036 { | |
2037 dw_container_set_item(handle, pointer, 0, row, (void *)&icon); | |
2038 dw_container_set_item(handle, pointer, 1, row, (void *)&filename); | |
2039 } | |
2040 | |
2041 /* | |
2042 * Sets an item in specified row and column to the given data. | |
2043 * Parameters: | |
2044 * handle: Handle to the container window (widget). | |
2045 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
2046 * column: Zero based column of data being set. | |
2047 * row: Zero based row of data being set. | |
2048 * data: Pointer to the data to be added. | |
2049 */ | |
2050 void API dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
2051 { | |
2052 dw_container_set_item(handle, pointer, column + 2, row, data); | |
2053 } | |
2054 | |
2055 /* | |
2056 * Sets the width of a column in the container. | |
2057 * Parameters: | |
2058 * handle: Handle to window (widget) of container. | |
2059 * column: Zero based column of width being set. | |
2060 * width: Width of column in pixels. | |
2061 */ | |
2062 void API dw_container_set_column_width(HWND handle, int column, int width) | |
2063 { | |
2064 } | |
2065 | |
2066 /* | |
2067 * Sets the title of a row in the container. | |
2068 * Parameters: | |
2069 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
2070 * row: Zero based row of data being set. | |
2071 * title: String title of the item. | |
2072 */ | |
2073 void API dw_container_set_row_title(void *pointer, int row, char *title) | |
2074 { | |
2075 } | |
2076 | |
2077 /* | |
2078 * Sets the title of a row in the container. | |
2079 * Parameters: | |
2080 * handle: Handle to the container window (widget). | |
2081 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
2082 * rowcount: The number of rows to be inserted. | |
2083 */ | |
2084 void API dw_container_insert(HWND handle, void *pointer, int rowcount) | |
2085 { | |
2086 } | |
2087 | |
2088 /* | |
2089 * Removes all rows from a container. | |
2090 * Parameters: | |
2091 * handle: Handle to the window (widget) to be cleared. | |
2092 * redraw: TRUE to cause the container to redraw immediately. | |
2093 */ | |
2094 void API dw_container_clear(HWND handle, int redraw) | |
2095 { | |
2096 } | |
2097 | |
2098 /* | |
2099 * Removes the first x rows from a container. | |
2100 * Parameters: | |
2101 * handle: Handle to the window (widget) to be deleted from. | |
2102 * rowcount: The number of rows to be deleted. | |
2103 */ | |
2104 void API dw_container_delete(HWND handle, int rowcount) | |
2105 { | |
2106 } | |
2107 | |
2108 /* | |
2109 * Scrolls container up or down. | |
2110 * Parameters: | |
2111 * handle: Handle to the window (widget) to be scrolled. | |
2112 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or | |
2113 * DW_SCROLL_BOTTOM. (rows is ignored for last two) | |
2114 * rows: The number of rows to be scrolled. | |
2115 */ | |
2116 void API dw_container_scroll(HWND handle, int direction, long rows) | |
2117 { | |
2118 } | |
2119 | |
2120 /* | |
2121 * Starts a new query of a container. | |
2122 * Parameters: | |
2123 * handle: Handle to the window (widget) to be queried. | |
2124 * flags: If this parameter is DW_CRA_SELECTED it will only | |
2125 * return items that are currently selected. Otherwise | |
2126 * it will return all records in the container. | |
2127 */ | |
2128 char * API dw_container_query_start(HWND handle, unsigned long flags) | |
2129 { | |
2130 return NULL; | |
2131 } | |
2132 | |
2133 /* | |
2134 * Continues an existing query of a container. | |
2135 * Parameters: | |
2136 * handle: Handle to the window (widget) to be queried. | |
2137 * flags: If this parameter is DW_CRA_SELECTED it will only | |
2138 * return items that are currently selected. Otherwise | |
2139 * it will return all records in the container. | |
2140 */ | |
2141 char * API dw_container_query_next(HWND handle, unsigned long flags) | |
2142 { | |
2143 return NULL; | |
2144 } | |
2145 | |
2146 /* | |
2147 * Cursors the item with the text speficied, and scrolls to that item. | |
2148 * Parameters: | |
2149 * handle: Handle to the window (widget) to be queried. | |
2150 * text: Text usually returned by dw_container_query(). | |
2151 */ | |
2152 void API dw_container_cursor(HWND handle, char *text) | |
2153 { | |
2154 } | |
2155 | |
2156 /* | |
2157 * Deletes the item with the text speficied. | |
2158 * Parameters: | |
2159 * handle: Handle to the window (widget). | |
2160 * text: Text usually returned by dw_container_query(). | |
2161 */ | |
2162 void API dw_container_delete_row(HWND handle, char *text) | |
2163 { | |
2164 } | |
2165 | |
2166 /* | |
2167 * Optimizes the column widths so that all data is visible. | |
2168 * Parameters: | |
2169 * handle: Handle to the window (widget) to be optimized. | |
2170 */ | |
2171 void API dw_container_optimize(HWND handle) | |
2172 { | |
2173 } | |
2174 | |
2175 /* | |
2176 * Creates a rendering context widget (window) to be packed. | |
2177 * Parameters: | |
2178 * id: An id to be used with dw_window_from_id. | |
2179 * Returns: | |
2180 * A handle to the widget or NULL on failure. | |
2181 */ | |
2182 HWND API dw_render_new(unsigned long id) | |
2183 { | |
2184 return 0; | |
2185 } | |
2186 | |
2187 /* Sets the current foreground drawing color. | |
2188 * Parameters: | |
2189 * red: red value. | |
2190 * green: green value. | |
2191 * blue: blue value. | |
2192 */ | |
2193 void API dw_color_foreground_set(unsigned long value) | |
2194 { | |
2195 } | |
2196 | |
2197 /* Sets the current background drawing color. | |
2198 * Parameters: | |
2199 * red: red value. | |
2200 * green: green value. | |
2201 * blue: blue value. | |
2202 */ | |
2203 void API dw_color_background_set(unsigned long value) | |
2204 { | |
2205 } | |
2206 | |
2207 /* Draw a point on a window (preferably a render window). | |
2208 * Parameters: | |
2209 * handle: Handle to the window. | |
2210 * pixmap: Handle to the pixmap. (choose only one of these) | |
2211 * x: X coordinate. | |
2212 * y: Y coordinate. | |
2213 */ | |
2214 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) | |
2215 { | |
2216 } | |
2217 | |
2218 /* Draw a line on a window (preferably a render window). | |
2219 * Parameters: | |
2220 * handle: Handle to the window. | |
2221 * pixmap: Handle to the pixmap. (choose only one of these) | |
2222 * x1: First X coordinate. | |
2223 * y1: First Y coordinate. | |
2224 * x2: Second X coordinate. | |
2225 * y2: Second Y coordinate. | |
2226 */ | |
2227 void API dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) | |
2228 { | |
2229 } | |
2230 | |
2231 /* Draw text on a window (preferably a render window). | |
2232 * Parameters: | |
2233 * handle: Handle to the window. | |
2234 * pixmap: Handle to the pixmap. (choose only one of these) | |
2235 * x: X coordinate. | |
2236 * y: Y coordinate. | |
2237 * text: Text to be displayed. | |
2238 */ | |
2239 void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) | |
2240 { | |
2241 } | |
2242 | |
2243 /* Query the width and height of a text string. | |
2244 * Parameters: | |
2245 * handle: Handle to the window. | |
2246 * pixmap: Handle to the pixmap. (choose only one of these) | |
2247 * text: Text to be queried. | |
2248 * width: Pointer to a variable to be filled in with the width. | |
2249 * height Pointer to a variable to be filled in with the height. | |
2250 */ | |
2251 void API dw_font_text_extents(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height) | |
2252 { | |
2253 } | |
2254 | |
2255 /* Draw a rectangle on a window (preferably a render window). | |
2256 * Parameters: | |
2257 * handle: Handle to the window. | |
2258 * pixmap: Handle to the pixmap. (choose only one of these) | |
2259 * fill: Fill box TRUE or FALSE. | |
2260 * x: X coordinate. | |
2261 * y: Y coordinate. | |
2262 * width: Width of rectangle. | |
2263 * height: Height of rectangle. | |
2264 */ | |
2265 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) | |
2266 { | |
2267 } | |
2268 | |
2269 /* Call this after drawing to the screen to make sure | |
2270 * anything you have drawn is visible. | |
2271 */ | |
2272 void API dw_flush(void) | |
2273 { | |
2274 } | |
2275 | |
2276 /* | |
2277 * Creates a pixmap with given parameters. | |
2278 * Parameters: | |
2279 * handle: Window handle the pixmap is associated with. | |
2280 * width: Width of the pixmap in pixels. | |
2281 * height: Height of the pixmap in pixels. | |
2282 * depth: Color depth of the pixmap. | |
2283 * Returns: | |
2284 * A handle to a pixmap or NULL on failure. | |
2285 */ | |
2286 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) | |
2287 { | |
2288 return 0; | |
2289 } | |
2290 | |
2291 /* | |
2292 * Creates a pixmap from a file. | |
2293 * Parameters: | |
2294 * handle: Window handle the pixmap is associated with. | |
2295 * filename: Name of the file, omit extention to have | |
2296 * DW pick the appropriate file extension. | |
2297 * (BMP on OS/2 or Windows, XPM on Unix) | |
2298 * Returns: | |
2299 * A handle to a pixmap or NULL on failure. | |
2300 */ | |
2301 HPIXMAP API dw_pixmap_new_from_file(HWND handle, char *filename) | |
2302 { | |
2303 return 0; | |
2304 } | |
2305 | |
2306 /* | |
2307 * Creates a pixmap from internal resource graphic specified by id. | |
2308 * Parameters: | |
2309 * handle: Window handle the pixmap is associated with. | |
2310 * id: Resource ID associated with requested pixmap. | |
2311 * Returns: | |
2312 * A handle to a pixmap or NULL on failure. | |
2313 */ | |
2314 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG id) | |
2315 { | |
2316 return 0; | |
2317 } | |
2318 | |
2319 /* | |
2320 * Destroys an allocated pixmap. | |
2321 * Parameters: | |
2322 * pixmap: Handle to a pixmap returned by | |
2323 * dw_pixmap_new.. | |
2324 */ | |
2325 void API dw_pixmap_destroy(HPIXMAP pixmap) | |
2326 { | |
2327 } | |
2328 | |
2329 /* | |
2330 * Copies from one item to another. | |
2331 * Parameters: | |
2332 * dest: Destination window handle. | |
2333 * destp: Destination pixmap. (choose only one). | |
2334 * xdest: X coordinate of destination. | |
2335 * ydest: Y coordinate of destination. | |
2336 * width: Width of area to copy. | |
2337 * height: Height of area to copy. | |
2338 * src: Source window handle. | |
2339 * srcp: Source pixmap. (choose only one). | |
2340 * xsrc: X coordinate of source. | |
2341 * ysrc: Y coordinate of source. | |
2342 */ | |
2343 void API dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) | |
2344 { | |
2345 } | |
2346 | |
2347 /* | |
2348 * Emits a beep. | |
2349 * Parameters: | |
2350 * freq: Frequency. | |
2351 * dur: Duration. | |
2352 */ | |
2353 void API dw_beep(int freq, int dur) | |
2354 { | |
2355 } | |
2356 | |
2357 /* Open a shared library and return a handle. | |
2358 * Parameters: | |
2359 * name: Base name of the shared library. | |
2360 * handle: Pointer to a module handle, | |
2361 * will be filled in with the handle. | |
2362 */ | |
2363 int API dw_module_load(char *name, HMOD *handle) | |
2364 { | |
2365 return 0; | |
2366 } | |
2367 | |
2368 /* Queries the address of a symbol within open handle. | |
2369 * Parameters: | |
2370 * handle: Module handle returned by dw_module_load() | |
2371 * name: Name of the symbol you want the address of. | |
2372 * func: A pointer to a function pointer, to obtain | |
2373 * the address. | |
2374 */ | |
2375 int API dw_module_symbol(HMOD handle, char *name, void**func) | |
2376 { | |
2377 return 0; | |
2378 } | |
2379 | |
2380 /* Frees the shared library previously opened. | |
2381 * Parameters: | |
2382 * handle: Module handle returned by dw_module_load() | |
2383 */ | |
2384 int API dw_module_close(HMOD handle) | |
2385 { | |
2386 return 0; | |
2387 } | |
2388 | |
2389 /* | |
2390 * Returns the handle to an unnamed mutex semaphore. | |
2391 */ | |
2392 HMTX API dw_mutex_new(void) | |
2393 { | |
2394 return 0; | |
2395 } | |
2396 | |
2397 /* | |
2398 * Closes a semaphore created by dw_mutex_new(). | |
2399 * Parameters: | |
2400 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
2401 */ | |
2402 void API dw_mutex_close(HMTX mutex) | |
2403 { | |
2404 } | |
2405 | |
2406 /* | |
2407 * Tries to gain access to the semaphore, if it can't it blocks. | |
2408 * If we are in a callback we must keep the message loop running | |
2409 * while blocking. | |
2410 * Parameters: | |
2411 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
2412 */ | |
2413 void API dw_mutex_lock(HMTX mutex) | |
2414 { | |
2415 } | |
2416 | |
2417 /* | |
2418 * Reliquishes the access to the semaphore. | |
2419 * Parameters: | |
2420 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
2421 */ | |
2422 void API dw_mutex_unlock(HMTX mutex) | |
2423 { | |
2424 } | |
2425 | |
2426 /* | |
2427 * Returns the handle to an unnamed event semaphore. | |
2428 */ | |
2429 HEV API dw_event_new(void) | |
2430 { | |
2431 return 0; | |
2432 } | |
2433 | |
2434 /* | |
2435 * Resets a semaphore created by dw_event_new(). | |
2436 * Parameters: | |
2437 * eve: The handle to the event returned by dw_event_new(). | |
2438 */ | |
2439 int API dw_event_reset(HEV eve) | |
2440 { | |
2441 return TRUE; | |
2442 } | |
2443 | |
2444 /* | |
2445 * Posts a semaphore created by dw_event_new(). Causing all threads | |
2446 * waiting on this event in dw_event_wait to continue. | |
2447 * Parameters: | |
2448 * eve: The handle to the event returned by dw_event_new(). | |
2449 */ | |
2450 int API dw_event_post(HEV eve) | |
2451 { | |
2452 return TRUE; | |
2453 } | |
2454 | |
2455 | |
2456 /* | |
2457 * Waits on a semaphore created by dw_event_new(), until the | |
2458 * event gets posted or until the timeout expires. | |
2459 * Parameters: | |
2460 * eve: The handle to the event returned by dw_event_new(). | |
2461 */ | |
2462 int API dw_event_wait(HEV eve, unsigned long timeout) | |
2463 { | |
2464 return 0; | |
2465 } | |
2466 | |
2467 /* | |
2468 * Closes a semaphore created by dw_event_new(). | |
2469 * Parameters: | |
2470 * eve: The handle to the event returned by dw_event_new(). | |
2471 */ | |
2472 int API dw_event_close(HEV *eve) | |
2473 { | |
2474 return TRUE; | |
2475 } | |
2476 | |
2477 /* | |
2478 * Creates a new thread with a starting point of func. | |
2479 * Parameters: | |
2480 * func: Function which will be run in the new thread. | |
2481 * data: Parameter(s) passed to the function. | |
2482 * stack: Stack size of new thread (OS/2 and Windows only). | |
2483 */ | |
2484 DWTID API dw_thread_new(void *func, void *data, int stack) | |
2485 { | |
2486 } | |
2487 | |
2488 /* | |
2489 * Ends execution of current thread immediately. | |
2490 */ | |
2491 void API dw_thread_end(void) | |
2492 { | |
2493 } | |
2494 | |
2495 /* | |
2496 * Returns the current thread's ID. | |
2497 */ | |
2498 DWTID API dw_thread_id(void) | |
2499 { | |
2500 return 0; | |
2501 } | |
2502 | |
2503 /* | |
2504 * Cleanly terminates a DW session, should be signal handler safe. | |
2505 * Parameters: | |
2506 * exitcode: Exit code reported to the operating system. | |
2507 */ | |
2508 void API dw_exit(int exitcode) | |
2509 { | |
2510 exit(exitcode); | |
2511 } | |
2512 | |
2513 /* | |
2514 * Creates a splitbar window (widget) with given parameters. | |
2515 * Parameters: | |
2516 * type: Value can be DW_VERT or DW_HORZ. | |
2517 * topleft: Handle to the window to be top or left. | |
2518 * bottomright: Handle to the window to be bottom or right. | |
2519 * Returns: | |
2520 * A handle to a splitbar window or NULL on failure. | |
2521 */ | |
2522 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id) | |
2523 { | |
2524 return 0; | |
2525 } | |
2526 | |
2527 /* | |
2528 * Sets the position of a splitbar (pecentage). | |
2529 * Parameters: | |
2530 * handle: The handle to the splitbar returned by dw_splitbar_new(). | |
2531 */ | |
2532 void API dw_splitbar_set(HWND handle, float percent) | |
2533 { | |
2534 } | |
2535 | |
2536 /* | |
2537 * Gets the position of a splitbar (pecentage). | |
2538 * Parameters: | |
2539 * handle: The handle to the splitbar returned by dw_splitbar_new(). | |
2540 */ | |
2541 float API dw_splitbar_get(HWND handle) | |
2542 return 0.0; | |
2543 } | |
2544 | |
2545 /* | |
2546 * Pack windows (widgets) into a box from the start (or top). | |
2547 * Parameters: | |
2548 * box: Window handle of the box to be packed into. | |
2549 * item: Window handle of the item to be back. | |
2550 * width: Width in pixels of the item or -1 to be self determined. | |
2551 * height: Height in pixels of the item or -1 to be self determined. | |
2552 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
2553 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
2554 * pad: Number of pixels of padding around the item. | |
2555 */ | |
2556 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
2557 { | |
2558 } | |
2559 | |
2560 /* | |
2561 * Sets the default focus item for a window/dialog. | |
2562 * Parameters: | |
2563 * window: Toplevel window or dialog. | |
2564 * defaultitem: Handle to the dialog item to be default. | |
2565 */ | |
2566 void API dw_window_default(HWND window, HWND defaultitem) | |
2567 { | |
2568 } | |
2569 | |
2570 /* | |
2571 * Sets window to click the default dialog item when an ENTER is pressed. | |
2572 * Parameters: | |
2573 * window: Window (widget) to look for the ENTER press. | |
2574 * next: Window (widget) to move to next (or click) | |
2575 */ | |
2576 void API dw_window_click_default(HWND window, HWND next) | |
2577 { | |
2578 } | |
2579 | |
2580 /* | |
2581 * Returns some information about the current operating environment. | |
2582 * Parameters: | |
2583 * env: Pointer to a DWEnv struct. | |
2584 */ | |
2585 void API dw_environment_query(DWEnv *env) | |
2586 { | |
2587 ULONG Build; | |
2588 | |
2589 if(!env) | |
2590 return; | |
2591 | |
2592 strcpy(env->osName,"MacOS"); | |
2593 env->MajorVersion = 10; | |
2594 env->MinorVersion = 0; | |
2595 | |
2596 env->MinorBuild = 0; | |
2597 env->MajorBuild = 0; | |
2598 | |
2599 strcpy(env->buildDate, __DATE__); | |
2600 strcpy(env->buildTime, __TIME__); | |
2601 env->DWMajorVersion = DW_MAJOR_VERSION; | |
2602 env->DWMinorVersion = DW_MINOR_VERSION; | |
2603 env->DWSubVersion = DW_SUB_VERSION; | |
2604 } | |
2605 | |
2606 /* | |
2607 * Opens a file dialog and queries user selection. | |
2608 * Parameters: | |
2609 * title: Title bar text for dialog. | |
2610 * defpath: The default path of the open dialog. | |
2611 * ext: Default file extention. | |
2612 * flags: DW_FILE_OPEN or DW_FILE_SAVE. | |
2613 * Returns: | |
2614 * NULL on error. A malloced buffer containing | |
2615 * the file path on success. | |
2616 * | |
2617 */ | |
2618 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags) | |
2619 { | |
2620 return NULL; | |
2621 } | |
2622 | |
2623 /* | |
2624 * Execute and external program in a seperate session. | |
2625 * Parameters: | |
2626 * program: Program name with optional path. | |
2627 * type: Either DW_EXEC_CON or DW_EXEC_GUI. | |
2628 * params: An array of pointers to string arguements. | |
2629 * Returns: | |
2630 * -1 on error. | |
2631 */ | |
2632 int API dw_exec(char *program, int type, char **params) | |
2633 { | |
2634 return -1; | |
2635 } | |
2636 | |
2637 /* | |
2638 * Loads a web browser pointed at the given URL. | |
2639 * Parameters: | |
2640 * url: Uniform resource locator. | |
2641 */ | |
2642 int API dw_browse(char *url) | |
2643 { | |
2644 return -1; | |
2645 } | |
2646 | |
2647 /* | |
2648 * Returns a pointer to a static buffer which containes the | |
2649 * current user directory. Or the root directory (C:\ on | |
2650 * OS/2 and Windows). | |
2651 */ | |
2652 char * API dw_user_dir(void) | |
2653 { | |
2654 static char _user_dir[1024] = ""; | |
2655 | |
2656 if(!_user_dir[0]) | |
2657 { | |
2658 char *home = getenv("HOME"); | |
2659 | |
2660 if(home) | |
2661 strcpy(_user_dir, home); | |
2662 else | |
2663 strcpy(_user_dir, "/"); | |
2664 } | |
2665 return _user_dir; | |
2666 } | |
2667 | |
2668 /* | |
2669 * Call a function from the window (widget)'s context. | |
2670 * Parameters: | |
2671 * handle: Window handle of the widget. | |
2672 * function: Function pointer to be called. | |
2673 * data: Pointer to the data to be passed to the function. | |
2674 */ | |
2675 void API dw_window_function(HWND handle, void *function, void *data) | |
2676 { | |
2677 } | |
2678 | |
2679 /* Functions for managing the user data lists that are associated with | |
2680 * a given window handle. Used in dw_window_set_data() and | |
2681 * dw_window_get_data(). | |
2682 */ | |
2683 UserData *_find_userdata(UserData **root, char *varname) | |
2684 { | |
2685 UserData *tmp = *root; | |
2686 | |
2687 while(tmp) | |
2688 { | |
2689 if(stricmp(tmp->varname, varname) == 0) | |
2690 return tmp; | |
2691 tmp = tmp->next; | |
2692 } | |
2693 return NULL; | |
2694 } | |
2695 | |
2696 int _new_userdata(UserData **root, char *varname, void *data) | |
2697 { | |
2698 UserData *new = _find_userdata(root, varname); | |
2699 | |
2700 if(new) | |
2701 { | |
2702 new->data = data; | |
2703 return TRUE; | |
2704 } | |
2705 else | |
2706 { | |
2707 new = malloc(sizeof(UserData)); | |
2708 if(new) | |
2709 { | |
2710 new->varname = strdup(varname); | |
2711 new->data = data; | |
2712 | |
2713 new->next = NULL; | |
2714 | |
2715 if (!*root) | |
2716 *root = new; | |
2717 else | |
2718 { | |
2719 UserData *prev = NULL, *tmp = *root; | |
2720 while(tmp) | |
2721 { | |
2722 prev = tmp; | |
2723 tmp = tmp->next; | |
2724 } | |
2725 if(prev) | |
2726 prev->next = new; | |
2727 else | |
2728 *root = new; | |
2729 } | |
2730 return TRUE; | |
2731 } | |
2732 } | |
2733 return FALSE; | |
2734 } | |
2735 | |
2736 int _remove_userdata(UserData **root, char *varname, int all) | |
2737 { | |
2738 UserData *prev = NULL, *tmp = *root; | |
2739 | |
2740 while(tmp) | |
2741 { | |
2742 if(all || stricmp(tmp->varname, varname) == 0) | |
2743 { | |
2744 if(!prev) | |
2745 { | |
2746 *root = tmp->next; | |
2747 free(tmp->varname); | |
2748 free(tmp); | |
2749 if(!all) | |
2750 return 0; | |
2751 tmp = *root; | |
2752 } | |
2753 else | |
2754 { | |
2755 /* If all is true we should | |
2756 * never get here. | |
2757 */ | |
2758 prev->next = tmp->next; | |
2759 free(tmp->varname); | |
2760 free(tmp); | |
2761 return 0; | |
2762 } | |
2763 } | |
2764 else | |
2765 { | |
2766 prev = tmp; | |
2767 tmp = tmp->next; | |
2768 } | |
2769 } | |
2770 return 0; | |
2771 } | |
2772 | |
2773 /* | |
2774 * Add a named user data item to a window handle. | |
2775 * Parameters: | |
2776 * window: Window handle of signal to be called back. | |
2777 * dataname: A string pointer identifying which signal to be hooked. | |
2778 * data: User data to be passed to the handler function. | |
2779 */ | |
2780 void API dw_window_set_data(HWND window, char *dataname, void *data) | |
2781 { | |
2782 WindowData *blah = (WindowData *)_get_window_pointer(window); | |
2783 | |
2784 if(!blah) | |
2785 { | |
2786 if(!dataname) | |
2787 return; | |
2788 | |
2789 blah = calloc(1, sizeof(WindowData)); | |
2790 WinSetWindowPtr(window, QWP_USER, blah); | |
2791 } | |
2792 | |
2793 if(data) | |
2794 _new_userdata(&(blah->root), dataname, data); | |
2795 else | |
2796 { | |
2797 if(dataname) | |
2798 _remove_userdata(&(blah->root), dataname, FALSE); | |
2799 else | |
2800 _remove_userdata(&(blah->root), NULL, TRUE); | |
2801 } | |
2802 } | |
2803 | |
2804 /* | |
2805 * Gets a named user data item to a window handle. | |
2806 * Parameters: | |
2807 * window: Window handle of signal to be called back. | |
2808 * dataname: A string pointer identifying which signal to be hooked. | |
2809 * data: User data to be passed to the handler function. | |
2810 */ | |
2811 void *dw_window_get_data(HWND window, char *dataname) | |
2812 { | |
2813 WindowData *blah = (WindowData *)_get_window_pointer(window); | |
2814 | |
2815 if(blah && blah->root && dataname) | |
2816 { | |
2817 UserData *ud = _find_userdata(&(blah->root), dataname); | |
2818 if(ud) | |
2819 return ud->data; | |
2820 } | |
2821 return NULL; | |
2822 } | |
2823 | |
2824 /* | |
2825 * Add a callback to a timer event. | |
2826 * Parameters: | |
2827 * interval: Milliseconds to delay between calls. | |
2828 * sigfunc: The pointer to the function to be used as the callback. | |
2829 * data: User data to be passed to the handler function. | |
2830 * Returns: | |
2831 * Timer ID for use with dw_timer_disconnect(), 0 on error. | |
2832 */ | |
2833 int API dw_timer_connect(int interval, void *sigfunc, void *data) | |
2834 { | |
2835 return 0; | |
2836 } | |
2837 | |
2838 /* | |
2839 * Removes timer callback. | |
2840 * Parameters: | |
2841 * id: Timer ID returned by dw_timer_connect(). | |
2842 */ | |
2843 void API dw_timer_disconnect(int id) | |
2844 { | |
2845 SignalHandler *prev = NULL, *tmp = Root; | |
2846 | |
2847 /* 0 is an invalid timer ID */ | |
2848 if(!id) | |
2849 return; | |
2850 | |
2851 while(tmp) | |
2852 { | |
2853 if(tmp->id == id) | |
2854 { | |
2855 if(prev) | |
2856 { | |
2857 prev->next = tmp->next; | |
2858 free(tmp); | |
2859 tmp = prev->next; | |
2860 } | |
2861 else | |
2862 { | |
2863 Root = tmp->next; | |
2864 free(tmp); | |
2865 tmp = Root; | |
2866 } | |
2867 } | |
2868 else | |
2869 { | |
2870 prev = tmp; | |
2871 tmp = tmp->next; | |
2872 } | |
2873 } | |
2874 } | |
2875 | |
2876 /* | |
2877 * Add a callback to a window event. | |
2878 * Parameters: | |
2879 * window: Window handle of signal to be called back. | |
2880 * signame: A string pointer identifying which signal to be hooked. | |
2881 * sigfunc: The pointer to the function to be used as the callback. | |
2882 * data: User data to be passed to the handler function. | |
2883 */ | |
2884 void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) | |
2885 { | |
2886 ULONG message = 0L; | |
2887 | |
2888 if(window && signame && sigfunc) | |
2889 { | |
2890 if((message = _findsigmessage(signame)) != 0) | |
2891 _new_signal(message, window, 0, sigfunc, data); | |
2892 } | |
2893 } | |
2894 | |
2895 /* | |
2896 * Removes callbacks for a given window with given name. | |
2897 * Parameters: | |
2898 * window: Window handle of callback to be removed. | |
2899 */ | |
2900 void API dw_signal_disconnect_by_name(HWND window, char *signame) | |
2901 { | |
2902 SignalHandler *prev = NULL, *tmp = Root; | |
2903 ULONG message; | |
2904 | |
2905 if(!window || !signame || (message = _findsigmessage(signame)) == 0) | |
2906 return; | |
2907 | |
2908 while(tmp) | |
2909 { | |
2910 if(tmp->window == window && tmp->message == message) | |
2911 { | |
2912 if(prev) | |
2913 { | |
2914 prev->next = tmp->next; | |
2915 free(tmp); | |
2916 tmp = prev->next; | |
2917 } | |
2918 else | |
2919 { | |
2920 Root = tmp->next; | |
2921 free(tmp); | |
2922 tmp = Root; | |
2923 } | |
2924 } | |
2925 else | |
2926 { | |
2927 prev = tmp; | |
2928 tmp = tmp->next; | |
2929 } | |
2930 } | |
2931 } | |
2932 | |
2933 /* | |
2934 * Removes all callbacks for a given window. | |
2935 * Parameters: | |
2936 * window: Window handle of callback to be removed. | |
2937 */ | |
2938 void API dw_signal_disconnect_by_window(HWND window) | |
2939 { | |
2940 SignalHandler *prev = NULL, *tmp = Root; | |
2941 | |
2942 while(tmp) | |
2943 { | |
2944 if(tmp->window == window) | |
2945 { | |
2946 if(prev) | |
2947 { | |
2948 prev->next = tmp->next; | |
2949 free(tmp); | |
2950 tmp = prev->next; | |
2951 } | |
2952 else | |
2953 { | |
2954 Root = tmp->next; | |
2955 free(tmp); | |
2956 tmp = Root; | |
2957 } | |
2958 } | |
2959 else | |
2960 { | |
2961 prev = tmp; | |
2962 tmp = tmp->next; | |
2963 } | |
2964 } | |
2965 } | |
2966 | |
2967 /* | |
2968 * Removes all callbacks for a given window with specified data. | |
2969 * Parameters: | |
2970 * window: Window handle of callback to be removed. | |
2971 * data: Pointer to the data to be compared against. | |
2972 */ | |
2973 void API dw_signal_disconnect_by_data(HWND window, void *data) | |
2974 { | |
2975 SignalHandler *prev = NULL, *tmp = Root; | |
2976 | |
2977 while(tmp) | |
2978 { | |
2979 if(tmp->window == window && tmp->data == data) | |
2980 { | |
2981 if(prev) | |
2982 { | |
2983 prev->next = tmp->next; | |
2984 free(tmp); | |
2985 tmp = prev->next; | |
2986 } | |
2987 else | |
2988 { | |
2989 Root = tmp->next; | |
2990 free(tmp); | |
2991 tmp = Root; | |
2992 } | |
2993 } | |
2994 else | |
2995 { | |
2996 prev = tmp; | |
2997 tmp = tmp->next; | |
2998 } | |
2999 } | |
3000 } | |
3001 | |
3002 |