1
/////////////////////////////////////////////////////////////////////////////
4
// Author: Robert Roebling
5
// Id: $Id: gauge.cpp,v 1.30 2004/06/24 20:04:01 RD Exp $
6
// Copyright: (c) 1998 Robert Roebling
7
// Licence: wxWindows licence
8
/////////////////////////////////////////////////////////////////////////////
10
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11
#pragma implementation "gauge.h"
14
// For compilers that support precompilation, includes "wx.h".
15
#include "wx/wxprec.h"
23
//-----------------------------------------------------------------------------
25
//-----------------------------------------------------------------------------
27
IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
29
bool wxGauge::Create( wxWindow *parent,
35
const wxValidator& validator,
36
const wxString& name )
40
if (!PreCreation( parent, pos, size ) ||
41
!CreateBase( parent, id, pos, size, style, validator, name ))
43
wxFAIL_MSG( wxT("wxGauge creation failed") );
49
m_widget = gtk_progress_bar_new();
50
if ( style & wxGA_VERTICAL )
52
gtk_progress_bar_set_orientation( GTK_PROGRESS_BAR(m_widget),
53
GTK_PROGRESS_BOTTOM_TO_TOP );
56
m_parent->DoAddChild( this );
64
void wxGauge::DoSetGauge()
66
wxASSERT_MSG( 0 <= m_gaugePos && m_gaugePos <= m_rangeMax,
67
_T("invalid gauge position in DoSetGauge()") );
69
gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget),
70
m_rangeMax ? ((float)m_gaugePos)/m_rangeMax : 0.);
73
wxSize wxGauge::DoGetBestSize() const
76
if (HasFlag(wxGA_VERTICAL))
77
best = wxSize(28, 100);
79
best = wxSize(100, 28);
84
void wxGauge::SetRange( int range )
87
if (m_gaugePos > m_rangeMax)
88
m_gaugePos = m_rangeMax;
93
void wxGauge::SetValue( int pos )
95
wxCHECK_RET( pos <= m_rangeMax, _T("invalid value in wxGauge::SetValue()") );
102
int wxGauge::GetRange() const
107
int wxGauge::GetValue() const
112
wxVisualAttributes wxGauge::GetDefaultAttributes() const
114
// Visible gauge colours use a different colour state
115
return GetDefaultAttributesFromGTKWidget(m_widget,
123
wxGauge::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
125
return GetDefaultAttributesFromGTKWidget(gtk_progress_bar_new,
126
false, GTK_STATE_ACTIVE);
129
#endif // wxUSE_GAUGE