]> git.saurik.com Git - wxWidgets.git/commitdiff
Removed previous broken fix for deferred positioning bug, and added
authorJulian Smart <julian@anthemion.co.uk>
Fri, 29 Apr 2005 18:58:38 +0000 (18:58 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Fri, 29 Apr 2005 18:58:38 +0000 (18:58 +0000)
fix using sizers, which works better

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33918 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/msw/window.h
src/msw/radiobox.cpp
src/msw/slider95.cpp
src/msw/spinctrl.cpp
src/msw/window.cpp

index 5500ee0fd445110ddda98d7fd90698ad9823684c..5e712b3e0a1c687d6a5b3817c1a129109da2794b 100644 (file)
@@ -23,6 +23,9 @@ wxMSW:
   by refreshing parent when the radio box moves.
 - Added ability set the system option "msw.staticbox.optimized-paint" to 0 to
   allow a panel to paint graphics around controls within a static box.
+- Worked around an apparent bug in deferred window positioning (moving a
+  window from (x, y) to (a, b) and back to (x, y) misses the last step) by
+  checking window positions against corresponding sizer state, if any.
 
 wxMac:
 
index 377afca91b5d180b5ecce87b4129505323200eaf..b5058d57da8ca39520a8b737f69fb22826b72799 100644 (file)
@@ -544,17 +544,5 @@ WX_DECLARE_HASH(wxWindowMSW, wxWindowList, wxWinHashTable);
 
 extern wxWinHashTable *wxWinHandleHash;
 
-// ----------------------------------------------------------------------------
-// extra data needed for correcting problems with deferred positioning
-// ----------------------------------------------------------------------------
-
-struct wxExtraWindowData
-{
-    // Stored during deferred positioning
-    wxPoint m_pos;
-    wxSize  m_size;
-    bool    m_deferring:1;
-};
-
 #endif
     // _WX_WINDOW_H_
index 181a778ae08fda5681047c14e11b988f86ae61dd..50e27bae8dbb4b8bec190469b0eb0d8130e968bb 100644 (file)
@@ -657,22 +657,14 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
             x_offset += widthBtn + cx1;
         }
     }
-    if (hdwp)
-    {
-        // Store the size so we can report it accurately
-        wxExtraWindowData* extraData = (wxExtraWindowData*) m_windowReserved;
-        if (!extraData)
-        {
-            extraData = new wxExtraWindowData;
-            m_windowReserved = (void*) extraData;
-        }
-        extraData->m_pos = wxPoint(xx, yy);
-        extraData->m_size = wxSize(width, height);
-        extraData->m_deferring = true;
 
+#if USE_DEFERRED_SIZING
+    if (parent)
+    {
         // hdwp must be updated as it may have been changed
         parent->m_hDWP = (WXHANDLE)hdwp;
     }
+#endif
 }
 
 // ----------------------------------------------------------------------------
index 35380bd868ae503f2e426cbd1d4412d2cf5ac6af..f9106b7830f51312bb63e7d7d669969d038e81a2 100644 (file)
@@ -43,7 +43,6 @@
 #endif
 
 #define USE_DEFERRED_SIZING 1
-#define USE_DEFER_BUG_WORKAROUND 0
 
 // ----------------------------------------------------------------------------
 // constants
@@ -507,22 +506,14 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
                      width,
                      height - hLabel);
     }
-    if ( hdwp )
-    {
-        // Store the size so we can report it accurately
-        wxExtraWindowData* extraData = (wxExtraWindowData*) m_windowReserved;
-        if (!extraData)
-        {
-            extraData = new wxExtraWindowData;
-            m_windowReserved = (void*) extraData;
-        }
-        extraData->m_pos = wxPoint(x, y);
-        extraData->m_size = wxSize(width, height);
-        extraData->m_deferring = true;
 
+#if USE_DEFERRED_SIZING
+    if ( parent )
+    {
         // hdwp must be updated as it may have been changed
         parent->m_hDWP = (WXHANDLE)hdwp;
     }
+#endif
 }
 
 wxSize wxSlider::DoGetBestSize() const
index b33dee669ba330e10f1a0f2a8267513267add69e..606772143fa4cb414f81def6786d8d61d2dd4a31 100644 (file)
@@ -590,37 +590,18 @@ void wxSpinCtrl::DoMoveWindow(int x, int y, int width, int height)
     wxMoveWindowDeferred(hdwp, this, GetHwnd(),
                      x, y, widthBtn, height);
 
-    if (hdwp)
+#if USE_DEFERRED_SIZING
+    if (parent)
     {
-        // Store the size so we can report it accurately
-        wxExtraWindowData* extraData = (wxExtraWindowData*) m_windowReserved;
-        if (!extraData)
-        {
-            extraData = new wxExtraWindowData;
-            m_windowReserved = (void*) extraData;
-        }
-        extraData->m_pos = wxPoint(originalX, y);
-        extraData->m_size = wxSize(width, height);
-        extraData->m_deferring = true;
-
         // hdwp must be updated as it may have been changed
         parent->m_hDWP = (WXHANDLE)hdwp;
     }
