changeset 2430:e08968d21d45

iOS: Additional code to calculate spinbutton size. Spinbuttons on iOS are unusually large, don't use a specific value in dwtest... let the system decide so the spinbutton isn't clipped on iOS.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 05 Apr 2021 15:24:08 +0000
parents 89f4aba2e387
children b0e6f8f0a1ff
files dwtest.c ios/dw.m
diffstat 2 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/dwtest.c	Mon Apr 05 14:36:23 2021 +0000
+++ b/dwtest.c	Mon Apr 05 15:24:08 2021 +0000
@@ -1407,7 +1407,7 @@
         dw_window_set_style(text, DW_DT_VCENTER, DW_DT_VCENTER);
         dw_box_pack_start(hbox, text, -1, -1, FALSE, TRUE, 1);
         fontsize = dw_spinbutton_new("9", 0);
-        dw_box_pack_start(hbox, fontsize, 50, -1, FALSE, FALSE, 1);
+        dw_box_pack_start(hbox, fontsize, -1, -1, FALSE, FALSE, 1);
         dw_spinbutton_set_limits(fontsize, 100, 5);
         dw_spinbutton_set_pos(fontsize, 9);
         fontname = dw_combobox_new("Default", 0);
--- a/ios/dw.m	Mon Apr 05 14:36:23 2021 +0000
+++ b/ios/dw.m	Mon Apr 05 15:24:08 2021 +0000
@@ -3264,9 +3264,9 @@
 
         if([object isEditable])
         {
-            /* Spinbuttons don't need to be as wide */
+            /* Spinbutton text doesn't need to be as wide */
             if([handle isMemberOfClass:[DWSpinButton class]])
-                thiswidth = 100;
+                thiswidth = 50;
             else
                 thiswidth = 150;
         }
@@ -3274,6 +3274,19 @@
 
         if(font)
             thisheight = (int)[font lineHeight];
+        
+        /* Spinbuttons need some extra */
+        if([handle isMemberOfClass:[DWSpinButton class]])
+        {
+            DWSpinButton *spinbutton = handle;
+            CGSize size = [[spinbutton stepper] intrinsicContentSize];
+            
+            /* Add the stepper width as extra... */
+            extrawidth = size.width;
+            /* The height should be the bigger of the two */
+            if(size.height > thisheight)
+                thisheight = size.height;
+        }
     }
     /* Handle the ranged widgets */
     else if([object isMemberOfClass:[DWPercent class]] ||