Mercurial > dwindows
comparison ios/dw.m @ 2416:353581ebf4a5
iOS: Fix display of widgets. DWMLE and DWContainer are subclasses of UIScrollView.
On MacOS we had to place them inside a NSScrollView, which is unnecessary on
iOS, thus the scrollView method was returning nil preventing packing of
those type widgets. Also fix UIScrollViewCell text and image creation.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 03 Apr 2021 00:14:05 +0000 |
parents | f33a81fa29e9 |
children | ccfc4ee9c4a7 |
comparison
equal
deleted
inserted
replaced
2415:f33a81fa29e9 | 2416:353581ebf4a5 |
---|---|
197 { | 197 { |
198 char *file = alloca(strlen(filename) + 6); | 198 char *file = alloca(strlen(filename) + 6); |
199 int found_ext = 0,i; | 199 int found_ext = 0,i; |
200 | 200 |
201 /* Try various extentions */ | 201 /* Try various extentions */ |
202 for ( i = 0; i < NUM_EXTS; i++ ) | 202 for(i = 0; i < NUM_EXTS; i++) |
203 { | 203 { |
204 strcpy( file, filename ); | 204 strcpy(file, filename); |
205 strcat( file, _dw_image_exts[i] ); | 205 strcat(file, _dw_image_exts[i]); |
206 if ( access( file, R_OK ) == 0 ) | 206 if(access(file, R_OK ) == 0) |
207 { | 207 { |
208 found_ext = 1; | 208 found_ext = 1; |
209 break; | 209 break; |
210 } | 210 } |
211 } | 211 } |
212 if ( found_ext == 1 ) | 212 if(found_ext == 1) |
213 { | 213 { |
214 return _dw_image_exts[i]; | 214 return _dw_image_exts[i]; |
215 } | 215 } |
216 return NULL; | 216 return NULL; |
217 } | 217 } |
303 typedef struct | 303 typedef struct |
304 { | 304 { |
305 ULONG message; | 305 ULONG message; |
306 char name[30]; | 306 char name[30]; |
307 | 307 |
308 } SignalList; | 308 } DWSignalList; |
309 | 309 |
310 /* List of signals */ | 310 /* List of signals */ |
311 #define SIGNALMAX 19 | 311 #define SIGNALMAX 19 |
312 | 312 |
313 static SignalList DWSignalTranslate[SIGNALMAX] = { | 313 static DWSignalList DWSignalTranslate[SIGNALMAX] = { |
314 { 1, DW_SIGNAL_CONFIGURE }, | 314 { 1, DW_SIGNAL_CONFIGURE }, |
315 { 2, DW_SIGNAL_KEY_PRESS }, | 315 { 2, DW_SIGNAL_KEY_PRESS }, |
316 { 3, DW_SIGNAL_BUTTON_PRESS }, | 316 { 3, DW_SIGNAL_BUTTON_PRESS }, |
317 { 4, DW_SIGNAL_BUTTON_RELEASE }, | 317 { 4, DW_SIGNAL_BUTTON_RELEASE }, |
318 { 5, DW_SIGNAL_MOTION_NOTIFY }, | 318 { 5, DW_SIGNAL_MOTION_NOTIFY }, |
581 static NSMutableArray *_DWDirtyDrawables; | 581 static NSMutableArray *_DWDirtyDrawables; |
582 static DWTID DWThread = (DWTID)-1; | 582 static DWTID DWThread = (DWTID)-1; |
583 static HEV DWMainEvent; | 583 static HEV DWMainEvent; |
584 | 584 |
585 /* Used for doing bitblts from the main thread */ | 585 /* Used for doing bitblts from the main thread */ |
586 typedef struct _bitbltinfo | 586 typedef struct _dw_bitbltinfo |
587 { | 587 { |
588 id src; | 588 id src; |
589 id dest; | 589 id dest; |
590 int xdest; | 590 int xdest; |
591 int ydest; | 591 int ydest; |
1017 /* Unhide our hidden window and make it key */ | 1017 /* Unhide our hidden window and make it key */ |
1018 [hiddenWindow setHidden:NO]; | 1018 [hiddenWindow setHidden:NO]; |
1019 [hiddenWindow makeKeyAndVisible]; | 1019 [hiddenWindow makeKeyAndVisible]; |
1020 [delegate setDialog:dialog]; | 1020 [delegate setDialog:dialog]; |
1021 [picker setDelegate:delegate]; | 1021 [picker setDelegate:delegate]; |
1022 /* Wait for them to pick a color */ | 1022 /* Wait for them to pick a font */ |
1023 [[hiddenWindow rootViewController] presentViewController:picker animated:YES completion:nil]; | 1023 [[hiddenWindow rootViewController] presentViewController:picker animated:YES completion:nil]; |
1024 font = dw_dialog_wait(dialog); | 1024 font = dw_dialog_wait(dialog); |
1025 /* Once the dialog is gone we can rehide our window */ | 1025 /* Once the dialog is gone we can rehide our window */ |
1026 [hiddenWindow resignKeyWindow]; | 1026 [hiddenWindow resignKeyWindow]; |
1027 [hiddenWindow setHidden:YES]; | 1027 [hiddenWindow setHidden:YES]; |
1065 /* Unhide our hidden window and make it key */ | 1065 /* Unhide our hidden window and make it key */ |
1066 [hiddenWindow setHidden:NO]; | 1066 [hiddenWindow setHidden:NO]; |
1067 [hiddenWindow makeKeyAndVisible]; | 1067 [hiddenWindow makeKeyAndVisible]; |
1068 [delegate setDialog:dialog]; | 1068 [delegate setDialog:dialog]; |
1069 [picker setDelegate:delegate]; | 1069 [picker setDelegate:delegate]; |
1070 /* Wait for them to pick a color */ | 1070 /* Wait for them to pick a file */ |
1071 [[hiddenWindow rootViewController] presentViewController:picker animated:YES completion:nil]; | 1071 [[hiddenWindow rootViewController] presentViewController:picker animated:YES completion:nil]; |
1072 file = dw_dialog_wait(dialog); | 1072 file = dw_dialog_wait(dialog); |
1073 /* Once the dialog is gone we can rehide our window */ | 1073 /* Once the dialog is gone we can rehide our window */ |
1074 [hiddenWindow resignKeyWindow]; | 1074 [hiddenWindow resignKeyWindow]; |
1075 [hiddenWindow setHidden:YES]; | 1075 [hiddenWindow setHidden:YES]; |
1665 | 1665 |
1666 /* Subclass for a MLE type */ | 1666 /* Subclass for a MLE type */ |
1667 @interface DWMLE : UITextView | 1667 @interface DWMLE : UITextView |
1668 { | 1668 { |
1669 void *userdata; | 1669 void *userdata; |
1670 id scrollview; | |
1671 } | 1670 } |
1672 -(void *)userdata; | 1671 -(void *)userdata; |
1673 -(void)setUserdata:(void *)input; | 1672 -(void)setUserdata:(void *)input; |
1674 -(id)scrollview; | |
1675 -(void)setScrollview:(id)input; | |
1676 @end | 1673 @end |
1677 | 1674 |
1678 @implementation DWMLE | 1675 @implementation DWMLE |
1679 -(void *)userdata { return userdata; } | 1676 -(void *)userdata { return userdata; } |
1680 -(void)setUserdata:(void *)input { userdata = input; } | 1677 -(void)setUserdata:(void *)input { userdata = input; } |
1681 -(id)scrollview { return scrollview; } | |
1682 -(void)setScrollview:(id)input { scrollview = input; } | |
1683 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } | 1678 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } |
1684 @end | 1679 @end |
1685 | 1680 |
1686 /* TODO: UITableView does not support variable columns... | 1681 /* TODO: UITableView does not support variable columns... |
1687 * also OutlineView does not exist in iOS. | 1682 * also OutlineView does not exist in iOS. |
1690 { | 1685 { |
1691 UITableViewCell *browsercell = [[[UITableViewCell alloc] init] autorelease]; | 1686 UITableViewCell *browsercell = [[[UITableViewCell alloc] init] autorelease]; |
1692 [browsercell setAutoresizesSubviews:YES]; | 1687 [browsercell setAutoresizesSubviews:YES]; |
1693 | 1688 |
1694 if(icon) | 1689 if(icon) |
1695 { | 1690 [[browsercell imageView] setImage:icon]; |
1696 if(@available(iOS 14.0, *)) | |
1697 { | |
1698 UIListContentConfiguration *content = [browsercell defaultContentConfiguration]; | |
1699 | |
1700 [content setImage:icon]; | |
1701 } | |
1702 else | |
1703 { | |
1704 [browsercell setImage:icon]; | |
1705 } | |
1706 } | |
1707 if(text) | 1691 if(text) |
1708 { | 1692 [[browsercell textLabel] setText:text]; |
1709 if(@available(iOS 14.0, *)) | |
1710 { | |
1711 UIListContentConfiguration *content = [browsercell defaultContentConfiguration]; | |
1712 | |
1713 [content setText:text]; | |
1714 } | |
1715 else | |
1716 { | |
1717 [browsercell setText:text]; | |
1718 } | |
1719 } | |
1720 return browsercell; | 1693 return browsercell; |
1721 } | 1694 } |
1722 | 1695 |
1723 /* Subclass for a Container/List type */ | 1696 /* Subclass for a Container/List type */ |
1724 @interface DWContainer : UITableView <UITableViewDataSource,UITableViewDelegate> | 1697 @interface DWContainer : UITableView <UITableViewDataSource,UITableViewDelegate> |
1731 NSPointerArray *rowdatas; | 1704 NSPointerArray *rowdatas; |
1732 UIColor *fgcolor, *oddcolor, *evencolor; | 1705 UIColor *fgcolor, *oddcolor, *evencolor; |
1733 unsigned long dw_oddcolor, dw_evencolor; | 1706 unsigned long dw_oddcolor, dw_evencolor; |
1734 unsigned long _DW_COLOR_ROW_ODD, _DW_COLOR_ROW_EVEN; | 1707 unsigned long _DW_COLOR_ROW_ODD, _DW_COLOR_ROW_EVEN; |
1735 int iLastAddPoint, iLastQueryPoint; | 1708 int iLastAddPoint, iLastQueryPoint; |
1736 id scrollview; | |
1737 int filesystem; | 1709 int filesystem; |
1738 } | 1710 } |
1739 -(NSInteger)tableView:(UITableView *)aTable numberOfRowsInSection:(NSInteger)section; | 1711 -(NSInteger)tableView:(UITableView *)aTable numberOfRowsInSection:(NSInteger)section; |
1740 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; | 1712 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; |
1741 -(void)tableView:(UITableView*)tableView willDisplayCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath; | 1713 -(void)tableView:(UITableView*)tableView willDisplayCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath; |
1743 -(NSString *)getColumn:(int)col; | 1715 -(NSString *)getColumn:(int)col; |
1744 -(void *)userdata; | 1716 -(void *)userdata; |
1745 -(void)setUserdata:(void *)input; | 1717 -(void)setUserdata:(void *)input; |
1746 -(void)setFilesystem:(int)input; | 1718 -(void)setFilesystem:(int)input; |
1747 -(int)filesystem; | 1719 -(int)filesystem; |
1748 -(id)scrollview; | |
1749 -(void)setScrollview:(id)input; | |
1750 -(int)addRow:(NSArray *)input; | 1720 -(int)addRow:(NSArray *)input; |
1751 -(int)addRows:(int)number; | 1721 -(int)addRows:(int)number; |
1752 -(void)editCell:(id)input at:(int)row and:(int)col; | 1722 -(void)editCell:(id)input at:(int)row and:(int)col; |
1753 -(void)removeRow:(int)row; | 1723 -(void)removeRow:(int)row; |
1754 -(void)setRow:(int)row title:(const char *)input; | 1724 -(void)setRow:(int)row title:(const char *)input; |
1774 if(tvcols && data) | 1744 if(tvcols && data) |
1775 { | 1745 { |
1776 int cols = (int)[tvcols count]; | 1746 int cols = (int)[tvcols count]; |
1777 int total = (int)[data count]; | 1747 int total = (int)[data count]; |
1778 if(cols && total) | 1748 if(cols && total) |
1779 { | |
1780 return total / cols; | 1749 return total / cols; |
1781 } | |
1782 } | 1750 } |
1783 return 0; | 1751 return 0; |
1784 } | 1752 } |
1785 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | 1753 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath |
1786 { | 1754 { |
1794 UITableViewCell *result = celldata; | 1762 UITableViewCell *result = celldata; |
1795 | 1763 |
1796 /* Copy the alignment setting from the column, | 1764 /* Copy the alignment setting from the column, |
1797 * and set the text color from the container. | 1765 * and set the text color from the container. |
1798 */ | 1766 */ |
1799 if(@available(iOS 14.0, *)) | 1767 if(fgcolor) |
1800 { | 1768 [[result textLabel] setTextColor:fgcolor]; |
1801 UIListContentConfiguration *content = [result defaultContentConfiguration]; | 1769 |
1802 | |
1803 if(fgcolor) | |
1804 [[content textProperties] setColor:fgcolor]; | |
1805 } | |
1806 else | |
1807 { | |
1808 if(fgcolor) | |
1809 [result setTextColor:fgcolor]; | |
1810 } | |
1811 /* Return the result */ | 1770 /* Return the result */ |
1812 return result; | 1771 return result; |
1813 } | 1772 } |
1814 return nil; | 1773 return nil; |
1815 } | 1774 } |
1830 -(NSString *)getColumn:(int)col { if(tvcols) { return [tvcols objectAtIndex:col]; } return nil; } | 1789 -(NSString *)getColumn:(int)col { if(tvcols) { return [tvcols objectAtIndex:col]; } return nil; } |
1831 -(void *)userdata { return userdata; } | 1790 -(void *)userdata { return userdata; } |
1832 -(void)setUserdata:(void *)input { userdata = input; } | 1791 -(void)setUserdata:(void *)input { userdata = input; } |
1833 -(void)setFilesystem:(int)input { filesystem = input; } | 1792 -(void)setFilesystem:(int)input { filesystem = input; } |
1834 -(int)filesystem { return filesystem; } | 1793 -(int)filesystem { return filesystem; } |
1835 -(id)scrollview { return scrollview; } | |
1836 -(void)setScrollview:(id)input { scrollview = input; } | |
1837 -(void)refreshColors | 1794 -(void)refreshColors |
1838 { | 1795 { |
1839 UIColor *oldodd = oddcolor; | 1796 UIColor *oldodd = oddcolor; |
1840 UIColor *oldeven = evencolor; | 1797 UIColor *oldeven = evencolor; |
1841 unsigned long thisodd = dw_oddcolor == DW_CLR_DEFAULT ? _DW_COLOR_ROW_ODD : dw_oddcolor; | 1798 unsigned long thisodd = dw_oddcolor == DW_CLR_DEFAULT ? _DW_COLOR_ROW_ODD : dw_oddcolor; |
3128 } | 3085 } |
3129 return range; | 3086 return range; |
3130 } | 3087 } |
3131 | 3088 |
3132 /* Return the handle to the text object */ | 3089 /* Return the handle to the text object */ |
3133 id _text_handle(id object) | 3090 id _dw_text_handle(id object) |
3134 { | 3091 { |
3135 if([object isMemberOfClass:[ DWSpinButton class]]) | 3092 if([object isMemberOfClass:[ DWSpinButton class]]) |
3136 { | 3093 { |
3137 DWSpinButton *spinbutton = object; | 3094 DWSpinButton *spinbutton = object; |
3138 object = [spinbutton textfield]; | 3095 object = [spinbutton textfield]; |
3165 */ | 3122 */ |
3166 void _dw_control_size(id handle, int *width, int *height) | 3123 void _dw_control_size(id handle, int *width, int *height) |
3167 { | 3124 { |
3168 int thiswidth = 1, thisheight = 1, extrawidth = 0, extraheight = 0; | 3125 int thiswidth = 1, thisheight = 1, extrawidth = 0, extraheight = 0; |
3169 NSString *nsstr = nil; | 3126 NSString *nsstr = nil; |
3170 id object = _text_handle(handle); | 3127 id object = _dw_text_handle(handle); |
3171 | 3128 |
3172 /* Handle all the different button types */ | 3129 /* Handle all the different button types */ |
3173 if([ object isKindOfClass:[ UIButton class ] ]) | 3130 if([ object isKindOfClass:[ UIButton class ] ]) |
3174 { | 3131 { |
3175 switch([object buttonType]) | 3132 switch([object buttonType]) |
3248 [ object isMemberOfClass:[DWContainer class] ]) | 3205 [ object isMemberOfClass:[DWContainer class] ]) |
3249 { | 3206 { |
3250 CGSize size; | 3207 CGSize size; |
3251 | 3208 |
3252 if([ object isMemberOfClass:[DWMLE class] ]) | 3209 if([ object isMemberOfClass:[DWMLE class] ]) |
3253 { | 3210 size = [object contentSize]; |
3254 UIScrollView *sv = [object scrollview]; | |
3255 CGRect frame = [sv frame]; | |
3256 | |
3257 /* Size the text view to fit */ | |
3258 [object sizeToFit]; | |
3259 frame.size = [object bounds].size; | |
3260 frame.size.width += 2.0; | |
3261 frame.size.height += 2.0; | |
3262 [sv setFrame:frame]; | |
3263 size = frame.size; | |
3264 } | |
3265 else | 3211 else |
3266 size = [object getsize]; | 3212 size = [object getsize]; |
3267 | 3213 |
3268 thiswidth = size.width; | 3214 thiswidth = size.width; |
3269 thisheight = size.height; | 3215 thisheight = size.height; |
3337 | 3283 |
3338 thisbox = [view box]; | 3284 thisbox = [view box]; |
3339 thisitem = thisbox->items; | 3285 thisitem = thisbox->items; |
3340 object = item; | 3286 object = item; |
3341 | 3287 |
3342 /* Query the objects */ | |
3343 if([ object isMemberOfClass:[ DWContainer class ] ] || | |
3344 [ object isMemberOfClass:[ DWMLE class ] ]) | |
3345 { | |
3346 this = item = [object scrollview]; | |
3347 } | |
3348 | |
3349 /* Do some sanity bounds checking */ | 3288 /* Do some sanity bounds checking */ |
3350 if(!thisitem) | 3289 if(!thisitem) |
3351 thisbox->count = 0; | 3290 thisbox->count = 0; |
3352 if(index < 0) | 3291 if(index < 0) |
3353 index = 0; | 3292 index = 0; |
3374 /* Fill in the item data appropriately */ | 3313 /* Fill in the item data appropriately */ |
3375 if([object isKindOfClass:[DWBox class]]) | 3314 if([object isKindOfClass:[DWBox class]]) |
3376 tmpitem[index].type = TYPEBOX; | 3315 tmpitem[index].type = TYPEBOX; |
3377 else | 3316 else |
3378 { | 3317 { |
3379 if ( width == 0 && hsize == FALSE ) | 3318 if(width == 0 && hsize == FALSE) |
3380 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item); | 3319 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item); |
3381 if ( height == 0 && vsize == FALSE ) | 3320 if(height == 0 && vsize == FALSE) |
3382 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item); | 3321 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item); |
3383 | 3322 |
3384 tmpitem[index].type = TYPEITEM; | 3323 tmpitem[index].type = TYPEITEM; |
3385 } | 3324 } |
3386 | 3325 |
3442 int retval = DW_ERROR_NONE; | 3381 int retval = DW_ERROR_NONE; |
3443 | 3382 |
3444 if([object isKindOfClass:[UIView class]] || [object isKindOfClass:[UIControl class]]) | 3383 if([object isKindOfClass:[UIView class]] || [object isKindOfClass:[UIControl class]]) |
3445 { | 3384 { |
3446 DWBox *parent = (DWBox *)[object superview]; | 3385 DWBox *parent = (DWBox *)[object superview]; |
3447 | |
3448 /* Some controls are embedded in scrollviews... | |
3449 * so get the parent of the scrollview in that case. | |
3450 */ | |
3451 if(([object isKindOfClass:[UITableView class]] || [object isMemberOfClass:[DWMLE class]])) | |
3452 { | |
3453 object = [parent superview]; | |
3454 parent = (DWBox *)[object superview]; | |
3455 } | |
3456 | 3386 |
3457 if([parent isKindOfClass:[DWBox class]]) | 3387 if([parent isKindOfClass:[DWBox class]]) |
3458 { | 3388 { |
3459 id window = [object window]; | 3389 id window = [object window]; |
3460 Box *thisbox = [parent box]; | 3390 Box *thisbox = [parent box]; |
4496 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG) | 4426 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG) |
4497 { | 4427 { |
4498 CGRect frame = CGRectMake(0, 0, 100, 50); | 4428 CGRect frame = CGRectMake(0, 0, 100, 50); |
4499 NSTextContainer *tc = [[NSTextContainer alloc] initWithSize:frame.size]; | 4429 NSTextContainer *tc = [[NSTextContainer alloc] initWithSize:frame.size]; |
4500 DWMLE *mle = [[[DWMLE alloc] initWithFrame:frame textContainer:tc] retain]; | 4430 DWMLE *mle = [[[DWMLE alloc] initWithFrame:frame textContainer:tc] retain]; |
4501 UIScrollView *scrollview = [[UIScrollView alloc] init]; | |
4502 CGSize size = [mle intrinsicContentSize]; | 4431 CGSize size = [mle intrinsicContentSize]; |
4503 | 4432 |
4504 size.width = size.height; | 4433 size.width = size.height; |
4505 [mle setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth]; | 4434 [mle setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth]; |
4506 [mle setScrollview:scrollview]; | |
4507 [mle setTag:cid]; | 4435 [mle setTag:cid]; |
4508 [mle autorelease]; | 4436 [mle autorelease]; |
4509 DW_FUNCTION_RETURN_THIS(mle); | 4437 DW_FUNCTION_RETURN_THIS(mle); |
4510 } | 4438 } |
4511 | 4439 |
6073 DW_FUNCTION_NO_RETURN(dw_container_scroll) | 6001 DW_FUNCTION_NO_RETURN(dw_container_scroll) |
6074 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, direction, int, DW_UNUSED(rows), long) | 6002 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, direction, int, DW_UNUSED(rows), long) |
6075 { | 6003 { |
6076 DW_FUNCTION_INIT; | 6004 DW_FUNCTION_INIT; |
6077 DWContainer *cont = handle; | 6005 DWContainer *cont = handle; |
6078 UIScrollView *sv = [cont scrollview]; | |
6079 int rowcount = (int)[cont numberOfRowsInSection:0]; | 6006 int rowcount = (int)[cont numberOfRowsInSection:0]; |
6080 CGPoint offset = [sv contentOffset]; | 6007 CGPoint offset = [cont contentOffset]; |
6081 | 6008 |
6082 /* Safety check */ | 6009 /* Safety check */ |
6083 if(rowcount < 1) | 6010 if(rowcount < 1) |
6084 { | 6011 { |
6085 return; | 6012 return; |
6092 offset.y = 0; | 6019 offset.y = 0; |
6093 break; | 6020 break; |
6094 } | 6021 } |
6095 case DW_SCROLL_BOTTOM: | 6022 case DW_SCROLL_BOTTOM: |
6096 { | 6023 { |
6097 offset.y = [sv contentSize].height - [sv visibleSize].height; | 6024 offset.y = [cont contentSize].height - [cont visibleSize].height; |
6098 break; | 6025 break; |
6099 } | 6026 } |
6100 /* TODO: Currently scrolling a full page, need to use row parameter instead */ | 6027 /* TODO: Currently scrolling a full page, need to use row parameter instead */ |
6101 case DW_SCROLL_UP: | 6028 case DW_SCROLL_UP: |
6102 { | 6029 { |
6103 offset.y -= [sv visibleSize].height; | 6030 offset.y -= [cont visibleSize].height; |
6104 break; | 6031 break; |
6105 } | 6032 } |
6106 case DW_SCROLL_DOWN: | 6033 case DW_SCROLL_DOWN: |
6107 { | 6034 { |
6108 offset.y += [sv visibleSize].height; | 6035 offset.y += [cont visibleSize].height; |
6109 break; | 6036 break; |
6110 } | 6037 } |
6111 } | 6038 } |
6112 if(offset.y < 0) | 6039 if(offset.y < 0) |
6113 offset.y = 0; | 6040 offset.y = 0; |
6114 [sv setContentOffset:offset]; | 6041 [cont setContentOffset:offset]; |
6115 DW_FUNCTION_RETURN_NOTHING; | 6042 DW_FUNCTION_RETURN_NOTHING; |
6116 } | 6043 } |
6117 | 6044 |
6118 /* | 6045 /* |
6119 * Starts a new query of a container. | 6046 * Starts a new query of a container. |
7807 DW_FUNCTION_DEFINITION(dw_window_set_style, void, HWND handle, ULONG style, ULONG mask) | 7734 DW_FUNCTION_DEFINITION(dw_window_set_style, void, HWND handle, ULONG style, ULONG mask) |
7808 DW_FUNCTION_ADD_PARAM3(handle, style, mask) | 7735 DW_FUNCTION_ADD_PARAM3(handle, style, mask) |
7809 DW_FUNCTION_NO_RETURN(dw_window_set_style) | 7736 DW_FUNCTION_NO_RETURN(dw_window_set_style) |
7810 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, style, ULONG, mask, ULONG) | 7737 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, style, ULONG, mask, ULONG) |
7811 { | 7738 { |
7812 id object = _text_handle(handle); | 7739 id object = _dw_text_handle(handle); |
7813 | 7740 |
7814 if([object isKindOfClass:[UILabel class]]) | 7741 if([object isKindOfClass:[UILabel class]]) |
7815 { | 7742 { |
7816 UILabel *label = object; | 7743 UILabel *label = object; |
7817 | 7744 |
7964 { | 7891 { |
7965 /* Find the item within the box it is packed into */ | 7892 /* Find the item within the box it is packed into */ |
7966 if([object isKindOfClass:[DWBox class]] || [object isKindOfClass:[UIControl class]]) | 7893 if([object isKindOfClass:[DWBox class]] || [object isKindOfClass:[UIControl class]]) |
7967 { | 7894 { |
7968 DWBox *parent = (DWBox *)[object superview]; | 7895 DWBox *parent = (DWBox *)[object superview]; |
7969 | |
7970 /* Some controls are embedded in scrollviews... | |
7971 * so get the parent of the scrollview in that case. | |
7972 */ | |
7973 if([object isKindOfClass:[UITableView class]]) | |
7974 { | |
7975 object = [parent superview]; | |
7976 parent = (DWBox *)[object superview]; | |
7977 } | |
7978 | 7896 |
7979 if([parent isKindOfClass:[DWBox class]]) | 7897 if([parent isKindOfClass:[DWBox class]]) |
7980 { | 7898 { |
7981 Box *thisbox = [parent box]; | 7899 Box *thisbox = [parent box]; |
7982 Item *thisitem = thisbox->items; | 7900 Item *thisitem = thisbox->items; |
8003 UIFont *font = fontname ? _dw_font_by_name(fontname) : | 7921 UIFont *font = fontname ? _dw_font_by_name(fontname) : |
8004 (DWDefaultFont ? DWDefaultFont : [UIFont systemFontOfSize:[UIFont smallSystemFontSize]]); | 7922 (DWDefaultFont ? DWDefaultFont : [UIFont systemFontOfSize:[UIFont smallSystemFontSize]]); |
8005 | 7923 |
8006 if(font) | 7924 if(font) |
8007 { | 7925 { |
8008 id object = _text_handle(handle); | 7926 id object = _dw_text_handle(handle); |
8009 if([object isMemberOfClass:[DWMLE class]]) | 7927 if([object isMemberOfClass:[DWMLE class]]) |
8010 { | 7928 { |
8011 DWMLE *mle = object; | 7929 DWMLE *mle = object; |
8012 | 7930 |
8013 [mle setFont:font]; | 7931 [mle setFont:font]; |
8044 * Parameters: | 7962 * Parameters: |
8045 * handle: The window handle from which to obtain the font. | 7963 * handle: The window handle from which to obtain the font. |
8046 */ | 7964 */ |
8047 char * API dw_window_get_font(HWND handle) | 7965 char * API dw_window_get_font(HWND handle) |
8048 { | 7966 { |
8049 id object = _text_handle(handle); | 7967 id object = _dw_text_handle(handle); |
8050 UIFont *font = nil; | 7968 UIFont *font = nil; |
8051 | 7969 |
8052 if([object isKindOfClass:[UIControl class]] || [object isMemberOfClass:[DWRender class]]) | 7970 if([object isKindOfClass:[UIControl class]] || [object isMemberOfClass:[DWRender class]]) |
8053 { | 7971 { |
8054 font = [object font]; | 7972 font = [object font]; |
8094 #endif | 8012 #endif |
8095 /* Handle destroying a control or box */ | 8013 /* Handle destroying a control or box */ |
8096 else if([object isKindOfClass:[UIView class]] || [object isKindOfClass:[UIControl class]]) | 8014 else if([object isKindOfClass:[UIView class]] || [object isKindOfClass:[UIControl class]]) |
8097 { | 8015 { |
8098 DWBox *parent = (DWBox *)[object superview]; | 8016 DWBox *parent = (DWBox *)[object superview]; |
8099 | |
8100 /* Some controls are embedded in scrollviews... | |
8101 * so get the parent of the scrollview in that case. | |
8102 */ | |
8103 if(([object isKindOfClass:[UITableView class]] || [object isMemberOfClass:[DWMLE class]])) | |
8104 { | |
8105 object = [parent superview]; | |
8106 parent = (DWBox *)[object superview]; | |
8107 } | |
8108 | 8017 |
8109 if([parent isKindOfClass:[DWBox class]]) | 8018 if([parent isKindOfClass:[DWBox class]]) |
8110 { | 8019 { |
8111 id window = [object window]; | 8020 id window = [object window]; |
8112 Box *thisbox = [parent box]; | 8021 Box *thisbox = [parent box]; |
8169 DW_FUNCTION_ADD_PARAM1(handle) | 8078 DW_FUNCTION_ADD_PARAM1(handle) |
8170 DW_FUNCTION_RETURN(dw_window_get_text, char *) | 8079 DW_FUNCTION_RETURN(dw_window_get_text, char *) |
8171 DW_FUNCTION_RESTORE_PARAM1(handle, HWND) | 8080 DW_FUNCTION_RESTORE_PARAM1(handle, HWND) |
8172 { | 8081 { |
8173 DW_FUNCTION_INIT; | 8082 DW_FUNCTION_INIT; |
8174 id object = _text_handle(handle); | 8083 id object = _dw_text_handle(handle); |
8175 char *retval = NULL; | 8084 char *retval = NULL; |
8176 | 8085 |
8177 if([ object isKindOfClass:[ UIWindow class ] ] || [ object isKindOfClass:[ UIButton class ] ]) | 8086 if([ object isKindOfClass:[ UIWindow class ] ] || [ object isKindOfClass:[ UIButton class ] ]) |
8178 { | 8087 { |
8179 id window = object; | 8088 id window = object; |
8201 DW_FUNCTION_ADD_PARAM2(handle, text) | 8110 DW_FUNCTION_ADD_PARAM2(handle, text) |
8202 DW_FUNCTION_NO_RETURN(dw_window_set_text) | 8111 DW_FUNCTION_NO_RETURN(dw_window_set_text) |
8203 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, text, char *) | 8112 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, text, char *) |
8204 { | 8113 { |
8205 DW_FUNCTION_INIT; | 8114 DW_FUNCTION_INIT; |
8206 id object = _text_handle(handle); | 8115 id object = _dw_text_handle(handle); |
8207 | 8116 |
8208 if([ object isKindOfClass:[ UIWindow class ] ] || [ object isKindOfClass:[ UIButton class ] ]) | 8117 if([ object isKindOfClass:[ UIWindow class ] ] || [ object isKindOfClass:[ UIButton class ] ]) |
8209 [object setTitle:[NSString stringWithUTF8String:text]]; | 8118 [object setTitle:[NSString stringWithUTF8String:text]]; |
8210 else if([ object isKindOfClass:[ UIControl class ] ]) | 8119 else if([ object isKindOfClass:[ UIControl class ] ]) |
8211 { | 8120 { |