# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1325907970 0 # Node ID eecfceaf581f9d787928a7bd5375b9c8498ea537 # Parent 92bed442620a3e72a29993d3b081031fc1374558 On Mac allow dw_window_get_preferred_size() to work on windows and boxes. diff -r 92bed442620a -r eecfceaf581f mac/dw.m --- 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); } /*