changeset 2588:8253e17b20ad

iOS: Remove some bogus secondary color code in DWBox. Add fallback code to give general sizes for DWCalendar widgets... because intrinsicContentSize is returing -1,-1. Use size autodetection for calendar when packing in dwtest.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 24 May 2021 23:29:15 +0000
parents 461006160d11
children e879afecf3ab
files dwtest.c ios/dw.m
diffstat 2 files changed, 24 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/dwtest.c	Mon May 24 20:32:05 2021 +0000
+++ b/dwtest.c	Mon May 24 23:29:15 2021 +0000
@@ -1608,9 +1608,9 @@
     dw_window_set_color(buttonsbox, DW_CLR_RED, DW_CLR_RED);
 
     calbox = dw_box_new(DW_HORZ, 0);
-    dw_box_pack_start(notebookbox5, calbox, 500, 200, TRUE, TRUE, 1);
+    dw_box_pack_start(notebookbox5, calbox, 0, 0, TRUE, TRUE, 1);
     cal = dw_calendar_new(100);
-    dw_box_pack_start(calbox, cal, 180, 120, TRUE, TRUE, 0);
+    dw_box_pack_start(calbox, cal, -1, -1, TRUE, TRUE, 0);
 
     dw_calendar_set_date(cal, 2019, 4, 30);
 
--- a/ios/dw.m	Mon May 24 20:32:05 2021 +0000
+++ b/ios/dw.m	Mon May 24 23:29:15 2021 +0000
@@ -688,16 +688,13 @@
 {
     Box *box;
     void *userdata;
-    UIColor *bgcolor;
 }
 -(id)init;
 -(void)dealloc;
 -(Box *)box;
 -(void *)userdata;
 -(void)setUserdata:(void *)input;
--(void)drawRect:(CGRect)rect;
 -(void)keyDown:(UIKey *)key API_AVAILABLE(ios(13.4));
--(void)setColor:(unsigned long)input;
 @end
 
 @implementation DWBox
@@ -727,35 +724,7 @@
 -(Box *)box { return box; }
 -(void *)userdata { return userdata; }
 -(void)setUserdata:(void *)input { userdata = input; }
--(void)drawRect:(CGRect)rect
-{
-    if(bgcolor)
-    {
-        [bgcolor set];
-        UIRectFill([self bounds]);
-    }
-}
 -(void)keyDown:(UIKey *)key  API_AVAILABLE(ios(13.4)){ _dw_event_handler(self, key, 2); }
--(void)setColor:(unsigned long)input
-{
-    id orig = bgcolor;
-
-    if(input == _dw_colors[DW_CLR_DEFAULT])
-    {
-        bgcolor = nil;
-    }
-    else
-    {
-        bgcolor = [[UIColor colorWithRed: DW_RED_VALUE(input)/255.0 green: DW_GREEN_VALUE(input)/255.0 blue: DW_BLUE_VALUE(input)/255.0 alpha: 1] retain];
-        if(UIGraphicsGetCurrentContext())
-        {
-            [bgcolor set];
-            UIRectFill([self bounds]);
-        }
-    }
-    [self setNeedsDisplay];
-    [orig release];
-}
 @end
 
 @interface DWWindow : UIWindow
@@ -3708,10 +3677,30 @@
     /* Handle calendar */
     else if([object isMemberOfClass:[DWCalendar class]])
     {
-            CGSize size = [object intrinsicContentSize];
-
+        DWCalendar *calendar = object;
+        CGSize size = [calendar intrinsicContentSize];
+
+        /* If we can't detect the size... */
+        if(size.width < 1 || size.height < 1)
+        {
+            if(DWOSMajor >= 14)
+            {
+                /* Bigger new style in ios 14 */
+                thiswidth = 200;
+                thisheight = 200;
+            }
+            else
+            {
+                /* Smaller spinner style in iOS 13 and earlier */
+                thiswidth = 200;
+                thisheight = 100;
+            }
+        }
+        else
+        {
             thiswidth = size.width;
             thisheight = size.height;
+        }
     }
     /* MLE and Container */
     else if([object isMemberOfClass:[DWMLE class]] ||
@@ -8135,7 +8124,6 @@
     {
         DWBox *box = object;
 
-        [box setColor:_back];
         [box setBackgroundColor:bg];
     }
     else if([object isKindOfClass:[UITableView class]])