changeset 2405:38c17a19e00d

iOS: Add adjustment for the statusbar so it isn't covered up by our windows. Also retain all UI objects we create so they don't get disposed off... during our jumps between threads. This may require a release in box packing.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 28 Mar 2021 18:23:57 +0000
parents d4a044d24529
children 716f38f69073
files ios/dw.m
diffstat 1 files changed, 21 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/ios/dw.m	Sun Mar 28 17:15:13 2021 +0000
+++ b/ios/dw.m	Sun Mar 28 18:23:57 2021 +0000
@@ -1129,6 +1129,7 @@
     DWWindow *window = (DWWindow *)[[self view] window];
     NSArray *array = [window subviews];
     DWView *view = [array firstObject];
+    CGRect frame = [window frame];
     /* Hide the UITransitionView which is blocking the screen...
      * This is probably not the correct solution, but it solves the
      * problem for the moment.  Figure out what to do with this view.
@@ -1136,8 +1137,10 @@
     id object = [array lastObject];
     if(![object isMemberOfClass:[DWView class]])
         [object setHidden:YES];
-    [view setFrame:[window frame]];
-    [view windowResized:[window frame].size];
+    /* Adjust the frame to account for the status bar */
+    frame.size.height -= [UIApplication sharedApplication].statusBarFrame.size.height;;
+    [view setFrame:frame];
+    [view windowResized:frame.size];
 }
 @end
 
