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 <AppKit/NSTabView.h>
20 // ============================================================================
21 // @class wxNSTabViewDelegate
22 // ============================================================================
23 @interface wxNSTabViewDelegate : NSObject
27 - (void)tabView:(NSTabView*)tabView didSelectTabViewItem:(NSTabViewItem*)tabViewItem;
28 - (BOOL)tabView:(NSTabView*)tabView shouldSelectTabViewItem:(NSTabViewItem*)tabViewItem;
29 @end // interface wxNSTabViewDelegate : NSObject
31 @implementation wxNSTabViewDelegate : NSObject
32 - (void)tabView:(NSTabView*)tabView didSelectTabViewItem:(NSTabViewItem*)tabViewItem
34 wxCocoaNSTabView *notebook = wxCocoaNSTabView::GetFromCocoa(tabView);
35 wxCHECK_RET(notebook, wxT("This delegate is for use only with wxCocoa NSTabViews"));
36 notebook->CocoaDelegate_tabView_didSelectTabViewItem(tabViewItem);
40 - (BOOL)tabView:(NSTabView*)tabView shouldSelectTabViewItem:(NSTabViewItem*)tabViewItem
42 wxCocoaNSTabView *notebook = wxCocoaNSTabView::GetFromCocoa(tabView);
43 wxCHECK_MSG(notebook, true, wxT("This delegate is for use only with wxCocoa NSTabViews"));
44 return notebook->CocoaDelegate_tabView_shouldSelectTabViewItem(tabViewItem);
47 @end // implementation wxNSTabViewDelegate : NSObject
49 // ============================================================================
50 // class wxCocoaNSTabView
51 // ============================================================================
52 WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSTabView)
54 wxObjcAutoRefFromAlloc<struct objc_object*> wxCocoaNSTabView::sm_cocoaDelegate = [[wxNSTabViewDelegate alloc] init];
56 void wxCocoaNSTabView::AssociateNSTabView(WX_NSTabView cocoaNSTabView)
60 sm_cocoaHash.insert(wxCocoaNSTabViewHash::value_type(cocoaNSTabView,this));
61 [cocoaNSTabView setDelegate: sm_cocoaDelegate];
65 void wxCocoaNSTabView::DisassociateNSTabView(WX_NSTabView cocoaNSTabView)
69 [cocoaNSTabView setDelegate: nil];
70 sm_cocoaHash.erase(cocoaNSTabView);