1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cocoa/NSTabView.mm
3 // Purpose: wxCocoaNSTabView
4 // Author: David Elliott
8 // Copyright: (c) 2004 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
16 #include "wx/cocoa/NSTabView.h"
18 #include "wx/cocoa/objc/objc_uniquifying.h"
20 #include <AppKit/NSTabView.h>
22 // ============================================================================
23 // @class wxNSTabViewDelegate
24 // ============================================================================
25 @interface wxNSTabViewDelegate : NSObject
29 - (void)tabView:(NSTabView*)tabView didSelectTabViewItem:(NSTabViewItem*)tabViewItem;
30 - (BOOL)tabView:(NSTabView*)tabView shouldSelectTabViewItem:(NSTabViewItem*)tabViewItem;
31 @end // interface wxNSTabViewDelegate : NSObject
32 WX_DECLARE_GET_OBJC_CLASS(wxNSTabViewDelegate,NSObject)
34 @implementation wxNSTabViewDelegate : NSObject
35 - (void)tabView:(NSTabView*)tabView didSelectTabViewItem:(NSTabViewItem*)tabViewItem
37 wxCocoaNSTabView *notebook = wxCocoaNSTabView::GetFromCocoa(tabView);
38 wxCHECK_RET(notebook, wxT("This delegate is for use only with wxCocoa NSTabViews"));
39 notebook->CocoaDelegate_tabView_didSelectTabViewItem(tabViewItem);
43 - (BOOL)tabView:(NSTabView*)tabView shouldSelectTabViewItem:(NSTabViewItem*)tabViewItem
45 wxCocoaNSTabView *notebook = wxCocoaNSTabView::GetFromCocoa(tabView);
46 wxCHECK_MSG(notebook, true, wxT("This delegate is for use only with wxCocoa NSTabViews"));
47 return notebook->CocoaDelegate_tabView_shouldSelectTabViewItem(tabViewItem);
50 @end // implementation wxNSTabViewDelegate : NSObject
51 WX_IMPLEMENT_GET_OBJC_CLASS(wxNSTabViewDelegate,NSObject)
53 // ============================================================================
54 // class wxCocoaNSTabView
55 // ============================================================================
56 WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSTabView)
58 wxObjcAutoRefFromAlloc<struct objc_object*> wxCocoaNSTabView::sm_cocoaDelegate = [[WX_GET_OBJC_CLASS(wxNSTabViewDelegate) alloc] init];
60 void wxCocoaNSTabView::AssociateNSTabView(WX_NSTabView cocoaNSTabView)
64 sm_cocoaHash.insert(wxCocoaNSTabViewHash::value_type(cocoaNSTabView,this));
65 [cocoaNSTabView setDelegate: sm_cocoaDelegate];
69 void wxCocoaNSTabView::DisassociateNSTabView(WX_NSTabView cocoaNSTabView)
73 [cocoaNSTabView setDelegate: nil];
74 sm_cocoaHash.erase(cocoaNSTabView);