#include "wx/wx.h"
#endif
+#if wxUSE_SPINCTRL
+
#if defined(__WIN95__)
#include "wx/spinctrl.h"
#include <commctrl.h>
#endif
+#include <limits.h> // for INT_MIN
+
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
bool wxSpinCtrl::Create(wxWindow *parent,
wxWindowID id,
+ const wxString& value,
const wxPoint& pos,
const wxSize& size,
long style,
// associate the text window with the spin button
(void)::SendMessage(GetHwnd(), UDM_SETBUDDY, (WPARAM)m_hwndBuddy, 0);
+ if ( !value.IsEmpty() )
+ {
+ SetValue(value);
+ }
+
return TRUE;
}
+// ----------------------------------------------------------------------------
+// wxTextCtrl-like methods
+// ----------------------------------------------------------------------------
+
+void wxSpinCtrl::SetValue(const wxString& text)
+{
+ if ( ::SetWindowText((HWND)m_hwndBuddy, text.c_str()) )
+ {
+ wxLogLastError("SetWindowText(buddy)");
+ }
+}
+
+int wxSpinCtrl::GetValue() const
+{
+ wxString val = wxGetWindowText(m_hwndBuddy);
+
+ long n;
+ if ( (wxSscanf(val, wxT("%lu"), &n) != 1) )
+ n = INT_MIN;
+
+ return n;
+}
+
// ----------------------------------------------------------------------------
// when setting font, we need to do it for both controls
// ----------------------------------------------------------------------------
// size calculations
// ----------------------------------------------------------------------------
-wxSize wxSpinCtrl::DoGetBestSize()
+wxSize wxSpinCtrl::DoGetBestSize() const
{
wxSize sizeBtn = wxSpinButton::DoGetBestSize();
sizeBtn.x += DEFAULT_ITEM_WIDTH + MARGIN_BETWEEN;
}
#endif // __WIN95__
+
+#endif
+ // wxUSE_SPINCTRL
+