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
)
46 gtk_orientable_set_orientation(GTK_ORIENTABLE(m_widget
), GTK_ORIENTATION_VERTICAL
);
47 gtk_progress_bar_set_inverted(GTK_PROGRESS_BAR(m_widget
), true);
49 gtk_progress_bar_set_orientation( GTK_PROGRESS_BAR(m_widget
),
50 GTK_PROGRESS_BOTTOM_TO_TOP
);
54 // when using the gauge in indeterminate mode, we need this:
55 gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR (m_widget
), 0.05);
57 m_parent
->DoAddChild( this );
65 void wxGauge::DoSetGauge()
67 wxASSERT_MSG( 0 <= m_gaugePos
&& m_gaugePos
<= m_rangeMax
,
68 wxT("invalid gauge position in DoSetGauge()") );
70 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (m_widget
),
71 m_rangeMax
? ((double)m_gaugePos
)/m_rangeMax
: 0.0);
74 wxSize
wxGauge::DoGetBestSize() const
77 if (HasFlag(wxGA_VERTICAL
))
78 best
= wxSize(28, 100);
80 best
= wxSize(100, 28);
85 void wxGauge::SetRange( int range
)
88 if (m_gaugePos
> m_rangeMax
)
89 m_gaugePos
= m_rangeMax
;
94 void wxGauge::SetValue( int pos
)
96 wxCHECK_RET( pos
<= m_rangeMax
, wxT("invalid value in wxGauge::SetValue()") );
103 int wxGauge::GetRange() const
108 int wxGauge::GetValue() const
113 void wxGauge::Pulse()
115 gtk_progress_bar_pulse(GTK_PROGRESS_BAR (m_widget
));
118 wxVisualAttributes
wxGauge::GetDefaultAttributes() const
120 // Visible gauge colours use a different colour state
121 return GetDefaultAttributesFromGTKWidget(m_widget
,
129 wxGauge::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
131 return GetDefaultAttributesFromGTKWidget(gtk_progress_bar_new(),
132 false, GTK_STATE_ACTIVE
);
135 #endif // wxUSE_GAUGE