# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1617548745 0 # Node ID b4cb136b52226d40e2c60b9c8c3dc5d22b33883e # Parent 4a353a83b2e4022f7dae25eb899d3c167f1a9922 iOS: Special handling for combined text/image buttons like check and radio buttons. diff -r 4a353a83b2e4 -r b4cb136b5222 ios/dw.m --- a/ios/dw.m Sun Apr 04 01:23:56 2021 +0000 +++ b/ios/dw.m Sun Apr 04 15:05:45 2021 +0000 @@ -3218,21 +3218,28 @@ /* Handle all the different button types */ if([ object isMemberOfClass:[ DWButton class ] ]) { - UIImage *image = (UIImage *)[object image]; + UIImage *image = (UIImage *)[object imageForState:UIControlStateNormal]; if(image) { /* Image button */ CGSize size = [image size]; - extrawidth = (int)size.width; - extraheight = (int)size.height; + extrawidth = (int)size.width + 1; + /* Height isn't additive */ + thisheight = (int)size.height + 1; } /* Text button */ nsstr = [[object titleLabel] text]; if(nsstr && [nsstr length] > 0) { - extrawidth += 8; + /* With combined text/image we seem to + * need a lot of additional width space. + */ + if(image) + extrawidth += 30; + else + extrawidth += 8; extraheight += 4; } } @@ -3306,7 +3313,10 @@ thisheight = _DW_SCROLLED_MAX_HEIGHT; } else if([ object isKindOfClass:[UILabel class] ]) + { nsstr = [object text]; + extrawidth = extraheight = 2; + } /* Any other control type */ else if([ object isKindOfClass:[ UIControl class ] ]) nsstr = [object text]; @@ -3315,7 +3325,16 @@ * calculate the size with the current font. */ if(nsstr && [nsstr length]) - dw_font_text_extents_get(object, NULL, (char *)[nsstr UTF8String], &thiswidth, &thisheight); + { + int textwidth, textheight; + + dw_font_text_extents_get(object, NULL, (char *)[nsstr UTF8String], &textwidth, &textheight); + + if(textheight > thisheight) + thisheight = textheight; + if(textwidth > thiswidth) + thiswidth = textwidth; + } /* Handle static text fields */ if([object isKindOfClass:[ UITextField class ]] && ![object isEditable]) @@ -5104,7 +5123,8 @@ } NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; /* If we didn't get a font from the pixmap... try the associated object */ - if(!font && ([object isMemberOfClass:[DWRender class]] || [object isKindOfClass:[UIControl class]])) + if(!font && ([object isMemberOfClass:[DWRender class]] || [object isKindOfClass:[UIControl class]] + || [object isKindOfClass:[UILabel class]])) { font = [object font]; }