]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/gauge.cpp
new makefiles (part I)
[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 #include "gdk/gdk.h"
16 #include "gtk/gtk.h"
17
18 //-----------------------------------------------------------------------------
19 // wxGauge
20 //-----------------------------------------------------------------------------
21
22 IMPLEMENT_DYNAMIC_CLASS(wxGauge,wxControl)
23
24 bool wxGauge::Create( wxWindow *parent, wxWindowID id, int range,
25 const wxPoint& pos, const wxSize& size,
26 long style, const wxValidator& validator, const wxString& name )
27 {
28 m_needParent = TRUE;
29
30 PreCreation( parent, id, pos, size, style, name );
31
32 SetValidator( validator );
33
34 m_rangeMax = range;
35 m_gaugePos = 0;
36 m_useProgressBar = TRUE;
37
38 m_widget = gtk_progress_bar_new();
39
40 m_parent->DoAddChild( this );
41
42 PostCreation();
43
44 Show( TRUE );
45
46 return TRUE;
47 }
48
49 void wxGauge::SetRange( int r )
50 {
51 m_rangeMax = r;
52 if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax;
53
54 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), ((float)m_gaugePos)/m_rangeMax );
55 }
56
57 void wxGauge::SetValue( int pos )
58 {
59 m_gaugePos = pos;
60 if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax;
61
62 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), ((float)m_gaugePos)/m_rangeMax );
63 }
64
65 int wxGauge::GetRange(void) const
66 {
67 return m_rangeMax;
68 }
69
70 int wxGauge::GetValue(void) const
71 {
72 return m_gaugePos;
73 }
74
75 void wxGauge::ApplyWidgetStyle()
76 {
77 SetWidgetStyle();
78 gtk_widget_set_style( m_widget, m_widgetStyle );
79 }
80