]> git.saurik.com Git - wxWidgets.git/blob - src/univ/gauge.cpp
Add wxTranslations::GetTranslatedString().
[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 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 // ============================================================================
12 // declarations
13 // ============================================================================
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
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 #if wxUSE_GAUGE
27
28 #include "wx/gauge.h"
29
30 #ifndef WX_PRECOMP
31 #endif //WX_PRECOMP
32
33 #include "wx/univ/renderer.h"
34
35 // ============================================================================
36 // implementation
37 // ============================================================================
38
39 // ----------------------------------------------------------------------------
40 // wxGauge creation
41 // ----------------------------------------------------------------------------
42
43 void wxGauge::Init()
44 {
45 m_gaugePos =
46 m_rangeMax = 0;
47 }
48
49 bool wxGauge::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 ( !wxGaugeBase::Create(parent, id, range, pos, size, style,
59 validator, name) )
60 {
61 return false;
62 }
63
64 SetInitialSize(size);
65
66 return true;
67 }
68
69 // ----------------------------------------------------------------------------
70 // wxGauge range/position
71 // ----------------------------------------------------------------------------
72
73 void wxGauge::SetRange(int range)
74 {
75 wxGaugeBase::SetRange(range);
76
77 Refresh();
78 }
79
80 void wxGauge::SetValue(int pos)
81 {
82 wxGaugeBase::SetValue(pos);
83
84 Refresh();
85 }
86
87 // ----------------------------------------------------------------------------
88 // wxGauge geometry
89 // ----------------------------------------------------------------------------
90
91 wxSize wxGauge::DoGetBestClientSize() const
92 {
93 wxSize size = GetRenderer()->GetProgressBarStep();
94
95 // these adjustments are really ridiculous - they are just done to find the
96 // "correct" result under Windows (FIXME)
97 if ( IsVertical() )
98 {
99 size.x = (3*size.y) / 2 + 2;
100 size.y = wxDefaultCoord;
101 }
102 else
103 {
104 size.y = (3*size.x) / 2 + 2;
105 size.x = wxDefaultCoord;
106 }
107
108 return size;
109 }
110
111 // ----------------------------------------------------------------------------
112 // wxGauge drawing
113 // ----------------------------------------------------------------------------
114
115 wxBorder wxGauge::GetDefaultBorder() const
116 {
117 return wxBORDER_STATIC;
118 }
119
120 void wxGauge::DoDraw(wxControlRenderer *renderer)
121 {
122 renderer->DrawProgressBar(this);
123 }
124
125 #endif // wxUSE_GAUGE