changeset 2591:f3d423cdbc2e

iOS: Collection of various fixes... UIButtonTypeRoundedRect is deprecated use UIButtonTypeSystem for text buttons. Use UIButtonTypeCustom for bitmap buttons so it doesn't tint the images. Fix error in the timer disconnect handler from the HTIMER change. Set the largetContentTitle with dw_window_set_text() on DWWindow along with changing the navigation bar title if it exists.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 25 May 2021 15:15:09 +0000
parents 8352c38bc20b
children dbb189c5d398
files ios/dw.m
diffstat 1 files changed, 17 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/ios/dw.m	Tue May 25 01:25:32 2021 +0000
+++ b/ios/dw.m	Tue May 25 15:15:09 2021 +0000
@@ -348,7 +348,7 @@
                 int (* API timerfunc)(void *) = (int (* API)(void *))handler->signalfunction;
 
                 if(!timerfunc(handler->data))
-                    dw_timer_disconnect(handler->id);
+                    dw_timer_disconnect(handler->window);
                 return 0;
             }
             /* Configure/Resize event */
@@ -4081,9 +4081,9 @@
 }
 
 /* Internal function to create a basic button, used by all button types */
-HWND _dw_internal_button_new(const char *text, ULONG cid)
-{
-    DWButton *button = [[DWButton buttonWithType:UIButtonTypeRoundedRect] retain];
+HWND _dw_internal_button_new(const char *text, ULONG cid, UIButtonType type)
+{
+    DWButton *button = [[DWButton buttonWithType:type] retain];
     if(text)
     {
         [button setTitle:[NSString stringWithUTF8String:text] forState:UIControlStateNormal];
@@ -4110,7 +4110,7 @@
 DW_FUNCTION_RETURN(dw_button_new, HWND)
 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
 {
-    DWButton *button = _dw_internal_button_new(text, cid);
+    DWButton *button = _dw_internal_button_new(text, cid, UIButtonTypeSystem);
     [button setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
     DW_FUNCTION_RETURN_THIS(button);
 }
@@ -4180,7 +4180,7 @@
     NSString *respath = [bundle resourcePath];
     NSString *filepath = [respath stringByAppendingFormat:@"/%lu.png", cid];
     UIImage *image = [[UIImage alloc] initWithContentsOfFile:filepath];
-    DWButton *button = _dw_internal_button_new("", cid);
+    DWButton *button = _dw_internal_button_new("", cid, UIButtonTypeCustom);
     if(image)
     {
         [button setImage:image forState:UIControlStateNormal];
@@ -4213,7 +4213,7 @@
         nstr = [nstr stringByAppendingString: [NSString stringWithUTF8String:ext]];
         image = [[UIImage alloc] initWithContentsOfFile:nstr];
     }
-    DWButton *button = _dw_internal_button_new("", cid);
+    DWButton *button = _dw_internal_button_new("", cid, UIButtonTypeCustom);
     if(image)
     {
         [button setImage:image forState:UIControlStateNormal];
@@ -4238,7 +4238,7 @@
 {
     NSData *thisdata = [NSData dataWithBytes:data length:len];
     UIImage *image = [[UIImage alloc] initWithData:thisdata];
-    DWButton *button = _dw_internal_button_new("", cid);
+    DWButton *button = _dw_internal_button_new("", cid, UIButtonTypeCustom);
     if(image)
     {
         [button setImage:image forState:UIControlStateNormal];
@@ -4338,7 +4338,7 @@
 DW_FUNCTION_RETURN(dw_radiobutton_new, HWND)
 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
 {
-    DWButton *button = _dw_internal_button_new(text, cid);
+    DWButton *button = _dw_internal_button_new(text, cid, UIButtonTypeSystem);
     [button setType:_DW_BUTTON_TYPE_RADIO];
     DW_FUNCTION_RETURN_THIS(button);
 }
@@ -4490,7 +4490,7 @@
 DW_FUNCTION_RETURN(dw_checkbox_new, HWND)
 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
 {
-    DWButton *button = _dw_internal_button_new(text, cid);
+    DWButton *button = _dw_internal_button_new(text, cid, UIButtonTypeSystem);
     [button setType:_DW_BUTTON_TYPE_CHECK];
     DW_FUNCTION_RETURN_THIS(button);
 }
@@ -8029,7 +8029,7 @@
     NSObject *object = handle;
     int retval = DW_ERROR_NONE;
 
-    if([ object isMemberOfClass:[ DWWindow class ] ])
+    if([ object isMemberOfClass:[DWWindow class]])
     {
         DWWindow *window = handle;
         CGRect rect = [window frame];
@@ -8569,15 +8569,18 @@
     {
         DWWindow *window = object;
         NSArray *array = [window subviews];
-        
+        NSString *nstr = [NSString stringWithUTF8String:text];
+
+        [window setLargeContentTitle:nstr];
+
         for(id obj in array)
         {
             if([obj isMemberOfClass:[UINavigationBar class]])
             {
                 UINavigationBar *nav = obj;
                 UINavigationItem *item = [[nav items] firstObject];
-                
-                [item setTitle:[NSString stringWithUTF8String:text]];
+
+                [item setTitle:nstr];
             }
         }
     }