+#endif
 }
 
 // get total size of the control
 void wxSpinCtrl::DoGetSize(int *x, int *y) const
 {
-#if USE_DEFER_BUG_WORKAROUND
-    wxExtraWindowData* extraData = (wxExtraWindowData*) m_windowReserved;
-    if (extraData && extraData->m_deferring && GetParent() && GetParent()->m_hDWP)
-    {
-        *x = extraData->m_size.x;        
-        *y = extraData->m_size.y;
-        return;
-    }
-#endif
-    
     RECT spinrect, textrect, ctrlrect;
     GetWindowRect(GetHwnd(), &spinrect);
     GetWindowRect(GetBuddyHwnd(), &textrect);
@@ -634,16 +615,6 @@ void wxSpinCtrl::DoGetSize(int *x, int *y) const
 
 void wxSpinCtrl::DoGetPosition(int *x, int *y) const
 {
-#if USE_DEFER_BUG_WORKAROUND
-    wxExtraWindowData* extraData = (wxExtraWindowData*) m_windowReserved;
-    if (extraData && extraData->m_deferring && GetParent() && GetParent()->m_hDWP)
-    {
-        *x = extraData->m_pos.x;        
-        *y = extraData->m_pos.y;
-        return;
-    }
-#endif
-
     // hack: pretend that our HWND is the text control just for a moment
     WXHWND hWnd = GetHWND();
     wxConstCast(this, wxSpinCtrl)->m_hWnd = m_hwndBuddy;
index c2a83c03479db67175c1371610f21c6cf4ac24ca..d72864aa135df7783ed3837ad651afcf7f62bd53 100644 (file)
 #endif // everything needed for TrackMouseEvent()
 
 #define USE_DEFERRED_SIZING 1
-#define USE_DEFER_BUG_WORKAROUND 0
+#define USE_DEFER_BUG_WORKAROUND 1
 
 // ---------------------------------------------------------------------------
 // global variables
@@ -471,12 +471,6 @@ wxWindowMSW::~wxWindowMSW()
 {
     m_isBeingDeleted = true;
 
-    if (m_windowReserved)
-    {
-        delete (wxExtraWindowData*) m_windowReserved;
-        m_windowReserved = NULL;
-    }
-
 #ifndef __WXUNIVERSAL__
     // VS: make sure there's no wxFrame with last focus set to us:
     for ( wxWindow *win = GetParent(); win; win = win->GetParent() )
@@ -1452,16 +1446,6 @@ void wxWindowMSW::DoSetToolTip(wxToolTip *tooltip)
 // Get total size
 void wxWindowMSW::DoGetSize(int *x, int *y) const
 {
-#if USE_DEFER_BUG_WORKAROUND
-    wxExtraWindowData* extraData = (wxExtraWindowData*) m_windowReserved;
-    if (extraData && extraData->m_deferring && GetParent() && GetParent()->m_hDWP)
-    {
-        *x = extraData->m_size.x;        
-        *y = extraData->m_size.y;
-        return;
-    }
-#endif
-
     RECT rect = wxGetWindowRect(GetHwnd());
 
     if ( x )
@@ -1483,16 +1467,6 @@ void wxWindowMSW::DoGetClientSize(int *x, int *y) const
 
 void wxWindowMSW::DoGetPosition(int *x, int *y) const
 {
-#if USE_DEFER_BUG_WORKAROUND
-    wxExtraWindowData* extraData = (wxExtraWindowData*) m_windowReserved;
-    if (extraData && extraData->m_deferring && GetParent() && GetParent()->m_hDWP)
-    {
-        *x = extraData->m_pos.x;        
-        *y = extraData->m_pos.y;
-        return;
-    }
-#endif
-
     RECT rect = wxGetWindowRect(GetHwnd());
 
     POINT point;
@@ -1584,22 +1558,11 @@ void wxWindowMSW::DoMoveWindow(int x, int y, int width, int height)
 
     wxMoveWindowDeferred(hdwp, this, GetHwnd(), x, y, width, height);
 
-    if ( hdwp )
-    {
-        // Store the size so we can report it accurately
-        wxExtraWindowData* extraData = (wxExtraWindowData*) m_windowReserved;
-        if (!extraData)
-        {
-            extraData = new wxExtraWindowData;
-            m_windowReserved = (void*) extraData;
-        }
-        extraData->m_pos = wxPoint(x, y);
-        extraData->m_size = wxSize(width, height);
-        extraData->m_deferring = true;
-
+#if USE_DEFERRED_SIZING
+    if ( parent )
         // hdwp must be updated as it may have been changed
         parent->m_hDWP = (WXHANDLE)hdwp;
-    }
+#endif
 }
 
 // set the size of the window: if the dimensions are positive, just use them,
@@ -4255,15 +4218,14 @@ bool wxWindowMSW::HandleSize(int WXUNUSED(w), int WXUNUSED(h), WXUINT wParam)
               node = node->GetNext() )
         {
             wxWindow *child = node->GetData();
-            wxExtraWindowData* extraData = (wxExtraWindowData*) child->m_windowReserved;
-            if (extraData && extraData->m_deferring)
+            wxSizer* sizer = child->GetContainingSizer();
+            if (sizer)
             {
-                wxPoint pos = child->GetPosition();
-                
-                if (extraData->m_pos != pos)
-                    child->Move(extraData->m_pos);
-                
-                extraData->m_deferring = false;
+                wxSizerItem* item = sizer->GetItem(child, true);
+                if (item->GetRect().GetPosition() != child->GetPosition())
+                {
+                    child->Move(item->GetRect().GetPosition());
+                }
             }
         }
 #endif