]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/gauge.mm
removing 10.4 code, adding webkit trick for showing dynamic tooltips
[wxWidgets.git] / src / osx / cocoa / gauge.mm
index 77189ce3d5fdb37096f8727c7b824be9ad1bd8e6..c9742ac478c389389444437a4b69eeb75054223f 100644 (file)
@@ -1,10 +1,10 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        gauge.mm
+// Name:        src/osx/cocoa/gauge.mm
 // Purpose:     wxGauge class
 // Author:      Stefan Csomor
 // Modified by:
 // Created:     1998-01-01
-// RCS-ID:      $Id: gauge.cpp 54820 2008-07-29 20:04:11Z SC $
+// RCS-ID:      $Id$
 // Copyright:   (c) Stefan Csomor
 // Licence:       wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 @interface wxNSProgressIndicator : NSProgressIndicator
 {
-    wxWidgetCocoaImpl* impl;
 }
 
-- (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation;
-- (wxWidgetImpl*) implementation;
-- (BOOL) isFlipped;
-
 @end
 
 @implementation wxNSProgressIndicator
 
-- (id)initWithFrame:(NSRect)frame
++ (void)initialize
 {
-    [super initWithFrame:frame];
-    impl = NULL;
-    return self;
+    static BOOL initialized = NO;
+    if (!initialized)
+    {
+        initialized = YES;
+        wxOSXCocoaClassAddWXMethods( self );
+    }
 }
 
-- (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation
-{
-    impl = theImplementation;
-}
+@end
 
-- (wxWidgetCocoaImpl*) implementation
-{
-    return impl;
-}
+@interface NSView(PossibleSizeMethods)
+- (NSControlSize)controlSize;
+@end
 
-- (BOOL) isFlipped
+namespace
 {
-    return YES;
-}
-
-@end
 
 class wxOSXGaugeCocoaImpl : public wxWidgetCocoaImpl
 {
@@ -60,19 +50,19 @@ public :
     wxOSXGaugeCocoaImpl( wxWindowMac* peer, WXWidget w) : wxWidgetCocoaImpl( peer, w )
     {
     }
-    
+
     void SetMaximum(wxInt32 v)
     {
         SetDeterminateMode();
         wxWidgetCocoaImpl::SetMaximum( v ) ;
     }
-    
+
     void SetValue(wxInt32 v)
     {
         SetDeterminateMode();
         wxWidgetCocoaImpl::SetValue( v ) ;
     }
-    
+
     void PulseGauge()
     {
         if ( ![(wxNSProgressIndicator*)m_osxView isIndeterminate] )
@@ -81,6 +71,27 @@ public :
             [(wxNSProgressIndicator*)m_osxView startAnimation:nil];
         }
     }
+
+    void GetLayoutInset(int &left , int &top , int &right, int &bottom) const
+    {
+        left = top = right = bottom = 0;
+        NSControlSize size = [(wxNSProgressIndicator*)m_osxView controlSize];
+
+        switch( size )
+        {
+            case NSRegularControlSize:
+                left = right = 2;
+                top = 0;
+                bottom = 4;
+                break;
+            case NSMiniControlSize:
+            case NSSmallControlSize:
+                left = right = 1;
+                top = 0;
+                bottom = 2;
+                break;
+        }
+    }
 protected:
     void SetDeterminateMode()
     {
@@ -92,18 +103,19 @@ protected:
         }
     }
 };
+    
+} // anonymous namespace
 
-
-wxWidgetImplType* wxWidgetImpl::CreateGauge( wxWindowMac* wxpeer, 
-                                    wxWindowMac* parent, 
-                                    wxWindowID id, 
+wxWidgetImplType* wxWidgetImpl::CreateGauge( wxWindowMac* wxpeer,
+                                    wxWindowMac* WXUNUSED(parent),
+                                    wxWindowID WXUNUSED(id),
                                     wxInt32 value,
                                     wxInt32 minimum,
                                     wxInt32 maximum,
-                                    const wxPoint& pos, 
+                                    const wxPoint& pos,
                                     const wxSize& size,
-                                    long style, 
-                                    long extraStyle)
+                                    long WXUNUSED(style),
+                                    long WXUNUSED(extraStyle))
 {
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSProgressIndicator* v = [[wxNSProgressIndicator alloc] initWithFrame:r];
@@ -113,7 +125,6 @@ wxWidgetImplType* wxWidgetImpl::CreateGauge( wxWindowMac* wxpeer,
     [v setIndeterminate:FALSE];
     [v setDoubleValue: (double) value];
     wxWidgetCocoaImpl* c = new wxOSXGaugeCocoaImpl( wxpeer, v );
-    [v setImplementation:c];
     return c;
 }