Mercurial > dwindows
comparison mac/dw.m @ 652:ef0f484c6c4b
Added even more... including first signal handling and notebooks among other controls.
Temporarily disabled garbage collection because it was causing crashes.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 23 Feb 2011 11:41:47 +0000 |
parents | 270580896dac |
children | 36c6669422d2 |
comparison
equal
deleted
inserted
replaced
651:270580896dac | 652:ef0f484c6c4b |
---|---|
15 #include <sys/un.h> | 15 #include <sys/un.h> |
16 #include <sys/mman.h> | 16 #include <sys/mman.h> |
17 #include <sys/time.h> | 17 #include <sys/time.h> |
18 #include <sys/stat.h> | 18 #include <sys/stat.h> |
19 | 19 |
20 typedef struct _sighandler | |
21 { | |
22 struct _sighandler *next; | |
23 ULONG message; | |
24 HWND window; | |
25 int id; | |
26 void *signalfunction; | |
27 void *data; | |
28 | |
29 } SignalHandler; | |
30 | |
31 SignalHandler *Root = NULL; | |
32 | |
20 static void _do_resize(Box *thisbox, int x, int y); | 33 static void _do_resize(Box *thisbox, int x, int y); |
34 SignalHandler *_get_handler(HWND window, int messageid) | |
35 { | |
36 SignalHandler *tmp = Root; | |
37 | |
38 /* Find any callbacks for this function */ | |
39 while(tmp) | |
40 { | |
41 if(tmp->message == messageid && window == tmp->window) | |
42 { | |
43 return tmp; | |
44 } | |
45 tmp = tmp->next; | |
46 } | |
47 return NULL; | |
48 } | |
49 | |
50 int _event_handler(id object, NSEvent *event, int message) | |
51 { | |
52 SignalHandler *handler = _get_handler(object, message); | |
53 NSLog(@"Event handler\n"); | |
54 | |
55 if(handler) | |
56 { | |
57 if(message == 3 || message == 4) | |
58 { | |
59 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; | |
60 int flags = [object pressedMouseButtons]; | |
61 NSPoint point = [object mouseLocation]; | |
62 int button = 0; | |
63 char *which = "pressed"; | |
64 | |
65 if(message == 4) | |
66 { | |
67 which = "released"; | |
68 } | |
69 | |
70 if(flags & 1) | |
71 { | |
72 button = 1; | |
73 } | |
74 else if(flags & (1 << 1)) | |
75 { | |
76 button = 2; | |
77 } | |
78 else if(flags & (1 << 2)) | |
79 { | |
80 button = 3; | |
81 } | |
82 | |
83 NSLog(@"Button %s x:%d y:%d button:%d\n", which, (int)point.x, (int)point.y, (int)button); | |
84 return buttonfunc(object, point.x, point.y, button, handler->data); | |
85 } | |
86 else if(message == 7) | |
87 { | |
88 DWExpose exp; | |
89 int (* API exposefunc)(HWND, DWExpose *, void *) = (int (* API)(HWND, DWExpose *, void *))handler->signalfunction; | |
90 NSRect rect = [object frame]; | |
91 | |
92 exp.x = rect.origin.x; | |
93 exp.y = rect.origin.y; | |
94 exp.width = rect.size.width; | |
95 exp.height = rect.size.height; | |
96 return exposefunc(object, &exp, handler->data); | |
97 } | |
98 else if(message == 8) | |
99 { | |
100 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; | |
101 | |
102 NSLog(@"Clicked\n"); | |
103 return clickfunc(object, handler->data); | |
104 } | |
105 } | |
106 return 0; | |
107 } | |
21 | 108 |
22 /* So basically to implement our event handlers... | 109 /* So basically to implement our event handlers... |
23 * it looks like we are going to have to subclass | 110 * it looks like we are going to have to subclass |
24 * basically everything. Was hoping to add methods | 111 * basically everything. Was hoping to add methods |
25 * to the superclasses but it looks like you can | 112 * to the superclasses but it looks like you can |
37 -(Box)box; | 124 -(Box)box; |
38 -(void *)userdata; | 125 -(void *)userdata; |
39 -(void)setBox:(Box)input; | 126 -(void)setBox:(Box)input; |
40 -(void)setUserdata:(void *)input; | 127 -(void)setUserdata:(void *)input; |
41 -(void)drawRect:(NSRect)rect; | 128 -(void)drawRect:(NSRect)rect; |
129 -(BOOL)isFlipped; | |
130 -(void)mouseDown:(NSEvent *)theEvent; | |
131 -(void)mouseUp:(NSEvent *)theEvent; | |
42 @end | 132 @end |
43 | 133 |
44 @implementation DWBox | 134 @implementation DWBox |
45 -(Box)box { return box; } | 135 -(Box)box { return box; } |
46 -(void *)userdata { return userdata; } | 136 -(void *)userdata { return userdata; } |
52 { | 142 { |
53 [bgcolor set]; | 143 [bgcolor set]; |
54 NSRectFill( [self bounds] ); | 144 NSRectFill( [self bounds] ); |
55 } | 145 } |
56 } | 146 } |
147 -(BOOL)isFlipped { return YES; } | |
148 -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); } | |
149 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); } | |
57 @end | 150 @end |
58 | 151 |
59 /* Subclass for a top-level window */ | 152 /* Subclass for a top-level window */ |
60 @interface DWView : DWBox { } | 153 @interface DWView : DWBox { } |
61 @end | 154 @end |
86 { | 179 { |
87 void *userdata; | 180 void *userdata; |
88 } | 181 } |
89 -(void *)userdata; | 182 -(void *)userdata; |
90 -(void)setUserdata:(void *)input; | 183 -(void)setUserdata:(void *)input; |
184 -(void)buttonClicked:(id)sender; | |
91 @end | 185 @end |
92 | 186 |
93 @implementation DWButton | 187 @implementation DWButton |
94 -(void *)userdata { return userdata; } | 188 -(void *)userdata { return userdata; } |
95 -(void)setUserdata:(void *)input { userdata = input; } | 189 -(void)setUserdata:(void *)input { userdata = input; } |
190 -(void)buttonClicked:(id)sender { _event_handler(self, nil, 8); } | |
96 @end | 191 @end |
97 | 192 |
98 /* Subclass for a progress type */ | 193 /* Subclass for a progress type */ |
99 @interface DWPercent : NSProgressIndicator | 194 @interface DWPercent : NSProgressIndicator |
100 { | 195 { |
135 @implementation DWEntryFieldPassword | 230 @implementation DWEntryFieldPassword |
136 -(void *)userdata { return userdata; } | 231 -(void *)userdata { return userdata; } |
137 -(void)setUserdata:(void *)input { userdata = input; } | 232 -(void)setUserdata:(void *)input { userdata = input; } |
138 @end | 233 @end |
139 | 234 |
235 /* Subclass for a Notebook control type */ | |
236 @interface DWNotebook : NSTabView | |
237 { | |
238 void *userdata; | |
239 int pageid; | |
240 } | |
241 -(void *)userdata; | |
242 -(void)setUserdata:(void *)input; | |
243 -(int)pageid; | |
244 -(void)setPageid:(int)input; | |
245 -(void)tabView:(NSTabView *)notebook didSelectTabViewItem:(NSTabViewItem *)notepage; | |
246 @end | |
247 | |
248 @implementation DWNotebook | |
249 -(void *)userdata { return userdata; } | |
250 -(void)setUserdata:(void *)input { userdata = input; } | |
251 -(int)pageid { return pageid; } | |
252 -(void)setPageid:(int)input { pageid = input; } | |
253 -(void)tabView:(NSTabView *)notebook didSelectTabViewItem:(NSTabViewItem *)notepage | |
254 { | |
255 id object = [notepage view]; | |
256 | |
257 if([object isMemberOfClass:[DWBox class]]) | |
258 { | |
259 DWBox *view = object; | |
260 Box box = [view box]; | |
261 NSSize size = [view frame].size; | |
262 _do_resize(&box, size.width, size.height); | |
263 } | |
264 } | |
265 @end | |
266 | |
267 /* Subclass for a Notebook page type */ | |
268 @interface DWNotebookPage : NSTabViewItem | |
269 { | |
270 void *userdata; | |
271 int pageid; | |
272 } | |
273 -(void *)userdata; | |
274 -(void)setUserdata:(void *)input; | |
275 -(int)pageid; | |
276 -(void)setPageid:(int)input; | |
277 @end | |
278 | |
279 @implementation DWNotebookPage | |
280 -(void *)userdata { return userdata; } | |
281 -(void)setUserdata:(void *)input { userdata = input; } | |
282 -(int)pageid { return pageid; } | |
283 -(void)setPageid:(int)input { pageid = input; } | |
284 @end | |
285 | |
286 /* Subclass for a color chooser type */ | |
287 @interface DWColorChoose : NSColorPanel | |
288 { | |
289 DWDialog *dialog; | |
290 } | |
291 -(void)changeColor:(id)sender; | |
292 -(void)setDialog:(DWDialog *)input; | |
293 @end | |
294 | |
295 @implementation DWColorChoose | |
296 - (void)changeColor:(id)sender | |
297 { | |
298 dw_dialog_dismiss(dialog, [self color]); | |
299 } | |
300 -(void)setDialog:(DWDialog *)input { dialog = input; } | |
301 @end | |
302 | |
303 /* Subclass for a splitbar type */ | |
304 @interface DWSplitBar : NSSplitView { } | |
305 - (void)splitViewDidResizeSubviews:(NSNotification *)aNotification; | |
306 @end | |
307 | |
308 @implementation DWSplitBar | |
309 - (void)splitViewDidResizeSubviews:(NSNotification *)aNotification | |
310 { | |
311 NSArray *views = [self subviews]; | |
312 id object; | |
313 | |
314 for(object in views) | |
315 { | |
316 if([object isMemberOfClass:[DWBox class]]) | |
317 { | |
318 DWBox *view = object; | |
319 Box box = [view box]; | |
320 NSSize size = [view frame].size; | |
321 _do_resize(&box, size.width, size.height); | |
322 } | |
323 } | |
324 } | |
325 @end | |
326 | |
140 NSApplication *DWApp; | 327 NSApplication *DWApp; |
141 NSRunLoop *DWRunLoop; | 328 NSRunLoop *DWRunLoop; |
142 | 329 #if !defined(GARBAGE_COLLECT) |
143 typedef struct _sighandler | 330 NSAutoreleasePool *pool; |
144 { | 331 #endif |
145 struct _sighandler *next; | |
146 ULONG message; | |
147 HWND window; | |
148 int id; | |
149 void *signalfunction; | |
150 void *data; | |
151 | |
152 } SignalHandler; | |
153 | |
154 SignalHandler *Root = NULL; | |
155 | 332 |
156 typedef struct | 333 typedef struct |
157 { | 334 { |
158 ULONG message; | 335 ULONG message; |
159 char name[30]; | 336 char name[30]; |
612 size.width = width + vectorx; | 789 size.width = width + vectorx; |
613 size.height = height + vectory; | 790 size.height = height + vectory; |
614 [handle setFrameOrigin:point]; | 791 [handle setFrameOrigin:point]; |
615 [handle setFrameSize:size]; | 792 [handle setFrameSize:size]; |
616 | 793 |
617 if(thisbox->type == DW_HORZ) | 794 /* Special handling for notebook controls */ |
795 if([handle isMemberOfClass:[DWNotebook class]]) | |
796 { | |
797 DWNotebook *notebook = (DWNotebook *)handle; | |
798 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem]; | |
799 DWBox *view = [notepage view]; | |
800 | |
801 if(view != nil) | |
802 { | |
803 Box box = [view box]; | |
804 NSSize size = [view frame].size; | |
805 _do_resize(&box, size.width, size.height); | |
806 } | |
807 } | |
808 if(thisbox->type == DW_HORZ) | |
618 currentx += width + vectorx + (pad * 2); | 809 currentx += width + vectorx + (pad * 2); |
619 if(thisbox->type == DW_VERT) | 810 if(thisbox->type == DW_VERT) |
620 currenty += height + vectory + (pad * 2); | 811 currenty += height + vectory + (pad * 2); |
621 } | 812 } |
622 } | 813 } |
687 { | 878 { |
688 /* Create the application object */ | 879 /* Create the application object */ |
689 DWApp = [NSApplication sharedApplication]; | 880 DWApp = [NSApplication sharedApplication]; |
690 /* Create a run loop for doing manual loops */ | 881 /* Create a run loop for doing manual loops */ |
691 DWRunLoop = [NSRunLoop alloc]; | 882 DWRunLoop = [NSRunLoop alloc]; |
883 #if !defined(GARBAGE_COLLECT) | |
884 pool = [[NSAutoreleasePool alloc] init]; | |
885 #endif | |
692 | 886 |
693 /* This only works on 10.6 so we have a backup method */ | 887 /* This only works on 10.6 so we have a backup method */ |
694 NSString * applicationName = [[NSRunningApplication currentApplication] localizedName]; | 888 NSString * applicationName = [[NSRunningApplication currentApplication] localizedName]; |
695 if(applicationName == nil) | 889 if(applicationName == nil) |
696 { | 890 { |
942 else | 1136 else |
943 { | 1137 { |
944 /* Create the File Save Dialog class. */ | 1138 /* Create the File Save Dialog class. */ |
945 NSSavePanel* saveDlg = [NSSavePanel savePanel]; | 1139 NSSavePanel* saveDlg = [NSSavePanel savePanel]; |
946 | 1140 |
947 /* Enable the selection of files in the dialog. */ | 1141 /* Enable the creation of directories in the dialog. */ |
948 [saveDlg setCanCreateDirectories:YES]; | 1142 [saveDlg setCanCreateDirectories:YES]; |
949 | 1143 |
950 /* Display the dialog. If the OK button was pressed, | 1144 /* Display the dialog. If the OK button was pressed, |
951 * process the files. | 1145 * process the files. |
952 */ | 1146 */ |
1002 * Parameters: | 1196 * Parameters: |
1003 * data: User defined data to be passed to functions. | 1197 * data: User defined data to be passed to functions. |
1004 */ | 1198 */ |
1005 DWDialog * API dw_dialog_new(void *data) | 1199 DWDialog * API dw_dialog_new(void *data) |
1006 { | 1200 { |
1007 NSLog(@"dw_dialog_new() unimplemented\n"); | 1201 DWDialog *tmp = malloc(sizeof(DWDialog)); |
1008 return NULL; | 1202 |
1203 if(tmp) | |
1204 { | |
1205 tmp->eve = dw_event_new(); | |
1206 dw_event_reset(tmp->eve); | |
1207 tmp->data = data; | |
1208 tmp->done = FALSE; | |
1209 tmp->result = NULL; | |
1210 } | |
1211 return tmp; | |
1009 } | 1212 } |
1010 | 1213 |
1011 /* | 1214 /* |
1012 * Accepts a dialog struct and returns the given data to the | 1215 * Accepts a dialog struct and returns the given data to the |
1013 * initial called of dw_dialog_wait(). | 1216 * initial called of dw_dialog_wait(). |
1015 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | 1218 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). |
1016 * result: Data to be returned by dw_dialog_wait(). | 1219 * result: Data to be returned by dw_dialog_wait(). |
1017 */ | 1220 */ |
1018 int API dw_dialog_dismiss(DWDialog *dialog, void *result) | 1221 int API dw_dialog_dismiss(DWDialog *dialog, void *result) |
1019 { | 1222 { |
1020 NSLog(@"dw_dialog_dismiss() unimplemented\n"); | 1223 dialog->result = result; |
1224 dw_event_post(dialog->eve); | |
1225 dialog->done = TRUE; | |
1021 return 0; | 1226 return 0; |
1022 } | 1227 } |
1023 | 1228 |
1024 /* | 1229 /* |
1025 * Accepts a dialog struct waits for dw_dialog_dismiss() to be | 1230 * Accepts a dialog struct waits for dw_dialog_dismiss() to be |
1027 * Parameters: | 1232 * Parameters: |
1028 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | 1233 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). |
1029 */ | 1234 */ |
1030 void * API dw_dialog_wait(DWDialog *dialog) | 1235 void * API dw_dialog_wait(DWDialog *dialog) |
1031 { | 1236 { |
1032 NSLog(@"dw_dialog_wait() unimplemented\n"); | 1237 void *tmp; |
1033 return NULL; | 1238 |
1239 while(!dialog->done) | |
1240 { | |
1241 dw_main_iteration(); | |
1242 } | |
1243 dw_event_close(&dialog->eve); | |
1244 tmp = dialog->result; | |
1245 free(dialog); | |
1246 return tmp; | |
1034 } | 1247 } |
1035 | 1248 |
1036 /* | 1249 /* |
1037 * Create a new Box to be packed. | 1250 * Create a new Box to be packed. |
1038 * Parameters: | 1251 * Parameters: |
1232 { | 1445 { |
1233 DWButton *button = [[DWButton alloc] init]; | 1446 DWButton *button = [[DWButton alloc] init]; |
1234 [button setTitle:[ NSString stringWithUTF8String:text ]]; | 1447 [button setTitle:[ NSString stringWithUTF8String:text ]]; |
1235 [button setButtonType:NSMomentaryPushInButton]; | 1448 [button setButtonType:NSMomentaryPushInButton]; |
1236 [button setBezelStyle:NSThickerSquareBezelStyle]; | 1449 [button setBezelStyle:NSThickerSquareBezelStyle]; |
1450 [button setTarget:button]; | |
1451 [button setAction:@selector(buttonClicked:)]; | |
1237 /*[button setGradientType:NSGradientConvexWeak];*/ | 1452 /*[button setGradientType:NSGradientConvexWeak];*/ |
1238 [button setTag:id]; | 1453 [button setTag:id]; |
1239 return button; | 1454 return button; |
1240 } | 1455 } |
1241 | 1456 |
1900 * Returns: | 2115 * Returns: |
1901 * The selected color or the current color if cancelled. | 2116 * The selected color or the current color if cancelled. |
1902 */ | 2117 */ |
1903 unsigned long API dw_color_choose(unsigned long value) | 2118 unsigned long API dw_color_choose(unsigned long value) |
1904 { | 2119 { |
1905 NSLog(@"dw_color_choose() unimplemented\n"); | 2120 /* Create the File Save Dialog class. */ |
1906 return 0; | 2121 DWColorChoose *colorDlg = (DWColorChoose *)[DWColorChoose sharedColorPanel]; |
2122 NSColor *color = [[NSColor alloc] init]; | |
2123 DWDialog *dialog = dw_dialog_new(colorDlg); | |
2124 | |
2125 /* Set defaults for the dialog. */ | |
2126 [colorDlg setColor:color]; | |
2127 [colorDlg setDialog:dialog]; | |
2128 | |
2129 color = (NSColor *)dw_dialog_wait(dialog); | |
2130 [color release]; | |
2131 return _foreground; | |
1907 } | 2132 } |
1908 | 2133 |
1909 /* Draw a point on a window (preferably a render window). | 2134 /* Draw a point on a window (preferably a render window). |
1910 * Parameters: | 2135 * Parameters: |
1911 * handle: Handle to the window. | 2136 * handle: Handle to the window. |
2530 * Returns: | 2755 * Returns: |
2531 * A handle to a splitbar window or NULL on failure. | 2756 * A handle to a splitbar window or NULL on failure. |
2532 */ | 2757 */ |
2533 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id) | 2758 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id) |
2534 { | 2759 { |
2535 NSLog(@"dw_splitbar_new() unimplemented\n"); | 2760 DWSplitBar *split = [[DWSplitBar alloc] init]; |
2536 return HWND_DESKTOP; | 2761 [split addSubview:topleft]; |
2762 [split addSubview:bottomright]; | |
2763 if(type == DW_VERT) | |
2764 { | |
2765 [split setVertical:YES]; | |
2766 } | |
2767 return split; | |
2537 } | 2768 } |
2538 | 2769 |
2539 /* | 2770 /* |
2540 * Sets the position of a splitbar (pecentage). | 2771 * Sets the position of a splitbar (pecentage). |
2541 * Parameters: | 2772 * Parameters: |
2542 * handle: The handle to the splitbar returned by dw_splitbar_new(). | 2773 * handle: The handle to the splitbar returned by dw_splitbar_new(). |
2543 */ | 2774 */ |
2544 void API dw_splitbar_set(HWND handle, float percent) | 2775 void API dw_splitbar_set(HWND handle, float percent) |
2545 { | 2776 { |
2546 NSLog(@"dw_splitbar_set() unimplemented\n"); | 2777 DWSplitBar *split = handle; |
2778 [split setPosition:percent ofDividerAtIndex:0]; | |
2547 } | 2779 } |
2548 | 2780 |
2549 /* | 2781 /* |
2550 * Gets the position of a splitbar (pecentage). | 2782 * Gets the position of a splitbar (pecentage). |
2551 * Parameters: | 2783 * Parameters: |
2932 void API dw_menu_item_set_state( HMENUI menux, unsigned long id, unsigned long state) | 3164 void API dw_menu_item_set_state( HMENUI menux, unsigned long id, unsigned long state) |
2933 { | 3165 { |
2934 NSLog(@"dw_menu_item_set_state() unimplemented\n"); | 3166 NSLog(@"dw_menu_item_set_state() unimplemented\n"); |
2935 } | 3167 } |
2936 | 3168 |
3169 /* Gets the notebook page from associated ID */ | |
3170 DWNotebookPage *_notepage_from_id(DWNotebook *notebook, unsigned long pageid) | |
3171 { | |
3172 NSArray *pages = [notebook tabViewItems]; | |
3173 for(DWNotebookPage *notepage in pages) | |
3174 { | |
3175 if([notepage pageid] == pageid) | |
3176 { | |
3177 return notepage; | |
3178 } | |
3179 } | |
3180 return nil; | |
3181 } | |
3182 | |
2937 /* | 3183 /* |
2938 * Create a notebook object to be packed. | 3184 * Create a notebook object to be packed. |
2939 * Parameters: | 3185 * Parameters: |
2940 * id: An ID to be used for getting the resource from the | 3186 * id: An ID to be used for getting the resource from the |
2941 * resource file. | 3187 * resource file. |
2942 */ | 3188 */ |
2943 HWND API dw_notebook_new(ULONG id, int top) | 3189 HWND API dw_notebook_new(ULONG id, int top) |
2944 { | 3190 { |
2945 NSLog(@"dw_notebook_new() unimplemented\n"); | 3191 DWNotebook *notebook = [[DWNotebook alloc] init]; |
2946 return HWND_DESKTOP; | 3192 [notebook setDelegate:notebook]; |
3193 return notebook; | |
2947 } | 3194 } |
2948 | 3195 |
2949 /* | 3196 /* |
2950 * Adds a new page to specified notebook. | 3197 * Adds a new page to specified notebook. |
2951 * Parameters: | 3198 * Parameters: |
2953 * flags: Any additional page creation flags. | 3200 * flags: Any additional page creation flags. |
2954 * front: If TRUE page is added at the beginning. | 3201 * front: If TRUE page is added at the beginning. |
2955 */ | 3202 */ |
2956 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front) | 3203 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front) |
2957 { | 3204 { |
2958 NSLog(@"dw_notebook_page_new() unimplemented\n"); | 3205 DWNotebook *notebook = handle; |
2959 return 0; | 3206 int page = [notebook pageid]; |
3207 DWNotebookPage *notepage = [[DWNotebookPage alloc] initWithIdentifier:nil]; | |
3208 [notepage setPageid:(NSInteger)page]; | |
3209 if(front) | |
3210 { | |
3211 [notebook insertTabViewItem:notepage atIndex:(NSInteger)0]; | |
3212 } | |
3213 else | |
3214 { | |
3215 [notebook addTabViewItem:notepage]; | |
3216 } | |
3217 [notebook setPageid:(page+1)]; | |
3218 return (unsigned long)page; | |
2960 } | 3219 } |
2961 | 3220 |
2962 /* | 3221 /* |
2963 * Remove a page from a notebook. | 3222 * Remove a page from a notebook. |
2964 * Parameters: | 3223 * Parameters: |
2965 * handle: Handle to the notebook widget. | 3224 * handle: Handle to the notebook widget. |
2966 * pageid: ID of the page to be destroyed. | 3225 * pageid: ID of the page to be destroyed. |
2967 */ | 3226 */ |
2968 void API dw_notebook_page_destroy(HWND handle, unsigned int pageid) | 3227 void API dw_notebook_page_destroy(HWND handle, unsigned int pageid) |
2969 { | 3228 { |
2970 NSLog(@"dw_notebook_page_destroy() unimplemented\n"); | 3229 DWNotebook *notebook = handle; |
3230 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); | |
3231 | |
3232 if(notepage != nil) | |
3233 { | |
3234 [notebook removeTabViewItem:notepage]; | |
3235 [notepage release]; | |
3236 } | |
2971 } | 3237 } |
2972 | 3238 |
2973 /* | 3239 /* |
2974 * Queries the currently visible page ID. | 3240 * Queries the currently visible page ID. |
2975 * Parameters: | 3241 * Parameters: |
2976 * handle: Handle to the notebook widget. | 3242 * handle: Handle to the notebook widget. |
2977 */ | 3243 */ |
2978 unsigned long API dw_notebook_page_get(HWND handle) | 3244 unsigned long API dw_notebook_page_get(HWND handle) |
2979 { | 3245 { |
2980 NSLog(@"dw_notebook_page_get() unimplemented\n"); | 3246 DWNotebook *notebook = handle; |
2981 return 0; | 3247 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem]; |
3248 return [notepage pageid]; | |
2982 } | 3249 } |
2983 | 3250 |
2984 /* | 3251 /* |
2985 * Sets the currently visibale page ID. | 3252 * Sets the currently visibale page ID. |
2986 * Parameters: | 3253 * Parameters: |
2987 * handle: Handle to the notebook widget. | 3254 * handle: Handle to the notebook widget. |
2988 * pageid: ID of the page to be made visible. | 3255 * pageid: ID of the page to be made visible. |
2989 */ | 3256 */ |
2990 void API dw_notebook_page_set(HWND handle, unsigned int pageid) | 3257 void API dw_notebook_page_set(HWND handle, unsigned int pageid) |
2991 { | 3258 { |
2992 NSLog(@"dw_notebook_page_set() unimplemented\n"); | 3259 DWNotebook *notebook = handle; |
3260 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); | |
3261 | |
3262 if(notepage != nil) | |
3263 { | |
3264 [notebook selectTabViewItem:notepage]; | |
3265 } | |
2993 } | 3266 } |
2994 | 3267 |
2995 /* | 3268 /* |
2996 * Sets the text on the specified notebook tab. | 3269 * Sets the text on the specified notebook tab. |
2997 * Parameters: | 3270 * Parameters: |
2999 * pageid: Page ID of the tab to set. | 3272 * pageid: Page ID of the tab to set. |
3000 * text: Pointer to the text to set. | 3273 * text: Pointer to the text to set. |
3001 */ | 3274 */ |
3002 void API dw_notebook_page_set_text(HWND handle, ULONG pageid, char *text) | 3275 void API dw_notebook_page_set_text(HWND handle, ULONG pageid, char *text) |
3003 { | 3276 { |
3004 NSLog(@"dw_notebook_page_set_text() unimplemented\n"); | 3277 DWNotebook *notebook = handle; |
3278 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); | |
3279 | |
3280 if(notepage != nil) | |
3281 { | |
3282 [notepage setLabel:[ NSString stringWithUTF8String:text ]]; | |
3283 } | |
3005 } | 3284 } |
3006 | 3285 |
3007 /* | 3286 /* |
3008 * Sets the text on the specified notebook tab status area. | 3287 * Sets the text on the specified notebook tab status area. |
3009 * Parameters: | 3288 * Parameters: |
3011 * pageid: Page ID of the tab to set. | 3290 * pageid: Page ID of the tab to set. |
3012 * text: Pointer to the text to set. | 3291 * text: Pointer to the text to set. |
3013 */ | 3292 */ |
3014 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text) | 3293 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text) |
3015 { | 3294 { |
3016 NSLog(@"dw_notebook_page_set_status_text() unimplemented\n"); | 3295 /* Note supported here... do nothing */ |
3017 } | 3296 } |
3018 | 3297 |
3019 /* | 3298 /* |
3020 * Packs the specified box into the notebook page. | 3299 * Packs the specified box into the notebook page. |
3021 * Parameters: | 3300 * Parameters: |
3023 * pageid: Page ID in the notebook which is being packed. | 3302 * pageid: Page ID in the notebook which is being packed. |
3024 * page: Box handle to be packed. | 3303 * page: Box handle to be packed. |
3025 */ | 3304 */ |
3026 void API dw_notebook_pack(HWND handle, ULONG pageid, HWND page) | 3305 void API dw_notebook_pack(HWND handle, ULONG pageid, HWND page) |
3027 { | 3306 { |
3028 NSLog(@"dw_notebook_pack() unimplemented\n"); | 3307 DWNotebook *notebook = handle; |
3308 DWNotebookPage *notepage = _notepage_from_id(notebook, pageid); | |
3309 DWBox *box = page; | |
3310 | |
3311 if(notepage != nil) | |
3312 { | |
3313 [notepage setView:box]; | |
3314 } | |
3029 } | 3315 } |
3030 | 3316 |
3031 /* | 3317 /* |
3032 * Create a new Window Frame. | 3318 * Create a new Window Frame. |
3033 * Parameters: | 3319 * Parameters: |