]> git.saurik.com Git - wxWidgets.git/blame - src/common/gaugecmn.cpp
wxMessageBox off the main thread lost result code.
[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
21709999 7// Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
526954c5 8// Licence: wxWindows licence
21709999
JS
9///////////////////////////////////////////////////////////////////////////////
10
11// ============================================================================
12// declarations
13// ============================================================================
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
21709999
JS
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
e7445ff8
PC
29#if wxUSE_GAUGE
30
21709999
JS
31#include "wx/gauge.h"
32
f36e602b 33const char wxGaugeNameStr[] = "gauge";
21709999
JS
34
35// ============================================================================
36// implementation
37// ============================================================================
38
799ea011
GD
39wxGaugeBase::~wxGaugeBase()
40{
41 // this destructor is required for Darwin
42}
43
28953245
SC
44// ----------------------------------------------------------------------------
45// XTI
46// ----------------------------------------------------------------------------
47
48wxDEFINE_FLAGS( wxGaugeStyle )
49wxBEGIN_FLAGS( wxGaugeStyle )
50// new style border flags, we put them first to
51// use them for streaming out
52wxFLAGS_MEMBER(wxBORDER_SIMPLE)
53wxFLAGS_MEMBER(wxBORDER_SUNKEN)
54wxFLAGS_MEMBER(wxBORDER_DOUBLE)
55wxFLAGS_MEMBER(wxBORDER_RAISED)
56wxFLAGS_MEMBER(wxBORDER_STATIC)
57wxFLAGS_MEMBER(wxBORDER_NONE)
58
59// old style border flags
60wxFLAGS_MEMBER(wxSIMPLE_BORDER)
61wxFLAGS_MEMBER(wxSUNKEN_BORDER)
62wxFLAGS_MEMBER(wxDOUBLE_BORDER)
63wxFLAGS_MEMBER(wxRAISED_BORDER)
64wxFLAGS_MEMBER(wxSTATIC_BORDER)
65wxFLAGS_MEMBER(wxBORDER)
66
67// standard window styles
68wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
69wxFLAGS_MEMBER(wxCLIP_CHILDREN)
70wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
71wxFLAGS_MEMBER(wxWANTS_CHARS)
72wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
73wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
74wxFLAGS_MEMBER(wxVSCROLL)
75wxFLAGS_MEMBER(wxHSCROLL)
76
77wxFLAGS_MEMBER(wxGA_HORIZONTAL)
78wxFLAGS_MEMBER(wxGA_VERTICAL)
79#if WXWIN_COMPATIBILITY_2_6
80wxFLAGS_MEMBER(wxGA_PROGRESSBAR)
81#endif // WXWIN_COMPATIBILITY_2_6
82wxFLAGS_MEMBER(wxGA_SMOOTH)
83wxEND_FLAGS( wxGaugeStyle )
84
85wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxGauge, wxControl, "wx/gauge.h")
86
87wxBEGIN_PROPERTIES_TABLE(wxGauge)
88wxPROPERTY( Value, int, SetValue, GetValue, 0, 0 /*flags*/, \
89 wxT("Helpstring"), wxT("group"))
90wxPROPERTY( Range, int, SetRange, GetRange, 0, 0 /*flags*/, \
91 wxT("Helpstring"), wxT("group"))
92wxPROPERTY( ShadowWidth, int, SetShadowWidth, GetShadowWidth, \
93 0, 0 /*flags*/, wxT("Helpstring"), wxT("group"))
94wxPROPERTY( BezelFace, int, SetBezelFace, GetBezelFace, \
95 0, 0 /*flags*/, wxT("Helpstring"), wxT("group"))
96
97wxPROPERTY_FLAGS( WindowStyle, wxGaugeStyle, long, SetWindowStyleFlag, \
98 GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \
99 wxT("Helpstring"), wxT("group")) // style
100wxEND_PROPERTIES_TABLE()
101
102wxEMPTY_HANDLERS_TABLE(wxGauge)
103
104wxCONSTRUCTOR_6( wxGauge, wxWindow*, Parent, wxWindowID, Id, int, Range, \
105 wxPoint, Position, wxSize, Size, long, WindowStyle )
106
21709999
JS
107// ----------------------------------------------------------------------------
108// wxGauge creation
109// ----------------------------------------------------------------------------
110
111bool 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) )
5d3e7b52 121 return false;
21709999
JS
122
123 SetName(name);
124
125#if wxUSE_VALIDATORS
126 SetValidator(validator);
127#endif // wxUSE_VALIDATORS
128
129 SetRange(range);
130 SetValue(0);
fe8635a7
RR
131#if wxGAUGE_EMULATE_INDETERMINATE_MODE
132 m_nDirection = wxRIGHT;
133#endif
21709999 134
5d3e7b52 135 return true;
21709999
JS
136}
137
138// ----------------------------------------------------------------------------
fe8635a7 139// wxGauge determinate mode range/position
21709999
JS
140// ----------------------------------------------------------------------------
141
142void wxGaugeBase::SetRange(int range)
143{
144 m_rangeMax = range;
145}
146
147int wxGaugeBase::GetRange() const
148{
149 return m_rangeMax;
150}
151
152void wxGaugeBase::SetValue(int pos)
153{
154 m_gaugePos = pos;
155}
156
157int wxGaugeBase::GetValue() const
158{
159 return m_gaugePos;
160}
161
fe8635a7
RR
162// ----------------------------------------------------------------------------
163// wxGauge indeterminate mode
164// ----------------------------------------------------------------------------
165
166void 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
21709999
JS
195// ----------------------------------------------------------------------------
196// wxGauge appearance params
197// ----------------------------------------------------------------------------
198
199void wxGaugeBase::SetShadowWidth(int WXUNUSED(w))
200{
201}
202
203int wxGaugeBase::GetShadowWidth() const
204{
205 return 0;
206}
207
208
209void wxGaugeBase::SetBezelFace(int WXUNUSED(w))
210{
211}
212
213int wxGaugeBase::GetBezelFace() const
214{
215 return 0;
216}
217
218#endif // wxUSE_GAUGE