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 bool wxGauge::Create( wxWindow
*parent
,
29 const wxValidator
& validator
,
30 const wxString
& name
)
32 if (!PreCreation( parent
, pos
, size
) ||
33 !CreateBase( parent
, id
, pos
, size
, style
, validator
, name
))
35 wxFAIL_MSG( wxT("wxGauge creation failed") );
41 m_widget
= gtk_progress_bar_new();
42 g_object_ref(m_widget
);
43 if ( style
& wxGA_VERTICAL
)
45 gtk_progress_bar_set_orientation( GTK_PROGRESS_BAR(m_widget
),
46 GTK_PROGRESS_BOTTOM_TO_TOP
);
49 // when using the gauge in indeterminate mode, we need this:
50 gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR (m_widget
), 0.05);
52 m_parent
->DoAddChild( this );
60 void wxGauge::DoSetGauge()
62 wxASSERT_MSG( 0 <= m_gaugePos
&& m_gaugePos
<= m_rangeMax
,
63 wxT("invalid gauge position in DoSetGauge()") );
65 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (m_widget
),
66 m_rangeMax
? ((double)m_gaugePos
)/m_rangeMax
: 0.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
, wxT("invalid value in wxGauge::SetValue()") );
98 int wxGauge::GetRange() const
103 int wxGauge::GetValue() const
108 void wxGauge::Pulse()
110 gtk_progress_bar_pulse(GTK_PROGRESS_BAR (m_widget
));
113 wxVisualAttributes
wxGauge::GetDefaultAttributes() const
115 // Visible gauge colours use a different colour state
116 return GetDefaultAttributesFromGTKWidget(m_widget
,
124 wxGauge::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
126 return GetDefaultAttributesFromGTKWidget(gtk_progress_bar_new
,
127 false, GTK_STATE_ACTIVE
);
130 #endif // wxUSE_GAUGE