comparison ios/dw.m @ 2425:60a459df758d

iOS: Account for the special area at the bottom of certain devies. We may need to do this conditionally based on the device type, but for now just moving up the bottom of the window view by 24 points to account. Also fix a few deprecations and other code warnings.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 04 Apr 2021 18:22:27 +0000
parents 6b302a8c856f
children 6220f0580088
comparison
equal deleted inserted replaced
2424:6b302a8c856f 2425:60a459df758d
1317 */ 1317 */
1318 id object = [array lastObject]; 1318 id object = [array lastObject];
1319 if(![object isMemberOfClass:[DWView class]]) 1319 if(![object isMemberOfClass:[DWView class]])
1320 [object setHidden:YES]; 1320 [object setHidden:YES];
1321 /* Adjust the frame to account for the status bar */ 1321 /* Adjust the frame to account for the status bar */
1322 NSInteger sbheight = [UIApplication sharedApplication].statusBarFrame.size.height; 1322 NSInteger sbheight = [[[window windowScene] statusBarManager] statusBarFrame].size.height;
1323 frame.size.height -= sbheight; 1323 frame.size.height -= sbheight;
1324 /* Account for the special area on iPhone X and iPad Pro
1325 * https://blog.maxrudberg.com/post/165590234593/ui-design-for-iphone-x-bottom-elements
1326 */
1327 frame.size.height -= 24;
1324 frame.origin.y += sbheight; 1328 frame.origin.y += sbheight;
1325 [view setFrame:frame]; 1329 [view setFrame:frame];
1326 [view windowResized:frame.size]; 1330 [view windowResized:frame.size];
1327 } 1331 }
1328 @end 1332 @end
7787 [label setLineBreakMode:NSLineBreakByWordWrapping]; 7791 [label setLineBreakMode:NSLineBreakByWordWrapping];
7788 else 7792 else
7789 [label setLineBreakMode:NSLineBreakByTruncatingTail]; 7793 [label setLineBreakMode:NSLineBreakByTruncatingTail];
7790 } 7794 }
7791 } 7795 }
7792 #if 0 /* TODO: See if we can change alignment... */ 7796 else if([object isMemberOfClass:[DWMLE class]])
7793 else if([object isMemberOfClass:[UITextView class]]) 7797 {
7794 { 7798 DWMLE *mle = handle;
7795 UITextView *tv = handle; 7799 [mle setTextAlignment:(style & mask)];
7796 [tv setAlignment:(style & mask)]; 7800 }
7797 } 7801 else if([object isMemberOfClass:[DWMenuItem class]])
7802 {
7803 DWMenuItem *menuitem = object;
7804
7805 if(mask & (DW_MIS_CHECKED | DW_MIS_UNCHECKED))
7806 {
7807 if(style & DW_MIS_CHECKED)
7808 [menuitem setState:UIMenuElementStateOn];
7809 else if(style & DW_MIS_UNCHECKED)
7810 [menuitem setState:UIMenuElementStateOff];
7811 }
7812 #if 0 /* Disabled menu items not available on iOS currently */
7813 if(mask & (DW_MIS_ENABLED | DW_MIS_DISABLED))
7814 {
7815 if(style & DW_MIS_ENABLED)
7816 [menuitem setEnabled:YES];
7817 else if(style & DW_MIS_DISABLED)
7818 [menuitem setEnabled:NO];
7819 }
7798 #endif 7820 #endif
7799 else if([object isMemberOfClass:[DWMenuItem class]])
7800 {
7801 if(mask & (DW_MIS_CHECKED | DW_MIS_UNCHECKED))
7802 {
7803 if(style & DW_MIS_CHECKED)
7804 [object setState:UIMenuElementStateOn];
7805 else if(style & DW_MIS_UNCHECKED)
7806 [object setState:UIMenuElementStateOff];
7807 }
7808 if(mask & (DW_MIS_ENABLED | DW_MIS_DISABLED))
7809 {
7810 if(style & DW_MIS_ENABLED)
7811 [object setEnabled:YES];
7812 else if(style & DW_MIS_DISABLED)
7813 [object setEnabled:NO];
7814 }
7815 } 7821 }
7816 DW_FUNCTION_RETURN_NOTHING; 7822 DW_FUNCTION_RETURN_NOTHING;
7817 } 7823 }
7818 7824
7819 /* 7825 /*
8125 else if([ object isKindOfClass:[ UIControl class ] ]) 8131 else if([ object isKindOfClass:[ UIControl class ] ])
8126 { 8132 {
8127 UIControl *control = object; 8133 UIControl *control = object;
8128 NSString *nsstr = [control text]; 8134 NSString *nsstr = [control text];
8129 8135
8130 retval = strdup([ nsstr UTF8String ]); 8136 if(nsstr && [nsstr length] > 0)
8137 retval = strdup([ nsstr UTF8String ]);
8131 } 8138 }
8132 DW_FUNCTION_RETURN_THIS(retval); 8139 DW_FUNCTION_RETURN_THIS(retval);
8133 } 8140 }
8134 8141
8135 /* 8142 /*