]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/spinctrl.h
1 ////////////////////////////////////////////////////////////////////////////
2 // Name: msw/spinctrl.h
3 // Purpose: wxSpinCtrl class declaration for Win32
4 // Author: Vadim Zeitlin
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_MSW_SPINCTRL_H_
13 #define _WX_MSW_SPINCTRL_H_
16 #pragma interface "spinctrl.h"
19 #include "wx/spinbutt.h" // the base class
21 #include "wx/dynarray.h"
22 class WXDLLEXPORT wxSpinCtrl
;
23 WX_DEFINE_EXPORTED_ARRAY(wxSpinCtrl
*, wxArraySpins
);
25 // ----------------------------------------------------------------------------
26 // Under Win32, wxSpinCtrl is a wxSpinButton with a buddy (as MSDN docs call
27 // it) text window whose contents is automatically updated when the spin
28 // control is clicked.
29 // ----------------------------------------------------------------------------
31 class WXDLLEXPORT wxSpinCtrl
: public wxSpinButton
36 wxSpinCtrl(wxWindow
*parent
,
38 const wxString
& value
= wxEmptyString
,
39 const wxPoint
& pos
= wxDefaultPosition
,
40 const wxSize
& size
= wxDefaultSize
,
41 long style
= wxSP_ARROW_KEYS
,
42 int min
= 0, int max
= 100, int initial
= 0,
43 const wxString
& name
= _T("wxSpinCtrl"))
45 Create(parent
, id
, value
, pos
, size
, style
, min
, max
, initial
, name
);
48 bool Create(wxWindow
*parent
,
50 const wxString
& value
= wxEmptyString
,
51 const wxPoint
& pos
= wxDefaultPosition
,
52 const wxSize
& size
= wxDefaultSize
,
53 long style
= wxSP_ARROW_KEYS
,
54 int min
= 0, int max
= 100, int initial
= 0,
55 const wxString
& name
= _T("wxSpinCtrl"));
57 // a wxTextCtrl-like method (but we can't have GetValue returning wxString
58 // because the base class already has one returning int!)
59 void SetValue(const wxString
& text
);
61 // implementation only from now on
62 // -------------------------------
64 virtual ~wxSpinCtrl();
66 virtual void SetValue(int val
) { wxSpinButton::SetValue(val
); }
67 virtual int GetValue() const;
68 virtual bool SetFont(const wxFont
&font
);
69 virtual void SetFocus();
71 virtual bool Enable(bool enable
= TRUE
);
72 virtual bool Show(bool show
= TRUE
);
74 // wxSpinButton doesn't accept focus, but we do
75 virtual bool AcceptsFocus() const { return wxWindow::AcceptsFocus(); }
77 // for internal use only
79 // get the subclassed window proc of the buddy text
80 WXFARPROC
GetBuddyWndProc() const { return m_wndProcBuddy
; }
82 // return the spinctrl object whose buddy is the given window or NULL
83 static wxSpinCtrl
*GetSpinForTextCtrl(WXHWND hwndBuddy
);
85 // process a WM_COMMAND generated by the buddy text control
86 bool ProcessTextCommand(WXWORD cmd
, WXWORD id
);
89 virtual void DoGetPosition(int *x
, int *y
) const;
90 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
91 virtual wxSize
DoGetBestSize() const;
92 virtual void DoGetSize(int *width
, int *height
) const;
94 // the handler for wxSpinButton events
95 void OnSpinChange(wxSpinEvent
& event
);
97 // the data for the "buddy" text ctrl
99 WXFARPROC m_wndProcBuddy
;
101 // all existing wxSpinCtrls - this allows to find the one corresponding to
102 // the given buddy window in GetSpinForTextCtrl()
103 static wxArraySpins ms_allSpins
;
106 DECLARE_DYNAMIC_CLASS(wxSpinCtrl
)
107 DECLARE_EVENT_TABLE()
110 #endif // _WX_MSW_SPINCTRL_H_