]> git.saurik.com Git - wxWidgets.git/blame - src/univ/gauge.cpp
supporting native content scaling on OSX
[wxWidgets.git] / src / univ / gauge.cpp
CommitLineData
1e6feb95 1///////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/gauge/gauge.cpp
1e6feb95
VZ
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)
526954c5 9// Licence: 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
1e6feb95
VZ
36// ============================================================================
37// implementation
38// ============================================================================
39
40// ----------------------------------------------------------------------------
41// wxGauge creation
42// ----------------------------------------------------------------------------
43
44void wxGauge::Init()
45{
46 m_gaugePos =
47 m_rangeMax = 0;
48}
49
50bool 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 {
a290fa5a 62 return false;
1e6feb95
VZ
63 }
64
170acdc9 65 SetInitialSize(size);
1e6feb95 66
a290fa5a 67 return true;
1e6feb95
VZ
68}
69
70// ----------------------------------------------------------------------------
71// wxGauge range/position
72// ----------------------------------------------------------------------------
73
74void wxGauge::SetRange(int range)
75{
76 wxGaugeBase::SetRange(range);
77
78 Refresh();
79}
80
81void wxGauge::SetValue(int pos)
82{
83 wxGaugeBase::SetValue(pos);
84
85 Refresh();
86}
87
88// ----------------------------------------------------------------------------
89// wxGauge geometry
90// ----------------------------------------------------------------------------
91
92wxSize 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;
a290fa5a 101 size.y = wxDefaultCoord;
1e6feb95
VZ
102 }
103 else
104 {
105 size.y = (3*size.x) / 2 + 2;
a290fa5a 106 size.x = wxDefaultCoord;
1e6feb95
VZ
107 }
108
109 return size;
110}
111
112// ----------------------------------------------------------------------------
113// wxGauge drawing
114// ----------------------------------------------------------------------------
115
116wxBorder wxGauge::GetDefaultBorder() const
117{
118 return wxBORDER_STATIC;
119}
120
121void wxGauge::DoDraw(wxControlRenderer *renderer)
122{
123 renderer->DrawProgressBar(this);
124}
125
126#endif // wxUSE_GAUGE