]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk/gauge.cpp
applied patch for compilation with gcc 3.0
[wxWidgets.git] / src / gtk / gauge.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: gauge.cpp
3// Purpose:
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#ifdef __GNUG__
11#pragma implementation "gauge.h"
12#endif
13
14#include "wx/gauge.h"
15
16#if wxUSE_GAUGE
17
18#include <gdk/gdk.h>
19#include <gtk/gtk.h>
20
21//-----------------------------------------------------------------------------
22// wxGauge
23//-----------------------------------------------------------------------------
24
25IMPLEMENT_DYNAMIC_CLASS(wxGauge,wxControl)
26
27bool wxGauge::Create( wxWindow *parent, wxWindowID id, int range,
28 const wxPoint& pos, const wxSize& size,
29 long style, const wxValidator& validator, const wxString& name )
30{
31 m_needParent = TRUE;
32
33 if (!PreCreation( parent, pos, size ) ||
34 !CreateBase( parent, id, pos, size, style, validator, name ))
35 {
36 wxFAIL_MSG( wxT("wxGauge creation failed") );
37 return FALSE;
38 }
39
40 m_rangeMax = range;
41 m_gaugePos = 0;
42 m_useProgressBar = TRUE;
43
44 m_widget = gtk_progress_bar_new();
45 if( style & wxGA_VERTICAL)
46 gtk_progress_bar_set_orientation( GTK_PROGRESS_BAR(m_widget) , GTK_PROGRESS_BOTTOM_TO_TOP );
47
48 m_parent->DoAddChild( this );
49
50 PostCreation();
51
52 Show( TRUE );
53
54 return TRUE;
55}
56
57void wxGauge::SetRange( int r )
58{
59 m_rangeMax = r;
60 if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax;
61
62 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), ((float)m_gaugePos)/m_rangeMax );
63}
64
65void wxGauge::SetValue( int pos )
66{
67 m_gaugePos = pos;
68 if (m_gaugePos > m_rangeMax) m_gaugePos = m_rangeMax;
69
70 gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), ((float)m_gaugePos)/m_rangeMax );
71}
72
73int wxGauge::GetRange() const
74{
75 return m_rangeMax;
76}
77
78int wxGauge::GetValue() const
79{
80 return m_gaugePos;
81}
82
83void wxGauge::ApplyWidgetStyle()
84{
85 SetWidgetStyle();
86 gtk_widget_set_style( m_widget, m_widgetStyle );
87}
88
89#endif