X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b466e85a7e81db84545bc44c83cbe4ccacd4fe8e..7e4952db837344e369ff9ccc7ece1f7b8c207cf1:/src/osx/cocoa/slider.mm diff --git a/src/osx/cocoa/slider.mm b/src/osx/cocoa/slider.mm index a56acbeadd..6e31a40e43 100644 --- a/src/osx/cocoa/slider.mm +++ b/src/osx/cocoa/slider.mm @@ -18,39 +18,65 @@ @interface wxNSSlider : NSSlider { - WXCOCOAIMPL_COMMON_MEMBERS } +@end -WXCOCOAIMPL_COMMON_INTERFACE +@implementation wxNSSlider - - (void) clickedAction: (id) sender; ++ (void)initialize +{ + static BOOL initialized = NO; + if (!initialized) + { + initialized = YES; + wxOSXCocoaClassAddWXMethods(self); + } +} @end -@implementation wxNSSlider +class wxSliderCocoaImpl : public wxWidgetCocoaImpl +{ +public : + wxSliderCocoaImpl(wxWindowMac* peer , WXWidget w) : + wxWidgetCocoaImpl(peer, w) + { + } + + ~wxSliderCocoaImpl() + { + } -- (id)initWithFrame:(NSRect)frame + 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 +// returns we will call the thumbrelease + +void wxSliderCocoaImpl::controlAction( WXWidget slf, void *_cmd, void *sender) { - [super initWithFrame:frame]; - impl = NULL; - [self setTarget: self]; - [self setAction: @selector(clickedAction:)]; - return self; + wxWindow* wxpeer = (wxWindow*) GetWXPeer(); + if ( wxpeer ) + wxpeer->TriggerScrollEvent(wxEVT_SCROLL_THUMBTRACK); } -- (void) clickedAction: (id) sender +void wxSliderCocoaImpl::mouseEvent(WX_NSEvent event, WXWidget slf, void *_cmd) { - if ( impl ) + wxWidgetCocoaImpl::mouseEvent(event, slf, _cmd); + + 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); } } -WXCOCOAIMPL_COMMON_IMPLEMENTATION -@end wxWidgetImplType* wxWidgetImpl::CreateSlider( wxWindowMac* wxpeer, wxWindowMac* parent, @@ -83,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; }