1 ///////////////////////////////////////////////////////////////////////////// 
   4 // Author:      Robert Roebling 
   6 // Copyright:   (c) 1998 Robert Roebling 
   7 // Licence:     wxWindows licence 
   8 ///////////////////////////////////////////////////////////////////////////// 
  11 #pragma implementation "gauge.h" 
  20 //----------------------------------------------------------------------------- 
  22 //----------------------------------------------------------------------------- 
  24 IMPLEMENT_DYNAMIC_CLASS(wxGauge
, wxControl
) 
  26 bool wxGauge::Create( wxWindow 
*parent
, 
  32                       const wxValidator
& validator
, 
  33                       const wxString
& name 
) 
  37     if (!PreCreation( parent
, pos
, size 
) || 
  38         !CreateBase( parent
, id
, pos
, size
, style
, validator
, name 
)) 
  40         wxFAIL_MSG( wxT("wxGauge creation failed") ); 
  46     m_widget 
= gtk_progress_bar_new(); 
  47     if ( style 
& wxGA_VERTICAL 
) 
  49         gtk_progress_bar_set_orientation( GTK_PROGRESS_BAR(m_widget
), 
  50                                           GTK_PROGRESS_BOTTOM_TO_TOP 
); 
  53     m_parent
->DoAddChild( this ); 
  62 void wxGauge::DoSetGauge() 
  64     wxASSERT_MSG( 0 <= m_gaugePos 
&& m_gaugePos 
<= m_rangeMax
, 
  65                   _T("invalid gauge position in DoSetGauge()") ); 
  67     gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget
), 
  68                              m_rangeMax 
? ((float)m_gaugePos
)/m_rangeMax 
: 0.); 
  71 void wxGauge::SetRange( int range 
) 
  74     if (m_gaugePos 
> m_rangeMax
) 
  75         m_gaugePos 
= m_rangeMax
; 
  80 void wxGauge::SetValue( int pos 
) 
  82     wxCHECK_RET( pos 
<= m_rangeMax
, _T("invalid value in wxGauge::SetValue()") ); 
  89 int wxGauge::GetRange() const 
  94 int wxGauge::GetValue() const 
  99 void wxGauge::ApplyWidgetStyle() 
 102     gtk_widget_set_style( m_widget
, m_widgetStyle 
); 
 105 #endif // wxUSE_GAUGE