changeset 2419:65ff339e9cd2

iOS: A number of fixes, notebook layout select first page if none selected. DWText is a kind of UILabel so check Kind not Member. Disable the calendar control for now, since it was hanging the UI. Cleanup some of the dwtest changes, now that no tabs are disabled. Remove some unnecessary macros since functionality is included in the thread safety macros.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 03 Apr 2021 18:44:01 +0000
parents 50e1ddce0aeb
children 384d076ed52a
files dwtest.c ios/dw.m
diffstat 2 files changed, 28 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/dwtest.c	Sat Apr 03 02:54:19 2021 +0000
+++ b/dwtest.c	Sat Apr 03 18:44:01 2021 +0000
@@ -1167,7 +1167,6 @@
 {
     HTREEITEM t1,t2;
     HWND listbox;
-    char *title;
 
     /* create a box to pack into the notebook page */
     listbox = dw_listbox_new(1024, TRUE);
@@ -1182,6 +1181,8 @@
     tree = dw_tree_new(101);
     if(tree)
     {
+        char *title;
+
         dw_box_pack_start(notebookbox3, tree, 500, 200, TRUE, TRUE, 1);
 
         /* and a status area to see whats going on */
@@ -2164,7 +2165,6 @@
     dw_notebook_page_set_text( notebook, notebookpage6, "mdi");
     mdi_add();
 #endif
-
     notebookbox7 = dw_box_new( DW_VERT, 6 );
     notebookpage7 = dw_notebook_page_new( notebook, 1, FALSE );
     dw_notebook_pack( notebook, notebookpage7, notebookbox7 );
--- a/ios/dw.m	Sat Apr 03 02:54:19 2021 +0000
+++ b/ios/dw.m	Sat Apr 03 18:44:01 2021 +0000
@@ -1561,7 +1561,7 @@
 {
     NSInteger intpageid = [tabs selectedSegmentIndex];
     
-    if(intpageid != NSNotFound && intpageid < [views count])
+    if(intpageid != -1 && intpageid < [views count])
     {
         DWNotebookPage *page = [views objectAtIndex:intpageid];
 
@@ -2306,7 +2306,7 @@
                 DWNotebook *notebook = handle;
                 NSInteger intpageid = [[notebook tabs] selectedSegmentIndex];
                 
-                if(intpageid != NSNotFound && intpageid < [[notebook views] count])
+                if(intpageid != -1 && intpageid < [[notebook views] count])
                 {
                     DWNotebookPage *page = [[notebook views] objectAtIndex:intpageid];
 
@@ -2511,8 +2511,21 @@
                 {
                     DWNotebook *notebook = handle;
                     NSInteger intpageid = [[notebook tabs] selectedSegmentIndex];
-                    
-                    if(intpageid != NSNotFound && intpageid < [[notebook views] count])
+
+                    if(intpageid == -1)
+                    {
+                        if([[notebook tabs] numberOfSegments] > 0)
+                        {
+                            DWNotebookPage *notepage = [[notebook views] firstObject];
+
+                            /* If there is no selected segment, select the first one... */
+                            [[notebook tabs] setSelectedSegmentIndex:0];
+                            intpageid = 0;
+                            [notepage setHidden:NO];
+                        }
+                    }
+
+                    if(intpageid != -1 && intpageid < [[notebook views] count])
                     {
                         DWNotebookPage *page = [[notebook views] objectAtIndex:intpageid];
 
@@ -3223,7 +3236,7 @@
         if(thisheight > _DW_SCROLLED_MAX_HEIGHT)
             thisheight = _DW_SCROLLED_MAX_HEIGHT;
     }
-    else if([ object isMemberOfClass:[UILabel class] ])
+    else if([ object isKindOfClass:[UILabel class] ])
         nsstr = [object text];
     /* Any other control type */
     else if([ object isKindOfClass:[ UIControl class ] ])
@@ -6787,10 +6800,13 @@
 DW_FUNCTION_RETURN(dw_calendar_new, HWND)
 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
 {
+    DWCalendar *calendar = nil;
+#if 0 /* TODO: Figure out why this hangs the UI */
     DWCalendar *calendar = [[[DWCalendar alloc] init] retain];
     [calendar setDatePickerMode:UIDatePickerModeDate];
     [calendar setTag:cid];
     [calendar setDate:[NSDate date]];
+#endif
     DW_FUNCTION_RETURN_THIS(calendar);
 }
 
@@ -6807,8 +6823,7 @@
 {
     DWCalendar *calendar = handle;
     NSDate *date;
-    char buffer[101];
-    DW_LOCAL_POOL_IN;
+    char buffer[101] = {0};
 
     snprintf(buffer, 100, "%04d-%02d-%02d", year, month, day);
 
@@ -6818,7 +6833,6 @@
     date = [dateFormatter dateFromString:[NSString stringWithUTF8String:buffer]];
     [calendar setDate:date];
     [date release];
-    DW_LOCAL_POOL_OUT;
     DW_FUNCTION_RETURN_NOTHING;
 }
 
@@ -6833,7 +6847,6 @@
 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, year, unsigned int *, month, unsigned int *, day, unsigned int *)
 {
     DWCalendar *calendar = handle;
-    DW_LOCAL_POOL_IN;
     NSCalendar *mycalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
     NSDate *date = [calendar date];
     NSDateComponents* components = [mycalendar components:NSCalendarUnitDay|NSCalendarUnitMonth|NSCalendarUnitYear fromDate:date];
@@ -6841,7 +6854,6 @@
     *month = (unsigned int)[components month];
     *year = (unsigned int)[components year];
     [mycalendar release];
-    DW_LOCAL_POOL_OUT;
     DW_FUNCTION_RETURN_NOTHING;
 }
 
@@ -7309,14 +7321,6 @@
     [notepage autorelease];
     [notebook setPageid:(int)(page+1)];
 
-#if 0
-    if([views objectAtIndex:[[notebook tabs] selectedSegmentIndex]] == notepage)
-    {
-        /* If the page we added is the visible page.. lay it out */
-        [notebook pageChanged:notebook];
-    }
-    else
-#endif
     if([views count] != 1)
     {
         /* Otherwise hide the page */
@@ -7373,7 +7377,7 @@
     NSInteger index = [[notebook tabs] selectedSegmentIndex];
     unsigned long retval = 0;
     
-    if(index != NSNotFound)
+    if(index != -1)
     {
         NSMutableArray<DWNotebookPage *> *views = [notebook views];
         DWNotebookPage *notepage = [views objectAtIndex:index];
@@ -7402,9 +7406,9 @@
         NSMutableArray<DWNotebookPage *> *views = [notebook views];
         NSUInteger index = [views indexOfObject:notepage];
 
-        if(index != NSNotFound)
-        {
-            [notebook tabs].selectedSegmentIndex = index;
+        if(index != -1)
+        {
+            [[notebook tabs] setSelectedSegmentIndex:index];
         }
     }
     DW_FUNCTION_RETURN_NOTHING;