// Modified by:
// Created: 22.07.99
// RCS-ID: $Id$
-// Copyright: (c) Vadim Zeitlin
+// Copyright: (c) 1999-2005 Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// declarations
// ============================================================================
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma implementation "spinctrlbase.h"
- #pragma implementation "spinctrl.h"
-#endif
-
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#if wxUSE_SPINCTRL
-#if defined(__WIN95__)
-
#include "wx/spinctrl.h"
#include "wx/msw/private.h"
+#include "wx/msw/wrapcctl.h"
-#if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__))
- #include <commctrl.h>
-#endif
+#if wxUSE_TOOLTIPS
+ #include "wx/tooltip.h"
+#endif // wxUSE_TOOLTIPS
#include <limits.h> // for INT_MIN
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()
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
// 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);
}
if ( (wxSscanf(val, wxT("%lu"), &n) != 1) )
n = INT_MIN;
+ if (n < m_min) n = m_min;
+ if (n > m_max) n = m_max;
+
return n;
}
from = 0;
}
- ::SendMessage((HWND)m_hwndBuddy, EM_SETSEL, (WPARAM)from, (LPARAM)to);
+ ::SendMessage(GetBuddyHwnd(), EM_SETSEL, (WPARAM)from, (LPARAM)to);
}
// ----------------------------------------------------------------------------
::SetFocus(GetBuddyHwnd());
}
+#if wxUSE_TOOLTIPS
+
+void wxSpinCtrl::DoSetToolTip(wxToolTip *tip)
+{
+ wxSpinButton::DoSetToolTip(tip);
+
+ if ( tip )
+ tip->Add(m_hwndBuddy);
+}
+
+#endif // wxUSE_TOOLTIPS
+
// ----------------------------------------------------------------------------
// event processing
// ----------------------------------------------------------------------------
wxLogDebug(_T("not enough space for wxSpinCtrl!"));
}
- if ( !::MoveWindow(GetBuddyHwnd(), x, y, widthText, height, TRUE) )
- {
- wxLogLastError(wxT("MoveWindow(buddy)"));
- }
+ // 1) The buddy window
+ DoMoveSibling(m_hwndBuddy, x, y, widthText, height);
+ // 2) The button window
x += widthText + MARGIN_BETWEEN;
- if ( !::MoveWindow(GetHwnd(), x, y, widthBtn, height, TRUE) )
- {
- wxLogLastError(wxT("MoveWindow"));
- }
+ wxSpinButton::DoMoveWindow(x, y, widthBtn, height);
}
// get total size of the control
wxConstCast(this, wxSpinCtrl)->m_hWnd = hWnd;
}
-#endif // __WIN95__
-
-#endif
- // wxUSE_SPINCTRL
+#endif // wxUSE_SPINCTRL