]>
Commit | Line | Data |
---|---|---|
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 | ||
21 | IMPLEMENT_DYNAMIC_CLASS(wxGauge,wxControl) | |
22 | ||
debe6624 | 23 | bool wxGauge::Create( wxWindow *parent, wxWindowID id, int range, |
1a56f55c | 24 | const wxPoint& pos, const wxSize& size, |
debe6624 | 25 | long style, const wxString& name ) |
1a56f55c RR |
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 | ||
debe6624 | 46 | void wxGauge::SetRange( int r ) |
1a56f55c RR |
47 | { |
48 | m_rangeMax = r; | |
49 | if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax; | |
50 | ||
5a8c6c9a | 51 | gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), ((float)m_gaugePos)/m_rangeMax ); |
1a56f55c RR |
52 | }; |
53 | ||
debe6624 | 54 | void wxGauge::SetValue( int pos ) |
1a56f55c RR |
55 | { |
56 | m_gaugePos = pos; | |
57 | if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax; | |
58 | ||
5a8c6c9a | 59 | gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), ((float)m_gaugePos)/m_rangeMax ); |
1a56f55c RR |
60 | }; |
61 | ||
62 | int wxGauge::GetRange(void) const | |
63 | { | |
64 | return m_rangeMax; | |
65 | }; | |
66 | ||
67 | int wxGauge::GetValue(void) const | |
68 | { | |
69 | return m_gaugePos; | |
70 | }; | |
71 |