Mercurial > dwindows
comparison mac/dw.m @ 650:55b677d460e9
Added initial support for a MacOS Cocoa port.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 22 Feb 2011 17:15:15 +0000 |
parents | |
children | 270580896dac |
comparison
equal
deleted
inserted
replaced
649:3e2ada9ee0ac | 650:55b677d460e9 |
---|---|
1 /* | |
2 * Dynamic Windows: | |
3 * A GTK like implementation of the MacOS GUI using Cocoa | |
4 * | |
5 * (C) 2011 Brian Smith <brian@dbsoft.org> | |
6 * | |
7 * Using garbage collection so requires 10.5 or later. | |
8 * clang -std=c99 -g -o dwtest -D__MAC__ -I. mac/dw.m -framework Cocoa -fobjc-gc-only | |
9 */ | |
10 #import <Cocoa/Cocoa.h> | |
11 #import <WebKit/WebKit.h> | |
12 #include "dw.h" | |
13 #include <sys/utsname.h> | |
14 #include <sys/socket.h> | |
15 #include <sys/un.h> | |
16 #include <sys/mman.h> | |
17 #include <sys/time.h> | |
18 #include <sys/stat.h> | |
19 | |
20 static void _do_resize(Box *thisbox, int x, int y); | |
21 | |
22 /* So basically to implement our event handlers... | |
23 * it looks like we are going to have to subclass | |
24 * basically everything. Was hoping to add methods | |
25 * to the superclasses but it looks like you can | |
26 * only add methods and no variables, which isn't | |
27 * going to work. -Brian | |
28 */ | |
29 | |
30 /* Subclass for a box type */ | |
31 @interface DWBox : NSView | |
32 { | |
33 Box box; | |
34 void *userdata; | |
35 NSColor *bgcolor; | |
36 } | |
37 -(Box)box; | |
38 -(void *)userdata; | |
39 -(void)setBox:(Box)input; | |
40 -(void)setUserdata:(void *)input; | |
41 -(void)drawRect:(NSRect)rect; | |
42 @end | |
43 | |
44 @implementation DWBox | |
45 -(Box)box { return box; } | |
46 -(void *)userdata { return userdata; } | |
47 -(void)setBox:(Box)input { box = input; } | |
48 -(void)setUserdata:(void *)input { userdata = input; } | |
49 -(void)drawRect:(NSRect)rect | |
50 { | |
51 if(bgcolor) | |
52 { | |
53 [bgcolor set]; | |
54 NSRectFill( [self bounds] ); | |
55 } | |
56 } | |
57 @end | |
58 | |
59 /* Subclass for a top-level window */ | |
60 @interface DWView : DWBox { } | |
61 @end | |
62 | |
63 @implementation DWView | |
64 -(void)windowWillClose:(NSNotification *)note | |
65 { | |
66 [[NSApplication sharedApplication] terminate:self]; | |
67 } | |
68 - (void)viewDidMoveToWindow | |
69 { | |
70 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowResized:) name:NSWindowDidResizeNotification object:[self window]]; | |
71 } | |
72 - (void)dealloc | |
73 { | |
74 [[NSNotificationCenter defaultCenter] removeObserver:self]; | |
75 [super dealloc]; | |
76 } | |
77 - (void)windowResized:(NSNotification *)notification; | |
78 { | |
79 NSSize size = [self frame].size; | |
80 _do_resize(&box, size.width, size.height); | |
81 } | |
82 @end | |
83 | |
84 /* Subclass for a button type */ | |
85 @interface DWButton : NSButton | |
86 { | |
87 void *userdata; | |
88 } | |
89 -(void *)userdata; | |
90 -(void)setUserdata:(void *)input; | |
91 @end | |
92 | |
93 @implementation DWButton | |
94 -(void *)userdata { return userdata; } | |
95 -(void)setUserdata:(void *)input { userdata = input; } | |
96 @end | |
97 | |
98 /* Subclass for a progress type */ | |
99 @interface DWPercent : NSProgressIndicator | |
100 { | |
101 void *userdata; | |
102 } | |
103 -(void *)userdata; | |
104 -(void)setUserdata:(void *)input; | |
105 @end | |
106 | |
107 @implementation DWPercent | |
108 -(void *)userdata { return userdata; } | |
109 -(void)setUserdata:(void *)input { userdata = input; } | |
110 @end | |
111 | |
112 NSApplication *DWApp; | |
113 NSRunLoop *DWRunLoop; | |
114 | |
115 typedef struct _sighandler | |
116 { | |
117 struct _sighandler *next; | |
118 ULONG message; | |
119 HWND window; | |
120 int id; | |
121 void *signalfunction; | |
122 void *data; | |
123 | |
124 } SignalHandler; | |
125 | |
126 SignalHandler *Root = NULL; | |
127 | |
128 typedef struct | |
129 { | |
130 ULONG message; | |
131 char name[30]; | |
132 | |
133 } SignalList; | |
134 | |
135 /* List of signals */ | |
136 #define SIGNALMAX 16 | |
137 | |
138 SignalList SignalTranslate[SIGNALMAX] = { | |
139 { 1, DW_SIGNAL_CONFIGURE }, | |
140 { 2, DW_SIGNAL_KEY_PRESS }, | |
141 { 3, DW_SIGNAL_BUTTON_PRESS }, | |
142 { 4, DW_SIGNAL_BUTTON_RELEASE }, | |
143 { 5, DW_SIGNAL_MOTION_NOTIFY }, | |
144 { 6, DW_SIGNAL_DELETE }, | |
145 { 7, DW_SIGNAL_EXPOSE }, | |
146 { 8, DW_SIGNAL_CLICKED }, | |
147 { 9, DW_SIGNAL_ITEM_ENTER }, | |
148 { 10, DW_SIGNAL_ITEM_CONTEXT }, | |
149 { 11, DW_SIGNAL_LIST_SELECT }, | |
150 { 12, DW_SIGNAL_ITEM_SELECT }, | |
151 { 13, DW_SIGNAL_SET_FOCUS }, | |
152 { 14, DW_SIGNAL_VALUE_CHANGED }, | |
153 { 15, DW_SIGNAL_SWITCH_PAGE }, | |
154 { 16, DW_SIGNAL_TREE_EXPAND } | |
155 }; | |
156 | |
157 /* This function adds a signal handler callback into the linked list. | |
158 */ | |
159 void _new_signal(ULONG message, HWND window, int id, void *signalfunction, void *data) | |
160 { | |
161 SignalHandler *new = malloc(sizeof(SignalHandler)); | |
162 | |
163 new->message = message; | |
164 new->window = window; | |
165 new->id = id; | |
166 new->signalfunction = signalfunction; | |
167 new->data = data; | |
168 new->next = NULL; | |
169 | |
170 if (!Root) | |
171 Root = new; | |
172 else | |
173 { | |
174 SignalHandler *prev = NULL, *tmp = Root; | |
175 while(tmp) | |
176 { | |
177 if(tmp->message == message && | |
178 tmp->window == window && | |
179 tmp->id == id && | |
180 tmp->signalfunction == signalfunction) | |
181 { | |
182 tmp->data = data; | |
183 free(new); | |
184 return; | |
185 } | |
186 prev = tmp; | |
187 tmp = tmp->next; | |
188 } | |
189 if(prev) | |
190 prev->next = new; | |
191 else | |
192 Root = new; | |
193 } | |
194 } | |
195 | |
196 /* Finds the message number for a given signal name */ | |
197 ULONG _findsigmessage(char *signame) | |
198 { | |
199 int z; | |
200 | |
201 for(z=0;z<SIGNALMAX;z++) | |
202 { | |
203 if(strcasecmp(signame, SignalTranslate[z].name) == 0) | |
204 return SignalTranslate[z].message; | |
205 } | |
206 return 0L; | |
207 } | |
208 | |
209 unsigned long _foreground = 0xAAAAAA, _background = 0; | |
210 | |
211 /* This function will recursively search a box and add up the total height of it */ | |
212 static void _count_size(HWND thisbox, int type, int *xsize, int *xorigsize) | |
213 { | |
214 int size = 0, origsize = 0, z; | |
215 DWBox *box = thisbox; | |
216 Box _tmp = [box box]; | |
217 Box *tmp = &_tmp; | |
218 | |
219 if(!tmp) | |
220 { | |
221 *xsize = *xorigsize = 0; | |
222 return; | |
223 } | |
224 | |
225 if(type == tmp->type) | |
226 { | |
227 /* If the box is going in the direction we want, then we | |
228 * return the entire sum of the items. | |
229 */ | |
230 for(z=0;z<tmp->count;z++) | |
231 { | |
232 if(tmp->items[z].type == TYPEBOX) | |
233 { | |
234 int s, os; | |
235 | |
236 _count_size(tmp->items[z].hwnd, type, &s, &os); | |
237 size += s; | |
238 origsize += os; | |
239 } | |
240 else | |
241 { | |
242 size += (type == DW_HORZ ? tmp->items[z].width : tmp->items[z].height); | |
243 origsize += (type == DW_HORZ ? tmp->items[z].origwidth : tmp->items[z].origheight); | |
244 } | |
245 } | |
246 } | |
247 else | |
248 { | |
249 /* If the box is not going in the direction we want, then we only | |
250 * want to return the maximum value. | |
251 */ | |
252 int tmpsize = 0, tmporigsize = 0; | |
253 | |
254 for(z=0;z<tmp->count;z++) | |
255 { | |
256 if(tmp->items[z].type == TYPEBOX) | |
257 _count_size(tmp->items[z].hwnd, type, &tmpsize, &tmporigsize); | |
258 else | |
259 { | |
260 tmpsize = (type == DW_HORZ ? tmp->items[z].width : tmp->items[z].height); | |
261 tmporigsize = (type == DW_HORZ ? tmp->items[z].origwidth : tmp->items[z].origheight); | |
262 } | |
263 | |
264 if(tmpsize > size) | |
265 size = tmpsize; | |
266 } | |
267 } | |
268 | |
269 *xsize = size; | |
270 *xorigsize = origsize; | |
271 } | |
272 | |
273 /* This function calculates how much space the widgets and boxes require | |
274 * and does expansion as necessary. | |
275 */ | |
276 static int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy, | |
277 int pass, int *usedpadx, int *usedpady) | |
278 { | |
279 int z, currentx = 0, currenty = 0; | |
280 int uymax = 0, uxmax = 0; | |
281 int upymax = 0, upxmax = 0; | |
282 /* Used for the SIZEEXPAND */ | |
283 int nux = *usedx, nuy = *usedy; | |
284 int nupx = *usedpadx, nupy = *usedpady; | |
285 | |
286 (*usedx) += (thisbox->pad * 2); | |
287 (*usedy) += (thisbox->pad * 2); | |
288 | |
289 for(z=0;z<thisbox->count;z++) | |
290 { | |
291 if(thisbox->items[z].type == TYPEBOX) | |
292 { | |
293 int initialx, initialy; | |
294 DWBox *box = thisbox->items[z].hwnd; | |
295 Box _tmp = [box box]; | |
296 Box *tmp = &_tmp; | |
297 | |
298 initialx = x - (*usedx); | |
299 initialy = y - (*usedy); | |
300 | |
301 if(tmp) | |
302 { | |
303 int newx, newy; | |
304 int nux = *usedx, nuy = *usedy; | |
305 int upx = *usedpadx + (tmp->pad*2), upy = *usedpady + (tmp->pad*2); | |
306 | |
307 /* On the second pass we know how big the box needs to be and how | |
308 * much space we have, so we can calculate a ratio for the new box. | |
309 */ | |
310 if(pass == 2) | |
311 { | |
312 int deep = *depth + 1; | |
313 | |
314 _resize_box(tmp, &deep, x, y, &nux, &nuy, 1, &upx, &upy); | |
315 | |
316 tmp->upx = upx - *usedpadx; | |
317 tmp->upy = upy - *usedpady; | |
318 | |
319 newx = x - nux; | |
320 newy = y - nuy; | |
321 | |
322 tmp->width = thisbox->items[z].width = initialx - newx; | |
323 tmp->height = thisbox->items[z].height = initialy - newy; | |
324 | |
325 tmp->parentxratio = thisbox->xratio; | |
326 tmp->parentyratio = thisbox->yratio; | |
327 | |
328 tmp->parentpad = tmp->pad; | |
329 | |
330 /* Just in case */ | |
331 tmp->xratio = thisbox->xratio; | |
332 tmp->yratio = thisbox->yratio; | |
333 | |
334 if(thisbox->type == DW_VERT) | |
335 { | |
336 if((thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) | |
337 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)))); | |
338 } | |
339 else | |
340 { | |
341 if((thisbox->items[z].width-tmp->upx)!=0) | |
342 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx)); | |
343 } | |
344 if(thisbox->type == DW_HORZ) | |
345 { | |
346 if((thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) | |
347 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)))); | |
348 } | |
349 else | |
350 { | |
351 if((thisbox->items[z].height-tmp->upy)!=0) | |
352 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy)); | |
353 } | |
354 | |
355 nux = *usedx; nuy = *usedy; | |
356 upx = *usedpadx + (tmp->pad*2); upy = *usedpady + (tmp->pad*2); | |
357 } | |
358 [box setBox:_tmp]; | |
359 | |
360 (*depth)++; | |
361 | |
362 _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &upx, &upy); | |
363 | |
364 (*depth)--; | |
365 | |
366 newx = x - nux; | |
367 newy = y - nuy; | |
368 | |
369 tmp->minwidth = thisbox->items[z].width = initialx - newx; | |
370 tmp->minheight = thisbox->items[z].height = initialy - newy; | |
371 [box setBox:_tmp]; | |
372 } | |
373 } | |
374 | |
375 if(pass > 1 && *depth > 0) | |
376 { | |
377 if(thisbox->type == DW_VERT) | |
378 { | |
379 if((thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0) | |
380 thisbox->items[z].xratio = 1.0; | |
381 else | |
382 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)))); | |
383 } | |
384 else | |
385 { | |
386 if(thisbox->minwidth-thisbox->upx == 0) | |
387 thisbox->items[z].xratio = 1.0; | |
388 else | |
389 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx)); | |
390 } | |
391 | |
392 if(thisbox->type == DW_HORZ) | |
393 { | |
394 if((thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0) | |
395 thisbox->items[z].yratio = 1.0; | |
396 else | |
397 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)))); | |
398 } | |
399 else | |
400 { | |
401 if(thisbox->minheight-thisbox->upy == 0) | |
402 thisbox->items[z].yratio = 1.0; | |
403 else | |
404 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy)); | |
405 } | |
406 | |
407 if(thisbox->items[z].type == TYPEBOX) | |
408 { | |
409 DWBox *box = thisbox->items[z].hwnd; | |
410 Box _tmp = [box box]; | |
411 Box *tmp = &_tmp; | |
412 | |
413 if(tmp) | |
414 { | |
415 tmp->parentxratio = thisbox->items[z].xratio; | |
416 tmp->parentyratio = thisbox->items[z].yratio; | |
417 } | |
418 [box setBox:_tmp]; | |
419 } | |
420 } | |
421 else | |
422 { | |
423 thisbox->items[z].xratio = thisbox->xratio; | |
424 thisbox->items[z].yratio = thisbox->yratio; | |
425 } | |
426 | |
427 if(thisbox->type == DW_VERT) | |
428 { | |
429 if((thisbox->items[z].width + (thisbox->items[z].pad*2)) > uxmax) | |
430 uxmax = (thisbox->items[z].width + (thisbox->items[z].pad*2)); | |
431 if(thisbox->items[z].hsize != SIZEEXPAND) | |
432 { | |
433 if(((thisbox->items[z].pad*2) + thisbox->items[z].width) > upxmax) | |
434 upxmax = (thisbox->items[z].pad*2) + thisbox->items[z].width; | |
435 } | |
436 else | |
437 { | |
438 if(thisbox->items[z].pad*2 > upxmax) | |
439 upxmax = thisbox->items[z].pad*2; | |
440 } | |
441 } | |
442 else | |
443 { | |
444 if(thisbox->items[z].width == -1) | |
445 { | |
446 /* figure out how much space this item requires */ | |
447 /* thisbox->items[z].width = */ | |
448 } | |
449 else | |
450 { | |
451 (*usedx) += thisbox->items[z].width + (thisbox->items[z].pad*2); | |
452 if(thisbox->items[z].hsize != SIZEEXPAND) | |
453 (*usedpadx) += (thisbox->items[z].pad*2) + thisbox->items[z].width; | |
454 else | |
455 (*usedpadx) += thisbox->items[z].pad*2; | |
456 } | |
457 } | |
458 if(thisbox->type == DW_HORZ) | |
459 { | |
460 if((thisbox->items[z].height + (thisbox->items[z].pad*2)) > uymax) | |
461 uymax = (thisbox->items[z].height + (thisbox->items[z].pad*2)); | |
462 if(thisbox->items[z].vsize != SIZEEXPAND) | |
463 { | |
464 if(((thisbox->items[z].pad*2) + thisbox->items[z].height) > upymax) | |
465 upymax = (thisbox->items[z].pad*2) + thisbox->items[z].height; | |
466 } | |
467 else | |
468 { | |
469 if(thisbox->items[z].pad*2 > upymax) | |
470 upymax = thisbox->items[z].pad*2; | |
471 } | |
472 } | |
473 else | |
474 { | |
475 if(thisbox->items[z].height == -1) | |
476 { | |
477 /* figure out how much space this item requires */ | |
478 /* thisbox->items[z].height = */ | |
479 } | |
480 else | |
481 { | |
482 (*usedy) += thisbox->items[z].height + (thisbox->items[z].pad*2); | |
483 if(thisbox->items[z].vsize != SIZEEXPAND) | |
484 (*usedpady) += (thisbox->items[z].pad*2) + thisbox->items[z].height; | |
485 else | |
486 (*usedpady) += thisbox->items[z].pad*2; | |
487 } | |
488 } | |
489 } | |
490 | |
491 (*usedx) += uxmax; | |
492 (*usedy) += uymax; | |
493 (*usedpadx) += upxmax; | |
494 (*usedpady) += upymax; | |
495 | |
496 currentx += thisbox->pad; | |
497 currenty += thisbox->pad; | |
498 | |
499 /* The second pass is for expansion and actual placement. */ | |
500 if(pass > 1) | |
501 { | |
502 /* Any SIZEEXPAND items should be set to uxmax/uymax */ | |
503 for(z=0;z<thisbox->count;z++) | |
504 { | |
505 if(thisbox->items[z].hsize == SIZEEXPAND && thisbox->type == DW_VERT) | |
506 thisbox->items[z].width = uxmax-(thisbox->items[z].pad*2); | |
507 if(thisbox->items[z].vsize == SIZEEXPAND && thisbox->type == DW_HORZ) | |
508 thisbox->items[z].height = uymax-(thisbox->items[z].pad*2); | |
509 /* Run this code segment again to finalize the sized after setting uxmax/uymax values. */ | |
510 if(thisbox->items[z].type == TYPEBOX) | |
511 { | |
512 DWBox *box = thisbox->items[z].hwnd; | |
513 Box _tmp = [box box]; | |
514 Box *tmp = &_tmp; | |
515 | |
516 if(tmp) | |
517 { | |
518 if(*depth > 0) | |
519 { | |
520 float calcval; | |
521 | |
522 if(thisbox->type == DW_VERT) | |
523 { | |
524 calcval = (float)(tmp->minwidth-((thisbox->items[z].pad*2)+(thisbox->pad*2))); | |
525 if(calcval == 0.0) | |
526 tmp->xratio = thisbox->xratio; | |
527 else | |
528 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/calcval; | |
529 tmp->width = thisbox->items[z].width; | |
530 } | |
531 if(thisbox->type == DW_HORZ) | |
532 { | |
533 calcval = (float)(tmp->minheight-((thisbox->items[z].pad*2)+(thisbox->pad*2))); | |
534 if(calcval == 0.0) | |
535 tmp->yratio = thisbox->yratio; | |
536 else | |
537 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/calcval; | |
538 tmp->height = thisbox->items[z].height; | |
539 } | |
540 } | |
541 [box setBox:_tmp]; | |
542 | |
543 (*depth)++; | |
544 | |
545 _resize_box(tmp, depth, x, y, &nux, &nuy, 3, &nupx, &nupy); | |
546 | |
547 (*depth)--; | |
548 | |
549 } | |
550 } | |
551 } | |
552 | |
553 for(z=0;z<(thisbox->count);z++) | |
554 { | |
555 int height = thisbox->items[z].height; | |
556 int width = thisbox->items[z].width; | |
557 int pad = thisbox->items[z].pad; | |
558 NSView *handle = thisbox->items[z].hwnd; | |
559 NSPoint point; | |
560 NSSize size; | |
561 int vectorx, vectory; | |
562 | |
563 /* When upxmax != pad*2 then ratios are incorrect. */ | |
564 vectorx = (int)((width*thisbox->items[z].xratio)-width); | |
565 vectory = (int)((height*thisbox->items[z].yratio)-height); | |
566 | |
567 if(width > 0 && height > 0) | |
568 { | |
569 /* This is a hack to fix rounding of the sizing */ | |
570 if(*depth == 0) | |
571 { | |
572 vectorx++; | |
573 vectory++; | |
574 } | |
575 | |
576 /* If this item isn't going to expand... reset the vectors to 0 */ | |
577 if(thisbox->items[z].vsize != SIZEEXPAND) | |
578 vectory = 0; | |
579 if(thisbox->items[z].hsize != SIZEEXPAND) | |
580 vectorx = 0; | |
581 | |
582 point.x = currentx + pad; | |
583 point.y = currenty + pad; | |
584 size.width = width + vectorx; | |
585 size.height = height + vectory; | |
586 [handle setFrameOrigin:point]; | |
587 [handle setFrameSize:size]; | |
588 | |
589 if(thisbox->type == DW_HORZ) | |
590 currentx += width + vectorx + (pad * 2); | |
591 if(thisbox->type == DW_VERT) | |
592 currenty += height + vectory + (pad * 2); | |
593 } | |
594 } | |
595 } | |
596 return 0; | |
597 } | |
598 | |
599 static void _do_resize(Box *thisbox, int x, int y) | |
600 { | |
601 if(x != 0 && y != 0) | |
602 { | |
603 if(thisbox) | |
604 { | |
605 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0; | |
606 | |
607 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady); | |
608 | |
609 if(usedx-usedpadx == 0 || usedy-usedpady == 0) | |
610 return; | |
611 | |
612 thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx)); | |
613 thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady)); | |
614 | |
615 usedx = usedy = usedpadx = usedpady = depth = 0; | |
616 | |
617 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady); | |
618 } | |
619 } | |
620 } | |
621 | |
622 static void _changebox(Box *thisbox, int percent, int type) | |
623 { | |
624 int z; | |
625 | |
626 for(z=0;z<thisbox->count;z++) | |
627 { | |
628 if(thisbox->items[z].type == TYPEBOX) | |
629 { | |
630 DWBox *box = thisbox->items[z].hwnd; | |
631 Box _tmp = [box box]; | |
632 Box *tmp = &_tmp; | |
633 _changebox(tmp, percent, type); | |
634 [box setBox:_tmp]; | |
635 } | |
636 else | |
637 { | |
638 if(type == DW_HORZ) | |
639 { | |
640 if(thisbox->items[z].hsize == SIZEEXPAND) | |
641 thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0))); | |
642 } | |
643 else | |
644 { | |
645 if(thisbox->items[z].vsize == SIZEEXPAND) | |
646 thisbox->items[z].height = (int)(((float)thisbox->items[z].origheight) * (((float)percent)/((float)100.0))); | |
647 } | |
648 } | |
649 } | |
650 } | |
651 | |
652 /* | |
653 * Initializes the Dynamic Windows engine. | |
654 * Parameters: | |
655 * newthread: True if this is the only thread. | |
656 * False if there is already a message loop running. | |
657 */ | |
658 int API dw_init(int newthread, int argc, char *argv[]) | |
659 { | |
660 /* Create the application object */ | |
661 DWApp = [NSApplication sharedApplication]; | |
662 /* Create a run loop for doing manual loops */ | |
663 DWRunLoop = [NSRunLoop alloc]; | |
664 | |
665 /* This only works on 10.6 so we have a backup method */ | |
666 NSString * applicationName = [[NSRunningApplication currentApplication] localizedName]; | |
667 if(applicationName == nil) | |
668 { | |
669 applicationName = [[NSProcessInfo processInfo] processName]; | |
670 } | |
671 | |
672 /* Create the main menu */ | |
673 NSMenu * mainMenu = [[[NSMenu alloc] initWithTitle:@"MainMenu"] autorelease]; | |
674 | |
675 NSMenuItem * mitem = [mainMenu addItemWithTitle:@"Apple" action:NULL keyEquivalent:@""]; | |
676 NSMenu * menu = [[[NSMenu alloc] initWithTitle:@"Apple"] autorelease]; | |
677 | |
678 [DWApp setMainMenu:mainMenu]; | |
679 | |
680 [DWApp performSelector:@selector(setAppleMenu:) withObject:menu]; | |
681 | |
682 /* Setup the Application menu */ | |
683 NSMenuItem * item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"About", nil), applicationName] | |
684 action:@selector(orderFrontStandardAboutPanel:) | |
685 keyEquivalent:@""]; | |
686 [item setTarget:DWApp]; | |
687 | |
688 [menu addItem:[NSMenuItem separatorItem]]; | |
689 | |
690 item = [menu addItemWithTitle:NSLocalizedString(@"Preferences...", nil) | |
691 action:NULL | |
692 keyEquivalent:@","]; | |
693 | |
694 [menu addItem:[NSMenuItem separatorItem]]; | |
695 | |
696 item = [menu addItemWithTitle:NSLocalizedString(@"Services", nil) | |
697 action:NULL | |
698 keyEquivalent:@""]; | |
699 NSMenu * servicesMenu = [[[NSMenu alloc] initWithTitle:@"Services"] autorelease]; | |
700 [menu setSubmenu:servicesMenu forItem:item]; | |
701 [DWApp setServicesMenu:servicesMenu]; | |
702 | |
703 [menu addItem:[NSMenuItem separatorItem]]; | |
704 | |
705 item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Hide", nil), applicationName] | |
706 action:@selector(hide:) | |
707 keyEquivalent:@"h"]; | |
708 [item setTarget:DWApp]; | |
709 | |
710 item = [menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil) | |
711 action:@selector(hideOtherApplications:) | |
712 keyEquivalent:@"h"]; | |
713 [item setKeyEquivalentModifierMask:NSCommandKeyMask | NSAlternateKeyMask]; | |
714 [item setTarget:DWApp]; | |
715 | |
716 item = [menu addItemWithTitle:NSLocalizedString(@"Show All", nil) | |
717 action:@selector(unhideAllApplications:) | |
718 keyEquivalent:@""]; | |
719 [item setTarget:DWApp]; | |
720 | |
721 [menu addItem:[NSMenuItem separatorItem]]; | |
722 | |
723 item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Quit", nil), applicationName] | |
724 action:@selector(terminate:) | |
725 keyEquivalent:@"q"]; | |
726 [item setTarget:DWApp]; | |
727 | |
728 [mainMenu setSubmenu:menu forItem:mitem]; | |
729 return 0; | |
730 } | |
731 | |
732 /* | |
733 * Runs a message loop for Dynamic Windows. | |
734 */ | |
735 void API dw_main(void) | |
736 { | |
737 [DWApp run]; | |
738 } | |
739 | |
740 /* | |
741 * Runs a message loop for Dynamic Windows, for a period of milliseconds. | |
742 * Parameters: | |
743 * milliseconds: Number of milliseconds to run the loop for. | |
744 */ | |
745 void API dw_main_sleep(int milliseconds) | |
746 { | |
747 double seconds = (double)milliseconds/1000.0; | |
748 NSDate *time = [[NSDate alloc] initWithTimeIntervalSinceNow:seconds]; | |
749 [DWRunLoop runUntilDate:time]; | |
750 } | |
751 | |
752 /* | |
753 * Processes a single message iteration and returns. | |
754 */ | |
755 void API dw_main_iteration(void) | |
756 { | |
757 [DWRunLoop limitDateForMode:NSDefaultRunLoopMode]; | |
758 } | |
759 | |
760 /* | |
761 * Cleanly terminates a DW session, should be signal handler safe. | |
762 * Parameters: | |
763 * exitcode: Exit code reported to the operating system. | |
764 */ | |
765 void API dw_exit(int exitcode) | |
766 { | |
767 exit(exitcode); | |
768 } | |
769 | |
770 /* | |
771 * Free's memory allocated by dynamic windows. | |
772 * Parameters: | |
773 * ptr: Pointer to dynamic windows allocated | |
774 * memory to be free()'d. | |
775 */ | |
776 void API dw_free(void *ptr) | |
777 { | |
778 free(ptr); | |
779 } | |
780 | |
781 /* | |
782 * Returns a pointer to a static buffer which containes the | |
783 * current user directory. Or the root directory (C:\ on | |
784 * OS/2 and Windows). | |
785 */ | |
786 char *dw_user_dir(void) | |
787 { | |
788 static char _user_dir[1024] = ""; | |
789 | |
790 if(!_user_dir[0]) | |
791 { | |
792 char *home = getenv("HOME"); | |
793 | |
794 if(home) | |
795 strcpy(_user_dir, home); | |
796 else | |
797 strcpy(_user_dir, "/"); | |
798 } | |
799 return _user_dir; | |
800 } | |
801 | |
802 /* | |
803 * Displays a Message Box with given text and title.. | |
804 * Parameters: | |
805 * title: The title of the message box. | |
806 * flags: flags to indicate buttons and icon | |
807 * format: printf style format string. | |
808 * ...: Additional variables for use in the format. | |
809 */ | |
810 int API dw_messagebox(char *title, int flags, char *format, ...) | |
811 { | |
812 int iResponse; | |
813 NSString *button1 = @"OK"; | |
814 NSString *button2 = nil; | |
815 NSString *button3 = nil; | |
816 va_list args; | |
817 char outbuf[1000]; | |
818 | |
819 va_start(args, format); | |
820 vsprintf(outbuf, format, args); | |
821 va_end(args); | |
822 | |
823 if(flags & DW_MB_OKCANCEL) | |
824 { | |
825 button2 = @"Cancel"; | |
826 } | |
827 else if(flags & DW_MB_YESNO) | |
828 { | |
829 button1 = @"Yes"; | |
830 button2 = @"No"; | |
831 } | |
832 else if(flags & DW_MB_YESNOCANCEL) | |
833 { | |
834 button1 = @"Yes"; | |
835 button2 = @"No"; | |
836 button3 = @"Cancel"; | |
837 } | |
838 | |
839 if(flags & DW_MB_ERROR) | |
840 { | |
841 iResponse = | |
842 NSRunCriticalAlertPanel([ NSString stringWithUTF8String:title ], | |
843 [ NSString stringWithUTF8String:outbuf ], | |
844 button1, button2, button3); } | |
845 else | |
846 { | |
847 iResponse = | |
848 NSRunAlertPanel([ NSString stringWithUTF8String:title ], | |
849 [ NSString stringWithUTF8String:outbuf ], | |
850 button1, button2, button3); | |
851 } | |
852 | |
853 switch(iResponse) | |
854 { | |
855 case NSAlertDefaultReturn: /* user pressed OK */ | |
856 if(flags & DW_MB_YESNO || flags & DW_MB_YESNOCANCEL) | |
857 { | |
858 return DW_MB_RETURN_YES; | |
859 } | |
860 return DW_MB_RETURN_OK; | |
861 case NSAlertAlternateReturn: /* user pressed Cancel */ | |
862 if(flags & DW_MB_OKCANCEL) | |
863 { | |
864 return DW_MB_RETURN_CANCEL; | |
865 } | |
866 return DW_MB_RETURN_NO; | |
867 case NSAlertOtherReturn: /* user pressed the third button */ | |
868 return DW_MB_RETURN_CANCEL; | |
869 case NSAlertErrorReturn: /* an error occurred */ | |
870 break; | |
871 } | |
872 return 0; | |
873 } | |
874 | |
875 /* | |
876 * Opens a file dialog and queries user selection. | |
877 * Parameters: | |
878 * title: Title bar text for dialog. | |
879 * defpath: The default path of the open dialog. | |
880 * ext: Default file extention. | |
881 * flags: DW_FILE_OPEN or DW_FILE_SAVE. | |
882 * Returns: | |
883 * NULL on error. A malloced buffer containing | |
884 * the file path on success. | |
885 * | |
886 */ | |
887 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags) | |
888 { | |
889 NSLog(@"dw_file_browse() unimplemented\n"); | |
890 return NULL; | |
891 } | |
892 | |
893 /* | |
894 * Gets the contents of the default clipboard as text. | |
895 * Parameters: | |
896 * None. | |
897 * Returns: | |
898 * Pointer to an allocated string of text or NULL if clipboard empty or contents could not | |
899 * be converted to text. | |
900 */ | |
901 char *dw_clipboard_get_text() | |
902 { | |
903 NSLog(@"dw_clipboard_get_text() unimplemented\n"); | |
904 return NULL; | |
905 } | |
906 | |
907 /* | |
908 * Sets the contents of the default clipboard to the supplied text. | |
909 * Parameters: | |
910 * Text. | |
911 */ | |
912 void dw_clipboard_set_text( char *str, int len ) | |
913 { | |
914 NSLog(@"dw_clipboard_set_text() unimplemented\n"); | |
915 return; | |
916 } | |
917 | |
918 | |
919 /* | |
920 * Allocates and initializes a dialog struct. | |
921 * Parameters: | |
922 * data: User defined data to be passed to functions. | |
923 */ | |
924 DWDialog * API dw_dialog_new(void *data) | |
925 { | |
926 NSLog(@"dw_dialog_new() unimplemented\n"); | |
927 return NULL; | |
928 } | |
929 | |
930 /* | |
931 * Accepts a dialog struct and returns the given data to the | |
932 * initial called of dw_dialog_wait(). | |
933 * Parameters: | |
934 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | |
935 * result: Data to be returned by dw_dialog_wait(). | |
936 */ | |
937 int API dw_dialog_dismiss(DWDialog *dialog, void *result) | |
938 { | |
939 NSLog(@"dw_dialog_dismiss() unimplemented\n"); | |
940 return 0; | |
941 } | |
942 | |
943 /* | |
944 * Accepts a dialog struct waits for dw_dialog_dismiss() to be | |
945 * called by a signal handler with the given dialog struct. | |
946 * Parameters: | |
947 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | |
948 */ | |
949 void * API dw_dialog_wait(DWDialog *dialog) | |
950 { | |
951 NSLog(@"dw_dialog_wait() unimplemented\n"); | |
952 return NULL; | |
953 } | |
954 | |
955 /* | |
956 * Create a new Box to be packed. | |
957 * Parameters: | |
958 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). | |
959 * pad: Number of pixels to pad around the box. | |
960 */ | |
961 HWND API dw_box_new(int type, int pad) | |
962 { | |
963 DWBox *view = [[DWBox alloc] init]; | |
964 Box newbox; | |
965 memset(&newbox, 0, sizeof(Box)); | |
966 newbox.pad = pad; | |
967 newbox.type = type; | |
968 [view setBox:newbox]; | |
969 return view; | |
970 } | |
971 | |
972 /* | |
973 * Create a new Group Box to be packed. | |
974 * Parameters: | |
975 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). | |
976 * pad: Number of pixels to pad around the box. | |
977 * title: Text to be displayined in the group outline. | |
978 */ | |
979 HWND API dw_groupbox_new(int type, int pad, char *title) | |
980 { | |
981 DWBox *box = dw_box_new(type, pad); | |
982 [box setFocusRingType:NSFocusRingTypeExterior]; | |
983 return box; | |
984 } | |
985 | |
986 /* | |
987 * Pack windows (widgets) into a box from the end (or bottom). | |
988 * Parameters: | |
989 * box: Window handle of the box to be packed into. | |
990 * item: Window handle of the item to be back. | |
991 * width: Width in pixels of the item or -1 to be self determined. | |
992 * height: Height in pixels of the item or -1 to be self determined. | |
993 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
994 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
995 * pad: Number of pixels of padding around the item. | |
996 */ | |
997 void API dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
998 { | |
999 NSObject *object = box; | |
1000 DWBox *view = box; | |
1001 DWBox *this = item; | |
1002 Box thisbox; | |
1003 int z; | |
1004 Item *tmpitem, *thisitem; | |
1005 | |
1006 /* Query the objects */ | |
1007 if([ object isKindOfClass:[ NSWindow class ] ]) | |
1008 { | |
1009 NSWindow *window = box; | |
1010 view = [window contentView]; | |
1011 } | |
1012 | |
1013 thisbox = [view box]; | |
1014 thisitem = thisbox.items; | |
1015 object = item; | |
1016 | |
1017 /* Duplicate the existing data */ | |
1018 tmpitem = malloc(sizeof(Item)*(thisbox.count+1)); | |
1019 | |
1020 for(z=0;z<thisbox.count;z++) | |
1021 { | |
1022 tmpitem[z+1] = thisitem[z]; | |
1023 } | |
1024 | |
1025 /* Sanity checks */ | |
1026 if(vsize && !height) | |
1027 height = 1; | |
1028 if(hsize && !width) | |
1029 width = 1; | |
1030 | |
1031 /* Fill in the item data appropriately */ | |
1032 if([ object isKindOfClass:[ DWBox class ] ]) | |
1033 tmpitem[0].type = TYPEBOX; | |
1034 else | |
1035 tmpitem[0].type = TYPEITEM; | |
1036 | |
1037 tmpitem[0].hwnd = item; | |
1038 tmpitem[0].origwidth = tmpitem[0].width = width; | |
1039 tmpitem[0].origheight = tmpitem[0].height = height; | |
1040 tmpitem[0].pad = pad; | |
1041 if(hsize) | |
1042 tmpitem[0].hsize = SIZEEXPAND; | |
1043 else | |
1044 tmpitem[0].hsize = SIZESTATIC; | |
1045 | |
1046 if(vsize) | |
1047 tmpitem[0].vsize = SIZEEXPAND; | |
1048 else | |
1049 tmpitem[0].vsize = SIZESTATIC; | |
1050 | |
1051 thisbox.items = tmpitem; | |
1052 | |
1053 /* Update the item count */ | |
1054 thisbox.count++; | |
1055 | |
1056 /* Add the item to the box */ | |
1057 [view setBox:thisbox]; | |
1058 [view addSubview:this]; | |
1059 | |
1060 /* Free the old data */ | |
1061 if(thisbox.count) | |
1062 free(thisitem); | |
1063 } | |
1064 | |
1065 /* | |
1066 * Pack windows (widgets) into a box from the start (or top). | |
1067 * Parameters: | |
1068 * box: Window handle of the box to be packed into. | |
1069 * item: Window handle of the item to be back. | |
1070 * width: Width in pixels of the item or -1 to be self determined. | |
1071 * height: Height in pixels of the item or -1 to be self determined. | |
1072 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
1073 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
1074 * pad: Number of pixels of padding around the item. | |
1075 */ | |
1076 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
1077 { | |
1078 NSObject *object = box; | |
1079 DWBox *view = box; | |
1080 DWBox *this = item; | |
1081 Box thisbox; | |
1082 int z; | |
1083 Item *tmpitem, *thisitem; | |
1084 | |
1085 /* Query the objects */ | |
1086 if([ object isKindOfClass:[ NSWindow class ] ]) | |
1087 { | |
1088 NSWindow *window = box; | |
1089 view = [window contentView]; | |
1090 } | |
1091 | |
1092 thisbox = [view box]; | |
1093 thisitem = thisbox.items; | |
1094 object = item; | |
1095 | |
1096 /* Duplicate the existing data */ | |
1097 tmpitem = malloc(sizeof(Item)*(thisbox.count+1)); | |
1098 | |
1099 for(z=0;z<thisbox.count;z++) | |
1100 { | |
1101 tmpitem[z] = thisitem[z]; | |
1102 } | |
1103 | |
1104 /* Sanity checks */ | |
1105 if(vsize && !height) | |
1106 height = 1; | |
1107 if(hsize && !width) | |
1108 width = 1; | |
1109 | |
1110 /* Fill in the item data appropriately */ | |
1111 if([ object isKindOfClass:[ DWBox class ] ]) | |
1112 tmpitem[thisbox.count].type = TYPEBOX; | |
1113 else | |
1114 tmpitem[thisbox.count].type = TYPEITEM; | |
1115 | |
1116 tmpitem[thisbox.count].hwnd = item; | |
1117 tmpitem[thisbox.count].origwidth = tmpitem[thisbox.count].width = width; | |
1118 tmpitem[thisbox.count].origheight = tmpitem[thisbox.count].height = height; | |
1119 tmpitem[thisbox.count].pad = pad; | |
1120 if(hsize) | |
1121 tmpitem[thisbox.count].hsize = SIZEEXPAND; | |
1122 else | |
1123 tmpitem[thisbox.count].hsize = SIZESTATIC; | |
1124 | |
1125 if(vsize) | |
1126 tmpitem[thisbox.count].vsize = SIZEEXPAND; | |
1127 else | |
1128 tmpitem[thisbox.count].vsize = SIZESTATIC; | |
1129 | |
1130 thisbox.items = tmpitem; | |
1131 | |
1132 /* Update the item count */ | |
1133 thisbox.count++; | |
1134 | |
1135 /* Add the item to the box */ | |
1136 [view setBox:thisbox]; | |
1137 [view addSubview:this]; | |
1138 | |
1139 /* Free the old data */ | |
1140 if(thisbox.count) | |
1141 free(thisitem); | |
1142 } | |
1143 | |
1144 /* | |
1145 * Create a new button window (widget) to be packed. | |
1146 * Parameters: | |
1147 * text: The text to be display by the static text widget. | |
1148 * id: An ID to be used with dw_window_from_id() or 0L. | |
1149 */ | |
1150 HWND API dw_button_new(char *text, ULONG id) | |
1151 { | |
1152 DWButton *button = [[DWButton alloc] init]; | |
1153 [button setTitle:[ NSString stringWithUTF8String:text ]]; | |
1154 [button setButtonType:NSMomentaryPushInButton]; | |
1155 [button setBezelStyle:NSThickerSquareBezelStyle]; | |
1156 /*[button setGradientType:NSGradientConvexWeak];*/ | |
1157 [button setTag:id]; | |
1158 return button; | |
1159 } | |
1160 | |
1161 /* | |
1162 * Create a new Entryfield window (widget) to be packed. | |
1163 * Parameters: | |
1164 * text: The default text to be in the entryfield widget. | |
1165 * id: An ID to be used with dw_window_from_id() or 0L. | |
1166 */ | |
1167 HWND API dw_entryfield_new(char *text, ULONG id) | |
1168 { | |
1169 NSTextField *entry = [[NSTextField alloc] init]; | |
1170 [entry setStringValue:[ NSString stringWithUTF8String:text ]]; | |
1171 [entry setTag:id]; | |
1172 return entry; | |
1173 } | |
1174 | |
1175 /* | |
1176 * Create a new Entryfield (password) window (widget) to be packed. | |
1177 * Parameters: | |
1178 * text: The default text to be in the entryfield widget. | |
1179 * id: An ID to be used with dw_window_from_id() or 0L. | |
1180 */ | |
1181 HWND API dw_entryfield_password_new(char *text, ULONG id) | |
1182 { | |
1183 NSSecureTextField *entry = [[NSSecureTextField alloc] init]; | |
1184 [entry setStringValue:[ NSString stringWithUTF8String:text ]]; | |
1185 [entry setTag:id]; | |
1186 return entry; | |
1187 } | |
1188 | |
1189 /* | |
1190 * Sets the entryfield character limit. | |
1191 * Parameters: | |
1192 * handle: Handle to the spinbutton to be set. | |
1193 * limit: Number of characters the entryfield will take. | |
1194 */ | |
1195 void API dw_entryfield_set_limit(HWND handle, ULONG limit) | |
1196 { | |
1197 NSLog(@"dw_entryfield_set_limit() unimplemented\n"); | |
1198 } | |
1199 | |
1200 /* | |
1201 * Create a new bitmap button window (widget) to be packed. | |
1202 * Parameters: | |
1203 * text: Bubble help text to be displayed. | |
1204 * id: An ID of a bitmap in the resource file. | |
1205 */ | |
1206 HWND API dw_bitmapbutton_new(char *text, ULONG id) | |
1207 { | |
1208 NSLog(@"dw_bitmapbutton_new() unimplemented\n"); | |
1209 return HWND_DESKTOP; | |
1210 } | |
1211 | |
1212 /* | |
1213 * Create a new bitmap button window (widget) to be packed from a file. | |
1214 * Parameters: | |
1215 * text: Bubble help text to be displayed. | |
1216 * id: An ID to be used with dw_window_from_id() or 0L. | |
1217 * filename: Name of the file, omit extention to have | |
1218 * DW pick the appropriate file extension. | |
1219 * (BMP on OS/2 or Windows, XPM on Unix) | |
1220 */ | |
1221 HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename) | |
1222 { | |
1223 NSLog(@"dw_bitmapbutton_new_from_file() unimplemented\n"); | |
1224 return HWND_DESKTOP; | |
1225 } | |
1226 | |
1227 /* | |
1228 * Create a new bitmap button window (widget) to be packed from data. | |
1229 * Parameters: | |
1230 * text: Bubble help text to be displayed. | |
1231 * id: An ID to be used with dw_window_from_id() or 0L. | |
1232 * data: The contents of the image | |
1233 * (BMP or ICO on OS/2 or Windows, XPM on Unix) | |
1234 * len: length of str | |
1235 */ | |
1236 HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *data, int len) | |
1237 { | |
1238 NSLog(@"dw_bitmapbutton_new_from_data() unimplemented\n"); | |
1239 return HWND_DESKTOP; | |
1240 } | |
1241 | |
1242 /* | |
1243 * Create a new spinbutton window (widget) to be packed. | |
1244 * Parameters: | |
1245 * text: The text to be display by the static text widget. | |
1246 * id: An ID to be used with dw_window_from_id() or 0L. | |
1247 */ | |
1248 HWND API dw_spinbutton_new(char *text, ULONG id) | |
1249 { | |
1250 NSLog(@"dw_spinbutton_new() unimplemented\n"); | |
1251 return HWND_DESKTOP; | |
1252 } | |
1253 | |
1254 /* | |
1255 * Sets the spinbutton value. | |
1256 * Parameters: | |
1257 * handle: Handle to the spinbutton to be set. | |
1258 * position: Current value of the spinbutton. | |
1259 */ | |
1260 void API dw_spinbutton_set_pos(HWND handle, long position) | |
1261 { | |
1262 NSLog(@"dw_spinbutton_set_pos() unimplemented\n"); | |
1263 } | |
1264 | |
1265 /* | |
1266 * Sets the spinbutton limits. | |
1267 * Parameters: | |
1268 * handle: Handle to the spinbutton to be set. | |
1269 * upper: Upper limit. | |
1270 * lower: Lower limit. | |
1271 */ | |
1272 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower) | |
1273 { | |
1274 NSLog(@"dw_spinbutton_set_limits() unimplemented\n"); | |
1275 } | |
1276 | |
1277 /* | |
1278 * Returns the current value of the spinbutton. | |
1279 * Parameters: | |
1280 * handle: Handle to the spinbutton to be queried. | |
1281 */ | |
1282 long API dw_spinbutton_get_pos(HWND handle) | |
1283 { | |
1284 NSLog(@"dw_spinbutton_get_pos() unimplemented\n"); | |
1285 return 0; | |
1286 } | |
1287 | |
1288 /* | |
1289 * Create a new radiobutton window (widget) to be packed. | |
1290 * Parameters: | |
1291 * text: The text to be display by the static text widget. | |
1292 * id: An ID to be used with dw_window_from_id() or 0L. | |
1293 */ | |
1294 HWND API dw_radiobutton_new(char *text, ULONG id) | |
1295 { | |
1296 DWButton *button = dw_button_new(text, id); | |
1297 [button setButtonType:NSRadioButton]; | |
1298 return button; | |
1299 } | |
1300 | |
1301 /* | |
1302 * Create a new slider window (widget) to be packed. | |
1303 * Parameters: | |
1304 * vertical: TRUE or FALSE if slider is vertical. | |
1305 * increments: Number of increments available. | |
1306 * id: An ID to be used with dw_window_from_id() or 0L. | |
1307 */ | |
1308 HWND API dw_slider_new(int vertical, int increments, ULONG id) | |
1309 { | |
1310 NSLog(@"dw_slider_new() unimplemented\n"); | |
1311 return HWND_DESKTOP; | |
1312 } | |
1313 | |
1314 /* | |
1315 * Returns the position of the slider. | |
1316 * Parameters: | |
1317 * handle: Handle to the slider to be queried. | |
1318 */ | |
1319 unsigned int API dw_slider_get_pos(HWND handle) | |
1320 { | |
1321 NSLog(@"dw_slider_get_pos() unimplemented\n"); | |
1322 return 0; | |
1323 } | |
1324 | |
1325 /* | |
1326 * Sets the slider position. | |
1327 * Parameters: | |
1328 * handle: Handle to the slider to be set. | |
1329 * position: Position of the slider withing the range. | |
1330 */ | |
1331 void API dw_slider_set_pos(HWND handle, unsigned int position) | |
1332 { | |
1333 NSLog(@"dw_slider_set_pos() unimplemented\n"); | |
1334 } | |
1335 | |
1336 /* | |
1337 * Create a new scrollbar window (widget) to be packed. | |
1338 * Parameters: | |
1339 * vertical: TRUE or FALSE if scrollbar is vertical. | |
1340 * increments: Number of increments available. | |
1341 * id: An ID to be used with dw_window_from_id() or 0L. | |
1342 */ | |
1343 HWND API dw_scrollbar_new(int vertical, ULONG id) | |
1344 { | |
1345 NSLog(@"dw_scrollbar_new() unimplemented\n"); | |
1346 return HWND_DESKTOP; | |
1347 } | |
1348 | |
1349 /* | |
1350 * Returns the position of the scrollbar. | |
1351 * Parameters: | |
1352 * handle: Handle to the scrollbar to be queried. | |
1353 */ | |
1354 unsigned int API dw_scrollbar_get_pos(HWND handle) | |
1355 { | |
1356 NSLog(@"dw_scrollbar_get_pos() unimplemented\n"); | |
1357 return 0; | |
1358 } | |
1359 | |
1360 /* | |
1361 * Sets the scrollbar position. | |
1362 * Parameters: | |
1363 * handle: Handle to the scrollbar to be set. | |
1364 * position: Position of the scrollbar withing the range. | |
1365 */ | |
1366 void API dw_scrollbar_set_pos(HWND handle, unsigned int position) | |
1367 { | |
1368 NSLog(@"dw_scrollbar_set_pos() unimplemented\n"); | |
1369 } | |
1370 | |
1371 /* | |
1372 * Sets the scrollbar range. | |
1373 * Parameters: | |
1374 * handle: Handle to the scrollbar to be set. | |
1375 * range: Maximum range value. | |
1376 * visible: Visible area relative to the range. | |
1377 */ | |
1378 void API dw_scrollbar_set_range(HWND handle, unsigned int range, unsigned int visible) | |
1379 { | |
1380 NSLog(@"dw_scrollbar_set_range() unimplemented\n"); | |
1381 } | |
1382 | |
1383 /* | |
1384 * Create a new percent bar window (widget) to be packed. | |
1385 * Parameters: | |
1386 * id: An ID to be used with dw_window_from_id() or 0L. | |
1387 */ | |
1388 HWND API dw_percent_new(ULONG id) | |
1389 { | |
1390 DWPercent *percent = [[DWPercent alloc] init]; | |
1391 [percent setBezeled:YES]; | |
1392 [percent setMaxValue:100]; | |
1393 [percent setMinValue:0]; | |
1394 /*[percent setTag:id]; Why doesn't this work? */ | |
1395 return percent; | |
1396 } | |
1397 | |
1398 /* | |
1399 * Sets the percent bar position. | |
1400 * Parameters: | |
1401 * handle: Handle to the percent bar to be set. | |
1402 * position: Position of the percent bar withing the range. | |
1403 */ | |
1404 void API dw_percent_set_pos(HWND handle, unsigned int position) | |
1405 { | |
1406 DWPercent *percent = handle; | |
1407 [percent setDoubleValue:(double)position]; | |
1408 } | |
1409 | |
1410 /* | |
1411 * Create a new checkbox window (widget) to be packed. | |
1412 * Parameters: | |
1413 * text: The text to be display by the static text widget. | |
1414 * id: An ID to be used with dw_window_from_id() or 0L. | |
1415 */ | |
1416 HWND API dw_checkbox_new(char *text, ULONG id) | |
1417 { | |
1418 DWButton *button = dw_button_new(text, id); | |
1419 [button setButtonType:NSSwitchButton]; | |
1420 [button setBezelStyle:NSRegularSquareBezelStyle]; | |
1421 return button; | |
1422 } | |
1423 | |
1424 /* | |
1425 * Returns the state of the checkbox. | |
1426 * Parameters: | |
1427 * handle: Handle to the checkbox to be queried. | |
1428 */ | |
1429 int API dw_checkbox_get(HWND handle) | |
1430 { | |
1431 NSLog(@"dw_checkbox_set() unimplemented\n"); | |
1432 return 0; | |
1433 } | |
1434 | |
1435 /* | |
1436 * Sets the state of the checkbox. | |
1437 * Parameters: | |
1438 * handle: Handle to the checkbox to be queried. | |
1439 * value: TRUE for checked, FALSE for unchecked. | |
1440 */ | |
1441 void API dw_checkbox_set(HWND handle, int value) | |
1442 { | |
1443 NSLog(@"dw_checkbox_set() unimplemented\n"); | |
1444 } | |
1445 | |
1446 /* | |
1447 * Create a new listbox window (widget) to be packed. | |
1448 * Parameters: | |
1449 * id: An ID to be used with dw_window_from_id() or 0L. | |
1450 * multi: Multiple select TRUE or FALSE. | |
1451 */ | |
1452 HWND API dw_listbox_new(ULONG id, int multi) | |
1453 { | |
1454 NSLog(@"dw_listbox_new() unimplemented\n"); | |
1455 return HWND_DESKTOP; | |
1456 } | |
1457 | |
1458 /* | |
1459 * Appends the specified text to the listbox's (or combobox) entry list. | |
1460 * Parameters: | |
1461 * handle: Handle to the listbox to be appended to. | |
1462 * text: Text to append into listbox. | |
1463 */ | |
1464 void API dw_listbox_append(HWND handle, char *text) | |
1465 { | |
1466 NSLog(@"dw_listbox_append() unimplemented\n"); | |
1467 } | |
1468 | |
1469 /* | |
1470 * Inserts the specified text into the listbox's (or combobox) entry list. | |
1471 * Parameters: | |
1472 * handle: Handle to the listbox to be inserted into. | |
1473 * text: Text to insert into listbox. | |
1474 * pos: 0-based position to insert text | |
1475 */ | |
1476 void API dw_listbox_insert(HWND handle, char *text, int pos) | |
1477 { | |
1478 NSLog(@"dw_listbox_insert() unimplemented\n"); | |
1479 } | |
1480 | |
1481 /* | |
1482 * Appends the specified text items to the listbox's (or combobox) entry list. | |
1483 * Parameters: | |
1484 * handle: Handle to the listbox to be appended to. | |
1485 * text: Text strings to append into listbox. | |
1486 * count: Number of text strings to append | |
1487 */ | |
1488 void API dw_listbox_list_append(HWND handle, char **text, int count) | |
1489 { | |
1490 NSLog(@"dw_listbox_list_append() unimplemented\n"); | |
1491 } | |
1492 | |
1493 /* | |
1494 * Clears the listbox's (or combobox) list of all entries. | |
1495 * Parameters: | |
1496 * handle: Handle to the listbox to be cleared. | |
1497 */ | |
1498 void API dw_listbox_clear(HWND handle) | |
1499 { | |
1500 NSLog(@"dw_listbox_clear() unimplemented\n"); | |
1501 } | |
1502 | |
1503 /* | |
1504 * Returns the listbox's item count. | |
1505 * Parameters: | |
1506 * handle: Handle to the listbox to be cleared. | |
1507 */ | |
1508 int API dw_listbox_count(HWND handle) | |
1509 { | |
1510 NSLog(@"dw_listbox_count() unimplemented\n"); | |
1511 return 0; | |
1512 } | |
1513 | |
1514 /* | |
1515 * Sets the topmost item in the viewport. | |
1516 * Parameters: | |
1517 * handle: Handle to the listbox to be cleared. | |
1518 * top: Index to the top item. | |
1519 */ | |
1520 void API dw_listbox_set_top(HWND handle, int top) | |
1521 { | |
1522 NSLog(@"dw_listbox_set_top() unimplemented\n"); | |
1523 } | |
1524 | |
1525 /* | |
1526 * Copies the given index item's text into buffer. | |
1527 * Parameters: | |
1528 * handle: Handle to the listbox to be queried. | |
1529 * index: Index into the list to be queried. | |
1530 * buffer: Buffer where text will be copied. | |
1531 * length: Length of the buffer (including NULL). | |
1532 */ | |
1533 void API dw_listbox_get_text(HWND handle, unsigned int index, char *buffer, unsigned int length) | |
1534 { | |
1535 NSLog(@"dw_listbox_get_text() unimplemented\n"); | |
1536 } | |
1537 | |
1538 /* | |
1539 * Sets the text of a given listbox entry. | |
1540 * Parameters: | |
1541 * handle: Handle to the listbox to be queried. | |
1542 * index: Index into the list to be queried. | |
1543 * buffer: Buffer where text will be copied. | |
1544 */ | |
1545 void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) | |
1546 { | |
1547 NSLog(@"dw_listbox_set_text() unimplemented\n"); | |
1548 } | |
1549 | |
1550 /* | |
1551 * Returns the index to the item in the list currently selected. | |
1552 * Parameters: | |
1553 * handle: Handle to the listbox to be queried. | |
1554 */ | |
1555 unsigned int API dw_listbox_selected(HWND handle) | |
1556 { | |
1557 NSLog(@"dw_listbox_selected() unimplemented\n"); | |
1558 return 0; | |
1559 } | |
1560 | |
1561 /* | |
1562 * Returns the index to the current selected item or -1 when done. | |
1563 * Parameters: | |
1564 * handle: Handle to the listbox to be queried. | |
1565 * where: Either the previous return or -1 to restart. | |
1566 */ | |
1567 int API dw_listbox_selected_multi(HWND handle, int where) | |
1568 { | |
1569 NSLog(@"dw_listbox_selected_multi() unimplemented\n"); | |
1570 return 0; | |
1571 } | |
1572 | |
1573 /* | |
1574 * Sets the selection state of a given index. | |
1575 * Parameters: | |
1576 * handle: Handle to the listbox to be set. | |
1577 * index: Item index. | |
1578 * state: TRUE if selected FALSE if unselected. | |
1579 */ | |
1580 void API dw_listbox_select(HWND handle, int index, int state) | |
1581 { | |
1582 NSLog(@"dw_listbox_select() unimplemented\n"); | |
1583 } | |
1584 | |
1585 /* | |
1586 * Deletes the item with given index from the list. | |
1587 * Parameters: | |
1588 * handle: Handle to the listbox to be set. | |
1589 * index: Item index. | |
1590 */ | |
1591 void API dw_listbox_delete(HWND handle, int index) | |
1592 { | |
1593 NSLog(@"dw_listbox_delete() unimplemented\n"); | |
1594 } | |
1595 | |
1596 /* | |
1597 * Create a new Combobox window (widget) to be packed. | |
1598 * Parameters: | |
1599 * text: The default text to be in the combpbox widget. | |
1600 * id: An ID to be used with dw_window_from_id() or 0L. | |
1601 */ | |
1602 HWND API dw_combobox_new(char *text, ULONG id) | |
1603 { | |
1604 NSLog(@"dw_combobox_new() unimplemented\n"); | |
1605 return HWND_DESKTOP; | |
1606 } | |
1607 | |
1608 /* | |
1609 * Create a new Multiline Editbox window (widget) to be packed. | |
1610 * Parameters: | |
1611 * id: An ID to be used with dw_window_from_id() or 0L. | |
1612 */ | |
1613 HWND API dw_mle_new(ULONG id) | |
1614 { | |
1615 NSLog(@"dw_mle_new() unimplemented\n"); | |
1616 return HWND_DESKTOP; | |
1617 } | |
1618 | |
1619 /* | |
1620 * Adds text to an MLE box and returns the current point. | |
1621 * Parameters: | |
1622 * handle: Handle to the MLE to be queried. | |
1623 * buffer: Text buffer to be imported. | |
1624 * startpoint: Point to start entering text. | |
1625 */ | |
1626 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint) | |
1627 { | |
1628 NSLog(@"dw_mle_import() unimplemented\n"); | |
1629 return 0; | |
1630 } | |
1631 | |
1632 /* | |
1633 * Grabs text from an MLE box. | |
1634 * Parameters: | |
1635 * handle: Handle to the MLE to be queried. | |
1636 * buffer: Text buffer to be exported. | |
1637 * startpoint: Point to start grabbing text. | |
1638 * length: Amount of text to be grabbed. | |
1639 */ | |
1640 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length) | |
1641 { | |
1642 NSLog(@"dw_mle_export() unimplemented\n"); | |
1643 } | |
1644 | |
1645 /* | |
1646 * Obtains information about an MLE box. | |
1647 * Parameters: | |
1648 * handle: Handle to the MLE to be queried. | |
1649 * bytes: A pointer to a variable to return the total bytes. | |
1650 * lines: A pointer to a variable to return the number of lines. | |
1651 */ | |
1652 void API dw_mle_get_size(HWND handle, unsigned long *bytes, unsigned long *lines) | |
1653 { | |
1654 NSLog(@"dw_mle_get_size() unimplemented\n"); | |
1655 } | |
1656 | |
1657 /* | |
1658 * Deletes text from an MLE box. | |
1659 * Parameters: | |
1660 * handle: Handle to the MLE to be deleted from. | |
1661 * startpoint: Point to start deleting text. | |
1662 * length: Amount of text to be deleted. | |
1663 */ | |
1664 void API dw_mle_delete(HWND handle, int startpoint, int length) | |
1665 { | |
1666 NSLog(@"dw_mle_delete() unimplemented\n"); | |
1667 } | |
1668 | |
1669 /* | |
1670 * Clears all text from an MLE box. | |
1671 * Parameters: | |
1672 * handle: Handle to the MLE to be cleared. | |
1673 */ | |
1674 void API dw_mle_clear(HWND handle) | |
1675 { | |
1676 NSLog(@"dw_mle_clear() unimplemented\n"); | |
1677 } | |
1678 | |
1679 /* | |
1680 * Sets the visible line of an MLE box. | |
1681 * Parameters: | |
1682 * handle: Handle to the MLE to be positioned. | |
1683 * line: Line to be visible. | |
1684 */ | |
1685 void API dw_mle_set_visible(HWND handle, int line) | |
1686 { | |
1687 NSLog(@"dw_mle_clear() unimplemented\n"); | |
1688 } | |
1689 | |
1690 /* | |
1691 * Sets the editablity of an MLE box. | |
1692 * Parameters: | |
1693 * handle: Handle to the MLE. | |
1694 * state: TRUE if it can be edited, FALSE for readonly. | |
1695 */ | |
1696 void API dw_mle_set_editable(HWND handle, int state) | |
1697 { | |
1698 NSLog(@"dw_mle_set_editable() unimplemented\n"); | |
1699 } | |
1700 | |
1701 /* | |
1702 * Sets the word wrap state of an MLE box. | |
1703 * Parameters: | |
1704 * handle: Handle to the MLE. | |
1705 * state: TRUE if it wraps, FALSE if it doesn't. | |
1706 */ | |
1707 void API dw_mle_set_word_wrap(HWND handle, int state) | |
1708 { | |
1709 NSLog(@"dw_mle_set_word_wrap() unimplemented\n"); | |
1710 } | |
1711 | |
1712 /* | |
1713 * Sets the current cursor position of an MLE box. | |
1714 * Parameters: | |
1715 * handle: Handle to the MLE to be positioned. | |
1716 * point: Point to position cursor. | |
1717 */ | |
1718 void API dw_mle_set_cursor(HWND handle, int point) | |
1719 { | |
1720 NSLog(@"dw_mle_set_cursor() unimplemented\n"); | |
1721 } | |
1722 | |
1723 /* | |
1724 * Finds text in an MLE box. | |
1725 * Parameters: | |
1726 * handle: Handle to the MLE to be cleared. | |
1727 * text: Text to search for. | |
1728 * point: Start point of search. | |
1729 * flags: Search specific flags. | |
1730 */ | |
1731 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags) | |
1732 { | |
1733 NSLog(@"dw_mle_search() unimplemented\n"); | |
1734 return 0; | |
1735 } | |
1736 | |
1737 /* | |
1738 * Stops redrawing of an MLE box. | |
1739 * Parameters: | |
1740 * handle: Handle to the MLE to freeze. | |
1741 */ | |
1742 void API dw_mle_freeze(HWND handle) | |
1743 { | |
1744 NSLog(@"dw_mle_freeze() unimplemented\n"); | |
1745 } | |
1746 | |
1747 /* | |
1748 * Resumes redrawing of an MLE box. | |
1749 * Parameters: | |
1750 * handle: Handle to the MLE to thaw. | |
1751 */ | |
1752 void API dw_mle_thaw(HWND handle) | |
1753 { | |
1754 NSLog(@"dw_mle_thaw() unimplemented\n"); | |
1755 } | |
1756 | |
1757 /* | |
1758 * Create a new status text window (widget) to be packed. | |
1759 * Parameters: | |
1760 * text: The text to be display by the static text widget. | |
1761 * id: An ID to be used with dw_window_from_id() or 0L. | |
1762 */ | |
1763 HWND API dw_status_text_new(char *text, ULONG id) | |
1764 { | |
1765 NSLog(@"dw_status_text_new() unimplemented\n"); | |
1766 return HWND_DESKTOP; | |
1767 } | |
1768 | |
1769 /* | |
1770 * Create a new static text window (widget) to be packed. | |
1771 * Parameters: | |
1772 * text: The text to be display by the static text widget. | |
1773 * id: An ID to be used with dw_window_from_id() or 0L. | |
1774 */ | |
1775 HWND API dw_text_new(char *text, ULONG id) | |
1776 { | |
1777 NSLog(@"dw_text_new() unimplemented\n"); | |
1778 return HWND_DESKTOP; | |
1779 } | |
1780 | |
1781 /* | |
1782 * Creates a rendering context widget (window) to be packed. | |
1783 * Parameters: | |
1784 * id: An id to be used with dw_window_from_id. | |
1785 * Returns: | |
1786 * A handle to the widget or NULL on failure. | |
1787 */ | |
1788 HWND API dw_render_new(unsigned long id) | |
1789 { | |
1790 NSLog(@"dw_render_new() unimplemented\n"); | |
1791 return HWND_DESKTOP; | |
1792 } | |
1793 | |
1794 /* Sets the current foreground drawing color. | |
1795 * Parameters: | |
1796 * red: red value. | |
1797 * green: green value. | |
1798 * blue: blue value. | |
1799 */ | |
1800 void API dw_color_foreground_set(unsigned long value) | |
1801 { | |
1802 _foreground = value; | |
1803 } | |
1804 | |
1805 /* Sets the current background drawing color. | |
1806 * Parameters: | |
1807 * red: red value. | |
1808 * green: green value. | |
1809 * blue: blue value. | |
1810 */ | |
1811 void API dw_color_background_set(unsigned long value) | |
1812 { | |
1813 _background = value; | |
1814 } | |
1815 | |
1816 /* Allows the user to choose a color using the system's color chooser dialog. | |
1817 * Parameters: | |
1818 * value: current color | |
1819 * Returns: | |
1820 * The selected color or the current color if cancelled. | |
1821 */ | |
1822 unsigned long API dw_color_choose(unsigned long value) | |
1823 { | |
1824 NSLog(@"dw_color_choose() unimplemented\n"); | |
1825 return 0; | |
1826 } | |
1827 | |
1828 /* Draw a point on a window (preferably a render window). | |
1829 * Parameters: | |
1830 * handle: Handle to the window. | |
1831 * pixmap: Handle to the pixmap. (choose only one of these) | |
1832 * x: X coordinate. | |
1833 * y: Y coordinate. | |
1834 */ | |
1835 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) | |
1836 { | |
1837 NSLog(@"dw_draw_point() unimplemented\n"); | |
1838 } | |
1839 | |
1840 /* Draw a line on a window (preferably a render window). | |
1841 * Parameters: | |
1842 * handle: Handle to the window. | |
1843 * pixmap: Handle to the pixmap. (choose only one of these) | |
1844 * x1: First X coordinate. | |
1845 * y1: First Y coordinate. | |
1846 * x2: Second X coordinate. | |
1847 * y2: Second Y coordinate. | |
1848 */ | |
1849 void API dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) | |
1850 { | |
1851 NSLog(@"dw_draw_line() unimplemented\n"); | |
1852 } | |
1853 | |
1854 /* Draw text on a window (preferably a render window). | |
1855 * Parameters: | |
1856 * handle: Handle to the window. | |
1857 * pixmap: Handle to the pixmap. (choose only one of these) | |
1858 * x: X coordinate. | |
1859 * y: Y coordinate. | |
1860 * text: Text to be displayed. | |
1861 */ | |
1862 void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) | |
1863 { | |
1864 NSLog(@"dw_draw_line() unimplemented\n"); | |
1865 } | |
1866 | |
1867 /* Query the width and height of a text string. | |
1868 * Parameters: | |
1869 * handle: Handle to the window. | |
1870 * pixmap: Handle to the pixmap. (choose only one of these) | |
1871 * text: Text to be queried. | |
1872 * width: Pointer to a variable to be filled in with the width. | |
1873 * height Pointer to a variable to be filled in with the height. | |
1874 */ | |
1875 void API dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height) | |
1876 { | |
1877 NSLog(@"dw_font_text_extents_get() unimplemented\n"); | |
1878 } | |
1879 | |
1880 /* Draw a polygon on a window (preferably a render window). | |
1881 * Parameters: | |
1882 * handle: Handle to the window. | |
1883 * pixmap: Handle to the pixmap. (choose only one of these) | |
1884 * fill: Fill box TRUE or FALSE. | |
1885 * x: X coordinate. | |
1886 * y: Y coordinate. | |
1887 * width: Width of rectangle. | |
1888 * height: Height of rectangle. | |
1889 */ | |
1890 void API dw_draw_polygon( HWND handle, HPIXMAP pixmap, int fill, int npoints, int *x, int *y ) | |
1891 { | |
1892 NSLog(@"dw_draw_polygon() unimplemented\n"); | |
1893 } | |
1894 | |
1895 /* Draw a rectangle on a window (preferably a render window). | |
1896 * Parameters: | |
1897 * handle: Handle to the window. | |
1898 * pixmap: Handle to the pixmap. (choose only one of these) | |
1899 * fill: Fill box TRUE or FALSE. | |
1900 * x: X coordinate. | |
1901 * y: Y coordinate. | |
1902 * width: Width of rectangle. | |
1903 * height: Height of rectangle. | |
1904 */ | |
1905 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) | |
1906 { | |
1907 NSLog(@"dw_draw_rect() unimplemented\n"); | |
1908 } | |
1909 | |
1910 /* | |
1911 * Create a tree object to be packed. | |
1912 * Parameters: | |
1913 * id: An ID to be used for getting the resource from the | |
1914 * resource file. | |
1915 */ | |
1916 HWND API dw_tree_new(ULONG id) | |
1917 { | |
1918 NSLog(@"dw_tree_new() unimplemented\n"); | |
1919 return HWND_DESKTOP; | |
1920 } | |
1921 | |
1922 /* | |
1923 * Inserts an item into a tree window (widget) after another item. | |
1924 * Parameters: | |
1925 * handle: Handle to the tree to be inserted. | |
1926 * item: Handle to the item to be positioned after. | |
1927 * title: The text title of the entry. | |
1928 * icon: Handle to coresponding icon. | |
1929 * parent: Parent handle or 0 if root. | |
1930 * itemdata: Item specific data. | |
1931 */ | |
1932 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) | |
1933 { | |
1934 NSLog(@"dw_tree_insert_item_after() unimplemented\n"); | |
1935 return HWND_DESKTOP; | |
1936 } | |
1937 | |
1938 /* | |
1939 * Inserts an item into a tree window (widget). | |
1940 * Parameters: | |
1941 * handle: Handle to the tree to be inserted. | |
1942 * title: The text title of the entry. | |
1943 * icon: Handle to coresponding icon. | |
1944 * parent: Parent handle or 0 if root. | |
1945 * itemdata: Item specific data. | |
1946 */ | |
1947 HTREEITEM API dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) | |
1948 { | |
1949 NSLog(@"dw_tree_insert_item() unimplemented\n"); | |
1950 return HWND_DESKTOP; | |
1951 } | |
1952 | |
1953 /* | |
1954 * Gets the text an item in a tree window (widget). | |
1955 * Parameters: | |
1956 * handle: Handle to the tree containing the item. | |
1957 * item: Handle of the item to be modified. | |
1958 */ | |
1959 char * API dw_tree_get_title(HWND handle, HTREEITEM item) | |
1960 { | |
1961 NSLog(@"dw_tree_get_title() unimplemented\n"); | |
1962 return NULL; | |
1963 } | |
1964 | |
1965 /* | |
1966 * Gets the text an item in a tree window (widget). | |
1967 * Parameters: | |
1968 * handle: Handle to the tree containing the item. | |
1969 * item: Handle of the item to be modified. | |
1970 */ | |
1971 HTREEITEM API dw_tree_get_parent(HWND handle, HTREEITEM item) | |
1972 { | |
1973 NSLog(@"dw_tree_get_parent() unimplemented\n"); | |
1974 return HWND_DESKTOP; | |
1975 } | |
1976 | |
1977 /* | |
1978 * Sets the text and icon of an item in a tree window (widget). | |
1979 * Parameters: | |
1980 * handle: Handle to the tree containing the item. | |
1981 * item: Handle of the item to be modified. | |
1982 * title: The text title of the entry. | |
1983 * icon: Handle to coresponding icon. | |
1984 */ | |
1985 void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, unsigned long icon) | |
1986 { | |
1987 NSLog(@"dw_tree_item_change() unimplemented\n"); | |
1988 } | |
1989 | |
1990 /* | |
1991 * Sets the item data of a tree item. | |
1992 * Parameters: | |
1993 * handle: Handle to the tree containing the item. | |
1994 * item: Handle of the item to be modified. | |
1995 * itemdata: User defined data to be associated with item. | |
1996 */ | |
1997 void API dw_tree_item_set_data(HWND handle, HTREEITEM item, void *itemdata) | |
1998 { | |
1999 NSLog(@"dw_tree_item_set_data() unimplemented\n"); | |
2000 } | |
2001 | |
2002 /* | |
2003 * Gets the item data of a tree item. | |
2004 * Parameters: | |
2005 * handle: Handle to the tree containing the item. | |
2006 * item: Handle of the item to be modified. | |
2007 */ | |
2008 void * API dw_tree_item_get_data(HWND handle, HTREEITEM item) | |
2009 { | |
2010 NSLog(@"dw_tree_item_get_data() unimplemented\n"); | |
2011 return NULL; | |
2012 } | |
2013 | |
2014 /* | |
2015 * Sets this item as the active selection. | |
2016 * Parameters: | |
2017 * handle: Handle to the tree window (widget) to be selected. | |
2018 * item: Handle to the item to be selected. | |
2019 */ | |
2020 void API dw_tree_item_select(HWND handle, HTREEITEM item) | |
2021 { | |
2022 NSLog(@"dw_tree_item_select() unimplemented\n"); | |
2023 } | |
2024 | |
2025 /* | |
2026 * Removes all nodes from a tree. | |
2027 * Parameters: | |
2028 * handle: Handle to the window (widget) to be cleared. | |
2029 */ | |
2030 void API dw_tree_clear(HWND handle) | |
2031 { | |
2032 NSLog(@"dw_tree_clear() unimplemented\n"); | |
2033 } | |
2034 | |
2035 /* | |
2036 * Expands a node on a tree. | |
2037 * Parameters: | |
2038 * handle: Handle to the tree window (widget). | |
2039 * item: Handle to node to be expanded. | |
2040 */ | |
2041 void API dw_tree_item_expand(HWND handle, HTREEITEM item) | |
2042 { | |
2043 NSLog(@"dw_tree_item_expand() unimplemented\n"); | |
2044 } | |
2045 | |
2046 /* | |
2047 * Collapses a node on a tree. | |
2048 * Parameters: | |
2049 * handle: Handle to the tree window (widget). | |
2050 * item: Handle to node to be collapsed. | |
2051 */ | |
2052 void API dw_tree_item_collapse(HWND handle, HTREEITEM item) | |
2053 { | |
2054 NSLog(@"dw_tree_item_collapse() unimplemented\n"); | |
2055 } | |
2056 | |
2057 /* | |
2058 * Removes a node from a tree. | |
2059 * Parameters: | |
2060 * handle: Handle to the window (widget) to be cleared. | |
2061 * item: Handle to node to be deleted. | |
2062 */ | |
2063 void API dw_tree_item_delete(HWND handle, HTREEITEM item) | |
2064 { | |
2065 NSLog(@"dw_tree_item_delete() unimplemented\n"); | |
2066 } | |
2067 | |
2068 /* | |
2069 * Create a container object to be packed. | |
2070 * Parameters: | |
2071 * id: An ID to be used for getting the resource from the | |
2072 * resource file. | |
2073 */ | |
2074 HWND API dw_container_new(ULONG id, int multi) | |
2075 { | |
2076 NSLog(@"dw_container_new() unimplemented\n"); | |
2077 return HWND_DESKTOP; | |
2078 } | |
2079 | |
2080 /* | |
2081 * Sets up the container columns. | |
2082 * Parameters: | |
2083 * handle: Handle to the container to be configured. | |
2084 * flags: An array of unsigned longs with column flags. | |
2085 * titles: An array of strings with column text titles. | |
2086 * count: The number of columns (this should match the arrays). | |
2087 * separator: The column number that contains the main separator. | |
2088 * (this item may only be used in OS/2) | |
2089 */ | |
2090 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) | |
2091 { | |
2092 NSLog(@"dw_container_setup() unimplemented\n"); | |
2093 return 0; | |
2094 } | |
2095 | |
2096 /* | |
2097 * Sets up the filesystem columns, note: filesystem always has an icon/filename field. | |
2098 * Parameters: | |
2099 * handle: Handle to the container to be configured. | |
2100 * flags: An array of unsigned longs with column flags. | |
2101 * titles: An array of strings with column text titles. | |
2102 * count: The number of columns (this should match the arrays). | |
2103 */ | |
2104 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) | |
2105 { | |
2106 NSLog(@"dw_filesystem_setup() unimplemented\n"); | |
2107 return 0; | |
2108 } | |
2109 | |
2110 /* | |
2111 * Allocates memory used to populate a container. | |
2112 * Parameters: | |
2113 * handle: Handle to the container window (widget). | |
2114 * rowcount: The number of items to be populated. | |
2115 */ | |
2116 void * API dw_container_alloc(HWND handle, int rowcount) | |
2117 { | |
2118 NSLog(@"dw_container_alloc() unimplemented\n"); | |
2119 return NULL; | |
2120 } | |
2121 | |
2122 /* | |
2123 * Sets an item in specified row and column to the given data. | |
2124 * Parameters: | |
2125 * handle: Handle to the container window (widget). | |
2126 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
2127 * column: Zero based column of data being set. | |
2128 * row: Zero based row of data being set. | |
2129 * data: Pointer to the data to be added. | |
2130 */ | |
2131 void API dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
2132 { | |
2133 NSLog(@"dw_container_set_item() unimplemented\n"); | |
2134 } | |
2135 | |
2136 /* | |
2137 * Changes an existing item in specified row and column to the given data. | |
2138 * Parameters: | |
2139 * handle: Handle to the container window (widget). | |
2140 * column: Zero based column of data being set. | |
2141 * row: Zero based row of data being set. | |
2142 * data: Pointer to the data to be added. | |
2143 */ | |
2144 void API dw_container_change_item(HWND handle, int column, int row, void *data) | |
2145 { | |
2146 NSLog(@"dw_container_change_item() unimplemented\n"); | |
2147 } | |
2148 | |
2149 /* | |
2150 * Changes an existing item in specified row and column to the given data. | |
2151 * Parameters: | |
2152 * handle: Handle to the container window (widget). | |
2153 * column: Zero based column of data being set. | |
2154 * row: Zero based row of data being set. | |
2155 * data: Pointer to the data to be added. | |
2156 */ | |
2157 void API dw_filesystem_change_item(HWND handle, int column, int row, void *data) | |
2158 { | |
2159 NSLog(@"dw_filesystem_change_item() unimplemented\n"); | |
2160 } | |
2161 | |
2162 /* | |
2163 * Changes an item in specified row and column to the given data. | |
2164 * Parameters: | |
2165 * handle: Handle to the container window (widget). | |
2166 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
2167 * column: Zero based column of data being set. | |
2168 * row: Zero based row of data being set. | |
2169 * data: Pointer to the data to be added. | |
2170 */ | |
2171 void API dw_filesystem_change_file(HWND handle, int row, char *filename, unsigned long icon) | |
2172 { | |
2173 NSLog(@"dw_filesystem_change_file() unimplemented\n"); | |
2174 } | |
2175 | |
2176 /* | |
2177 * Sets an item in specified row and column to the given data. | |
2178 * Parameters: | |
2179 * handle: Handle to the container window (widget). | |
2180 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
2181 * column: Zero based column of data being set. | |
2182 * row: Zero based row of data being set. | |
2183 * data: Pointer to the data to be added. | |
2184 */ | |
2185 void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) | |
2186 { | |
2187 NSLog(@"dw_filesystem_set_file() unimplemented\n"); | |
2188 } | |
2189 | |
2190 /* | |
2191 * Sets an item in specified row and column to the given data. | |
2192 * Parameters: | |
2193 * handle: Handle to the container window (widget). | |
2194 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
2195 * column: Zero based column of data being set. | |
2196 * row: Zero based row of data being set. | |
2197 * data: Pointer to the data to be added. | |
2198 */ | |
2199 void API dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
2200 { | |
2201 NSLog(@"dw_filesystem_set_item() unimplemented\n"); | |
2202 } | |
2203 | |
2204 /* | |
2205 * Gets column type for a container column | |
2206 * Parameters: | |
2207 * handle: Handle to the container window (widget). | |
2208 * column: Zero based column. | |
2209 */ | |
2210 int API dw_container_get_column_type(HWND handle, int column) | |
2211 { | |
2212 NSLog(@"dw_container_get_column_type() unimplemented\n"); | |
2213 return 0; | |
2214 } | |
2215 | |
2216 /* | |
2217 * Gets column type for a filesystem container column | |
2218 * Parameters: | |
2219 * handle: Handle to the container window (widget). | |
2220 * column: Zero based column. | |
2221 */ | |
2222 int API dw_filesystem_get_column_type(HWND handle, int column) | |
2223 { | |
2224 NSLog(@"dw_filesystem_get_column_type() unimplemented\n"); | |
2225 return 0; | |
2226 } | |
2227 | |
2228 /* | |
2229 * Sets the width of a column in the container. | |
2230 * Parameters: | |
2231 * handle: Handle to window (widget) of container. | |
2232 * column: Zero based column of width being set. | |
2233 * width: Width of column in pixels. | |
2234 */ | |
2235 void API dw_container_set_column_width(HWND handle, int column, int width) | |
2236 { | |
2237 NSLog(@"dw_container_set_column_width() unimplemented\n"); | |
2238 } | |
2239 | |
2240 /* | |
2241 * Sets the title of a row in the container. | |
2242 * Parameters: | |
2243 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
2244 * row: Zero based row of data being set. | |
2245 * title: String title of the item. | |
2246 */ | |
2247 void API dw_container_set_row_title(void *pointer, int row, char *title) | |
2248 { | |
2249 NSLog(@"dw_container_set_row_title() unimplemented\n"); | |
2250 } | |
2251 | |
2252 /* | |
2253 * Sets the title of a row in the container. | |
2254 * Parameters: | |
2255 * handle: Handle to the container window (widget). | |
2256 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
2257 * rowcount: The number of rows to be inserted. | |
2258 */ | |
2259 void API dw_container_insert(HWND handle, void *pointer, int rowcount) | |
2260 { | |
2261 NSLog(@"dw_container_insert() unimplemented\n"); | |
2262 } | |
2263 | |
2264 /* | |
2265 * Removes all rows from a container. | |
2266 * Parameters: | |
2267 * handle: Handle to the window (widget) to be cleared. | |
2268 * redraw: TRUE to cause the container to redraw immediately. | |
2269 */ | |
2270 void API dw_container_clear(HWND handle, int redraw) | |
2271 { | |
2272 NSLog(@"dw_container_clear() unimplemented\n"); | |
2273 } | |
2274 | |
2275 /* | |
2276 * Removes the first x rows from a container. | |
2277 * Parameters: | |
2278 * handle: Handle to the window (widget) to be deleted from. | |
2279 * rowcount: The number of rows to be deleted. | |
2280 */ | |
2281 void API dw_container_delete(HWND handle, int rowcount) | |
2282 { | |
2283 NSLog(@"dw_container_delete() unimplemented\n"); | |
2284 } | |
2285 | |
2286 /* | |
2287 * Scrolls container up or down. | |
2288 * Parameters: | |
2289 * handle: Handle to the window (widget) to be scrolled. | |
2290 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or | |
2291 * DW_SCROLL_BOTTOM. (rows is ignored for last two) | |
2292 * rows: The number of rows to be scrolled. | |
2293 */ | |
2294 void API dw_container_scroll(HWND handle, int direction, long rows) | |
2295 { | |
2296 NSLog(@"dw_container_scroll() unimplemented\n"); | |
2297 } | |
2298 | |
2299 /* | |
2300 * Starts a new query of a container. | |
2301 * Parameters: | |
2302 * handle: Handle to the window (widget) to be queried. | |
2303 * flags: If this parameter is DW_CRA_SELECTED it will only | |
2304 * return items that are currently selected. Otherwise | |
2305 * it will return all records in the container. | |
2306 */ | |
2307 char * API dw_container_query_start(HWND handle, unsigned long flags) | |
2308 { | |
2309 NSLog(@"dw_container_query_start() unimplemented\n"); | |
2310 return NULL; | |
2311 } | |
2312 | |
2313 /* | |
2314 * Continues an existing query of a container. | |
2315 * Parameters: | |
2316 * handle: Handle to the window (widget) to be queried. | |
2317 * flags: If this parameter is DW_CRA_SELECTED it will only | |
2318 * return items that are currently selected. Otherwise | |
2319 * it will return all records in the container. | |
2320 */ | |
2321 char * API dw_container_query_next(HWND handle, unsigned long flags) | |
2322 { | |
2323 NSLog(@"dw_container_query_next() unimplemented\n"); | |
2324 return NULL; | |
2325 } | |
2326 | |
2327 /* | |
2328 * Cursors the item with the text speficied, and scrolls to that item. | |
2329 * Parameters: | |
2330 * handle: Handle to the window (widget) to be queried. | |
2331 * text: Text usually returned by dw_container_query(). | |
2332 */ | |
2333 void API dw_container_cursor(HWND handle, char *text) | |
2334 { | |
2335 NSLog(@"dw_container_cursor() unimplemented\n"); | |
2336 } | |
2337 | |
2338 /* | |
2339 * Deletes the item with the text speficied. | |
2340 * Parameters: | |
2341 * handle: Handle to the window (widget). | |
2342 * text: Text usually returned by dw_container_query(). | |
2343 */ | |
2344 void API dw_container_delete_row(HWND handle, char *text) | |
2345 { | |
2346 NSLog(@"dw_container_delete_row() unimplemented\n"); | |
2347 } | |
2348 | |
2349 /* | |
2350 * Optimizes the column widths so that all data is visible. | |
2351 * Parameters: | |
2352 * handle: Handle to the window (widget) to be optimized. | |
2353 */ | |
2354 void API dw_container_optimize(HWND handle) | |
2355 { | |
2356 NSLog(@"dw_container_optimize() unimplemented\n"); | |
2357 } | |
2358 | |
2359 /* | |
2360 * Inserts an icon into the taskbar. | |
2361 * Parameters: | |
2362 * handle: Window handle that will handle taskbar icon messages. | |
2363 * icon: Icon handle to display in the taskbar. | |
2364 * bubbletext: Text to show when the mouse is above the icon. | |
2365 */ | |
2366 void API dw_taskbar_insert(HWND handle, unsigned long icon, char *bubbletext) | |
2367 { | |
2368 NSLog(@"dw_taskbar_insert() unimplemented\n"); | |
2369 } | |
2370 | |
2371 /* | |
2372 * Deletes an icon from the taskbar. | |
2373 * Parameters: | |
2374 * handle: Window handle that was used with dw_taskbar_insert(). | |
2375 * icon: Icon handle that was used with dw_taskbar_insert(). | |
2376 */ | |
2377 void API dw_taskbar_delete(HWND handle, unsigned long icon) | |
2378 { | |
2379 NSLog(@"dw_taskbar_delete() unimplemented\n"); | |
2380 } | |
2381 | |
2382 /* | |
2383 * Obtains an icon from a module (or header in GTK). | |
2384 * Parameters: | |
2385 * module: Handle to module (DLL) in OS/2 and Windows. | |
2386 * id: A unsigned long id int the resources on OS/2 and | |
2387 * Windows, on GTK this is converted to a pointer | |
2388 * to an embedded XPM. | |
2389 */ | |
2390 unsigned long API dw_icon_load(unsigned long module, unsigned long id) | |
2391 { | |
2392 NSLog(@"dw_icon_load() unimplemented\n"); | |
2393 return 0; | |
2394 } | |
2395 | |
2396 /* | |
2397 * Obtains an icon from a file. | |
2398 * Parameters: | |
2399 * filename: Name of the file, omit extention to have | |
2400 * DW pick the appropriate file extension. | |
2401 * (ICO on OS/2 or Windows, XPM on Unix) | |
2402 */ | |
2403 unsigned long API dw_icon_load_from_file(char *filename) | |
2404 { | |
2405 NSLog(@"dw_icon_load_from_file() unimplemented\n"); | |
2406 return 0; | |
2407 } | |
2408 | |
2409 /* | |
2410 * Obtains an icon from data | |
2411 * Parameters: | |
2412 * filename: Name of the file, omit extention to have | |
2413 * DW pick the appropriate file extension. | |
2414 * (ICO on OS/2 or Windows, XPM on Unix) | |
2415 */ | |
2416 unsigned long API dw_icon_load_from_data(char *data, int len) | |
2417 { | |
2418 NSLog(@"dw_icon_load_from_data() unimplemented\n"); | |
2419 return 0; | |
2420 } | |
2421 | |
2422 /* | |
2423 * Frees a loaded resource in OS/2 and Windows. | |
2424 * Parameters: | |
2425 * handle: Handle to icon returned by dw_icon_load(). | |
2426 */ | |
2427 void API dw_icon_free(unsigned long handle) | |
2428 { | |
2429 NSLog(@"dw_icon_free() unimplemented\n"); | |
2430 } | |
2431 | |
2432 /* | |
2433 * Create a new MDI Frame to be packed. | |
2434 * Parameters: | |
2435 * id: An ID to be used with dw_window_from_id or 0L. | |
2436 */ | |
2437 HWND API dw_mdi_new(unsigned long id) | |
2438 { | |
2439 NSLog(@"dw_mdi_new() unimplemented\n"); | |
2440 return HWND_DESKTOP; | |
2441 } | |
2442 | |
2443 /* | |
2444 * Creates a splitbar window (widget) with given parameters. | |
2445 * Parameters: | |
2446 * type: Value can be DW_VERT or DW_HORZ. | |
2447 * topleft: Handle to the window to be top or left. | |
2448 * bottomright: Handle to the window to be bottom or right. | |
2449 * Returns: | |
2450 * A handle to a splitbar window or NULL on failure. | |
2451 */ | |
2452 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id) | |
2453 { | |
2454 NSLog(@"dw_splitbar_new() unimplemented\n"); | |
2455 return HWND_DESKTOP; | |
2456 } | |
2457 | |
2458 /* | |
2459 * Sets the position of a splitbar (pecentage). | |
2460 * Parameters: | |
2461 * handle: The handle to the splitbar returned by dw_splitbar_new(). | |
2462 */ | |
2463 void API dw_splitbar_set(HWND handle, float percent) | |
2464 { | |
2465 NSLog(@"dw_splitbar_set() unimplemented\n"); | |
2466 } | |
2467 | |
2468 /* | |
2469 * Gets the position of a splitbar (pecentage). | |
2470 * Parameters: | |
2471 * handle: The handle to the splitbar returned by dw_splitbar_new(). | |
2472 */ | |
2473 float API dw_splitbar_get(HWND handle) | |
2474 { | |
2475 NSLog(@"dw_splitbar_get() unimplemented\n"); | |
2476 return 0.0; | |
2477 } | |
2478 | |
2479 /* | |
2480 * Create a bitmap object to be packed. | |
2481 * Parameters: | |
2482 * id: An ID to be used with dw_window_from_id() or 0L. | |
2483 */ | |
2484 HWND API dw_bitmap_new(ULONG id) | |
2485 { | |
2486 NSLog(@"dw_bitmap_new() unimplemented\n"); | |
2487 return HWND_DESKTOP; | |
2488 } | |
2489 | |
2490 /* | |
2491 * Creates a pixmap with given parameters. | |
2492 * Parameters: | |
2493 * handle: Window handle the pixmap is associated with. | |
2494 * width: Width of the pixmap in pixels. | |
2495 * height: Height of the pixmap in pixels. | |
2496 * depth: Color depth of the pixmap. | |
2497 * Returns: | |
2498 * A handle to a pixmap or NULL on failure. | |
2499 */ | |
2500 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) | |
2501 { | |
2502 NSLog(@"dw_pixmap_new() unimplemented\n"); | |
2503 return HWND_DESKTOP; | |
2504 } | |
2505 | |
2506 /* | |
2507 * Creates a pixmap from a file. | |
2508 * Parameters: | |
2509 * handle: Window handle the pixmap is associated with. | |
2510 * filename: Name of the file, omit extention to have | |
2511 * DW pick the appropriate file extension. | |
2512 * (BMP on OS/2 or Windows, XPM on Unix) | |
2513 * Returns: | |
2514 * A handle to a pixmap or NULL on failure. | |
2515 */ | |
2516 HPIXMAP API dw_pixmap_new_from_file(HWND handle, char *filename) | |
2517 { | |
2518 NSLog(@"dw_pixmap_new_from_file() unimplemented\n"); | |
2519 return HWND_DESKTOP; | |
2520 } | |
2521 | |
2522 /* | |
2523 * Creates a pixmap from memory. | |
2524 * Parameters: | |
2525 * handle: Window handle the pixmap is associated with. | |
2526 * data: Source of the image data | |
2527 * (BMP on OS/2 or Windows, XPM on Unix) | |
2528 * le: length of data | |
2529 * Returns: | |
2530 * A handle to a pixmap or NULL on failure. | |
2531 */ | |
2532 HPIXMAP API dw_pixmap_new_from_data(HWND handle, char *data, int len) | |
2533 { | |
2534 NSLog(@"dw_pixmap_new_from_data() unimplemented\n"); | |
2535 return HWND_DESKTOP; | |
2536 } | |
2537 | |
2538 /* | |
2539 * Creates a bitmap mask for rendering bitmaps with transparent backgrounds | |
2540 */ | |
2541 void API dw_pixmap_set_transparent_color( HPIXMAP pixmap, ULONG color ) | |
2542 { | |
2543 NSLog(@"dw_pixmap_set_transparent_color() unimplemented\n"); | |
2544 } | |
2545 | |
2546 /* | |
2547 * Creates a pixmap from internal resource graphic specified by id. | |
2548 * Parameters: | |
2549 * handle: Window handle the pixmap is associated with. | |
2550 * id: Resource ID associated with requested pixmap. | |
2551 * Returns: | |
2552 * A handle to a pixmap or NULL on failure. | |
2553 */ | |
2554 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG id) | |
2555 { | |
2556 NSLog(@"dw_pixmap_grab() unimplemented\n"); | |
2557 return HWND_DESKTOP; | |
2558 } | |
2559 | |
2560 /* | |
2561 * Destroys an allocated pixmap. | |
2562 * Parameters: | |
2563 * pixmap: Handle to a pixmap returned by | |
2564 * dw_pixmap_new.. | |
2565 */ | |
2566 void API dw_pixmap_destroy(HPIXMAP pixmap) | |
2567 { | |
2568 NSLog(@"dw_pixmap_destroy() unimplemented\n"); | |
2569 } | |
2570 | |
2571 /* | |
2572 * Copies from one item to another. | |
2573 * Parameters: | |
2574 * dest: Destination window handle. | |
2575 * destp: Destination pixmap. (choose only one). | |
2576 * xdest: X coordinate of destination. | |
2577 * ydest: Y coordinate of destination. | |
2578 * width: Width of area to copy. | |
2579 * height: Height of area to copy. | |
2580 * src: Source window handle. | |
2581 * srcp: Source pixmap. (choose only one). | |
2582 * xsrc: X coordinate of source. | |
2583 * ysrc: Y coordinate of source. | |
2584 */ | |
2585 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) | |
2586 { | |
2587 NSLog(@"dw_pixmap_bitblt() unimplemented\n"); | |
2588 } | |
2589 | |
2590 /* | |
2591 * Create a new static text window (widget) to be packed. | |
2592 * Not available under OS/2, eCS | |
2593 * Parameters: | |
2594 * text: The text to be display by the static text widget. | |
2595 * id: An ID to be used with dw_window_from_id() or 0L. | |
2596 */ | |
2597 HWND API dw_calendar_new(ULONG id) | |
2598 { | |
2599 NSLog(@"dw_calendar_new() unimplemented\n"); | |
2600 return HWND_DESKTOP; | |
2601 } | |
2602 | |
2603 /* | |
2604 * Sets the current date of a calendar | |
2605 * Parameters: | |
2606 * handle: The handle to the calendar returned by dw_calendar_new(). | |
2607 * year... | |
2608 */ | |
2609 void dw_calendar_set_date(HWND handle, unsigned int year, unsigned int month, unsigned int day) | |
2610 { | |
2611 NSLog(@"dw_calendar_set_date() unimplemented\n"); | |
2612 } | |
2613 | |
2614 /* | |
2615 * Gets the position of a splitbar (pecentage). | |
2616 * Parameters: | |
2617 * handle: The handle to the splitbar returned by dw_splitbar_new(). | |
2618 */ | |
2619 void dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day) | |
2620 { | |
2621 NSLog(@"dw_calendar_get_date() unimplemented\n"); | |
2622 } | |
2623 | |
2624 /* | |
2625 * Causes the embedded HTML widget to take action. | |
2626 * Parameters: | |
2627 * handle: Handle to the window. | |
2628 * action: One of the DW_HTML_* constants. | |
2629 */ | |
2630 void API dw_html_action(HWND handle, int action) | |
2631 { | |
2632 NSLog(@"dw_html_action() unimplemented\n"); | |
2633 } | |
2634 | |
2635 /* | |
2636 * Render raw HTML code in the embedded HTML widget.. | |
2637 * Parameters: | |
2638 * handle: Handle to the window. | |
2639 * string: String buffer containt HTML code to | |
2640 * be rendered. | |
2641 * Returns: | |
2642 * 0 on success. | |
2643 */ | |
2644 int API dw_html_raw(HWND handle, char *string) | |
2645 { | |
2646 WebView *html = handle; | |
2647 [[html mainFrame] loadHTMLString:[ NSString stringWithUTF8String:string ] baseURL:nil]; | |
2648 return 0; | |
2649 } | |
2650 | |
2651 /* | |
2652 * Render file or web page in the embedded HTML widget.. | |
2653 * Parameters: | |
2654 * handle: Handle to the window. | |
2655 * url: Universal Resource Locator of the web or | |
2656 * file object to be rendered. | |
2657 * Returns: | |
2658 * 0 on success. | |
2659 */ | |
2660 int API dw_html_url(HWND handle, char *url) | |
2661 { | |
2662 WebView *html = handle; | |
2663 [[html mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[ NSString stringWithUTF8String:url ]]]]; | |
2664 return 0; | |
2665 } | |
2666 | |
2667 /* | |
2668 * Create a new HTML window (widget) to be packed. | |
2669 * Not available under OS/2, eCS | |
2670 * Parameters: | |
2671 * text: The default text to be in the entryfield widget. | |
2672 * id: An ID to be used with dw_window_from_id() or 0L. | |
2673 */ | |
2674 HWND API dw_html_new(unsigned long id) | |
2675 { | |
2676 WebView *web = [[WebView alloc] init]; | |
2677 return web; | |
2678 } | |
2679 | |
2680 /* | |
2681 * Call a function from the window (widget)'s context. | |
2682 * Parameters: | |
2683 * handle: Window handle of the widget. | |
2684 * function: Function pointer to be called. | |
2685 * data: Pointer to the data to be passed to the function. | |
2686 */ | |
2687 void API dw_window_function(HWND handle, void *function, void *data) | |
2688 { | |
2689 NSLog(@"dw_window_function() unimplemented\n"); | |
2690 } | |
2691 | |
2692 /* | |
2693 * Returns the current X and Y coordinates of the mouse pointer. | |
2694 * Parameters: | |
2695 * x: Pointer to variable to store X coordinate. | |
2696 * y: Pointer to variable to store Y coordinate. | |
2697 */ | |
2698 void API dw_pointer_query_pos(long *x, long *y) | |
2699 { | |
2700 NSPoint mouseLoc; | |
2701 mouseLoc = [NSEvent mouseLocation]; | |
2702 if(x) | |
2703 { | |
2704 *x = mouseLoc.x; | |
2705 } | |
2706 if(y) | |
2707 { | |
2708 *y = mouseLoc.y; | |
2709 } | |
2710 } | |
2711 | |
2712 /* | |
2713 * Sets the X and Y coordinates of the mouse pointer. | |
2714 * Parameters: | |
2715 * x: X coordinate. | |
2716 * y: Y coordinate. | |
2717 */ | |
2718 void API dw_pointer_set_pos(long x, long y) | |
2719 { | |
2720 NSLog(@"dw_pointer_set_pos() unimplemented\n"); | |
2721 } | |
2722 | |
2723 /* | |
2724 * Create a menu object to be popped up. | |
2725 * Parameters: | |
2726 * id: An ID to be used for getting the resource from the | |
2727 * resource file. | |
2728 */ | |
2729 HMENUI API dw_menu_new(ULONG id) | |
2730 { | |
2731 NSMenu *menu = [[[NSMenu alloc] initWithTitle:@"Apple"] autorelease]; | |
2732 return menu; | |
2733 } | |
2734 | |
2735 /* | |
2736 * Create a menubar on a window. | |
2737 * Parameters: | |
2738 * location: Handle of a window frame to be attached to. | |
2739 */ | |
2740 HMENUI API dw_menubar_new(HWND location) | |
2741 { | |
2742 NSLog(@"dw_menubar_new() unimplemented\n"); | |
2743 return HWND_DESKTOP; | |
2744 } | |
2745 | |
2746 /* | |
2747 * Destroys a menu created with dw_menubar_new or dw_menu_new. | |
2748 * Parameters: | |
2749 * menu: Handle of a menu. | |
2750 */ | |
2751 void API dw_menu_destroy(HMENUI *menu) | |
2752 { | |
2753 NSMenu *thismenu = *menu; | |
2754 [thismenu dealloc]; | |
2755 } | |
2756 | |
2757 /* | |
2758 * Pops up a context menu at given x and y coordinates. | |
2759 * Parameters: | |
2760 * menu: The handle the the existing menu. | |
2761 * parent: Handle to the window initiating the popup. | |
2762 * x: X coordinate. | |
2763 * y: Y coordinate. | |
2764 */ | |
2765 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) | |
2766 { | |
2767 NSMenu *thismenu = (NSMenu *)menu; | |
2768 NSView *view = parent; | |
2769 NSEvent* fake = [[NSEvent alloc] | |
2770 mouseEventWithType:NSLeftMouseDown | |
2771 location:NSMakePoint(x,y) | |
2772 modifierFlags:0 | |
2773 timestamp:1 | |
2774 windowNumber:[[view window] windowNumber] | |
2775 context:[NSGraphicsContext currentContext] | |
2776 eventNumber:1 | |
2777 clickCount:1 | |
2778 pressure:0.0]; | |
2779 [NSMenu popUpContextMenu:thismenu withEvent:fake forView:view]; | |
2780 } | |
2781 | |
2782 char _removetilde(char *dest, char *src) | |
2783 { | |
2784 int z, cur=0; | |
2785 char accel = '\0'; | |
2786 | |
2787 for(z=0;z<strlen(src);z++) | |
2788 { | |
2789 if(src[z] != '~') | |
2790 { | |
2791 dest[cur] = src[z]; | |
2792 cur++; | |
2793 } | |
2794 else | |
2795 { | |
2796 dest[cur] = '_'; | |
2797 accel = src[z+1]; | |
2798 cur++; | |
2799 } | |
2800 } | |
2801 dest[cur] = 0; | |
2802 return accel; | |
2803 } | |
2804 | |
2805 /* | |
2806 * Adds a menuitem or submenu to an existing menu. | |
2807 * Parameters: | |
2808 * menu: The handle the the existing menu. | |
2809 * title: The title text on the menu item to be added. | |
2810 * id: An ID to be used for message passing. | |
2811 * flags: Extended attributes to set on the menu. | |
2812 * end: If TRUE memu is positioned at the end of the menu. | |
2813 * check: If TRUE menu is "check"able. | |
2814 * flags: Extended attributes to set on the menu. | |
2815 * submenu: Handle to an existing menu to be a submenu or NULL. | |
2816 */ | |
2817 HWND API dw_menu_append_item(HMENUI menux, char *title, ULONG id, ULONG flags, int end, int check, HMENUI submenu) | |
2818 { | |
2819 NSMenu *menu = menux; | |
2820 NSMenuItem *item = NULL; | |
2821 if(strlen(title) == 0) | |
2822 { | |
2823 [menu addItem:[NSMenuItem separatorItem]]; | |
2824 } | |
2825 else | |
2826 { | |
2827 char accel[2]; | |
2828 char *newtitle = malloc(strlen(title)+1); | |
2829 | |
2830 accel[0] = _removetilde(newtitle, title); | |
2831 accel[1] = 0; | |
2832 | |
2833 item = [menu addItemWithTitle:[ NSString stringWithUTF8String:newtitle ] | |
2834 action:NULL | |
2835 keyEquivalent:[ NSString stringWithUTF8String:accel ]]; | |
2836 free(newtitle); | |
2837 return item; | |
2838 } | |
2839 return item; | |
2840 } | |
2841 | |
2842 /* | |
2843 * Sets the state of a menu item check. | |
2844 * Deprecated; use dw_menu_item_set_state() | |
2845 * Parameters: | |
2846 * menu: The handle the the existing menu. | |
2847 * id: Menuitem id. | |
2848 * check: TRUE for checked FALSE for not checked. | |
2849 */ | |
2850 void API dw_menu_item_set_check(HMENUI menux, unsigned long id, int check) | |
2851 { | |
2852 NSLog(@"dw_menu_item_set_check() unimplemented\n"); | |
2853 } | |
2854 | |
2855 /* | |
2856 * Sets the state of a menu item. | |
2857 * Parameters: | |
2858 * menu: The handle to the existing menu. | |
2859 * id: Menuitem id. | |
2860 * flags: DW_MIS_ENABLED/DW_MIS_DISABLED | |
2861 * DW_MIS_CHECKED/DW_MIS_UNCHECKED | |
2862 */ | |
2863 void API dw_menu_item_set_state( HMENUI menux, unsigned long id, unsigned long state) | |
2864 { | |
2865 NSLog(@"dw_menu_item_set_state() unimplemented\n"); | |
2866 } | |
2867 | |
2868 /* | |
2869 * Create a notebook object to be packed. | |
2870 * Parameters: | |
2871 * id: An ID to be used for getting the resource from the | |
2872 * resource file. | |
2873 */ | |
2874 HWND API dw_notebook_new(ULONG id, int top) | |
2875 { | |
2876 NSLog(@"dw_notebook_new() unimplemented\n"); | |
2877 return HWND_DESKTOP; | |
2878 } | |
2879 | |
2880 /* | |
2881 * Adds a new page to specified notebook. | |
2882 * Parameters: | |
2883 * handle: Window (widget) handle. | |
2884 * flags: Any additional page creation flags. | |
2885 * front: If TRUE page is added at the beginning. | |
2886 */ | |
2887 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front) | |
2888 { | |
2889 NSLog(@"dw_notebook_page_new() unimplemented\n"); | |
2890 return 0; | |
2891 } | |
2892 | |
2893 /* | |
2894 * Remove a page from a notebook. | |
2895 * Parameters: | |
2896 * handle: Handle to the notebook widget. | |
2897 * pageid: ID of the page to be destroyed. | |
2898 */ | |
2899 void API dw_notebook_page_destroy(HWND handle, unsigned int pageid) | |
2900 { | |
2901 NSLog(@"dw_notebook_page_destroy() unimplemented\n"); | |
2902 } | |
2903 | |
2904 /* | |
2905 * Queries the currently visible page ID. | |
2906 * Parameters: | |
2907 * handle: Handle to the notebook widget. | |
2908 */ | |
2909 unsigned long API dw_notebook_page_get(HWND handle) | |
2910 { | |
2911 NSLog(@"dw_notebook_page_get() unimplemented\n"); | |
2912 return 0; | |
2913 } | |
2914 | |
2915 /* | |
2916 * Sets the currently visibale page ID. | |
2917 * Parameters: | |
2918 * handle: Handle to the notebook widget. | |
2919 * pageid: ID of the page to be made visible. | |
2920 */ | |
2921 void API dw_notebook_page_set(HWND handle, unsigned int pageid) | |
2922 { | |
2923 NSLog(@"dw_notebook_page_set() unimplemented\n"); | |
2924 } | |
2925 | |
2926 /* | |
2927 * Sets the text on the specified notebook tab. | |
2928 * Parameters: | |
2929 * handle: Notebook handle. | |
2930 * pageid: Page ID of the tab to set. | |
2931 * text: Pointer to the text to set. | |
2932 */ | |
2933 void API dw_notebook_page_set_text(HWND handle, ULONG pageid, char *text) | |
2934 { | |
2935 NSLog(@"dw_notebook_page_set_text() unimplemented\n"); | |
2936 } | |
2937 | |
2938 /* | |
2939 * Sets the text on the specified notebook tab status area. | |
2940 * Parameters: | |
2941 * handle: Notebook handle. | |
2942 * pageid: Page ID of the tab to set. | |
2943 * text: Pointer to the text to set. | |
2944 */ | |
2945 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text) | |
2946 { | |
2947 NSLog(@"dw_notebook_page_set_status_text() unimplemented\n"); | |
2948 } | |
2949 | |
2950 /* | |
2951 * Packs the specified box into the notebook page. | |
2952 * Parameters: | |
2953 * handle: Handle to the notebook to be packed. | |
2954 * pageid: Page ID in the notebook which is being packed. | |
2955 * page: Box handle to be packed. | |
2956 */ | |
2957 void API dw_notebook_pack(HWND handle, ULONG pageid, HWND page) | |
2958 { | |
2959 NSLog(@"dw_notebook_pack() unimplemented\n"); | |
2960 } | |
2961 | |
2962 /* | |
2963 * Create a new Window Frame. | |
2964 * Parameters: | |
2965 * owner: The Owner's window handle or HWND_DESKTOP. | |
2966 * title: The Window title. | |
2967 * flStyle: Style flags, see the PM reference. | |
2968 */ | |
2969 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) | |
2970 { | |
2971 NSRect frame = NSMakeRect(1,1,1,1); | |
2972 NSWindow *window = [[NSWindow alloc] | |
2973 initWithContentRect:frame | |
2974 styleMask:flStyle | |
2975 backing:NSBackingStoreBuffered | |
2976 defer:false]; | |
2977 | |
2978 [window setTitle:[ NSString stringWithUTF8String:title ]]; | |
2979 | |
2980 DWView *view = [[DWView alloc] init]; | |
2981 | |
2982 [window setContentView:view]; | |
2983 [window setDelegate:view]; | |
2984 [window makeKeyAndOrderFront:nil]; | |
2985 | |
2986 return (HWND)window; | |
2987 } | |
2988 | |
2989 /* | |
2990 * Changes the appearance of the mouse pointer. | |
2991 * Parameters: | |
2992 * handle: Handle to widget for which to change. | |
2993 * cursortype: ID of the pointer you want. | |
2994 */ | |
2995 void API dw_window_set_pointer(HWND handle, int pointertype) | |
2996 { | |
2997 NSLog(@"dw_window_set_pointer() unimplemented\n"); | |
2998 } | |
2999 | |
3000 /* | |
3001 * Makes the window visible. | |
3002 * Parameters: | |
3003 * handle: The window handle to make visible. | |
3004 */ | |
3005 int API dw_window_show(HWND handle) | |
3006 { | |
3007 NSObject *object = handle; | |
3008 | |
3009 if([ object isKindOfClass:[ NSWindow class ] ]) | |
3010 { | |
3011 NSWindow *window = handle; | |
3012 if([window isMiniaturized]) | |
3013 { | |
3014 [window deminiaturize:nil]; | |
3015 } | |
3016 [[window contentView] windowResized:nil]; | |
3017 } | |
3018 return 0; | |
3019 } | |
3020 | |
3021 /* | |
3022 * Makes the window invisible. | |
3023 * Parameters: | |
3024 * handle: The window handle to make visible. | |
3025 */ | |
3026 int API dw_window_hide(HWND handle) | |
3027 { | |
3028 NSLog(@"dw_window_hide() unimplemented\n"); | |
3029 return 0; | |
3030 } | |
3031 | |
3032 /* | |
3033 * Sets the colors used by a specified window (widget) handle. | |
3034 * Parameters: | |
3035 * handle: The window (widget) handle. | |
3036 * fore: Foreground color in DW_RGB format or a default color index. | |
3037 * back: Background color in DW_RGB format or a default color index. | |
3038 */ | |
3039 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back) | |
3040 { | |
3041 NSLog(@"dw_window_set_color() unimplemented\n"); | |
3042 return -1; | |
3043 } | |
3044 | |
3045 /* | |
3046 * Sets the font used by a specified window (widget) handle. | |
3047 * Parameters: | |
3048 * handle: The window (widget) handle. | |
3049 * border: Size of the window border in pixels. | |
3050 */ | |
3051 int API dw_window_set_border(HWND handle, int border) | |
3052 { | |
3053 NSLog(@"dw_window_set_border() unimplemented\n"); | |
3054 return 0; | |
3055 } | |
3056 | |
3057 /* | |
3058 * Sets the style of a given window (widget). | |
3059 * Parameters: | |
3060 * handle: Window (widget) handle. | |
3061 * width: New width in pixels. | |
3062 * height: New height in pixels. | |
3063 */ | |
3064 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask) | |
3065 { | |
3066 NSLog(@"dw_window_set_style() unimplemented\n"); | |
3067 } | |
3068 | |
3069 /* | |
3070 * Sets the default focus item for a window/dialog. | |
3071 * Parameters: | |
3072 * window: Toplevel window or dialog. | |
3073 * defaultitem: Handle to the dialog item to be default. | |
3074 */ | |
3075 void API dw_window_default(HWND window, HWND defaultitem) | |
3076 { | |
3077 NSLog(@"dw_window_default() unimplemented\n"); | |
3078 } | |
3079 | |
3080 /* | |
3081 * Sets window to click the default dialog item when an ENTER is pressed. | |
3082 * Parameters: | |
3083 * window: Window (widget) to look for the ENTER press. | |
3084 * next: Window (widget) to move to next (or click) | |
3085 */ | |
3086 void API dw_window_click_default(HWND window, HWND next) | |
3087 { | |
3088 NSLog(@"dw_window_click_default() unimplemented\n"); | |
3089 } | |
3090 | |
3091 /* | |
3092 * Captures the mouse input to this window. | |
3093 * Parameters: | |
3094 * handle: Handle to receive mouse input. | |
3095 */ | |
3096 void API dw_window_capture(HWND handle) | |
3097 { | |
3098 NSLog(@"dw_window_capture() unimplemented\n"); | |
3099 } | |
3100 | |
3101 /* | |
3102 * Releases previous mouse capture. | |
3103 */ | |
3104 void API dw_window_release(void) | |
3105 { | |
3106 NSLog(@"dw_window_release() unimplemented\n"); | |
3107 } | |
3108 | |
3109 /* | |
3110 * Tracks this window movement. | |
3111 * Parameters: | |
3112 * handle: Handle to frame to be tracked. | |
3113 */ | |
3114 void API dw_window_track(HWND handle) | |
3115 { | |
3116 NSLog(@"dw_window_track() unimplemented\n"); | |
3117 } | |
3118 | |
3119 /* | |
3120 * Changes a window's parent to newparent. | |
3121 * Parameters: | |
3122 * handle: The window handle to destroy. | |
3123 * newparent: The window's new parent window. | |
3124 */ | |
3125 void API dw_window_reparent(HWND handle, HWND newparent) | |
3126 { | |
3127 /* Is this even possible? */ | |
3128 NSLog(@"dw_window_reparent() unimplemented\n"); | |
3129 } | |
3130 | |
3131 /* | |
3132 * Sets the font used by a specified window (widget) handle. | |
3133 * Parameters: | |
3134 * handle: The window (widget) handle. | |
3135 * fontname: Name and size of the font in the form "size.fontname" | |
3136 */ | |
3137 int API dw_window_set_font(HWND handle, char *fontname) | |
3138 { | |
3139 NSLog(@"dw_window_set_font() unimplemented\n"); | |
3140 return 0; | |
3141 } | |
3142 | |
3143 /* | |
3144 * Destroys a window and all of it's children. | |
3145 * Parameters: | |
3146 * handle: The window handle to destroy. | |
3147 */ | |
3148 int API dw_window_destroy(HWND handle) | |
3149 { | |
3150 NSObject *object = handle; | |
3151 | |
3152 if([ object isKindOfClass:[ NSWindow class ] ]) | |
3153 { | |
3154 NSWindow *window = handle; | |
3155 [window close]; | |
3156 } | |
3157 return 0; | |
3158 } | |
3159 | |
3160 /* | |
3161 * Gets the text used for a given window. | |
3162 * Parameters: | |
3163 * handle: Handle to the window. | |
3164 * Returns: | |
3165 * text: The text associsated with a given window. | |
3166 */ | |
3167 char * API dw_window_get_text(HWND handle) | |
3168 { | |
3169 NSObject *object = handle; | |
3170 | |
3171 if([ object isKindOfClass:[ NSControl class ] ]) | |
3172 { | |
3173 NSControl *control = handle; | |
3174 NSString *nsstr = [ control stringValue]; | |
3175 | |
3176 return strdup([ nsstr UTF8String ]); | |
3177 } | |
3178 else if([ object isKindOfClass:[ NSWindow class ] ]) | |
3179 { | |
3180 NSWindow *window = handle; | |
3181 NSString *nsstr = [ window title]; | |
3182 | |
3183 return strdup([ nsstr UTF8String ]); | |
3184 } | |
3185 return NULL; | |
3186 } | |
3187 | |
3188 /* | |
3189 * Sets the text used for a given window. | |
3190 * Parameters: | |
3191 * handle: Handle to the window. | |
3192 * text: The text associsated with a given window. | |
3193 */ | |
3194 void API dw_window_set_text(HWND handle, char *text) | |
3195 { | |
3196 NSObject *object = handle; | |
3197 | |
3198 if([ object isKindOfClass:[ NSControl class ] ]) | |
3199 { | |
3200 NSControl *control = handle; | |
3201 [control setStringValue:[ NSString stringWithUTF8String:text ]]; | |
3202 } | |
3203 else if([ object isKindOfClass:[ NSWindow class ] ]) | |
3204 { | |
3205 NSWindow *window = handle; | |
3206 [window setTitle:[ NSString stringWithUTF8String:text ]]; | |
3207 } | |
3208 } | |
3209 | |
3210 /* | |
3211 * Disables given window (widget). | |
3212 * Parameters: | |
3213 * handle: Handle to the window. | |
3214 */ | |
3215 void API dw_window_disable(HWND handle) | |
3216 { | |
3217 NSObject *object = handle; | |
3218 if([ object isKindOfClass:[ NSControl class ] ]) | |
3219 { | |
3220 NSControl *control = handle; | |
3221 [control setEnabled:NO]; | |
3222 } | |
3223 } | |
3224 | |
3225 /* | |
3226 * Enables given window (widget). | |
3227 * Parameters: | |
3228 * handle: Handle to the window. | |
3229 */ | |
3230 void API dw_window_enable(HWND handle) | |
3231 { | |
3232 NSObject *object = handle; | |
3233 if([ object isKindOfClass:[ NSControl class ] ]) | |
3234 { | |
3235 NSControl *control = handle; | |
3236 [control setEnabled:YES]; | |
3237 } | |
3238 } | |
3239 | |
3240 /* | |
3241 * Sets the bitmap used for a given static window. | |
3242 * Parameters: | |
3243 * handle: Handle to the window. | |
3244 * id: An ID to be used to specify the icon, | |
3245 * (pass 0 if you use the filename param) | |
3246 * filename: a path to a file (Bitmap on OS/2 or | |
3247 * Windows and a pixmap on Unix, pass | |
3248 * NULL if you use the id param) | |
3249 */ | |
3250 void API dw_window_set_bitmap_from_data(HWND handle, unsigned long id, char *data, int len) | |
3251 { | |
3252 NSLog(@"dw_window_set_bitmap_from_data() unimplemented\n"); | |
3253 } | |
3254 | |
3255 /* | |
3256 * Sets the bitmap used for a given static window. | |
3257 * Parameters: | |
3258 * handle: Handle to the window. | |
3259 * id: An ID to be used to specify the icon, | |
3260 * (pass 0 if you use the filename param) | |
3261 * filename: a path to a file (Bitmap on OS/2 or | |
3262 * Windows and a pixmap on Unix, pass | |
3263 * NULL if you use the id param) | |
3264 */ | |
3265 void API dw_window_set_bitmap(HWND handle, unsigned long id, char *filename) | |
3266 { | |
3267 NSLog(@"dw_window_set_bitmap() unimplemented\n"); | |
3268 } | |
3269 | |
3270 /* | |
3271 * Sets the icon used for a given window. | |
3272 * Parameters: | |
3273 * handle: Handle to the window. | |
3274 * id: An ID to be used to specify the icon. | |
3275 */ | |
3276 void API dw_window_set_icon(HWND handle, ULONG id) | |
3277 { | |
3278 NSLog(@"dw_window_set_icon() unimplemented\n"); | |
3279 } | |
3280 | |
3281 /* | |
3282 * Gets the child window handle with specified ID. | |
3283 * Parameters: | |
3284 * handle: Handle to the parent window. | |
3285 * id: Integer ID of the child. | |
3286 */ | |
3287 HWND API dw_window_from_id(HWND handle, int id) | |
3288 { | |
3289 NSObject *object = handle; | |
3290 NSView *view = handle; | |
3291 if([ object isKindOfClass:[ NSWindow class ] ]) | |
3292 { | |
3293 NSWindow *window = handle; | |
3294 view = [window contentView]; | |
3295 } | |
3296 return [view viewWithTag:id]; | |
3297 } | |
3298 | |
3299 /* | |
3300 * Minimizes or Iconifies a top-level window. | |
3301 * Parameters: | |
3302 * handle: The window handle to minimize. | |
3303 */ | |
3304 int API dw_window_minimize(HWND handle) | |
3305 { | |
3306 NSWindow *window = handle; | |
3307 [window miniaturize:nil]; | |
3308 return 0; | |
3309 } | |
3310 | |
3311 /* Causes entire window to be invalidated and redrawn. | |
3312 * Parameters: | |
3313 * handle: Toplevel window handle to be redrawn. | |
3314 */ | |
3315 void API dw_window_redraw(HWND handle) | |
3316 { | |
3317 NSWindow *window = handle; | |
3318 [window flushWindow]; | |
3319 } | |
3320 | |
3321 /* | |
3322 * Makes the window topmost. | |
3323 * Parameters: | |
3324 * handle: The window handle to make topmost. | |
3325 */ | |
3326 int API dw_window_raise(HWND handle) | |
3327 { | |
3328 NSWindow *window = handle; | |
3329 [window orderFront:nil]; | |
3330 return 0; | |
3331 } | |
3332 | |
3333 /* | |
3334 * Makes the window bottommost. | |
3335 * Parameters: | |
3336 * handle: The window handle to make bottommost. | |
3337 */ | |
3338 int API dw_window_lower(HWND handle) | |
3339 { | |
3340 NSWindow *window = handle; | |
3341 [window orderBack:nil]; | |
3342 return 0; | |
3343 } | |
3344 | |
3345 /* | |
3346 * Sets the size of a given window (widget). | |
3347 * Parameters: | |
3348 * handle: Window (widget) handle. | |
3349 * width: New width in pixels. | |
3350 * height: New height in pixels. | |
3351 */ | |
3352 void API dw_window_set_size(HWND handle, ULONG width, ULONG height) | |
3353 { | |
3354 NSObject *object = handle; | |
3355 NSSize size; | |
3356 size.width = width; | |
3357 size.height = height; | |
3358 | |
3359 if([ object isKindOfClass:[ NSWindow class ] ]) | |
3360 { | |
3361 NSWindow *window = handle; | |
3362 [window setContentSize:size]; | |
3363 } | |
3364 } | |
3365 | |
3366 /* | |
3367 * Sets the position of a given window (widget). | |
3368 * Parameters: | |
3369 * handle: Window (widget) handle. | |
3370 * x: X location from the bottom left. | |
3371 * y: Y location from the bottom left. | |
3372 */ | |
3373 void API dw_window_set_pos(HWND handle, LONG x, LONG y) | |
3374 { | |
3375 NSObject *object = handle; | |
3376 NSPoint point; | |
3377 point.x = x; | |
3378 point.y = y; | |
3379 | |
3380 if([ object isKindOfClass:[ NSWindow class ] ]) | |
3381 { | |
3382 NSWindow *window = handle; | |
3383 [window setFrameOrigin:point]; | |
3384 } | |
3385 } | |
3386 | |
3387 /* | |
3388 * Sets the position and size of a given window (widget). | |
3389 * Parameters: | |
3390 * handle: Window (widget) handle. | |
3391 * x: X location from the bottom left. | |
3392 * y: Y location from the bottom left. | |
3393 * width: Width of the widget. | |
3394 * height: Height of the widget. | |
3395 */ | |
3396 void API dw_window_set_pos_size(HWND handle, LONG x, LONG y, ULONG width, ULONG height) | |
3397 { | |
3398 dw_window_set_pos(handle, x, y); | |
3399 dw_window_set_size(handle, width, height); | |
3400 } | |
3401 | |
3402 /* | |
3403 * Gets the position and size of a given window (widget). | |
3404 * Parameters: | |
3405 * handle: Window (widget) handle. | |
3406 * x: X location from the bottom left. | |
3407 * y: Y location from the bottom left. | |
3408 * width: Width of the widget. | |
3409 * height: Height of the widget. | |
3410 */ | |
3411 void API dw_window_get_pos_size(HWND handle, LONG *x, LONG *y, ULONG *width, ULONG *height) | |
3412 { | |
3413 NSObject *object = handle; | |
3414 | |
3415 if([ object isKindOfClass:[ NSWindow class ] ]) | |
3416 { | |
3417 NSWindow *window = handle; | |
3418 NSRect rect = [window frame]; | |
3419 if(x) | |
3420 *x = rect.origin.x; | |
3421 if(y) | |
3422 *y = rect.origin.y; | |
3423 if(width) | |
3424 *width = rect.size.width; | |
3425 if(height) | |
3426 *height = rect.size.height; | |
3427 return; | |
3428 } | |
3429 } | |
3430 | |
3431 /* | |
3432 * Returns the width of the screen. | |
3433 */ | |
3434 int API dw_screen_width(void) | |
3435 { | |
3436 NSRect screenRect = [[NSScreen mainScreen] frame]; | |
3437 return screenRect.size.width; | |
3438 } | |
3439 | |
3440 /* | |
3441 * Returns the height of the screen. | |
3442 */ | |
3443 int API dw_screen_height(void) | |
3444 { | |
3445 NSRect screenRect = [[NSScreen mainScreen] frame]; | |
3446 return screenRect.size.height; | |
3447 } | |
3448 | |
3449 /* This should return the current color depth */ | |
3450 unsigned long API dw_color_depth_get(void) | |
3451 { | |
3452 NSWindowDepth screenDepth = [[NSScreen mainScreen] depth]; | |
3453 return NSBitsPerPixelFromDepth(screenDepth); | |
3454 } | |
3455 | |
3456 /* | |
3457 * Returns some information about the current operating environment. | |
3458 * Parameters: | |
3459 * env: Pointer to a DWEnv struct. | |
3460 */ | |
3461 void dw_environment_query(DWEnv *env) | |
3462 { | |
3463 struct utsname name; | |
3464 char tempbuf[100]; | |
3465 int len, z; | |
3466 | |
3467 uname(&name); | |
3468 strcpy(env->osName, name.sysname); | |
3469 strcpy(tempbuf, name.release); | |
3470 | |
3471 env->MajorBuild = env->MinorBuild = 0; | |
3472 | |
3473 len = strlen(tempbuf); | |
3474 | |
3475 strcpy(env->buildDate, __DATE__); | |
3476 strcpy(env->buildTime, __TIME__); | |
3477 env->DWMajorVersion = DW_MAJOR_VERSION; | |
3478 env->DWMinorVersion = DW_MINOR_VERSION; | |
3479 env->DWSubVersion = DW_SUB_VERSION; | |
3480 | |
3481 for(z=1;z<len;z++) | |
3482 { | |
3483 if(tempbuf[z] == '.') | |
3484 { | |
3485 tempbuf[z] = '\0'; | |
3486 env->MajorVersion = atoi(&tempbuf[z-1]); | |
3487 env->MinorVersion = atoi(&tempbuf[z+1]); | |
3488 return; | |
3489 } | |
3490 } | |
3491 env->MajorVersion = atoi(tempbuf); | |
3492 env->MinorVersion = 0; | |
3493 } | |
3494 | |
3495 /* | |
3496 * Emits a beep. | |
3497 * Parameters: | |
3498 * freq: Frequency. | |
3499 * dur: Duration. | |
3500 */ | |
3501 void API dw_beep(int freq, int dur) | |
3502 { | |
3503 NSLog(@"dw_beep() unimplemented\n"); | |
3504 } | |
3505 | |
3506 /* Call this after drawing to the screen to make sure | |
3507 * anything you have drawn is visible. | |
3508 */ | |
3509 void API dw_flush(void) | |
3510 { | |
3511 } | |
3512 | |
3513 /* | |
3514 * Add a named user data item to a window handle. | |
3515 * Parameters: | |
3516 * window: Window handle of signal to be called back. | |
3517 * dataname: A string pointer identifying which signal to be hooked. | |
3518 * data: User data to be passed to the handler function. | |
3519 */ | |
3520 void dw_window_set_data(HWND window, char *dataname, void *data) | |
3521 { | |
3522 NSLog(@"dw_window_set_data() unimplemented\n"); | |
3523 } | |
3524 | |
3525 /* | |
3526 * Gets a named user data item to a window handle. | |
3527 * Parameters: | |
3528 * window: Window handle of signal to be called back. | |
3529 * dataname: A string pointer identifying which signal to be hooked. | |
3530 * data: User data to be passed to the handler function. | |
3531 */ | |
3532 void *dw_window_get_data(HWND window, char *dataname) | |
3533 { | |
3534 NSLog(@"dw_window_get_data() unimplemented\n"); | |
3535 return NULL; | |
3536 } | |
3537 | |
3538 /* | |
3539 * Add a callback to a timer event. | |
3540 * Parameters: | |
3541 * interval: Milliseconds to delay between calls. | |
3542 * sigfunc: The pointer to the function to be used as the callback. | |
3543 * data: User data to be passed to the handler function. | |
3544 * Returns: | |
3545 * Timer ID for use with dw_timer_disconnect(), 0 on error. | |
3546 */ | |
3547 int API dw_timer_connect(int interval, void *sigfunc, void *data) | |
3548 { | |
3549 NSLog(@"dw_timer_connect() unimplemented\n"); | |
3550 if(sigfunc) | |
3551 { | |
3552 int timerid = 0; | |
3553 /* = WinStartTimer(dwhab, NULLHANDLE, 0, interval)*/ | |
3554 | |
3555 if(timerid) | |
3556 { | |
3557 _new_signal(0, HWND_DESKTOP, timerid, sigfunc, data); | |
3558 return timerid; | |
3559 } | |
3560 } | |
3561 return 0; | |
3562 } | |
3563 | |
3564 /* | |
3565 * Removes timer callback. | |
3566 * Parameters: | |
3567 * id: Timer ID returned by dw_timer_connect(). | |
3568 */ | |
3569 void API dw_timer_disconnect(int id) | |
3570 { | |
3571 SignalHandler *prev = NULL, *tmp = Root; | |
3572 NSLog(@"dw_timer_disconnect() unimplemented\n"); | |
3573 | |
3574 /* 0 is an invalid timer ID */ | |
3575 if(!id) | |
3576 return; | |
3577 | |
3578 /*WinStopTimer(dwhab, NULLHANDLE, id);*/ | |
3579 | |
3580 while(tmp) | |
3581 { | |
3582 if(tmp->id == id) | |
3583 { | |
3584 if(prev) | |
3585 { | |
3586 prev->next = tmp->next; | |
3587 free(tmp); | |
3588 tmp = prev->next; | |
3589 } | |
3590 else | |
3591 { | |
3592 Root = tmp->next; | |
3593 free(tmp); | |
3594 tmp = Root; | |
3595 } | |
3596 } | |
3597 else | |
3598 { | |
3599 prev = tmp; | |
3600 tmp = tmp->next; | |
3601 } | |
3602 } | |
3603 } | |
3604 | |
3605 /* | |
3606 * Add a callback to a window event. | |
3607 * Parameters: | |
3608 * window: Window handle of signal to be called back. | |
3609 * signame: A string pointer identifying which signal to be hooked. | |
3610 * sigfunc: The pointer to the function to be used as the callback. | |
3611 * data: User data to be passed to the handler function. | |
3612 */ | |
3613 void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) | |
3614 { | |
3615 ULONG message = 0, id = 0; | |
3616 | |
3617 if(window && signame && sigfunc) | |
3618 { | |
3619 if((message = _findsigmessage(signame)) != 0) | |
3620 { | |
3621 _new_signal(message, window, id, sigfunc, data); | |
3622 } | |
3623 } | |
3624 } | |
3625 | |
3626 /* | |
3627 * Removes callbacks for a given window with given name. | |
3628 * Parameters: | |
3629 * window: Window handle of callback to be removed. | |
3630 */ | |
3631 void API dw_signal_disconnect_by_name(HWND window, char *signame) | |
3632 { | |
3633 SignalHandler *prev = NULL, *tmp = Root; | |
3634 ULONG message; | |
3635 | |
3636 if(!window || !signame || (message = _findsigmessage(signame)) == 0) | |
3637 return; | |
3638 | |
3639 while(tmp) | |
3640 { | |
3641 if(tmp->window == window && tmp->message == message) | |
3642 { | |
3643 if(prev) | |
3644 { | |
3645 prev->next = tmp->next; | |
3646 free(tmp); | |
3647 tmp = prev->next; | |
3648 } | |
3649 else | |
3650 { | |
3651 Root = tmp->next; | |
3652 free(tmp); | |
3653 tmp = Root; | |
3654 } | |
3655 } | |
3656 else | |
3657 { | |
3658 prev = tmp; | |
3659 tmp = tmp->next; | |
3660 } | |
3661 } | |
3662 } | |
3663 | |
3664 /* | |
3665 * Removes all callbacks for a given window. | |
3666 * Parameters: | |
3667 * window: Window handle of callback to be removed. | |
3668 */ | |
3669 void API dw_signal_disconnect_by_window(HWND window) | |
3670 { | |
3671 SignalHandler *prev = NULL, *tmp = Root; | |
3672 | |
3673 while(tmp) | |
3674 { | |
3675 if(tmp->window == window) | |
3676 { | |
3677 if(prev) | |
3678 { | |
3679 prev->next = tmp->next; | |
3680 free(tmp); | |
3681 tmp = prev->next; | |
3682 } | |
3683 else | |
3684 { | |
3685 Root = tmp->next; | |
3686 free(tmp); | |
3687 tmp = Root; | |
3688 } | |
3689 } | |
3690 else | |
3691 { | |
3692 prev = tmp; | |
3693 tmp = tmp->next; | |
3694 } | |
3695 } | |
3696 } | |
3697 | |
3698 /* | |
3699 * Removes all callbacks for a given window with specified data. | |
3700 * Parameters: | |
3701 * window: Window handle of callback to be removed. | |
3702 * data: Pointer to the data to be compared against. | |
3703 */ | |
3704 void API dw_signal_disconnect_by_data(HWND window, void *data) | |
3705 { | |
3706 SignalHandler *prev = NULL, *tmp = Root; | |
3707 | |
3708 while(tmp) | |
3709 { | |
3710 if(tmp->window == window && tmp->data == data) | |
3711 { | |
3712 if(prev) | |
3713 { | |
3714 prev->next = tmp->next; | |
3715 free(tmp); | |
3716 tmp = prev->next; | |
3717 } | |
3718 else | |
3719 { | |
3720 Root = tmp->next; | |
3721 free(tmp); | |
3722 tmp = Root; | |
3723 } | |
3724 } | |
3725 else | |
3726 { | |
3727 prev = tmp; | |
3728 tmp = tmp->next; | |
3729 } | |
3730 } | |
3731 } | |
3732 | |
3733 void _my_strlwr(char *buf) | |
3734 { | |
3735 int z, len = strlen(buf); | |
3736 | |
3737 for(z=0;z<len;z++) | |
3738 { | |
3739 if(buf[z] >= 'A' && buf[z] <= 'Z') | |
3740 buf[z] -= 'A' - 'a'; | |
3741 } | |
3742 } | |
3743 | |
3744 /* Open a shared library and return a handle. | |
3745 * Parameters: | |
3746 * name: Base name of the shared library. | |
3747 * handle: Pointer to a module handle, | |
3748 * will be filled in with the handle. | |
3749 */ | |
3750 int dw_module_load(char *name, HMOD *handle) | |
3751 { | |
3752 int len; | |
3753 char *newname; | |
3754 char errorbuf[1024]; | |
3755 | |
3756 | |
3757 if(!handle) | |
3758 return -1; | |
3759 | |
3760 if((len = strlen(name)) == 0) | |
3761 return -1; | |
3762 | |
3763 /* Lenth + "lib" + ".dylib" + NULL */ | |
3764 newname = malloc(len + 10); | |
3765 | |
3766 if(!newname) | |
3767 return -1; | |
3768 | |
3769 sprintf(newname, "lib%s.dylib", name); | |
3770 _my_strlwr(newname); | |
3771 | |
3772 *handle = dlopen(newname, RTLD_NOW); | |
3773 if(*handle == NULL) | |
3774 { | |
3775 strncpy(errorbuf, dlerror(), 1024); | |
3776 printf("%s\n", errorbuf); | |
3777 sprintf(newname, "lib%s.dylib", name); | |
3778 *handle = dlopen(newname, RTLD_NOW); | |
3779 } | |
3780 | |
3781 free(newname); | |
3782 | |
3783 return (NULL == *handle) ? -1 : 0; | |
3784 } | |
3785 | |
3786 /* Queries the address of a symbol within open handle. | |
3787 * Parameters: | |
3788 * handle: Module handle returned by dw_module_load() | |
3789 * name: Name of the symbol you want the address of. | |
3790 * func: A pointer to a function pointer, to obtain | |
3791 * the address. | |
3792 */ | |
3793 int dw_module_symbol(HMOD handle, char *name, void**func) | |
3794 { | |
3795 if(!func || !name) | |
3796 return -1; | |
3797 | |
3798 if(strlen(name) == 0) | |
3799 return -1; | |
3800 | |
3801 *func = (void*)dlsym(handle, name); | |
3802 return (NULL == *func); | |
3803 } | |
3804 | |
3805 /* Frees the shared library previously opened. | |
3806 * Parameters: | |
3807 * handle: Module handle returned by dw_module_load() | |
3808 */ | |
3809 int dw_module_close(HMOD handle) | |
3810 { | |
3811 if(handle) | |
3812 return dlclose(handle); | |
3813 return 0; | |
3814 } | |
3815 | |
3816 /* | |
3817 * Returns the handle to an unnamed mutex semaphore. | |
3818 */ | |
3819 HMTX dw_mutex_new(void) | |
3820 { | |
3821 HMTX mutex = malloc(sizeof(pthread_mutex_t)); | |
3822 | |
3823 pthread_mutex_init(mutex, NULL); | |
3824 return mutex; | |
3825 } | |
3826 | |
3827 /* | |
3828 * Closes a semaphore created by dw_mutex_new(). | |
3829 * Parameters: | |
3830 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
3831 */ | |
3832 void dw_mutex_close(HMTX mutex) | |
3833 { | |
3834 if(mutex) | |
3835 { | |
3836 pthread_mutex_destroy(mutex); | |
3837 free(mutex); | |
3838 } | |
3839 } | |
3840 | |
3841 /* | |
3842 * Tries to gain access to the semaphore, if it can't it blocks. | |
3843 * Parameters: | |
3844 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
3845 */ | |
3846 void dw_mutex_lock(HMTX mutex) | |
3847 { | |
3848 pthread_mutex_lock(mutex); | |
3849 } | |
3850 | |
3851 /* | |
3852 * Reliquishes the access to the semaphore. | |
3853 * Parameters: | |
3854 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
3855 */ | |
3856 void dw_mutex_unlock(HMTX mutex) | |
3857 { | |
3858 pthread_mutex_unlock(mutex); | |
3859 } | |
3860 | |
3861 /* | |
3862 * Returns the handle to an unnamed event semaphore. | |
3863 */ | |
3864 HEV dw_event_new(void) | |
3865 { | |
3866 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event)); | |
3867 | |
3868 if(!eve) | |
3869 return NULL; | |
3870 | |
3871 /* We need to be careful here, mutexes on Linux are | |
3872 * FAST by default but are error checking on other | |
3873 * systems such as FreeBSD and OS/2, perhaps others. | |
3874 */ | |
3875 pthread_mutex_init (&(eve->mutex), NULL); | |
3876 pthread_mutex_lock (&(eve->mutex)); | |
3877 pthread_cond_init (&(eve->event), NULL); | |
3878 | |
3879 pthread_mutex_unlock (&(eve->mutex)); | |
3880 eve->alive = 1; | |
3881 eve->posted = 0; | |
3882 | |
3883 return eve; | |
3884 } | |
3885 | |
3886 /* | |
3887 * Resets a semaphore created by dw_event_new(). | |
3888 * Parameters: | |
3889 * eve: The handle to the event returned by dw_event_new(). | |
3890 */ | |
3891 int dw_event_reset (HEV eve) | |
3892 { | |
3893 if(!eve) | |
3894 return FALSE; | |
3895 | |
3896 pthread_mutex_lock (&(eve->mutex)); | |
3897 pthread_cond_broadcast (&(eve->event)); | |
3898 pthread_cond_init (&(eve->event), NULL); | |
3899 eve->posted = 0; | |
3900 pthread_mutex_unlock (&(eve->mutex)); | |
3901 return 0; | |
3902 } | |
3903 | |
3904 /* | |
3905 * Posts a semaphore created by dw_event_new(). Causing all threads | |
3906 * waiting on this event in dw_event_wait to continue. | |
3907 * Parameters: | |
3908 * eve: The handle to the event returned by dw_event_new(). | |
3909 */ | |
3910 int dw_event_post (HEV eve) | |
3911 { | |
3912 if(!eve) | |
3913 return FALSE; | |
3914 | |
3915 pthread_mutex_lock (&(eve->mutex)); | |
3916 pthread_cond_broadcast (&(eve->event)); | |
3917 eve->posted = 1; | |
3918 pthread_mutex_unlock (&(eve->mutex)); | |
3919 return 0; | |
3920 } | |
3921 | |
3922 /* | |
3923 * Waits on a semaphore created by dw_event_new(), until the | |
3924 * event gets posted or until the timeout expires. | |
3925 * Parameters: | |
3926 * eve: The handle to the event returned by dw_event_new(). | |
3927 */ | |
3928 int dw_event_wait(HEV eve, unsigned long timeout) | |
3929 { | |
3930 int rc; | |
3931 struct timeval now; | |
3932 struct timespec timeo; | |
3933 | |
3934 if(!eve) | |
3935 return FALSE; | |
3936 | |
3937 if(eve->posted) | |
3938 return 0; | |
3939 | |
3940 pthread_mutex_lock (&(eve->mutex)); | |
3941 gettimeofday(&now, 0); | |
3942 timeo.tv_sec = now.tv_sec + (timeout / 1000); | |
3943 timeo.tv_nsec = now.tv_usec * 1000; | |
3944 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo); | |
3945 pthread_mutex_unlock (&(eve->mutex)); | |
3946 if(!rc) | |
3947 return 1; | |
3948 if(rc == ETIMEDOUT) | |
3949 return -1; | |
3950 return 0; | |
3951 } | |
3952 | |
3953 /* | |
3954 * Closes a semaphore created by dw_event_new(). | |
3955 * Parameters: | |
3956 * eve: The handle to the event returned by dw_event_new(). | |
3957 */ | |
3958 int dw_event_close(HEV *eve) | |
3959 { | |
3960 if(!eve || !(*eve)) | |
3961 return FALSE; | |
3962 | |
3963 pthread_mutex_lock (&((*eve)->mutex)); | |
3964 pthread_cond_destroy (&((*eve)->event)); | |
3965 pthread_mutex_unlock (&((*eve)->mutex)); | |
3966 pthread_mutex_destroy (&((*eve)->mutex)); | |
3967 free(*eve); | |
3968 *eve = NULL; | |
3969 | |
3970 return TRUE; | |
3971 } | |
3972 | |
3973 struct _seminfo { | |
3974 int fd; | |
3975 int waiting; | |
3976 }; | |
3977 | |
3978 static void _handle_sem(int *tmpsock) | |
3979 { | |
3980 fd_set rd; | |
3981 struct _seminfo *array = (struct _seminfo *)malloc(sizeof(struct _seminfo)); | |
3982 int listenfd = tmpsock[0]; | |
3983 int bytesread, connectcount = 1, maxfd, z, posted = 0; | |
3984 char command; | |
3985 sigset_t mask; | |
3986 | |
3987 sigfillset(&mask); /* Mask all allowed signals */ | |
3988 pthread_sigmask(SIG_BLOCK, &mask, NULL); | |
3989 | |
3990 /* problems */ | |
3991 if(tmpsock[1] == -1) | |
3992 { | |
3993 free(array); | |
3994 return; | |
3995 } | |
3996 | |
3997 array[0].fd = tmpsock[1]; | |
3998 array[0].waiting = 0; | |
3999 | |
4000 /* Free the memory allocated in dw_named_event_new. */ | |
4001 free(tmpsock); | |
4002 | |
4003 while(1) | |
4004 { | |
4005 FD_ZERO(&rd); | |
4006 FD_SET(listenfd, &rd); | |
4007 | |
4008 maxfd = listenfd; | |
4009 | |
4010 /* Added any connections to the named event semaphore */ | |
4011 for(z=0;z<connectcount;z++) | |
4012 { | |
4013 if(array[z].fd > maxfd) | |
4014 maxfd = array[z].fd; | |
4015 | |
4016 FD_SET(array[z].fd, &rd); | |
4017 } | |
4018 | |
4019 if(select(maxfd+1, &rd, NULL, NULL, NULL) == -1) | |
4020 return; | |
4021 | |
4022 if(FD_ISSET(listenfd, &rd)) | |
4023 { | |
4024 struct _seminfo *newarray; | |
4025 int newfd = accept(listenfd, 0, 0); | |
4026 | |
4027 if(newfd > -1) | |
4028 { | |
4029 /* Add new connections to the set */ | |
4030 newarray = (struct _seminfo *)malloc(sizeof(struct _seminfo)*(connectcount+1)); | |
4031 memcpy(newarray, array, sizeof(struct _seminfo)*(connectcount)); | |
4032 | |
4033 newarray[connectcount].fd = newfd; | |
4034 newarray[connectcount].waiting = 0; | |
4035 | |
4036 connectcount++; | |
4037 | |
4038 /* Replace old array with new one */ | |
4039 free(array); | |
4040 array = newarray; | |
4041 } | |
4042 } | |
4043 | |
4044 /* Handle any events posted to the semaphore */ | |
4045 for(z=0;z<connectcount;z++) | |
4046 { | |
4047 if(FD_ISSET(array[z].fd, &rd)) | |
4048 { | |
4049 if((bytesread = read(array[z].fd, &command, 1)) < 1) | |
4050 { | |
4051 struct _seminfo *newarray; | |
4052 | |
4053 /* Remove this connection from the set */ | |
4054 newarray = (struct _seminfo *)malloc(sizeof(struct _seminfo)*(connectcount-1)); | |
4055 if(!z) | |
4056 memcpy(newarray, &array[1], sizeof(struct _seminfo)*(connectcount-1)); | |
4057 else | |
4058 { | |
4059 memcpy(newarray, array, sizeof(struct _seminfo)*z); | |
4060 if(z!=(connectcount-1)) | |
4061 memcpy(&newarray[z], &array[z+1], sizeof(struct _seminfo)*(z-connectcount-1)); | |
4062 } | |
4063 connectcount--; | |
4064 | |
4065 /* Replace old array with new one */ | |
4066 free(array); | |
4067 array = newarray; | |
4068 } | |
4069 else if(bytesread == 1) | |
4070 { | |
4071 switch(command) | |
4072 { | |
4073 case 0: | |
4074 { | |
4075 /* Reset */ | |
4076 posted = 0; | |
4077 } | |
4078 break; | |
4079 case 1: | |
4080 /* Post */ | |
4081 { | |
4082 int s; | |
4083 char tmp = (char)0; | |
4084 | |
4085 posted = 1; | |
4086 | |
4087 for(s=0;s<connectcount;s++) | |
4088 { | |
4089 /* The semaphore has been posted so | |
4090 * we tell all the waiting threads to | |
4091 * continue. | |
4092 */ | |
4093 if(array[s].waiting) | |
4094 write(array[s].fd, &tmp, 1); | |
4095 } | |
4096 } | |
4097 break; | |
4098 case 2: | |
4099 /* Wait */ | |
4100 { | |
4101 char tmp = (char)0; | |
4102 | |
4103 array[z].waiting = 1; | |
4104 | |
4105 /* If we are posted exit immeditately */ | |
4106 if(posted) | |
4107 write(array[z].fd, &tmp, 1); | |
4108 } | |
4109 break; | |
4110 case 3: | |
4111 { | |
4112 /* Done Waiting */ | |
4113 array[z].waiting = 0; | |
4114 } | |
4115 break; | |
4116 } | |
4117 } | |
4118 } | |
4119 } | |
4120 | |
4121 } | |
4122 | |
4123 } | |
4124 | |
4125 /* Using domain sockets on unix for IPC */ | |
4126 /* Create a named event semaphore which can be | |
4127 * opened from other processes. | |
4128 * Parameters: | |
4129 * eve: Pointer to an event handle to receive handle. | |
4130 * name: Name given to semaphore which can be opened | |
4131 * by other processes. | |
4132 */ | |
4133 HEV dw_named_event_new(char *name) | |
4134 { | |
4135 struct sockaddr_un un; | |
4136 int ev, *tmpsock = (int *)malloc(sizeof(int)*2); | |
4137 HEV eve; | |
4138 DWTID dwthread; | |
4139 | |
4140 if(!tmpsock) | |
4141 return NULL; | |
4142 | |
4143 eve = (HEV)malloc(sizeof(struct _dw_unix_event)); | |
4144 | |
4145 if(!eve) | |
4146 { | |
4147 free(tmpsock); | |
4148 return NULL; | |
4149 } | |
4150 | |
4151 tmpsock[0] = socket(AF_UNIX, SOCK_STREAM, 0); | |
4152 ev = socket(AF_UNIX, SOCK_STREAM, 0); | |
4153 memset(&un, 0, sizeof(un)); | |
4154 un.sun_family=AF_UNIX; | |
4155 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); | |
4156 strcpy(un.sun_path, "/tmp/.dw/"); | |
4157 strcat(un.sun_path, name); | |
4158 | |
4159 /* just to be safe, this should be changed | |
4160 * to support multiple instances. | |
4161 */ | |
4162 remove(un.sun_path); | |
4163 | |
4164 bind(tmpsock[0], (struct sockaddr *)&un, sizeof(un)); | |
4165 listen(tmpsock[0], 0); | |
4166 connect(ev, (struct sockaddr *)&un, sizeof(un)); | |
4167 tmpsock[1] = accept(tmpsock[0], 0, 0); | |
4168 | |
4169 if(tmpsock[0] < 0 || tmpsock[1] < 0 || ev < 0) | |
4170 { | |
4171 if(tmpsock[0] > -1) | |
4172 close(tmpsock[0]); | |
4173 if(tmpsock[1] > -1) | |
4174 close(tmpsock[1]); | |
4175 if(ev > -1) | |
4176 close(ev); | |
4177 free(tmpsock); | |
4178 free(eve); | |
4179 return NULL; | |
4180 } | |
4181 | |
4182 /* Create a thread to handle this event semaphore */ | |
4183 pthread_create(&dwthread, NULL, (void *)_handle_sem, (void *)tmpsock); | |
4184 eve->alive = ev; | |
4185 return eve; | |
4186 } | |
4187 | |
4188 /* Open an already existing named event semaphore. | |
4189 * Parameters: | |
4190 * eve: Pointer to an event handle to receive handle. | |
4191 * name: Name given to semaphore which can be opened | |
4192 * by other processes. | |
4193 */ | |
4194 HEV dw_named_event_get(char *name) | |
4195 { | |
4196 struct sockaddr_un un; | |
4197 HEV eve; | |
4198 int ev = socket(AF_UNIX, SOCK_STREAM, 0); | |
4199 if(ev < 0) | |
4200 return NULL; | |
4201 | |
4202 eve = (HEV)malloc(sizeof(struct _dw_unix_event)); | |
4203 | |
4204 if(!eve) | |
4205 { | |
4206 close(ev); | |
4207 return NULL; | |
4208 } | |
4209 | |
4210 un.sun_family=AF_UNIX; | |
4211 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); | |
4212 strcpy(un.sun_path, "/tmp/.dw/"); | |
4213 strcat(un.sun_path, name); | |
4214 connect(ev, (struct sockaddr *)&un, sizeof(un)); | |
4215 eve->alive = ev; | |
4216 return eve; | |
4217 } | |
4218 | |
4219 /* Resets the event semaphore so threads who call wait | |
4220 * on this semaphore will block. | |
4221 * Parameters: | |
4222 * eve: Handle to the semaphore obtained by | |
4223 * an open or create call. | |
4224 */ | |
4225 int dw_named_event_reset(HEV eve) | |
4226 { | |
4227 /* signal reset */ | |
4228 char tmp = (char)0; | |
4229 | |
4230 if(!eve || eve->alive < 0) | |
4231 return 0; | |
4232 | |
4233 if(write(eve->alive, &tmp, 1) == 1) | |
4234 return 0; | |
4235 return 1; | |
4236 } | |
4237 | |
4238 /* Sets the posted state of an event semaphore, any threads | |
4239 * waiting on the semaphore will no longer block. | |
4240 * Parameters: | |
4241 * eve: Handle to the semaphore obtained by | |
4242 * an open or create call. | |
4243 */ | |
4244 int dw_named_event_post(HEV eve) | |
4245 { | |
4246 | |
4247 /* signal post */ | |
4248 char tmp = (char)1; | |
4249 | |
4250 if(!eve || eve->alive < 0) | |
4251 return 0; | |
4252 | |
4253 if(write(eve->alive, &tmp, 1) == 1) | |
4254 return 0; | |
4255 return 1; | |
4256 } | |
4257 | |
4258 /* Waits on the specified semaphore until it becomes | |
4259 * posted, or returns immediately if it already is posted. | |
4260 * Parameters: | |
4261 * eve: Handle to the semaphore obtained by | |
4262 * an open or create call. | |
4263 * timeout: Number of milliseconds before timing out | |
4264 * or -1 if indefinite. | |
4265 */ | |
4266 int dw_named_event_wait(HEV eve, unsigned long timeout) | |
4267 { | |
4268 fd_set rd; | |
4269 struct timeval tv, *useme; | |
4270 int retval = 0; | |
4271 char tmp; | |
4272 | |
4273 if(!eve || eve->alive < 0) | |
4274 return DW_ERROR_NON_INIT; | |
4275 | |
4276 /* Set the timout or infinite */ | |
4277 if(timeout == -1) | |
4278 useme = NULL; | |
4279 else | |
4280 { | |
4281 tv.tv_sec = timeout / 1000; | |
4282 tv.tv_usec = timeout % 1000; | |
4283 | |
4284 useme = &tv; | |
4285 } | |
4286 | |
4287 FD_ZERO(&rd); | |
4288 FD_SET(eve->alive, &rd); | |
4289 | |
4290 /* Signal wait */ | |
4291 tmp = (char)2; | |
4292 write(eve->alive, &tmp, 1); | |
4293 | |
4294 retval = select(eve->alive+1, &rd, NULL, NULL, useme); | |
4295 | |
4296 /* Signal done waiting. */ | |
4297 tmp = (char)3; | |
4298 write(eve->alive, &tmp, 1); | |
4299 | |
4300 if(retval == 0) | |
4301 return DW_ERROR_TIMEOUT; | |
4302 else if(retval == -1) | |
4303 return DW_ERROR_INTERRUPT; | |
4304 | |
4305 /* Clear the entry from the pipe so | |
4306 * we don't loop endlessly. :) | |
4307 */ | |
4308 read(eve->alive, &tmp, 1); | |
4309 return 0; | |
4310 } | |
4311 | |
4312 /* Release this semaphore, if there are no more open | |
4313 * handles on this semaphore the semaphore will be destroyed. | |
4314 * Parameters: | |
4315 * eve: Handle to the semaphore obtained by | |
4316 * an open or create call. | |
4317 */ | |
4318 int dw_named_event_close(HEV eve) | |
4319 { | |
4320 /* Finally close the domain socket, | |
4321 * cleanup will continue in _handle_sem. | |
4322 */ | |
4323 if(eve) | |
4324 { | |
4325 close(eve->alive); | |
4326 free(eve); | |
4327 } | |
4328 return 0; | |
4329 } | |
4330 | |
4331 /* | |
4332 * Setup thread independent color sets. | |
4333 */ | |
4334 void _dwthreadstart(void *data) | |
4335 { | |
4336 void (*threadfunc)(void *) = NULL; | |
4337 void **tmp = (void **)data; | |
4338 | |
4339 threadfunc = (void (*)(void *))tmp[0]; | |
4340 | |
4341 threadfunc(tmp[1]); | |
4342 free(tmp); | |
4343 } | |
4344 | |
4345 /* | |
4346 * Allocates a shared memory region with a name. | |
4347 * Parameters: | |
4348 * handle: A pointer to receive a SHM identifier. | |
4349 * dest: A pointer to a pointer to receive the memory address. | |
4350 * size: Size in bytes of the shared memory region to allocate. | |
4351 * name: A string pointer to a unique memory name. | |
4352 */ | |
4353 HSHM dw_named_memory_new(void **dest, int size, char *name) | |
4354 { | |
4355 char namebuf[1024]; | |
4356 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm)); | |
4357 | |
4358 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); | |
4359 sprintf(namebuf, "/tmp/.dw/%s", name); | |
4360 | |
4361 if((handle->fd = open(namebuf, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) < 0) | |
4362 { | |
4363 free(handle); | |
4364 return NULL; | |
4365 } | |
4366 | |
4367 ftruncate(handle->fd, size); | |
4368 | |
4369 /* attach the shared memory segment to our process's address space. */ | |
4370 *dest = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); | |
4371 | |
4372 if(*dest == MAP_FAILED) | |
4373 { | |
4374 close(handle->fd); | |
4375 *dest = NULL; | |
4376 free(handle); | |
4377 return NULL; | |
4378 } | |
4379 | |
4380 handle->size = size; | |
4381 handle->sid = getsid(0); | |
4382 handle->path = strdup(namebuf); | |
4383 | |
4384 return handle; | |
4385 } | |
4386 | |
4387 /* | |
4388 * Aquires shared memory region with a name. | |
4389 * Parameters: | |
4390 * dest: A pointer to a pointer to receive the memory address. | |
4391 * size: Size in bytes of the shared memory region to requested. | |
4392 * name: A string pointer to a unique memory name. | |
4393 */ | |
4394 HSHM dw_named_memory_get(void **dest, int size, char *name) | |
4395 { | |
4396 char namebuf[1024]; | |
4397 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm)); | |
4398 | |
4399 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); | |
4400 sprintf(namebuf, "/tmp/.dw/%s", name); | |
4401 | |
4402 if((handle->fd = open(namebuf, O_RDWR)) < 0) | |
4403 { | |
4404 free(handle); | |
4405 return NULL; | |
4406 } | |
4407 | |
4408 /* attach the shared memory segment to our process's address space. */ | |
4409 *dest = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); | |
4410 | |
4411 if(*dest == MAP_FAILED) | |
4412 { | |
4413 close(handle->fd); | |
4414 *dest = NULL; | |
4415 free(handle); | |
4416 return NULL; | |
4417 } | |
4418 | |
4419 handle->size = size; | |
4420 handle->sid = -1; | |
4421 handle->path = NULL; | |
4422 | |
4423 return handle; | |
4424 } | |
4425 | |
4426 /* | |
4427 * Frees a shared memory region previously allocated. | |
4428 * Parameters: | |
4429 * handle: Handle obtained from DB_named_memory_allocate. | |
4430 * ptr: The memory address aquired with DB_named_memory_allocate. | |
4431 */ | |
4432 int dw_named_memory_free(HSHM handle, void *ptr) | |
4433 { | |
4434 struct _dw_unix_shm *h = handle; | |
4435 int rc = munmap(ptr, h->size); | |
4436 | |
4437 close(h->fd); | |
4438 if(h->path) | |
4439 { | |
4440 /* Only remove the actual file if we are the | |
4441 * creator of the file. | |
4442 */ | |
4443 if(h->sid != -1 && h->sid == getsid(0)) | |
4444 remove(h->path); | |
4445 free(h->path); | |
4446 } | |
4447 return rc; | |
4448 } | |
4449 /* | |
4450 * Creates a new thread with a starting point of func. | |
4451 * Parameters: | |
4452 * func: Function which will be run in the new thread. | |
4453 * data: Parameter(s) passed to the function. | |
4454 * stack: Stack size of new thread (OS/2 and Windows only). | |
4455 */ | |
4456 DWTID dw_thread_new(void *func, void *data, int stack) | |
4457 { | |
4458 DWTID thread; | |
4459 void **tmp = malloc(sizeof(void *) * 2); | |
4460 int rc; | |
4461 | |
4462 tmp[0] = func; | |
4463 tmp[1] = data; | |
4464 | |
4465 rc = pthread_create(&thread, NULL, (void *)_dwthreadstart, (void *)tmp); | |
4466 if(rc == 0) | |
4467 return thread; | |
4468 return (DWTID)-1; | |
4469 } | |
4470 | |
4471 /* | |
4472 * Ends execution of current thread immediately. | |
4473 */ | |
4474 void dw_thread_end(void) | |
4475 { | |
4476 pthread_exit(NULL); | |
4477 } | |
4478 | |
4479 /* | |
4480 * Returns the current thread's ID. | |
4481 */ | |
4482 DWTID dw_thread_id(void) | |
4483 { | |
4484 return (DWTID)pthread_self(); | |
4485 } | |
4486 | |
4487 #ifdef DWTEST | |
4488 int main(int argc, char *argv[]) | |
4489 { | |
4490 HWND window, box, vbox, hbox, button, text, checkbox, html; | |
4491 LONG x, y; | |
4492 ULONG width, height; | |
4493 | |
4494 dw_init(TRUE, argc, argv); | |
4495 | |
4496 window = dw_window_new(HWND_DESKTOP, "Dynamic Windows Test", DW_FCF_TITLEBAR | DW_FCF_SYSMENU | DW_FCF_MINMAX | DW_FCF_SIZEBORDER); | |
4497 box = dw_box_new(DW_VERT, 0); | |
4498 vbox = dw_groupbox_new(DW_VERT, 4, "Checks"); | |
4499 checkbox = dw_checkbox_new("Checkbox 1", 0); | |
4500 dw_box_pack_start(vbox, checkbox, 100, 25, TRUE, FALSE, 2); | |
4501 checkbox = dw_checkbox_new("Checkbox 2", 0); | |
4502 dw_box_pack_start(vbox, checkbox, 100, 25, TRUE, FALSE, 2); | |
4503 checkbox = dw_checkbox_new("Checkbox 3", 0); | |
4504 dw_box_pack_start(vbox, checkbox, 100, 25, TRUE, FALSE, 2); | |
4505 hbox = dw_box_new(DW_HORZ, 0); | |
4506 button = dw_button_new("Test Button", 0); | |
4507 /*dw_window_disable(button);*/ | |
4508 text = dw_entryfield_new("Entry", 0); | |
4509 dw_box_pack_start(hbox, button, 100, 40, TRUE, FALSE, 2); | |
4510 dw_box_pack_start(hbox, text, 100, 40, TRUE, FALSE, 2); | |
4511 dw_box_pack_start(vbox, hbox, 0, 0, TRUE, FALSE, 0); | |
4512 html = dw_html_new(0); | |
4513 dw_html_url(html, "http://dbsoft.org"); | |
4514 dw_box_pack_start(vbox, html, 0, 0, TRUE, TRUE, 0); | |
4515 dw_box_pack_start(box, vbox, 0, 0, TRUE, TRUE, 0); | |
4516 dw_box_pack_start(window, box, 0, 0, TRUE, TRUE, 0); | |
4517 dw_window_show(window); | |
4518 dw_window_set_pos_size(window, 400, 400, 500, 500); | |
4519 dw_window_get_pos_size(window, &x, &y, &width, &height); | |
4520 dw_messagebox("Dynamic Windows Information", DW_MB_OK | DW_MB_INFORMATION, "%d %d %d %d %d %d %d\n", (int)x, (int)y, (int)width, (int)height, (int)dw_screen_width(), (int)dw_screen_height(), (int)dw_color_depth_get()); | |
4521 dw_main(); | |
4522 | |
4523 return 0; | |
4524 } | |
4525 #endif |