]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/gauge.cpp
* Hope this is the last bug fix in the wxThread merge ...
[wxWidgets.git] / src / gtk1 / gauge.cpp
CommitLineData
1a56f55c
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: gauge.cpp
3// Purpose:
4// Author: Robert Roebling
5// Created: 01/02/97
6// Id:
7// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifdef __GNUG__
12#pragma implementation "gauge.h"
13#endif
14
15#include "wx/gauge.h"
16
17//-----------------------------------------------------------------------------
18// wxGauge
19//-----------------------------------------------------------------------------
20
21IMPLEMENT_DYNAMIC_CLASS(wxGauge,wxControl)
22
23bool wxGauge::Create( wxWindow *parent, const wxWindowID id, const int range,
24 const wxPoint& pos, const wxSize& size,
25 const long style, const wxString& name )
26{
27 m_needParent = TRUE;
28
29 wxSize newSize = size;
30
31 PreCreation( parent, id, pos, size, style, name );
32
33 m_rangeMax = range;
34 m_gaugePos = 0;
35 m_useProgressBar = TRUE;
36
37 m_widget = gtk_progress_bar_new();
38
39 PostCreation();
40
41 Show( TRUE );
42
43 return TRUE;
44};
45
46void wxGauge::SetRange( const int r )
47{
48 m_rangeMax = r;
49 if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax;
50
51 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), (float)(m_rangeMax/m_gaugePos) );
52};
53
54void wxGauge::SetValue( const int pos )
55{
56 m_gaugePos = pos;
57 if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax;
58
59 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), (float)(m_rangeMax/m_gaugePos) );
60};
61
62int wxGauge::GetRange(void) const
63{
64 return m_rangeMax;
65};
66
67int wxGauge::GetValue(void) const
68{
69 return m_gaugePos;
70};
71