]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/gauge.cpp
Version 0.4 of wxPython for MSW.
[wxWidgets.git] / src / gtk1 / gauge.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: gauge.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Created: 01/02/97
6 // Id:
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifdef __GNUG__
12 #pragma implementation "gauge.h"
13 #endif
14
15 #include "wx/gauge.h"
16
17 //-----------------------------------------------------------------------------
18 // wxGauge
19 //-----------------------------------------------------------------------------
20
21 IMPLEMENT_DYNAMIC_CLASS(wxGauge,wxControl)
22
23 bool wxGauge::Create( wxWindow *parent, wxWindowID id, int range,
24 const wxPoint& pos, const wxSize& size,
25 long style, const wxValidator& validator, const wxString& name )
26 {
27 m_needParent = TRUE;
28
29 PreCreation( parent, id, pos, size, style, name );
30
31 SetValidator( validator );
32
33 m_rangeMax = range;
34 m_gaugePos = 0;
35 m_useProgressBar = TRUE;
36
37 m_widget = gtk_progress_bar_new();
38
39 PostCreation();
40
41 Show( TRUE );
42
43 return TRUE;
44 }
45
46 void wxGauge::SetRange( int r )
47 {
48 m_rangeMax = r;
49 if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax;
50
51 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), ((float)m_gaugePos)/m_rangeMax );
52 }
53
54 void wxGauge::SetValue( int pos )
55 {
56 m_gaugePos = pos;
57 if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax;
58
59 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), ((float)m_gaugePos)/m_rangeMax );
60 }
61
62 int wxGauge::GetRange(void) const
63 {
64 return m_rangeMax;
65 }
66
67 int wxGauge::GetValue(void) const
68 {
69 return m_gaugePos;
70 }
71