1 /////////////////////////////////////////////////////////////////////////////
2 // Name: msw/spinctrl.h
3 // Purpose: wxSpinCtrl class declaration for Win32
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_MSW_SPINCTRL_H_
13 #define _WX_MSW_SPINCTRL_H_
15 #include "wx/spinbutt.h" // the base class
16 #include "wx/dynarray.h"
17 class WXDLLIMPEXP_FWD_CORE wxSpinCtrl
;
18 WX_DEFINE_EXPORTED_ARRAY_PTR(wxSpinCtrl
*, wxArraySpins
);
20 // ----------------------------------------------------------------------------
21 // Under Win32 and OS2 PM, wxSpinCtrl is a wxSpinButton with a buddy
22 // text window whose contents is automatically updated when the spin
23 // control is clicked.
24 // ----------------------------------------------------------------------------
26 class WXDLLIMPEXP_CORE wxSpinCtrl
: public wxSpinButton
30 wxSpinCtrl( wxWindow
* pParent
31 ,wxWindowID vId
= wxID_ANY
32 ,const wxString
& rsValue
= wxEmptyString
33 ,const wxPoint
& rPos
= wxDefaultPosition
34 ,const wxSize
& rSize
= wxDefaultSize
35 ,long lStyle
= wxSP_ARROW_KEYS
39 ,const wxString
& rsName
= wxT("wxSpinCtrl")
42 Create(pParent
, vId
, rsValue
, rPos
, rSize
, lStyle
, nMin
, nMax
, nInitial
, rsName
);
44 virtual ~wxSpinCtrl();
46 bool Create(wxWindow
* pParent
47 ,wxWindowID vId
= wxID_ANY
48 ,const wxString
& rsValue
= wxEmptyString
49 ,const wxPoint
& rPos
= wxDefaultPosition
50 ,const wxSize
& rSize
= wxDefaultSize
51 ,long lStyle
= wxSP_ARROW_KEYS
55 ,const wxString
& rsName
= wxT("wxSpinCtrl")
59 // A wxTextCtrl-like method (but we can't have GetValue returning wxString
60 // because the base class already has one returning int!)
62 void SetValue(const wxString
& rsText
);
65 // implementation only from now on
66 // -------------------------------
68 virtual bool Enable(bool bEnable
= true);
70 virtual int GetValue(void) const;
72 virtual bool SetFont(const wxFont
&rFont
);
73 virtual void SetFocus(void);
75 inline virtual void SetValue(int nVal
) { wxSpinButton::SetValue(nVal
); }
77 void SetSelection(long lFrom
, long lTo
);
79 virtual bool Show(bool bShow
= true);
82 // wxSpinButton doesn't accept focus, but we do
84 inline virtual bool AcceptsFocus(void) const { return false; }
87 // Return the spinctrl object whose buddy is the given window or NULL
88 // Doesn't really do much under OS/2
90 static wxSpinCtrl
* GetSpinForTextCtrl(WXHWND hWndBuddy
);
93 // Process a WM_COMMAND generated by the buddy text control
95 bool ProcessTextCommand( WXWORD wCmd
100 virtual void DoGetPosition( int* nlX
103 void DoMoveWindow( int nX
108 virtual wxSize
DoGetBestSize(void) const;
109 virtual void DoGetSize( int* pnWidth
114 // The handler for wxSpinButton events
116 void OnSpinChange(wxSpinEvent
& rEvent
);
117 void OnChar(wxKeyEvent
& rEvent
);
118 void OnSetFocus(wxFocusEvent
& rEvent
);
121 static wxArraySpins m_svAllSpins
;
124 DECLARE_DYNAMIC_CLASS(wxSpinCtrl
)
125 DECLARE_EVENT_TABLE()
126 }; // end of CLASS wxSpinCtrl
128 #endif // _WX_MSW_SPINCTRL_H_