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