Mercurial > dwindows
comparison ios/dw.m @ 2423:b4cb136b5222
iOS: Special handling for combined text/image buttons like check and radio
buttons.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 04 Apr 2021 15:05:45 +0000 |
parents | 4a353a83b2e4 |
children | 6b302a8c856f |
comparison
equal
deleted
inserted
replaced
2422:4a353a83b2e4 | 2423:b4cb136b5222 |
---|---|
3216 id object = _dw_text_handle(handle); | 3216 id object = _dw_text_handle(handle); |
3217 | 3217 |
3218 /* Handle all the different button types */ | 3218 /* Handle all the different button types */ |
3219 if([ object isMemberOfClass:[ DWButton class ] ]) | 3219 if([ object isMemberOfClass:[ DWButton class ] ]) |
3220 { | 3220 { |
3221 UIImage *image = (UIImage *)[object image]; | 3221 UIImage *image = (UIImage *)[object imageForState:UIControlStateNormal]; |
3222 | 3222 |
3223 if(image) | 3223 if(image) |
3224 { | 3224 { |
3225 /* Image button */ | 3225 /* Image button */ |
3226 CGSize size = [image size]; | 3226 CGSize size = [image size]; |
3227 extrawidth = (int)size.width; | 3227 extrawidth = (int)size.width + 1; |
3228 extraheight = (int)size.height; | 3228 /* Height isn't additive */ |
3229 thisheight = (int)size.height + 1; | |
3229 } | 3230 } |
3230 /* Text button */ | 3231 /* Text button */ |
3231 nsstr = [[object titleLabel] text]; | 3232 nsstr = [[object titleLabel] text]; |
3232 | 3233 |
3233 if(nsstr && [nsstr length] > 0) | 3234 if(nsstr && [nsstr length] > 0) |
3234 { | 3235 { |
3235 extrawidth += 8; | 3236 /* With combined text/image we seem to |
3237 * need a lot of additional width space. | |
3238 */ | |
3239 if(image) | |
3240 extrawidth += 30; | |
3241 else | |
3242 extrawidth += 8; | |
3236 extraheight += 4; | 3243 extraheight += 4; |
3237 } | 3244 } |
3238 } | 3245 } |
3239 /* If the control is an entryfield set width to 150 */ | 3246 /* If the control is an entryfield set width to 150 */ |
3240 else if([object isKindOfClass:[ UITextField class ]]) | 3247 else if([object isKindOfClass:[ UITextField class ]]) |
3304 thisheight = _DW_SCROLLED_MIN_HEIGHT; | 3311 thisheight = _DW_SCROLLED_MIN_HEIGHT; |
3305 if(thisheight > _DW_SCROLLED_MAX_HEIGHT) | 3312 if(thisheight > _DW_SCROLLED_MAX_HEIGHT) |
3306 thisheight = _DW_SCROLLED_MAX_HEIGHT; | 3313 thisheight = _DW_SCROLLED_MAX_HEIGHT; |
3307 } | 3314 } |
3308 else if([ object isKindOfClass:[UILabel class] ]) | 3315 else if([ object isKindOfClass:[UILabel class] ]) |
3316 { | |
3309 nsstr = [object text]; | 3317 nsstr = [object text]; |
3318 extrawidth = extraheight = 2; | |
3319 } | |
3310 /* Any other control type */ | 3320 /* Any other control type */ |
3311 else if([ object isKindOfClass:[ UIControl class ] ]) | 3321 else if([ object isKindOfClass:[ UIControl class ] ]) |
3312 nsstr = [object text]; | 3322 nsstr = [object text]; |
3313 | 3323 |
3314 /* If we have a string... | 3324 /* If we have a string... |
3315 * calculate the size with the current font. | 3325 * calculate the size with the current font. |
3316 */ | 3326 */ |
3317 if(nsstr && [nsstr length]) | 3327 if(nsstr && [nsstr length]) |
3318 dw_font_text_extents_get(object, NULL, (char *)[nsstr UTF8String], &thiswidth, &thisheight); | 3328 { |
3329 int textwidth, textheight; | |
3330 | |
3331 dw_font_text_extents_get(object, NULL, (char *)[nsstr UTF8String], &textwidth, &textheight); | |
3332 | |
3333 if(textheight > thisheight) | |
3334 thisheight = textheight; | |
3335 if(textwidth > thiswidth) | |
3336 thiswidth = textwidth; | |
3337 } | |
3319 | 3338 |
3320 /* Handle static text fields */ | 3339 /* Handle static text fields */ |
3321 if([object isKindOfClass:[ UITextField class ]] && ![object isEditable]) | 3340 if([object isKindOfClass:[ UITextField class ]] && ![object isEditable]) |
3322 { | 3341 { |
3323 extrawidth = 10; | 3342 extrawidth = 10; |
5102 object = pixmap->handle; | 5121 object = pixmap->handle; |
5103 font = pixmap->font; | 5122 font = pixmap->font; |
5104 } | 5123 } |
5105 NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; | 5124 NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; |
5106 /* If we didn't get a font from the pixmap... try the associated object */ | 5125 /* If we didn't get a font from the pixmap... try the associated object */ |
5107 if(!font && ([object isMemberOfClass:[DWRender class]] || [object isKindOfClass:[UIControl class]])) | 5126 if(!font && ([object isMemberOfClass:[DWRender class]] || [object isKindOfClass:[UIControl class]] |
5127 || [object isKindOfClass:[UILabel class]])) | |
5108 { | 5128 { |
5109 font = [object font]; | 5129 font = [object font]; |
5110 } | 5130 } |
5111 /* If we got a font... add it to the dictionary */ | 5131 /* If we got a font... add it to the dictionary */ |
5112 if(font) | 5132 if(font) |