]> git.saurik.com Git - wxWidgets.git/blob - src/univ/gauge.cpp
Extract wxFDIOEventLoopSourceHandler in its own header.
[wxWidgets.git] / src / univ / gauge.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/gauge/gauge.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 // Licence: 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 // ============================================================================
37 // implementation
38 // ============================================================================
39
40 // ----------------------------------------------------------------------------
41 // wxGauge creation
42 // ----------------------------------------------------------------------------
43
44 void wxGauge::Init()
45 {
46 m_gaugePos =
47 m_rangeMax = 0;
48 }
49
50 bool wxGauge::Create(wxWindow *parent,
51 wxWindowID id,
52 int range,
53 const wxPoint& pos,
54 const wxSize& size,
55 long style,
56 const wxValidator& validator,
57 const wxString& name)
58 {
59 if ( !wxGaugeBase::Create(parent, id, range, pos, size, style,
60 validator, name) )
61 {
62 return false;
63 }
64
65 SetInitialSize(size);
66
67 return true;
68 }
69
70 // ----------------------------------------------------------------------------
71 // wxGauge range/position
72 // ----------------------------------------------------------------------------
73
74 void wxGauge::SetRange(int range)
75 {
76 wxGaugeBase::SetRange(range);
77
78 Refresh();
79 }
80
81 void wxGauge::SetValue(int pos)
82 {
83 wxGaugeBase::SetValue(pos);
84
85 Refresh();
86 }
87
88 // ----------------------------------------------------------------------------
89 // wxGauge geometry
90 // ----------------------------------------------------------------------------
91
92 wxSize wxGauge::DoGetBestClientSize() const
93 {
94 wxSize size = GetRenderer()->GetProgressBarStep();
95
96 // these adjustments are really ridiculous - they are just done to find the
97 // "correct" result under Windows (FIXME)
98 if ( IsVertical() )
99 {
100 size.x = (3*size.y) / 2 + 2;
101 size.y = wxDefaultCoord;
102 }
103 else
104 {
105 size.y = (3*size.x) / 2 + 2;
106 size.x = wxDefaultCoord;
107 }
108
109 return size;
110 }
111
112 // ----------------------------------------------------------------------------
113 // wxGauge drawing
114 // ----------------------------------------------------------------------------
115
116 wxBorder wxGauge::GetDefaultBorder() const
117 {
118 return wxBORDER_STATIC;
119 }
120
121 void wxGauge::DoDraw(wxControlRenderer *renderer)
122 {
123 renderer->DrawProgressBar(this);
124 }
125
126 #endif // wxUSE_GAUGE