Mercurial > dwindows
comparison ios/dw.m @ 2381:3777ea1cccdb
iOS: Continuing conversion...
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 20 Mar 2021 21:53:56 +0000 |
parents | 93424ad710de |
children | 41a04e6b3e8e |
comparison
equal
deleted
inserted
replaced
2380:93424ad710de | 2381:3777ea1cccdb |
---|---|
1199 } | 1199 } |
1200 -(void *)userdata; | 1200 -(void *)userdata; |
1201 -(void)setUserdata:(void *)input; | 1201 -(void)setUserdata:(void *)input; |
1202 -(int)pageid; | 1202 -(int)pageid; |
1203 -(void)setPageid:(int)input; | 1203 -(void)setPageid:(int)input; |
1204 -(void)pageChanged; | 1204 -(void)pageChanged:(id)sender; |
1205 @end | 1205 @end |
1206 | 1206 |
1207 /* Subclass for a Notebook page type */ | 1207 /* Subclass for a Notebook page type */ |
1208 @interface DWNotebookPage : UISegmentedControl | 1208 @interface DWNotebookPage : UIView |
1209 { | 1209 { |
1210 void *userdata; | 1210 void *userdata; |
1211 int pageid; | 1211 int pageid; |
1212 } | 1212 } |
1213 -(void *)userdata; | 1213 -(void *)userdata; |
1219 @implementation DWNotebook | 1219 @implementation DWNotebook |
1220 -(void *)userdata { return userdata; } | 1220 -(void *)userdata { return userdata; } |
1221 -(void)setUserdata:(void *)input { userdata = input; } | 1221 -(void)setUserdata:(void *)input { userdata = input; } |
1222 -(int)pageid { return pageid; } | 1222 -(int)pageid { return pageid; } |
1223 -(void)setPageid:(int)input { pageid = input; } | 1223 -(void)setPageid:(int)input { pageid = input; } |
1224 -(void)pageChanged | 1224 -(void)pageChanged:(id)sender |
1225 { | 1225 { |
1226 #if 0 /* TODO: Implement page/segment changed handler */ | 1226 #if 0 /* TODO: Implement page/segment changed handler */ |
1227 id object = [notepage view]; | 1227 id object = [notepage view]; |
1228 DWNotebookPage *page = (DWNotebookPage *)notepage; | 1228 DWNotebookPage *page = (DWNotebookPage *)notepage; |
1229 | 1229 |
1233 Box *box = [view box]; | 1233 Box *box = [view box]; |
1234 CGSize size = [view frame].size; | 1234 CGSize size = [view frame].size; |
1235 _do_resize(box, size.width, size.height); | 1235 _do_resize(box, size.width, size.height); |
1236 _handle_resize_events(box); | 1236 _handle_resize_events(box); |
1237 } | 1237 } |
1238 _event_handler(self, DW_INT_TO_POINTER([page pageid]), 15); | |
1239 #endif | 1238 #endif |
1239 _event_handler(self, DW_INT_TO_POINTER([self selectedSegmentIndex]), 15); | |
1240 } | 1240 } |
1241 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } | 1241 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } |
1242 @end | 1242 @end |
1243 | 1243 |
1244 @implementation DWNotebookPage | 1244 @implementation DWNotebookPage |
2081 _event_handler(handle, nil, 1); | 2081 _event_handler(handle, nil, 1); |
2082 } | 2082 } |
2083 } | 2083 } |
2084 } | 2084 } |
2085 /* Special handling for notebook controls */ | 2085 /* Special handling for notebook controls */ |
2086 #if 0 /* TODO: Segmented control might not have subviews */ | |
2086 else if([handle isMemberOfClass:[DWNotebook class]]) | 2087 else if([handle isMemberOfClass:[DWNotebook class]]) |
2087 { | 2088 { |
2088 DWNotebook *notebook = (DWNotebook *)handle; | 2089 DWNotebook *notebook = (DWNotebook *)handle; |
2089 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem]; | 2090 NSInteger index = [notebook selectedSegmentIndex]; |
2090 id view = [notepage view]; | 2091 id view = [notepage view]; |
2091 | 2092 |
2092 if([view isMemberOfClass:[DWBox class]]) | 2093 if([view isMemberOfClass:[DWBox class]]) |
2093 { | 2094 { |
2094 Box *box = (Box *)[view box]; | 2095 Box *box = (Box *)[view box]; |
2095 _handle_resize_events(box); | 2096 _handle_resize_events(box); |
2096 } | 2097 } |
2097 } | 2098 } |
2099 #endif | |
2098 /* Handle laying out scrollviews... if required space is less | 2100 /* Handle laying out scrollviews... if required space is less |
2099 * than available space, then expand. Otherwise use required space. | 2101 * than available space, then expand. Otherwise use required space. |
2100 */ | 2102 */ |
2101 else if([handle isMemberOfClass:[DWScrollBox class]]) | 2103 else if([handle isMemberOfClass:[DWScrollBox class]]) |
2102 { | 2104 { |
2103 DWScrollBox *scrollbox = (DWScrollBox *)handle; | 2105 DWScrollBox *scrollbox = (DWScrollBox *)handle; |
2104 DWBox *contentbox = [scrollbox documentView]; | 2106 NSArray *subviews = [scrollbox subviews]; |
2107 DWBox *contentbox = [subviews firstObject]; | |
2105 Box *thisbox = [contentbox box]; | 2108 Box *thisbox = [contentbox box]; |
2106 | 2109 |
2107 /* Get the required space for the box */ | 2110 /* Get the required space for the box */ |
2108 _handle_resize_events(thisbox); | 2111 _handle_resize_events(thisbox); |
2109 } | 2112 } |
2259 /* If the calculated size is valid... */ | 2262 /* If the calculated size is valid... */ |
2260 if(height > 0 && width > 0) | 2263 if(height > 0 && width > 0) |
2261 { | 2264 { |
2262 int pad = thisbox->items[z].pad; | 2265 int pad = thisbox->items[z].pad; |
2263 UIView *handle = thisbox->items[z].hwnd; | 2266 UIView *handle = thisbox->items[z].hwnd; |
2264 CGPoint point; | 2267 CGRect rect; |
2265 CGSize size; | 2268 |
2266 | 2269 rect.origin.x = currentx + pad; |
2267 point.x = currentx + pad; | 2270 rect.origin.y = currenty + pad; |
2268 point.y = currenty + pad; | 2271 rect.size.width = width; |
2269 size.width = width; | 2272 rect.size.height = height; |
2270 size.height = height; | 2273 [handle setFrame:rect]; |
2271 [handle setFrameOrigin:point]; | |
2272 [handle setFrameSize:size]; | |
2273 | 2274 |
2274 /* After placing a box... place its components */ | 2275 /* After placing a box... place its components */ |
2275 if(thisbox->items[z].type == TYPEBOX) | 2276 if(thisbox->items[z].type == TYPEBOX) |
2276 { | 2277 { |
2277 id box = thisbox->items[z].hwnd; | 2278 id box = thisbox->items[z].hwnd; |
2283 _resize_box(tmp, depth, width, height, pass); | 2284 _resize_box(tmp, depth, width, height, pass); |
2284 (*depth)--; | 2285 (*depth)--; |
2285 } | 2286 } |
2286 } | 2287 } |
2287 | 2288 |
2289 #if 0 /* TODO: Segemented control may not have subviews */ | |
2288 /* Special handling for notebook controls */ | 2290 /* Special handling for notebook controls */ |
2289 if([handle isMemberOfClass:[DWNotebook class]]) | 2291 if([handle isMemberOfClass:[DWNotebook class]]) |
2290 { | 2292 { |
2291 DWNotebook *notebook = (DWNotebook *)handle; | 2293 DWNotebook *notebook = (DWNotebook *)handle; |
2292 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem]; | 2294 NSInteger index = [notebook selectedSegmentIndex]; |
2293 id view = [notepage view]; | 2295 id view = [notepage view]; |
2294 | 2296 |
2295 if([view isMemberOfClass:[DWBox class]]) | 2297 if([view isMemberOfClass:[DWBox class]]) |
2296 { | 2298 { |
2297 Box *box = (Box *)[view box]; | 2299 Box *box = (Box *)[view box]; |
2298 CGSize size = [view frame].size; | 2300 CGSize size = [view frame].size; |
2299 _do_resize(box, size.width, size.height); | 2301 _do_resize(box, size.width, size.height); |
2300 _handle_resize_events(box); | 2302 _handle_resize_events(box); |
2301 } | 2303 } |
2302 } | 2304 } |
2305 #endif | |
2303 /* Handle laying out scrollviews... if required space is less | 2306 /* Handle laying out scrollviews... if required space is less |
2304 * than available space, then expand. Otherwise use required space. | 2307 * than available space, then expand. Otherwise use required space. |
2305 */ | 2308 */ |
2306 else if([handle isMemberOfClass:[DWScrollBox class]]) | 2309 else if([handle isMemberOfClass:[DWScrollBox class]]) |
2307 { | 2310 { |
2308 int depth = 0; | 2311 int depth = 0; |
2309 DWScrollBox *scrollbox = (DWScrollBox *)handle; | 2312 DWScrollBox *scrollbox = (DWScrollBox *)handle; |
2310 DWBox *contentbox = [scrollbox contentView]; | 2313 NSArray *subviews = [scrollbox subviews]; |
2314 DWBox *contentbox = [subviews firstObject]; | |
2311 Box *thisbox = [contentbox box]; | 2315 Box *thisbox = [contentbox box]; |
2312 CGSize contentsize = [scrollbox contentSize]; | 2316 CGSize contentsize = [scrollbox contentSize]; |
2317 CGRect frame = [contentbox frame]; | |
2313 | 2318 |
2314 /* Get the required space for the box */ | 2319 /* Get the required space for the box */ |
2315 _resize_box(thisbox, &depth, x, y, 1); | 2320 _resize_box(thisbox, &depth, x, y, 1); |
2316 | 2321 |
2317 if(contentsize.width < thisbox->minwidth) | 2322 if(contentsize.width < thisbox->minwidth) |
2320 } | 2325 } |
2321 if(contentsize.height < thisbox->minheight) | 2326 if(contentsize.height < thisbox->minheight) |
2322 { | 2327 { |
2323 contentsize.height = thisbox->minheight; | 2328 contentsize.height = thisbox->minheight; |
2324 } | 2329 } |
2325 [contentbox setFrameSize:contentsize]; | 2330 frame.size = contentsize; |
2331 [contentbox setFrame:frame]; | |
2326 | 2332 |
2327 /* Layout the content of the scrollbox */ | 2333 /* Layout the content of the scrollbox */ |
2328 _do_resize(thisbox, contentsize.width, contentsize.height); | 2334 _do_resize(thisbox, contentsize.width, contentsize.height); |
2329 _handle_resize_events(thisbox); | 2335 _handle_resize_events(thisbox); |
2330 } | 2336 } |
2332 else if([handle isMemberOfClass:[DWSpinButton class]]) | 2338 else if([handle isMemberOfClass:[DWSpinButton class]]) |
2333 { | 2339 { |
2334 DWSpinButton *spinbutton = (DWSpinButton *)handle; | 2340 DWSpinButton *spinbutton = (DWSpinButton *)handle; |
2335 UITextField *textfield = [spinbutton textfield]; | 2341 UITextField *textfield = [spinbutton textfield]; |
2336 UIStepper *stepper = [spinbutton stepper]; | 2342 UIStepper *stepper = [spinbutton stepper]; |
2337 [textfield setFrameOrigin:CGPointMake(0,0)]; | 2343 [textfield setFrame:CGRectMake(0,0,rect.size.width-20,rect.size.height)]; |
2338 [textfield setFrameSize:CGSizeMake(size.width-20,size.height)]; | 2344 [stepper setFrame:CGRectMake(rect.size.width-20,0,20,rect.size.height)]; |
2339 [stepper setFrameOrigin:CGPointMake(size.width-20,0)]; | |
2340 [stepper setFrameSize:CGSizeMake(20,size.height)]; | |
2341 } | 2345 } |
2342 else if([handle isMemberOfClass:[DWSplitBar class]]) | 2346 else if([handle isMemberOfClass:[DWSplitBar class]]) |
2343 { | 2347 { |
2344 DWSplitBar *split = (DWSplitBar *)handle; | 2348 DWSplitBar *split = (DWSplitBar *)handle; |
2345 DWWindow *window = (DWWindow *)[split window]; | |
2346 float percent = [split percent]; | 2349 float percent = [split percent]; |
2347 | 2350 |
2348 if(percent > 0 && size.width > 20 && size.height > 20) | 2351 if(percent > 0 && rect.size.width > 20 && rect.size.height > 20) |
2349 { | 2352 { |
2350 dw_splitbar_set(handle, percent); | 2353 dw_splitbar_set(handle, percent); |
2351 [split setPercent:0]; | 2354 [split setPercent:0]; |
2352 } | 2355 } |
2353 else if([window redraw]) | 2356 [split splitViewDidResizeSubviews:nil]; |
2354 { | |
2355 [split splitViewDidResizeSubviews:nil]; | |
2356 } | |
2357 } | 2357 } |
2358 | 2358 |
2359 /* Advance the current position in the box */ | 2359 /* Advance the current position in the box */ |
2360 if(thisbox->type == DW_HORZ) | 2360 if(thisbox->type == DW_HORZ) |
2361 currentx += width + (pad * 2); | 2361 currentx += width + (pad * 2); |
2786 { | 2786 { |
2787 DWScrollBox *scrollbox = [[DWScrollBox alloc] init]; | 2787 DWScrollBox *scrollbox = [[DWScrollBox alloc] init]; |
2788 DWBox *box = dw_box_new(type, pad); | 2788 DWBox *box = dw_box_new(type, pad); |
2789 DWBox *tmpbox = dw_box_new(DW_VERT, 0); | 2789 DWBox *tmpbox = dw_box_new(DW_VERT, 0); |
2790 dw_box_pack_start(tmpbox, box, 1, 1, TRUE, TRUE, 0); | 2790 dw_box_pack_start(tmpbox, box, 1, 1, TRUE, TRUE, 0); |
2791 [scrollbox setHasVerticalScroller:YES]; | |
2792 [scrollbox setHasHorizontalScroller:YES]; | |
2793 [scrollbox setBorderType:NSNoBorder]; | |
2794 [scrollbox setDrawsBackground:NO]; | |
2795 [scrollbox setBox:box]; | 2791 [scrollbox setBox:box]; |
2796 [scrollbox setDocumentView:tmpbox]; | 2792 [scrollbox addSubview:tmpbox]; |
2797 [tmpbox autorelease]; | 2793 [tmpbox autorelease]; |
2798 return scrollbox; | 2794 return scrollbox; |
2799 } | 2795 } |
2800 | 2796 |
2801 /* | 2797 /* |
2805 * orient: The vertical or horizontal scrollbar. | 2801 * orient: The vertical or horizontal scrollbar. |
2806 */ | 2802 */ |
2807 int API dw_scrollbox_get_pos(HWND handle, int orient) | 2803 int API dw_scrollbox_get_pos(HWND handle, int orient) |
2808 { | 2804 { |
2809 DWScrollBox *scrollbox = handle; | 2805 DWScrollBox *scrollbox = handle; |
2810 UIView *view = [scrollbox documentView]; | 2806 NSArray *subviews = [scrollbox subviews]; |
2807 UIView *view = [subviews firstObject]; | |
2811 CGSize contentsize = [scrollbox contentSize]; | 2808 CGSize contentsize = [scrollbox contentSize]; |
2812 NSScroller *scrollbar; | 2809 CGPoint contentoffset = [scrollbox contentOffset]; |
2813 int range = 0; | 2810 int range = 0; |
2814 int val = 0; | 2811 int val = 0; |
2815 if(orient == DW_VERT) | 2812 if(orient == DW_VERT) |
2816 { | 2813 { |
2817 scrollbar = [scrollbox verticalScroller]; | |
2818 range = [view bounds].size.height - contentsize.height; | 2814 range = [view bounds].size.height - contentsize.height; |
2815 val = contentoffset.y; | |
2819 } | 2816 } |
2820 else | 2817 else |
2821 { | 2818 { |
2822 scrollbar = [scrollbox horizontalScroller]; | |
2823 range = [view bounds].size.width - contentsize.width; | 2819 range = [view bounds].size.width - contentsize.width; |
2824 } | 2820 val = contentoffset.x; |
2825 if(range > 0) | 2821 } |
2826 { | 2822 if(val > range) |
2827 val = [scrollbar floatValue] * range; | 2823 { |
2824 val = range; | |
2828 } | 2825 } |
2829 return val; | 2826 return val; |
2830 } | 2827 } |
2831 | 2828 |
2832 /* | 2829 /* |
2836 * orient: The vertical or horizontal scrollbar. | 2833 * orient: The vertical or horizontal scrollbar. |
2837 */ | 2834 */ |
2838 int API dw_scrollbox_get_range(HWND handle, int orient) | 2835 int API dw_scrollbox_get_range(HWND handle, int orient) |
2839 { | 2836 { |
2840 DWScrollBox *scrollbox = handle; | 2837 DWScrollBox *scrollbox = handle; |
2841 UIView *view = [scrollbox documentView]; | 2838 NSArray *subviews = [scrollbox subviews]; |
2839 UIView *view = [subviews firstObject]; | |
2842 int range = 0; | 2840 int range = 0; |
2843 if(orient == DW_VERT) | 2841 if(orient == DW_VERT) |
2844 { | 2842 { |
2845 range = [view bounds].size.height; | 2843 range = [view bounds].size.height; |
2846 } | 2844 } |
2857 if([object isMemberOfClass:[ DWSpinButton class]]) | 2855 if([object isMemberOfClass:[ DWSpinButton class]]) |
2858 { | 2856 { |
2859 DWSpinButton *spinbutton = object; | 2857 DWSpinButton *spinbutton = object; |
2860 object = [spinbutton textfield]; | 2858 object = [spinbutton textfield]; |
2861 } | 2859 } |
2860 #if 0 /* TODO: Fix this when we have a groupbox implemented */ | |
2862 if([object isMemberOfClass:[ NSBox class]]) | 2861 if([object isMemberOfClass:[ NSBox class]]) |
2863 { | 2862 { |
2864 NSBox *box = object; | 2863 NSBox *box = object; |
2865 id content = [box contentView]; | 2864 id content = [box contentView]; |
2866 | 2865 |
2867 if([content isMemberOfClass:[ DWText class]]) | 2866 if([content isMemberOfClass:[ DWText class]]) |
2868 { | 2867 { |
2869 object = content; | 2868 object = content; |
2870 } | 2869 } |
2871 } | 2870 } |
2871 #endif | |
2872 return object; | 2872 return object; |
2873 } | 2873 } |
2874 | 2874 |
2875 /* Internal function to calculate the widget's required size.. | 2875 /* Internal function to calculate the widget's required size.. |
2876 * These are the general rules for widget sizes: | 2876 * These are the general rules for widget sizes: |
2892 /* Handle all the different button types */ | 2892 /* Handle all the different button types */ |
2893 if([ object isKindOfClass:[ UIButton class ] ]) | 2893 if([ object isKindOfClass:[ UIButton class ] ]) |
2894 { | 2894 { |
2895 switch([object buttonType]) | 2895 switch([object buttonType]) |
2896 { | 2896 { |
2897 case DWButtonTypeSwitch: | |
2898 case DWButtonTypeRadio: | |
2899 extrawidth = 24; | |
2900 extraheight = 4; | |
2901 nsstr = [object title]; | |
2902 break; | |
2903 default: | 2897 default: |
2904 { | 2898 { |
2905 UIImage *image = [object image]; | 2899 UIImage *image = (UIImage *)[object image]; |
2906 | 2900 |
2907 if(image) | 2901 if(image) |
2908 { | 2902 { |
2909 /* Image button */ | 2903 /* Image button */ |
2910 CGSize size = [image size]; | 2904 CGSize size = [image size]; |
2911 thiswidth = (int)size.width; | 2905 thiswidth = (int)size.width; |
2912 thisheight = (int)size.height; | 2906 thisheight = (int)size.height; |
2913 if([object isBordered]) | |
2914 { | |
2915 extrawidth = 4; | |
2916 extraheight = 4; | |
2917 } | |
2918 } | 2907 } |
2919 else | 2908 else |
2920 { | 2909 { |
2921 /* Text button */ | 2910 /* Text button */ |
2922 nsstr = [object title]; | 2911 nsstr = [object title]; |
2923 | 2912 |
2924 if([object isBordered]) | 2913 extrawidth = 8; |
2925 { | 2914 extraheight = 4; |
2926 extrawidth = 30; | |
2927 extraheight = 8; | |
2928 } | |
2929 else | |
2930 { | |
2931 extrawidth = 8; | |
2932 extraheight = 4; | |
2933 } | |
2934 } | 2915 } |
2935 break; | 2916 break; |
2936 } | 2917 } |
2937 } | 2918 } |
2938 } | 2919 } |
2951 } | 2932 } |
2952 else | 2933 else |
2953 nsstr = [object stringValue]; | 2934 nsstr = [object stringValue]; |
2954 | 2935 |
2955 if(font) | 2936 if(font) |
2956 thisheight = (int)[font boundingRectForFont].size.height; | 2937 thisheight = (int)[font lineHeight]; |
2957 } | 2938 } |
2958 /* Handle the ranged widgets */ | 2939 /* Handle the ranged widgets */ |
2959 else if([ object isMemberOfClass:[DWPercent class] ] || | 2940 else if([ object isMemberOfClass:[DWPercent class] ] || |
2960 [ object isMemberOfClass:[DWSlider class] ]) | 2941 [ object isMemberOfClass:[DWSlider class] ]) |
2961 { | 2942 { |
2963 thisheight = 20; | 2944 thisheight = 20; |
2964 } | 2945 } |
2965 /* Handle bitmap size */ | 2946 /* Handle bitmap size */ |
2966 else if([ object isMemberOfClass:[UIImageView class] ]) | 2947 else if([ object isMemberOfClass:[UIImageView class] ]) |
2967 { | 2948 { |
2968 UIImage *image = [object image]; | 2949 UIImage *image = (UIImage *)[object image]; |
2969 | 2950 |
2970 if(image) | 2951 if(image) |
2971 { | 2952 { |
2972 CGSize size = [image size]; | 2953 CGSize size = [image size]; |
2973 thiswidth = (int)size.width; | 2954 thiswidth = (int)size.width; |
2975 } | 2956 } |
2976 } | 2957 } |
2977 /* Handle calendar */ | 2958 /* Handle calendar */ |
2978 else if([ object isMemberOfClass:[DWCalendar class] ]) | 2959 else if([ object isMemberOfClass:[DWCalendar class] ]) |
2979 { | 2960 { |
2980 NSCell *cell = [object cell]; | 2961 CGSize size = [object intrinsicContentSize]; |
2981 | |
2982 if(cell) | |
2983 { | |
2984 CGSize size = [cell cellSize]; | |
2985 | 2962 |
2986 thiswidth = size.width; | 2963 thiswidth = size.width; |
2987 thisheight = size.height; | 2964 thisheight = size.height; |
2988 } | |
2989 } | 2965 } |
2990 /* MLE and Container */ | 2966 /* MLE and Container */ |
2991 else if([ object isMemberOfClass:[DWMLE class] ] || | 2967 else if([ object isMemberOfClass:[DWMLE class] ] || |
2992 [ object isMemberOfClass:[DWContainer class] ]) | 2968 [ object isMemberOfClass:[DWContainer class] ]) |
2993 { | 2969 { |
2994 CGSize size; | 2970 CGSize size; |
2995 | 2971 |
2996 if([ object isMemberOfClass:[DWMLE class] ]) | 2972 if([ object isMemberOfClass:[DWMLE class] ]) |
2997 { | 2973 { |
2998 UIScrollView *sv = [object scrollview]; | 2974 UIScrollView *sv = [object scrollview]; |
2999 CGSize frame = [sv frame].size; | 2975 CGRect frame = [sv frame]; |
3000 BOOL hscroll = [sv hasHorizontalScroller]; | 2976 |
3001 | |
3002 /* Make sure word wrap is off for the first part */ | |
3003 if(!hscroll) | |
3004 { | |
3005 [[object textContainer] setWidthTracksTextView:NO]; | |
3006 [[object textContainer] setContainerSize:[object maxSize]]; | |
3007 [object setHorizontallyResizable:YES]; | |
3008 [sv setHasHorizontalScroller:YES]; | |
3009 } | |
3010 /* Size the text view to fit */ | 2977 /* Size the text view to fit */ |
3011 [object sizeToFit]; | 2978 [object sizeToFit]; |
3012 size = [object bounds].size; | 2979 frame.size = [object bounds].size; |
3013 size.width += 2.0; | 2980 frame.size.width += 2.0; |
3014 size.height += 2.0; | 2981 frame.size.height += 2.0; |
3015 /* Re-enable word wrapping if it was on */ | 2982 [sv setFrame:frame]; |
3016 if(!hscroll) | |
3017 { | |
3018 [[object textContainer] setWidthTracksTextView:YES]; | |
3019 [sv setHasHorizontalScroller:NO]; | |
3020 | |
3021 /* If the un wrapped it is beyond the bounds... */ | |
3022 if(size.width > _DW_SCROLLED_MAX_WIDTH) | |
3023 { | |
3024 CGSize max = [object maxSize]; | |
3025 | |
3026 /* Set the max size to the limit */ | |
3027 [object setMaxSize:NSMakeSize(_DW_SCROLLED_MAX_WIDTH, max.height)]; | |
3028 /* Recalculate the size */ | |
3029 [object sizeToFit]; | |
3030 size = [object bounds].size; | |
3031 size.width += 2.0; | |
3032 size.height += 2.0; | |
3033 [object setMaxSize:max]; | |
3034 } | |
3035 } | |
3036 [sv setFrameSize:frame]; | |
3037 /* Take into account the horizontal scrollbar */ | |
3038 if(hscroll && size.width > _DW_SCROLLED_MAX_WIDTH) | |
3039 size.height += 16.0; | |
3040 } | 2983 } |
3041 else | 2984 else |
3042 size = [object getsize]; | 2985 size = [object getsize]; |
3043 | 2986 |
3044 thiswidth = size.width; | 2987 thiswidth = size.width; |
3051 if(thisheight < _DW_SCROLLED_MIN_HEIGHT) | 2994 if(thisheight < _DW_SCROLLED_MIN_HEIGHT) |
3052 thisheight = _DW_SCROLLED_MIN_HEIGHT; | 2995 thisheight = _DW_SCROLLED_MIN_HEIGHT; |
3053 if(thisheight > _DW_SCROLLED_MAX_HEIGHT) | 2996 if(thisheight > _DW_SCROLLED_MAX_HEIGHT) |
3054 thisheight = _DW_SCROLLED_MAX_HEIGHT; | 2997 thisheight = _DW_SCROLLED_MAX_HEIGHT; |
3055 } | 2998 } |
3056 /* Tree */ | |
3057 else if([ object isMemberOfClass:[DWTree class] ]) | |
3058 { | |
3059 thiswidth = (int)((_DW_SCROLLED_MAX_WIDTH + _DW_SCROLLED_MIN_WIDTH)/2); | |
3060 thisheight = (int)((_DW_SCROLLED_MAX_HEIGHT + _DW_SCROLLED_MIN_HEIGHT)/2); | |
3061 } | |
3062 /* Any other control type */ | 2999 /* Any other control type */ |
3063 else if([ object isKindOfClass:[ UIControl class ] ]) | 3000 else if([ object isKindOfClass:[ UIControl class ] ]) |
3064 nsstr = [object stringValue]; | 3001 nsstr = [object stringValue]; |
3065 | 3002 |
3066 /* If we have a string... | 3003 /* If we have a string... |
3070 dw_font_text_extents_get(object, NULL, (char *)[nsstr UTF8String], &thiswidth, &thisheight); | 3007 dw_font_text_extents_get(object, NULL, (char *)[nsstr UTF8String], &thiswidth, &thisheight); |
3071 | 3008 |
3072 /* Handle static text fields */ | 3009 /* Handle static text fields */ |
3073 if([object isKindOfClass:[ UITextField class ]] && ![object isEditable]) | 3010 if([object isKindOfClass:[ UITextField class ]] && ![object isEditable]) |
3074 { | 3011 { |
3075 id border = handle; | |
3076 | |
3077 extrawidth = 10; | 3012 extrawidth = 10; |
3078 | |
3079 /* Handle status bar field */ | |
3080 if([border isMemberOfClass:[ NSBox class ] ]) | |
3081 { | |
3082 extrawidth += 2; | |
3083 extraheight = 8; | |
3084 } | |
3085 } | 3013 } |
3086 | 3014 |
3087 /* Set the requested sizes */ | 3015 /* Set the requested sizes */ |
3088 if(width) | 3016 if(width) |
3089 *width = thiswidth + extrawidth; | 3017 *width = thiswidth + extrawidth; |
3113 | 3041 |
3114 /* Query the objects */ | 3042 /* Query the objects */ |
3115 if([ object isKindOfClass:[ UIWindow class ] ]) | 3043 if([ object isKindOfClass:[ UIWindow class ] ]) |
3116 { | 3044 { |
3117 UIWindow *window = box; | 3045 UIWindow *window = box; |
3118 view = [window contentView]; | 3046 NSArray *subviews = [window subviews]; |
3047 view = [subviews firstObject]; | |
3119 } | 3048 } |
3120 else if([ object isMemberOfClass:[ DWScrollBox class ] ]) | 3049 else if([ object isMemberOfClass:[ DWScrollBox class ] ]) |
3121 { | 3050 { |
3122 DWScrollBox *scrollbox = box; | 3051 DWScrollBox *scrollbox = box; |
3123 view = [scrollbox box]; | 3052 view = [scrollbox box]; |
3127 thisitem = thisbox->items; | 3056 thisitem = thisbox->items; |
3128 object = item; | 3057 object = item; |
3129 | 3058 |
3130 /* Query the objects */ | 3059 /* Query the objects */ |
3131 if([ object isMemberOfClass:[ DWContainer class ] ] || | 3060 if([ object isMemberOfClass:[ DWContainer class ] ] || |
3132 [ object isMemberOfClass:[ DWTree class ] ] || | |
3133 [ object isMemberOfClass:[ DWMLE class ] ]) | 3061 [ object isMemberOfClass:[ DWMLE class ] ]) |
3134 { | 3062 { |
3135 this = item = [object scrollview]; | 3063 this = item = [object scrollview]; |
3136 } | 3064 } |
3137 | 3065 |
3235 DWBox *parent = (DWBox *)[object superview]; | 3163 DWBox *parent = (DWBox *)[object superview]; |
3236 | 3164 |
3237 /* Some controls are embedded in scrollviews... | 3165 /* Some controls are embedded in scrollviews... |
3238 * so get the parent of the scrollview in that case. | 3166 * so get the parent of the scrollview in that case. |
3239 */ | 3167 */ |
3240 if(([object isKindOfClass:[NSTableView class]] || [object isMemberOfClass:[DWMLE class]]) | 3168 if(([object isKindOfClass:[UITableView class]] || [object isMemberOfClass:[DWMLE class]])) |
3241 && [parent isMemberOfClass:[NSClipView class]]) | |
3242 { | 3169 { |
3243 object = [parent superview]; | 3170 object = [parent superview]; |
3244 parent = (DWBox *)[object superview]; | 3171 parent = (DWBox *)[object superview]; |
3245 } | 3172 } |
3246 | 3173 |
3421 HWND _dw_button_new(const char *text, ULONG cid) | 3348 HWND _dw_button_new(const char *text, ULONG cid) |
3422 { | 3349 { |
3423 DWButton *button = [[DWButton alloc] init]; | 3350 DWButton *button = [[DWButton alloc] init]; |
3424 if(text) | 3351 if(text) |
3425 { | 3352 { |
3426 [button setTitle:[ NSString stringWithUTF8String:text ]]; | 3353 [button setTitle:[NSString stringWithUTF8String:text] forState:UIControlStateNormal]; |
3427 } | 3354 } |
3428 [button setTarget:button]; | 3355 [button addTarget:button |
3429 [button setAction:@selector(buttonClicked:)]; | 3356 action:@selector(buttonClicked:) |
3357 forControlEvents:UIControlEventPrimaryActionTriggered]; | |
3430 [button setTag:cid]; | 3358 [button setTag:cid]; |
3431 if(DWDefaultFont) | 3359 if(DWDefaultFont) |
3432 { | 3360 { |
3433 [[button cell] setFont:DWDefaultFont]; | 3361 [[button titleLabel] setFont:DWDefaultFont]; |
3434 } | 3362 } |
3435 return button; | 3363 return button; |
3436 } | 3364 } |
3437 | 3365 |
3438 /* | 3366 /* |
3442 * id: An ID to be used with dw_window_from_id() or 0L. | 3370 * id: An ID to be used with dw_window_from_id() or 0L. |
3443 */ | 3371 */ |
3444 HWND API dw_button_new(const char *text, ULONG cid) | 3372 HWND API dw_button_new(const char *text, ULONG cid) |
3445 { | 3373 { |
3446 DWButton *button = _dw_button_new(text, cid); | 3374 DWButton *button = _dw_button_new(text, cid); |
3447 [button setImagePosition:NSNoImage]; | 3375 [button setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter]; |
3448 [button setAlignment:DWTextAlignmentCenter]; | |
3449 [[button cell] setControlTint:NSBlueControlTint]; | |
3450 return button; | 3376 return button; |
3451 } | 3377 } |
3452 | 3378 |
3453 /* | 3379 /* |
3454 * Create a new Entryfield window (widget) to be packed. | 3380 * Create a new Entryfield window (widget) to be packed. |
3457 * id: An ID to be used with dw_window_from_id() or 0L. | 3383 * id: An ID to be used with dw_window_from_id() or 0L. |
3458 */ | 3384 */ |
3459 HWND API dw_entryfield_new(const char *text, ULONG cid) | 3385 HWND API dw_entryfield_new(const char *text, ULONG cid) |
3460 { | 3386 { |
3461 DWEntryField *entry = [[DWEntryField alloc] init]; | 3387 DWEntryField *entry = [[DWEntryField alloc] init]; |
3462 [entry setStringValue:[ NSString stringWithUTF8String:text ]]; | 3388 [entry setText:[ NSString stringWithUTF8String:text ]]; |
3463 [entry setTag:cid]; | 3389 [entry setTag:cid]; |
3464 return entry; | 3390 return entry; |
3465 } | 3391 } |
3466 | 3392 |
3467 /* | 3393 /* |
3487 { | 3413 { |
3488 DWEntryField *entry = handle; | 3414 DWEntryField *entry = handle; |
3489 DWEntryFieldFormatter *formatter = [[[DWEntryFieldFormatter alloc] init] autorelease]; | 3415 DWEntryFieldFormatter *formatter = [[[DWEntryFieldFormatter alloc] init] autorelease]; |
3490 | 3416 |
3491 [formatter setMaximumLength:(int)limit]; | 3417 [formatter setMaximumLength:(int)limit]; |
3492 [[entry cell] setFormatter:formatter]; | 3418 [entry setFormatter:formatter]; |
3493 } | 3419 } |
3494 | 3420 |
3495 /* | 3421 /* |
3496 * Create a new bitmap button window (widget) to be packed. | 3422 * Create a new bitmap button window (widget) to be packed. |
3497 * Parameters: | 3423 * Parameters: |
3505 NSString *filepath = [respath stringByAppendingFormat:@"/%lu.png", resid]; | 3431 NSString *filepath = [respath stringByAppendingFormat:@"/%lu.png", resid]; |
3506 UIImage *image = [[UIImage alloc] initWithContentsOfFile:filepath]; | 3432 UIImage *image = [[UIImage alloc] initWithContentsOfFile:filepath]; |
3507 DWButton *button = _dw_button_new("", resid); | 3433 DWButton *button = _dw_button_new("", resid); |
3508 if(image) | 3434 if(image) |
3509 { | 3435 { |
3510 [button setImage:image]; | 3436 [button setImage:image forState:UIControlStateNormal]; |
3511 } | 3437 } |
3512 if(text) | |
3513 [button setToolTip:[NSString stringWithUTF8String:text]]; | |
3514 [image release]; | 3438 [image release]; |
3515 return button; | 3439 return button; |
3516 } | 3440 } |
3517 | 3441 |
3518 /* | 3442 /* |
3537 image = [[UIImage alloc] initWithContentsOfFile:nstr]; | 3461 image = [[UIImage alloc] initWithContentsOfFile:nstr]; |
3538 } | 3462 } |
3539 DWButton *button = _dw_button_new("", cid); | 3463 DWButton *button = _dw_button_new("", cid); |
3540 if(image) | 3464 if(image) |
3541 { | 3465 { |
3542 [button setImage:image]; | 3466 [button setImage:image forState:UIControlStateNormal]; |
3543 } | 3467 } |
3544 if(text) | |
3545 [button setToolTip:[NSString stringWithUTF8String:text]]; | |
3546 [image release]; | 3468 [image release]; |
3547 return button; | 3469 return button; |
3548 } | 3470 } |
3549 | 3471 |
3550 /* | 3472 /* |
3561 NSData *thisdata = [NSData dataWithBytes:data length:len]; | 3483 NSData *thisdata = [NSData dataWithBytes:data length:len]; |
3562 UIImage *image = [[UIImage alloc] initWithData:thisdata]; | 3484 UIImage *image = [[UIImage alloc] initWithData:thisdata]; |
3563 DWButton *button = _dw_button_new("", cid); | 3485 DWButton *button = _dw_button_new("", cid); |
3564 if(image) | 3486 if(image) |
3565 { | 3487 { |
3566 [button setImage:image]; | 3488 [button setImage:image forState:UIControlStateNormal]; |
3567 } | 3489 } |
3568 if(text) | |
3569 [button setToolTip:[NSString stringWithUTF8String:text]]; | |
3570 [image release]; | 3490 [image release]; |
3571 return button; | 3491 return button; |
3572 } | 3492 } |
3573 | 3493 |
3574 /* | 3494 /* |
3582 DWSpinButton *spinbutton = [[DWSpinButton alloc] init]; | 3502 DWSpinButton *spinbutton = [[DWSpinButton alloc] init]; |
3583 UIStepper *stepper = [spinbutton stepper]; | 3503 UIStepper *stepper = [spinbutton stepper]; |
3584 UITextField *textfield = [spinbutton textfield]; | 3504 UITextField *textfield = [spinbutton textfield]; |
3585 long val = atol(text); | 3505 long val = atol(text); |
3586 | 3506 |
3587 [stepper setIncrement:1]; | 3507 [stepper setStepValue:1]; |
3588 [stepper setTag:cid]; | 3508 [stepper setTag:cid]; |
3589 [stepper setMinValue:-65536]; | 3509 [stepper setMinimumValue:-65536]; |
3590 [stepper setMaxValue:65536]; | 3510 [stepper setMaximumValue:65536]; |
3591 [stepper setValue:(float)val]; | 3511 [stepper setValue:(float)val]; |
3592 [textfield setText:[NSString stringWithFormat:@"%ld",val]]; | 3512 [textfield setText:[NSString stringWithFormat:@"%ld",val]]; |
3593 return spinbutton; | 3513 return spinbutton; |
3594 } | 3514 } |
3595 | 3515 |
3603 { | 3523 { |
3604 DWSpinButton *spinbutton = handle; | 3524 DWSpinButton *spinbutton = handle; |
3605 UIStepper *stepper = [spinbutton stepper]; | 3525 UIStepper *stepper = [spinbutton stepper]; |
3606 UITextField *textfield = [spinbutton textfield]; | 3526 UITextField *textfield = [spinbutton textfield]; |
3607 [stepper setValue:(float)position]; | 3527 [stepper setValue:(float)position]; |
3608 [textfield [NSString stringWithFormat:@"%ld",position]]; | 3528 [textfield setText:[NSString stringWithFormat:@"%ld",position]]; |
3609 } | 3529 } |
3610 | 3530 |
3611 /* | 3531 /* |
3612 * Sets the spinbutton limits. | 3532 * Sets the spinbutton limits. |
3613 * Parameters: | 3533 * Parameters: |
3617 */ | 3537 */ |
3618 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower) | 3538 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower) |
3619 { | 3539 { |
3620 DWSpinButton *spinbutton = handle; | 3540 DWSpinButton *spinbutton = handle; |
3621 UIStepper *stepper = [spinbutton stepper]; | 3541 UIStepper *stepper = [spinbutton stepper]; |
3622 [stepper setMinValue:(double)lower]; | 3542 [stepper setMinimumValue:(double)lower]; |
3623 [stepper setMaxValue:(double)upper]; | 3543 [stepper setMaximumValue:(double)upper]; |
3624 } | 3544 } |
3625 | 3545 |
3626 /* | 3546 /* |
3627 * Returns the current value of the spinbutton. | 3547 * Returns the current value of the spinbutton. |
3628 * Parameters: | 3548 * Parameters: |
3656 * id: An ID to be used with dw_window_from_id() or 0L. | 3576 * id: An ID to be used with dw_window_from_id() or 0L. |
3657 */ | 3577 */ |
3658 HWND API dw_slider_new(int vertical, int increments, ULONG cid) | 3578 HWND API dw_slider_new(int vertical, int increments, ULONG cid) |
3659 { | 3579 { |
3660 DWSlider *slider = [[DWSlider alloc] init]; | 3580 DWSlider *slider = [[DWSlider alloc] init]; |
3661 [slider setMaxValue:(double)increments]; | 3581 [slider setMaximumValue:(double)increments]; |
3662 [slider setMinValue:0]; | 3582 [slider setMinimumValue:0]; |
3663 [slider setContinuous:YES]; | 3583 [slider setContinuous:YES]; |
3664 [slider setTarget:slider]; | 3584 [slider setTarget:slider]; |
3665 [slider setAction:@selector(sliderChanged:)]; | 3585 [slider setAction:@selector(sliderChanged:)]; |
3666 [slider setTag:cid]; | 3586 [slider setTag:cid]; |
3667 return slider; | 3587 return slider; |
3673 * handle: Handle to the slider to be queried. | 3593 * handle: Handle to the slider to be queried. |
3674 */ | 3594 */ |
3675 unsigned int API dw_slider_get_pos(HWND handle) | 3595 unsigned int API dw_slider_get_pos(HWND handle) |
3676 { | 3596 { |
3677 DWSlider *slider = handle; | 3597 DWSlider *slider = handle; |
3678 double val = [slider doubleValue]; | 3598 double val = [slider value]; |
3679 return (int)val; | 3599 return (int)val; |
3680 } | 3600 } |
3681 | 3601 |
3682 /* | 3602 /* |
3683 * Sets the slider position. | 3603 * Sets the slider position. |
3686 * position: Position of the slider withing the range. | 3606 * position: Position of the slider withing the range. |
3687 */ | 3607 */ |
3688 void API dw_slider_set_pos(HWND handle, unsigned int position) | 3608 void API dw_slider_set_pos(HWND handle, unsigned int position) |
3689 { | 3609 { |
3690 DWSlider *slider = handle; | 3610 DWSlider *slider = handle; |
3691 [slider setDoubleValue:(double)position]; | 3611 [slider setValue:(double)position]; |
3692 } | 3612 } |
3693 | 3613 |
3694 /* | 3614 /* |
3695 * Create a new scrollbar window (widget) to be packed. | 3615 * Create a new scrollbar window (widget) to be packed. |
3696 * Parameters: | 3616 * Parameters: |
3744 * id: An ID to be used with dw_window_from_id() or 0L. | 3664 * id: An ID to be used with dw_window_from_id() or 0L. |
3745 */ | 3665 */ |
3746 HWND API dw_percent_new(ULONG cid) | 3666 HWND API dw_percent_new(ULONG cid) |
3747 { | 3667 { |
3748 DWPercent *percent = [[DWPercent alloc] init]; | 3668 DWPercent *percent = [[DWPercent alloc] init]; |
3749 [percent setStyle:DWProgressIndicatorStyleBar]; | |
3750 [percent setBezeled:YES]; | |
3751 [percent setMaxValue:100]; | |
3752 [percent setMinValue:0]; | |
3753 [percent incrementBy:1]; | |
3754 [percent setIndeterminate:NO]; | |
3755 [percent setDoubleValue:0]; | |
3756 /*[percent setTag:cid]; Why doesn't this work? */ | 3669 /*[percent setTag:cid]; Why doesn't this work? */ |
3757 return percent; | 3670 return percent; |
3758 } | 3671 } |
3759 | 3672 |
3760 /* | 3673 /* |
3772 DWPercent *percent = handle; | 3685 DWPercent *percent = handle; |
3773 | 3686 |
3774 /* Handle indeterminate */ | 3687 /* Handle indeterminate */ |
3775 if(position == DW_PERCENT_INDETERMINATE) | 3688 if(position == DW_PERCENT_INDETERMINATE) |
3776 { | 3689 { |
3777 [percent setIndeterminate:YES]; | 3690 [percent setProgress:0 animated:NO]; |
3778 [percent startAnimation:percent]; | |
3779 } | 3691 } |
3780 else | 3692 else |
3781 { | 3693 { |
3782 /* Handle normal */ | 3694 /* Handle normal */ |
3783 if([percent isIndeterminate]) | 3695 [percent setProgress:(float)position/100.0 animated:YES]; |
3784 { | |
3785 [percent stopAnimation:percent]; | |
3786 [percent setIndeterminate:NO]; | |
3787 } | |
3788 [percent setDoubleValue:(double)position]; | |
3789 } | 3696 } |
3790 DW_FUNCTION_RETURN_NOTHING; | 3697 DW_FUNCTION_RETURN_NOTHING; |
3791 } | 3698 } |
3792 | 3699 |
3793 /* | 3700 /* |
3824 * handle: Handle to the checkbox to be queried. | 3731 * handle: Handle to the checkbox to be queried. |
3825 * value: TRUE for checked, FALSE for unchecked. | 3732 * value: TRUE for checked, FALSE for unchecked. |
3826 */ | 3733 */ |
3827 void API dw_checkbox_set(HWND handle, int value) | 3734 void API dw_checkbox_set(HWND handle, int value) |
3828 { | 3735 { |
3736 #if 0 /* TODO: Convert to UISwitch */ | |
3829 DWButton *button = handle; | 3737 DWButton *button = handle; |
3830 if(value) | 3738 if(value) |
3831 { | 3739 { |
3832 [button setState:DWControlStateValueOn]; | 3740 [button setState:DWControlStateValueOn]; |
3833 } | 3741 } |
3834 else | 3742 else |
3835 { | 3743 { |
3836 [button setState:DWControlStateValueOff]; | 3744 [button setState:DWControlStateValueOff]; |
3837 } | 3745 } |
3838 | 3746 #endif |
3839 } | 3747 } |
3840 | 3748 |
3841 /* Internal common function to create containers and listboxes */ | 3749 /* Internal common function to create containers and listboxes */ |
3842 HWND _dw_cont_new(ULONG cid, int multi) | 3750 HWND _dw_cont_new(ULONG cid, int multi) |
3843 { | 3751 { |
3844 DWFocusRingScrollView *scrollview = [[DWFocusRingScrollView alloc] init]; | |
3845 DWContainer *cont = [[DWContainer alloc] init]; | 3752 DWContainer *cont = [[DWContainer alloc] init]; |
3846 | 3753 |
3847 [cont setScrollview:scrollview]; | |
3848 [scrollview setBorderType:NSBezelBorder]; | |
3849 [scrollview setHasVerticalScroller:YES]; | |
3850 [scrollview setAutohidesScrollers:YES]; | |
3851 [cont setAllowsMultipleSelection:(multi ? YES : NO)]; | 3754 [cont setAllowsMultipleSelection:(multi ? YES : NO)]; |
3852 [cont setAllowsColumnReordering:NO]; | |
3853 [cont setDataSource:cont]; | 3755 [cont setDataSource:cont]; |
3854 [cont setDelegate:cont]; | 3756 [cont setDelegate:cont]; |
3855 [scrollview setDocumentView:cont]; | |
3856 [cont setTag:cid]; | 3757 [cont setTag:cid]; |
3857 [cont autorelease]; | 3758 [cont autorelease]; |
3858 [cont setRowBgOdd:DW_RGB_TRANSPARENT andEven:DW_RGB_TRANSPARENT]; | 3759 [cont setRowBgOdd:DW_RGB_TRANSPARENT andEven:DW_RGB_TRANSPARENT]; |
3859 return cont; | 3760 return cont; |
3860 } | 3761 } |
3870 DW_FUNCTION_RETURN(dw_listbox_new, HWND) | 3771 DW_FUNCTION_RETURN(dw_listbox_new, HWND) |
3871 DW_FUNCTION_RESTORE_PARAM2(cid, ULONG, multi, int) | 3772 DW_FUNCTION_RESTORE_PARAM2(cid, ULONG, multi, int) |
3872 { | 3773 { |
3873 DW_FUNCTION_INIT; | 3774 DW_FUNCTION_INIT; |
3874 DWContainer *cont = _dw_cont_new(cid, multi); | 3775 DWContainer *cont = _dw_cont_new(cid, multi); |
3875 [cont setHeaderView:nil]; | |
3876 int type = DW_CFA_STRING; | |
3877 [cont setup]; | 3776 [cont setup]; |
3878 NSTableColumn *column = [[[NSTableColumn alloc] initWithIdentifier:@"_DWListboxColumn"] autorelease]; | |
3879 [column setEditable:NO]; | |
3880 [cont addTableColumn:column]; | |
3881 [cont addColumn:column andType:type]; | |
3882 DW_FUNCTION_RETURN_THIS(cont); | 3777 DW_FUNCTION_RETURN_THIS(cont); |
3883 } | 3778 } |
3884 | 3779 |
3885 /* | 3780 /* |
3886 * Appends the specified text to the listbox's (or combobox) entry list. | 3781 * Appends the specified text to the listbox's (or combobox) entry list. |
4031 id object = handle; | 3926 id object = handle; |
4032 | 3927 |
4033 if([object isMemberOfClass:[DWContainer class]]) | 3928 if([object isMemberOfClass:[DWContainer class]]) |
4034 { | 3929 { |
4035 DWContainer *cont = handle; | 3930 DWContainer *cont = handle; |
4036 | 3931 NSIndexPath *myIP = [NSIndexPath indexPathForRow:top inSection:0]; |
4037 [cont scrollRowToVisible:top]; | 3932 |
3933 [cont scrollToRowAtIndexPath:myIP atScrollPosition:UITableViewScrollPositionNone animated:NO]; | |
4038 } | 3934 } |
4039 DW_FUNCTION_RETURN_NOTHING; | 3935 DW_FUNCTION_RETURN_NOTHING; |
4040 } | 3936 } |
4041 | 3937 |
4042 /* | 3938 /* |
4064 { | 3960 { |
4065 *buffer = '\0'; | 3961 *buffer = '\0'; |
4066 } | 3962 } |
4067 else | 3963 else |
4068 { | 3964 { |
4069 NSTableCellView *cell = [cont getRow:index and:0]; | 3965 UITableViewCell *cell = [cont getRow:index and:0]; |
4070 NSString *nstr = [[cell textField] stringValue]; | 3966 NSString *nstr; |
3967 | |
3968 if(@available(iOS 14.0, *)) | |
3969 { | |
3970 UIListContentConfiguration *content = [cell defaultContentConfiguration]; | |
3971 | |
3972 nstr = [content text]; | |
3973 } | |
3974 else | |
3975 { | |
3976 nstr = [cell text]; | |
3977 } | |
4071 | 3978 |
4072 strncpy(buffer, [nstr UTF8String], length - 1); | 3979 strncpy(buffer, [nstr UTF8String], length - 1); |
4073 } | 3980 } |
4074 } | 3981 } |
4075 DW_FUNCTION_RETURN_NOTHING; | 3982 DW_FUNCTION_RETURN_NOTHING; |
4096 int count = (int)[cont numberOfRowsInTableView:cont]; | 4003 int count = (int)[cont numberOfRowsInTableView:cont]; |
4097 | 4004 |
4098 if(index <= count) | 4005 if(index <= count) |
4099 { | 4006 { |
4100 NSString *nstr = [NSString stringWithUTF8String:buffer]; | 4007 NSString *nstr = [NSString stringWithUTF8String:buffer]; |
4101 NSTableCellView *cell = [cont getRow:index and:0]; | 4008 UITableViewCell *cell = [cont getRow:index and:0]; |
4102 | 4009 |
4103 [[cell textField] setStringValue:nstr]; | 4010 if(@available(iOS 14.0, *)) |
4011 { | |
4012 UIListContentConfiguration *content = [cell defaultContentConfiguration]; | |
4013 | |
4014 [content setText:nstr]; | |
4015 } | |
4016 else | |
4017 { | |
4018 [cell setText:nstr]; | |
4019 } | |
4104 [cont reloadData]; | 4020 [cont reloadData]; |
4105 [cont setNeedsDisplay]; | 4021 [cont setNeedsDisplay]; |
4106 } | 4022 } |
4107 } | 4023 } |
4108 DW_FUNCTION_RETURN_NOTHING; | 4024 DW_FUNCTION_RETURN_NOTHING; |
4123 int result = -1; | 4039 int result = -1; |
4124 | 4040 |
4125 if([object isMemberOfClass:[DWContainer class]]) | 4041 if([object isMemberOfClass:[DWContainer class]]) |
4126 { | 4042 { |
4127 DWContainer *cont = handle; | 4043 DWContainer *cont = handle; |
4128 result = (int)[cont indexPathForSelectedRow].row; | 4044 NSIndexPath *ip = [cont indexPathForSelectedRow]; |
4045 | |
4046 if(ip) | |
4047 result = (int)ip.row; | |
4129 } | 4048 } |
4130 DW_FUNCTION_RETURN_THIS(result); | 4049 DW_FUNCTION_RETURN_THIS(result); |
4131 } | 4050 } |
4132 | 4051 |
4133 /* | 4052 /* |
4145 id object = handle; | 4064 id object = handle; |
4146 int retval = -1; | 4065 int retval = -1; |
4147 | 4066 |
4148 if([object isMemberOfClass:[DWContainer class]]) | 4067 if([object isMemberOfClass:[DWContainer class]]) |
4149 { | 4068 { |
4150 NSUInteger result; | |
4151 DWContainer *cont = handle; | 4069 DWContainer *cont = handle; |
4152 NSArray *selected = [cont indexPathsForSelectedRows]; | 4070 NSArray *selected = [cont indexPathsForSelectedRows]; |
4153 if(where == -1) | 4071 NSIndexPath *ip = [selected objectAtIndex:(where == -1 ? 0 :where)]; |
4154 result = [selected objectAtIndex:0]; | 4072 |
4155 else | 4073 if(ip) |
4156 result = [selected objectAtIndex:where]; | 4074 retval = (int)ip.row; |
4157 | |
4158 if(result) | |
4159 { | |
4160 retval = (int)result; | |
4161 } | |
4162 } | 4075 } |
4163 DW_FUNCTION_RETURN_THIS(retval) | 4076 DW_FUNCTION_RETURN_THIS(retval) |
4164 } | 4077 } |
4165 | 4078 |
4166 /* | 4079 /* |
4168 * Parameters: | 4081 * Parameters: |
4169 * handle: Handle to the listbox to be set. | 4082 * handle: Handle to the listbox to be set. |
4170 * index: Item index. | 4083 * index: Item index. |
4171 * state: TRUE if selected FALSE if unselected. | 4084 * state: TRUE if selected FALSE if unselected. |
4172 */ | 4085 */ |
4173 DW_FUNCTION_DEFINITION(dw_listbox_select, void, HWND handle, int index, int state) | 4086 DW_FUNCTION_DEFINITION(dw_listbox_select, void, HWND handle, int index, DW_UNUSED(int state)) |
4174 DW_FUNCTION_ADD_PARAM3(handle, index, state) | 4087 DW_FUNCTION_ADD_PARAM3(handle, index, state) |
4175 DW_FUNCTION_NO_RETURN(dw_listbox_select) | 4088 DW_FUNCTION_NO_RETURN(dw_listbox_select) |
4176 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, index, int, state, int) | 4089 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, index, int, DW_UNUSED(state), int) |
4177 { | 4090 { |
4178 DW_FUNCTION_INIT; | 4091 DW_FUNCTION_INIT; |
4179 id object = handle; | 4092 id object = handle; |
4180 | 4093 |
4181 if([object isMemberOfClass:[DWContainer class]]) | 4094 if([object isMemberOfClass:[DWContainer class]]) |
4182 { | 4095 { |
4183 DWContainer *cont = handle; | 4096 DWContainer *cont = handle; |
4184 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)index]; | 4097 NSIndexPath *ip = [NSIndexPath indexPathForRow:index inSection:0]; |
4185 | 4098 |
4186 [cont selectRowIndexes:selected byExtendingSelection:YES]; | 4099 [cont selectRowAtIndexPath:ip |
4187 [selected release]; | 4100 animated:NO |
4101 scrollPosition:UITableViewScrollPositionNone]; | |
4188 } | 4102 } |
4189 DW_FUNCTION_RETURN_NOTHING; | 4103 DW_FUNCTION_RETURN_NOTHING; |
4190 } | 4104 } |
4191 | 4105 |
4192 /* | 4106 /* |
4218 * Create a new Combobox window (widget) to be packed. | 4132 * Create a new Combobox window (widget) to be packed. |
4219 * Parameters: | 4133 * Parameters: |
4220 * text: The default text to be in the combpbox widget. | 4134 * text: The default text to be in the combpbox widget. |
4221 * id: An ID to be used with dw_window_from_id() or 0L. | 4135 * id: An ID to be used with dw_window_from_id() or 0L. |
4222 */ | 4136 */ |
4223 HWND API dw_combobox_new, HWND, const char *text, ULONG cid); | 4137 HWND API dw_combobox_new(const char *text, ULONG cid) |
4224 { | 4138 { |
4225 /* TODO: Implment comboboxes. https://www.codeproject.com/Articles/301681/iPhone-ComboBox */ | 4139 /* TODO: Implment comboboxes. https://www.codeproject.com/Articles/301681/iPhone-ComboBox */ |
4226 return 0; | 4140 return 0; |
4227 } | 4141 } |
4228 | 4142 |
4233 */ | 4147 */ |
4234 HWND API dw_mle_new(ULONG cid) | 4148 HWND API dw_mle_new(ULONG cid) |
4235 { | 4149 { |
4236 DWMLE *mle = [[DWMLE alloc] init]; | 4150 DWMLE *mle = [[DWMLE alloc] init]; |
4237 UIScrollView *scrollview = [[UIScrollView alloc] init]; | 4151 UIScrollView *scrollview = [[UIScrollView alloc] init]; |
4238 CGSize size = [mle maxSize]; | 4152 CGSize size = [mle intrinsicContentSize]; |
4239 | 4153 |
4240 size.width = size.height; | 4154 size.width = size.height; |
4241 [mle setMaxSize:size]; | 4155 [mle setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth]; |
4242 [scrollview setBorderType:NSBezelBorder]; | |
4243 [scrollview setHasVerticalScroller:YES]; | |
4244 [scrollview setAutohidesScrollers:YES]; | |
4245 [scrollview setAutoresizingMask:UIViewWidthSizable|UIViewHeightSizable]; | |
4246 [scrollview setDocumentView:mle]; | |
4247 [mle setVerticallyResizable:YES]; | |
4248 [mle setAutoresizingMask:UIViewWidthSizable|UIViewHeightSizable]; | |
4249 [mle setScrollview:scrollview]; | 4156 [mle setScrollview:scrollview]; |
4250 [mle setAutomaticQuoteSubstitutionEnabled:NO]; | |
4251 [mle setAutomaticDashSubstitutionEnabled:NO]; | |
4252 [mle setAutomaticTextReplacementEnabled:NO]; | |
4253 /* [mle setTag:cid]; Why doesn't this work? */ | 4157 /* [mle setTag:cid]; Why doesn't this work? */ |
4254 [mle autorelease]; | 4158 [mle autorelease]; |
4255 return mle; | 4159 return mle; |
4256 } | 4160 } |
4257 | 4161 |
4270 DW_FUNCTION_INIT; | 4174 DW_FUNCTION_INIT; |
4271 DWMLE *mle = handle; | 4175 DWMLE *mle = handle; |
4272 unsigned int retval; | 4176 unsigned int retval; |
4273 NSTextStorage *ts = [mle textStorage]; | 4177 NSTextStorage *ts = [mle textStorage]; |
4274 NSString *nstr = [NSString stringWithUTF8String:buffer]; | 4178 NSString *nstr = [NSString stringWithUTF8String:buffer]; |
4275 UIColor *fgcolor = [ts foregroundColor]; | 4179 NSAttributedString *nastr = [[NSAttributedString alloc] initWithString:nstr]; |
4276 UIFont *font = [ts font]; | |
4277 NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init]; | |
4278 [attributes setObject:(fgcolor ? fgcolor : [UIColor textColor]) forKey:NSForegroundColorAttributeName]; | |
4279 if(font) | |
4280 [attributes setObject:font forKey:UIFontAttributeName]; | |
4281 NSAttributedString *nastr = [[NSAttributedString alloc] initWithString:nstr attributes:attributes]; | |
4282 NSUInteger length = [ts length]; | 4180 NSUInteger length = [ts length]; |
4283 if(startpoint < 0) | 4181 if(startpoint < 0) |
4284 startpoint = 0; | 4182 startpoint = 0; |
4285 if(startpoint > length) | 4183 if(startpoint > length) |
4286 startpoint = (int)length; | 4184 startpoint = (int)length; |
4440 * handle: Handle to the MLE. | 4338 * handle: Handle to the MLE. |
4441 * state: TRUE if it wraps, FALSE if it doesn't. | 4339 * state: TRUE if it wraps, FALSE if it doesn't. |
4442 */ | 4340 */ |
4443 void API dw_mle_set_word_wrap(HWND handle, int state) | 4341 void API dw_mle_set_word_wrap(HWND handle, int state) |
4444 { | 4342 { |
4445 DWMLE *mle = handle; | 4343 /* TODO: Figure out how to do this in iOS */ |
4446 UIScrollView *sv = [mle scrollview]; | |
4447 | |
4448 if(state) | |
4449 { | |
4450 CGSize newsize = NSMakeSize([sv contentSize].width,[mle maxSize].height); | |
4451 CGRect newrect = NSMakeRect(0, 0, [sv contentSize].width, 0); | |
4452 | |
4453 [[mle textContainer] setWidthTracksTextView:YES]; | |
4454 [mle setFrame:newrect]; | |
4455 [[mle textContainer] setContainerSize:newsize]; | |
4456 [mle setHorizontallyResizable:NO]; | |
4457 [sv setHasHorizontalScroller:NO]; | |
4458 } | |
4459 else | |
4460 { | |
4461 [[mle textContainer] setWidthTracksTextView:NO]; | |
4462 [[mle textContainer] setContainerSize:[mle maxSize]]; | |
4463 [mle setHorizontallyResizable:YES]; | |
4464 [sv setHasHorizontalScroller:YES]; | |
4465 } | |
4466 } | 4344 } |
4467 | 4345 |
4468 /* | 4346 /* |
4469 * Sets the word auto complete state of an MLE box. | 4347 * Sets the word auto complete state of an MLE box. |
4470 * Parameters: | 4348 * Parameters: |
4471 * handle: Handle to the MLE. | 4349 * handle: Handle to the MLE. |
4472 * state: Bitwise combination of DW_MLE_COMPLETE_TEXT/DASH/QUOTE | 4350 * state: Bitwise combination of DW_MLE_COMPLETE_TEXT/DASH/QUOTE |
4473 */ | 4351 */ |
4474 void API dw_mle_set_auto_complete(HWND handle, int state) | 4352 void API dw_mle_set_auto_complete(HWND handle, int state) |
4475 { | 4353 { |
4476 DWMLE *mle = handle; | 4354 /* TODO: Figure out how to do this in iOS */ |
4477 [mle setAutomaticQuoteSubstitutionEnabled:(state & DW_MLE_COMPLETE_QUOTE ? YES : NO)]; | |
4478 [mle setAutomaticDashSubstitutionEnabled:(state & DW_MLE_COMPLETE_DASH ? YES : NO)]; | |
4479 [mle setAutomaticTextReplacementEnabled:(state & DW_MLE_COMPLETE_TEXT ? YES : NO)]; | |
4480 } | 4355 } |
4481 | 4356 |
4482 /* | 4357 /* |
4483 * Sets the current cursor position of an MLE box. | 4358 * Sets the current cursor position of an MLE box. |
4484 * Parameters: | 4359 * Parameters: |
4560 * text: The text to be display by the static text widget. | 4435 * text: The text to be display by the static text widget. |
4561 * id: An ID to be used with dw_window_from_id() or 0L. | 4436 * id: An ID to be used with dw_window_from_id() or 0L. |
4562 */ | 4437 */ |
4563 HWND API dw_status_text_new(const char *text, ULONG cid) | 4438 HWND API dw_status_text_new(const char *text, ULONG cid) |
4564 { | 4439 { |
4565 NSBox *border = [[NSBox alloc] init]; | 4440 return dw_text_new(text, cid); |
4566 UITextField *textfield = dw_text_new(text, cid); | |
4567 | |
4568 [border setTitlePosition:NSNoTitle]; | |
4569 [border setContentView:textfield]; | |
4570 [border setContentViewMargins:NSMakeSize(1.5,1.5)]; | |
4571 [textfield autorelease]; | |
4572 [textfield setBackgroundColor:[UIColor clearColor]]; | |
4573 [[textfield cell] setVCenter:YES]; | |
4574 return border; | |
4575 } | 4441 } |
4576 | 4442 |
4577 /* | 4443 /* |
4578 * Create a new static text window (widget) to be packed. | 4444 * Create a new static text window (widget) to be packed. |
4579 * Parameters: | 4445 * Parameters: |
4581 * id: An ID to be used with dw_window_from_id() or 0L. | 4447 * id: An ID to be used with dw_window_from_id() or 0L. |
4582 */ | 4448 */ |
4583 HWND API dw_text_new(const char *text, ULONG cid) | 4449 HWND API dw_text_new(const char *text, ULONG cid) |
4584 { | 4450 { |
4585 DWText *textfield = [[DWText alloc] init]; | 4451 DWText *textfield = [[DWText alloc] init]; |
4586 [textfield setEditable:NO]; | 4452 [textfield setText:[NSString stringWithUTF8String:text]]; |
4587 [textfield setSelectable:NO]; | |
4588 [textfield setBordered:NO]; | |
4589 [textfield setDrawsBackground:NO]; | |
4590 [textfield setStringValue:[ NSString stringWithUTF8String:text ]]; | |
4591 [textfield setTag:cid]; | 4453 [textfield setTag:cid]; |
4592 if(DWDefaultFont) | 4454 if(DWDefaultFont) |
4593 { | 4455 { |
4594 [[textfield cell] setFont:DWDefaultFont]; | 4456 [textfield setFont:DWDefaultFont]; |
4595 } | 4457 } |
4596 [[textfield cell] setWraps:NO]; | |
4597 return textfield; | 4458 return textfield; |
4598 } | 4459 } |
4599 | 4460 |
4600 /* | 4461 /* |
4601 * Creates a rendering context widget (window) to be packed. | 4462 * Creates a rendering context widget (window) to be packed. |
4640 UIColor *newcolor; | 4501 UIColor *newcolor; |
4641 DW_LOCAL_POOL_IN; | 4502 DW_LOCAL_POOL_IN; |
4642 | 4503 |
4643 _foreground = _get_color(value); | 4504 _foreground = _get_color(value); |
4644 | 4505 |
4645 newcolor = [[UIColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: | 4506 newcolor = [[UIColor colorWithRed: DW_RED_VALUE(_foreground)/255.0 green: |
4646 DW_GREEN_VALUE(_foreground)/255.0 blue: | 4507 DW_GREEN_VALUE(_foreground)/255.0 blue: |
4647 DW_BLUE_VALUE(_foreground)/255.0 alpha: 1] retain]; | 4508 DW_BLUE_VALUE(_foreground)/255.0 alpha: 1] retain]; |
4648 pthread_setspecific(_dw_fg_color_key, newcolor); | 4509 pthread_setspecific(_dw_fg_color_key, newcolor); |
4649 [oldcolor release]; | 4510 [oldcolor release]; |
4650 DW_LOCAL_POOL_OUT; | 4511 DW_LOCAL_POOL_OUT; |
4651 } | 4512 } |
4652 | 4513 |
4668 } | 4529 } |
4669 else | 4530 else |
4670 { | 4531 { |
4671 _background = _get_color(value); | 4532 _background = _get_color(value); |
4672 | 4533 |
4673 newcolor = [[UIColor colorWithDeviceRed: DW_RED_VALUE(_background)/255.0 green: | 4534 newcolor = [[UIColor colorWithRed: DW_RED_VALUE(_background)/255.0 green: |
4674 DW_GREEN_VALUE(_background)/255.0 blue: | 4535 DW_GREEN_VALUE(_background)/255.0 blue: |
4675 DW_BLUE_VALUE(_background)/255.0 alpha: 1] retain]; | 4536 DW_BLUE_VALUE(_background)/255.0 alpha: 1] retain]; |
4676 pthread_setspecific(_dw_bg_color_key, newcolor); | 4537 pthread_setspecific(_dw_bg_color_key, newcolor); |
4677 } | 4538 } |
4678 [oldcolor release]; | 4539 [oldcolor release]; |
4679 DW_LOCAL_POOL_OUT; | 4540 DW_LOCAL_POOL_OUT; |
4680 } | 4541 } |
4685 * Returns: | 4546 * Returns: |
4686 * The selected color or the current color if cancelled. | 4547 * The selected color or the current color if cancelled. |
4687 */ | 4548 */ |
4688 unsigned long API dw_color_choose(unsigned long value) | 4549 unsigned long API dw_color_choose(unsigned long value) |
4689 { | 4550 { |
4551 #if 0 /* TODO: Implement this with UIColorPickerViewController */ | |
4690 /* Create the Color Chooser Dialog class. */ | 4552 /* Create the Color Chooser Dialog class. */ |
4691 DWColorChoose *colorDlg; | 4553 DWColorChoose *colorDlg; |
4692 DWDialog *dialog; | 4554 DWDialog *dialog; |
4693 DW_LOCAL_POOL_IN; | 4555 DW_LOCAL_POOL_IN; |
4694 | 4556 |
4724 /* Figure out the value of what they returned */ | 4586 /* Figure out the value of what they returned */ |
4725 CGFloat red, green, blue; | 4587 CGFloat red, green, blue; |
4726 [color getRed:&red green:&green blue:&blue alpha:NULL]; | 4588 [color getRed:&red green:&green blue:&blue alpha:NULL]; |
4727 value = DW_RGB((int)(red * 255), (int)(green *255), (int)(blue *255)); | 4589 value = DW_RGB((int)(red * 255), (int)(green *255), (int)(blue *255)); |
4728 DW_LOCAL_POOL_OUT; | 4590 DW_LOCAL_POOL_OUT; |
4591 #endif | |
4729 return value; | 4592 return value; |
4730 } | 4593 } |
4731 | 4594 |
4732 CGContextRef _dw_draw_context(UIImage *image) | 4595 CGContextRef _dw_draw_context(UIImage *image) |
4733 { | 4596 { |
5950 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, flags, unsigned long) | 5813 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, flags, unsigned long) |
5951 { | 5814 { |
5952 DW_FUNCTION_INIT; | 5815 DW_FUNCTION_INIT; |
5953 DWContainer *cont = handle; | 5816 DWContainer *cont = handle; |
5954 NSArray *selected = [cont indexPathsForSelectedRows]; | 5817 NSArray *selected = [cont indexPathsForSelectedRows]; |
5955 NSIndexPath *result = [selected objectAtIndex:0]; | 5818 NSIndexPath *result = [selected firstObject]; |
5956 void *retval = NULL; | 5819 void *retval = NULL; |
5957 | 5820 |
5958 if(result) | 5821 if(result) |
5959 { | 5822 { |
5960 if(flags & DW_CR_RETDATA) | 5823 if(flags & DW_CR_RETDATA) |
6365 float API dw_splitbar_get(HWND handle) | 6228 float API dw_splitbar_get(HWND handle) |
6366 { | 6229 { |
6367 DWSplitBar *split = handle; | 6230 DWSplitBar *split = handle; |
6368 CGRect rect1 = [split frame]; | 6231 CGRect rect1 = [split frame]; |
6369 NSArray *subviews = [split subviews]; | 6232 NSArray *subviews = [split subviews]; |
6370 UIView *view = [subviews objectAtIndex:0]; | 6233 UIView *view = [subviews firstObject]; |
6371 CGRect rect2 = [view frame]; | 6234 CGRect rect2 = [view frame]; |
6372 float pos, total, retval = 0.0; | 6235 float pos, total, retval = 0.0; |
6373 if([split isVertical]) | 6236 if([split isVertical]) |
6374 { | 6237 { |
6375 total = rect1.size.width; | 6238 total = rect1.size.width; |
7210 */ | 7073 */ |
7211 HWND API dw_notebook_new(ULONG cid, int top) | 7074 HWND API dw_notebook_new(ULONG cid, int top) |
7212 { | 7075 { |
7213 DWNotebook *notebook = [[DWNotebook alloc] init]; | 7076 DWNotebook *notebook = [[DWNotebook alloc] init]; |
7214 [notebook setDelegate:notebook]; | 7077 [notebook setDelegate:notebook]; |
7078 [notebook addTarget:notebook | |
7079 action:@selector(pageChanged:) | |
7080 forControlEvents:UIControlEventValueChanged]; | |
7215 /* [notebook setTag:cid]; Why doesn't this work? */ | 7081 /* [notebook setTag:cid]; Why doesn't this work? */ |
7216 return notebook; | 7082 return notebook; |
7217 } | 7083 } |
7218 | 7084 |
7219 /* | 7085 /* |