Added zillions of #if wxUSE_XXX
[wxWidgets.git] / src / gtk / gauge.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: gauge.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifdef __GNUG__
11 #pragma implementation "gauge.h"
12 #endif
13
14 #include "wx/gauge.h"
15
16 #if wxUSE_GAUGE
17
18 #include "gdk/gdk.h"
19 #include "gtk/gtk.h"
20
21 //-----------------------------------------------------------------------------
22 // wxGauge
23 //-----------------------------------------------------------------------------
24
25 IMPLEMENT_DYNAMIC_CLASS(wxGauge,wxControl)
26
27 bool wxGauge::Create( wxWindow *parent, wxWindowID id, int range,
28 const wxPoint& pos, const wxSize& size,
29 long style, const wxValidator& validator, const wxString& name )
30 {
31 m_needParent = TRUE;
32
33 PreCreation( parent, id, pos, size, style, name );
34
35 SetValidator( validator );
36
37 m_rangeMax = range;
38 m_gaugePos = 0;
39 m_useProgressBar = TRUE;
40
41 m_widget = gtk_progress_bar_new();
42
43 m_parent->DoAddChild( this );
44
45 PostCreation();
46
47 Show( TRUE );
48
49 return TRUE;
50 }
51
52 void wxGauge::SetRange( int r )
53 {
54 m_rangeMax = r;
55 if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax;
56
57 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), ((float)m_gaugePos)/m_rangeMax );
58 }
59
60 void wxGauge::SetValue( int pos )
61 {
62 m_gaugePos = pos;
63 if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax;
64
65 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), ((float)m_gaugePos)/m_rangeMax );
66 }
67
68 int wxGauge::GetRange(void) const
69 {
70 return m_rangeMax;
71 }
72
73 int wxGauge::GetValue(void) const
74 {
75 return m_gaugePos;
76 }
77
78 void wxGauge::ApplyWidgetStyle()
79 {
80 SetWidgetStyle();
81 gtk_widget_set_style( m_widget, m_widgetStyle );
82 }
83
84 #endif