@@ -2791,7 +2794,7 @@
 DW_FUNCTION_RESTORE_PARAM2(type, int, pad, int)
 {
     DW_FUNCTION_INIT;
-    DWBox *view = [[DWBox alloc] init];
+    DWBox *view = [[[DWBox alloc] init] retain];
     Box *newbox = [view box];
     [view setTranslatesAutoresizingMaskIntoConstraints:NO];
     memset(newbox, 0, sizeof(Box));
@@ -2823,7 +2826,7 @@
 DW_FUNCTION_RETURN(dw_scrollbox_new, HWND)
 DW_FUNCTION_RESTORE_PARAM2(type, int, pad, int)
 {
-    DWScrollBox *scrollbox = [[DWScrollBox alloc] init];
+    DWScrollBox *scrollbox = [[[DWScrollBox alloc] init] retain];
     DWBox *box = dw_box_new(type, pad);
     DWBox *tmpbox = dw_box_new(DW_VERT, 0);
     dw_box_pack_start(tmpbox, box, 1, 1, TRUE, TRUE, 0);
@@ -3442,7 +3445,7 @@
 DW_FUNCTION_RETURN(dw_entryfield_new, HWND)
 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
 {
-    DWEntryField *entry = [[DWEntryField alloc] init];
+    DWEntryField *entry = [[[DWEntryField alloc] init] retain];
     [entry setText:[ NSString stringWithUTF8String:text ]];
     [entry setTag:cid];
     DW_FUNCTION_RETURN_THIS(entry);
@@ -3574,7 +3577,7 @@
 DW_FUNCTION_RETURN(dw_spinbutton_new, HWND)
 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
 {
-    DWSpinButton *spinbutton = [[DWSpinButton alloc] init];
+    DWSpinButton *spinbutton = [[[DWSpinButton alloc] init] retain];
     UIStepper *stepper = [spinbutton stepper];
     UITextField *textfield = [spinbutton textfield];
     long val = atol(text);
@@ -3671,7 +3674,7 @@
 DW_FUNCTION_RETURN(dw_slider_new, HWND)
 DW_FUNCTION_RESTORE_PARAM3(vertical, int, increments, int, cid, ULONG)
 {
-    DWSlider *slider = [[DWSlider alloc] init];
+    DWSlider *slider = [[[DWSlider alloc] init] retain];
     [slider setMaximumValue:(double)increments];
     [slider setMinimumValue:0];
     [slider setContinuous:YES];
@@ -3763,7 +3766,7 @@
 DW_FUNCTION_RETURN(dw_percent_new, HWND)
 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
 {
-    DWPercent *percent = [[DWPercent alloc] init];
+    DWPercent *percent = [[[DWPercent alloc] init] retain];
     [percent setTag:cid];
     DW_FUNCTION_RETURN_THIS(percent);
 }
@@ -4254,7 +4257,7 @@
 {
     CGRect frame = CGRectMake(0, 0, 100, 50);
     NSTextContainer *tc = [[NSTextContainer alloc] initWithSize:frame.size];
-    DWMLE *mle = [[DWMLE alloc] initWithFrame:frame textContainer:tc];
+    DWMLE *mle = [[[DWMLE alloc] initWithFrame:frame textContainer:tc] retain];
     UIScrollView *scrollview  = [[UIScrollView alloc] init];
     CGSize size = [mle intrinsicContentSize];
 
@@ -4558,7 +4561,7 @@
 DW_FUNCTION_RETURN(dw_text_new, HWND)
 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
 {
-    DWText *textfield = [[DWText alloc] init];
+    DWText *textfield = [[[DWText alloc] init] retain];
     [textfield setText:[NSString stringWithUTF8String:text]];
     [textfield setTag:cid];
     if(DWDefaultFont)
@@ -4580,7 +4583,7 @@
 DW_FUNCTION_RETURN(dw_render_new, HWND)
 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
 {
-    DWRender *render = [[DWRender alloc] init];
+    DWRender *render = [[[DWRender alloc] init] retain];
     [render setTag:cid];
     DW_FUNCTION_RETURN_THIS(render);
 }
@@ -6245,7 +6248,7 @@
      * when the application is deactivated to simulate
      * similar behavior.
      */
-    DWMDI *mdi = [[DWMDI alloc] init];
+    DWMDI *mdi = [[[DWMDI alloc] init] retain];
     /* [mdi setTag:cid]; Why doesn't this work? */
     return mdi;
 }
@@ -6267,7 +6270,7 @@
     DW_FUNCTION_INIT;
     id tmpbox = dw_box_new(DW_VERT, 0);
     DWSplitBar *split = [[DWSplitBar alloc] init];
-    UIViewController *vc = [[UIViewController alloc] init];
+    UIViewController *vc = [[[UIViewController alloc] init] retain];
     [split setDelegate:split];
     dw_box_pack_start(tmpbox, topleft, 0, 0, TRUE, TRUE, 0);
     [vc setView:tmpbox];
@@ -6408,7 +6411,7 @@
 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
 {
     DW_FUNCTION_INIT;
-    UIImageView *bitmap = [[UIImageView alloc] init];
+    UIImageView *bitmap = [[[UIImageView alloc] init] retain];
     [bitmap setTag:cid];
     DW_FUNCTION_RETURN_THIS(bitmap);
 }
@@ -6713,7 +6716,7 @@
 DW_FUNCTION_RETURN(dw_calendar_new, HWND)
 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
 {
-    DWCalendar *calendar = [[DWCalendar alloc] init];
+    DWCalendar *calendar = [[[DWCalendar alloc] init] retain];
     [calendar setDatePickerMode:UIDatePickerModeDate];
     [calendar setTag:cid];
     [calendar setDate:[NSDate date]];
@@ -6889,7 +6892,7 @@
 DW_FUNCTION_RESTORE_PARAM1(DW_UNUSED(cid), ULONG)
 {
     DW_FUNCTION_INIT;
-    DWWebView *web = [[DWWebView alloc] init];
+    DWWebView *web = [[[DWWebView alloc] init] retain];
     web.navigationDelegate = web;
     /* [web setTag:cid]; Why doesn't this work? */
     DW_FUNCTION_RETURN_THIS(web);
@@ -6932,7 +6935,7 @@
  */
 HMENUI API dw_menu_new(ULONG cid)
 {
-    DWMenu *menu = [[DWMenu alloc] init];
+    DWMenu *menu = [[[DWMenu alloc] init] retain];
     /* [menu setTag:cid]; Why doesn't this work? */
     return menu;
 }
@@ -7194,7 +7197,7 @@
 DW_FUNCTION_RETURN(dw_notebook_new, HWND)
 DW_FUNCTION_RESTORE_PARAM2(cid, ULONG, top, int)
 {
-    DWNotebook *notebook = [[DWNotebook alloc] init];
+    DWNotebook *notebook = [[[DWNotebook alloc] init] retain];
     [notebook addTarget:notebook
                  action:@selector(pageChanged:)
        forControlEvents:UIControlEventValueChanged];