wxSUNKEN_BORDER | wxDOUBLE_BORDER)) != 0;
}
-// Deferred window moving
-bool wxMoveWindowDeferred(HDWP& hdwp, wxWindowBase* win, HWND hWnd, int x, int y, int width, int height);
-
// ----------------------------------------------------------------------------
// functions mapping HWND to wxWindow
// ----------------------------------------------------------------------------
// has the window been frozen by Freeze()?
bool IsFrozen() const { return m_frozenness > 0; }
+ // this simply moves/resizes the given HWND which is supposed to be our
+ // sibling (this is useful for controls which are composite at MSW level
+ // and for which DoMoveWindow() is not enough)
+ void DoMoveSibling(WXHWND hwnd, int x, int y, int width, int height);
+
// move the window to the specified location and resize it: this is called
// from both DoSetSize() and DoSetClientSize() and would usually just call
// ::MoveWindow() except for composite controls which will want to arrange
#include "wx/msw/subwin.h"
-// This is switched off because in some situations, the radiobox
-// buttons simply don't appear when deferred sizing is on.
-// Instead, refreshing on WM_MOVE seems to at least cure the droppings.
-#define USE_DEFERRED_SIZING 0
-
#if wxUSE_TOOLTIPS
#if !defined(__GNUWIN32_OLD__) || defined(__CYGWIN10__)
#include <commctrl.h>
height = heightOld;
}
- // if our parent had prepared a defer window handle for us, use it (unless
- // we are a top level window)
-
-#if USE_DEFERRED_SIZING
- wxWindowMSW *parent = GetParent();
- HDWP hdwp = parent && !IsTopLevel() ? (HDWP)parent->m_hDWP : NULL;
-#else
- HDWP hdwp = 0;
-#endif
-
- wxMoveWindowDeferred(hdwp, this, GetHwnd(), xx, yy, width, height);
+ DoMoveWindow(xx, yy, width, height);
// Now position all the buttons: the current button will be put at
// wxPoint(x_offset, y_offset) and the new row/column will start at
x_offset += widthBtn + cx1;
}
}
-
-#if USE_DEFERRED_SIZING
- if (parent)
- {
- // hdwp must be updated as it may have been changed
- parent->m_hDWP = (WXHANDLE)hdwp;
- }
-#endif
}
// ----------------------------------------------------------------------------
#include <commctrl.h>
#endif
-#define USE_DEFERRED_SIZING 1
-
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
return;
}
- // if our parent had prepared a defer window handle for us, use it (unless
- // we are a top level window)
- wxWindowMSW *parent = GetParent();
-
-#if USE_DEFERRED_SIZING
- HDWP hdwp = parent && !IsTopLevel() ? (HDWP)parent->m_hDWP : NULL;
-#else
- HDWP hdwp = 0;
-#endif
-
// be careful to position the slider itself after moving the labels as
// otherwise our GetBoundingBox(), which is called from WM_SIZE handler,
// would return a wrong result and wrong size would be cached internally
// position all labels: min at the top, value in the middle and max at
// the bottom
- wxMoveWindowDeferred(hdwp, this, (*m_labels)[SliderLabel_Min],
+ DoMoveSibling((HWND)(*m_labels)[SliderLabel_Min],
xLabel, y, wLabel, hLabel);
- wxMoveWindowDeferred(hdwp, this, (*m_labels)[SliderLabel_Value],
+ DoMoveSibling((HWND)(*m_labels)[SliderLabel_Value],
xLabel, y + (height - hLabel)/2, wLabel, hLabel);
- wxMoveWindowDeferred(hdwp, this, (*m_labels)[SliderLabel_Max],
- xLabel, y + height - hLabel, wLabel, hLabel);
+ DoMoveSibling((HWND)(*m_labels)[SliderLabel_Max],
+ xLabel, y + height - hLabel, wLabel, hLabel);
// position the slider itself along the left/right edge
- wxMoveWindowDeferred(hdwp, this, GetHwnd(),
- HasFlag(wxSL_LEFT) ? x : x + wLabel + HGAP,
- y + hLabel/2,
- width - wLabel - HGAP,
- height - hLabel);
+ wxSliderBase::DoMoveWindow(HasFlag(wxSL_LEFT) ? x : x + wLabel + HGAP,
+ y + hLabel/2,
+ width - wLabel - HGAP,
+ height - hLabel);
}
else // horizontal
{
// position all labels: min on the left, value in the middle and max to
// the right
- wxMoveWindowDeferred(hdwp, this, (*m_labels)[SliderLabel_Min],
- x, yLabel, wLabel, hLabel);
+ DoMoveSibling((HWND)(*m_labels)[SliderLabel_Min],
+ x, yLabel, wLabel, hLabel);
- wxMoveWindowDeferred(hdwp, this, (*m_labels)[SliderLabel_Value],
- x + (width - wLabel)/2, yLabel, wLabel, hLabel);
+ DoMoveSibling((HWND)(*m_labels)[SliderLabel_Value],
+ x + (width - wLabel)/2, yLabel, wLabel, hLabel);
- wxMoveWindowDeferred(hdwp, this, (*m_labels)[SliderLabel_Max],
- x + width - wLabel, yLabel, wLabel, hLabel);
+ DoMoveSibling((HWND)(*m_labels)[SliderLabel_Max],
+ x + width - wLabel, yLabel, wLabel, hLabel);
// position the slider itself along the top/bottom edge
- wxMoveWindowDeferred(hdwp, this, GetHwnd(),
- x,
- HasFlag(wxSL_TOP) ? y : y + hLabel,
- width,
- height - hLabel);
+ wxSliderBase::DoMoveWindow(x,
+ HasFlag(wxSL_TOP) ? y : y + hLabel,
+ width,
+ height - hLabel);
}
-
-#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
#include <limits.h> // for INT_MIN
-#define USE_DEFERRED_SIZING 1
-#define USE_DEFER_BUG_WORKAROUND 0
-
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
from = 0;
}
- ::SendMessage((HWND)m_hwndBuddy, EM_SETSEL, (WPARAM)from, (LPARAM)to);
+ ::SendMessage(GetBuddyHwnd(), EM_SETSEL, (WPARAM)from, (LPARAM)to);
}
// ----------------------------------------------------------------------------
wxLogDebug(_T("not enough space for wxSpinCtrl!"));
}
- // if our parent had prepared a defer window handle for us, use it (unless
- // we are a top level window)
- wxWindowMSW *parent = GetParent();
-
-#if USE_DEFERRED_SIZING
- HDWP hdwp = parent && !IsTopLevel() ? (HDWP)parent->m_hDWP : NULL;
-#else
- HDWP hdwp = 0;
-#endif
-
// 1) The buddy window
- wxMoveWindowDeferred(hdwp, this, GetBuddyHwnd(),
- x, y, widthText, height);
+ DoMoveSibling(m_hwndBuddy, x, y, widthText, height);
// 2) The button window
x += widthText + MARGIN_BETWEEN;
- wxMoveWindowDeferred(hdwp, this, GetHwnd(),
- x, y, widthBtn, height);
-
-#if USE_DEFERRED_SIZING
- if (parent)
- {
- // hdwp must be updated as it may have been changed
- parent->m_hDWP = (WXHANDLE)hdwp;
- }
-#endif
+ wxSpinButton::DoMoveWindow(x, y, widthBtn, height);
}
// get total size of the control
#define HAVE_TRACKMOUSEEVENT
#endif // everything needed for TrackMouseEvent()
+// if this is set to 1, we use deferred window sizing to reduce flicker when
+// resizing complicated window hierarchies, but this can in theory result in
+// different behaviour than the old code so we keep the possibility to use it
+// by setting this to 0 (in the future this should be removed completely)
#define USE_DEFERRED_SIZING 1
-#define USE_DEFER_BUG_WORKAROUND 1
// ---------------------------------------------------------------------------
// global variables
if ( parent )
hParentWnd = GetWinHwnd(parent);
- // Since we now have the absolute screen coords, if there's a parent we
- // must subtract its top left corner
+ // Since we now have the absolute screen coords, if there's a
+ // parent we must subtract its top left corner
if ( hParentWnd )
{
::ScreenToClient(hParentWnd, &point);
if ( parent )
{
- // We may be faking the client origin. So a window that's really at (0,
- // 30) may appear (to wxWin apps) to be at (0, 0).
+ // We may be faking the client origin. So a window that's
+ // really at (0, 30) may appear (to wxWin apps) to be at (0, 0).
wxPoint pt(parent->GetClientAreaOrigin());
point.x -= pt.x;
point.y -= pt.y;
*y = pt.y;
}
+void
+wxWindowMSW::DoMoveSibling(WXHWND hwnd, int x, int y, int width, int height)
+{
+#if USE_DEFERRED_SIZING
+ // if our parent had prepared a defer window handle for us, use it (unless
+ // we are a top level window)
+ wxWindowMSW * const parent = IsTopLevel() ? NULL : GetParent();
+
+ HDWP hdwp = parent ? (HDWP)parent->m_hDWP : NULL;
+ if ( hdwp )
+ {
+ hdwp = ::DeferWindowPos(hdwp, (HWND)hwnd, NULL, x, y, width, height,
+ SWP_NOZORDER);
+ if ( !hdwp )
+ {
+ wxLogLastError(_T("DeferWindowPos"));
+ }
+ }
+
+ if ( parent )
+ {
+ // hdwp must be updated as it may have been changed
+ parent->m_hDWP = (WXHANDLE)hdwp;
+ }
+
+ // otherwise (or if deferring failed) move the window in place immediately
+ if ( !hdwp )
+#endif // USE_DEFERRED_SIZING
+ {
+ if ( !::MoveWindow((HWND)hwnd, x, y, width, height, IsShown()) )
+ {
+ wxLogLastError(wxT("MoveWindow"));
+ }
+ }
+}
+
void wxWindowMSW::DoMoveWindow(int x, int y, int width, int height)
{
// TODO: is this consistent with other platforms?
if (height < 0)
height = 0;
- // if our parent had prepared a defer window handle for us, use it (unless
- // we are a top level window)
- wxWindowMSW *parent = GetParent();
-
-#if USE_DEFERRED_SIZING
- HDWP hdwp = parent && !IsTopLevel() ? (HDWP)parent->m_hDWP : NULL;
-#else
- HDWP hdwp = 0;
-#endif
-
- wxMoveWindowDeferred(hdwp, this, GetHwnd(), x, y, width, height);
-
-#if USE_DEFERRED_SIZING
- if ( parent )
- // hdwp must be updated as it may have been changed
- parent->m_hDWP = (WXHANDLE)hdwp;
-#endif
+ DoMoveSibling(m_hWnd, x, y, width, height);
}
// set the size of the window: if the dimensions are positive, just use them,
int currentX, currentY;
int currentW, currentH;
-#if USE_DEFER_BUG_WORKAROUND
- currentX = m_pendingPosition.x;
- if (currentX == wxDefaultCoord)
- GetPosition(¤tX, NULL);
-
- currentY = m_pendingPosition.y;
- if (currentY == wxDefaultCoord)
- GetPosition(NULL, ¤tY);
-
- currentW = m_pendingSize.x;
- if (currentW == wxDefaultCoord)
- GetSize(¤tW, NULL);
-
- currentH = m_pendingSize.y;
- if (currentH == wxDefaultCoord)
- GetSize(NULL, ¤tH);
-#else
GetPosition(¤tX, ¤tY);
GetSize(¤tW, ¤tH);
-#endif
// ... and don't do anything (avoiding flicker) if it's already ok
if ( x == currentX && y == currentY &&
}
}
-#if USE_DEFER_BUG_WORKAROUND
- // We don't actually use the hdwp here, but we need to know whether to
- // save the pending dimensions or not. This isn't done in DoMoveWindow
- // (where the hdwp is used) because some controls have thier own
- // DoMoveWindow so it is easier to catch it here.
- wxWindowMSW *parent = GetParent();
- HDWP hdwp = parent && !IsTopLevel() ? (HDWP)parent->m_hDWP : NULL;
- if (hdwp)
- {
- m_pendingPosition = wxPoint(x, y);
- m_pendingSize = wxSize(width, height);
- }
- else
- {
- m_pendingPosition = wxDefaultPosition;
- m_pendingSize = wxDefaultSize;
- }
-#endif
-
+ m_pendingPosition = wxPoint(x, y);
+ m_pendingSize = wxSize(width, height);
DoMoveWindow(x, y, width, height);
}
wxLogLastError(_T("EndDeferWindowPos"));
}
-#if USE_DEFER_BUG_WORKAROUND
// Reset our children's pending pos/size values.
for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
node;
child->m_pendingPosition = wxDefaultPosition;
child->m_pendingSize = wxDefaultSize;
}
-#endif
}
-#endif
+#endif // USE_DEFERRED_SIZING
return processed;
}
#endif // wxUSE_HOTKEY
-// Moves a window by deferred method or normal method
-bool wxMoveWindowDeferred(HDWP& hdwp, wxWindowBase* win, HWND hWnd, int x, int y, int width, int height)
-{
- if ( hdwp )
- {
- hdwp = ::DeferWindowPos(hdwp, hWnd, NULL,
- x, y, width, height,
- SWP_NOZORDER);
- if ( !hdwp )
- {
- wxLogLastError(_T("DeferWindowPos"));
- }
- }
-
- // otherwise (or if deferring failed) move the window in place immediately
- if ( !hdwp )
- {
- if ( !::MoveWindow(hWnd, x, y, width, height, win->IsShown()) )
- {
- wxLogLastError(wxT("MoveWindow"));
- }
- }
- return hdwp != NULL;
-}
-
// Not tested under WinCE
#ifndef __WXWINCE__