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