changeset 1498:f8b4d6075cac

Added auto-size support during dw_window_set_pos() on OS/2, Mac and Windows. Since dw_window_set_pos() can have unexpected results on unsized windows... if a window is unsized attempt to auto-size at that point. Auto-sizing during dw_window_set_pos() will cause auto-sizing not to happen during dw_window_show() so make sure it is completely packed before setting the position.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 25 Dec 2011 13:56:30 +0000
parents 99a53823079f
children 97e5e8688fe1
files mac/dw.m os2/dw.c win/dw.c
diffstat 3 files changed, 25 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mac/dw.m	Sun Dec 25 06:58:53 2011 +0000
+++ b/mac/dw.m	Sun Dec 25 13:56:30 2011 +0000
@@ -8595,8 +8595,16 @@
     {
         DWWindow *window = handle;
         NSPoint point;
-        NSSize size = [window frame].size;
-        
+        NSSize size = [[window contentView] frame].size;
+
+        /* Can't position an unsized window, so attempt to auto-size */
+        if(size.width <= 1 || size.height <= 1)
+        {
+            /* Determine the contents size */
+            dw_window_set_size(handle, 0, 0);
+        }
+
+        size = [window frame].size;
         _handle_gravity(handle, &x, &y, (unsigned long)size.width, (unsigned long)size.height);
         
         point.x = x;
--- a/os2/dw.c	Sun Dec 25 06:58:53 2011 +0000
+++ b/os2/dw.c	Sun Dec 25 13:56:30 2011 +0000
@@ -7084,8 +7084,14 @@
 void API dw_window_set_pos(HWND handle, LONG x, LONG y)
 {
    unsigned long width, height;
-   
+
    dw_window_get_pos_size(handle, NULL, NULL, &width, &height);
+   /* Can't position an unsized window, so attempt to auto-size */
+   if(width == 0 || height == 0)
+   {
+      dw_window_set_size(handle, 0, 0);
+      dw_window_get_pos_size(handle, NULL, NULL, &width, &height);
+   }
    _handle_gravity(handle, &x, &y, width, height);
    WinSetWindowPos(handle, NULLHANDLE, x, y, 0, 0, SWP_MOVE);
 }
--- a/win/dw.c	Sun Dec 25 06:58:53 2011 +0000
+++ b/win/dw.c	Sun Dec 25 13:56:30 2011 +0000
@@ -6714,7 +6714,14 @@
 void API dw_window_set_pos(HWND handle, long x, long y)
 {
    unsigned long width, height;
-   
+   RECT rect;
+
+   GetClientRect(handle, &rect);
+
+   /* Can't position an unsized window, so attempt to auto-size */
+   if((rect.bottom - rect.top) == 0 || (rect.right - rect.left) == 0)
+      dw_window_set_size(handle, 0, 0);
+
    dw_window_get_pos_size(handle, NULL, NULL, &width, &height);
    _handle_gravity(handle, &x, &y, width, height);
    SetWindowPos(handle, (HWND)NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);