1 /////////////////////////////////////////////////////////////////////////////
 
   2 // Name:        src/osx/cocoa/gauge.mm
 
   3 // Purpose:     wxGauge class
 
   4 // Author:      Stefan Csomor
 
   8 // Copyright:   (c) Stefan Csomor
 
   9 // Licence:       wxWindows licence
 
  10 /////////////////////////////////////////////////////////////////////////////
 
  12 #include "wx/wxprec.h"
 
  18 #include "wx/osx/private.h"
 
  20 @interface wxNSProgressIndicator : NSProgressIndicator
 
  26 @implementation wxNSProgressIndicator
 
  30     static BOOL initialized = NO;
 
  34         wxOSXCocoaClassAddWXMethods( self );
 
  40 @interface NSView(PossibleSizeMethods)
 
  41 - (NSControlSize)controlSize;
 
  47 class wxOSXGaugeCocoaImpl : public wxWidgetCocoaImpl
 
  50     wxOSXGaugeCocoaImpl( wxWindowMac* peer, WXWidget w) : wxWidgetCocoaImpl( peer, w )
 
  54     void SetMaximum(wxInt32 v)
 
  57         wxWidgetCocoaImpl::SetMaximum( v ) ;
 
  60     void SetValue(wxInt32 v)
 
  63         wxWidgetCocoaImpl::SetValue( v ) ;
 
  68         if ( ![(wxNSProgressIndicator*)m_osxView isIndeterminate] )
 
  70             [(wxNSProgressIndicator*)m_osxView setIndeterminate:YES];
 
  71             [(wxNSProgressIndicator*)m_osxView startAnimation:nil];
 
  75     void GetLayoutInset(int &left , int &top , int &right, int &bottom) const
 
  77         left = top = right = bottom = 0;
 
  78         NSControlSize size = [(wxNSProgressIndicator*)m_osxView controlSize];
 
  82             case NSRegularControlSize:
 
  87             case NSMiniControlSize:
 
  88             case NSSmallControlSize:
 
  96     void SetDeterminateMode()
 
  98        // switch back to determinate mode if necessary
 
  99         if ( [(wxNSProgressIndicator*)m_osxView isIndeterminate]  )
 
 101             [(wxNSProgressIndicator*)m_osxView stopAnimation:nil];
 
 102             [(wxNSProgressIndicator*)m_osxView setIndeterminate:NO];
 
 107 } // anonymous namespace
 
 109 wxWidgetImplType* wxWidgetImpl::CreateGauge( wxWindowMac* wxpeer,
 
 110                                     wxWindowMac* WXUNUSED(parent),
 
 111                                     wxWindowID WXUNUSED(id),
 
 117                                     long WXUNUSED(style),
 
 118                                     long WXUNUSED(extraStyle))
 
 120     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
 
 121     wxNSProgressIndicator* v = [[wxNSProgressIndicator alloc] initWithFrame:r];
 
 123     [v setMinValue: minimum];
 
 124     [v setMaxValue: maximum];
 
 125     [v setIndeterminate:FALSE];
 
 126     [v setDoubleValue: (double) value];
 
 127     wxWidgetCocoaImpl* c = new wxOSXGaugeCocoaImpl( wxpeer, v );
 
 131 #endif // wxUSE_GAUGE