]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/spinbutt.mm
Fixed wxPropertyGridManager::CreatePropertyGrid(), corrected documentation about...
[wxWidgets.git] / src / osx / cocoa / spinbutt.mm
index 980fc81ddaf448e1ff1583635a68eda66a41db61..da57bbea789765a65db782a19cf1d07585621a23 100644 (file)
 
 @interface wxNSStepper : NSStepper
 {
-    wxWidgetCocoaImpl* impl;
+    WXCOCOAIMPL_COMMON_MEMBERS
+    int formerValue;
 }
 
-- (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation;
-- (wxWidgetCocoaImpl*) implementation;
-- (BOOL) isFlipped;
+WXCOCOAIMPL_COMMON_INTERFACE
+
  - (void) clickedAction: (id) sender;
 
 @end
@@ -34,6 +34,7 @@
 {
     [super initWithFrame:frame];
     impl = NULL;
+    formerValue = 0;
     [self setTarget: self];
     [self setAction: @selector(clickedAction:)];
     return self;
     {
         wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
         if ( wxpeer )
-            wxpeer->HandleClicked(0);
+        {
+            // because wx expects to be able to veto 
+            // a change we must revert the value change
+            // and expose it
+            int currentValue = [self intValue];
+            [self setIntValue:formerValue];
+            int inc = currentValue-formerValue;
+            
+            // adjust for wrap arounds
+            if ( inc > 1 )
+                inc = -1;
+            else if (inc < -1 )
+                inc = 1;
+                
+            if ( inc == 1 )
+                wxpeer->TriggerScrollEvent(wxEVT_SCROLL_LINEUP);
+            else if ( inc == -1 )
+                wxpeer->TriggerScrollEvent(wxEVT_SCROLL_LINEDOWN);
+
+            formerValue = [self intValue];
+        }
     }
 }
 
-- (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation
-{
-    impl = theImplementation;
-}
-
-- (wxWidgetCocoaImpl*) implementation
+-(void)mouseDown:(NSEvent *)event 
 {
-    return impl;
+    formerValue = [self intValue];
+    if ( !impl->DoHandleMouseEvent(event) )
+        [super mouseDown:event];
 }
 
-- (BOOL) isFlipped
-{
-    return YES;
-}
+WXCOCOAIMPL_COMMON_IMPLEMENTATION_NO_MOUSEDOWN
 
 @end