changeset 1530:eecfceaf581f

On Mac allow dw_window_get_preferred_size() to work on windows and boxes.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 07 Jan 2012 03:46:10 +0000
parents 92bed442620a
children 783a464afab2
files mac/dw.m
diffstat 1 files changed, 39 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mac/dw.m	Thu Jan 05 15:55:26 2012 +0000
+++ b/mac/dw.m	Sat Jan 07 03:46:10 2012 +0000
@@ -8544,7 +8544,45 @@
  */
 void API dw_window_get_preferred_size(HWND handle, int *width, int *height)
 {
-    _control_size(handle, width, height);
+    id object = handle;
+    
+    if([object isMemberOfClass:[DWWindow class]])
+    {
+        Box *thisbox;
+        
+        if((thisbox = [[object contentView] box]))
+        {
+            int depth = 0;
+            NSRect frame;
+            
+            /* Calculate space requirements */
+            _resize_box(thisbox, &depth, 0, 0, 1);
+            
+            frame = [NSWindow frameRectForContentRect:NSMakeRect(0, 0, thisbox->minwidth, thisbox->minheight) styleMask:[object styleMask]];
+            
+            /* Might need to take into account the window border here */
+            if(width) *width = frame.size.width;
+            if(height) *height = frame.size.height;
+        }
+    }
+    else if([object isMemberOfClass:[DWBox class]])
+    {
+        Box *thisbox;
+        
+        if((thisbox = [object box]))
+        {
+            int depth = 0;
+            
+            /* Calculate space requirements */
+            _resize_box(thisbox, &depth, 0, 0, 1);
+            
+            /* Might need to take into account the window border here */
+            if(width) *width = thisbox->minwidth;
+            if(height) *height = thisbox->minheight;
+        }
+    }
+    else
+        _control_size(handle, width, height);
 }
 
 /*