]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/spinctrl.cpp
VTK wrapper of vtkRenderWindow for wxPython. Tested on MSW so far.
[wxWidgets.git] / src / msw / spinctrl.cpp
index 983181c466fde5fed7e5aa17260502491b325811..d37468bbf011b7ae05bc281fea1757672c71013d 100644 (file)
@@ -33,6 +33,8 @@
     #include "wx/wx.h"
 #endif
 
     #include "wx/wx.h"
 #endif
 
+#if wxUSE_SPINCTRL
+
 #if defined(__WIN95__)
 
 #include "wx/spinctrl.h"
 #if defined(__WIN95__)
 
 #include "wx/spinctrl.h"
@@ -42,6 +44,8 @@
     #include <commctrl.h>
 #endif
 
     #include <commctrl.h>
 #endif
 
+#include <limits.h>         // for INT_MIN
+
 // ----------------------------------------------------------------------------
 // macros
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // macros
 // ----------------------------------------------------------------------------
@@ -69,6 +73,7 @@ static const int MARGIN_BETWEEN = 1;
 
 bool wxSpinCtrl::Create(wxWindow *parent,
                         wxWindowID id,
 
 bool wxSpinCtrl::Create(wxWindow *parent,
                         wxWindowID id,
+                        const wxString& value,
                         const wxPoint& pos,
                         const wxSize& size,
                         long style,
                         const wxPoint& pos,
                         const wxSize& size,
                         long style,
@@ -149,9 +154,37 @@ bool wxSpinCtrl::Create(wxWindow *parent,
     // associate the text window with the spin button
     (void)::SendMessage(GetHwnd(), UDM_SETBUDDY, (WPARAM)m_hwndBuddy, 0);
 
     // associate the text window with the spin button
     (void)::SendMessage(GetHwnd(), UDM_SETBUDDY, (WPARAM)m_hwndBuddy, 0);
 
+    if ( !value.IsEmpty() )
+    {
+        SetValue(value);
+    }
+
     return TRUE;
 }
 
     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
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // when setting font, we need to do it for both controls
 // ----------------------------------------------------------------------------
@@ -214,3 +247,7 @@ void wxSpinCtrl::DoMoveWindow(int x, int y, int width, int height)
 }
 
 #endif // __WIN95__
 }
 
 #endif // __WIN95__
+
+#endif
+       // wxUSE_SPINCTRL
+