1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/gauge.cpp
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
18 //-----------------------------------------------------------------------------
20 //-----------------------------------------------------------------------------
22 bool wxGauge::Create( wxWindow
*parent
,
28 const wxValidator
& validator
,
29 const wxString
& name
)
33 if (!PreCreation( parent
, pos
, size
) ||
34 !CreateBase( parent
, id
, pos
, size
, style
, validator
, name
))
36 wxFAIL_MSG( wxT("wxGauge creation failed") );
42 m_widget
= gtk_progress_bar_new();
43 if ( style
& wxGA_VERTICAL
)
45 gtk_progress_bar_set_orientation( GTK_PROGRESS_BAR(m_widget
),
46 GTK_PROGRESS_BOTTOM_TO_TOP
);
49 m_parent
->DoAddChild( this );
57 void wxGauge::DoSetGauge()
59 wxASSERT_MSG( 0 <= m_gaugePos
&& m_gaugePos
<= m_rangeMax
,
60 wxT("invalid gauge position in DoSetGauge()") );
62 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget
),
63 m_rangeMax
? ((float)m_gaugePos
)/m_rangeMax
: 0.);
66 wxSize
wxGauge::DoGetBestSize() const
69 if (HasFlag(wxGA_VERTICAL
))
70 best
= wxSize(28, 100);
72 best
= wxSize(100, 28);
77 void wxGauge::SetRange( int range
)
80 if (m_gaugePos
> m_rangeMax
)
81 m_gaugePos
= m_rangeMax
;
86 void wxGauge::SetValue( int pos
)
88 wxCHECK_RET( pos
<= m_rangeMax
, wxT("invalid value in wxGauge::SetValue()") );
95 int wxGauge::GetRange() const
100 int wxGauge::GetValue() const
105 wxVisualAttributes
wxGauge::GetDefaultAttributes() const
107 // Visible gauge colours use a different colour state
108 return GetDefaultAttributesFromGTKWidget(m_widget
,
116 wxGauge::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
118 return GetDefaultAttributesFromGTKWidget(gtk_progress_bar_new
,
119 false, GTK_STATE_ACTIVE
);
122 #endif // wxUSE_GAUGE