]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk/gauge.cpp
Added sashtest GTK makefiles (crashing bug to be solved); added typetest sample
[wxWidgets.git] / src / gtk / gauge.cpp
... / ...
CommitLineData
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, wxWindowID id, int range,
24 const wxPoint& pos, const wxSize& size,
25 long style, const wxValidator& validator, const wxString& name )
26{
27 m_needParent = TRUE;
28
29 PreCreation( parent, id, pos, size, style, name );
30
31 SetValidator( validator );
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( 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_gaugePos)/m_rangeMax );
52}
53
54void wxGauge::SetValue( 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_gaugePos)/m_rangeMax );
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