1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/gauge.cpp
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
19 //-----------------------------------------------------------------------------
21 //-----------------------------------------------------------------------------
23 IMPLEMENT_DYNAMIC_CLASS(wxGauge
, wxControl
)
25 bool wxGauge::Create( wxWindow
*parent
,
31 const wxValidator
& validator
,
32 const wxString
& name
)
36 if (!PreCreation( parent
, pos
, size
) ||
37 !CreateBase( parent
, id
, pos
, size
, style
, validator
, name
))
39 wxFAIL_MSG( wxT("wxGauge creation failed") );
45 m_widget
= gtk_progress_bar_new();
46 if ( style
& wxGA_VERTICAL
)
48 gtk_progress_bar_set_orientation( GTK_PROGRESS_BAR(m_widget
),
49 GTK_PROGRESS_BOTTOM_TO_TOP
);
52 m_parent
->DoAddChild( this );
60 void wxGauge::DoSetGauge()
62 wxASSERT_MSG( 0 <= m_gaugePos
&& m_gaugePos
<= m_rangeMax
,
63 _T("invalid gauge position in DoSetGauge()") );
65 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget
),
66 m_rangeMax
? ((float)m_gaugePos
)/m_rangeMax
: 0.);
69 wxSize
wxGauge::DoGetBestSize() const
72 if (HasFlag(wxGA_VERTICAL
))
73 best
= wxSize(28, 100);
75 best
= wxSize(100, 28);
80 void wxGauge::SetRange( int range
)
83 if (m_gaugePos
> m_rangeMax
)
84 m_gaugePos
= m_rangeMax
;
89 void wxGauge::SetValue( int pos
)
91 wxCHECK_RET( pos
<= m_rangeMax
, _T("invalid value in wxGauge::SetValue()") );
98 int wxGauge::GetRange() const
103 int wxGauge::GetValue() const
108 wxVisualAttributes
wxGauge::GetDefaultAttributes() const
110 // Visible gauge colours use a different colour state
111 return GetDefaultAttributesFromGTKWidget(m_widget
,
119 wxGauge::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
121 return GetDefaultAttributesFromGTKWidget(gtk_progress_bar_new
,
122 false, GTK_STATE_ACTIVE
);
125 #endif // wxUSE_GAUGE