| 1 | ///////////////////////////////////////////////////////////////////////////// |
| 2 | // Name: src/cocoa/NSScroller.mm |
| 3 | // Purpose: wxCocoaNSScroller |
| 4 | // Author: David Elliott |
| 5 | // Modified by: |
| 6 | // Created: 2004/04/27 |
| 7 | // RCS-ID: $Id$ |
| 8 | // Copyright: (c) 2004 David Elliott |
| 9 | // Licence: wxWindows licence |
| 10 | ///////////////////////////////////////////////////////////////////////////// |
| 11 | |
| 12 | #include "wx/wxprec.h" |
| 13 | #ifndef WX_PRECOMP |
| 14 | #include "wx/log.h" |
| 15 | #endif // WX_PRECOMP |
| 16 | |
| 17 | #include "wx/cocoa/objc/objc_uniquifying.h" |
| 18 | |
| 19 | #include "wx/cocoa/NSScroller.h" |
| 20 | #import <AppKit/NSScroller.h> |
| 21 | |
| 22 | WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSScroller) |
| 23 | |
| 24 | // ============================================================================ |
| 25 | // @class wxNSScrollerTarget |
| 26 | // ============================================================================ |
| 27 | @interface wxNSScrollerTarget : NSObject |
| 28 | { |
| 29 | } |
| 30 | |
| 31 | - (void)wxNSScrollerAction: (id)sender; |
| 32 | @end // wxNSScrollerTarget |
| 33 | WX_DECLARE_GET_OBJC_CLASS(wxNSScrollerTarget,NSObject) |
| 34 | |
| 35 | @implementation wxNSScrollerTarget : NSObject |
| 36 | - (void)wxNSScrollerAction: (id)sender |
| 37 | { |
| 38 | wxCocoaNSScroller *scroller = wxCocoaNSScroller::GetFromCocoa(sender); |
| 39 | wxCHECK_RET(scroller,wxT("wxNSScrollerAction received without associated wx object")); |
| 40 | scroller->Cocoa_wxNSScrollerAction(); |
| 41 | } |
| 42 | |
| 43 | @end // implementation wxNSScrollerTarget |
| 44 | WX_IMPLEMENT_GET_OBJC_CLASS(wxNSScrollerTarget,NSObject) |
| 45 | |
| 46 | // ============================================================================ |
| 47 | // class wxCocoaNSScroller |
| 48 | // ============================================================================ |
| 49 | const wxObjcAutoRefFromAlloc<struct objc_object*> wxCocoaNSScroller::sm_cocoaTarget = [[WX_GET_OBJC_CLASS(wxNSScrollerTarget) alloc] init]; |
| 50 | |
| 51 | void wxCocoaNSScroller::AssociateNSScroller(WX_NSScroller cocoaNSScroller) |
| 52 | { |
| 53 | if(cocoaNSScroller) |
| 54 | { |
| 55 | sm_cocoaHash.insert(wxCocoaNSScrollerHash::value_type(cocoaNSScroller,this)); |
| 56 | [cocoaNSScroller setTarget: sm_cocoaTarget]; |
| 57 | [cocoaNSScroller setAction: @selector(wxNSScrollerAction:)]; |
| 58 | } |
| 59 | } |
| 60 | |