]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/gauge.cpp
wxWindow::OnClose() removed completely from wxGTK, wxCloseEvent is now
[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"
83624f79
RR
15#include "gdk/gdk.h"
16#include "gtk/gtk.h"
1a56f55c
RR
17
18//-----------------------------------------------------------------------------
19// wxGauge
20//-----------------------------------------------------------------------------
21
22IMPLEMENT_DYNAMIC_CLASS(wxGauge,wxControl)
23
debe6624 24bool wxGauge::Create( wxWindow *parent, wxWindowID id, int range,
1a56f55c 25 const wxPoint& pos, const wxSize& size,
6de97a3b 26 long style, const wxValidator& validator, const wxString& name )
1a56f55c
RR
27{
28 m_needParent = TRUE;
29
1a56f55c
RR
30 PreCreation( parent, id, pos, size, style, name );
31
6de97a3b
RR
32 SetValidator( validator );
33
1a56f55c
RR
34 m_rangeMax = range;
35 m_gaugePos = 0;
36 m_useProgressBar = TRUE;
37
38 m_widget = gtk_progress_bar_new();
39
6ca41e57
RR
40 m_parent->AddChild( this );
41
42 (m_parent->m_insertCallback)( m_parent, this );
43
1a56f55c
RR
44 PostCreation();
45
46 Show( TRUE );
47
48 return TRUE;
6de97a3b 49}
1a56f55c 50
debe6624 51void wxGauge::SetRange( int r )
1a56f55c
RR
52{
53 m_rangeMax = r;
54 if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax;
55
5a8c6c9a 56 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), ((float)m_gaugePos)/m_rangeMax );
6de97a3b 57}
1a56f55c 58
debe6624 59void wxGauge::SetValue( int pos )
1a56f55c
RR
60{
61 m_gaugePos = pos;
62 if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax;
63
5a8c6c9a 64 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), ((float)m_gaugePos)/m_rangeMax );
6de97a3b 65}
1a56f55c
RR
66
67int wxGauge::GetRange(void) const
68{
69 return m_rangeMax;
6de97a3b 70}
1a56f55c
RR
71
72int wxGauge::GetValue(void) const
73{
74 return m_gaugePos;
6de97a3b 75}
1a56f55c 76
58614078
RR
77void wxGauge::ApplyWidgetStyle()
78{
79 SetWidgetStyle();
80 gtk_widget_set_style( m_widget, m_widgetStyle );
81}
82