Mercurial > dwindows
annotate mac/dw.m @ 687:5dde8d34bc69
Implemented dw_listbox_insert for containers.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 03 Mar 2011 14:49:30 +0000 |
parents | 218d676baf7f |
children | b52f1d4a60dd |
rev | line source |
---|---|
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2 * Dynamic Windows: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3 * A GTK like implementation of the MacOS GUI using Cocoa |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4 * |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5 * (C) 2011 Brian Smith <brian@dbsoft.org> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6 * |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7 * Using garbage collection so requires 10.5 or later. |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
8 * clang -std=c99 -g -o dwtest -D__MAC__ -I. dwtest.c mac/dw.m -framework Cocoa -framework WebKit -fobjc-gc-only |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
9 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
10 #import <Cocoa/Cocoa.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
11 #import <WebKit/WebKit.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
12 #include "dw.h" |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
13 #include <sys/utsname.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
14 #include <sys/socket.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
15 #include <sys/un.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
16 #include <sys/mman.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
17 #include <sys/time.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
18 #include <sys/stat.h> |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
19 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
20 unsigned long _colors[] = |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
21 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
22 0x00000000, /* 0 black */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
23 0x00bb0000, /* 1 red */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
24 0x0000bb00, /* 2 green */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
25 0x00aaaa00, /* 3 yellow */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
26 0x000000cc, /* 4 blue */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
27 0x00bb00bb, /* 5 magenta */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
28 0x0000bbbb, /* 6 cyan */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
29 0x00bbbbbb, /* 7 white */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
30 0x00777777, /* 8 grey */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
31 0x00ff0000, /* 9 bright red */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
32 0x0000ff00, /* 10 bright green */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
33 0x00eeee00, /* 11 bright yellow */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
34 0x000000ff, /* 12 bright blue */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
35 0x00ff00ff, /* 13 bright magenta */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
36 0x0000eeee, /* 14 bright cyan */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
37 0x00ffffff, /* 15 bright white */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
38 0xff000000 /* 16 default color */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
39 }; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
40 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
41 unsigned long _get_color(unsigned long thiscolor) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
42 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
43 if(thiscolor & DW_RGB_COLOR) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
44 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
45 return thiscolor & ~DW_RGB_COLOR; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
46 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
47 else if(thiscolor < 17) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
48 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
49 return _colors[thiscolor]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
50 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
51 return 0; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
52 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
53 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
54 typedef struct _sighandler |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
55 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
56 struct _sighandler *next; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
57 ULONG message; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
58 HWND window; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
59 int id; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
60 void *signalfunction; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
61 void *data; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
62 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
63 } SignalHandler; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
64 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
65 SignalHandler *Root = NULL; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
66 |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
67 /* Some internal prototypes */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
68 static void _do_resize(Box *thisbox, int x, int y); |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
69 int _remove_userdata(UserData **root, char *varname, int all); |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
70 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
71 SignalHandler *_get_handler(HWND window, int messageid) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
72 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
73 SignalHandler *tmp = Root; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
74 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
75 /* Find any callbacks for this function */ |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
76 while(tmp) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
77 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
78 if(tmp->message == messageid && window == tmp->window) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
79 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
80 return tmp; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
81 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
82 tmp = tmp->next; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
83 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
84 return NULL; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
85 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
86 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
87 int _event_handler(id object, NSEvent *event, int message) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
88 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
89 SignalHandler *handler = _get_handler(object, message); |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
90 /*NSLog(@"Event handler - type %d\n", message);*/ |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
91 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
92 if(handler) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
93 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
94 switch(message) |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
95 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
96 case 0: |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
97 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
98 int (* API timerfunc)(void *) = (int (* API)(void *))handler->signalfunction; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
99 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
100 if(!timerfunc(handler->data)) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
101 dw_timer_disconnect(handler->id); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
102 return 0; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
103 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
104 case 1: |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
105 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
106 int (*sizefunc)(HWND, int, int, void *) = handler->signalfunction; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
107 NSSize size; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
108 |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
109 if([object isMemberOfClass:[NSWindow class]]) |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
110 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
111 NSWindow *window = object; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
112 size = [[window contentView] frame].size; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
113 } |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
114 else |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
115 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
116 NSView *view = object; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
117 size = [view frame].size; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
118 } |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
119 |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
120 return sizefunc(object, size.width, size.height, handler->data); |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
121 } |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
122 case 3: |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
123 case 4: |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
124 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
125 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
126 int flags = (int)[object pressedMouseButtons]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
127 NSPoint point = [object mouseLocation]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
128 int button = 0; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
129 |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
130 if(flags & 1) |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
131 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
132 button = 1; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
133 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
134 else if(flags & (1 << 1)) |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
135 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
136 button = 2; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
137 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
138 else if(flags & (1 << 2)) |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
139 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
140 button = 3; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
141 } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
142 |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
143 return buttonfunc(object, point.x, point.y, button, handler->data); |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
144 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
145 case 6: |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
146 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
147 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
148 return closefunc(object, handler->data); |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
149 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
150 case 7: |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
151 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
152 DWExpose exp; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
153 int (* API exposefunc)(HWND, DWExpose *, void *) = (int (* API)(HWND, DWExpose *, void *))handler->signalfunction; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
154 NSRect rect = [object frame]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
155 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
156 exp.x = rect.origin.x; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
157 exp.y = rect.origin.y; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
158 exp.width = rect.size.width; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
159 exp.height = rect.size.height; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
160 int result = exposefunc(object, &exp, handler->data); |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
161 [[object window] flushWindow]; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
162 return result; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
163 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
164 case 8: |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
165 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
166 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
167 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
168 return clickfunc(object, handler->data); |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
169 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
170 case 9: |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
171 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
172 int (*containerselectfunc)(HWND, char *, void *) = handler->signalfunction; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
173 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
174 return containerselectfunc(handler->window, (char *)event, handler->data); |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
175 } |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
176 case 10: |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
177 { |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
178 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))handler->signalfunction; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
179 char *text = (char *)event; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
180 void *user = NULL; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
181 LONG x,y; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
182 |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
183 dw_pointer_query_pos(&x, &y); |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
184 |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
185 return containercontextfunc(handler->window, text, (int)x, (int)y, handler->data, user); |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
186 } |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
187 case 12: |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
188 { |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
189 int (* API treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = (int (* API)(HWND, HTREEITEM, char *, void *, void *))handler->signalfunction; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
190 char *text = (char *)event; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
191 void *user = NULL; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
192 |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
193 return treeselectfunc(handler->window, NULL, text, handler->data, user); |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
194 } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
195 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
196 } |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
197 return -1; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
198 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
199 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
200 /* Subclass for the Timer type */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
201 @interface DWTimerHandler : NSObject { } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
202 -(void)runTimer:(id)sender; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
203 @end |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
204 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
205 @implementation DWTimerHandler |
674
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
206 -(void)runTimer:(id)sender { _event_handler(sender, nil, 0); } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
207 @end |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
208 |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
209 NSApplication *DWApp; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
210 NSRunLoop *DWRunLoop; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
211 NSMenu *DWMainMenu; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
212 DWTimerHandler *DWHandler; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
213 #if !defined(GARBAGE_COLLECT) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
214 NSAutoreleasePool *pool; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
215 #endif |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
216 HWND _DWLastDrawable; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
217 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
218 /* So basically to implement our event handlers... |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
219 * it looks like we are going to have to subclass |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
220 * basically everything. Was hoping to add methods |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
221 * to the superclasses but it looks like you can |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
222 * only add methods and no variables, which isn't |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
223 * going to work. -Brian |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
224 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
225 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
226 /* Subclass for a box type */ |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
227 @interface DWBox : NSView <NSWindowDelegate> |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
228 { |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
229 Box *box; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
230 void *userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
231 NSColor *bgcolor; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
232 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
233 -(id)init; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
234 -(void)dealloc; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
235 -(Box *)box; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
236 -(void *)userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
237 -(void)setUserdata:(void *)input; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
238 -(void)drawRect:(NSRect)rect; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
239 -(BOOL)isFlipped; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
240 -(void)mouseDown:(NSEvent *)theEvent; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
241 -(void)mouseUp:(NSEvent *)theEvent; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
242 -(void)setColor:(unsigned long)input; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
243 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
244 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
245 @implementation DWBox |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
246 -(id)init |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
247 { |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
248 self = [super init]; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
249 |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
250 if (self) |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
251 { |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
252 box = calloc(1, sizeof(Box)); |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
253 } |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
254 return self; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
255 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
256 -(void)dealloc |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
257 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
258 UserData *root = userdata; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
259 free(box); |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
260 _remove_userdata(&root, NULL, TRUE); |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
261 [super dealloc]; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
262 } |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
263 -(Box *)box { return box; } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
264 -(void *)userdata { return userdata; } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
265 -(void)setUserdata:(void *)input { userdata = input; } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
266 -(void)drawRect:(NSRect)rect |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
267 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
268 if(bgcolor) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
269 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
270 [bgcolor set]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
271 NSRectFill( [self bounds] ); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
272 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
273 } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
274 -(BOOL)isFlipped { return YES; } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
275 -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
276 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
277 -(void)setColor:(unsigned long)input |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
278 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
279 if(input == _colors[DW_CLR_DEFAULT]) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
280 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
281 bgcolor = nil; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
282 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
283 else |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
284 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
285 bgcolor = [NSColor colorWithDeviceRed: DW_RED_VALUE(input)/255.0 green: DW_GREEN_VALUE(input)/255.0 blue: DW_BLUE_VALUE(input)/255.0 alpha: 1]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
286 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
287 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
288 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
289 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
290 /* Subclass for a top-level window */ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
291 @interface DWView : DWBox |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
292 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
293 NSMenu *windowmenu; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
294 } |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
295 -(BOOL)windowShouldClose:(id)sender; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
296 -(void)setMenu:(NSMenu *)input; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
297 -(void)windowDidBecomeMain:(id)sender; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
298 -(void)menuHandler:(id)sender; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
299 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
300 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
301 @implementation DWView |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
302 -(BOOL)windowShouldClose:(id)sender |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
303 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
304 if(_event_handler(self, nil, 6) == FALSE) |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
305 return NO; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
306 return YES; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
307 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
308 - (void)viewDidMoveToWindow |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
309 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
310 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowResized:) name:NSWindowDidResizeNotification object:[self window]]; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
311 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidBecomeMain:) name:NSWindowDidBecomeMainNotification object:[self window]]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
312 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
313 - (void)dealloc |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
314 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
315 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
316 [super dealloc]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
317 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
318 - (void)windowResized:(NSNotification *)notification; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
319 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
320 NSSize size = [self frame].size; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
321 _do_resize(box, size.width, size.height); |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
322 _event_handler([self window], nil, 1); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
323 } |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
324 -(void)windowDidBecomeMain:(id)sender |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
325 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
326 if(windowmenu) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
327 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
328 [DWApp setMainMenu:windowmenu]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
329 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
330 else |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
331 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
332 [DWApp setMainMenu:DWMainMenu]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
333 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
334 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
335 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
336 -(void)setMenu:(NSMenu *)input { windowmenu = input; } |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
337 -(void)menuHandler:(id)sender { _event_handler(sender, nil, 8); } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
338 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
339 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
340 /* Subclass for a button type */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
341 @interface DWButton : NSButton |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
342 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
343 void *userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
344 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
345 -(void *)userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
346 -(void)setUserdata:(void *)input; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
347 -(void)buttonClicked:(id)sender; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
348 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
349 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
350 @implementation DWButton |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
351 -(void *)userdata { return userdata; } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
352 -(void)setUserdata:(void *)input { userdata = input; } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
353 -(void)buttonClicked:(id)sender { _event_handler(self, nil, 8); } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
354 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
355 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
356 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
357 /* Subclass for a progress type */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
358 @interface DWPercent : NSProgressIndicator |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
359 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
360 void *userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
361 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
362 -(void *)userdata; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
363 -(void)setUserdata:(void *)input; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
364 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
365 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
366 @implementation DWPercent |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
367 -(void *)userdata { return userdata; } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
368 -(void)setUserdata:(void *)input { userdata = input; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
369 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
370 @end |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
371 |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
372 /* Subclass for a entryfield type */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
373 @interface DWEntryField : NSTextField |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
374 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
375 void *userdata; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
376 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
377 -(void *)userdata; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
378 -(void)setUserdata:(void *)input; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
379 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
380 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
381 @implementation DWEntryField |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
382 -(void *)userdata { return userdata; } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
383 -(void)setUserdata:(void *)input { userdata = input; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
384 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
385 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
386 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
387 /* Subclass for a entryfield password type */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
388 @interface DWEntryFieldPassword : NSSecureTextField |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
389 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
390 void *userdata; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
391 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
392 -(void *)userdata; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
393 -(void)setUserdata:(void *)input; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
394 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
395 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
396 @implementation DWEntryFieldPassword |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
397 -(void *)userdata { return userdata; } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
398 -(void)setUserdata:(void *)input { userdata = input; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
399 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
400 @end |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
401 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
402 /* Subclass for a Notebook control type */ |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
403 @interface DWNotebook : NSTabView <NSTabViewDelegate> |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
404 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
405 void *userdata; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
406 int pageid; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
407 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
408 -(void *)userdata; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
409 -(void)setUserdata:(void *)input; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
410 -(int)pageid; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
411 -(void)setPageid:(int)input; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
412 -(void)tabView:(NSTabView *)notebook didSelectTabViewItem:(NSTabViewItem *)notepage; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
413 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
414 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
415 @implementation DWNotebook |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
416 -(void *)userdata { return userdata; } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
417 -(void)setUserdata:(void *)input { userdata = input; } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
418 -(int)pageid { return pageid; } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
419 -(void)setPageid:(int)input { pageid = input; } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
420 -(void)tabView:(NSTabView *)notebook didSelectTabViewItem:(NSTabViewItem *)notepage |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
421 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
422 id object = [notepage view]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
423 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
424 if([object isMemberOfClass:[DWBox class]]) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
425 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
426 DWBox *view = object; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
427 Box *box = [view box]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
428 NSSize size = [view frame].size; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
429 _do_resize(box, size.width, size.height); |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
430 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
431 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
432 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
433 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
434 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
435 /* Subclass for a Notebook page type */ |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
436 @interface DWNotebookPage : NSTabViewItem |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
437 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
438 void *userdata; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
439 int pageid; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
440 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
441 -(void *)userdata; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
442 -(void)setUserdata:(void *)input; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
443 -(int)pageid; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
444 -(void)setPageid:(int)input; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
445 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
446 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
447 @implementation DWNotebookPage |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
448 -(void *)userdata { return userdata; } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
449 -(void)setUserdata:(void *)input { userdata = input; } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
450 -(int)pageid { return pageid; } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
451 -(void)setPageid:(int)input { pageid = input; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
452 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
453 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
454 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
455 /* Subclass for a color chooser type */ |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
456 @interface DWColorChoose : NSColorPanel |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
457 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
458 DWDialog *dialog; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
459 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
460 -(void)changeColor:(id)sender; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
461 -(void)setDialog:(DWDialog *)input; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
462 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
463 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
464 @implementation DWColorChoose |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
465 - (void)changeColor:(id)sender |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
466 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
467 dw_dialog_dismiss(dialog, [self color]); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
468 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
469 -(void)setDialog:(DWDialog *)input { dialog = input; } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
470 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
471 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
472 /* Subclass for a splitbar type */ |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
473 @interface DWSplitBar : NSSplitView <NSSplitViewDelegate> |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
474 { |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
475 void *userdata; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
476 float percent; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
477 } |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
478 -(void)splitViewDidResizeSubviews:(NSNotification *)aNotification; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
479 -(void *)userdata; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
480 -(void)setUserdata:(void *)input; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
481 -(float)percent; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
482 -(void)setPercent:(float)input; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
483 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
484 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
485 @implementation DWSplitBar |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
486 -(void)splitViewDidResizeSubviews:(NSNotification *)aNotification |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
487 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
488 NSArray *views = [self subviews]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
489 id object; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
490 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
491 for(object in views) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
492 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
493 if([object isMemberOfClass:[DWBox class]]) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
494 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
495 DWBox *view = object; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
496 Box *box = [view box]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
497 NSSize size = [view frame].size; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
498 _do_resize(box, size.width, size.height); |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
499 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
500 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
501 } |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
502 -(void *)userdata { return userdata; } |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
503 -(void)setUserdata:(void *)input { userdata = input; } |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
504 -(float)percent { return percent; } |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
505 -(void)setPercent:(float)input { percent = input; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
506 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
507 @end |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
508 |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
509 /* Subclass for a slider type */ |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
510 @interface DWSlider : NSSlider |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
511 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
512 void *userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
513 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
514 -(void *)userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
515 -(void)setUserdata:(void *)input; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
516 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
517 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
518 @implementation DWSlider |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
519 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
520 -(void)setUserdata:(void *)input { userdata = input; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
521 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
522 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
523 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
524 /* Subclass for a slider type */ |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
525 @interface DWScrollbar : NSScroller |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
526 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
527 void *userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
528 float range; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
529 float visible; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
530 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
531 -(void *)userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
532 -(void)setUserdata:(void *)input; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
533 -(float)range; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
534 -(float)visible; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
535 -(void)setRange:(float)input1 andVisible:(float)input2; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
536 -(void)changed:(id)sender; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
537 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
538 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
539 @implementation DWScrollbar |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
540 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
541 -(void)setUserdata:(void *)input { userdata = input; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
542 -(float)range { return range; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
543 -(float)visible { return visible; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
544 -(void)setRange:(float)input1 andVisible:(float)input2 { range = input1; visible = input2; } |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
545 -(void)changed:(id)sender { /*NSNumber *num = [NSNumber numberWithDouble:[scroller floatValue]]; NSLog([num stringValue]);*/ } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
546 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
547 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
548 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
549 /* Subclass for a render area type */ |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
550 @interface DWRender : NSView |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
551 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
552 void *userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
553 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
554 -(void *)userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
555 -(void)setUserdata:(void *)input; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
556 -(void)drawRect:(NSRect)rect; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
557 -(void)mouseDown:(NSEvent *)theEvent; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
558 -(void)mouseUp:(NSEvent *)theEvent; |
664
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
559 -(BOOL)isFlipped; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
560 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
561 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
562 @implementation DWRender |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
563 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
564 -(void)setUserdata:(void *)input { userdata = input; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
565 -(void)drawRect:(NSRect)rect { _event_handler(self, nil, 7); } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
566 -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); } |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
567 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); } |
664
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
568 -(BOOL)isFlipped { return NO; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
569 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
570 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
571 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
572 /* Subclass for a MLE type */ |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
573 @interface DWMLE : NSTextView |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
574 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
575 void *userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
576 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
577 -(void *)userdata; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
578 -(void)setUserdata:(void *)input; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
579 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
580 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
581 @implementation DWMLE |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
582 -(void *)userdata { return userdata; } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
583 -(void)setUserdata:(void *)input { userdata = input; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
584 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
585 @end |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
586 |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
587 /* Subclass for a Container/List type */ |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
588 @interface DWContainer : NSTableView <NSTableViewDataSource> |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
589 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
590 void *userdata; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
591 NSMutableArray *tvcols; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
592 NSMutableArray *data; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
593 NSMutableArray *types; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
594 NSPointerArray *titles; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
595 int lastAddPoint, lastQueryPoint; |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
596 id scrollview; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
597 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
598 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
599 -(id)tableView:(NSTableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
600 /*-(void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex;*/ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
601 -(void *)userdata; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
602 -(void)setUserdata:(void *)input; |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
603 -(id)scrollview; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
604 -(void)setScrollview:(id)input; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
605 -(void)addColumn:(NSTableColumn *)input andType:(int)type; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
606 -(NSTableColumn *)getColumn:(int)col; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
607 -(int)addRow:(NSArray *)input; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
608 -(int)addRows:(int)number; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
609 -(void)editCell:(id)input at:(int)row and:(int)col; |
662
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
610 -(void)removeRow:(int)row; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
611 -(void)setRow:(int)row title:(void *)input; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
612 -(void *)getRowTitle:(int)row; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
613 -(id)getRow:(int)row and:(int)col; |
662
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
614 -(int)cellType:(int)col; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
615 -(int)lastAddPoint; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
616 -(int)lastQueryPoint; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
617 -(void)setLastQueryPoint:(int)input; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
618 -(void)clear; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
619 -(void)setup; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
620 -(void)selectionChanged:(id)sender; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
621 -(NSMenu *)menuForEvent:(NSEvent *)event; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
622 @end |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
623 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
624 @implementation DWContainer |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
625 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
626 { |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
627 if(tvcols && data) |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
628 { |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
629 int cols = (int)[tvcols count]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
630 if(cols) |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
631 { |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
632 return [data count] / cols; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
633 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
634 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
635 return 0; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
636 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
637 -(id)tableView:(NSTableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
638 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
639 if(tvcols) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
640 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
641 int z, col = -1; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
642 int count = (int)[tvcols count]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
643 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
644 for(z=0;z<count;z++) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
645 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
646 if([tvcols objectAtIndex:z] == aCol) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
647 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
648 col = z; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
649 break; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
650 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
651 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
652 if(col != -1) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
653 { |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
654 int index = (int)(aRow * count) + col; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
655 id this = [data objectAtIndex:index]; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
656 return ([this isKindOfClass:[NSNull class]]) ? nil : this; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
657 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
658 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
659 return nil; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
660 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
661 /*-(void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
662 { |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
663 if(tvcols) |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
664 { |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
665 int z, col = -1; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
666 int count = (int)[tvcols count]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
667 |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
668 for(z=0;z<count;z++) |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
669 { |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
670 if([tvcols objectAtIndex:z] == aTableColumn) |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
671 { |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
672 col = z; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
673 break; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
674 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
675 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
676 if(col != -1) |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
677 { |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
678 int index = (int)(rowIndex * count) + col; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
679 [data replaceObjectAtIndex:index withObject:anObject]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
680 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
681 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
682 }*/ |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
683 -(void *)userdata { return userdata; } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
684 -(void)setUserdata:(void *)input { userdata = input; } |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
685 -(NSScrollView *)scrollview { return scrollview; } |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
686 -(void)setScrollview:(NSScrollView *)input { scrollview = input; } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
687 -(void)addColumn:(NSTableColumn *)input andType:(int)type { if(tvcols) { [tvcols addObject:input]; [types addObject:[NSNumber numberWithInt:type]]; } } |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
688 -(NSTableColumn *)getColumn:(int)col { if(tvcols) { return [tvcols objectAtIndex:col]; } return nil; } |
687
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
689 -(int)insertRow:(NSArray *)input at:(int)index |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
690 { |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
691 if(data) |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
692 { |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
693 unsigned long start = [tvcols count] * index; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
694 NSIndexSet *set = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(start, start + [tvcols count])]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
695 if(index < lastAddPoint) |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
696 { |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
697 lastAddPoint++; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
698 } |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
699 [data insertObjects:input atIndexes:set]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
700 [titles insertPointer:NULL atIndex:index]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
701 [set release]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
702 return (int)[titles count]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
703 } |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
704 return 0; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
705 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
706 -(int)addRow:(NSArray *)input { if(data) { lastAddPoint = (int)[titles count]; [data addObjectsFromArray:input]; [titles addPointer:NULL]; return (int)[titles count]; } return 0; } |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
707 -(int)addRows:(int)number |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
708 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
709 if(tvcols) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
710 { |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
711 int count = (int)(number * [tvcols count]); |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
712 int z; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
713 |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
714 lastAddPoint = (int)[titles count]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
715 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
716 for(z=0;z<count;z++) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
717 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
718 [data addObject:[NSNull null]]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
719 } |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
720 for(z=0;z<number;z++) |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
721 { |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
722 [titles addPointer:NULL]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
723 } |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
724 return (int)[titles count]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
725 } |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
726 return 0; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
727 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
728 -(void)editCell:(id)input at:(int)row and:(int)col |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
729 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
730 if(tvcols && input) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
731 { |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
732 int index = (int)(row * [tvcols count]) + col; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
733 [data replaceObjectAtIndex:index withObject:input]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
734 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
735 } |
662
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
736 -(void)removeRow:(int)row |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
737 { |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
738 if(tvcols) |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
739 { |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
740 int z, start, end; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
741 int count = (int)[tvcols count]; |
662
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
742 |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
743 start = count * row; |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
744 end = start + count; |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
745 |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
746 for(z=start;z<end;z++) |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
747 { |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
748 [data removeObjectAtIndex:z]; |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
749 } |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
750 [titles removePointerAtIndex:row]; |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
751 if(lastAddPoint > 0 && lastAddPoint < row) |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
752 { |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
753 lastAddPoint--; |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
754 } |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
755 } |
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
756 } |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
757 -(void)setRow:(int)row title:(void *)input { if(titles && input) { [titles replacePointerAtIndex:row withPointer:input]; } } |
683
7385011c3327
Fixed a minor issue causing crashes when right clicking on an empty container.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
682
diff
changeset
|
758 -(void *)getRowTitle:(int)row { if(titles && row > -1) { return [titles pointerAtIndex:row]; } return NULL; } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
759 -(id)getRow:(int)row and:(int)col { if(data) { int index = (int)(row * [tvcols count]) + col; return [data objectAtIndex:index]; } return nil; } |
662
d7badd5606ca
Removed the Carbon source file, and changes to configure to build the Cocoa version.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
661
diff
changeset
|
760 -(int)cellType:(int)col { return [[types objectAtIndex:col] intValue]; } |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
761 -(int)lastAddPoint { return lastAddPoint; } |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
762 -(int)lastQueryPoint { return lastQueryPoint; } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
763 -(void)setLastQueryPoint:(int)input { lastQueryPoint = input; } |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
764 -(void)clear { if(data) { [data removeAllObjects]; while([titles count]) { [titles removePointerAtIndex:0]; } } lastAddPoint = 0; } |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
765 -(void)setup |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
766 { |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
767 tvcols = [[NSMutableArray alloc] init]; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
768 data = [[NSMutableArray alloc] init]; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
769 types = [[NSMutableArray alloc] init]; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
770 titles = [NSPointerArray pointerArrayWithWeakObjects]; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
771 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectionChanged:) name:NSTableViewSelectionDidChangeNotification object:[self window]]; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
772 } |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
773 -(void)selectionChanged:(id)sender |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
774 { |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
775 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9); |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
776 } |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
777 -(NSMenu *)menuForEvent:(NSEvent *)event |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
778 { |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
779 int row; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
780 NSPoint where = [self convertPoint:[event locationInWindow] fromView:nil]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
781 row = (int)[self rowAtPoint:where]; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
782 _event_handler(self, (NSEvent *)[self getRowTitle:row], 10); |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
783 return nil; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
784 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
785 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
786 @end |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
787 |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
788 /* Dive into the tree showing all nodes */ |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
789 void _free_tree_recurse(NSMutableArray *node, NSPointerArray *item) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
790 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
791 if(node) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
792 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
793 int count = (int)[node count]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
794 int z; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
795 |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
796 for(z=0;z<count;z++) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
797 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
798 NSPointerArray *pnt = [node objectAtIndex:z]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
799 NSMutableArray *children = (NSMutableArray *)[pnt pointerAtIndex:3]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
800 |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
801 if(children) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
802 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
803 if(item == pnt) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
804 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
805 _free_tree_recurse(children, NULL); |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
806 } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
807 else |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
808 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
809 _free_tree_recurse(children, item); |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
810 } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
811 } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
812 if(!item || item == pnt) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
813 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
814 [pnt release]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
815 } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
816 } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
817 } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
818 if(!item) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
819 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
820 [node release]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
821 } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
822 } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
823 |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
824 /* Subclass for a Tree type */ |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
825 @interface DWTree : NSOutlineView <NSOutlineViewDataSource> |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
826 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
827 void *userdata; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
828 NSTableColumn *imagecol; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
829 NSTableColumn *textcol; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
830 NSMutableArray *data; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
831 /* Each data item consists of a linked lists of tree item data. |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
832 * NSImage *, NSString *, Item Data *, NSMutableArray * of Children |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
833 */ |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
834 id scrollview; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
835 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
836 -(id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
837 -(BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
838 -(int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
839 -(id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
840 -(void)addTree:(NSPointerArray *)item and:(NSPointerArray *)parent; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
841 -(void *)userdata; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
842 -(void)setUserdata:(void *)input; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
843 -(NSScrollView *)scrollview; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
844 -(void)setScrollview:(NSScrollView *)input; |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
845 -(void)deleteNode:(NSPointerArray *)item; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
846 -(void)clear; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
847 @end |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
848 |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
849 @implementation DWTree |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
850 -(id)init |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
851 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
852 self = [super init]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
853 |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
854 if (self) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
855 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
856 imagecol = [[NSTableColumn alloc] init]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
857 NSImageCell *imagecell = [[[NSImageCell alloc] init] autorelease]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
858 [imagecol setDataCell:imagecell]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
859 [imagecol setResizingMask:NSTableColumnNoResizing]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
860 [imagecol setWidth:20]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
861 [self addTableColumn:imagecol]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
862 textcol = [[NSTableColumn alloc] init]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
863 [self addTableColumn:textcol]; |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
864 [self setOutlineTableColumn:textcol]; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
865 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
866 return self; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
867 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
868 -(id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
869 { |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
870 if(item) |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
871 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
872 NSMutableArray *array = [item pointerAtIndex:3]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
873 return array ? [array objectAtIndex:index] : nil; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
874 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
875 else |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
876 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
877 return [data objectAtIndex:index]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
878 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
879 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
880 -(BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
881 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
882 return [self outlineView:outlineView numberOfChildrenOfItem:item] != 0; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
883 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
884 -(int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
885 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
886 if(item) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
887 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
888 if([item isKindOfClass:[NSPointerArray class]]) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
889 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
890 NSMutableArray *array = [item pointerAtIndex:3]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
891 return array ? (int)[array count] : 0; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
892 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
893 else |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
894 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
895 return 0; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
896 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
897 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
898 else |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
899 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
900 return data ? (int)[data count] : 0; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
901 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
902 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
903 -(id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
904 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
905 if(item) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
906 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
907 if([item isKindOfClass:[NSPointerArray class]]) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
908 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
909 NSPointerArray *this = (NSPointerArray *)item; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
910 if(tableColumn == imagecol) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
911 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
912 return [this pointerAtIndex:0]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
913 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
914 return [this pointerAtIndex:1]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
915 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
916 else |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
917 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
918 return nil; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
919 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
920 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
921 return @"List Root"; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
922 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
923 -(void)addTree:(NSPointerArray *)item and:(NSPointerArray *)parent; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
924 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
925 NSMutableArray *children = data; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
926 if(parent) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
927 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
928 children = [parent pointerAtIndex:3]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
929 if(!children) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
930 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
931 children = [[NSMutableArray alloc] init]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
932 [parent replacePointerAtIndex:3 withPointer:children]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
933 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
934 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
935 else |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
936 { |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
937 if(!data) |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
938 { |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
939 children = data = [[NSMutableArray alloc] init]; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
940 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
941 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
942 [children addObject:item]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
943 } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
944 -(void *)userdata { return userdata; } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
945 -(void)setUserdata:(void *)input { userdata = input; } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
946 -(NSScrollView *)scrollview { return scrollview; } |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
947 -(void)setScrollview:(NSScrollView *)input { scrollview = input; } |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
948 -(void)deleteNode:(NSPointerArray *)item { _free_tree_recurse(data, item); } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
949 -(void)clear { NSMutableArray *toclear = data; data = nil; _free_tree_recurse(toclear, NULL); [self reloadData]; } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
950 -(void)dealloc |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
951 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
952 UserData *root = userdata; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
953 _remove_userdata(&root, NULL, TRUE); |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
954 _free_tree_recurse(data, NULL); |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
955 [imagecol release]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
956 [textcol release]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
957 [super dealloc]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
958 } |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
959 @end |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
960 |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
961 /* Subclass for a Calendar type */ |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
962 @interface DWCalendar : NSDatePicker |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
963 { |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
964 void *userdata; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
965 } |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
966 -(void *)userdata; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
967 -(void)setUserdata:(void *)input; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
968 @end |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
969 |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
970 @implementation DWCalendar |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
971 -(void *)userdata { return userdata; } |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
972 -(void)setUserdata:(void *)input { userdata = input; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
973 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
974 @end |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
975 |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
976 /* Subclass for a Combobox type */ |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
977 @interface DWComboBox : NSComboBox |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
978 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
979 void *userdata; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
980 } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
981 -(void *)userdata; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
982 -(void)setUserdata:(void *)input; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
983 @end |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
984 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
985 @implementation DWComboBox |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
986 -(void *)userdata { return userdata; } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
987 -(void)setUserdata:(void *)input { userdata = input; } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
988 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
989 @end |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
990 |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
991 /* Subclass for a stepper component of the spinbutton type */ |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
992 /* This is a bad way of doing this... but I can't get the other methods to work */ |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
993 @interface DWStepper : NSStepper |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
994 { |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
995 id textfield; |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
996 } |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
997 -(void)setTextfield:(id)input; |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
998 -(id)textfield; |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
999 -(void)mouseDown:(NSEvent *)event; |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1000 -(void)mouseUp:(NSEvent *)event; |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1001 @end |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1002 |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1003 @implementation DWStepper |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1004 -(void)setTextfield:(id)input { textfield = input; } |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1005 -(id)textfield { return textfield; } |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1006 -(void)mouseDown:(NSEvent *)event |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1007 { |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1008 [super mouseDown:event]; |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1009 if([[NSApp currentEvent] type] == NSLeftMouseUp) |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1010 { |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1011 [textfield takeIntValueFrom:self]; |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1012 } |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1013 } |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1014 -(void)mouseUp:(NSEvent *)event |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1015 { |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1016 [textfield takeIntValueFrom:self]; |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1017 } |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1018 @end |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1019 |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1020 /* Subclass for a Spinbutton type */ |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1021 @interface DWSpinButton : NSView <NSTextFieldDelegate> |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1022 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1023 void *userdata; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1024 NSTextField *textfield; |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1025 DWStepper *stepper; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1026 } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1027 -(id)init; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1028 -(void *)userdata; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1029 -(void)setUserdata:(void *)input; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1030 -(NSTextField *)textfield; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1031 -(NSStepper *)stepper; |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1032 -(void)controlTextDidChange:(NSNotification *)aNotification; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1033 @end |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1034 |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1035 @implementation DWSpinButton |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1036 -(id)init |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1037 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1038 self = [super init]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1039 |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1040 if(self) |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1041 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1042 textfield = [[NSTextField alloc] init]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1043 [self addSubview:textfield]; |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1044 stepper = [[DWStepper alloc] init]; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1045 [self addSubview:stepper]; |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1046 [stepper setTextfield:textfield]; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1047 [textfield takeIntValueFrom:stepper]; |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1048 [textfield setDelegate:self]; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1049 } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1050 return self; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1051 } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1052 -(void *)userdata { return userdata; } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1053 -(void)setUserdata:(void *)input { userdata = input; } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1054 -(NSTextField *)textfield { return textfield; } |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1055 -(NSStepper *)stepper { return stepper; } |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1056 -(void)controlTextDidChange:(NSNotification *)aNotification |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1057 { |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1058 [stepper takeIntValueFrom:textfield]; |
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
1059 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1060 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1061 @end |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
1062 |
684
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1063 /* Subclass for a MDI type |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1064 * This is just a box for display purposes... but it is a |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1065 * unique class so it can be identified when creating windows. |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1066 */ |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1067 @interface DWMDI : DWBox {} |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1068 @end |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1069 |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1070 @implementation DWMDI |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1071 @end |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
1072 |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1073 /* Subclass for a test object type */ |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1074 @interface DWObject : NSObject {} |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1075 -(void)uselessThread:(id)sender; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1076 @end |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1077 |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1078 @implementation DWObject |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1079 -(void)uselessThread:(id)sender { /* Thread only to initialize threading */ } |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1080 @end |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1081 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1082 typedef struct |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1083 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1084 ULONG message; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1085 char name[30]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1086 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1087 } SignalList; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1088 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1089 /* List of signals */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1090 #define SIGNALMAX 16 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1091 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1092 SignalList SignalTranslate[SIGNALMAX] = { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1093 { 1, DW_SIGNAL_CONFIGURE }, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1094 { 2, DW_SIGNAL_KEY_PRESS }, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1095 { 3, DW_SIGNAL_BUTTON_PRESS }, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1096 { 4, DW_SIGNAL_BUTTON_RELEASE }, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1097 { 5, DW_SIGNAL_MOTION_NOTIFY }, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1098 { 6, DW_SIGNAL_DELETE }, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1099 { 7, DW_SIGNAL_EXPOSE }, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1100 { 8, DW_SIGNAL_CLICKED }, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1101 { 9, DW_SIGNAL_ITEM_ENTER }, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1102 { 10, DW_SIGNAL_ITEM_CONTEXT }, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1103 { 11, DW_SIGNAL_LIST_SELECT }, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1104 { 12, DW_SIGNAL_ITEM_SELECT }, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1105 { 13, DW_SIGNAL_SET_FOCUS }, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1106 { 14, DW_SIGNAL_VALUE_CHANGED }, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1107 { 15, DW_SIGNAL_SWITCH_PAGE }, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1108 { 16, DW_SIGNAL_TREE_EXPAND } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1109 }; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1110 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1111 /* This function adds a signal handler callback into the linked list. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1112 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1113 void _new_signal(ULONG message, HWND window, int id, void *signalfunction, void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1114 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1115 SignalHandler *new = malloc(sizeof(SignalHandler)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1116 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1117 new->message = message; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1118 new->window = window; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1119 new->id = id; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1120 new->signalfunction = signalfunction; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1121 new->data = data; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1122 new->next = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1123 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1124 if (!Root) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1125 Root = new; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1126 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1127 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1128 SignalHandler *prev = NULL, *tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1129 while(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1130 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1131 if(tmp->message == message && |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1132 tmp->window == window && |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1133 tmp->id == id && |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1134 tmp->signalfunction == signalfunction) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1135 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1136 tmp->data = data; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1137 free(new); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1138 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1139 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1140 prev = tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1141 tmp = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1142 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1143 if(prev) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1144 prev->next = new; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1145 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1146 Root = new; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1147 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1148 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1149 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1150 /* Finds the message number for a given signal name */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1151 ULONG _findsigmessage(char *signame) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1152 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1153 int z; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1154 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1155 for(z=0;z<SIGNALMAX;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1156 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1157 if(strcasecmp(signame, SignalTranslate[z].name) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1158 return SignalTranslate[z].message; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1159 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1160 return 0L; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1161 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1162 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1163 unsigned long _foreground = 0xAAAAAA, _background = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1164 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1165 /* This function calculates how much space the widgets and boxes require |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1166 * and does expansion as necessary. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1167 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1168 static int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1169 int pass, int *usedpadx, int *usedpady) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1170 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1171 int z, currentx = 0, currenty = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1172 int uymax = 0, uxmax = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1173 int upymax = 0, upxmax = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1174 /* Used for the SIZEEXPAND */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1175 int nux = *usedx, nuy = *usedy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1176 int nupx = *usedpadx, nupy = *usedpady; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1177 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1178 (*usedx) += (thisbox->pad * 2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1179 (*usedy) += (thisbox->pad * 2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1180 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1181 for(z=0;z<thisbox->count;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1182 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1183 if(thisbox->items[z].type == TYPEBOX) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1184 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1185 int initialx, initialy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1186 DWBox *box = thisbox->items[z].hwnd; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1187 Box *tmp = [box box]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1188 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1189 initialx = x - (*usedx); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1190 initialy = y - (*usedy); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1191 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1192 if(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1193 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1194 int newx, newy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1195 int nux = *usedx, nuy = *usedy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1196 int upx = *usedpadx + (tmp->pad*2), upy = *usedpady + (tmp->pad*2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1197 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1198 /* On the second pass we know how big the box needs to be and how |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1199 * much space we have, so we can calculate a ratio for the new box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1200 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1201 if(pass == 2) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1202 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1203 int deep = *depth + 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1204 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1205 _resize_box(tmp, &deep, x, y, &nux, &nuy, 1, &upx, &upy); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1206 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1207 tmp->upx = upx - *usedpadx; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1208 tmp->upy = upy - *usedpady; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1209 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1210 newx = x - nux; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1211 newy = y - nuy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1212 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1213 tmp->width = thisbox->items[z].width = initialx - newx; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1214 tmp->height = thisbox->items[z].height = initialy - newy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1215 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1216 tmp->parentxratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1217 tmp->parentyratio = thisbox->yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1218 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1219 tmp->parentpad = tmp->pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1220 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1221 /* Just in case */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1222 tmp->xratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1223 tmp->yratio = thisbox->yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1224 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1225 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1226 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1227 if((thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1228 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)))); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1229 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1230 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1231 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1232 if((thisbox->items[z].width-tmp->upx)!=0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1233 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1234 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1235 if(thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1236 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1237 if((thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1238 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)))); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1239 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1240 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1241 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1242 if((thisbox->items[z].height-tmp->upy)!=0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1243 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1244 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1245 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1246 nux = *usedx; nuy = *usedy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1247 upx = *usedpadx + (tmp->pad*2); upy = *usedpady + (tmp->pad*2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1248 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1249 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1250 (*depth)++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1251 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1252 _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &upx, &upy); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1253 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1254 (*depth)--; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1255 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1256 newx = x - nux; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1257 newy = y - nuy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1258 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1259 tmp->minwidth = thisbox->items[z].width = initialx - newx; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1260 tmp->minheight = thisbox->items[z].height = initialy - newy; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1261 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1262 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1263 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1264 if(pass > 1 && *depth > 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1265 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1266 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1267 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1268 if((thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1269 thisbox->items[z].xratio = 1.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1270 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1271 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)))); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1272 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1273 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1274 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1275 if(thisbox->minwidth-thisbox->upx == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1276 thisbox->items[z].xratio = 1.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1277 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1278 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1279 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1280 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1281 if(thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1282 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1283 if((thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1284 thisbox->items[z].yratio = 1.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1285 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1286 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)))); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1287 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1288 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1289 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1290 if(thisbox->minheight-thisbox->upy == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1291 thisbox->items[z].yratio = 1.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1292 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1293 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1294 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1295 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1296 if(thisbox->items[z].type == TYPEBOX) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1297 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1298 DWBox *box = thisbox->items[z].hwnd; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1299 Box *tmp = [box box]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1300 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1301 if(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1302 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1303 tmp->parentxratio = thisbox->items[z].xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1304 tmp->parentyratio = thisbox->items[z].yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1305 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1306 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1307 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1308 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1309 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1310 thisbox->items[z].xratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1311 thisbox->items[z].yratio = thisbox->yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1312 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1313 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1314 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1315 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1316 if((thisbox->items[z].width + (thisbox->items[z].pad*2)) > uxmax) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1317 uxmax = (thisbox->items[z].width + (thisbox->items[z].pad*2)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1318 if(thisbox->items[z].hsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1319 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1320 if(((thisbox->items[z].pad*2) + thisbox->items[z].width) > upxmax) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1321 upxmax = (thisbox->items[z].pad*2) + thisbox->items[z].width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1322 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1323 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1324 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1325 if(thisbox->items[z].pad*2 > upxmax) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1326 upxmax = thisbox->items[z].pad*2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1327 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1328 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1329 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1330 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1331 if(thisbox->items[z].width == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1332 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1333 /* figure out how much space this item requires */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1334 /* thisbox->items[z].width = */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1335 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1336 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1337 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1338 (*usedx) += thisbox->items[z].width + (thisbox->items[z].pad*2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1339 if(thisbox->items[z].hsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1340 (*usedpadx) += (thisbox->items[z].pad*2) + thisbox->items[z].width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1341 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1342 (*usedpadx) += thisbox->items[z].pad*2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1343 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1344 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1345 if(thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1346 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1347 if((thisbox->items[z].height + (thisbox->items[z].pad*2)) > uymax) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1348 uymax = (thisbox->items[z].height + (thisbox->items[z].pad*2)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1349 if(thisbox->items[z].vsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1350 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1351 if(((thisbox->items[z].pad*2) + thisbox->items[z].height) > upymax) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1352 upymax = (thisbox->items[z].pad*2) + thisbox->items[z].height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1353 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1354 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1355 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1356 if(thisbox->items[z].pad*2 > upymax) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1357 upymax = thisbox->items[z].pad*2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1358 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1359 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1360 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1361 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1362 if(thisbox->items[z].height == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1363 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1364 /* figure out how much space this item requires */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1365 /* thisbox->items[z].height = */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1366 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1367 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1368 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1369 (*usedy) += thisbox->items[z].height + (thisbox->items[z].pad*2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1370 if(thisbox->items[z].vsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1371 (*usedpady) += (thisbox->items[z].pad*2) + thisbox->items[z].height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1372 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1373 (*usedpady) += thisbox->items[z].pad*2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1374 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1375 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1376 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1377 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1378 (*usedx) += uxmax; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1379 (*usedy) += uymax; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1380 (*usedpadx) += upxmax; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1381 (*usedpady) += upymax; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1382 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1383 currentx += thisbox->pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1384 currenty += thisbox->pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1385 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1386 /* The second pass is for expansion and actual placement. */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1387 if(pass > 1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1388 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1389 /* Any SIZEEXPAND items should be set to uxmax/uymax */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1390 for(z=0;z<thisbox->count;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1391 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1392 if(thisbox->items[z].hsize == SIZEEXPAND && thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1393 thisbox->items[z].width = uxmax-(thisbox->items[z].pad*2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1394 if(thisbox->items[z].vsize == SIZEEXPAND && thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1395 thisbox->items[z].height = uymax-(thisbox->items[z].pad*2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1396 /* Run this code segment again to finalize the sized after setting uxmax/uymax values. */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1397 if(thisbox->items[z].type == TYPEBOX) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1398 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1399 DWBox *box = thisbox->items[z].hwnd; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1400 Box *tmp = [box box]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1401 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1402 if(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1403 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1404 if(*depth > 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1405 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1406 float calcval; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1407 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1408 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1409 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1410 calcval = (float)(tmp->minwidth-((thisbox->items[z].pad*2)+(thisbox->pad*2))); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1411 if(calcval == 0.0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1412 tmp->xratio = thisbox->xratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1413 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1414 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/calcval; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1415 tmp->width = thisbox->items[z].width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1416 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1417 if(thisbox->type == DW_HORZ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1418 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1419 calcval = (float)(tmp->minheight-((thisbox->items[z].pad*2)+(thisbox->pad*2))); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1420 if(calcval == 0.0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1421 tmp->yratio = thisbox->yratio; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1422 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1423 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/calcval; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1424 tmp->height = thisbox->items[z].height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1425 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1426 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1427 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1428 (*depth)++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1429 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1430 _resize_box(tmp, depth, x, y, &nux, &nuy, 3, &nupx, &nupy); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1431 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1432 (*depth)--; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1433 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1434 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1435 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1436 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1437 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1438 for(z=0;z<(thisbox->count);z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1439 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1440 int height = thisbox->items[z].height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1441 int width = thisbox->items[z].width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1442 int pad = thisbox->items[z].pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1443 NSView *handle = thisbox->items[z].hwnd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1444 NSPoint point; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1445 NSSize size; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1446 int vectorx, vectory; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1447 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1448 /* When upxmax != pad*2 then ratios are incorrect. */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1449 vectorx = (int)((width*thisbox->items[z].xratio)-width); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1450 vectory = (int)((height*thisbox->items[z].yratio)-height); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1451 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1452 if(width > 0 && height > 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1453 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1454 /* This is a hack to fix rounding of the sizing */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1455 if(*depth == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1456 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1457 vectorx++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1458 vectory++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1459 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1460 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1461 /* If this item isn't going to expand... reset the vectors to 0 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1462 if(thisbox->items[z].vsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1463 vectory = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1464 if(thisbox->items[z].hsize != SIZEEXPAND) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1465 vectorx = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1466 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1467 point.x = currentx + pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1468 point.y = currenty + pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1469 size.width = width + vectorx; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1470 size.height = height + vectory; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1471 [handle setFrameOrigin:point]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1472 [handle setFrameSize:size]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1473 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1474 /* Special handling for notebook controls */ |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1475 if([handle isMemberOfClass:[DWNotebook class]]) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1476 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1477 DWNotebook *notebook = (DWNotebook *)handle; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1478 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1479 DWBox *view = [notepage view]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1480 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1481 if(view != nil) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1482 { |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1483 Box *box = [view box]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1484 NSSize size = [view frame].size; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1485 _do_resize(box, size.width, size.height); |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1486 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1487 } |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1488 /* Special handling for spinbutton controls */ |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1489 else if([handle isMemberOfClass:[DWSpinButton class]]) |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1490 { |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1491 DWSpinButton *spinbutton = (DWSpinButton *)handle; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1492 NSTextField *textfield = [spinbutton textfield]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1493 NSStepper *stepper = [spinbutton stepper]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1494 [textfield setFrameOrigin:NSMakePoint(0,0)]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1495 [textfield setFrameSize:NSMakeSize(size.width-20,size.height)]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1496 [stepper setFrameOrigin:NSMakePoint(size.width-20,0)]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1497 [stepper setFrameSize:NSMakeSize(20,size.height)]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
1498 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1499 else if([handle isMemberOfClass:[DWRender class]]) |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1500 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1501 _event_handler(handle, nil, 1); |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1502 } |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1503 else if([handle isMemberOfClass:[DWSplitBar class]] && size.width > 20 && size.height > 20) |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1504 { |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1505 DWSplitBar *split = (DWSplitBar *)handle; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1506 float percent = [split percent]; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1507 |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1508 if(percent > 0) |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1509 { |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1510 dw_splitbar_set(handle, percent); |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1511 [split setPercent:0]; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1512 } |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
1513 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1514 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1515 if(thisbox->type == DW_HORZ) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1516 currentx += width + vectorx + (pad * 2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1517 if(thisbox->type == DW_VERT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1518 currenty += height + vectory + (pad * 2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1519 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1520 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1521 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1522 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1523 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1524 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1525 static void _do_resize(Box *thisbox, int x, int y) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1526 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1527 if(x != 0 && y != 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1528 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1529 if(thisbox) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1530 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1531 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1532 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1533 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1534 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1535 if(usedx-usedpadx == 0 || usedy-usedpady == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1536 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1537 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1538 thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1539 thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1540 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1541 usedx = usedy = usedpadx = usedpady = depth = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1542 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1543 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1544 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1545 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1546 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1547 |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1548 NSMenu *_generate_main_menu() |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1549 { |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1550 /* This only works on 10.6 so we have a backup method */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1551 NSString * applicationName = [[NSRunningApplication currentApplication] localizedName]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1552 if(applicationName == nil) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1553 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1554 applicationName = [[NSProcessInfo processInfo] processName]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1555 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1556 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1557 /* Create the main menu */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1558 NSMenu * mainMenu = [[[NSMenu alloc] initWithTitle:@"MainMenu"] autorelease]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1559 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1560 NSMenuItem * mitem = [mainMenu addItemWithTitle:@"Apple" action:NULL keyEquivalent:@""]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1561 NSMenu * menu = [[[NSMenu alloc] initWithTitle:@"Apple"] autorelease]; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1562 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1563 [DWApp performSelector:@selector(setAppleMenu:) withObject:menu]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1564 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1565 /* Setup the Application menu */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1566 NSMenuItem * item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"About", nil), applicationName] |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1567 action:@selector(orderFrontStandardAboutPanel:) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1568 keyEquivalent:@""]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1569 [item setTarget:DWApp]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1570 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1571 [menu addItem:[NSMenuItem separatorItem]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1572 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1573 item = [menu addItemWithTitle:NSLocalizedString(@"Preferences...", nil) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1574 action:NULL |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1575 keyEquivalent:@","]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1576 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1577 [menu addItem:[NSMenuItem separatorItem]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1578 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1579 item = [menu addItemWithTitle:NSLocalizedString(@"Services", nil) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1580 action:NULL |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1581 keyEquivalent:@""]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1582 NSMenu * servicesMenu = [[[NSMenu alloc] initWithTitle:@"Services"] autorelease]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1583 [menu setSubmenu:servicesMenu forItem:item]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1584 [DWApp setServicesMenu:servicesMenu]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1585 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1586 [menu addItem:[NSMenuItem separatorItem]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1587 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1588 item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Hide", nil), applicationName] |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1589 action:@selector(hide:) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1590 keyEquivalent:@"h"]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1591 [item setTarget:DWApp]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1592 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1593 item = [menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1594 action:@selector(hideOtherApplications:) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1595 keyEquivalent:@"h"]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1596 [item setKeyEquivalentModifierMask:NSCommandKeyMask | NSAlternateKeyMask]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1597 [item setTarget:DWApp]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1598 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1599 item = [menu addItemWithTitle:NSLocalizedString(@"Show All", nil) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1600 action:@selector(unhideAllApplications:) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1601 keyEquivalent:@""]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1602 [item setTarget:DWApp]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1603 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1604 [menu addItem:[NSMenuItem separatorItem]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1605 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1606 item = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Quit", nil), applicationName] |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1607 action:@selector(terminate:) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1608 keyEquivalent:@"q"]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1609 [item setTarget:DWApp]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1610 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1611 [mainMenu setSubmenu:menu forItem:mitem]; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1612 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1613 return mainMenu; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1614 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1615 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1616 /* |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1617 * Initializes the Dynamic Windows engine. |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1618 * Parameters: |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1619 * newthread: True if this is the only thread. |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1620 * False if there is already a message loop running. |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1621 */ |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1622 int API dw_init(int newthread, int argc, char *argv[]) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1623 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1624 /* Create the application object */ |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1625 DWApp = [NSApplication sharedApplication]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1626 /* Create a run loop for doing manual loops */ |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1627 DWRunLoop = [NSRunLoop alloc]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1628 /* Create object for handling timers */ |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
1629 DWHandler = [[DWTimerHandler alloc] init]; |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
1630 /* If we aren't using garbage collection we need autorelease pools */ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1631 #if !defined(GARBAGE_COLLECT) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1632 pool = [[NSAutoreleasePool alloc] init]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1633 #endif |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
1634 /* Create a default main menu, with just the application menu */ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1635 DWMainMenu = _generate_main_menu(); |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
1636 [DWApp setMainMenu:DWMainMenu]; |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
1637 DWObject *test = [[DWObject alloc] init]; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
1638 /* Use NSThread to start a dummy thread to initialize the threading subsystem */ |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
1639 NSThread *thread = [[ NSThread alloc] initWithTarget:test selector:@selector(uselessThread:) object:nil]; |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
1640 [thread start]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1641 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1642 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1643 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1644 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1645 * Runs a message loop for Dynamic Windows. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1646 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1647 void API dw_main(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1648 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1649 [DWApp run]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1650 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1651 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1652 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1653 * Runs a message loop for Dynamic Windows, for a period of milliseconds. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1654 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1655 * milliseconds: Number of milliseconds to run the loop for. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1656 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1657 void API dw_main_sleep(int milliseconds) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1658 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1659 double seconds = (double)milliseconds/1000.0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1660 NSDate *time = [[NSDate alloc] initWithTimeIntervalSinceNow:seconds]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1661 [DWRunLoop runUntilDate:time]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1662 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1663 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1664 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1665 * Processes a single message iteration and returns. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1666 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1667 void API dw_main_iteration(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1668 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1669 [DWRunLoop limitDateForMode:NSDefaultRunLoopMode]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1670 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1671 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1672 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1673 * Cleanly terminates a DW session, should be signal handler safe. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1674 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1675 * exitcode: Exit code reported to the operating system. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1676 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1677 void API dw_exit(int exitcode) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1678 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1679 exit(exitcode); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1680 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1681 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1682 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1683 * Free's memory allocated by dynamic windows. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1684 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1685 * ptr: Pointer to dynamic windows allocated |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1686 * memory to be free()'d. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1687 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1688 void API dw_free(void *ptr) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1689 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1690 free(ptr); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1691 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1692 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1693 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1694 * Returns a pointer to a static buffer which containes the |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1695 * current user directory. Or the root directory (C:\ on |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1696 * OS/2 and Windows). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1697 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1698 char *dw_user_dir(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1699 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1700 static char _user_dir[1024] = ""; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1701 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1702 if(!_user_dir[0]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1703 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1704 char *home = getenv("HOME"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1705 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1706 if(home) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1707 strcpy(_user_dir, home); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1708 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1709 strcpy(_user_dir, "/"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1710 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1711 return _user_dir; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1712 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1713 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1714 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1715 * Displays a Message Box with given text and title.. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1716 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1717 * title: The title of the message box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1718 * flags: flags to indicate buttons and icon |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1719 * format: printf style format string. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1720 * ...: Additional variables for use in the format. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1721 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1722 int API dw_messagebox(char *title, int flags, char *format, ...) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1723 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1724 int iResponse; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1725 NSString *button1 = @"OK"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1726 NSString *button2 = nil; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1727 NSString *button3 = nil; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1728 va_list args; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1729 char outbuf[1000]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1730 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1731 va_start(args, format); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1732 vsprintf(outbuf, format, args); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1733 va_end(args); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1734 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1735 if(flags & DW_MB_OKCANCEL) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1736 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1737 button2 = @"Cancel"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1738 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1739 else if(flags & DW_MB_YESNO) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1740 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1741 button1 = @"Yes"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1742 button2 = @"No"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1743 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1744 else if(flags & DW_MB_YESNOCANCEL) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1745 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1746 button1 = @"Yes"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1747 button2 = @"No"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1748 button3 = @"Cancel"; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1749 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1750 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1751 if(flags & DW_MB_ERROR) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1752 { |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
1753 iResponse = (int) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1754 NSRunCriticalAlertPanel([ NSString stringWithUTF8String:title ], |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1755 [ NSString stringWithUTF8String:outbuf ], |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1756 button1, button2, button3); } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1757 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1758 { |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
1759 iResponse = (int) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1760 NSRunAlertPanel([ NSString stringWithUTF8String:title ], |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1761 [ NSString stringWithUTF8String:outbuf ], |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1762 button1, button2, button3); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1763 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1764 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1765 switch(iResponse) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1766 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1767 case NSAlertDefaultReturn: /* user pressed OK */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1768 if(flags & DW_MB_YESNO || flags & DW_MB_YESNOCANCEL) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1769 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1770 return DW_MB_RETURN_YES; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1771 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1772 return DW_MB_RETURN_OK; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1773 case NSAlertAlternateReturn: /* user pressed Cancel */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1774 if(flags & DW_MB_OKCANCEL) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1775 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1776 return DW_MB_RETURN_CANCEL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1777 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1778 return DW_MB_RETURN_NO; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1779 case NSAlertOtherReturn: /* user pressed the third button */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1780 return DW_MB_RETURN_CANCEL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1781 case NSAlertErrorReturn: /* an error occurred */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1782 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1783 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1784 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1785 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1786 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1787 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1788 * Opens a file dialog and queries user selection. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1789 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1790 * title: Title bar text for dialog. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1791 * defpath: The default path of the open dialog. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1792 * ext: Default file extention. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1793 * flags: DW_FILE_OPEN or DW_FILE_SAVE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1794 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1795 * NULL on error. A malloced buffer containing |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1796 * the file path on success. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1797 * |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1798 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1799 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1800 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1801 if(flags == DW_FILE_OPEN) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1802 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1803 /* Create the File Open Dialog class. */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1804 NSOpenPanel* openDlg = [NSOpenPanel openPanel]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1805 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1806 /* Enable the selection of files in the dialog. */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1807 [openDlg setCanChooseFiles:YES]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1808 [openDlg setCanChooseDirectories:NO]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1809 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1810 /* Disable multiple selection */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1811 [openDlg setAllowsMultipleSelection:NO]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1812 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1813 /* Display the dialog. If the OK button was pressed, |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1814 * process the files. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1815 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1816 if([openDlg runModal] == NSOKButton) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1817 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1818 /* Get an array containing the full filenames of all |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1819 * files and directories selected. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1820 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1821 NSArray* files = [openDlg filenames]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1822 NSString* fileName = [files objectAtIndex:0]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1823 return strdup([ fileName UTF8String ]); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1824 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1825 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1826 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1827 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1828 /* Create the File Save Dialog class. */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1829 NSSavePanel* saveDlg = [NSSavePanel savePanel]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1830 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1831 /* Enable the creation of directories in the dialog. */ |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1832 [saveDlg setCanCreateDirectories:YES]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1833 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1834 /* Display the dialog. If the OK button was pressed, |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1835 * process the files. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1836 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1837 if([saveDlg runModal] == NSFileHandlingPanelOKButton) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1838 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1839 /* Get an array containing the full filenames of all |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1840 * files and directories selected. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1841 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1842 NSString* fileName = [saveDlg filename]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1843 return strdup([ fileName UTF8String ]); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1844 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1845 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1846 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1847 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1848 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1849 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1850 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1851 * Gets the contents of the default clipboard as text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1852 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1853 * None. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1854 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1855 * Pointer to an allocated string of text or NULL if clipboard empty or contents could not |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1856 * be converted to text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1857 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1858 char *dw_clipboard_get_text() |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1859 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1860 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1861 NSString *str = [pasteboard stringForType:NSStringPboardType]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1862 if(str != nil) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1863 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1864 return strdup([ str UTF8String ]); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1865 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1866 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1867 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1868 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1869 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1870 * Sets the contents of the default clipboard to the supplied text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1871 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1872 * Text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1873 */ |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1874 void dw_clipboard_set_text( char *str, int len) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1875 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1876 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1877 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1878 [pasteboard clearContents]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1879 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
1880 [pasteboard setString:[ NSString stringWithUTF8String:str ] forType:NSStringPboardType]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1881 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1882 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1883 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1884 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1885 * Allocates and initializes a dialog struct. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1886 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1887 * data: User defined data to be passed to functions. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1888 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1889 DWDialog * API dw_dialog_new(void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1890 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1891 DWDialog *tmp = malloc(sizeof(DWDialog)); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1892 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1893 if(tmp) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1894 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1895 tmp->eve = dw_event_new(); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1896 dw_event_reset(tmp->eve); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1897 tmp->data = data; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1898 tmp->done = FALSE; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1899 tmp->result = NULL; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1900 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1901 return tmp; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1902 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1903 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1904 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1905 * Accepts a dialog struct and returns the given data to the |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1906 * initial called of dw_dialog_wait(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1907 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1908 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1909 * result: Data to be returned by dw_dialog_wait(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1910 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1911 int API dw_dialog_dismiss(DWDialog *dialog, void *result) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1912 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1913 dialog->result = result; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1914 dw_event_post(dialog->eve); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1915 dialog->done = TRUE; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1916 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1917 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1918 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1919 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1920 * Accepts a dialog struct waits for dw_dialog_dismiss() to be |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1921 * called by a signal handler with the given dialog struct. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1922 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1923 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1924 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1925 void * API dw_dialog_wait(DWDialog *dialog) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1926 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1927 void *tmp; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1928 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1929 while(!dialog->done) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1930 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1931 dw_main_iteration(); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1932 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1933 dw_event_close(&dialog->eve); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1934 tmp = dialog->result; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1935 free(dialog); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
1936 return tmp; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1937 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1938 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1939 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1940 * Create a new Box to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1941 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1942 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1943 * pad: Number of pixels to pad around the box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1944 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1945 HWND API dw_box_new(int type, int pad) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1946 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1947 DWBox *view = [[DWBox alloc] init]; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1948 Box *newbox = [view box]; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1949 memset(newbox, 0, sizeof(Box)); |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1950 newbox->pad = pad; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1951 newbox->type = type; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1952 return view; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1953 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1954 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1955 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1956 * Create a new Group Box to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1957 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1958 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1959 * pad: Number of pixels to pad around the box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1960 * title: Text to be displayined in the group outline. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1961 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1962 HWND API dw_groupbox_new(int type, int pad, char *title) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1963 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1964 DWBox *box = dw_box_new(type, pad); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1965 [box setFocusRingType:NSFocusRingTypeExterior]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1966 return box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1967 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1968 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1969 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1970 * Pack windows (widgets) into a box from the end (or bottom). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1971 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1972 * box: Window handle of the box to be packed into. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1973 * item: Window handle of the item to be back. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1974 * width: Width in pixels of the item or -1 to be self determined. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1975 * height: Height in pixels of the item or -1 to be self determined. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1976 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1977 * vsize: TRUE if the window (widget) should expand vertically to fill space given. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1978 * pad: Number of pixels of padding around the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1979 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1980 void API dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1981 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1982 NSObject *object = box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1983 DWBox *view = box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1984 DWBox *this = item; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1985 Box *thisbox; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1986 int z; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1987 Item *tmpitem, *thisitem; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1988 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1989 /* Query the objects */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1990 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1991 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1992 NSWindow *window = box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1993 view = [window contentView]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1994 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1995 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1996 thisbox = [view box]; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
1997 thisitem = thisbox->items; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1998 object = item; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1999 |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2000 /* Query the objects */ |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2001 if([ object isKindOfClass:[ DWContainer class ] ]) |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2002 { |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2003 DWContainer *cont = item; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2004 this = item = [cont scrollview]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2005 } |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2006 else if([ object isKindOfClass:[ DWTree class ] ]) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2007 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2008 DWTree *tree = item; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2009 this = item = [tree scrollview]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2010 } |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2011 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2012 /* Duplicate the existing data */ |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2013 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2014 |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2015 for(z=0;z<thisbox->count;z++) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2016 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2017 tmpitem[z+1] = thisitem[z]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2018 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2019 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2020 /* Sanity checks */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2021 if(vsize && !height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2022 height = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2023 if(hsize && !width) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2024 width = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2025 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2026 /* Fill in the item data appropriately */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2027 if([ object isKindOfClass:[ DWBox class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2028 tmpitem[0].type = TYPEBOX; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2029 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2030 tmpitem[0].type = TYPEITEM; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2031 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2032 tmpitem[0].hwnd = item; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2033 tmpitem[0].origwidth = tmpitem[0].width = width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2034 tmpitem[0].origheight = tmpitem[0].height = height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2035 tmpitem[0].pad = pad; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2036 if(hsize) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2037 tmpitem[0].hsize = SIZEEXPAND; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2038 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2039 tmpitem[0].hsize = SIZESTATIC; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2040 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2041 if(vsize) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2042 tmpitem[0].vsize = SIZEEXPAND; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2043 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2044 tmpitem[0].vsize = SIZESTATIC; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2045 |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2046 thisbox->items = tmpitem; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2047 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2048 /* Update the item count */ |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2049 thisbox->count++; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2050 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2051 /* Add the item to the box */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2052 [view addSubview:this]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2053 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2054 /* Free the old data */ |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2055 if(thisbox->count) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2056 free(thisitem); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2057 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2058 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2059 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2060 * Pack windows (widgets) into a box from the start (or top). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2061 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2062 * box: Window handle of the box to be packed into. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2063 * item: Window handle of the item to be back. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2064 * width: Width in pixels of the item or -1 to be self determined. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2065 * height: Height in pixels of the item or -1 to be self determined. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2066 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2067 * vsize: TRUE if the window (widget) should expand vertically to fill space given. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2068 * pad: Number of pixels of padding around the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2069 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2070 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2071 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2072 NSObject *object = box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2073 DWBox *view = box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2074 DWBox *this = item; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2075 Box *thisbox; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2076 int z; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2077 Item *tmpitem, *thisitem; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2078 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2079 /* Query the objects */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2080 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2081 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2082 NSWindow *window = box; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2083 view = [window contentView]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2084 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2085 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2086 thisbox = [view box]; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2087 thisitem = thisbox->items; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2088 object = item; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2089 |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2090 /* Query the objects */ |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2091 if([ object isKindOfClass:[ DWContainer class ] ]) |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2092 { |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2093 DWContainer *cont = item; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2094 this = item = [cont scrollview]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2095 } |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2096 else if([ object isKindOfClass:[ DWTree class ] ]) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2097 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2098 DWTree *tree = item; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2099 this = item = [tree scrollview]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
2100 } |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2101 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2102 /* Duplicate the existing data */ |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2103 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2104 |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2105 for(z=0;z<thisbox->count;z++) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2106 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2107 tmpitem[z] = thisitem[z]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2108 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2109 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2110 /* Sanity checks */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2111 if(vsize && !height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2112 height = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2113 if(hsize && !width) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2114 width = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2115 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2116 /* Fill in the item data appropriately */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2117 if([ object isKindOfClass:[ DWBox class ] ]) |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2118 tmpitem[thisbox->count].type = TYPEBOX; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2119 else |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2120 tmpitem[thisbox->count].type = TYPEITEM; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2121 |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2122 tmpitem[thisbox->count].hwnd = item; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2123 tmpitem[thisbox->count].origwidth = tmpitem[thisbox->count].width = width; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2124 tmpitem[thisbox->count].origheight = tmpitem[thisbox->count].height = height; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2125 tmpitem[thisbox->count].pad = pad; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2126 if(hsize) |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2127 tmpitem[thisbox->count].hsize = SIZEEXPAND; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2128 else |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2129 tmpitem[thisbox->count].hsize = SIZESTATIC; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2130 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2131 if(vsize) |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2132 tmpitem[thisbox->count].vsize = SIZEEXPAND; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2133 else |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2134 tmpitem[thisbox->count].vsize = SIZESTATIC; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2135 |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2136 thisbox->items = tmpitem; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2137 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2138 /* Update the item count */ |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2139 thisbox->count++; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2140 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2141 /* Add the item to the box */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2142 [view addSubview:this]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2143 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2144 /* Free the old data */ |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
2145 if(thisbox->count) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2146 free(thisitem); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2147 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2148 |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2149 HWND _button_new(char *text, ULONG cid) |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2150 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2151 DWButton *button = [[DWButton alloc] init]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2152 if(text && *text) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2153 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2154 [button setTitle:[ NSString stringWithUTF8String:text ]]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2155 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2156 [button setTarget:button]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2157 [button setAction:@selector(buttonClicked:)]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2158 [button setTag:cid]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2159 [button setButtonType:NSMomentaryPushInButton]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2160 [button setBezelStyle:NSThickerSquareBezelStyle]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2161 return button; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2162 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2163 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2164 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2165 * Create a new button window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2166 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2167 * text: The text to be display by the static text widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2168 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2169 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2170 HWND API dw_button_new(char *text, ULONG cid) |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2171 { |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2172 DWButton *button = _button_new(text, cid); |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2173 [button setButtonType:NSMomentaryPushInButton]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2174 [button setBezelStyle:NSRoundedBezelStyle]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2175 [button setImagePosition:NSNoImage]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2176 [button setAlignment:NSCenterTextAlignment]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2177 [[button cell] setControlTint:NSBlueControlTint]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2178 return button; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2179 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2180 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2181 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2182 * Create a new Entryfield window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2183 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2184 * text: The default text to be in the entryfield widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2185 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2186 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2187 HWND API dw_entryfield_new(char *text, ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2188 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2189 DWEntryField *entry = [[DWEntryField alloc] init]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2190 [entry setStringValue:[ NSString stringWithUTF8String:text ]]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2191 [entry setTag:cid]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2192 return entry; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2193 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2194 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2195 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2196 * Create a new Entryfield (password) window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2197 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2198 * text: The default text to be in the entryfield widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2199 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2200 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2201 HWND API dw_entryfield_password_new(char *text, ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2202 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
2203 DWEntryFieldPassword *entry = [[DWEntryFieldPassword alloc] init]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2204 [entry setStringValue:[ NSString stringWithUTF8String:text ]]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2205 [entry setTag:cid]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2206 return entry; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2207 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2208 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2209 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2210 * Sets the entryfield character limit. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2211 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2212 * handle: Handle to the spinbutton to be set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2213 * limit: Number of characters the entryfield will take. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2214 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2215 void API dw_entryfield_set_limit(HWND handle, ULONG limit) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2216 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2217 NSLog(@"dw_entryfield_set_limit() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2218 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2219 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2220 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2221 * Create a new bitmap button window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2222 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2223 * text: Bubble help text to be displayed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2224 * id: An ID of a bitmap in the resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2225 */ |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2226 HWND API dw_bitmapbutton_new(char *text, ULONG resid) |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2227 { |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
2228 /* TODO: Implement tooltips */ |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2229 NSBundle *bundle = [NSBundle mainBundle]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2230 NSString *respath = [bundle resourcePath]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2231 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2232 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2233 DWButton *button = _button_new("", resid); |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2234 [button setImage:image]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2235 //[button setBezelStyle:0]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2236 [button setButtonType:NSMomentaryLight]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2237 [button setBordered:NO]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2238 [bundle release]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2239 [respath release]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2240 [filepath release]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2241 [image release]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2242 return button; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2243 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2244 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2245 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2246 * Create a new bitmap button window (widget) to be packed from a file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2247 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2248 * text: Bubble help text to be displayed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2249 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2250 * filename: Name of the file, omit extention to have |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2251 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2252 * (BMP on OS/2 or Windows, XPM on Unix) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2253 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2254 HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long cid, char *filename) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2255 { |
674
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
2256 NSString *nstr = [ NSString stringWithUTF8String:filename ]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
2257 NSImage *image = [[NSImage alloc] initWithContentsOfFile:nstr]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
2258 if(!image) |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
2259 { |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
2260 nstr = [nstr stringByAppendingString:@".png"]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
2261 image = [[NSImage alloc] initWithContentsOfFile:nstr]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
2262 } |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
2263 [nstr release]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2264 DWButton *button = _button_new("", cid); |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2265 [button setImage:image]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2266 return button; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2267 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2268 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2269 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2270 * Create a new bitmap button window (widget) to be packed from data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2271 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2272 * text: Bubble help text to be displayed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2273 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2274 * data: The contents of the image |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2275 * (BMP or ICO on OS/2 or Windows, XPM on Unix) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2276 * len: length of str |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2277 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2278 HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long cid, char *data, int len) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2279 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2280 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2281 NSImage *image = [[NSImage alloc] initWithData:thisdata]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2282 DWButton *button = _button_new("", cid); |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2283 [button setImage:image]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2284 return button; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2285 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2286 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2287 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2288 * Create a new spinbutton window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2289 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2290 * text: The text to be display by the static text widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2291 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2292 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2293 HWND API dw_spinbutton_new(char *text, ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2294 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2295 DWSpinButton *spinbutton = [[DWSpinButton alloc] init]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2296 NSStepper *stepper = [spinbutton stepper]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2297 [stepper setIncrement:1]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2298 [stepper setTag:cid]; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2299 return spinbutton; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2300 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2301 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2302 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2303 * Sets the spinbutton value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2304 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2305 * handle: Handle to the spinbutton to be set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2306 * position: Current value of the spinbutton. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2307 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2308 void API dw_spinbutton_set_pos(HWND handle, long position) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2309 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2310 DWSpinButton *spinbutton = handle; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2311 NSStepper *stepper = [spinbutton stepper]; |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
2312 NSTextField *textfield = [spinbutton textfield]; |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2313 [stepper setIntValue:(int)position]; |
679
d2d7d1802af4
Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
678
diff
changeset
|
2314 [textfield takeIntValueFrom:stepper]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2315 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2316 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2317 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2318 * Sets the spinbutton limits. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2319 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2320 * handle: Handle to the spinbutton to be set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2321 * upper: Upper limit. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2322 * lower: Lower limit. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2323 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2324 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2325 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2326 DWSpinButton *spinbutton = handle; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2327 NSStepper *stepper = [spinbutton stepper]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2328 [stepper setMinValue:(double)lower]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2329 [stepper setMaxValue:(double)upper]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2330 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2331 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2332 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2333 * Returns the current value of the spinbutton. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2334 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2335 * handle: Handle to the spinbutton to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2336 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2337 long API dw_spinbutton_get_pos(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2338 { |
678
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2339 DWSpinButton *spinbutton = handle; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2340 NSStepper *stepper = [spinbutton stepper]; |
0ec8edbb82cf
Basic spinbutton implementation, something isn't quite working right but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
677
diff
changeset
|
2341 return (long)[stepper integerValue]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2342 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2343 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2344 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2345 * Create a new radiobutton window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2346 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2347 * text: The text to be display by the static text widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2348 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2349 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2350 HWND API dw_radiobutton_new(char *text, ULONG cid) |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2351 { |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2352 DWButton *button = _button_new(text, cid); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2353 [button setButtonType:NSRadioButton]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2354 return button; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2355 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2356 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2357 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2358 * Create a new slider window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2359 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2360 * vertical: TRUE or FALSE if slider is vertical. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2361 * increments: Number of increments available. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2362 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2363 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2364 HWND API dw_slider_new(int vertical, int increments, ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2365 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2366 DWSlider *slider = [[DWSlider alloc] init]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2367 [slider setMaxValue:(double)increments]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2368 [slider setMinValue:0]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2369 [slider setTag:cid]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2370 return slider; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2371 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2372 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2373 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2374 * Returns the position of the slider. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2375 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2376 * handle: Handle to the slider to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2377 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2378 unsigned int API dw_slider_get_pos(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2379 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2380 DWSlider *slider = handle; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2381 double val = [slider doubleValue]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2382 return (int)val; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2383 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2384 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2385 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2386 * Sets the slider position. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2387 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2388 * handle: Handle to the slider to be set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2389 * position: Position of the slider withing the range. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2390 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2391 void API dw_slider_set_pos(HWND handle, unsigned int position) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2392 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2393 DWSlider *slider = handle; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2394 [slider setDoubleValue:(double)position]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2395 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2396 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2397 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2398 * Create a new scrollbar window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2399 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2400 * vertical: TRUE or FALSE if scrollbar is vertical. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2401 * increments: Number of increments available. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2402 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2403 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2404 HWND API dw_scrollbar_new(int vertical, ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2405 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2406 DWScrollbar *scrollbar = [[DWScrollbar alloc] init]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2407 [scrollbar setArrowsPosition: NSScrollerArrowsDefaultSetting]; |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
2408 [scrollbar setTarget:scrollbar]; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
2409 [scrollbar setAction:@selector(changed:)]; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
2410 [scrollbar setRange:0.0 andVisible:0.0]; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
2411 [scrollbar setKnobProportion:1.0]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2412 [scrollbar setTag:cid]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2413 return scrollbar; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2414 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2415 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2416 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2417 * Returns the position of the scrollbar. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2418 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2419 * handle: Handle to the scrollbar to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2420 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2421 unsigned int API dw_scrollbar_get_pos(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2422 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2423 DWScrollbar *scrollbar = handle; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2424 float range = [scrollbar range]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2425 float fresult = [scrollbar doubleValue] * range; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2426 return (int)fresult; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2427 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2428 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2429 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2430 * Sets the scrollbar position. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2431 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2432 * handle: Handle to the scrollbar to be set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2433 * position: Position of the scrollbar withing the range. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2434 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2435 void API dw_scrollbar_set_pos(HWND handle, unsigned int position) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2436 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2437 DWScrollbar *scrollbar = handle; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2438 double range = (double)[scrollbar range]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2439 double newpos = (double)position/range; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2440 [scrollbar setDoubleValue:newpos]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2441 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2442 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2443 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2444 * Sets the scrollbar range. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2445 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2446 * handle: Handle to the scrollbar to be set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2447 * range: Maximum range value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2448 * visible: Visible area relative to the range. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2449 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2450 void API dw_scrollbar_set_range(HWND handle, unsigned int range, unsigned int visible) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2451 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2452 DWScrollbar *scrollbar = handle; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2453 float knob = (float)visible/(float)range; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2454 [scrollbar setRange:(float)range andVisible:(float)visible]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2455 [scrollbar setKnobProportion:knob]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2456 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2457 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2458 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2459 * Create a new percent bar window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2460 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2461 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2462 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2463 HWND API dw_percent_new(ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2464 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2465 DWPercent *percent = [[DWPercent alloc] init]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2466 [percent setBezeled:YES]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2467 [percent setMaxValue:100]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2468 [percent setMinValue:0]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2469 /*[percent setTag:cid]; Why doesn't this work? */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2470 return percent; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2471 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2472 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2473 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2474 * Sets the percent bar position. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2475 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2476 * handle: Handle to the percent bar to be set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2477 * position: Position of the percent bar withing the range. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2478 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2479 void API dw_percent_set_pos(HWND handle, unsigned int position) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2480 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2481 DWPercent *percent = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2482 [percent setDoubleValue:(double)position]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2483 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2484 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2485 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2486 * Create a new checkbox window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2487 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2488 * text: The text to be display by the static text widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2489 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2490 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2491 HWND API dw_checkbox_new(char *text, ULONG cid) |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2492 { |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2493 DWButton *button = _button_new(text, cid); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2494 [button setButtonType:NSSwitchButton]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2495 [button setBezelStyle:NSRegularSquareBezelStyle]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2496 return button; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2497 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2498 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2499 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2500 * Returns the state of the checkbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2501 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2502 * handle: Handle to the checkbox to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2503 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2504 int API dw_checkbox_get(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2505 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2506 DWButton *button = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2507 if([button state]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2508 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2509 return TRUE; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2510 } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2511 return FALSE; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2512 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2513 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2514 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2515 * Sets the state of the checkbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2516 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2517 * handle: Handle to the checkbox to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2518 * value: TRUE for checked, FALSE for unchecked. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2519 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2520 void API dw_checkbox_set(HWND handle, int value) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2521 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2522 DWButton *button = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2523 if(value) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2524 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2525 [button setState:NSOnState]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2526 } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2527 else |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2528 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2529 [button setState:NSOffState]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2530 } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2531 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2532 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2533 |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2534 /* Common code for containers and listboxes */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2535 HWND _cont_new(ULONG cid, int multi) |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2536 { |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2537 NSScrollView *scrollview = [[NSScrollView alloc] init]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2538 DWContainer *cont = [[DWContainer alloc] init]; |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2539 |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2540 [cont setScrollview:scrollview]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2541 [scrollview setBorderType:NSBezelBorder]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2542 [scrollview setHasVerticalScroller:YES]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2543 [scrollview setAutohidesScrollers:YES]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2544 |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2545 if(multi) |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2546 { |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2547 [cont setAllowsMultipleSelection:YES]; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2548 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2549 else |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2550 { |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2551 [cont setAllowsMultipleSelection:NO]; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2552 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2553 [cont setDataSource:cont]; |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2554 [scrollview setDocumentView:cont]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2555 [cont setTag:cid]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2556 return cont; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2557 } |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2558 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2559 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2560 * Create a new listbox window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2561 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2562 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2563 * multi: Multiple select TRUE or FALSE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2564 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2565 HWND API dw_listbox_new(ULONG cid, int multi) |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2566 { |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2567 DWContainer *cont = _cont_new(cid, multi); |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
2568 [cont setHeaderView:nil]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2569 int type = DW_CFA_STRING; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2570 [cont setup]; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2571 NSTableColumn *column = [[NSTableColumn alloc] init]; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2572 [cont addTableColumn:column]; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2573 [cont addColumn:column andType:type]; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
2574 return cont; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2575 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2576 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2577 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2578 * Appends the specified text to the listbox's (or combobox) entry list. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2579 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2580 * handle: Handle to the listbox to be appended to. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2581 * text: Text to append into listbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2582 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2583 void API dw_listbox_append(HWND handle, char *text) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2584 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2585 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2586 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2587 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2588 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2589 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2590 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2591 [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text ]]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2592 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2593 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2594 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2595 DWContainer *cont = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2596 NSString *nstr = [ NSString stringWithUTF8String:text ]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2597 NSArray *newrow = [NSArray arrayWithObject:nstr]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2598 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2599 [cont addRow:newrow]; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2600 [cont reloadData]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2601 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2602 [newrow release]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2603 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2604 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2605 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2606 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2607 * Inserts the specified text into the listbox's (or combobox) entry list. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2608 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2609 * handle: Handle to the listbox to be inserted into. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2610 * text: Text to insert into listbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2611 * pos: 0-based position to insert text |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2612 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2613 void API dw_listbox_insert(HWND handle, char *text, int pos) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2614 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2615 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2616 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2617 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2618 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2619 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2620 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2621 [combo insertItemWithObjectValue:[ NSString stringWithUTF8String:text ] atIndex:pos]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2622 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2623 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2624 { |
687
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
2625 DWContainer *cont = handle; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
2626 NSString *nstr = [ NSString stringWithUTF8String:text ]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
2627 NSArray *newrow = [NSArray arrayWithObject:nstr]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
2628 |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
2629 [cont insertRow:newrow at:pos]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
2630 [cont reloadData]; |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
2631 |
5dde8d34bc69
Implemented dw_listbox_insert for containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
686
diff
changeset
|
2632 [newrow release]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2633 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2634 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2635 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2636 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2637 * Appends the specified text items to the listbox's (or combobox) entry list. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2638 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2639 * handle: Handle to the listbox to be appended to. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2640 * text: Text strings to append into listbox. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2641 * count: Number of text strings to append |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2642 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2643 void API dw_listbox_list_append(HWND handle, char **text, int count) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2644 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2645 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2646 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2647 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2648 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2649 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2650 int z; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2651 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2652 for(z=0;z<count;z++) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2653 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2654 [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text[z] ]]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2655 } |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2656 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2657 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2658 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2659 DWContainer *cont = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2660 int z; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2661 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2662 for(z=0;z<count;z++) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2663 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2664 NSString *nstr = [ NSString stringWithUTF8String:text[z] ]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2665 NSArray *newrow = [[NSArray alloc] arrayWithObject:nstr]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2666 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2667 [cont addRow:newrow]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2668 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2669 [newrow release]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2670 } |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2671 [cont reloadData]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2672 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2673 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2674 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2675 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2676 * Clears the listbox's (or combobox) list of all entries. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2677 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2678 * handle: Handle to the listbox to be cleared. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2679 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2680 void API dw_listbox_clear(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2681 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2682 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2683 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2684 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2685 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2686 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2687 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2688 [combo removeAllItems]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2689 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2690 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2691 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2692 DWContainer *cont = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2693 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2694 [cont clear]; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2695 [cont reloadData]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2696 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2697 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2698 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2699 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2700 * Returns the listbox's item count. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2701 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2702 * handle: Handle to the listbox to be cleared. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2703 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2704 int API dw_listbox_count(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2705 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2706 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2707 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2708 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2709 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2710 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2711 |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
2712 return (int)[combo numberOfItems]; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2713 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2714 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2715 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2716 DWContainer *cont = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2717 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2718 return (int)[cont numberOfRowsInTableView:cont]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2719 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2720 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2721 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2722 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2723 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2724 * Sets the topmost item in the viewport. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2725 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2726 * handle: Handle to the listbox to be cleared. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2727 * top: Index to the top item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2728 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2729 void API dw_listbox_set_top(HWND handle, int top) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2730 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2731 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2732 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2733 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2734 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2735 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2736 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2737 [combo scrollItemAtIndexToTop:top]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2738 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2739 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2740 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2741 DWContainer *cont = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2742 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2743 [cont scrollRowToVisible:top]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2744 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2745 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2746 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2747 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2748 * Copies the given index item's text into buffer. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2749 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2750 * handle: Handle to the listbox to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2751 * index: Index into the list to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2752 * buffer: Buffer where text will be copied. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2753 * length: Length of the buffer (including NULL). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2754 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2755 void API dw_listbox_get_text(HWND handle, unsigned int index, char *buffer, unsigned int length) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2756 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2757 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2758 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2759 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2760 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2761 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2762 NSString *nstr = [combo itemObjectValueAtIndex:index]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2763 strncpy(buffer, [ nstr UTF8String ], length - 1); |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2764 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2765 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2766 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2767 DWContainer *cont = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2768 NSString *nstr = [cont getRow:index and:0]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2769 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2770 strncpy(buffer, [ nstr UTF8String ], length - 1); |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2771 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2772 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2773 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2774 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2775 * Sets the text of a given listbox entry. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2776 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2777 * handle: Handle to the listbox to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2778 * index: Index into the list to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2779 * buffer: Buffer where text will be copied. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2780 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2781 void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2782 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2783 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2784 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2785 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2786 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2787 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2788 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
2789 [combo removeItemAtIndex:index]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
2790 [combo insertItemWithObjectValue:[ NSString stringWithUTF8String:buffer ] atIndex:index]; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2791 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2792 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2793 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2794 DWContainer *cont = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2795 NSString *nstr = [ NSString stringWithUTF8String:buffer ]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2796 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2797 [cont editCell:nstr at:index and:0]; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2798 [cont reloadData]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2799 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2800 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2801 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2802 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2803 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2804 * Returns the index to the item in the list currently selected. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2805 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2806 * handle: Handle to the listbox to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2807 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2808 unsigned int API dw_listbox_selected(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2809 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2810 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2811 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2812 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2813 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2814 DWComboBox *combo = handle; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
2815 return (int)[combo indexOfSelectedItem]; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2816 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2817 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2818 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2819 DWContainer *cont = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2820 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2821 return (int)[cont selectedRow]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2822 } |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2823 return -1; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2824 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2825 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2826 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2827 * Returns the index to the current selected item or -1 when done. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2828 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2829 * handle: Handle to the listbox to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2830 * where: Either the previous return or -1 to restart. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2831 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2832 int API dw_listbox_selected_multi(HWND handle, int where) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2833 { |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2834 id object = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2835 int retval = -1; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2836 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2837 if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2838 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2839 DWContainer *cont = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2840 NSIndexSet *selected = [cont selectedRowIndexes]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2841 NSUInteger result = [selected indexGreaterThanIndex:where]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2842 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2843 if(result != NSNotFound) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2844 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2845 retval = (int)result; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2846 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2847 [selected release]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2848 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2849 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2850 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2851 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2852 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2853 * Sets the selection state of a given index. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2854 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2855 * handle: Handle to the listbox to be set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2856 * index: Item index. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2857 * state: TRUE if selected FALSE if unselected. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2858 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2859 void API dw_listbox_select(HWND handle, int index, int state) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2860 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2861 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2862 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2863 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2864 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2865 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2866 if(state) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2867 [combo selectItemAtIndex:index]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2868 else |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2869 [combo deselectItemAtIndex:index]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2870 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2871 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2872 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2873 DWContainer *cont = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2874 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)index]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2875 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2876 [cont selectRowIndexes:selected byExtendingSelection:YES]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2877 [selected release]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2878 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2879 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2880 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2881 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2882 * Deletes the item with given index from the list. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2883 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2884 * handle: Handle to the listbox to be set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2885 * index: Item index. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2886 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2887 void API dw_listbox_delete(HWND handle, int index) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2888 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2889 id object = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2890 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2891 if([object isMemberOfClass:[DWComboBox class]]) |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2892 { |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2893 DWComboBox *combo = handle; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2894 |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2895 [combo removeItemAtIndex:index]; |
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2896 } |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2897 else if([object isMemberOfClass:[DWContainer class]]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2898 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2899 DWContainer *cont = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2900 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2901 [cont removeRow:index]; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
2902 [cont reloadData]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
2903 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2904 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2905 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2906 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2907 * Create a new Combobox window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2908 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2909 * text: The default text to be in the combpbox widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2910 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2911 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2912 HWND API dw_combobox_new(char *text, ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2913 { |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2914 DWComboBox *combo = [[DWComboBox alloc] init]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2915 [combo setTag:cid]; |
656
6c8b95ca877b
Comboboxes implemented.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
655
diff
changeset
|
2916 return combo; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2917 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2918 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2919 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2920 * Create a new Multiline Editbox window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2921 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2922 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2923 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2924 HWND API dw_mle_new(ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2925 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
2926 DWMLE *mle = [[DWMLE alloc] init]; |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
2927 NSScrollView *scrollview = [[NSScrollView alloc] init]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
2928 |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
2929 //[mle setScrollview:scrollview]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
2930 [scrollview setBorderType:NSBezelBorder]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
2931 [scrollview setHasVerticalScroller:YES]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
2932 [scrollview setAutohidesScrollers:YES]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
2933 [scrollview setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
2934 [scrollview setDocumentView:mle]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
2935 [mle setAutoresizingMask:NSViewWidthSizable]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
2936 /* [mle setTag:cid]; Why doesn't this work? */ |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
2937 return scrollview; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2938 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2939 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2940 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2941 * Adds text to an MLE box and returns the current point. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2942 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2943 * handle: Handle to the MLE to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2944 * buffer: Text buffer to be imported. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2945 * startpoint: Point to start entering text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2946 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2947 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2948 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
2949 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
2950 DWMLE *mle = [sv documentView]; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
2951 NSTextStorage *ts = [mle textStorage]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
2952 NSString *nstr = [NSString stringWithUTF8String:buffer]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
2953 NSMutableString *ms = [ts mutableString]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
2954 [ms insertString:nstr atIndex:(startpoint+1)]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
2955 return (unsigned int)strlen(buffer) + startpoint; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2956 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2957 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2958 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2959 * Grabs text from an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2960 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2961 * handle: Handle to the MLE to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2962 * buffer: Text buffer to be exported. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2963 * startpoint: Point to start grabbing text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2964 * length: Amount of text to be grabbed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2965 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2966 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2967 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
2968 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
2969 DWMLE *mle = [sv documentView]; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
2970 NSTextStorage *ts = [mle textStorage]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
2971 NSMutableString *ms = [ts mutableString]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
2972 strncpy(buffer, [ms UTF8String], length); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2973 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2974 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2975 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2976 * Obtains information about an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2977 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2978 * handle: Handle to the MLE to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2979 * bytes: A pointer to a variable to return the total bytes. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2980 * lines: A pointer to a variable to return the number of lines. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2981 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2982 void API dw_mle_get_size(HWND handle, unsigned long *bytes, unsigned long *lines) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2983 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
2984 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
2985 DWMLE *mle = [sv documentView]; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
2986 NSTextStorage *ts = [mle textStorage]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
2987 NSMutableString *ms = [ts mutableString]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
2988 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
2989 *bytes = [ms length]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
2990 *lines = 0; /* TODO: Line count */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2991 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2992 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2993 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2994 * Deletes text from an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2995 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2996 * handle: Handle to the MLE to be deleted from. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2997 * startpoint: Point to start deleting text. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2998 * length: Amount of text to be deleted. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2999 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3000 void API dw_mle_delete(HWND handle, int startpoint, int length) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3001 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3002 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3003 DWMLE *mle = [sv documentView]; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3004 NSTextStorage *ts = [mle textStorage]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3005 NSMutableString *ms = [ts mutableString]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3006 [ms deleteCharactersInRange:NSMakeRange(startpoint+1, length)]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3007 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3008 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3009 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3010 * Clears all text from an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3011 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3012 * handle: Handle to the MLE to be cleared. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3013 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3014 void API dw_mle_clear(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3015 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3016 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3017 DWMLE *mle = [sv documentView]; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3018 NSTextStorage *ts = [mle textStorage]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3019 NSMutableString *ms = [ts mutableString]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3020 NSUInteger length = [ms length]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3021 [ms deleteCharactersInRange:NSMakeRange(0, length)]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3022 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3023 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3024 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3025 * Sets the visible line of an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3026 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3027 * handle: Handle to the MLE to be positioned. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3028 * line: Line to be visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3029 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3030 void API dw_mle_set_visible(HWND handle, int line) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3031 { |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3032 NSLog(@"dw_mle_set_visible() unimplemented\n"); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3033 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3034 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3035 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3036 * Sets the editablity of an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3037 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3038 * handle: Handle to the MLE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3039 * state: TRUE if it can be edited, FALSE for readonly. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3040 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3041 void API dw_mle_set_editable(HWND handle, int state) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3042 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3043 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3044 DWMLE *mle = [sv documentView]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3045 if(state) |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3046 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3047 [mle setEditable:YES]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3048 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3049 else |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3050 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3051 [mle setEditable:NO]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3052 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3053 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3054 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3055 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3056 * Sets the word wrap state of an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3057 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3058 * handle: Handle to the MLE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3059 * state: TRUE if it wraps, FALSE if it doesn't. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3060 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3061 void API dw_mle_set_word_wrap(HWND handle, int state) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3062 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3063 NSScrollView *sv = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
3064 DWMLE *mle = [sv documentView]; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3065 if(state) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3066 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3067 [mle setHorizontallyResizable:NO]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3068 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3069 else |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3070 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3071 [mle setHorizontallyResizable:YES]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3072 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3073 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3074 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3075 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3076 * Sets the current cursor position of an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3077 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3078 * handle: Handle to the MLE to be positioned. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3079 * point: Point to position cursor. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3080 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3081 void API dw_mle_set_cursor(HWND handle, int point) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3082 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3083 NSLog(@"dw_mle_set_cursor() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3084 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3085 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3086 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3087 * Finds text in an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3088 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3089 * handle: Handle to the MLE to be cleared. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3090 * text: Text to search for. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3091 * point: Start point of search. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3092 * flags: Search specific flags. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3093 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3094 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3095 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3096 NSLog(@"dw_mle_search() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3097 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3098 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3099 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3100 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3101 * Stops redrawing of an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3102 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3103 * handle: Handle to the MLE to freeze. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3104 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3105 void API dw_mle_freeze(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3106 { |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3107 /* Don't think this is necessary */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3108 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3109 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3110 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3111 * Resumes redrawing of an MLE box. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3112 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3113 * handle: Handle to the MLE to thaw. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3114 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3115 void API dw_mle_thaw(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3116 { |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3117 /* Don't think this is necessary */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3118 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3119 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3120 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3121 * Create a new status text window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3122 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3123 * text: The text to be display by the static text widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3124 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3125 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3126 HWND API dw_status_text_new(char *text, ULONG cid) |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3127 { |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3128 NSTextField *textfield = dw_text_new(text, cid); |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3129 [textfield setBordered:YES]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3130 [textfield setBezeled:YES]; |
673
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
3131 [textfield setBezelStyle:NSTextFieldSquareBezel]; |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
3132 [textfield setBackgroundColor:[NSColor colorWithDeviceRed:1 green:1 blue:1 alpha: 0]]; |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
3133 [textfield setDrawsBackground:NO]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3134 return textfield; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3135 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3136 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3137 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3138 * Create a new static text window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3139 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3140 * text: The text to be display by the static text widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3141 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3142 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3143 HWND API dw_text_new(char *text, ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3144 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3145 NSTextField *textfield = [[NSTextField alloc] init]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3146 [textfield setEditable:NO]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3147 [textfield setSelectable:NO]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3148 [textfield setBordered:NO]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3149 [textfield setDrawsBackground:NO]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3150 [textfield setStringValue:[ NSString stringWithUTF8String:text ]]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3151 [textfield setTag:cid]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3152 return textfield; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3153 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3154 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3155 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3156 * Creates a rendering context widget (window) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3157 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3158 * id: An id to be used with dw_window_from_id. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3159 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3160 * A handle to the widget or NULL on failure. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3161 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3162 HWND API dw_render_new(unsigned long cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3163 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3164 DWRender *render = [[DWRender alloc] init]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3165 /* [render setTag:cid]; Why doesn't this work? */ |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
3166 return render; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3167 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3168 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3169 /* Sets the current foreground drawing color. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3170 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3171 * red: red value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3172 * green: green value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3173 * blue: blue value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3174 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3175 void API dw_color_foreground_set(unsigned long value) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3176 { |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3177 /* This may need to be thread specific */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3178 _foreground = _get_color(value); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3179 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3180 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3181 /* Sets the current background drawing color. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3182 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3183 * red: red value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3184 * green: green value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3185 * blue: blue value. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3186 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3187 void API dw_color_background_set(unsigned long value) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3188 { |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3189 /* This may need to be thread specific */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3190 _background = _get_color(value); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3191 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3192 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3193 /* Allows the user to choose a color using the system's color chooser dialog. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3194 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3195 * value: current color |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3196 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3197 * The selected color or the current color if cancelled. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3198 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3199 unsigned long API dw_color_choose(unsigned long value) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3200 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
3201 /* Create the File Save Dialog class. */ |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
3202 DWColorChoose *colorDlg = (DWColorChoose *)[DWColorChoose sharedColorPanel]; |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
3203 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
3204 DWDialog *dialog = dw_dialog_new(colorDlg); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
3205 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
3206 /* Set defaults for the dialog. */ |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
3207 [colorDlg setColor:color]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
3208 [colorDlg setDialog:dialog]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
3209 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
3210 color = (NSColor *)dw_dialog_wait(dialog); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
3211 [color release]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
3212 return _foreground; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3213 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3214 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3215 /* Draw a point on a window (preferably a render window). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3216 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3217 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3218 * pixmap: Handle to the pixmap. (choose only one of these) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3219 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3220 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3221 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3222 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3223 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3224 id image = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3225 if(pixmap) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3226 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3227 image = (id)pixmap->handle; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3228 [image lockFocus]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3229 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3230 else |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3231 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3232 [image lockFocusIfCanDraw]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3233 _DWLastDrawable = handle; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3234 } |
664
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3235 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3236 [aPath setLineWidth: 0.5]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3237 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3238 [color set]; |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3239 [color release]; |
664
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3240 |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3241 [aPath moveToPoint:NSMakePoint(x, y)]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3242 [aPath stroke]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3243 [aPath release]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3244 [image unlockFocus]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3245 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3246 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3247 /* Draw a line on a window (preferably a render window). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3248 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3249 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3250 * pixmap: Handle to the pixmap. (choose only one of these) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3251 * x1: First X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3252 * y1: First Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3253 * x2: Second X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3254 * y2: Second Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3255 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3256 void API dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3257 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3258 id image = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3259 if(pixmap) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3260 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3261 image = (id)pixmap->handle; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3262 [image lockFocus]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3263 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3264 else |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3265 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3266 [image lockFocusIfCanDraw]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3267 _DWLastDrawable = handle; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3268 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3269 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3270 [aPath setLineWidth: 0.5]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3271 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3272 [color set]; |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3273 [color release]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3274 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3275 [aPath moveToPoint:NSMakePoint(x1, y1)]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3276 [aPath lineToPoint:NSMakePoint(x2, y2)]; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3277 [aPath stroke]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3278 [aPath release]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3279 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3280 [image unlockFocus]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3281 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3282 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3283 /* Draw text on a window (preferably a render window). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3284 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3285 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3286 * pixmap: Handle to the pixmap. (choose only one of these) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3287 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3288 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3289 * text: Text to be displayed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3290 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3291 void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3292 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3293 id image = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3294 NSString *nstr = [ NSString stringWithUTF8String:text ]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3295 if(image) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3296 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3297 if([image isMemberOfClass:[NSView class]]) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3298 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3299 [image lockFocusIfCanDraw]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3300 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3301 NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys: |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3302 /*[NSFont fontWithName:@"Helvetica" size:26], NSFontAttributeName,*/ |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3303 color, NSForegroundColorAttributeName, nil]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3304 [nstr drawAtPoint:NSMakePoint(x, y) withAttributes:dict]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3305 [dict release]; |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3306 [color release]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3307 [image unlockFocus]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3308 } |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3309 _DWLastDrawable = handle; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3310 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3311 if(pixmap) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3312 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3313 image = (id)pixmap->handle; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3314 [image lockFocus]; |
664
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3315 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3316 NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys: |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3317 /*[NSFont fontWithName:@"Helvetica" size:26], NSFontAttributeName,*/ |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3318 color, NSForegroundColorAttributeName, nil]; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3319 [nstr drawAtPoint:NSMakePoint(x, y) withAttributes:dict]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3320 [dict release]; |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3321 [color release]; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3322 [image unlockFocus]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3323 } |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3324 [nstr release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3325 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3326 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3327 /* Query the width and height of a text string. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3328 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3329 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3330 * pixmap: Handle to the pixmap. (choose only one of these) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3331 * text: Text to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3332 * width: Pointer to a variable to be filled in with the width. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3333 * height Pointer to a variable to be filled in with the height. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3334 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3335 void API dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3336 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3337 id image = handle; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3338 NSString *nstr = [[ NSString stringWithUTF8String:text ] autorelease]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3339 if(pixmap) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3340 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3341 image = (id)pixmap->handle; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3342 [image lockFocus]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3343 } |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3344 else |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3345 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3346 [image lockFocusIfCanDraw]; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3347 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3348 NSDictionary *dict = [[NSDictionary alloc] init]; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3349 NSSize size = [nstr sizeWithAttributes:dict]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3350 [dict release]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3351 if(width) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3352 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3353 *width = size.width; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3354 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3355 if(height) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3356 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3357 *height = size.height; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3358 } |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3359 [nstr release]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3360 [image unlockFocus]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3361 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3362 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3363 /* Draw a polygon on a window (preferably a render window). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3364 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3365 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3366 * pixmap: Handle to the pixmap. (choose only one of these) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3367 * fill: Fill box TRUE or FALSE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3368 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3369 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3370 * width: Width of rectangle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3371 * height: Height of rectangle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3372 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3373 void API dw_draw_polygon( HWND handle, HPIXMAP pixmap, int fill, int npoints, int *x, int *y ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3374 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3375 id image = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3376 int z; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3377 if(pixmap) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3378 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3379 image = (id)pixmap->handle; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3380 [image lockFocus]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3381 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3382 else |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3383 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3384 [image lockFocusIfCanDraw]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3385 _DWLastDrawable = handle; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3386 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3387 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3388 [aPath setLineWidth: 0.5]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3389 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3390 [color set]; |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3391 [color release]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3392 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3393 [aPath moveToPoint:NSMakePoint(*x, *y)]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3394 for(z=1;z<npoints;z++) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3395 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3396 [aPath lineToPoint:NSMakePoint(x[z], y[z])]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3397 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3398 [aPath closePath]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3399 if(fill) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3400 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3401 [aPath fill]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3402 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3403 [aPath stroke]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3404 [aPath release]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3405 [image unlockFocus]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3406 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3407 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3408 /* Draw a rectangle on a window (preferably a render window). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3409 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3410 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3411 * pixmap: Handle to the pixmap. (choose only one of these) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3412 * fill: Fill box TRUE or FALSE. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3413 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3414 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3415 * width: Width of rectangle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3416 * height: Height of rectangle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3417 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3418 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3419 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3420 id image = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3421 if(pixmap) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3422 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3423 image = (id)pixmap->handle; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3424 [image lockFocus]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3425 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3426 else |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3427 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3428 [image lockFocusIfCanDraw]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
3429 _DWLastDrawable = handle; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
3430 } |
664
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3431 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3432 [aPath setLineWidth: 0.5]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3433 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3434 [color set]; |
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3435 [color release]; |
664
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3436 |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3437 [aPath moveToPoint:NSMakePoint(x, y)]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3438 [aPath lineToPoint:NSMakePoint(x, y + height)]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3439 [aPath lineToPoint:NSMakePoint(x + width, y + height)]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3440 [aPath lineToPoint:NSMakePoint(x + width, y)]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3441 [aPath closePath]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3442 [aPath fill]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
3443 [aPath stroke]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3444 [aPath release]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3445 [image unlockFocus]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3446 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3447 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3448 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3449 * Create a tree object to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3450 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3451 * id: An ID to be used for getting the resource from the |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3452 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3453 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3454 HWND API dw_tree_new(ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3455 { |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3456 NSScrollView *scrollview = [[NSScrollView alloc] init]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3457 DWTree *tree = [[DWTree alloc] init]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3458 |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3459 [tree setScrollview:scrollview]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3460 [scrollview setBorderType:NSBezelBorder]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3461 [scrollview setHasVerticalScroller:YES]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3462 [scrollview setAutohidesScrollers:YES]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3463 |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3464 [tree setAllowsMultipleSelection:NO]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3465 [tree setDataSource:tree]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3466 [scrollview setDocumentView:tree]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3467 [tree setHeaderView:nil]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3468 [tree setTag:cid]; |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3469 return tree; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3470 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3471 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3472 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3473 * Inserts an item into a tree window (widget) after another item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3474 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3475 * handle: Handle to the tree to be inserted. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3476 * item: Handle to the item to be positioned after. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3477 * title: The text title of the entry. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3478 * icon: Handle to coresponding icon. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3479 * parent: Parent handle or 0 if root. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3480 * itemdata: Item specific data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3481 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3482 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, HICN icon, HTREEITEM parent, void *itemdata) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3483 { |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3484 DWTree *tree = handle; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3485 NSString *nstr = [NSString stringWithUTF8String:title]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3486 NSPointerArray *treenode = [NSPointerArray pointerArrayWithWeakObjects]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3487 [treenode addPointer:icon]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3488 [treenode addPointer:nstr]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3489 [treenode addPointer:itemdata]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3490 [treenode addPointer:NULL]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3491 [tree addTree:treenode and:parent]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3492 [tree reloadData]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3493 return treenode; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3494 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3495 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3496 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3497 * Inserts an item into a tree window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3498 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3499 * handle: Handle to the tree to be inserted. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3500 * title: The text title of the entry. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3501 * icon: Handle to coresponding icon. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3502 * parent: Parent handle or 0 if root. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3503 * itemdata: Item specific data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3504 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3505 HTREEITEM API dw_tree_insert(HWND handle, char *title, HICN icon, HTREEITEM parent, void *itemdata) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3506 { |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3507 return dw_tree_insert_after(handle, NULL, title, icon, parent, itemdata); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3508 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3509 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3510 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3511 * Gets the text an item in a tree window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3512 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3513 * handle: Handle to the tree containing the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3514 * item: Handle of the item to be modified. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3515 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3516 char * API dw_tree_get_title(HWND handle, HTREEITEM item) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3517 { |
680
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3518 NSPointerArray *array = (NSPointerArray *)item; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3519 NSString *nstr = (NSString *)[array pointerAtIndex:1]; |
db315779a283
Initial tree support, lots more to do but basics are there.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
679
diff
changeset
|
3520 return strdup([nstr UTF8String]); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3521 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3522 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3523 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3524 * Gets the text an item in a tree window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3525 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3526 * handle: Handle to the tree containing the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3527 * item: Handle of the item to be modified. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3528 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3529 HTREEITEM API dw_tree_get_parent(HWND handle, HTREEITEM item) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3530 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3531 NSLog(@"dw_tree_get_parent() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3532 return HWND_DESKTOP; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3533 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3534 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3535 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3536 * Sets the text and icon of an item in a tree window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3537 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3538 * handle: Handle to the tree containing the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3539 * item: Handle of the item to be modified. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3540 * title: The text title of the entry. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3541 * icon: Handle to coresponding icon. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3542 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3543 void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, HICN icon) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3544 { |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3545 DWTree *tree = handle; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3546 NSPointerArray *array = (NSPointerArray *)item; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3547 if(title) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3548 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3549 NSString *nstr = [NSString stringWithUTF8String:title]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3550 [array replacePointerAtIndex:1 withPointer:nstr]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3551 } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3552 if(icon) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3553 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3554 [array replacePointerAtIndex:0 withPointer:icon]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3555 } |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3556 [tree reloadData]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3557 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3558 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3559 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3560 * Sets the item data of a tree item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3561 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3562 * handle: Handle to the tree containing the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3563 * item: Handle of the item to be modified. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3564 * itemdata: User defined data to be associated with item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3565 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3566 void API dw_tree_item_set_data(HWND handle, HTREEITEM item, void *itemdata) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3567 { |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3568 NSPointerArray *array = (NSPointerArray *)item; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3569 [array replacePointerAtIndex:2 withPointer:itemdata]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3570 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3571 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3572 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3573 * Gets the item data of a tree item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3574 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3575 * handle: Handle to the tree containing the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3576 * item: Handle of the item to be modified. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3577 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3578 void * API dw_tree_item_get_data(HWND handle, HTREEITEM item) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3579 { |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3580 NSPointerArray *array = (NSPointerArray *)item; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3581 return [array pointerAtIndex:2]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3582 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3583 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3584 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3585 * Sets this item as the active selection. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3586 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3587 * handle: Handle to the tree window (widget) to be selected. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3588 * item: Handle to the item to be selected. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3589 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3590 void API dw_tree_item_select(HWND handle, HTREEITEM item) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3591 { |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3592 DWTree *tree = handle; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3593 NSInteger itemIndex = [tree rowForItem:item]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3594 if(itemIndex > -1) |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3595 { |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3596 [tree selectRowIndexes:[NSIndexSet indexSetWithIndex:itemIndex] byExtendingSelection:NO]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3597 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3598 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3599 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3600 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3601 * Removes all nodes from a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3602 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3603 * handle: Handle to the window (widget) to be cleared. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3604 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3605 void API dw_tree_clear(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3606 { |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3607 DWTree *tree = handle; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3608 [tree clear]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3609 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3610 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3611 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3612 * Expands a node on a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3613 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3614 * handle: Handle to the tree window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3615 * item: Handle to node to be expanded. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3616 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3617 void API dw_tree_item_expand(HWND handle, HTREEITEM item) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3618 { |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3619 DWTree *tree = handle; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3620 [tree expandItem:item]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3621 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3622 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3623 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3624 * Collapses a node on a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3625 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3626 * handle: Handle to the tree window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3627 * item: Handle to node to be collapsed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3628 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3629 void API dw_tree_item_collapse(HWND handle, HTREEITEM item) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3630 { |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3631 DWTree *tree = handle; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3632 [tree collapseItem:item]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3633 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3634 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3635 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3636 * Removes a node from a tree. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3637 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3638 * handle: Handle to the window (widget) to be cleared. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3639 * item: Handle to node to be deleted. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3640 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3641 void API dw_tree_item_delete(HWND handle, HTREEITEM item) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3642 { |
682
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3643 DWTree *tree = handle; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3644 [tree deleteNode:item]; |
de4aa126fb2f
Fixes for tree packing and a data source issue. Implemented most of the missing tree functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
681
diff
changeset
|
3645 [tree reloadData]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3646 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3647 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3648 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3649 * Create a container object to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3650 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3651 * id: An ID to be used for getting the resource from the |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3652 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3653 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3654 HWND API dw_container_new(ULONG cid, int multi) |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3655 { |
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
3656 DWContainer *cont = _cont_new(cid, multi); |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
3657 NSScrollView *scrollview = [cont scrollview]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
3658 [scrollview setHasHorizontalScroller:YES]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
3659 NSTableHeaderView *header = [[NSTableHeaderView alloc] init]; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
3660 [cont setHeaderView:header]; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
3661 return cont; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3662 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3663 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3664 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3665 * Sets up the container columns. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3666 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3667 * handle: Handle to the container to be configured. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3668 * flags: An array of unsigned longs with column flags. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3669 * titles: An array of strings with column text titles. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3670 * count: The number of columns (this should match the arrays). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3671 * separator: The column number that contains the main separator. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3672 * (this item may only be used in OS/2) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3673 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3674 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3675 { |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
3676 int z; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
3677 DWContainer *cont = handle; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
3678 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3679 [cont setup]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3680 |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
3681 for(z=0;z<count;z++) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
3682 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
3683 NSTableColumn *column = [[NSTableColumn alloc] init]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
3684 [[column headerCell] setStringValue:[ NSString stringWithUTF8String:titles[z] ]]; |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3685 if(flags[z] & DW_CFA_BITMAPORICON) |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3686 { |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3687 NSImageCell *imagecell = [[[NSImageCell alloc] init] autorelease]; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3688 [column setDataCell:imagecell]; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3689 if(z == 0 && titles[z] && strcmp(titles[z], "Icon") == 0) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3690 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3691 [column setResizingMask:NSTableColumnNoResizing]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3692 [column setWidth:20]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3693 } |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3694 } |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
3695 [cont addTableColumn:column]; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
3696 [cont addColumn:column andType:(int)flags[z]]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3697 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3698 |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
3699 return TRUE; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3700 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3701 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3702 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3703 * Sets up the filesystem columns, note: filesystem always has an icon/filename field. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3704 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3705 * handle: Handle to the container to be configured. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3706 * flags: An array of unsigned longs with column flags. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3707 * titles: An array of strings with column text titles. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3708 * count: The number of columns (this should match the arrays). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3709 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3710 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3711 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3712 char **newtitles = malloc(sizeof(char *) * (count + 2)); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3713 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
3714 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3715 newtitles[0] = "Icon"; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3716 newtitles[1] = "Filename"; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
3717 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3718 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3719 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
3720 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3721 memcpy(&newtitles[2], titles, sizeof(char *) * count); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3722 memcpy(&newflags[2], flags, sizeof(unsigned long) * count); |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
3723 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3724 dw_container_setup(handle, newflags, newtitles, count + 2, 0); |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
3725 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
3726 free(newtitles); |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
3727 free(newflags); |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
3728 return TRUE; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3729 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3730 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3731 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3732 * Allocates memory used to populate a container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3733 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3734 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3735 * rowcount: The number of items to be populated. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3736 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3737 void * API dw_container_alloc(HWND handle, int rowcount) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3738 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3739 DWContainer *cont = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3740 [cont addRows:rowcount]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3741 return cont; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3742 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3743 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3744 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3745 * Sets an item in specified row and column to the given data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3746 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3747 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3748 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3749 * column: Zero based column of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3750 * row: Zero based row of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3751 * data: Pointer to the data to be added. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3752 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3753 void API dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3754 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3755 DWContainer *cont = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3756 id object = nil; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3757 int type = [cont cellType:column]; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
3758 int lastadd = [cont lastAddPoint]; |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3759 |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3760 if(!data) |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3761 { |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3762 return; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3763 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3764 if(type & DW_CFA_BITMAPORICON) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3765 { |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3766 object = *((NSImage **)data); |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3767 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3768 else if(type & DW_CFA_STRING) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3769 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3770 object = [ NSString stringWithUTF8String:data ]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3771 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3772 else |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3773 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3774 char textbuffer[100]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3775 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3776 if(type & DW_CFA_ULONG) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3777 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3778 ULONG tmp = *((ULONG *)data); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3779 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3780 sprintf(textbuffer, "%lu", tmp); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3781 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3782 else if(type & DW_CFA_DATE) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3783 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3784 struct tm curtm; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3785 CDATE cdate = *((CDATE *)data); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3786 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3787 memset( &curtm, 0, sizeof(curtm) ); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3788 curtm.tm_mday = cdate.day; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3789 curtm.tm_mon = cdate.month - 1; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3790 curtm.tm_year = cdate.year - 1900; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3791 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3792 strftime(textbuffer, 100, "%x", &curtm); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3793 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3794 else if(type & DW_CFA_TIME) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3795 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3796 struct tm curtm; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3797 CTIME ctime = *((CTIME *)data); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3798 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3799 memset( &curtm, 0, sizeof(curtm) ); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3800 curtm.tm_hour = ctime.hours; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3801 curtm.tm_min = ctime.minutes; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3802 curtm.tm_sec = ctime.seconds; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3803 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3804 strftime(textbuffer, 100, "%X", &curtm); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3805 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3806 else |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3807 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3808 return; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3809 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3810 object = [ NSString stringWithUTF8String:textbuffer ]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3811 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3812 |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
3813 [cont editCell:object at:(row+lastadd) and:column]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3814 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3815 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3816 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3817 * Changes an existing item in specified row and column to the given data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3818 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3819 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3820 * column: Zero based column of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3821 * row: Zero based row of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3822 * data: Pointer to the data to be added. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3823 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3824 void API dw_container_change_item(HWND handle, int column, int row, void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3825 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3826 dw_container_set_item(handle, NULL, column, row, data); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3827 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3828 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3829 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3830 * Changes an existing item in specified row and column to the given data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3831 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3832 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3833 * column: Zero based column of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3834 * row: Zero based row of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3835 * data: Pointer to the data to be added. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3836 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3837 void API dw_filesystem_change_item(HWND handle, int column, int row, void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3838 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3839 dw_container_change_item(handle, column+2, row, data); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3840 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3841 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3842 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3843 * Changes an item in specified row and column to the given data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3844 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3845 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3846 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3847 * column: Zero based column of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3848 * row: Zero based row of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3849 * data: Pointer to the data to be added. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3850 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3851 void API dw_filesystem_change_file(HWND handle, int row, char *filename, HICN icon) |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3852 { |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3853 dw_container_change_item(handle, 0, row, &icon); |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
3854 dw_container_change_item(handle, 1, row, filename); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3855 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3856 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3857 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3858 * Sets an item in specified row and column to the given data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3859 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3860 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3861 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3862 * column: Zero based column of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3863 * row: Zero based row of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3864 * data: Pointer to the data to be added. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3865 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3866 void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, HICN icon) |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3867 { |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
3868 dw_container_set_item(handle, pointer, 0, row, &icon); |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
3869 dw_container_set_item(handle, pointer, 1, row, filename); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3870 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3871 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3872 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3873 * Sets an item in specified row and column to the given data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3874 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3875 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3876 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3877 * column: Zero based column of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3878 * row: Zero based row of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3879 * data: Pointer to the data to be added. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3880 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3881 void API dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3882 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3883 dw_container_set_item(handle, pointer, column+2, row, data); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3884 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3885 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3886 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3887 * Gets column type for a container column |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3888 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3889 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3890 * column: Zero based column. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3891 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3892 int API dw_container_get_column_type(HWND handle, int column) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3893 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3894 DWContainer *cont = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3895 return [cont cellType:column]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3896 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3897 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3898 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3899 * Gets column type for a filesystem container column |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3900 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3901 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3902 * column: Zero based column. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3903 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3904 int API dw_filesystem_get_column_type(HWND handle, int column) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3905 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3906 DWContainer *cont = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3907 return [cont cellType:column+2]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3908 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3909 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3910 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3911 * Sets the width of a column in the container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3912 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3913 * handle: Handle to window (widget) of container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3914 * column: Zero based column of width being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3915 * width: Width of column in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3916 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3917 void API dw_container_set_column_width(HWND handle, int column, int width) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3918 { |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3919 DWContainer *cont = handle; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3920 NSTableColumn *col = [cont getColumn:column]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3921 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3922 [col setWidth:width]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3923 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3924 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3925 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3926 * Sets the title of a row in the container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3927 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3928 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3929 * row: Zero based row of data being set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3930 * title: String title of the item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3931 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3932 void API dw_container_set_row_title(void *pointer, int row, char *title) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3933 { |
659
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
3934 DWContainer *cont = pointer; |
756015085da7
Fixes for container signal handling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
658
diff
changeset
|
3935 return [cont setRow:row title:title]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3936 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3937 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3938 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3939 * Sets the title of a row in the container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3940 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3941 * handle: Handle to the container window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3942 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3943 * rowcount: The number of rows to be inserted. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3944 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3945 void API dw_container_insert(HWND handle, void *pointer, int rowcount) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3946 { |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
3947 DWContainer *cont = handle; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
3948 return [cont reloadData]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3949 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3950 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3951 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3952 * Removes all rows from a container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3953 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3954 * handle: Handle to the window (widget) to be cleared. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3955 * redraw: TRUE to cause the container to redraw immediately. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3956 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3957 void API dw_container_clear(HWND handle, int redraw) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3958 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
3959 DWContainer *cont = handle; |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3960 [cont clear]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3961 if(redraw) |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3962 { |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3963 [cont reloadData]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
3964 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3965 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3966 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3967 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3968 * Removes the first x rows from a container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3969 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3970 * handle: Handle to the window (widget) to be deleted from. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3971 * rowcount: The number of rows to be deleted. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3972 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3973 void API dw_container_delete(HWND handle, int rowcount) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3974 { |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3975 DWContainer *cont = handle; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3976 int x; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3977 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3978 for(x=0;x<rowcount;x++) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3979 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3980 [cont removeRow:0]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
3981 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3982 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3983 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3984 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3985 * Scrolls container up or down. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3986 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3987 * handle: Handle to the window (widget) to be scrolled. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3988 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3989 * DW_SCROLL_BOTTOM. (rows is ignored for last two) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3990 * rows: The number of rows to be scrolled. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3991 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3992 void API dw_container_scroll(HWND handle, int direction, long rows) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3993 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3994 NSLog(@"dw_container_scroll() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3995 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3996 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3997 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3998 * Starts a new query of a container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3999 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4000 * handle: Handle to the window (widget) to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4001 * flags: If this parameter is DW_CRA_SELECTED it will only |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4002 * return items that are currently selected. Otherwise |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4003 * it will return all records in the container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4004 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4005 char * API dw_container_query_start(HWND handle, unsigned long flags) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4006 { |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4007 DWContainer *cont = handle; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4008 NSIndexSet *selected = [cont selectedRowIndexes]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4009 NSUInteger result = [selected indexGreaterThanOrEqualToIndex:0]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4010 char *retval = NULL; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4011 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4012 if(result != NSNotFound) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4013 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4014 retval = [cont getRowTitle:(int)result]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4015 [cont setLastQueryPoint:(int)result]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4016 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4017 [selected release]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4018 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4019 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4020 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4021 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4022 * Continues an existing query of a container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4023 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4024 * handle: Handle to the window (widget) to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4025 * flags: If this parameter is DW_CRA_SELECTED it will only |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4026 * return items that are currently selected. Otherwise |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4027 * it will return all records in the container. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4028 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4029 char * API dw_container_query_next(HWND handle, unsigned long flags) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4030 { |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4031 DWContainer *cont = handle; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4032 int lastQueryPoint = [cont lastQueryPoint]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4033 NSIndexSet *selected = [cont selectedRowIndexes]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4034 NSUInteger result = [selected indexGreaterThanIndex:lastQueryPoint]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4035 char *retval = NULL; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4036 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4037 if(result != NSNotFound) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4038 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4039 retval = [cont getRowTitle:(int)result]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4040 [cont setLastQueryPoint:(int)result]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4041 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4042 [selected release]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4043 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4044 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4045 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4046 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4047 * Cursors the item with the text speficied, and scrolls to that item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4048 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4049 * handle: Handle to the window (widget) to be queried. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4050 * text: Text usually returned by dw_container_query(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4051 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4052 void API dw_container_cursor(HWND handle, char *text) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4053 { |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4054 DWContainer *cont = handle; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4055 char *thistext; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4056 int x, count = (int)[cont numberOfRowsInTableView:cont]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4057 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4058 for(x=0;x<count;x++) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4059 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4060 thistext = [cont getRowTitle:x]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4061 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4062 if(thistext == text) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4063 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4064 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)x]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4065 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4066 [cont selectRowIndexes:selected byExtendingSelection:YES]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4067 [selected release]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4068 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4069 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4070 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4071 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4072 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4073 * Deletes the item with the text speficied. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4074 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4075 * handle: Handle to the window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4076 * text: Text usually returned by dw_container_query(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4077 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4078 void API dw_container_delete_row(HWND handle, char *text) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4079 { |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4080 DWContainer *cont = handle; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4081 char *thistext; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4082 int x, count = (int)[cont numberOfRowsInTableView:cont]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4083 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4084 for(x=0;x<count;x++) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4085 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4086 thistext = [cont getRowTitle:x]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4087 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4088 if(thistext == text) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4089 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4090 [cont removeRow:x]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4091 return; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4092 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
4093 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4094 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4095 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4096 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4097 * Optimizes the column widths so that all data is visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4098 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4099 * handle: Handle to the window (widget) to be optimized. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4100 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4101 void API dw_container_optimize(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4102 { |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
4103 DWContainer *cont = handle; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
4104 /*[cont sizeToFit];*/ |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
4105 [cont setColumnAutoresizingStyle:NSTableViewUniformColumnAutoresizingStyle]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4106 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4107 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4108 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4109 * Inserts an icon into the taskbar. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4110 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4111 * handle: Window handle that will handle taskbar icon messages. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4112 * icon: Icon handle to display in the taskbar. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4113 * bubbletext: Text to show when the mouse is above the icon. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4114 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4115 void API dw_taskbar_insert(HWND handle, HICN icon, char *bubbletext) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4116 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4117 NSLog(@"dw_taskbar_insert() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4118 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4119 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4120 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4121 * Deletes an icon from the taskbar. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4122 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4123 * handle: Window handle that was used with dw_taskbar_insert(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4124 * icon: Icon handle that was used with dw_taskbar_insert(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4125 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4126 void API dw_taskbar_delete(HWND handle, HICN icon) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4127 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4128 NSLog(@"dw_taskbar_delete() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4129 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4130 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4131 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4132 * Obtains an icon from a module (or header in GTK). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4133 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4134 * module: Handle to module (DLL) in OS/2 and Windows. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4135 * id: A unsigned long id int the resources on OS/2 and |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4136 * Windows, on GTK this is converted to a pointer |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4137 * to an embedded XPM. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4138 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4139 HICN API dw_icon_load(unsigned long module, unsigned long resid) |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4140 { |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4141 NSBundle *bundle = [NSBundle mainBundle]; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4142 NSString *respath = [bundle resourcePath]; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4143 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4144 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4145 [bundle release]; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4146 [respath release]; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4147 [filepath release]; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4148 return image; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4149 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4150 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4151 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4152 * Obtains an icon from a file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4153 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4154 * filename: Name of the file, omit extention to have |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4155 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4156 * (ICO on OS/2 or Windows, XPM on Unix) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4157 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4158 HICN API dw_icon_load_from_file(char *filename) |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4159 { |
674
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4160 NSString *nstr = [ NSString stringWithUTF8String:filename ]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4161 NSImage *image = [[NSImage alloc] initWithContentsOfFile:nstr]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4162 if(!image) |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4163 { |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4164 nstr = [nstr stringByAppendingString:@".png"]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4165 image = [[NSImage alloc] initWithContentsOfFile:nstr]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4166 } |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4167 [nstr release]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4168 return image; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4169 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4170 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4171 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4172 * Obtains an icon from data |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4173 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4174 * filename: Name of the file, omit extention to have |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4175 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4176 * (ICO on OS/2 or Windows, XPM on Unix) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4177 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4178 HICN API dw_icon_load_from_data(char *data, int len) |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4179 { |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4180 NSData *thisdata = [[[NSData alloc] dataWithBytes:data length:len] autorelease]; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4181 NSImage *image = [[NSImage alloc] initWithData:thisdata]; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4182 [thisdata release]; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4183 return image; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4184 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4185 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4186 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4187 * Frees a loaded resource in OS/2 and Windows. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4188 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4189 * handle: Handle to icon returned by dw_icon_load(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4190 */ |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4191 void API dw_icon_free(HICN handle) |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4192 { |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4193 NSImage *image = handle; |
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4194 [image release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4195 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4196 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4197 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4198 * Create a new MDI Frame to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4199 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4200 * id: An ID to be used with dw_window_from_id or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4201 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4202 HWND API dw_mdi_new(unsigned long cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4203 { |
684
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
4204 /* There isn't anything like quite like MDI on MacOS... |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
4205 * However we will make floating windows that hide |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
4206 * when the application is deactivated to simulate |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
4207 * similar behavior. |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
4208 */ |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
4209 DWMDI *mdi = [[DWMDI alloc] init]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4210 /* [mdi setTag:cid]; Why doesn't this work? */ |
684
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
4211 return mdi; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4212 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4213 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4214 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4215 * Creates a splitbar window (widget) with given parameters. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4216 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4217 * type: Value can be DW_VERT or DW_HORZ. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4218 * topleft: Handle to the window to be top or left. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4219 * bottomright: Handle to the window to be bottom or right. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4220 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4221 * A handle to a splitbar window or NULL on failure. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4222 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4223 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4224 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4225 DWSplitBar *split = [[DWSplitBar alloc] init]; |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4226 HWND tmpbox = dw_box_new(DW_VERT, 0); |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4227 [split setDelegate:split]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4228 dw_box_pack_start(tmpbox, topleft, 0, 0, TRUE, TRUE, 0); |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4229 [split addSubview:tmpbox]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4230 tmpbox = dw_box_new(DW_VERT, 0); |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4231 dw_box_pack_start(tmpbox, bottomright, 0, 0, TRUE, TRUE, 0); |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4232 [split addSubview:tmpbox]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4233 if(type == DW_VERT) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4234 { |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4235 [split setVertical:NO]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4236 } |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4237 else |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4238 { |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4239 [split setVertical:YES]; |
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
4240 } |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4241 /* [split setTag:cid]; Why doesn't this work? */ |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4242 return split; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4243 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4244 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4245 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4246 * Sets the position of a splitbar (pecentage). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4247 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4248 * handle: The handle to the splitbar returned by dw_splitbar_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4249 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4250 void API dw_splitbar_set(HWND handle, float percent) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4251 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4252 DWSplitBar *split = handle; |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4253 NSRect rect = [split frame]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4254 float pos; |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4255 /* Calculate the position based on the size */ |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4256 if([split isVertical]) |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4257 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4258 pos = rect.size.width * (percent / 100.0); |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4259 } |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4260 else |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4261 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4262 pos = rect.size.height * (percent / 100.0); |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4263 } |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4264 if(pos > 0) |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4265 { |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4266 [split setPosition:pos ofDividerAtIndex:0]; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4267 } |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4268 else |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4269 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4270 /* If we have no size.. wait until the resize |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4271 * event when we get an actual size to try |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4272 * to set the splitbar again. |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4273 */ |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4274 [split setPercent:percent]; |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4275 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4276 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4277 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4278 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4279 * Gets the position of a splitbar (pecentage). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4280 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4281 * handle: The handle to the splitbar returned by dw_splitbar_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4282 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4283 float API dw_splitbar_get(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4284 { |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4285 DWSplitBar *split = handle; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4286 NSRect rect1 = [split frame]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4287 NSArray *subviews = [split subviews]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4288 NSView *view = [subviews objectAtIndex:0]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4289 NSRect rect2 = [view frame]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4290 float pos, total, retval = 0.0; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4291 if([split isVertical]) |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4292 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4293 total = rect1.size.width; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4294 pos = rect2.size.width; |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4295 } |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4296 else |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4297 { |
677
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4298 total = rect1.size.height; |
99002595f549
Fixes for dw_splitbar_set() not working on an unsized window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
676
diff
changeset
|
4299 pos = rect2.size.height; |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4300 } |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4301 if(total > 0) |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4302 { |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4303 retval = pos / total; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4304 } |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
4305 return retval; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4306 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4307 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4308 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4309 * Create a bitmap object to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4310 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4311 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4312 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4313 HWND API dw_bitmap_new(ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4314 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
4315 NSImageView *bitmap = [[NSImageView alloc] init]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
4316 [bitmap setImageFrameStyle:NSImageFrameNone]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
4317 [bitmap setEditable:NO]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4318 [bitmap setTag:cid]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
4319 return bitmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4320 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4321 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4322 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4323 * Creates a pixmap with given parameters. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4324 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4325 * handle: Window handle the pixmap is associated with. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4326 * width: Width of the pixmap in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4327 * height: Height of the pixmap in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4328 * depth: Color depth of the pixmap. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4329 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4330 * A handle to a pixmap or NULL on failure. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4331 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4332 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4333 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
4334 NSSize size = { (float)width, (float)height }; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4335 HPIXMAP pixmap; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4336 |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4337 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4338 return NULL; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4339 pixmap->width = width; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4340 pixmap->height = height; |
664
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
4341 NSImage *image = pixmap->handle = [[NSImage alloc] initWithSize:size]; |
ba3af8eb56f1
Fixed drawing of rects and points. Fonts now properly draw in color. Updated property list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
662
diff
changeset
|
4342 [image setFlipped:YES]; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4343 return pixmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4344 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4345 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4346 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4347 * Creates a pixmap from a file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4348 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4349 * handle: Window handle the pixmap is associated with. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4350 * filename: Name of the file, omit extention to have |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4351 * DW pick the appropriate file extension. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4352 * (BMP on OS/2 or Windows, XPM on Unix) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4353 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4354 * A handle to a pixmap or NULL on failure. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4355 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4356 HPIXMAP API dw_pixmap_new_from_file(HWND handle, char *filename) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4357 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4358 HPIXMAP pixmap; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4359 |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4360 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4361 return NULL; |
674
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4362 NSString *nstr = [ NSString stringWithUTF8String:filename ]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4363 NSImage *image = [[NSImage alloc] initWithContentsOfFile:nstr]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4364 if(!image) |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4365 { |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4366 nstr = [nstr stringByAppendingString:@".png"]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4367 image = [[NSImage alloc] initWithContentsOfFile:nstr]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4368 } |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
4369 [nstr release]; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4370 NSSize size = [image size]; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4371 pixmap->width = size.width; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4372 pixmap->height = size.height; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4373 pixmap->handle = image; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4374 return pixmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4375 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4376 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4377 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4378 * Creates a pixmap from memory. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4379 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4380 * handle: Window handle the pixmap is associated with. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4381 * data: Source of the image data |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4382 * (BMP on OS/2 or Windows, XPM on Unix) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4383 * le: length of data |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4384 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4385 * A handle to a pixmap or NULL on failure. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4386 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4387 HPIXMAP API dw_pixmap_new_from_data(HWND handle, char *data, int len) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4388 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4389 HPIXMAP pixmap; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4390 |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4391 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4392 return NULL; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
4393 NSData *thisdata = [[[NSData alloc] dataWithBytes:data length:len] autorelease]; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4394 NSImage *image = [[NSImage alloc] initWithData:thisdata]; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4395 NSSize size = [image size]; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4396 pixmap->width = size.width; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4397 pixmap->height = size.height; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4398 pixmap->handle = image; |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
4399 [thisdata release]; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4400 return pixmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4401 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4402 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4403 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4404 * Creates a bitmap mask for rendering bitmaps with transparent backgrounds |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4405 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4406 void API dw_pixmap_set_transparent_color( HPIXMAP pixmap, ULONG color ) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4407 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4408 NSLog(@"dw_pixmap_set_transparent_color() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4409 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4410 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4411 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4412 * Creates a pixmap from internal resource graphic specified by id. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4413 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4414 * handle: Window handle the pixmap is associated with. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4415 * id: Resource ID associated with requested pixmap. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4416 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4417 * A handle to a pixmap or NULL on failure. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4418 */ |
670
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4419 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG resid) |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4420 { |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4421 HPIXMAP pixmap; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4422 |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4423 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4424 return NULL; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4425 |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4426 NSBundle *bundle = [NSBundle mainBundle]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4427 NSString *respath = [bundle resourcePath]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4428 NSString *filepath = [respath stringByAppendingFormat:@"/%u.png", resid]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4429 NSImage *image = [[NSImage alloc] initWithContentsOfFile:filepath]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4430 NSSize size = [image size]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4431 pixmap->width = size.width; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4432 pixmap->height = size.height; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4433 pixmap->handle = image; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4434 [bundle release]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4435 [respath release]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4436 [filepath release]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4437 [image release]; |
0b920d0dc13e
Implemented bitmap buttons and pixmaps from bundle resources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
669
diff
changeset
|
4438 return pixmap; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4439 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4440 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4441 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4442 * Destroys an allocated pixmap. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4443 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4444 * pixmap: Handle to a pixmap returned by |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4445 * dw_pixmap_new.. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4446 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4447 void API dw_pixmap_destroy(HPIXMAP pixmap) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4448 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4449 NSImage *image = (NSImage *)pixmap->handle; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
4450 [image dealloc]; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4451 free(pixmap); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4452 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4453 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4454 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4455 * Copies from one item to another. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4456 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4457 * dest: Destination window handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4458 * destp: Destination pixmap. (choose only one). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4459 * xdest: X coordinate of destination. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4460 * ydest: Y coordinate of destination. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4461 * width: Width of area to copy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4462 * height: Height of area to copy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4463 * src: Source window handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4464 * srcp: Source pixmap. (choose only one). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4465 * xsrc: X coordinate of source. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4466 * ysrc: Y coordinate of source. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4467 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4468 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) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4469 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4470 id bltdest = dest; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4471 id bltsrc = src; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4472 if(destp) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4473 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4474 bltdest = (id)destp->handle; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4475 [bltdest lockFocus]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4476 } |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4477 else |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4478 { |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4479 [bltdest lockFocusIfCanDraw]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
4480 _DWLastDrawable = dest; |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4481 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4482 if(srcp) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4483 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
4484 bltsrc = (id)srcp->handle; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
4485 NSImage *image = bltsrc; |
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
4486 [image drawAtPoint:NSMakePoint(xdest, ydest) fromRect:NSMakeRect(xsrc, ysrc, width, height) operation:NSCompositeCopy fraction:1.0]; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4487 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4488 [bltdest unlockFocus]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4489 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4490 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4491 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4492 * Create a new static text window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4493 * Not available under OS/2, eCS |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4494 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4495 * text: The text to be display by the static text widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4496 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4497 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4498 HWND API dw_calendar_new(ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4499 { |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4500 DWCalendar *calendar = [[DWCalendar alloc] init]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4501 /*[calendar setDatePickerMode:UIDatePickerModeDate];*/ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4502 [calendar setTag:cid]; |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4503 return calendar; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4504 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4505 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4506 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4507 * Sets the current date of a calendar |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4508 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4509 * handle: The handle to the calendar returned by dw_calendar_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4510 * year... |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4511 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4512 void dw_calendar_set_date(HWND handle, unsigned int year, unsigned int month, unsigned int day) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4513 { |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4514 DWCalendar *calendar = handle; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4515 NSDate *date; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4516 char buffer[100]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4517 |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4518 sprintf(buffer, "%04d-%02d-%02d 00:00:00 +0600", year, month, day); |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4519 |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4520 date = [[NSDate alloc] initWithString:[ NSString stringWithUTF8String:buffer ]]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4521 [calendar setDateValue:date]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4522 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4523 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4524 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4525 * Gets the position of a splitbar (pecentage). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4526 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4527 * handle: The handle to the splitbar returned by dw_splitbar_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4528 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4529 void dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4530 { |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4531 DWCalendar *calendar = handle; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4532 NSDate *date = [calendar dateValue]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4533 NSDateFormatter *df = [[NSDateFormatter alloc] init]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4534 NSString *nstr = [df stringFromDate:date]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4535 sscanf([ nstr UTF8String ], "%d-%d-%d", year, month, day); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4536 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4537 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4538 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4539 * Causes the embedded HTML widget to take action. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4540 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4541 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4542 * action: One of the DW_HTML_* constants. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4543 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4544 void API dw_html_action(HWND handle, int action) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4545 { |
655
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4546 WebView *html = handle; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4547 switch(action) |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4548 { |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4549 case DW_HTML_GOBACK: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4550 [html goBack]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4551 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4552 case DW_HTML_GOFORWARD: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4553 [html goForward]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4554 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4555 case DW_HTML_GOHOME: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4556 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4557 case DW_HTML_SEARCH: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4558 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4559 case DW_HTML_RELOAD: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4560 [html reload:html]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4561 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4562 case DW_HTML_STOP: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4563 [html stopLoading:html]; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4564 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4565 case DW_HTML_PRINT: |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4566 break; |
27eb39d2577b
Calendar and HTML functions filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
654
diff
changeset
|
4567 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4568 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4569 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4570 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4571 * Render raw HTML code in the embedded HTML widget.. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4572 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4573 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4574 * string: String buffer containt HTML code to |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4575 * be rendered. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4576 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4577 * 0 on success. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4578 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4579 int API dw_html_raw(HWND handle, char *string) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4580 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4581 WebView *html = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4582 [[html mainFrame] loadHTMLString:[ NSString stringWithUTF8String:string ] baseURL:nil]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4583 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4584 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4585 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4586 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4587 * Render file or web page in the embedded HTML widget.. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4588 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4589 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4590 * url: Universal Resource Locator of the web or |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4591 * file object to be rendered. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4592 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4593 * 0 on success. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4594 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4595 int API dw_html_url(HWND handle, char *url) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4596 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4597 WebView *html = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4598 [[html mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[ NSString stringWithUTF8String:url ]]]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4599 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4600 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4601 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4602 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4603 * Create a new HTML window (widget) to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4604 * Not available under OS/2, eCS |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4605 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4606 * text: The default text to be in the entryfield widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4607 * id: An ID to be used with dw_window_from_id() or 0L. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4608 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4609 HWND API dw_html_new(unsigned long cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4610 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4611 WebView *web = [[WebView alloc] init]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4612 /* [web setTag:cid]; Why doesn't this work? */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4613 return web; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4614 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4615 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4616 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4617 * Returns the current X and Y coordinates of the mouse pointer. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4618 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4619 * x: Pointer to variable to store X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4620 * y: Pointer to variable to store Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4621 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4622 void API dw_pointer_query_pos(long *x, long *y) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4623 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4624 NSPoint mouseLoc; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4625 mouseLoc = [NSEvent mouseLocation]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4626 if(x) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4627 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4628 *x = mouseLoc.x; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4629 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4630 if(y) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4631 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4632 *y = mouseLoc.y; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4633 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4634 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4635 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4636 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4637 * Sets the X and Y coordinates of the mouse pointer. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4638 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4639 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4640 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4641 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4642 void API dw_pointer_set_pos(long x, long y) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4643 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
4644 /* From what I have read this isn't possible, agaist human interface rules */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4645 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4646 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4647 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4648 * Create a menu object to be popped up. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4649 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4650 * id: An ID to be used for getting the resource from the |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4651 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4652 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4653 HMENUI API dw_menu_new(ULONG cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4654 { |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4655 NSMenu *menu = [[[NSMenu alloc] init] autorelease]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4656 [menu setAutoenablesItems:NO]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4657 /* [menu setTag:cid]; Why doesn't this work? */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4658 return menu; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4659 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4660 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4661 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4662 * Create a menubar on a window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4663 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4664 * location: Handle of a window frame to be attached to. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4665 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4666 HMENUI API dw_menubar_new(HWND location) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4667 { |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4668 NSWindow *window = location; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4669 NSMenu *windowmenu = _generate_main_menu(); |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4670 [[window contentView] setMenu:windowmenu]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4671 return (HMENUI)windowmenu; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4672 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4673 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4674 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4675 * Destroys a menu created with dw_menubar_new or dw_menu_new. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4676 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4677 * menu: Handle of a menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4678 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4679 void API dw_menu_destroy(HMENUI *menu) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4680 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4681 NSMenu *thismenu = *menu; |
658
0502e5b6743b
Haven't finished but the basics of the container/listbox are now working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
657
diff
changeset
|
4682 [thismenu release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4683 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4684 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4685 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4686 * Pops up a context menu at given x and y coordinates. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4687 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4688 * menu: The handle the the existing menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4689 * parent: Handle to the window initiating the popup. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4690 * x: X coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4691 * y: Y coordinate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4692 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4693 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4694 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4695 NSMenu *thismenu = (NSMenu *)menu; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4696 NSView *view = parent; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4697 NSEvent* fake = [[NSEvent alloc] |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4698 mouseEventWithType:NSLeftMouseDown |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4699 location:NSMakePoint(x,y) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4700 modifierFlags:0 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4701 timestamp:1 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4702 windowNumber:[[view window] windowNumber] |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4703 context:[NSGraphicsContext currentContext] |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4704 eventNumber:1 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4705 clickCount:1 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4706 pressure:0.0]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4707 [NSMenu popUpContextMenu:thismenu withEvent:fake forView:view]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4708 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4709 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4710 char _removetilde(char *dest, char *src) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4711 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4712 int z, cur=0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4713 char accel = '\0'; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4714 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4715 for(z=0;z<strlen(src);z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4716 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4717 if(src[z] != '~') |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4718 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4719 dest[cur] = src[z]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4720 cur++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4721 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4722 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4723 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4724 accel = src[z+1]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4725 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4726 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4727 dest[cur] = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4728 return accel; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4729 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4730 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4731 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4732 * Adds a menuitem or submenu to an existing menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4733 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4734 * menu: The handle the the existing menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4735 * title: The title text on the menu item to be added. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4736 * id: An ID to be used for message passing. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4737 * flags: Extended attributes to set on the menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4738 * end: If TRUE memu is positioned at the end of the menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4739 * check: If TRUE menu is "check"able. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4740 * flags: Extended attributes to set on the menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4741 * submenu: Handle to an existing menu to be a submenu or NULL. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4742 */ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4743 HWND API dw_menu_append_item(HMENUI menux, char *title, ULONG itemid, ULONG flags, int end, int check, HMENUI submenux) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4744 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4745 NSMenu *menu = menux; |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4746 NSMenu *submenu = submenux; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4747 NSMenuItem *item = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4748 if(strlen(title) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4749 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4750 [menu addItem:[NSMenuItem separatorItem]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4751 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4752 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4753 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4754 char accel[2]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4755 char *newtitle = malloc(strlen(title)+1); |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4756 NSString *nstr; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4757 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4758 accel[0] = _removetilde(newtitle, title); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4759 accel[1] = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4760 |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4761 nstr = [ NSString stringWithUTF8String:newtitle ]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4762 free(newtitle); |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4763 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4764 item = [menu addItemWithTitle: nstr |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4765 action:@selector(menuHandler:) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4766 keyEquivalent:[ NSString stringWithUTF8String:accel ]]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4767 [item setTag:itemid]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4768 if(flags & DW_MIS_CHECKED) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4769 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4770 [item setState:NSOnState]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4771 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4772 if(flags & DW_MIS_DISABLED) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4773 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4774 [item setEnabled:NO]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4775 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4776 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4777 if(submenux) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4778 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4779 [submenu setTitle:nstr]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4780 [menu setSubmenu:submenu forItem:item]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4781 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4782 return item; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4783 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4784 return item; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4785 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4786 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4787 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4788 * Sets the state of a menu item check. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4789 * Deprecated; use dw_menu_item_set_state() |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4790 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4791 * menu: The handle the the existing menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4792 * id: Menuitem id. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4793 * check: TRUE for checked FALSE for not checked. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4794 */ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4795 void API dw_menu_item_set_check(HMENUI menux, unsigned long itemid, int check) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4796 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4797 id menu = menux; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4798 NSMenuItem *menuitem = (NSMenuItem *)[menu itemWithTag:itemid]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4799 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4800 if(menuitem != nil) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4801 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4802 if(check) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4803 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4804 [menuitem setState:NSOnState]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4805 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4806 else |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4807 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4808 [menuitem setState:NSOffState]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4809 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4810 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4811 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4812 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4813 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4814 * Sets the state of a menu item. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4815 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4816 * menu: The handle to the existing menu. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4817 * id: Menuitem id. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4818 * flags: DW_MIS_ENABLED/DW_MIS_DISABLED |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4819 * DW_MIS_CHECKED/DW_MIS_UNCHECKED |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4820 */ |
654
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4821 void API dw_menu_item_set_state(HMENUI menux, unsigned long itemid, unsigned long state) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4822 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4823 id menu = menux; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4824 NSMenuItem *menuitem = (NSMenuItem *)[menu itemWithTag:itemid]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4825 |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4826 if(menuitem != nil) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4827 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4828 if(state & DW_MIS_CHECKED) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4829 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4830 [menuitem setState:NSOnState]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4831 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4832 else if(state & DW_MIS_UNCHECKED) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4833 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4834 [menuitem setState:NSOffState]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4835 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4836 if(state & DW_MIS_ENABLED) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4837 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4838 [menuitem setEnabled:YES]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4839 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4840 else if(state & DW_MIS_DISABLED) |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4841 { |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4842 [menuitem setEnabled:NO]; |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4843 } |
80e253df49fd
Implementing the menubar and hopefully popup menus.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
653
diff
changeset
|
4844 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4845 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4846 |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4847 /* Gets the notebook page from associated ID */ |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4848 DWNotebookPage *_notepage_from_id(DWNotebook *notebook, unsigned long pageid) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4849 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4850 NSArray *pages = [notebook tabViewItems]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4851 for(DWNotebookPage *notepage in pages) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4852 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4853 if([notepage pageid] == pageid) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4854 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4855 return notepage; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4856 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4857 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4858 return nil; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4859 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4860 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4861 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4862 * Create a notebook object to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4863 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4864 * id: An ID to be used for getting the resource from the |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4865 * resource file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4866 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4867 HWND API dw_notebook_new(ULONG cid, int top) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4868 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4869 DWNotebook *notebook = [[DWNotebook alloc] init]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4870 [notebook setDelegate:notebook]; |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
4871 /* [notebook setTag:cid]; Why doesn't this work? */ |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4872 return notebook; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4873 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4874 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4875 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4876 * Adds a new page to specified notebook. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4877 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4878 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4879 * flags: Any additional page creation flags. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4880 * front: If TRUE page is added at the beginning. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4881 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4882 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4883 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4884 DWNotebook *notebook = handle; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
4885 NSInteger page = [notebook pageid]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4886 DWNotebookPage *notepage = [[DWNotebookPage alloc] initWithIdentifier:nil]; |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
4887 [notepage setPageid:(NSInteger)page]; |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4888 if(front) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4889 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4890 [notebook insertTabViewItem:notepage atIndex:(NSInteger)0]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4891 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4892 else |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4893 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4894 [notebook addTabViewItem:notepage]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4895 } |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4896 [notebook setPageid:(page+1)]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4897 return (unsigned long)page; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4898 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4899 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4900 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4901 * Remove a page from a notebook. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4902 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4903 * handle: Handle to the notebook widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4904 * pageid: ID of the page to be destroyed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4905 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4906 void API dw_notebook_page_destroy(HWND handle, unsigned int pageid) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4907 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4908 DWNotebook *notebook = handle; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4909 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4910 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4911 if(notepage != nil) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4912 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4913 [notebook removeTabViewItem:notepage]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4914 [notepage release]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4915 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4916 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4917 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4918 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4919 * Queries the currently visible page ID. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4920 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4921 * handle: Handle to the notebook widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4922 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4923 unsigned long API dw_notebook_page_get(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4924 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4925 DWNotebook *notebook = handle; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4926 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4927 return [notepage pageid]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4928 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4929 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4930 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4931 * Sets the currently visibale page ID. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4932 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4933 * handle: Handle to the notebook widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4934 * pageid: ID of the page to be made visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4935 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4936 void API dw_notebook_page_set(HWND handle, unsigned int pageid) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4937 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4938 DWNotebook *notebook = handle; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4939 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4940 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4941 if(notepage != nil) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4942 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4943 [notebook selectTabViewItem:notepage]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4944 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4945 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4946 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4947 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4948 * Sets the text on the specified notebook tab. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4949 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4950 * handle: Notebook handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4951 * pageid: Page ID of the tab to set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4952 * text: Pointer to the text to set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4953 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4954 void API dw_notebook_page_set_text(HWND handle, ULONG pageid, char *text) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4955 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4956 DWNotebook *notebook = handle; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4957 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4958 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4959 if(notepage != nil) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4960 { |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4961 [notepage setLabel:[ NSString stringWithUTF8String:text ]]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4962 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4963 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4964 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4965 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4966 * Sets the text on the specified notebook tab status area. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4967 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4968 * handle: Notebook handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4969 * pageid: Page ID of the tab to set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4970 * text: Pointer to the text to set. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4971 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4972 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4973 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4974 /* Note supported here... do nothing */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4975 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4976 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4977 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4978 * Packs the specified box into the notebook page. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4979 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4980 * handle: Handle to the notebook to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4981 * pageid: Page ID in the notebook which is being packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4982 * page: Box handle to be packed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4983 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4984 void API dw_notebook_pack(HWND handle, ULONG pageid, HWND page) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4985 { |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4986 DWNotebook *notebook = handle; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4987 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4988 |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4989 if(notepage != nil) |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4990 { |
667
28727d9a835c
Fix for a rather serious notebook layout bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
666
diff
changeset
|
4991 HWND tmpbox = dw_box_new(DW_VERT, 0); |
28727d9a835c
Fix for a rather serious notebook layout bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
666
diff
changeset
|
4992 DWBox *box = tmpbox; |
28727d9a835c
Fix for a rather serious notebook layout bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
666
diff
changeset
|
4993 |
28727d9a835c
Fix for a rather serious notebook layout bug.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
666
diff
changeset
|
4994 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0); |
652
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4995 [notepage setView:box]; |
ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
651
diff
changeset
|
4996 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4997 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4998 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4999 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5000 * Create a new Window Frame. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5001 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5002 * owner: The Owner's window handle or HWND_DESKTOP. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5003 * title: The Window title. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5004 * flStyle: Style flags, see the PM reference. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5005 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5006 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5007 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5008 NSRect frame = NSMakeRect(1,1,1,1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5009 NSWindow *window = [[NSWindow alloc] |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5010 initWithContentRect:frame |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5011 styleMask:(flStyle | NSTexturedBackgroundWindowMask) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5012 backing:NSBackingStoreBuffered |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5013 defer:false]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5014 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5015 [window setTitle:[ NSString stringWithUTF8String:title ]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5016 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5017 DWView *view = [[DWView alloc] init]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5018 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5019 [window setContentView:view]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5020 [window setDelegate:view]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5021 [window makeKeyAndOrderFront:nil]; |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
5022 [window setAllowsConcurrentViewDrawing:NO]; |
684
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5023 |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5024 /* If it isn't a toplevel window... */ |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5025 if(hwndOwner) |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5026 { |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5027 id object = hwndOwner; |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5028 |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5029 /* Check to see if the parent is an MDI window */ |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5030 if([object isMemberOfClass:[DWMDI class]]) |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5031 { |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5032 /* Set the window level to be floating */ |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5033 [window setLevel:NSFloatingWindowLevel]; |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5034 [window setHidesOnDeactivate:YES]; |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5035 } |
014b02436c1f
Added MDI simulation code... the MDI "window" will just be a box for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
683
diff
changeset
|
5036 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5037 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5038 return (HWND)window; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5039 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5040 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5041 /* |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5042 * Call a function from the window (widget)'s context. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5043 * Parameters: |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5044 * handle: Window handle of the widget. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5045 * function: Function pointer to be called. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5046 * data: Pointer to the data to be passed to the function. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5047 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5048 void API dw_window_function(HWND handle, void *function, void *data) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5049 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5050 void (* windowfunc)(void *); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5051 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5052 windowfunc = function; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5053 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5054 if(windowfunc) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5055 windowfunc(data); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5056 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5057 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5058 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5059 /* |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5060 * Changes the appearance of the mouse pointer. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5061 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5062 * handle: Handle to widget for which to change. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5063 * cursortype: ID of the pointer you want. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5064 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5065 void API dw_window_set_pointer(HWND handle, int pointertype) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5066 { |
669
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5067 id object = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5068 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5069 if([ object isKindOfClass:[ NSView class ] ]) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5070 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5071 NSView *view = handle; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5072 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5073 if(pointertype == DW_POINTER_DEFAULT) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5074 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5075 [view discardCursorRects]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5076 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5077 else if(pointertype == DW_POINTER_ARROW) |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5078 { |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5079 NSRect rect = [view frame]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5080 NSCursor *cursor = [NSCursor arrowCursor]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5081 |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5082 [view addCursorRect:rect cursor:cursor]; |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5083 } |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5084 /* No cursor for DW_POINTER_CLOCK? */ |
62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
668
diff
changeset
|
5085 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5086 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5087 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5088 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5089 * Makes the window visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5090 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5091 * handle: The window handle to make visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5092 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5093 int API dw_window_show(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5094 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5095 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5096 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5097 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5098 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5099 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5100 if([window isMiniaturized]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5101 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5102 [window deminiaturize:nil]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5103 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5104 [[window contentView] windowResized:nil]; |
668
7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
667
diff
changeset
|
5105 [[window contentView] windowDidBecomeMain:nil]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5106 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5107 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5108 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5109 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5110 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5111 * Makes the window invisible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5112 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5113 * handle: The window handle to make visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5114 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5115 int API dw_window_hide(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5116 { |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5117 /* TODO: Figure out proper dw_window_hide behavior... |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5118 * individual windows don't appear to be hidable, |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5119 * but all application windows can be hidden/deactivated |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5120 * via the NS/DWApplication class. |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5121 */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5122 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5123 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5124 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5125 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5126 * Sets the colors used by a specified window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5127 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5128 * handle: The window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5129 * fore: Foreground color in DW_RGB format or a default color index. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5130 * back: Background color in DW_RGB format or a default color index. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5131 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5132 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5133 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5134 id object = handle; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5135 unsigned long _fore = _get_color(fore); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5136 unsigned long _back = _get_color(back); |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5137 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5138 if([object isMemberOfClass:[NSTextFieldCell class]]) |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5139 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5140 NSTextFieldCell *text = object; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5141 [text setTextColor:[NSColor colorWithDeviceRed: DW_RED_VALUE(_fore)/255.0 green: DW_GREEN_VALUE(_fore)/255.0 blue: DW_BLUE_VALUE(_fore)/255.0 alpha: 1]]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5142 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5143 else if([object isMemberOfClass:[DWBox class]]) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5144 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5145 DWBox *box = object; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5146 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5147 [box setColor:_back]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5148 } |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5149 return 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5150 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5151 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5152 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5153 * Sets the font used by a specified window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5154 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5155 * handle: The window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5156 * border: Size of the window border in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5157 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5158 int API dw_window_set_border(HWND handle, int border) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5159 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5160 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5161 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5162 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5163 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5164 * Sets the style of a given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5165 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5166 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5167 * width: New width in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5168 * height: New height in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5169 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5170 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5171 { |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5172 id object = handle; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5173 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5174 if([object isMemberOfClass:[NSWindow class]]) |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5175 { |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5176 NSWindow *window = object; |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
5177 int currentstyle = (int)[window styleMask]; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5178 int tmp; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5179 |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
5180 tmp = currentstyle | (int)mask; |
653
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5181 tmp ^= mask; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5182 tmp |= style; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5183 |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5184 [window setStyleMask:tmp]; |
36c6669422d2
Continuing to add types... looking to almost be usable. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
652
diff
changeset
|
5185 } |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5186 else if([object isMemberOfClass:[NSTextView class]]) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5187 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5188 NSTextView *tv = handle; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5189 [tv setAlignment:(style & mask)]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5190 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5191 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5192 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5193 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5194 * Sets the default focus item for a window/dialog. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5195 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5196 * window: Toplevel window or dialog. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5197 * defaultitem: Handle to the dialog item to be default. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5198 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5199 void API dw_window_default(HWND window, HWND defaultitem) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5200 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5201 NSLog(@"dw_window_default() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5202 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5203 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5204 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5205 * Sets window to click the default dialog item when an ENTER is pressed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5206 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5207 * window: Window (widget) to look for the ENTER press. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5208 * next: Window (widget) to move to next (or click) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5209 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5210 void API dw_window_click_default(HWND window, HWND next) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5211 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5212 NSLog(@"dw_window_click_default() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5213 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5214 |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5215 static id _DWCapture; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5216 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5217 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5218 * Captures the mouse input to this window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5219 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5220 * handle: Handle to receive mouse input. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5221 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5222 void API dw_window_capture(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5223 { |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5224 id object = handle; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5225 |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5226 if(![object isMemberOfClass:[NSWindow class]]) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5227 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5228 object = [object window]; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5229 } |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5230 if(object) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5231 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5232 [object setAcceptsMouseMovedEvents:YES]; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5233 _DWCapture = object; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5234 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5235 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5236 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5237 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5238 * Releases previous mouse capture. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5239 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5240 void API dw_window_release(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5241 { |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5242 if(_DWCapture) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5243 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5244 [_DWCapture setAcceptsMouseMovedEvents:NO]; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5245 _DWCapture = nil; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5246 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5247 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5248 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5249 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5250 * Tracks this window movement. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5251 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5252 * handle: Handle to frame to be tracked. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5253 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5254 void API dw_window_track(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5255 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5256 NSLog(@"dw_window_track() unimplemented\n"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5257 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5258 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5259 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5260 * Changes a window's parent to newparent. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5261 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5262 * handle: The window handle to destroy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5263 * newparent: The window's new parent window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5264 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5265 void API dw_window_reparent(HWND handle, HWND newparent) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5266 { |
686
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5267 id object = handle; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5268 |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5269 if([object isMemberOfClass:[NSWindow class]]) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5270 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5271 /* We can't actually reparent on MacOS but if the |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5272 * new parent is an MDI window, change to be a |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5273 * floating window... otherwise set it to normal. |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5274 */ |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5275 NSWindow *window = handle; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5276 |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5277 /* If it isn't a toplevel window... */ |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5278 if(newparent) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5279 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5280 object = newparent; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5281 |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5282 /* Check to see if the parent is an MDI window */ |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5283 if([object isMemberOfClass:[DWMDI class]]) |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5284 { |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5285 /* Set the window level to be floating */ |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5286 [window setLevel:NSFloatingWindowLevel]; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5287 [window setHidesOnDeactivate:YES]; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5288 return; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5289 } |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5290 } |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5291 /* Set the window back to a normal window */ |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5292 [window setLevel:NSNormalWindowLevel]; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5293 [window setHidesOnDeactivate:NO]; |
218d676baf7f
Implemented dw_window_reparent using the method used for MDI simulation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
685
diff
changeset
|
5294 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5295 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5296 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5297 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5298 * Sets the font used by a specified window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5299 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5300 * handle: The window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5301 * fontname: Name and size of the font in the form "size.fontname" |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5302 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5303 int API dw_window_set_font(HWND handle, char *fontname) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5304 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5305 char *fontcopy = strdup(fontname); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5306 char *name = strchr(fontcopy, '.'); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5307 if(name) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5308 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5309 int size = atoi(fontcopy); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5310 *name = 0; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5311 name++; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5312 NSFont *font = [NSFont fontWithName:[ NSString stringWithUTF8String:name ] size:(float)size]; |
673
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5313 if(font) |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5314 { |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5315 id object = handle; |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5316 if([object window]) |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5317 { |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5318 [object lockFocus]; |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5319 [font set]; |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5320 [object unlockFocus]; |
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5321 } |
674
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
5322 if([object isMemberOfClass:[NSControl class]]) |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
5323 { |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
5324 [object setFont:font]; |
78f9aa6d6d89
Fixes or fonts and loading images from files. Added Mac specific settings to dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
673
diff
changeset
|
5325 } |
673
6d0f0dc7ff7c
Some minor font fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
672
diff
changeset
|
5326 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5327 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5328 free(fontcopy); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5329 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5330 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5331 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5332 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5333 * Destroys a window and all of it's children. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5334 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5335 * handle: The window handle to destroy. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5336 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5337 int API dw_window_destroy(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5338 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5339 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5340 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5341 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5342 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5343 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5344 [window close]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5345 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5346 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5347 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5348 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5349 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5350 * Gets the text used for a given window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5351 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5352 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5353 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5354 * text: The text associsated with a given window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5355 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5356 char * API dw_window_get_text(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5357 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5358 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5359 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5360 if([ object isKindOfClass:[ NSControl class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5361 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5362 NSControl *control = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5363 NSString *nsstr = [ control stringValue]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5364 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5365 return strdup([ nsstr UTF8String ]); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5366 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5367 else if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5368 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5369 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5370 NSString *nsstr = [ window title]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5371 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5372 return strdup([ nsstr UTF8String ]); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5373 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5374 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5375 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5376 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5377 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5378 * Sets the text used for a given window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5379 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5380 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5381 * text: The text associsated with a given window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5382 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5383 void API dw_window_set_text(HWND handle, char *text) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5384 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5385 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5386 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5387 if([ object isKindOfClass:[ NSControl class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5388 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5389 NSControl *control = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5390 [control setStringValue:[ NSString stringWithUTF8String:text ]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5391 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5392 else if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5393 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5394 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5395 [window setTitle:[ NSString stringWithUTF8String:text ]]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5396 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5397 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5398 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5399 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5400 * Disables given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5401 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5402 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5403 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5404 void API dw_window_disable(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5405 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5406 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5407 if([ object isKindOfClass:[ NSControl class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5408 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5409 NSControl *control = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5410 [control setEnabled:NO]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5411 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5412 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5413 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5414 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5415 * Enables given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5416 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5417 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5418 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5419 void API dw_window_enable(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5420 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5421 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5422 if([ object isKindOfClass:[ NSControl class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5423 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5424 NSControl *control = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5425 [control setEnabled:YES]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5426 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5427 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5428 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5429 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5430 * Sets the bitmap used for a given static window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5431 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5432 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5433 * id: An ID to be used to specify the icon, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5434 * (pass 0 if you use the filename param) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5435 * filename: a path to a file (Bitmap on OS/2 or |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5436 * Windows and a pixmap on Unix, pass |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5437 * NULL if you use the id param) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5438 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5439 void API dw_window_set_bitmap_from_data(HWND handle, unsigned long cid, char *data, int len) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5440 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5441 NSObject *object = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5442 if([ object isKindOfClass:[ NSImageView class ] ]) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5443 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5444 NSImageView *iv = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5445 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5446 NSImage *pixmap = [[NSImage alloc] initWithData:thisdata]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5447 |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5448 if(pixmap) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5449 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5450 [iv setImage:pixmap]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5451 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5452 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5453 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5454 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5455 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5456 * Sets the bitmap used for a given static window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5457 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5458 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5459 * id: An ID to be used to specify the icon, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5460 * (pass 0 if you use the filename param) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5461 * filename: a path to a file (Bitmap on OS/2 or |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5462 * Windows and a pixmap on Unix, pass |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5463 * NULL if you use the id param) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5464 */ |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5465 void API dw_window_set_bitmap(HWND handle, unsigned long resid, char *filename) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5466 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5467 NSObject *object = handle; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5468 if([ object isKindOfClass:[ NSImageView class ] ]) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5469 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5470 NSImageView *iv = handle; |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5471 NSImage *bitmap = NULL; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5472 |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5473 if(filename) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5474 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5475 bitmap = [[NSImage alloc] initWithContentsOfFile:[ NSString stringWithUTF8String:filename ]]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5476 } |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5477 else if(resid > 0 && resid < 65536) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5478 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5479 bitmap = dw_icon_load(0, resid); |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5480 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5481 |
675
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5482 if(bitmap) |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5483 { |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5484 [iv setImage:bitmap]; |
48f8efba898f
Filled in most of the remaining MLE and container functions... the remaining few
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
674
diff
changeset
|
5485 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5486 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5487 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5488 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5489 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5490 * Sets the icon used for a given window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5491 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5492 * handle: Handle to the window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5493 * id: An ID to be used to specify the icon. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5494 */ |
672
388f2a48aaae
Missed one function to typedef. Fixed errors in the test program and switched to using
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
671
diff
changeset
|
5495 void API dw_window_set_icon(HWND handle, HICN icon) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5496 { |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
5497 /* This isn't needed, it is loaded from the bundle */ |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5498 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5499 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5500 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5501 * Gets the child window handle with specified ID. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5502 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5503 * handle: Handle to the parent window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5504 * id: Integer ID of the child. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5505 */ |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5506 HWND API dw_window_from_id(HWND handle, int cid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5507 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5508 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5509 NSView *view = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5510 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5511 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5512 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5513 view = [window contentView]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5514 } |
685
314a12dccd20
Cleanups for conflicts with "id" which is a keyword in Objective-C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
684
diff
changeset
|
5515 return [view viewWithTag:cid]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5516 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5517 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5518 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5519 * Minimizes or Iconifies a top-level window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5520 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5521 * handle: The window handle to minimize. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5522 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5523 int API dw_window_minimize(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5524 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5525 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5526 [window miniaturize:nil]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5527 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5528 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5529 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5530 /* Causes entire window to be invalidated and redrawn. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5531 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5532 * handle: Toplevel window handle to be redrawn. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5533 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5534 void API dw_window_redraw(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5535 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5536 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5537 [window flushWindow]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5538 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5539 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5540 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5541 * Makes the window topmost. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5542 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5543 * handle: The window handle to make topmost. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5544 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5545 int API dw_window_raise(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5546 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5547 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5548 [window orderFront:nil]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5549 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5550 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5551 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5552 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5553 * Makes the window bottommost. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5554 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5555 * handle: The window handle to make bottommost. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5556 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5557 int API dw_window_lower(HWND handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5558 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5559 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5560 [window orderBack:nil]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5561 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5562 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5563 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5564 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5565 * Sets the size of a given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5566 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5567 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5568 * width: New width in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5569 * height: New height in pixels. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5570 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5571 void API dw_window_set_size(HWND handle, ULONG width, ULONG height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5572 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5573 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5574 NSSize size; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5575 size.width = width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5576 size.height = height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5577 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5578 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5579 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5580 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5581 [window setContentSize:size]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5582 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5583 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5584 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5585 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5586 * Sets the position of a given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5587 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5588 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5589 * x: X location from the bottom left. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5590 * y: Y location from the bottom left. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5591 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5592 void API dw_window_set_pos(HWND handle, LONG x, LONG y) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5593 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5594 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5595 NSPoint point; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5596 point.x = x; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5597 point.y = y; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5598 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5599 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5600 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5601 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5602 [window setFrameOrigin:point]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5603 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5604 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5605 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5606 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5607 * Sets the position and size of a given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5608 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5609 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5610 * x: X location from the bottom left. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5611 * y: Y location from the bottom left. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5612 * width: Width of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5613 * height: Height of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5614 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5615 void API dw_window_set_pos_size(HWND handle, LONG x, LONG y, ULONG width, ULONG height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5616 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5617 dw_window_set_pos(handle, x, y); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5618 dw_window_set_size(handle, width, height); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5619 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5620 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5621 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5622 * Gets the position and size of a given window (widget). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5623 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5624 * handle: Window (widget) handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5625 * x: X location from the bottom left. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5626 * y: Y location from the bottom left. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5627 * width: Width of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5628 * height: Height of the widget. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5629 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5630 void API dw_window_get_pos_size(HWND handle, LONG *x, LONG *y, ULONG *width, ULONG *height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5631 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5632 NSObject *object = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5633 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5634 if([ object isKindOfClass:[ NSWindow class ] ]) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5635 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5636 NSWindow *window = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5637 NSRect rect = [window frame]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5638 if(x) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5639 *x = rect.origin.x; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5640 if(y) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5641 *y = rect.origin.y; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5642 if(width) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5643 *width = rect.size.width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5644 if(height) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5645 *height = rect.size.height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5646 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5647 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5648 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5649 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5650 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5651 * Returns the width of the screen. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5652 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5653 int API dw_screen_width(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5654 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5655 NSRect screenRect = [[NSScreen mainScreen] frame]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5656 return screenRect.size.width; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5657 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5658 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5659 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5660 * Returns the height of the screen. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5661 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5662 int API dw_screen_height(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5663 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5664 NSRect screenRect = [[NSScreen mainScreen] frame]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5665 return screenRect.size.height; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5666 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5667 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5668 /* This should return the current color depth */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5669 unsigned long API dw_color_depth_get(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5670 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5671 NSWindowDepth screenDepth = [[NSScreen mainScreen] depth]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5672 return NSBitsPerPixelFromDepth(screenDepth); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5673 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5674 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5675 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5676 * Returns some information about the current operating environment. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5677 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5678 * env: Pointer to a DWEnv struct. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5679 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5680 void dw_environment_query(DWEnv *env) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5681 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5682 struct utsname name; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5683 char tempbuf[100]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5684 int len, z; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5685 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5686 uname(&name); |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5687 strcpy(env->osName, "MacOS"); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5688 strcpy(tempbuf, name.release); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5689 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5690 env->MajorBuild = env->MinorBuild = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5691 |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
5692 len = (int)strlen(tempbuf); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5693 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5694 strcpy(env->buildDate, __DATE__); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5695 strcpy(env->buildTime, __TIME__); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5696 env->DWMajorVersion = DW_MAJOR_VERSION; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5697 env->DWMinorVersion = DW_MINOR_VERSION; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5698 env->DWSubVersion = DW_SUB_VERSION; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5699 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5700 for(z=1;z<len;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5701 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5702 if(tempbuf[z] == '.') |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5703 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5704 int ver = atoi(tempbuf); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5705 tempbuf[z] = '\0'; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5706 if(ver > 4) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5707 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5708 env->MajorVersion = 10; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5709 env->MinorVersion = ver - 4; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5710 env->MajorBuild = atoi(&tempbuf[z+1]); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5711 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5712 else |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5713 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5714 env->MajorVersion = ver; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5715 env->MinorVersion = atoi(&tempbuf[z+1]); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5716 } |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5717 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5718 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5719 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5720 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5721 env->MajorVersion = atoi(tempbuf); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5722 env->MinorVersion = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5723 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5724 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5725 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5726 * Emits a beep. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5727 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5728 * freq: Frequency. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5729 * dur: Duration. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5730 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5731 void API dw_beep(int freq, int dur) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5732 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5733 NSBeep(); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5734 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5735 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5736 /* Call this after drawing to the screen to make sure |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5737 * anything you have drawn is visible. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5738 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5739 void API dw_flush(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5740 { |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
5741 /* This may need to be thread specific */ |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
5742 if(_DWLastDrawable) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
5743 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
5744 id object = _DWLastDrawable; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
5745 NSWindow *window = [object window]; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
5746 [window flushWindow]; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
5747 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5748 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5749 |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5750 /* Functions for managing the user data lists that are associated with |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5751 * a given window handle. Used in dw_window_set_data() and |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5752 * dw_window_get_data(). |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5753 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5754 UserData *_find_userdata(UserData **root, char *varname) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5755 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5756 UserData *tmp = *root; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5757 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5758 while(tmp) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5759 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5760 if(strcasecmp(tmp->varname, varname) == 0) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5761 return tmp; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5762 tmp = tmp->next; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5763 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5764 return NULL; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5765 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5766 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5767 int _new_userdata(UserData **root, char *varname, void *data) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5768 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5769 UserData *new = _find_userdata(root, varname); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5770 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5771 if(new) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5772 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5773 new->data = data; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5774 return TRUE; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5775 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5776 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5777 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5778 new = malloc(sizeof(UserData)); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5779 if(new) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5780 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5781 new->varname = strdup(varname); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5782 new->data = data; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5783 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5784 new->next = NULL; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5785 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5786 if (!*root) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5787 *root = new; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5788 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5789 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5790 UserData *prev = NULL, *tmp = *root; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5791 while(tmp) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5792 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5793 prev = tmp; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5794 tmp = tmp->next; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5795 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5796 if(prev) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5797 prev->next = new; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5798 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5799 *root = new; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5800 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5801 return TRUE; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5802 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5803 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5804 return FALSE; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5805 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5806 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5807 int _remove_userdata(UserData **root, char *varname, int all) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5808 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5809 UserData *prev = NULL, *tmp = *root; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5810 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5811 while(tmp) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5812 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5813 if(all || strcasecmp(tmp->varname, varname) == 0) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5814 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5815 if(!prev) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5816 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5817 *root = tmp->next; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5818 free(tmp->varname); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5819 free(tmp); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5820 if(!all) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5821 return 0; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5822 tmp = *root; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5823 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5824 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5825 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5826 /* If all is true we should |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5827 * never get here. |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5828 */ |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5829 prev->next = tmp->next; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5830 free(tmp->varname); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5831 free(tmp); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5832 return 0; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5833 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5834 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5835 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5836 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5837 prev = tmp; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5838 tmp = tmp->next; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5839 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5840 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5841 return 0; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5842 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5843 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5844 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5845 * Add a named user data item to a window handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5846 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5847 * window: Window handle of signal to be called back. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5848 * dataname: A string pointer identifying which signal to be hooked. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5849 * data: User data to be passed to the handler function. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5850 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5851 void dw_window_set_data(HWND window, char *dataname, void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5852 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5853 id object = window; |
681
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
5854 if([object isMemberOfClass:[NSWindow class]]) |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
5855 { |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
5856 NSWindow *win = window; |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
5857 object = [win contentView]; |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
5858 } |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
5859 else if([object isMemberOfClass:[NSScrollView class]]) |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5860 { |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5861 NSScrollView *sv = window; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5862 object = [sv documentView]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5863 } |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5864 WindowData *blah = (WindowData *)[object userdata]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5865 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5866 if(!blah) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5867 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5868 if(!dataname) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5869 return; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5870 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5871 blah = calloc(1, sizeof(WindowData)); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5872 [object setUserdata:blah]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5873 } |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5874 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5875 if(data) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5876 _new_userdata(&(blah->root), dataname, data); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5877 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5878 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5879 if(dataname) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5880 _remove_userdata(&(blah->root), dataname, FALSE); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5881 else |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5882 _remove_userdata(&(blah->root), NULL, TRUE); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5883 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5884 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5885 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5886 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5887 * Gets a named user data item to a window handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5888 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5889 * window: Window handle of signal to be called back. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5890 * dataname: A string pointer identifying which signal to be hooked. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5891 * data: User data to be passed to the handler function. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5892 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5893 void *dw_window_get_data(HWND window, char *dataname) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5894 { |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5895 id object = window; |
681
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
5896 if([object isMemberOfClass:[NSWindow class]]) |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
5897 { |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
5898 NSWindow *win = window; |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
5899 object = [win contentView]; |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
5900 } |
5fe12469c1fb
Fix for dw_window_set/get_data() on a top-level window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
680
diff
changeset
|
5901 else if([object isMemberOfClass:[NSScrollView class]]) |
676
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5902 { |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5903 NSScrollView *sv = window; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5904 object = [sv documentView]; |
9861d264925d
MLE was missing the scrollbar. Fixes for getting and setting the position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
675
diff
changeset
|
5905 } |
651
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5906 WindowData *blah = (WindowData *)[object userdata]; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5907 |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5908 if(blah && blah->root && dataname) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5909 { |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5910 UserData *ud = _find_userdata(&(blah->root), dataname); |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5911 if(ud) |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5912 return ud->data; |
270580896dac
Filling in more class types.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
650
diff
changeset
|
5913 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5914 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5915 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5916 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5917 #define DW_TIMER_MAX 64 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5918 NSTimer *DWTimers[DW_TIMER_MAX]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5919 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5920 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5921 * Add a callback to a timer event. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5922 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5923 * interval: Milliseconds to delay between calls. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5924 * sigfunc: The pointer to the function to be used as the callback. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5925 * data: User data to be passed to the handler function. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5926 * Returns: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5927 * Timer ID for use with dw_timer_disconnect(), 0 on error. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5928 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5929 int API dw_timer_connect(int interval, void *sigfunc, void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5930 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5931 int z; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5932 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5933 for(z=0;z<DW_TIMER_MAX;z++) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5934 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5935 if(!DWTimers[z]) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5936 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5937 break; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5938 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5939 } |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5940 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5941 if(sigfunc && !DWTimers[z]) |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5942 { |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5943 NSTimeInterval seconds = (double)interval / 1000.0; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5944 NSTimer *thistimer = DWTimers[z] = [NSTimer timerWithTimeInterval:seconds target:DWHandler selector:@selector(runTimer:) userInfo:nil repeats:YES]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5945 _new_signal(0, thistimer, z+1, sigfunc, data); |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5946 return z+1; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5947 } |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5948 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5949 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5950 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5951 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5952 * Removes timer callback. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5953 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5954 * id: Timer ID returned by dw_timer_connect(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5955 */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5956 void API dw_timer_disconnect(int timerid) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5957 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5958 SignalHandler *prev = NULL, *tmp = Root; |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5959 NSTimer *thistimer; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5960 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5961 /* 0 is an invalid timer ID */ |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5962 if(timerid < 1 || !DWTimers[timerid-1]) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5963 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5964 |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5965 thistimer = DWTimers[timerid-1]; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5966 DWTimers[timerid-1] = nil; |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5967 |
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5968 [thistimer release]; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5969 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5970 while(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5971 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
5972 if(tmp->id == (timerid-1) && tmp->window == thistimer) |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5973 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5974 if(prev) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5975 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5976 prev->next = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5977 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5978 tmp = prev->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5979 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5980 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5981 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5982 Root = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5983 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5984 tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5985 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5986 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5987 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5988 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5989 prev = tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5990 tmp = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5991 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5992 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5993 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5994 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5995 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5996 * Add a callback to a window event. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5997 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5998 * window: Window handle of signal to be called back. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5999 * signame: A string pointer identifying which signal to be hooked. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6000 * sigfunc: The pointer to the function to be used as the callback. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6001 * data: User data to be passed to the handler function. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6002 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6003 void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6004 { |
657
f31a47b055f8
Work (unfinished) on container objects.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
656
diff
changeset
|
6005 ULONG message = 0, msgid = 0; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6006 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6007 if(window && signame && sigfunc) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6008 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6009 if((message = _findsigmessage(signame)) != 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6010 { |
665
e6bec2290f3f
Fixing warnings with Xcode 4 and switched to manual releasing in the draw functions to stop leaking.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
664
diff
changeset
|
6011 _new_signal(message, window, (int)msgid, sigfunc, data); |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6012 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6013 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6014 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6015 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6016 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6017 * Removes callbacks for a given window with given name. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6018 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6019 * window: Window handle of callback to be removed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6020 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6021 void API dw_signal_disconnect_by_name(HWND window, char *signame) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6022 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6023 SignalHandler *prev = NULL, *tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6024 ULONG message; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6025 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6026 if(!window || !signame || (message = _findsigmessage(signame)) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6027 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6028 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6029 while(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6030 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6031 if(tmp->window == window && tmp->message == message) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6032 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6033 if(prev) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6034 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6035 prev->next = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6036 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6037 tmp = prev->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6038 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6039 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6040 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6041 Root = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6042 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6043 tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6044 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6045 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6046 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6047 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6048 prev = tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6049 tmp = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6050 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6051 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6052 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6053 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6054 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6055 * Removes all callbacks for a given window. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6056 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6057 * window: Window handle of callback to be removed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6058 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6059 void API dw_signal_disconnect_by_window(HWND window) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6060 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6061 SignalHandler *prev = NULL, *tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6062 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6063 while(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6064 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6065 if(tmp->window == window) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6066 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6067 if(prev) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6068 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6069 prev->next = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6070 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6071 tmp = prev->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6072 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6073 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6074 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6075 Root = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6076 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6077 tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6078 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6079 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6080 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6081 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6082 prev = tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6083 tmp = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6084 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6085 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6086 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6087 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6088 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6089 * Removes all callbacks for a given window with specified data. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6090 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6091 * window: Window handle of callback to be removed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6092 * data: Pointer to the data to be compared against. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6093 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6094 void API dw_signal_disconnect_by_data(HWND window, void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6095 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6096 SignalHandler *prev = NULL, *tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6097 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6098 while(tmp) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6099 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6100 if(tmp->window == window && tmp->data == data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6101 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6102 if(prev) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6103 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6104 prev->next = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6105 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6106 tmp = prev->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6107 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6108 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6109 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6110 Root = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6111 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6112 tmp = Root; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6113 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6114 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6115 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6116 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6117 prev = tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6118 tmp = tmp->next; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6119 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6120 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6121 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6122 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6123 void _my_strlwr(char *buf) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6124 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6125 int z, len = strlen(buf); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6126 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6127 for(z=0;z<len;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6128 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6129 if(buf[z] >= 'A' && buf[z] <= 'Z') |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6130 buf[z] -= 'A' - 'a'; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6131 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6132 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6133 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6134 /* Open a shared library and return a handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6135 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6136 * name: Base name of the shared library. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6137 * handle: Pointer to a module handle, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6138 * will be filled in with the handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6139 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6140 int dw_module_load(char *name, HMOD *handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6141 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6142 int len; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6143 char *newname; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6144 char errorbuf[1024]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6145 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6146 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6147 if(!handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6148 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6149 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6150 if((len = strlen(name)) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6151 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6152 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6153 /* Lenth + "lib" + ".dylib" + NULL */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6154 newname = malloc(len + 10); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6155 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6156 if(!newname) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6157 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6158 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6159 sprintf(newname, "lib%s.dylib", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6160 _my_strlwr(newname); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6161 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6162 *handle = dlopen(newname, RTLD_NOW); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6163 if(*handle == NULL) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6164 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6165 strncpy(errorbuf, dlerror(), 1024); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6166 printf("%s\n", errorbuf); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6167 sprintf(newname, "lib%s.dylib", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6168 *handle = dlopen(newname, RTLD_NOW); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6169 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6170 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6171 free(newname); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6172 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6173 return (NULL == *handle) ? -1 : 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6174 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6175 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6176 /* Queries the address of a symbol within open handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6177 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6178 * handle: Module handle returned by dw_module_load() |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6179 * name: Name of the symbol you want the address of. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6180 * func: A pointer to a function pointer, to obtain |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6181 * the address. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6182 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6183 int dw_module_symbol(HMOD handle, char *name, void**func) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6184 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6185 if(!func || !name) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6186 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6187 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6188 if(strlen(name) == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6189 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6190 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6191 *func = (void*)dlsym(handle, name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6192 return (NULL == *func); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6193 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6194 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6195 /* Frees the shared library previously opened. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6196 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6197 * handle: Module handle returned by dw_module_load() |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6198 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6199 int dw_module_close(HMOD handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6200 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6201 if(handle) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6202 return dlclose(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6203 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6204 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6205 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6206 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6207 * Returns the handle to an unnamed mutex semaphore. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6208 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6209 HMTX dw_mutex_new(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6210 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6211 HMTX mutex = malloc(sizeof(pthread_mutex_t)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6212 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6213 pthread_mutex_init(mutex, NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6214 return mutex; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6215 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6216 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6217 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6218 * Closes a semaphore created by dw_mutex_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6219 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6220 * mutex: The handle to the mutex returned by dw_mutex_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6221 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6222 void dw_mutex_close(HMTX mutex) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6223 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6224 if(mutex) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6225 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6226 pthread_mutex_destroy(mutex); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6227 free(mutex); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6228 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6229 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6230 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6231 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6232 * Tries to gain access to the semaphore, if it can't it blocks. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6233 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6234 * mutex: The handle to the mutex returned by dw_mutex_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6235 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6236 void dw_mutex_lock(HMTX mutex) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6237 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6238 pthread_mutex_lock(mutex); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6239 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6240 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6241 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6242 * Reliquishes the access to the semaphore. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6243 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6244 * mutex: The handle to the mutex returned by dw_mutex_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6245 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6246 void dw_mutex_unlock(HMTX mutex) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6247 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6248 pthread_mutex_unlock(mutex); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6249 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6250 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6251 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6252 * Returns the handle to an unnamed event semaphore. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6253 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6254 HEV dw_event_new(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6255 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6256 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6257 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6258 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6259 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6260 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6261 /* We need to be careful here, mutexes on Linux are |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6262 * FAST by default but are error checking on other |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6263 * systems such as FreeBSD and OS/2, perhaps others. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6264 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6265 pthread_mutex_init (&(eve->mutex), NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6266 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6267 pthread_cond_init (&(eve->event), NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6268 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6269 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6270 eve->alive = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6271 eve->posted = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6272 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6273 return eve; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6274 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6275 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6276 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6277 * Resets a semaphore created by dw_event_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6278 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6279 * eve: The handle to the event returned by dw_event_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6280 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6281 int dw_event_reset (HEV eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6282 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6283 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6284 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6285 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6286 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6287 pthread_cond_broadcast (&(eve->event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6288 pthread_cond_init (&(eve->event), NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6289 eve->posted = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6290 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6291 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6292 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6293 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6294 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6295 * Posts a semaphore created by dw_event_new(). Causing all threads |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6296 * waiting on this event in dw_event_wait to continue. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6297 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6298 * eve: The handle to the event returned by dw_event_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6299 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6300 int dw_event_post (HEV eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6301 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6302 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6303 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6304 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6305 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6306 pthread_cond_broadcast (&(eve->event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6307 eve->posted = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6308 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6309 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6310 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6311 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6312 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6313 * Waits on a semaphore created by dw_event_new(), until the |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6314 * event gets posted or until the timeout expires. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6315 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6316 * eve: The handle to the event returned by dw_event_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6317 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6318 int dw_event_wait(HEV eve, unsigned long timeout) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6319 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6320 int rc; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6321 struct timeval now; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6322 struct timespec timeo; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6323 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6324 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6325 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6326 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6327 if(eve->posted) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6328 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6329 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6330 pthread_mutex_lock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6331 gettimeofday(&now, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6332 timeo.tv_sec = now.tv_sec + (timeout / 1000); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6333 timeo.tv_nsec = now.tv_usec * 1000; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6334 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6335 pthread_mutex_unlock (&(eve->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6336 if(!rc) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6337 return 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6338 if(rc == ETIMEDOUT) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6339 return -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6340 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6341 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6342 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6343 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6344 * Closes a semaphore created by dw_event_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6345 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6346 * eve: The handle to the event returned by dw_event_new(). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6347 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6348 int dw_event_close(HEV *eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6349 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6350 if(!eve || !(*eve)) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6351 return FALSE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6352 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6353 pthread_mutex_lock (&((*eve)->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6354 pthread_cond_destroy (&((*eve)->event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6355 pthread_mutex_unlock (&((*eve)->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6356 pthread_mutex_destroy (&((*eve)->mutex)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6357 free(*eve); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6358 *eve = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6359 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6360 return TRUE; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6361 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6362 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6363 struct _seminfo { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6364 int fd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6365 int waiting; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6366 }; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6367 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6368 static void _handle_sem(int *tmpsock) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6369 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6370 fd_set rd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6371 struct _seminfo *array = (struct _seminfo *)malloc(sizeof(struct _seminfo)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6372 int listenfd = tmpsock[0]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6373 int bytesread, connectcount = 1, maxfd, z, posted = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6374 char command; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6375 sigset_t mask; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6376 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6377 sigfillset(&mask); /* Mask all allowed signals */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6378 pthread_sigmask(SIG_BLOCK, &mask, NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6379 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6380 /* problems */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6381 if(tmpsock[1] == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6382 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6383 free(array); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6384 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6385 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6386 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6387 array[0].fd = tmpsock[1]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6388 array[0].waiting = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6389 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6390 /* Free the memory allocated in dw_named_event_new. */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6391 free(tmpsock); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6392 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6393 while(1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6394 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6395 FD_ZERO(&rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6396 FD_SET(listenfd, &rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6397 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6398 maxfd = listenfd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6399 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6400 /* Added any connections to the named event semaphore */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6401 for(z=0;z<connectcount;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6402 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6403 if(array[z].fd > maxfd) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6404 maxfd = array[z].fd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6405 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6406 FD_SET(array[z].fd, &rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6407 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6408 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6409 if(select(maxfd+1, &rd, NULL, NULL, NULL) == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6410 return; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6411 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6412 if(FD_ISSET(listenfd, &rd)) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6413 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6414 struct _seminfo *newarray; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6415 int newfd = accept(listenfd, 0, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6416 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6417 if(newfd > -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6418 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6419 /* Add new connections to the set */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6420 newarray = (struct _seminfo *)malloc(sizeof(struct _seminfo)*(connectcount+1)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6421 memcpy(newarray, array, sizeof(struct _seminfo)*(connectcount)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6422 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6423 newarray[connectcount].fd = newfd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6424 newarray[connectcount].waiting = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6425 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6426 connectcount++; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6427 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6428 /* Replace old array with new one */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6429 free(array); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6430 array = newarray; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6431 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6432 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6433 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6434 /* Handle any events posted to the semaphore */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6435 for(z=0;z<connectcount;z++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6436 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6437 if(FD_ISSET(array[z].fd, &rd)) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6438 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6439 if((bytesread = read(array[z].fd, &command, 1)) < 1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6440 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6441 struct _seminfo *newarray; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6442 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6443 /* Remove this connection from the set */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6444 newarray = (struct _seminfo *)malloc(sizeof(struct _seminfo)*(connectcount-1)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6445 if(!z) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6446 memcpy(newarray, &array[1], sizeof(struct _seminfo)*(connectcount-1)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6447 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6448 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6449 memcpy(newarray, array, sizeof(struct _seminfo)*z); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6450 if(z!=(connectcount-1)) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6451 memcpy(&newarray[z], &array[z+1], sizeof(struct _seminfo)*(z-connectcount-1)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6452 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6453 connectcount--; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6454 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6455 /* Replace old array with new one */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6456 free(array); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6457 array = newarray; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6458 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6459 else if(bytesread == 1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6460 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6461 switch(command) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6462 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6463 case 0: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6464 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6465 /* Reset */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6466 posted = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6467 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6468 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6469 case 1: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6470 /* Post */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6471 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6472 int s; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6473 char tmp = (char)0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6474 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6475 posted = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6476 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6477 for(s=0;s<connectcount;s++) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6478 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6479 /* The semaphore has been posted so |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6480 * we tell all the waiting threads to |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6481 * continue. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6482 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6483 if(array[s].waiting) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6484 write(array[s].fd, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6485 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6486 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6487 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6488 case 2: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6489 /* Wait */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6490 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6491 char tmp = (char)0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6492 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6493 array[z].waiting = 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6494 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6495 /* If we are posted exit immeditately */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6496 if(posted) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6497 write(array[z].fd, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6498 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6499 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6500 case 3: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6501 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6502 /* Done Waiting */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6503 array[z].waiting = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6504 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6505 break; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6506 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6507 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6508 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6509 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6510 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6511 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6512 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6513 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6514 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6515 /* Using domain sockets on unix for IPC */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6516 /* Create a named event semaphore which can be |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6517 * opened from other processes. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6518 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6519 * eve: Pointer to an event handle to receive handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6520 * name: Name given to semaphore which can be opened |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6521 * by other processes. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6522 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6523 HEV dw_named_event_new(char *name) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6524 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6525 struct sockaddr_un un; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6526 int ev, *tmpsock = (int *)malloc(sizeof(int)*2); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6527 HEV eve; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6528 DWTID dwthread; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6529 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6530 if(!tmpsock) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6531 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6532 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6533 eve = (HEV)malloc(sizeof(struct _dw_unix_event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6534 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6535 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6536 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6537 free(tmpsock); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6538 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6539 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6540 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6541 tmpsock[0] = socket(AF_UNIX, SOCK_STREAM, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6542 ev = socket(AF_UNIX, SOCK_STREAM, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6543 memset(&un, 0, sizeof(un)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6544 un.sun_family=AF_UNIX; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6545 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6546 strcpy(un.sun_path, "/tmp/.dw/"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6547 strcat(un.sun_path, name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6548 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6549 /* just to be safe, this should be changed |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6550 * to support multiple instances. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6551 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6552 remove(un.sun_path); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6553 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6554 bind(tmpsock[0], (struct sockaddr *)&un, sizeof(un)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6555 listen(tmpsock[0], 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6556 connect(ev, (struct sockaddr *)&un, sizeof(un)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6557 tmpsock[1] = accept(tmpsock[0], 0, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6558 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6559 if(tmpsock[0] < 0 || tmpsock[1] < 0 || ev < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6560 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6561 if(tmpsock[0] > -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6562 close(tmpsock[0]); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6563 if(tmpsock[1] > -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6564 close(tmpsock[1]); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6565 if(ev > -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6566 close(ev); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6567 free(tmpsock); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6568 free(eve); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6569 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6570 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6571 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6572 /* Create a thread to handle this event semaphore */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6573 pthread_create(&dwthread, NULL, (void *)_handle_sem, (void *)tmpsock); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6574 eve->alive = ev; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6575 return eve; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6576 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6577 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6578 /* Open an already existing named event semaphore. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6579 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6580 * eve: Pointer to an event handle to receive handle. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6581 * name: Name given to semaphore which can be opened |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6582 * by other processes. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6583 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6584 HEV dw_named_event_get(char *name) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6585 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6586 struct sockaddr_un un; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6587 HEV eve; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6588 int ev = socket(AF_UNIX, SOCK_STREAM, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6589 if(ev < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6590 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6591 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6592 eve = (HEV)malloc(sizeof(struct _dw_unix_event)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6593 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6594 if(!eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6595 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6596 close(ev); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6597 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6598 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6599 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6600 un.sun_family=AF_UNIX; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6601 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6602 strcpy(un.sun_path, "/tmp/.dw/"); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6603 strcat(un.sun_path, name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6604 connect(ev, (struct sockaddr *)&un, sizeof(un)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6605 eve->alive = ev; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6606 return eve; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6607 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6608 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6609 /* Resets the event semaphore so threads who call wait |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6610 * on this semaphore will block. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6611 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6612 * eve: Handle to the semaphore obtained by |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6613 * an open or create call. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6614 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6615 int dw_named_event_reset(HEV eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6616 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6617 /* signal reset */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6618 char tmp = (char)0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6619 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6620 if(!eve || eve->alive < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6621 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6622 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6623 if(write(eve->alive, &tmp, 1) == 1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6624 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6625 return 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6626 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6627 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6628 /* Sets the posted state of an event semaphore, any threads |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6629 * waiting on the semaphore will no longer block. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6630 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6631 * eve: Handle to the semaphore obtained by |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6632 * an open or create call. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6633 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6634 int dw_named_event_post(HEV eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6635 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6636 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6637 /* signal post */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6638 char tmp = (char)1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6639 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6640 if(!eve || eve->alive < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6641 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6642 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6643 if(write(eve->alive, &tmp, 1) == 1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6644 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6645 return 1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6646 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6647 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6648 /* Waits on the specified semaphore until it becomes |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6649 * posted, or returns immediately if it already is posted. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6650 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6651 * eve: Handle to the semaphore obtained by |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6652 * an open or create call. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6653 * timeout: Number of milliseconds before timing out |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6654 * or -1 if indefinite. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6655 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6656 int dw_named_event_wait(HEV eve, unsigned long timeout) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6657 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6658 fd_set rd; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6659 struct timeval tv, *useme; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6660 int retval = 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6661 char tmp; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6662 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6663 if(!eve || eve->alive < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6664 return DW_ERROR_NON_INIT; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6665 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6666 /* Set the timout or infinite */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6667 if(timeout == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6668 useme = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6669 else |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6670 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6671 tv.tv_sec = timeout / 1000; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6672 tv.tv_usec = timeout % 1000; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6673 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6674 useme = &tv; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6675 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6676 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6677 FD_ZERO(&rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6678 FD_SET(eve->alive, &rd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6679 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6680 /* Signal wait */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6681 tmp = (char)2; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6682 write(eve->alive, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6683 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6684 retval = select(eve->alive+1, &rd, NULL, NULL, useme); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6685 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6686 /* Signal done waiting. */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6687 tmp = (char)3; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6688 write(eve->alive, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6689 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6690 if(retval == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6691 return DW_ERROR_TIMEOUT; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6692 else if(retval == -1) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6693 return DW_ERROR_INTERRUPT; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6694 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6695 /* Clear the entry from the pipe so |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6696 * we don't loop endlessly. :) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6697 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6698 read(eve->alive, &tmp, 1); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6699 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6700 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6701 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6702 /* Release this semaphore, if there are no more open |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6703 * handles on this semaphore the semaphore will be destroyed. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6704 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6705 * eve: Handle to the semaphore obtained by |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6706 * an open or create call. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6707 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6708 int dw_named_event_close(HEV eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6709 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6710 /* Finally close the domain socket, |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6711 * cleanup will continue in _handle_sem. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6712 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6713 if(eve) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6714 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6715 close(eve->alive); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6716 free(eve); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6717 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6718 return 0; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6719 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6720 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6721 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6722 * Setup thread independent color sets. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6723 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6724 void _dwthreadstart(void *data) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6725 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6726 void (*threadfunc)(void *) = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6727 void **tmp = (void **)data; |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
6728 /* If we aren't using garbage collection we need autorelease pools */ |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
6729 #if !defined(GARBAGE_COLLECT) |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
6730 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
6731 #endif |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
6732 |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6733 threadfunc = (void (*)(void *))tmp[0]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6734 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6735 threadfunc(tmp[1]); |
671
c60a4f6cfae8
Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
670
diff
changeset
|
6736 /* Release the pool when we are done so we don't leak */ |
666
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
6737 #if !defined(GARBAGE_COLLECT) |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
6738 [pool release]; |
e426de6e6c7c
Changes to make the resize function more like on the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
665
diff
changeset
|
6739 #endif |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6740 free(tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6741 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6742 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6743 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6744 * Allocates a shared memory region with a name. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6745 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6746 * handle: A pointer to receive a SHM identifier. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6747 * dest: A pointer to a pointer to receive the memory address. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6748 * size: Size in bytes of the shared memory region to allocate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6749 * name: A string pointer to a unique memory name. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6750 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6751 HSHM dw_named_memory_new(void **dest, int size, char *name) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6752 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6753 char namebuf[1024]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6754 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6755 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6756 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6757 sprintf(namebuf, "/tmp/.dw/%s", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6758 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6759 if((handle->fd = open(namebuf, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6760 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6761 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6762 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6763 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6764 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6765 ftruncate(handle->fd, size); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6766 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6767 /* attach the shared memory segment to our process's address space. */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6768 *dest = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6769 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6770 if(*dest == MAP_FAILED) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6771 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6772 close(handle->fd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6773 *dest = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6774 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6775 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6776 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6777 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6778 handle->size = size; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6779 handle->sid = getsid(0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6780 handle->path = strdup(namebuf); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6781 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6782 return handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6783 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6784 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6785 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6786 * Aquires shared memory region with a name. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6787 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6788 * dest: A pointer to a pointer to receive the memory address. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6789 * size: Size in bytes of the shared memory region to requested. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6790 * name: A string pointer to a unique memory name. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6791 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6792 HSHM dw_named_memory_get(void **dest, int size, char *name) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6793 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6794 char namebuf[1024]; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6795 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm)); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6796 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6797 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6798 sprintf(namebuf, "/tmp/.dw/%s", name); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6799 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6800 if((handle->fd = open(namebuf, O_RDWR)) < 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6801 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6802 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6803 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6804 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6805 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6806 /* attach the shared memory segment to our process's address space. */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6807 *dest = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6808 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6809 if(*dest == MAP_FAILED) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6810 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6811 close(handle->fd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6812 *dest = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6813 free(handle); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6814 return NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6815 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6816 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6817 handle->size = size; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6818 handle->sid = -1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6819 handle->path = NULL; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6820 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6821 return handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6822 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6823 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6824 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6825 * Frees a shared memory region previously allocated. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6826 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6827 * handle: Handle obtained from DB_named_memory_allocate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6828 * ptr: The memory address aquired with DB_named_memory_allocate. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6829 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6830 int dw_named_memory_free(HSHM handle, void *ptr) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6831 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6832 struct _dw_unix_shm *h = handle; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6833 int rc = munmap(ptr, h->size); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6834 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6835 close(h->fd); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6836 if(h->path) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6837 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6838 /* Only remove the actual file if we are the |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6839 * creator of the file. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6840 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6841 if(h->sid != -1 && h->sid == getsid(0)) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6842 remove(h->path); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6843 free(h->path); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6844 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6845 return rc; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6846 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6847 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6848 * Creates a new thread with a starting point of func. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6849 * Parameters: |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6850 * func: Function which will be run in the new thread. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6851 * data: Parameter(s) passed to the function. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6852 * stack: Stack size of new thread (OS/2 and Windows only). |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6853 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6854 DWTID dw_thread_new(void *func, void *data, int stack) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6855 { |
660
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
6856 DWTID thread; |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
6857 void **tmp = malloc(sizeof(void *) * 2); |
2784e7ee8bcb
Fixes for pixmaps and drawing to the screen.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
659
diff
changeset
|
6858 int rc; |
650
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6859 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6860 tmp[0] = func; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6861 tmp[1] = data; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6862 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6863 rc = pthread_create(&thread, NULL, (void *)_dwthreadstart, (void *)tmp); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6864 if(rc == 0) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6865 return thread; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6866 return (DWTID)-1; |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6867 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6868 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6869 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6870 * Ends execution of current thread immediately. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6871 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6872 void dw_thread_end(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6873 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6874 pthread_exit(NULL); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6875 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6876 |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6877 /* |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6878 * Returns the current thread's ID. |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6879 */ |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6880 DWTID dw_thread_id(void) |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6881 { |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6882 return (DWTID)pthread_self(); |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6883 } |
55b677d460e9
Added initial support for a MacOS Cocoa port.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6884 |
661
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6885 /* |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6886 * Execute and external program in a seperate session. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6887 * Parameters: |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6888 * program: Program name with optional path. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6889 * type: Either DW_EXEC_CON or DW_EXEC_GUI. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6890 * params: An array of pointers to string arguements. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6891 * Returns: |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6892 * -1 on error. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6893 */ |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6894 int dw_exec(char *program, int type, char **params) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6895 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6896 int ret = -1; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6897 |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6898 if((ret = fork()) == 0) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6899 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6900 int i; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6901 |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6902 for (i = 3; i < 256; i++) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6903 close(i); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6904 setsid(); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6905 if(type == DW_EXEC_GUI) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6906 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6907 execvp(program, params); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6908 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6909 else if(type == DW_EXEC_CON) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6910 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6911 char **tmpargs; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6912 |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6913 if(!params) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6914 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6915 tmpargs = malloc(sizeof(char *)); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6916 tmpargs[0] = NULL; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6917 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6918 else |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6919 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6920 int z = 0; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6921 |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6922 while(params[z]) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6923 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6924 z++; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6925 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6926 tmpargs = malloc(sizeof(char *)*(z+3)); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6927 z=0; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6928 tmpargs[0] = "xterm"; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6929 tmpargs[1] = "-e"; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6930 while(params[z]) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6931 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6932 tmpargs[z+2] = params[z]; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6933 z++; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6934 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6935 tmpargs[z+2] = NULL; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6936 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6937 execvp("xterm", tmpargs); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6938 free(tmpargs); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6939 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6940 /* If we got here exec failed */ |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6941 _exit(-1); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6942 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6943 return ret; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6944 } |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6945 |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6946 /* |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6947 * Loads a web browser pointed at the given URL. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6948 * Parameters: |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6949 * url: Uniform resource locator. |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6950 */ |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6951 int dw_browse(char *url) |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6952 { |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6953 /* Is there a way to find the webbrowser in Unix? */ |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6954 char *execargs[3], *browser = "netscape", *tmp; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6955 |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6956 tmp = getenv( "DW_BROWSER" ); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6957 if(tmp) browser = tmp; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6958 execargs[0] = browser; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6959 execargs[1] = url; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6960 execargs[2] = NULL; |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6961 |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6962 return dw_exec(browser, DW_EXEC_GUI, execargs); |
eee90a788876
Added missing functions needed to build HandyFTP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
660
diff
changeset
|
6963 } |