X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/19c7ac3d3bf1ac2113505a805a79c40ce3db1f5b..8383e673b1d839548b7336947a61fa699eeb6621:/src/osx/cocoa/slider.mm diff --git a/src/osx/cocoa/slider.mm b/src/osx/cocoa/slider.mm index 2316dece5d..fbde6dc22a 100644 --- a/src/osx/cocoa/slider.mm +++ b/src/osx/cocoa/slider.mm @@ -18,69 +18,76 @@ @interface wxNSSlider : NSSlider { - WXCOCOAIMPL_COMMON_MEMBERS } - -WXCOCOAIMPL_COMMON_INTERFACE - - - (void) clickedAction: (id) sender; - @end @implementation wxNSSlider -- (id)initWithFrame:(NSRect)frame ++ (void)initialize { - [super initWithFrame:frame]; - impl = NULL; - [self setTarget: self]; - [self setAction: @selector(clickedAction:)]; - return self; + static BOOL initialized = NO; + if (!initialized) + { + initialized = YES; + wxOSXCocoaClassAddWXMethods(self); + } } -WXCOCOAIMPL_COMMON_IMPLEMENTATION_NO_MOUSEDOWN +@end + +class wxSliderCocoaImpl : public wxWidgetCocoaImpl +{ +public : + wxSliderCocoaImpl(wxWindowMac* peer , WXWidget w) : + wxWidgetCocoaImpl(peer, w) + { + } + + ~wxSliderCocoaImpl() + { + } -// we will have a mouseDown, then in the native + virtual void controlAction(WXWidget slf, void* _cmd, void *sender); + virtual void mouseEvent(WX_NSEvent event, WXWidget slf, void* _cmd); +}; + +// we will have a mouseDown, then in the native // implementation of mouseDown the tracking code // is calling clickedAction, therefore we wire this -// to thumbtrack and only after super mouseDown +// to thumbtrack and only after super mouseDown // returns we will call the thumbrelease -- (void) clickedAction: (id) sender +void wxSliderCocoaImpl::controlAction( WXWidget WXUNUSED(slf), void *WXUNUSED(_cmd), void *WXUNUSED(sender)) { - if ( impl ) - { - wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer(); - if ( wxpeer ) - wxpeer->TriggerScrollEvent(wxEVT_SCROLL_THUMBTRACK); - } + wxWindow* wxpeer = (wxWindow*) GetWXPeer(); + if ( wxpeer ) + wxpeer->TriggerScrollEvent(wxEVT_SCROLL_THUMBTRACK); } --(void)mouseDown:(NSEvent *)event +void wxSliderCocoaImpl::mouseEvent(WX_NSEvent event, WXWidget slf, void *_cmd) { - if ( !impl->DoHandleMouseEvent(event) ) - [super mouseDown:event]; + wxWidgetCocoaImpl::mouseEvent(event, slf, _cmd); - if ( impl ) + if ( strcmp( sel_getName((SEL) _cmd) , "mouseDown:") == 0 ) { - wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer(); + wxWindow* wxpeer = (wxWindow*) GetWXPeer(); if ( wxpeer ) - wxpeer->HandleClicked(0); + wxpeer->OSXHandleClicked(0); } } -@end -wxWidgetImplType* wxWidgetImpl::CreateSlider( wxWindowMac* wxpeer, - wxWindowMac* parent, - wxWindowID id, + +wxWidgetImplType* wxWidgetImpl::CreateSlider( 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 style, + long WXUNUSED(extraStyle)) { NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ; wxNSSlider* v = [[wxNSSlider alloc] initWithFrame:r]; @@ -94,7 +101,7 @@ wxWidgetImplType* wxWidgetImpl::CreateSlider( wxWindowMac* wxpeer, // it to a UInt16 while (tickMarks > 20) tickMarks /= 5; - + [v setNumberOfTickMarks:tickMarks]; [v setTickMarkPosition:NSTickMarkBelow]; } @@ -102,8 +109,7 @@ wxWidgetImplType* wxWidgetImpl::CreateSlider( wxWindowMac* wxpeer, [v setMinValue: minimum]; [v setMaxValue: maximum]; [v setFloatValue: (double) value]; - wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v ); - [v setImplementation:c]; + wxWidgetCocoaImpl* c = new wxSliderCocoaImpl( wxpeer, v ); return c; }