]> git.saurik.com Git - wxWidgets.git/blob - src/univ/gauge.cpp
Warning fix.
[wxWidgets.git] / src / univ / gauge.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/gauge/gaugecmn.cpp
3 // Purpose: wxGauge for wxUniversal
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 20.02.01
7 // RCS-ID: $Id$
8 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
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 #if wxUSE_GAUGE
28
29 #include "wx/gauge.h"
30
31 #ifndef WX_PRECOMP
32 #endif //WX_PRECOMP
33
34 #include "wx/univ/renderer.h"
35
36 IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
37
38 // ============================================================================
39 // implementation
40 // ============================================================================
41
42 // ----------------------------------------------------------------------------
43 // wxGauge creation
44 // ----------------------------------------------------------------------------
45
46 void wxGauge::Init()
47 {
48 m_gaugePos =
49 m_rangeMax = 0;
50 }
51
52 bool wxGauge::Create(wxWindow *parent,
53 wxWindowID id,
54 int range,
55 const wxPoint& pos,
56 const wxSize& size,
57 long style,
58 const wxValidator& validator,
59 const wxString& name)
60 {
61 if ( !wxGaugeBase::Create(parent, id, range, pos, size, style,
62 validator, name) )
63 {
64 return false;
65 }
66
67 SetBestSize(size);
68
69 return true;
70 }
71
72 // ----------------------------------------------------------------------------
73 // wxGauge range/position
74 // ----------------------------------------------------------------------------
75
76 void wxGauge::SetRange(int range)
77 {
78 wxGaugeBase::SetRange(range);
79
80 Refresh();
81 }
82
83 void wxGauge::SetValue(int pos)
84 {
85 wxGaugeBase::SetValue(pos);
86
87 Refresh();
88 }
89
90 // ----------------------------------------------------------------------------
91 // wxGauge geometry
92 // ----------------------------------------------------------------------------
93
94 wxSize wxGauge::DoGetBestClientSize() const
95 {
96 wxSize size = GetRenderer()->GetProgressBarStep();
97
98 // these adjustments are really ridiculous - they are just done to find the
99 // "correct" result under Windows (FIXME)
100 if ( IsVertical() )
101 {
102 size.x = (3*size.y) / 2 + 2;
103 size.y = wxDefaultCoord;
104 }
105 else
106 {
107 size.y = (3*size.x) / 2 + 2;
108 size.x = wxDefaultCoord;
109 }
110
111 return size;
112 }
113
114 // ----------------------------------------------------------------------------
115 // wxGauge drawing
116 // ----------------------------------------------------------------------------
117
118 wxBorder wxGauge::GetDefaultBorder() const
119 {
120 return wxBORDER_STATIC;
121 }
122
123 void wxGauge::DoDraw(wxControlRenderer *renderer)
124 {
125 renderer->DrawProgressBar(this);
126 }
127
128 #endif // wxUSE_GAUGE