]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/spinctrl.h
Make wxComboCtrlBase::Set*groundColour() methods public.
[wxWidgets.git] / include / wx / msw / spinctrl.h
CommitLineData
f6bcfd97 1////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: wx/msw/spinctrl.h
b782f2e0
VZ
3// Purpose: wxSpinCtrl class declaration for Win32
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 22.07.99
b782f2e0 7// Copyright: (c) Vadim Zeitlin
65571936 8// Licence: wxWindows licence
b782f2e0
VZ
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_MSW_SPINCTRL_H_
12#define _WX_MSW_SPINCTRL_H_
13
b782f2e0
VZ
14#include "wx/spinbutt.h" // the base class
15
0e871ad0
WS
16#if wxUSE_SPINCTRL
17
6fe19057 18#include "wx/dynarray.h"
d77254fc 19
b5dbe15d 20class WXDLLIMPEXP_FWD_CORE wxSpinCtrl;
d5d29b8a 21WX_DEFINE_EXPORTED_ARRAY_PTR(wxSpinCtrl *, wxArraySpins);
6fe19057 22
b782f2e0
VZ
23// ----------------------------------------------------------------------------
24// Under Win32, wxSpinCtrl is a wxSpinButton with a buddy (as MSDN docs call
25// it) text window whose contents is automatically updated when the spin
26// control is clicked.
27// ----------------------------------------------------------------------------
28
53a2db12 29class WXDLLIMPEXP_CORE wxSpinCtrl : public wxSpinButton
b782f2e0
VZ
30{
31public:
bcdeea5a 32 wxSpinCtrl() { Init(); }
b782f2e0
VZ
33
34 wxSpinCtrl(wxWindow *parent,
57f4f925 35 wxWindowID id = wxID_ANY,
678cd6de 36 const wxString& value = wxEmptyString,
b782f2e0
VZ
37 const wxPoint& pos = wxDefaultPosition,
38 const wxSize& size = wxDefaultSize,
f1ddb476 39 long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
b782f2e0 40 int min = 0, int max = 100, int initial = 0,
9a83f860 41 const wxString& name = wxT("wxSpinCtrl"))
b782f2e0 42 {
bcdeea5a
VZ
43 Init();
44
678cd6de 45 Create(parent, id, value, pos, size, style, min, max, initial, name);
b782f2e0
VZ
46 }
47
48 bool Create(wxWindow *parent,
57f4f925 49 wxWindowID id = wxID_ANY,
678cd6de 50 const wxString& value = wxEmptyString,
b782f2e0
VZ
51 const wxPoint& pos = wxDefaultPosition,
52 const wxSize& size = wxDefaultSize,
f1ddb476 53 long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
b782f2e0 54 int min = 0, int max = 100, int initial = 0,
9a83f860 55 const wxString& name = wxT("wxSpinCtrl"));
b782f2e0 56
678cd6de
VZ
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);
60
07901ec9
VZ
61 // another wxTextCtrl-like method
62 void SetSelection(long from, long to);
63
9e565667
VZ
64 // wxSpinCtrlBase methods
65 virtual int GetBase() const;
66 virtual bool SetBase(int base);
67
68
882a8f40
VZ
69 // implementation only from now on
70 // -------------------------------
71
f6bcfd97
BP
72 virtual ~wxSpinCtrl();
73
eeea41ab 74 virtual void SetValue(int val);
b44d69ba 75 virtual int GetValue() const;
345ff9c6 76 virtual void SetRange(int minVal, int maxVal);
baccb514 77 virtual bool SetFont(const wxFont &font);
b44d69ba 78 virtual void SetFocus();
baccb514 79
57f4f925
WS
80 virtual bool Enable(bool enable = true);
81 virtual bool Show(bool show = true);
882a8f40 82
03d4194d
VZ
83 virtual bool Reparent(wxWindowBase *newParent);
84
f6bcfd97
BP
85 // wxSpinButton doesn't accept focus, but we do
86 virtual bool AcceptsFocus() const { return wxWindow::AcceptsFocus(); }
87
ddc4214a
VZ
88 // we're like wxTextCtrl and not (default) wxButton
89 virtual wxVisualAttributes GetDefaultAttributes() const
90 {
91 return GetClassDefaultAttributes(GetWindowVariant());
92 }
93
94 static wxVisualAttributes
95 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL)
96 {
97 return GetCompositeControlsDefaultAttributes(variant);
98 }
99
6fe19057
VZ
100 // for internal use only
101
102 // get the subclassed window proc of the buddy text
103 WXFARPROC GetBuddyWndProc() const { return m_wndProcBuddy; }
104
105 // return the spinctrl object whose buddy is the given window or NULL
106 static wxSpinCtrl *GetSpinForTextCtrl(WXHWND hwndBuddy);
107
108 // process a WM_COMMAND generated by the buddy text control
109 bool ProcessTextCommand(WXWORD cmd, WXWORD id);
8614c467 110
ea283460
VZ
111 // recognize buddy window as part of this control at wx level
112 virtual bool ContainsHWND(WXHWND hWnd) const { return hWnd == m_hwndBuddy; }
113
b782f2e0 114protected:
f6bcfd97 115 virtual void DoGetPosition(int *x, int *y) const;
baccb514 116 virtual void DoMoveWindow(int x, int y, int width, int height);
f68586e5 117 virtual wxSize DoGetBestSize() const;
40aa1a7e 118 virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const;
f6bcfd97 119 virtual void DoGetSize(int *width, int *height) const;
b7527dde 120 virtual void DoGetClientSize(int *x, int *y) const;
74124ea9
VZ
121#if wxUSE_TOOLTIPS
122 virtual void DoSetToolTip( wxToolTip *tip );
123#endif // wxUSE_TOOLTIPS
b782f2e0 124
177e38e6
RR
125 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
126 virtual bool MSWOnScroll(int orientation, WXWORD wParam,
127 WXWORD pos, WXHWND control);
9750fc42 128
d40e9e06 129 // handle processing of special keys
e08d628d 130 void OnChar(wxKeyEvent& event);
c5c04fab 131 void OnSetFocus(wxFocusEvent& event);
4c81b431 132 void OnKillFocus(wxFocusEvent& event);
e08d628d 133
d40e9e06
VZ
134 // generate spin control update event with the given value
135 void SendSpinUpdate(int value);
136
137 // called to ensure that the value is in the correct range
1e8dba5e 138 virtual void NormalizeValue();
d40e9e06
VZ
139
140
141 // the value of the control before the latest change (which might not have
142 // changed anything in fact -- this is why we need this field)
143 int m_oldValue;
144
f6bcfd97
BP
145 // the data for the "buddy" text ctrl
146 WXHWND m_hwndBuddy;
6fe19057
VZ
147 WXFARPROC m_wndProcBuddy;
148
03647350 149 // Block text update event after SetValue()
ea6cbf48
RR
150 bool m_blockEvent;
151
9750fc42 152private:
bcdeea5a
VZ
153 // Common part of all ctors.
154 void Init();
155
9e565667
VZ
156 // Adjust the text control style depending on whether we need to enter only
157 // digits or may need to enter something else (e.g. "-" sign, "x"
158 // hexadecimal prefix, ...) in it.
159 void UpdateBuddyStyle();
160
161
b782f2e0 162 DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
9750fc42 163 DECLARE_EVENT_TABLE()
c0c133e1 164 wxDECLARE_NO_COPY_CLASS(wxSpinCtrl);
b782f2e0
VZ
165};
166
0e871ad0
WS
167#endif // wxUSE_SPINCTRL
168
b782f2e0
VZ
169#endif // _WX_MSW_SPINCTRL_H_
170
171