]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/spinctrl.h
e29c806d7273a8fd4a271f6940cc1d54d0c3ca3f
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/spinctlg.h
3 // Purpose: generic wxSpinCtrl class
4 // Author: Vadim Zeitlin
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_MAC_SPINCTRL_H_
13 #define _WX_MAC_SPINCTRL_H_
15 // ----------------------------------------------------------------------------
16 // wxSpinCtrl is a combination of wxSpinButton and wxTextCtrl, so if
17 // wxSpinButton is available, this is what we do - but if it isn't, we still
18 // define wxSpinCtrl class which then has the same appearance as wxTextCtrl but
19 // the different interface. This allows to write programs using wxSpinCtrl
20 // without tons of #ifdefs.
21 // ----------------------------------------------------------------------------
25 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
26 #pragma interface "spinctlg.h"
29 class WXDLLEXPORT wxSpinButton
;
30 class WXDLLEXPORT wxTextCtrl
;
32 // ----------------------------------------------------------------------------
33 // wxSpinCtrl is a combination of wxTextCtrl and wxSpinButton
34 // ----------------------------------------------------------------------------
36 class WXDLLEXPORT wxSpinCtrl
: public wxControl
39 wxSpinCtrl() { Init(); }
41 wxSpinCtrl(wxWindow
*parent
,
43 const wxString
& value
= wxEmptyString
,
44 const wxPoint
& pos
= wxDefaultPosition
,
45 const wxSize
& size
= wxDefaultSize
,
46 long style
= wxSP_ARROW_KEYS
,
47 int min
= 0, int max
= 100, int initial
= 0,
48 const wxString
& name
= _T("wxSpinCtrl"))
51 Create(parent
, id
, value
, pos
, size
, style
, min
, max
, initial
, name
);
54 bool Create(wxWindow
*parent
,
56 const wxString
& value
= wxEmptyString
,
57 const wxPoint
& pos
= wxDefaultPosition
,
58 const wxSize
& size
= wxDefaultSize
,
59 long style
= wxSP_ARROW_KEYS
,
60 int min
= 0, int max
= 100, int initial
= 0,
61 const wxString
& name
= _T("wxSpinCtrl"));
63 // wxTextCtrl-like method
64 void SetSelection(long from
, long to
);
66 virtual ~wxSpinCtrl();
69 void SetValue(int val
);
70 void SetValue(const wxString
& text
);
71 void SetRange(int min
, int max
);
78 // implementation from now on
80 // forward these functions to all subcontrols
81 virtual bool Enable(bool enable
= TRUE
);
82 virtual bool Show(bool show
= TRUE
);
83 virtual void SetFocus();
85 // get the subcontrols
86 wxTextCtrl
*GetText() const { return m_text
; }
87 wxSpinButton
*GetSpinButton() const { return m_btn
; }
89 // set the value of the text (only)
90 void SetTextValue(int val
);
92 // put the numeric value of the string in the text ctrl into val and return
93 // TRUE or return FALSE if the text ctrl doesn't contain a number or if the
94 // number is out of range
95 bool GetTextValue(int *val
) const;
98 // override the base class virtuals involved into geometry calculations
99 virtual wxSize
DoGetBestSize() const;
100 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
102 // common part of all ctors
111 DECLARE_DYNAMIC_CLASS(wxSpinCtrl
)
114 #else // !wxUSE_SPINBTN
116 // ----------------------------------------------------------------------------
117 // wxSpinCtrl is just a text control
118 // ----------------------------------------------------------------------------
120 #include "wx/textctrl.h"
122 class WXDLLEXPORT wxSpinCtrl
: public wxTextCtrl
125 wxSpinCtrl() { Init(); }
127 wxSpinCtrl(wxWindow
*parent
,
129 const wxString
& value
= wxEmptyString
,
130 const wxPoint
& pos
= wxDefaultPosition
,
131 const wxSize
& size
= wxDefaultSize
,
132 long style
= wxSP_ARROW_KEYS
,
133 int min
= 0, int max
= 100, int initial
= 0,
134 const wxString
& name
= _T("wxSpinCtrl"))
136 Create(parent
, id
, value
, pos
, size
, style
, min
, max
, initial
, name
);
139 bool Create(wxWindow
*parent
,
141 const wxString
& value
= wxEmptyString
,
142 const wxPoint
& pos
= wxDefaultPosition
,
143 const wxSize
& size
= wxDefaultSize
,
144 long style
= wxSP_ARROW_KEYS
,
145 int min
= 0, int max
= 100, int initial
= 0,
146 const wxString
& name
= _T("wxSpinCtrl"))
150 bool ok
= wxTextCtrl::Create(parent
, id
, value
, pos
, size
, style
,
151 wxDefaultValidator
, name
);
158 int GetValue(int WXUNUSED(dummy
) = 1) const
161 if ( (wxSscanf(wxTextCtrl::GetValue(), wxT("%d"), &n
) != 1) )
167 int GetMin() const { return m_min
; }
168 int GetMax() const { return m_max
; }
171 void SetValue(const wxString
& value
) { wxTextCtrl::SetValue(value
); }
172 void SetValue(int val
) { wxString s
; s
<< val
; wxTextCtrl::SetValue(s
); }
173 void SetRange(int min
, int max
) { m_min
= min
; m_max
= max
; }
176 // initialize m_min/max with the default values
177 void Init() { SetRange(0, 100); }
183 DECLARE_DYNAMIC_CLASS(wxSpinCtrl
)
186 #endif // wxUSE_SPINBTN/!wxUSE_SPINBTN
188 #endif // _WX_MAC_SPINCTRL_H_