1 /////////////////////////////////////////////////////////////////////////////
 
   2 // Name:        src/osx/cocoa/gauge.mm
 
   3 // Purpose:     wxGauge class
 
   4 // Author:      Stefan Csomor
 
   7 // Copyright:   (c) Stefan Csomor
 
   8 // Licence:       wxWindows licence
 
   9 /////////////////////////////////////////////////////////////////////////////
 
  11 #include "wx/wxprec.h"
 
  17 #include "wx/osx/private.h"
 
  19 @interface wxNSProgressIndicator : NSProgressIndicator
 
  25 @implementation wxNSProgressIndicator
 
  29     static BOOL initialized = NO;
 
  33         wxOSXCocoaClassAddWXMethods( self );
 
  39 @interface NSView(PossibleSizeMethods)
 
  40 - (NSControlSize)controlSize;
 
  46 class wxOSXGaugeCocoaImpl : public wxWidgetCocoaImpl
 
  49     wxOSXGaugeCocoaImpl( wxWindowMac* peer, WXWidget w) : wxWidgetCocoaImpl( peer, w )
 
  53     void SetMaximum(wxInt32 v)
 
  56         wxWidgetCocoaImpl::SetMaximum( v ) ;
 
  59     void SetValue(wxInt32 v)
 
  62         wxWidgetCocoaImpl::SetValue( v ) ;
 
  67         if ( ![(wxNSProgressIndicator*)m_osxView isIndeterminate] )
 
  69             [(wxNSProgressIndicator*)m_osxView setIndeterminate:YES];
 
  70             [(wxNSProgressIndicator*)m_osxView startAnimation:nil];
 
  74     void GetLayoutInset(int &left , int &top , int &right, int &bottom) const
 
  76         left = top = right = bottom = 0;
 
  77         NSControlSize size = [(wxNSProgressIndicator*)m_osxView controlSize];
 
  81             case NSRegularControlSize:
 
  86             case NSMiniControlSize:
 
  87             case NSSmallControlSize:
 
  95     void SetDeterminateMode()
 
  97        // switch back to determinate mode if necessary
 
  98         if ( [(wxNSProgressIndicator*)m_osxView isIndeterminate]  )
 
 100             [(wxNSProgressIndicator*)m_osxView stopAnimation:nil];
 
 101             [(wxNSProgressIndicator*)m_osxView setIndeterminate:NO];
 
 106 } // anonymous namespace
 
 108 wxWidgetImplType* wxWidgetImpl::CreateGauge( wxWindowMac* wxpeer,
 
 109                                     wxWindowMac* WXUNUSED(parent),
 
 110                                     wxWindowID WXUNUSED(id),
 
 116                                     long WXUNUSED(style),
 
 117                                     long WXUNUSED(extraStyle))
 
 119     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
 
 120     wxNSProgressIndicator* v = [[wxNSProgressIndicator alloc] initWithFrame:r];
 
 122     [v setMinValue: minimum];
 
 123     [v setMaxValue: maximum];
 
 124     [v setIndeterminate:FALSE];
 
 125     [v setDoubleValue: (double) value];
 
 126     wxWidgetCocoaImpl* c = new wxOSXGaugeCocoaImpl( wxpeer, v );
 
 130 #endif // wxUSE_GAUGE