]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/gauge.cpp
*** empty log message ***
[wxWidgets.git] / src / gtk1 / 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 if (!PreCreation( parent, pos, size ) ||
34 !CreateBase( parent, id, pos, size, style, validator, name ))
35 {
36 wxFAIL_MSG( wxT("wxGauge creation failed") );
37 return FALSE;
38 }
39
40 m_rangeMax = range;
41 m_gaugePos = 0;
42 m_useProgressBar = TRUE;
43
44 m_widget = gtk_progress_bar_new();
45
46 m_parent->DoAddChild( this );
47
48 PostCreation();
49
50 Show( TRUE );
51
52 return TRUE;
53 }
54
55 void wxGauge::SetRange( int r )
56 {
57 m_rangeMax = r;
58 if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax;
59
60 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), ((float)m_gaugePos)/m_rangeMax );
61 }
62
63 void wxGauge::SetValue( int pos )
64 {
65 m_gaugePos = pos;
66 if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax;
67
68 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), ((float)m_gaugePos)/m_rangeMax );
69 }
70
71 int wxGauge::GetRange() const
72 {
73 return m_rangeMax;
74 }
75
76 int wxGauge::GetValue() const
77 {
78 return m_gaugePos;
79 }
80
81 void wxGauge::ApplyWidgetStyle()
82 {
83 SetWidgetStyle();
84 gtk_widget_set_style( m_widget, m_widgetStyle );
85 }
86
87 #endif