]> git.saurik.com Git - wxWidgets.git/blame - src/univ/gauge.cpp
Sizing fixes according to patch #1523304.
[wxWidgets.git] / src / univ / gauge.cpp
CommitLineData
1e6feb95
VZ
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$
442b35b5 8// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
65571936 9// License: wxWindows licence
1e6feb95
VZ
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
1e6feb95
VZ
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
24 #pragma hdrstop
25#endif
26
9d2c19f1 27#if wxUSE_GAUGE
1e6feb95
VZ
28
29#include "wx/gauge.h"
30
9d2c19f1
WS
31#ifndef WX_PRECOMP
32#endif //WX_PRECOMP
1e6feb95
VZ
33
34#include "wx/univ/renderer.h"
35
36IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
37
38// ============================================================================
39// implementation
40// ============================================================================
41
42// ----------------------------------------------------------------------------
43// wxGauge creation
44// ----------------------------------------------------------------------------
45
46void wxGauge::Init()
47{
48 m_gaugePos =
49 m_rangeMax = 0;
50}
51
52bool 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 {
a290fa5a 64 return false;
1e6feb95
VZ
65 }
66
67 SetBestSize(size);
68
a290fa5a 69 return true;
1e6feb95
VZ
70}
71
72// ----------------------------------------------------------------------------
73// wxGauge range/position
74// ----------------------------------------------------------------------------
75
76void wxGauge::SetRange(int range)
77{
78 wxGaugeBase::SetRange(range);
79
80 Refresh();
81}
82
83void wxGauge::SetValue(int pos)
84{
85 wxGaugeBase::SetValue(pos);
86
87 Refresh();
88}
89
90// ----------------------------------------------------------------------------
91// wxGauge geometry
92// ----------------------------------------------------------------------------
93
94wxSize 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;
a290fa5a 103 size.y = wxDefaultCoord;
1e6feb95
VZ
104 }
105 else
106 {
107 size.y = (3*size.x) / 2 + 2;
a290fa5a 108 size.x = wxDefaultCoord;
1e6feb95
VZ
109 }
110
111 return size;
112}
113
114// ----------------------------------------------------------------------------
115// wxGauge drawing
116// ----------------------------------------------------------------------------
117
118wxBorder wxGauge::GetDefaultBorder() const
119{
120 return wxBORDER_STATIC;
121}
122
123void wxGauge::DoDraw(wxControlRenderer *renderer)
124{
125 renderer->DrawProgressBar(this);
126}
127
128#endif // wxUSE_GAUGE