]> git.saurik.com Git - wxWidgets.git/blame - src/common/gaugecmn.cpp
avoiding nesting dcs on the same window concurrently
[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>
65571936 9// License: 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
4a2e5ee8 34const wxChar wxGaugeNameStr[] = wxT("gauge");
21709999
JS
35
36// ============================================================================
37// implementation
38// ============================================================================
39
799ea011
GD
40wxGaugeBase::~wxGaugeBase()
41{
42 // this destructor is required for Darwin
43}
44
21709999
JS
45// ----------------------------------------------------------------------------
46// wxGauge creation
47// ----------------------------------------------------------------------------
48
49bool 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) )
5d3e7b52 59 return false;
21709999
JS
60
61 SetName(name);
62
63#if wxUSE_VALIDATORS
64 SetValidator(validator);
65#endif // wxUSE_VALIDATORS
66
67 SetRange(range);
68 SetValue(0);
fe8635a7
RR
69#if wxGAUGE_EMULATE_INDETERMINATE_MODE
70 m_nDirection = wxRIGHT;
71#endif
21709999 72
5d3e7b52 73 return true;
21709999
JS
74}
75
76// ----------------------------------------------------------------------------
fe8635a7 77// wxGauge determinate mode range/position
21709999
JS
78// ----------------------------------------------------------------------------
79
80void wxGaugeBase::SetRange(int range)
81{
82 m_rangeMax = range;
83}
84
85int wxGaugeBase::GetRange() const
86{
87 return m_rangeMax;
88}
89
90void wxGaugeBase::SetValue(int pos)
91{
92 m_gaugePos = pos;
93}
94
95int wxGaugeBase::GetValue() const
96{
97 return m_gaugePos;
98}
99
fe8635a7
RR
100// ----------------------------------------------------------------------------
101// wxGauge indeterminate mode
102// ----------------------------------------------------------------------------
103
104void 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
21709999
JS
133// ----------------------------------------------------------------------------
134// wxGauge appearance params
135// ----------------------------------------------------------------------------
136
137void wxGaugeBase::SetShadowWidth(int WXUNUSED(w))
138{
139}
140
141int wxGaugeBase::GetShadowWidth() const
142{
143 return 0;
144}
145
146
147void wxGaugeBase::SetBezelFace(int WXUNUSED(w))
148{
149}
150
151int wxGaugeBase::GetBezelFace() const
152{
153 return 0;
154}
155
156#endif // wxUSE_GAUGE