1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/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
)
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 // when using the gauge in indeterminate mode, we need this:
51 gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR (m_widget
), 0.05);
53 m_parent
->DoAddChild( this );
61 void wxGauge::DoSetGauge()
63 wxASSERT_MSG( 0 <= m_gaugePos
&& m_gaugePos
<= m_rangeMax
,
64 _T("invalid gauge position in DoSetGauge()") );
66 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (m_widget
),
67 m_rangeMax
? ((double)m_gaugePos
)/m_rangeMax
: 0.0);
70 wxSize
wxGauge::DoGetBestSize() const
73 if (HasFlag(wxGA_VERTICAL
))
74 best
= wxSize(28, 100);
76 best
= wxSize(100, 28);
81 void wxGauge::SetRange( int range
)
84 if (m_gaugePos
> m_rangeMax
)
85 m_gaugePos
= m_rangeMax
;
90 void wxGauge::SetValue( int pos
)
92 wxCHECK_RET( pos
<= m_rangeMax
, _T("invalid value in wxGauge::SetValue()") );
99 int wxGauge::GetRange() const
104 int wxGauge::GetValue() const
109 void wxGauge::Pulse()
111 gtk_progress_bar_pulse(GTK_PROGRESS_BAR (m_widget
));
114 wxVisualAttributes
wxGauge::GetDefaultAttributes() const
116 // Visible gauge colours use a different colour state
117 return GetDefaultAttributesFromGTKWidget(m_widget
,
125 wxGauge::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
127 return GetDefaultAttributesFromGTKWidget(gtk_progress_bar_new
,
128 false, GTK_STATE_ACTIVE
);
131 #endif // wxUSE_GAUGE