]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/msw/spinctrl.h
Add wxDEBUG_LEVEL to wx/setup.h and document it.
[wxWidgets.git] / include / wx / msw / spinctrl.h
... / ...
CommitLineData
1////////////////////////////////////////////////////////////////////////////
2// Name: msw/spinctrl.h
3// Purpose: wxSpinCtrl class declaration for Win32
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 22.07.99
7// RCS-ID: $Id$
8// Copyright: (c) Vadim Zeitlin
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_MSW_SPINCTRL_H_
13#define _WX_MSW_SPINCTRL_H_
14
15#include "wx/spinbutt.h" // the base class
16
17#if wxUSE_SPINCTRL
18
19#include "wx/dynarray.h"
20
21class WXDLLIMPEXP_FWD_CORE wxSpinCtrl;
22WX_DEFINE_EXPORTED_ARRAY_PTR(wxSpinCtrl *, wxArraySpins);
23
24// ----------------------------------------------------------------------------
25// Under Win32, wxSpinCtrl is a wxSpinButton with a buddy (as MSDN docs call
26// it) text window whose contents is automatically updated when the spin
27// control is clicked.
28// ----------------------------------------------------------------------------
29
30class WXDLLIMPEXP_CORE wxSpinCtrl : public wxSpinButton
31{
32public:
33 wxSpinCtrl() { }
34
35 wxSpinCtrl(wxWindow *parent,
36 wxWindowID id = wxID_ANY,
37 const wxString& value = wxEmptyString,
38 const wxPoint& pos = wxDefaultPosition,
39 const wxSize& size = wxDefaultSize,
40 long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
41 int min = 0, int max = 100, int initial = 0,
42 const wxString& name = wxT("wxSpinCtrl"))
43 {
44 Create(parent, id, value, pos, size, style, min, max, initial, name);
45 }
46
47 bool Create(wxWindow *parent,
48 wxWindowID id = wxID_ANY,
49 const wxString& value = wxEmptyString,
50 const wxPoint& pos = wxDefaultPosition,
51 const wxSize& size = wxDefaultSize,
52 long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
53 int min = 0, int max = 100, int initial = 0,
54 const wxString& name = wxT("wxSpinCtrl"));
55
56 // a wxTextCtrl-like method (but we can't have GetValue returning wxString
57 // because the base class already has one returning int!)
58 void SetValue(const wxString& text);
59
60 // another wxTextCtrl-like method
61 void SetSelection(long from, long to);
62
63 // implementation only from now on
64 // -------------------------------
65
66 virtual ~wxSpinCtrl();
67
68 virtual void SetValue(int val);
69 virtual int GetValue() const;
70 virtual void SetRange(int minVal, int maxVal);
71 virtual bool SetFont(const wxFont &font);
72 virtual void SetFocus();
73
74 virtual bool Enable(bool enable = true);
75 virtual bool Show(bool show = true);
76
77 virtual bool Reparent(wxWindowBase *newParent);
78
79 // wxSpinButton doesn't accept focus, but we do
80 virtual bool AcceptsFocus() const { return wxWindow::AcceptsFocus(); }
81
82 // we're like wxTextCtrl and not (default) wxButton
83 virtual wxVisualAttributes GetDefaultAttributes() const
84 {
85 return GetClassDefaultAttributes(GetWindowVariant());
86 }
87
88 static wxVisualAttributes
89 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL)
90 {
91 return GetCompositeControlsDefaultAttributes(variant);
92 }
93
94 // for internal use only
95
96 // get the subclassed window proc of the buddy text
97 WXFARPROC GetBuddyWndProc() const { return m_wndProcBuddy; }
98
99 // return the spinctrl object whose buddy is the given window or NULL
100 static wxSpinCtrl *GetSpinForTextCtrl(WXHWND hwndBuddy);
101
102 // process a WM_COMMAND generated by the buddy text control
103 bool ProcessTextCommand(WXWORD cmd, WXWORD id);
104
105 // recognize buddy window as part of this control at wx level
106 virtual bool ContainsHWND(WXHWND hWnd) const { return hWnd == m_hwndBuddy; }
107
108protected:
109 virtual void DoGetPosition(int *x, int *y) const;
110 virtual void DoMoveWindow(int x, int y, int width, int height);
111 virtual wxSize DoGetBestSize() const;
112 virtual void DoGetSize(int *width, int *height) const;
113 virtual void DoGetClientSize(int *x, int *y) const;
114#if wxUSE_TOOLTIPS
115 virtual void DoSetToolTip( wxToolTip *tip );
116#endif // wxUSE_TOOLTIPS
117
118 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
119 virtual bool MSWOnScroll(int orientation, WXWORD wParam,
120 WXWORD pos, WXHWND control);
121
122 // handle processing of special keys
123 void OnChar(wxKeyEvent& event);
124 void OnSetFocus(wxFocusEvent& event);
125 void OnKillFocus(wxFocusEvent& event);
126
127 // generate spin control update event with the given value
128 void SendSpinUpdate(int value);
129
130 // called to ensure that the value is in the correct range
131 virtual void NormalizeValue();
132
133
134 // the value of the control before the latest change (which might not have
135 // changed anything in fact -- this is why we need this field)
136 int m_oldValue;
137
138 // the data for the "buddy" text ctrl
139 WXHWND m_hwndBuddy;
140 WXFARPROC m_wndProcBuddy;
141
142 // Block text update event after SetValue()
143 bool m_blockEvent;
144
145 // all existing wxSpinCtrls - this allows to find the one corresponding to
146 // the given buddy window in GetSpinForTextCtrl()
147 static wxArraySpins ms_allSpins;
148
149private:
150 DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
151 DECLARE_EVENT_TABLE()
152 wxDECLARE_NO_COPY_CLASS(wxSpinCtrl);
153};
154
155#endif // wxUSE_SPINCTRL
156
157#endif // _WX_MSW_SPINCTRL_H_
158
159