]> git.saurik.com Git - wxWidgets.git/blob - src/common/gaugecmn.cpp
Don't generate any events from wxSpinCtrl and wxSpinCtrlDouble methods.
[wxWidgets.git] / src / common / gaugecmn.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/gaugecmn.cpp
3 // Purpose: wxGaugeBase: common to all ports methods of wxGauge
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 20.02.01
7 // Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 // ============================================================================
12 // declarations
13 // ============================================================================
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
21
22 #ifdef __BORLANDC__
23 #pragma hdrstop
24 #endif
25
26 #ifndef WX_PRECOMP
27 #endif //WX_PRECOMP
28
29 #if wxUSE_GAUGE
30
31 #include "wx/gauge.h"
32
33 const char wxGaugeNameStr[] = "gauge";
34
35 // ============================================================================
36 // implementation
37 // ============================================================================
38
39 wxGaugeBase::~wxGaugeBase()
40 {
41 // this destructor is required for Darwin
42 }
43
44 // ----------------------------------------------------------------------------
45 // XTI
46 // ----------------------------------------------------------------------------
47
48 wxDEFINE_FLAGS( wxGaugeStyle )
49 wxBEGIN_FLAGS( wxGaugeStyle )
50 // new style border flags, we put them first to
51 // use them for streaming out
52 wxFLAGS_MEMBER(wxBORDER_SIMPLE)
53 wxFLAGS_MEMBER(wxBORDER_SUNKEN)
54 wxFLAGS_MEMBER(wxBORDER_DOUBLE)
55 wxFLAGS_MEMBER(wxBORDER_RAISED)
56 wxFLAGS_MEMBER(wxBORDER_STATIC)
57 wxFLAGS_MEMBER(wxBORDER_NONE)
58
59 // old style border flags
60 wxFLAGS_MEMBER(wxSIMPLE_BORDER)
61 wxFLAGS_MEMBER(wxSUNKEN_BORDER)
62 wxFLAGS_MEMBER(wxDOUBLE_BORDER)
63 wxFLAGS_MEMBER(wxRAISED_BORDER)
64 wxFLAGS_MEMBER(wxSTATIC_BORDER)
65 wxFLAGS_MEMBER(wxBORDER)
66
67 // standard window styles
68 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
69 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
70 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
71 wxFLAGS_MEMBER(wxWANTS_CHARS)
72 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
73 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
74 wxFLAGS_MEMBER(wxVSCROLL)
75 wxFLAGS_MEMBER(wxHSCROLL)
76
77 wxFLAGS_MEMBER(wxGA_HORIZONTAL)
78 wxFLAGS_MEMBER(wxGA_VERTICAL)
79 #if WXWIN_COMPATIBILITY_2_6
80 wxFLAGS_MEMBER(wxGA_PROGRESSBAR)
81 #endif // WXWIN_COMPATIBILITY_2_6
82 wxFLAGS_MEMBER(wxGA_SMOOTH)
83 wxEND_FLAGS( wxGaugeStyle )
84
85 wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxGauge, wxControl, "wx/gauge.h")
86
87 wxBEGIN_PROPERTIES_TABLE(wxGauge)
88 wxPROPERTY( Value, int, SetValue, GetValue, 0, 0 /*flags*/, \
89 wxT("Helpstring"), wxT("group"))
90 wxPROPERTY( Range, int, SetRange, GetRange, 0, 0 /*flags*/, \
91 wxT("Helpstring"), wxT("group"))
92 wxPROPERTY( ShadowWidth, int, SetShadowWidth, GetShadowWidth, \
93 0, 0 /*flags*/, wxT("Helpstring"), wxT("group"))
94 wxPROPERTY( BezelFace, int, SetBezelFace, GetBezelFace, \
95 0, 0 /*flags*/, wxT("Helpstring"), wxT("group"))
96
97 wxPROPERTY_FLAGS( WindowStyle, wxGaugeStyle, long, SetWindowStyleFlag, \
98 GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \
99 wxT("Helpstring"), wxT("group")) // style
100 wxEND_PROPERTIES_TABLE()
101
102 wxEMPTY_HANDLERS_TABLE(wxGauge)
103
104 wxCONSTRUCTOR_6( wxGauge, wxWindow*, Parent, wxWindowID, Id, int, Range, \
105 wxPoint, Position, wxSize, Size, long, WindowStyle )
106
107 // ----------------------------------------------------------------------------
108 // wxGauge creation
109 // ----------------------------------------------------------------------------
110
111 bool wxGaugeBase::Create(wxWindow *parent,
112 wxWindowID id,
113 int range,
114 const wxPoint& pos,
115 const wxSize& size,
116 long style,
117 const wxValidator& validator,
118 const wxString& name)
119 {
120 if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
121 return false;
122
123 SetName(name);
124
125 #if wxUSE_VALIDATORS
126 SetValidator(validator);
127 #endif // wxUSE_VALIDATORS
128
129 SetRange(range);
130 SetValue(0);
131 #if wxGAUGE_EMULATE_INDETERMINATE_MODE
132 m_nDirection = wxRIGHT;
133 #endif
134
135 return true;
136 }
137
138 // ----------------------------------------------------------------------------
139 // wxGauge determinate mode range/position
140 // ----------------------------------------------------------------------------
141
142 void wxGaugeBase::SetRange(int range)
143 {
144 m_rangeMax = range;
145 }
146
147 int wxGaugeBase::GetRange() const
148 {
149 return m_rangeMax;
150 }
151
152 void wxGaugeBase::SetValue(int pos)
153 {
154 m_gaugePos = pos;
155 }
156
157 int wxGaugeBase::GetValue() const
158 {
159 return m_gaugePos;
160 }
161
162 // ----------------------------------------------------------------------------
163 // wxGauge indeterminate mode
164 // ----------------------------------------------------------------------------
165
166 void wxGaugeBase::Pulse()
167 {
168 #if wxGAUGE_EMULATE_INDETERMINATE_MODE
169 // simulate indeterminate mode
170 int curr = GetValue(), max = GetRange();
171
172 if (m_nDirection == wxRIGHT)
173 {
174 if (curr < max)
175 SetValue(curr + 1);
176 else
177 {
178 SetValue(max - 1);
179 m_nDirection = wxLEFT;
180 }
181 }
182 else
183 {
184 if (curr > 0)
185 SetValue(curr - 1);
186 else
187 {
188 SetValue(1);
189 m_nDirection = wxRIGHT;
190 }
191 }
192 #endif
193 }
194
195 // ----------------------------------------------------------------------------
196 // wxGauge appearance params
197 // ----------------------------------------------------------------------------
198
199 void wxGaugeBase::SetShadowWidth(int WXUNUSED(w))
200 {
201 }
202
203 int wxGaugeBase::GetShadowWidth() const
204 {
205 return 0;
206 }
207
208
209 void wxGaugeBase::SetBezelFace(int WXUNUSED(w))
210 {
211 }
212
213 int wxGaugeBase::GetBezelFace() const
214 {
215 return 0;
216 }
217
218 #endif // wxUSE_GAUGE