From: David Elliott Date: Fri, 10 Aug 2007 20:28:07 +0000 (+0000) Subject: Don't needlessly indirect through NSNotificationCenter. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/72ee73c1968745451f136f3d88d954aee86c4b38 Don't needlessly indirect through NSNotificationCenter. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48017 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/cocoa/NSSlider.mm b/src/cocoa/NSSlider.mm index 5ea545ba4c..5e352332d7 100644 --- a/src/cocoa/NSSlider.mm +++ b/src/cocoa/NSSlider.mm @@ -240,64 +240,36 @@ WX_IMPLEMENT_GET_OBJC_CLASS(WXNSSlider,NSSlider) - (BOOL)startTrackingAt:(NSPoint)startPoint inView:(NSView *)controlView { BOOL result = [super startTrackingAt:startPoint inView:controlView]; - [[NSNotificationCenter defaultCenter] postNotificationName:kwxNSSliderStartTracking object:controlView]; + + wxCocoaNSSlider *slider = wxCocoaNSSlider::GetFromCocoa(controlView); + if(slider) + slider->CocoaNotification_startTracking(NULL); + return result; } - (BOOL)continueTracking:(NSPoint)lastPoint at:(NSPoint)currentPoint inView:(NSView *)controlView { BOOL result = [super continueTracking:lastPoint at:currentPoint inView:controlView]; - [[NSNotificationCenter defaultCenter] postNotificationName:kwxNSSliderContinueTracking object:controlView]; + + wxCocoaNSSlider *slider = wxCocoaNSSlider::GetFromCocoa(controlView); + if(slider) + slider->CocoaNotification_continueTracking(NULL); + return result; } - (void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint inView:(NSView *)controlView mouseIsUp:(BOOL)flag { [super stopTracking:lastPoint at:stopPoint inView:controlView mouseIsUp:flag]; - [[NSNotificationCenter defaultCenter] postNotificationName:kwxNSSliderStopTracking object:controlView]; + + wxCocoaNSSlider *slider = wxCocoaNSSlider::GetFromCocoa(controlView); + if(slider) + slider->CocoaNotification_stopTracking(NULL); } @end WX_IMPLEMENT_GET_OBJC_CLASS(WXNSSliderCell,NSSliderCell) -// ============================================================================ -// @class wxNSSliderNotificationObserver -// ============================================================================ -@interface wxNSSliderNotificationObserver : NSObject -{ -} - -struct objc_object *wxCocoaNSSlider::sm_cocoaObserver = [[wxNSSliderNotificationObserver alloc] init]; - -- (void)startTracking: (NSNotification *)notification; -- (void)continueTracking: (NSNotification *)notification; -- (void)stopTracking: (NSNotification *)notification; -@end // interface wxNSSliderNotificationObserver - -@implementation wxNSSliderNotificationObserver : NSObject - -- (void)startTracking: (NSNotification *)notification; -{ - wxCocoaNSSlider *slider = wxCocoaNSSlider::GetFromCocoa([notification object]); - wxCHECK_RET(slider,wxT("startTracking received but no wxSlider exists")); - slider->CocoaNotification_startTracking(notification); -} - -- (void)continueTracking: (NSNotification *)notification; -{ - wxCocoaNSSlider *slider = wxCocoaNSSlider::GetFromCocoa([notification object]); - wxCHECK_RET(slider,wxT("continueTracking received but no wxSlider exists")); - slider->CocoaNotification_continueTracking(notification); -} - -- (void)stopTracking: (NSNotification *)notification; -{ - wxCocoaNSSlider *slider = wxCocoaNSSlider::GetFromCocoa([notification object]); - wxCHECK_RET(slider,wxT("stopTracking received but no wxSlider exists")); - slider->CocoaNotification_stopTracking(notification); -} - -@end // implementation wxNSSliderNotificationObserver - // ============================================================================ // class wxCocoaNSSlider // ============================================================================ @@ -309,9 +281,6 @@ void wxCocoaNSSlider::AssociateNSSlider(WX_NSSlider cocoaNSSlider) if(cocoaNSSlider) { sm_cocoaHash.insert(wxCocoaNSSliderHash::value_type(cocoaNSSlider,this)); - [[NSNotificationCenter defaultCenter] addObserver:(id)sm_cocoaObserver selector:@selector(startTracking:) name:kwxNSSliderStartTracking object:cocoaNSSlider]; - [[NSNotificationCenter defaultCenter] addObserver:(id)sm_cocoaObserver selector:@selector(continueTracking:) name:kwxNSSliderContinueTracking object:cocoaNSSlider]; - [[NSNotificationCenter defaultCenter] addObserver:(id)sm_cocoaObserver selector:@selector(stopTracking:) name:kwxNSSliderStopTracking object:cocoaNSSlider]; [cocoaNSSlider setTarget:sm_cocoaTarget]; } } @@ -321,8 +290,5 @@ void wxCocoaNSSlider::DisassociateNSSlider(WX_NSSlider cocoaNSSlider) if(cocoaNSSlider) { sm_cocoaHash.erase(cocoaNSSlider); - [[NSNotificationCenter defaultCenter] removeObserver:(id)sm_cocoaObserver name:kwxNSSliderStartTracking object:cocoaNSSlider]; - [[NSNotificationCenter defaultCenter] removeObserver:(id)sm_cocoaObserver name:kwxNSSliderContinueTracking object:cocoaNSSlider]; - [[NSNotificationCenter defaultCenter] removeObserver:(id)sm_cocoaObserver name:kwxNSSliderStopTracking object:cocoaNSSlider]; } }