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