]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/gauge.cpp
Disable final failing wxWebView test. It fails on the buildbot but not locally.
[wxWidgets.git] / src / gtk1 / gauge.cpp
CommitLineData
1a56f55c 1/////////////////////////////////////////////////////////////////////////////
9d2c19f1 2// Name: src/gtk1/gauge.cpp
1a56f55c
RR
3// Purpose:
4// Author: Robert Roebling
a81258be 5// Id: $Id$
01111366 6// Copyright: (c) 1998 Robert Roebling
65571936 7// Licence: wxWindows licence
1a56f55c
RR
8/////////////////////////////////////////////////////////////////////////////
9
14f355c2
VS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
dcf924a3
RR
13#if wxUSE_GAUGE
14
9d2c19f1
WS
15#include "wx/gauge.h"
16
55703c91 17#include <gtk/gtk.h>
1a56f55c
RR
18
19//-----------------------------------------------------------------------------
20// wxGauge
21//-----------------------------------------------------------------------------
22
2b5f62a0
VZ
23bool wxGauge::Create( wxWindow *parent,
24 wxWindowID id,
25 int range,
26 const wxPoint& pos,
27 const wxSize& size,
28 long style,
29 const wxValidator& validator,
30 const wxString& name )
1a56f55c 31{
9d2c19f1 32 m_needParent = true;
4a0f7f3f 33
4dcaf11a
RR
34 if (!PreCreation( parent, pos, size ) ||
35 !CreateBase( parent, id, pos, size, style, validator, name ))
36 {
223d09f6 37 wxFAIL_MSG( wxT("wxGauge creation failed") );
9d2c19f1 38 return false;
4dcaf11a 39 }
6de97a3b 40
4dcaf11a 41 m_rangeMax = range;
4a0f7f3f 42
4dcaf11a 43 m_widget = gtk_progress_bar_new();
2b5f62a0
VZ
44 if ( style & wxGA_VERTICAL )
45 {
46 gtk_progress_bar_set_orientation( GTK_PROGRESS_BAR(m_widget),
47 GTK_PROGRESS_BOTTOM_TO_TOP );
48 }
4a0f7f3f 49
4dcaf11a 50 m_parent->DoAddChild( this );
4a0f7f3f 51
abdeb9e7 52 PostCreation(size);
170acdc9 53 SetInitialSize(size);
3d257b8d 54
9d2c19f1 55 return true;
6de97a3b 56}
1a56f55c 57
2b5f62a0
VZ
58void wxGauge::DoSetGauge()
59{
60 wxASSERT_MSG( 0 <= m_gaugePos && m_gaugePos <= m_rangeMax,
9a83f860 61 wxT("invalid gauge position in DoSetGauge()") );
2b5f62a0
VZ
62
63 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget),
64 m_rangeMax ? ((float)m_gaugePos)/m_rangeMax : 0.);
65}
66
3a12cb0a
RD
67wxSize wxGauge::DoGetBestSize() const
68{
9f884528 69 wxSize best;
ebbb22bd 70 if (HasFlag(wxGA_VERTICAL))
9f884528 71 best = wxSize(28, 100);
ebbb22bd 72 else
9f884528
RD
73 best = wxSize(100, 28);
74 CacheBestSize(best);
75 return best;
3a12cb0a
RD
76}
77
2b5f62a0 78void wxGauge::SetRange( int range )
1a56f55c 79{
2b5f62a0
VZ
80 m_rangeMax = range;
81 if (m_gaugePos > m_rangeMax)
82 m_gaugePos = m_rangeMax;
4a0f7f3f 83
2b5f62a0 84 DoSetGauge();
6de97a3b 85}
1a56f55c 86
debe6624 87void wxGauge::SetValue( int pos )
1a56f55c 88{
9a83f860 89 wxCHECK_RET( pos <= m_rangeMax, wxT("invalid value in wxGauge::SetValue()") );
2b5f62a0 90
4dcaf11a 91 m_gaugePos = pos;
4a0f7f3f 92
2b5f62a0 93 DoSetGauge();
6de97a3b 94}
1a56f55c 95
4dcaf11a 96int wxGauge::GetRange() const
1a56f55c 97{
4dcaf11a 98 return m_rangeMax;
6de97a3b 99}
1a56f55c 100
4dcaf11a 101int wxGauge::GetValue() const
1a56f55c 102{
4dcaf11a 103 return m_gaugePos;
6de97a3b 104}
1a56f55c 105
9d522606
RD
106wxVisualAttributes wxGauge::GetDefaultAttributes() const
107{
108 // Visible gauge colours use a different colour state
109 return GetDefaultAttributesFromGTKWidget(m_widget,
110 UseGTKStyleBase(),
111 GTK_STATE_ACTIVE);
112
113}
114
115// static
116wxVisualAttributes
117wxGauge::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
118{
119 return GetDefaultAttributesFromGTKWidget(gtk_progress_bar_new,
120 false, GTK_STATE_ACTIVE);
121}
122
4a0f7f3f 123#endif // wxUSE_GAUGE