]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/gauge.cpp
Corrected memory.cpp checkpoint bug; added Tex2RTF
[wxWidgets.git] / src / gtk1 / gauge.cpp
CommitLineData
1a56f55c
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: gauge.cpp
3// Purpose:
4// Author: Robert Roebling
a81258be 5// Id: $Id$
01111366 6// Copyright: (c) 1998 Robert Roebling
1a56f55c
RR
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
20IMPLEMENT_DYNAMIC_CLASS(wxGauge,wxControl)
21
debe6624 22bool wxGauge::Create( wxWindow *parent, wxWindowID id, int range,
1a56f55c 23 const wxPoint& pos, const wxSize& size,
6de97a3b 24 long style, const wxValidator& validator, const wxString& name )
1a56f55c
RR
25{
26 m_needParent = TRUE;
27
1a56f55c
RR
28 PreCreation( parent, id, pos, size, style, name );
29
6de97a3b
RR
30 SetValidator( validator );
31
1a56f55c
RR
32 m_rangeMax = range;
33 m_gaugePos = 0;
34 m_useProgressBar = TRUE;
35
36 m_widget = gtk_progress_bar_new();
37
6ca41e57
RR
38 m_parent->AddChild( this );
39
40 (m_parent->m_insertCallback)( m_parent, this );
41
1a56f55c
RR
42 PostCreation();
43
44 Show( TRUE );
45
46 return TRUE;
6de97a3b 47}
1a56f55c 48
debe6624 49void wxGauge::SetRange( int r )
1a56f55c
RR
50{
51 m_rangeMax = r;
52 if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax;
53
5a8c6c9a 54 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), ((float)m_gaugePos)/m_rangeMax );
6de97a3b 55}
1a56f55c 56
debe6624 57void wxGauge::SetValue( int pos )
1a56f55c
RR
58{
59 m_gaugePos = pos;
60 if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax;
61
5a8c6c9a 62 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), ((float)m_gaugePos)/m_rangeMax );
6de97a3b 63}
1a56f55c
RR
64
65int wxGauge::GetRange(void) const
66{
67 return m_rangeMax;
6de97a3b 68}
1a56f55c
RR
69
70int wxGauge::GetValue(void) const
71{
72 return m_gaugePos;
6de97a3b 73}
1a56f55c 74
58614078
RR
75void wxGauge::ApplyWidgetStyle()
76{
77 SetWidgetStyle();
78 gtk_widget_set_style( m_widget, m_widgetStyle );
79}
80