]> git.saurik.com Git - wxWidgets.git/blame - src/common/gaugecmn.cpp
updated setup.h for OpenVMS
[wxWidgets.git] / src / common / gaugecmn.cpp
CommitLineData
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 34const char wxGaugeNameStr[] = "gauge";
21709999
JS
35
36// ============================================================================
37// implementation
38// ============================================================================
39
799ea011
GD
40wxGaugeBase::~wxGaugeBase()
41{
42 // this destructor is required for Darwin
43}
44
28953245
SC
45// ----------------------------------------------------------------------------
46// XTI
47// ----------------------------------------------------------------------------
48
49wxDEFINE_FLAGS( wxGaugeStyle )
50wxBEGIN_FLAGS( wxGaugeStyle )
51// new style border flags, we put them first to
52// use them for streaming out
53wxFLAGS_MEMBER(wxBORDER_SIMPLE)
54wxFLAGS_MEMBER(wxBORDER_SUNKEN)
55wxFLAGS_MEMBER(wxBORDER_DOUBLE)
56wxFLAGS_MEMBER(wxBORDER_RAISED)
57wxFLAGS_MEMBER(wxBORDER_STATIC)
58wxFLAGS_MEMBER(wxBORDER_NONE)
59
60// old style border flags
61wxFLAGS_MEMBER(wxSIMPLE_BORDER)
62wxFLAGS_MEMBER(wxSUNKEN_BORDER)
63wxFLAGS_MEMBER(wxDOUBLE_BORDER)
64wxFLAGS_MEMBER(wxRAISED_BORDER)
65wxFLAGS_MEMBER(wxSTATIC_BORDER)
66wxFLAGS_MEMBER(wxBORDER)
67
68// standard window styles
69wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
70wxFLAGS_MEMBER(wxCLIP_CHILDREN)
71wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
72wxFLAGS_MEMBER(wxWANTS_CHARS)
73wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
74wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
75wxFLAGS_MEMBER(wxVSCROLL)
76wxFLAGS_MEMBER(wxHSCROLL)
77
78wxFLAGS_MEMBER(wxGA_HORIZONTAL)
79wxFLAGS_MEMBER(wxGA_VERTICAL)
80#if WXWIN_COMPATIBILITY_2_6
81wxFLAGS_MEMBER(wxGA_PROGRESSBAR)
82#endif // WXWIN_COMPATIBILITY_2_6
83wxFLAGS_MEMBER(wxGA_SMOOTH)
84wxEND_FLAGS( wxGaugeStyle )
85
86wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxGauge, wxControl, "wx/gauge.h")
87
88wxBEGIN_PROPERTIES_TABLE(wxGauge)
89wxPROPERTY( Value, int, SetValue, GetValue, 0, 0 /*flags*/, \
90 wxT("Helpstring"), wxT("group"))
91wxPROPERTY( Range, int, SetRange, GetRange, 0, 0 /*flags*/, \
92 wxT("Helpstring"), wxT("group"))
93wxPROPERTY( ShadowWidth, int, SetShadowWidth, GetShadowWidth, \
94 0, 0 /*flags*/, wxT("Helpstring"), wxT("group"))
95wxPROPERTY( BezelFace, int, SetBezelFace, GetBezelFace, \
96 0, 0 /*flags*/, wxT("Helpstring"), wxT("group"))
97
98wxPROPERTY_FLAGS( WindowStyle, wxGaugeStyle, long, SetWindowStyleFlag, \
99 GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \
100 wxT("Helpstring"), wxT("group")) // style
101wxEND_PROPERTIES_TABLE()
102
103wxEMPTY_HANDLERS_TABLE(wxGauge)
104
105wxCONSTRUCTOR_6( wxGauge, wxWindow*, Parent, wxWindowID, Id, int, Range, \
106 wxPoint, Position, wxSize, Size, long, WindowStyle )
107
21709999
JS
108// ----------------------------------------------------------------------------
109// wxGauge creation
110// ----------------------------------------------------------------------------
111
112bool 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
143void wxGaugeBase::SetRange(int range)
144{
145 m_rangeMax = range;
146}
147
148int wxGaugeBase::GetRange() const
149{
150 return m_rangeMax;
151}
152
153void wxGaugeBase::SetValue(int pos)
154{
155 m_gaugePos = pos;
156}
157
158int wxGaugeBase::GetValue() const
159{
160 return m_gaugePos;
161}
162
fe8635a7
RR
163// ----------------------------------------------------------------------------
164// wxGauge indeterminate mode
165// ----------------------------------------------------------------------------
166
167void 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
200void wxGaugeBase::SetShadowWidth(int WXUNUSED(w))
201{
202}
203
204int wxGaugeBase::GetShadowWidth() const
205{
206 return 0;
207}
208
209
210void wxGaugeBase::SetBezelFace(int WXUNUSED(w))
211{
212}
213
214int wxGaugeBase::GetBezelFace() const
215{
216 return 0;
217}
218
219#endif // wxUSE_GAUGE