]> git.saurik.com Git - wxWidgets.git/blob - src/common/gaugecmn.cpp
fix wxMBConv_iconv to respect the base class conventions: when the input is NUL-termi...
[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 // RCS-ID: $Id$
8 // Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // License: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
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
30 #if wxUSE_GAUGE
31
32 #include "wx/gauge.h"
33
34 const char wxGaugeNameStr[] = "gauge";
35
36 // ============================================================================
37 // implementation
38 // ============================================================================
39
40 wxGaugeBase::~wxGaugeBase()
41 {
42 // this destructor is required for Darwin
43 }
44
45 // ----------------------------------------------------------------------------
46 // wxGauge creation
47 // ----------------------------------------------------------------------------
48
49 bool wxGaugeBase::Create(wxWindow *parent,
50 wxWindowID id,
51 int range,
52 const wxPoint& pos,
53 const wxSize& size,
54 long style,
55 const wxValidator& validator,
56 const wxString& name)
57 {
58 if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
59 return false;
60
61 SetName(name);
62
63 #if wxUSE_VALIDATORS
64 SetValidator(validator);
65 #endif // wxUSE_VALIDATORS
66
67 SetRange(range);
68 SetValue(0);
69 #if wxGAUGE_EMULATE_INDETERMINATE_MODE
70 m_nDirection = wxRIGHT;
71 #endif
72
73 return true;
74 }
75
76 // ----------------------------------------------------------------------------
77 // wxGauge determinate mode range/position
78 // ----------------------------------------------------------------------------
79
80 void wxGaugeBase::SetRange(int range)
81 {
82 m_rangeMax = range;
83 }
84
85 int wxGaugeBase::GetRange() const
86 {
87 return m_rangeMax;
88 }
89
90 void wxGaugeBase::SetValue(int pos)
91 {
92 m_gaugePos = pos;
93 }
94
95 int wxGaugeBase::GetValue() const
96 {
97 return m_gaugePos;
98 }
99
100 // ----------------------------------------------------------------------------
101 // wxGauge indeterminate mode
102 // ----------------------------------------------------------------------------
103
104 void wxGaugeBase::Pulse()
105 {
106 #if wxGAUGE_EMULATE_INDETERMINATE_MODE
107 // simulate indeterminate mode
108 int curr = GetValue(), max = GetRange();
109
110 if (m_nDirection == wxRIGHT)
111 {
112 if (curr < max)
113 SetValue(curr + 1);
114 else
115 {
116 SetValue(max - 1);
117 m_nDirection = wxLEFT;
118 }
119 }
120 else
121 {
122 if (curr > 0)
123 SetValue(curr - 1);
124 else
125 {
126 SetValue(1);
127 m_nDirection = wxRIGHT;
128 }
129 }
130 #endif
131 }
132
133 // ----------------------------------------------------------------------------
134 // wxGauge appearance params
135 // ----------------------------------------------------------------------------
136
137 void wxGaugeBase::SetShadowWidth(int WXUNUSED(w))
138 {
139 }
140
141 int wxGaugeBase::GetShadowWidth() const
142 {
143 return 0;
144 }
145
146
147 void wxGaugeBase::SetBezelFace(int WXUNUSED(w))
148 {
149 }
150
151 int wxGaugeBase::GetBezelFace() const
152 {
153 return 0;
154 }
155
156 #endif // wxUSE_GAUGE