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 bool wxGauge::Create( wxWindow
*parent
,
29 const wxValidator
& validator
,
30 const wxString
& name
)
34 if (!PreCreation( parent
, pos
, size
) ||
35 !CreateBase( parent
, id
, pos
, size
, style
, validator
, name
))
37 wxFAIL_MSG( wxT("wxGauge creation failed") );
43 m_widget
= gtk_progress_bar_new();
44 if ( style
& wxGA_VERTICAL
)
46 gtk_progress_bar_set_orientation( GTK_PROGRESS_BAR(m_widget
),
47 GTK_PROGRESS_BOTTOM_TO_TOP
);
50 m_parent
->DoAddChild( this );
58 void wxGauge::DoSetGauge()
60 wxASSERT_MSG( 0 <= m_gaugePos
&& m_gaugePos
<= m_rangeMax
,
61 wxT("invalid gauge position in DoSetGauge()") );
63 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget
),
64 m_rangeMax
? ((float)m_gaugePos
)/m_rangeMax
: 0.);
67 wxSize
wxGauge::DoGetBestSize() const
70 if (HasFlag(wxGA_VERTICAL
))
71 best
= wxSize(28, 100);
73 best
= wxSize(100, 28);
78 void wxGauge::SetRange( int range
)
81 if (m_gaugePos
> m_rangeMax
)
82 m_gaugePos
= m_rangeMax
;
87 void wxGauge::SetValue( int pos
)
89 wxCHECK_RET( pos
<= m_rangeMax
, wxT("invalid value in wxGauge::SetValue()") );
96 int wxGauge::GetRange() const
101 int wxGauge::GetValue() const
106 wxVisualAttributes
wxGauge::GetDefaultAttributes() const
108 // Visible gauge colours use a different colour state
109 return GetDefaultAttributesFromGTKWidget(m_widget
,
117 wxGauge::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
119 return GetDefaultAttributesFromGTKWidget(gtk_progress_bar_new
,
120 false, GTK_STATE_ACTIVE
);
123 #endif // wxUSE_GAUGE