X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/55079b432bf9e46f9b19efa71462b32022ffcf5e..233387bdcbb1c4f31c54b0fe6b3f03e8d261cab1:/src/msw/spinctrl.cpp diff --git a/src/msw/spinctrl.cpp b/src/msw/spinctrl.cpp index 606772143f..dbc1bdd3ff 100644 --- a/src/msw/spinctrl.cpp +++ b/src/msw/spinctrl.cpp @@ -13,11 +13,6 @@ // declarations // ============================================================================ -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "spinctrlbase.h" - #pragma implementation "spinctrl.h" -#endif - // ---------------------------------------------------------------------------- // headers // ---------------------------------------------------------------------------- @@ -45,9 +40,6 @@ #include // for INT_MIN -#define USE_DEFERRED_SIZING 1 -#define USE_DEFER_BUG_WORKAROUND 0 - // ---------------------------------------------------------------------------- // macros // ---------------------------------------------------------------------------- @@ -117,11 +109,12 @@ wxCONSTRUCTOR_6( wxSpinCtrl , wxWindow* , Parent , wxWindowID , Id , wxString , IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl, wxControl) #endif +//pmg EVT_KILL_FOCUS BEGIN_EVENT_TABLE(wxSpinCtrl, wxSpinButton) EVT_CHAR(wxSpinCtrl::OnChar) EVT_SET_FOCUS(wxSpinCtrl::OnSetFocus) - + EVT_KILL_FOCUS(wxSpinCtrl::OnKillFocus) EVT_SPIN(wxID_ANY, wxSpinCtrl::OnSpinChange) END_EVENT_TABLE() @@ -270,6 +263,13 @@ void wxSpinCtrl::OnChar(wxKeyEvent& event) event.Skip(); } +void wxSpinCtrl::OnKillFocus(wxFocusEvent& event) +{ + // ensure that the value is shown correctly + SetValue(GetValue()) ; + event.Skip(); +} + void wxSpinCtrl::OnSetFocus(wxFocusEvent& event) { // when we get focus, give it to our buddy window as it needs it more than @@ -394,7 +394,7 @@ bool wxSpinCtrl::Create(wxWindow *parent, // associate the text window with the spin button (void)::SendMessage(GetHwnd(), UDM_SETBUDDY, (WPARAM)m_hwndBuddy, 0); - if ( !value.IsEmpty() ) + if ( !value.empty() ) { SetValue(value); } @@ -438,7 +438,7 @@ int wxSpinCtrl::GetValue() const long n; if ( (wxSscanf(val, wxT("%lu"), &n) != 1) ) n = INT_MIN; - + if (n < m_min) n = m_min; if (n > m_max) n = m_max; @@ -454,7 +454,7 @@ void wxSpinCtrl::SetSelection(long from, long to) from = 0; } - ::SendMessage((HWND)m_hwndBuddy, EM_SETSEL, (WPARAM)from, (LPARAM)to); + ::SendMessage(GetBuddyHwnd(), EM_SETSEL, (WPARAM)from, (LPARAM)to); } // ---------------------------------------------------------------------------- @@ -570,33 +570,12 @@ void wxSpinCtrl::DoMoveWindow(int x, int y, int width, int height) 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(); - int originalX = x; - -#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