Mercurial > dwindows
comparison ios/dw.m @ 2464:4fba0b9453ee
iOS: Fix calculating label size when there is no text. Use "gT" to calculate
the height. Fix some menu tests, they were using old classes or disabled
code.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 14 Apr 2021 21:35:21 +0000 |
parents | 79c7bf492bc1 |
children | 4d1f370bf65e |
comparison
equal
deleted
inserted
replaced
2463:79c7bf492bc1 | 2464:4fba0b9453ee |
---|---|
2109 { | 2109 { |
2110 __block UIMenu *popupmenu = [window popupMenu]; | 2110 __block UIMenu *popupmenu = [window popupMenu]; |
2111 config = [UIContextMenuConfiguration configurationWithIdentifier:@"DWContextMenu" | 2111 config = [UIContextMenuConfiguration configurationWithIdentifier:@"DWContextMenu" |
2112 previewProvider:nil | 2112 previewProvider:nil |
2113 actionProvider:^(NSArray* suggestedAction){return popupmenu;}]; | 2113 actionProvider:^(NSArray* suggestedAction){return popupmenu;}]; |
2114 [window setPopupMenu:nil]; | |
2114 } | 2115 } |
2115 return config; | 2116 return config; |
2116 } | 2117 } |
2117 -(void)addColumn:(NSString *)input andType:(int)type { if(tvcols) { [tvcols addObject:input]; [types addObject:[NSNumber numberWithInt:type]]; } } | 2118 -(void)addColumn:(NSString *)input andType:(int)type { if(tvcols) { [tvcols addObject:input]; [types addObject:[NSNumber numberWithInt:type]]; } } |
2118 -(NSString *)getColumn:(int)col { if(tvcols) { return [tvcols objectAtIndex:col]; } return nil; } | 2119 -(NSString *)getColumn:(int)col { if(tvcols) { return [tvcols objectAtIndex:col]; } return nil; } |
3720 #endif | 3721 #endif |
3721 | 3722 |
3722 /* If we have a string... | 3723 /* If we have a string... |
3723 * calculate the size with the current font. | 3724 * calculate the size with the current font. |
3724 */ | 3725 */ |
3725 if(nsstr && [nsstr length]) | 3726 if(nsstr) |
3726 { | 3727 { |
3727 int textwidth, textheight; | 3728 int textwidth, textheight; |
3728 | 3729 |
3729 dw_font_text_extents_get(object, NULL, (char *)[nsstr UTF8String], &textwidth, &textheight); | 3730 /* If we have an empty string, use "gT" to get the most height for the font */ |
3731 dw_font_text_extents_get(object, NULL, [nsstr length] ? (char *)[nsstr UTF8String] : "gT", &textwidth, &textheight); | |
3730 | 3732 |
3731 if(textheight > thisheight) | 3733 if(textheight > thisheight) |
3732 thisheight = textheight; | 3734 thisheight = textheight; |
3733 if(textwidth > thiswidth) | 3735 if(textwidth > thiswidth) |
3734 thiswidth = textwidth; | 3736 thiswidth = textwidth; |
8564 { | 8566 { |
8565 UIScrollView *sv = handle; | 8567 UIScrollView *sv = handle; |
8566 NSArray *subviews = [sv subviews]; | 8568 NSArray *subviews = [sv subviews]; |
8567 object = [subviews firstObject]; | 8569 object = [subviews firstObject]; |
8568 } | 8570 } |
8569 if([object isKindOfClass:[UIControl class]] || [object isKindOfClass:[UIMenuItem class]]) | 8571 if([object isKindOfClass:[UIControl class]] || [object isMemberOfClass:[DWMenuItem class]]) |
8570 { | 8572 { |
8571 [object setEnabled:NO]; | 8573 [object setEnabled:NO]; |
8572 } | 8574 } |
8573 if([object isKindOfClass:[UITextView class]]) | 8575 if([object isKindOfClass:[UITextView class]]) |
8574 { | 8576 { |
8596 { | 8598 { |
8597 UIScrollView *sv = handle; | 8599 UIScrollView *sv = handle; |
8598 NSArray *subviews = [sv subviews]; | 8600 NSArray *subviews = [sv subviews]; |
8599 object = [subviews firstObject]; | 8601 object = [subviews firstObject]; |
8600 } | 8602 } |
8601 if([object isKindOfClass:[UIControl class]] /* TODO: || [object isKindOfClass:[UIMenuItem class]] */) | 8603 if([object isKindOfClass:[UIControl class]] || [object isMemberOfClass:[DWMenuItem class]]) |
8602 { | 8604 { |
8603 [object setEnabled:YES]; | 8605 [object setEnabled:YES]; |
8604 } | 8606 } |
8605 if([object isKindOfClass:[UITextView class]]) | 8607 if([object isKindOfClass:[UITextView class]]) |
8606 { | 8608 { |