diff mac/dw.m @ 1438:bde7ebced556

Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code... Improved auto-window sizing on Windows and added OS/2 and Mac support.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 08 Dec 2011 09:30:32 +0000
parents a50e8b486a1a
children 02a329b2b0cd
line wrap: on
line diff
--- a/mac/dw.m	Thu Dec 08 06:47:05 2011 +0000
+++ b/mac/dw.m	Thu Dec 08 09:30:32 2011 +0000
@@ -2674,6 +2674,8 @@
                         [split splitViewDidResizeSubviews:nil];
                     }
                 }
+                
+                /* Advance the current position in the box */
                 if(thisbox->type == DW_HORZ)
                     currentx += width + (pad * 2);
                 if(thisbox->type == DW_VERT)
@@ -8422,13 +8424,32 @@
     int _locked_by_me = FALSE;
     DW_MUTEX_LOCK;
     NSObject *object = handle;
-    NSSize size;
-    size.width = width;
-    size.height = height;
 
     if([ object isKindOfClass:[ NSWindow class ] ])
     {
         NSWindow *window = handle;
+        Box *thisbox;
+        NSSize size;
+       
+        /*
+         * The following is an attempt to dynamically size a window based on the size of its
+         * children before realization. Only applicable when width or height is less than one.
+         */
+        if((width < 1 || height < 1) && (thisbox = [[window contentView] box]))
+        {
+            int depth = 0;
+                
+            /* Calculate space requirements */
+            _resize_box(thisbox, &depth, width, height, 1);
+          
+            /* Might need to take into account the window border here */
+            if(width < 1) width = thisbox->minwidth;
+            if(height < 1) height = thisbox->minheight;
+        }
+       
+        /* Finally set the size */
+        size.width = width;
+        size.height = height;
         [window setContentSize:size];
     }
     DW_MUTEX_UNLOCK;