]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk1/gauge.cpp
Added #include wx/dcclient.h and wx/settings.h for Vadims new code under
[wxWidgets.git] / src / gtk1 / gauge.cpp
... / ...
CommitLineData
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
25IMPLEMENT_DYNAMIC_CLASS(wxGauge,wxControl)
26
27bool 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#if wxUSE_VALIDATORS
36 SetValidator( validator );
37#endif
38
39 m_rangeMax = range;
40 m_gaugePos = 0;
41 m_useProgressBar = TRUE;
42
43 m_widget = gtk_progress_bar_new();
44
45 m_parent->DoAddChild( this );
46
47 PostCreation();
48
49 Show( TRUE );
50
51 return TRUE;
52}
53
54void wxGauge::SetRange( int r )
55{
56 m_rangeMax = r;
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
62void wxGauge::SetValue( int pos )
63{
64 m_gaugePos = pos;
65 if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax;
66
67 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), ((float)m_gaugePos)/m_rangeMax );
68}
69
70int wxGauge::GetRange(void) const
71{
72 return m_rangeMax;
73}
74
75int wxGauge::GetValue(void) const
76{
77 return m_gaugePos;
78}
79
80void wxGauge::ApplyWidgetStyle()
81{
82 SetWidgetStyle();
83 gtk_widget_set_style( m_widget, m_widgetStyle );
84}
85
86#endif