]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/NSTabView.mm
Replace deprecated wxNB_* flags with wxBK_* used in last commit.
[wxWidgets.git] / src / cocoa / NSTabView.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cocoa/NSTabView.mm
3 // Purpose: wxCocoaNSTabView
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2004/04/08
7 // RCS-ID: $Id$
8 // Copyright: (c) 2004 David Elliott
9 // Licence: wxWidgets licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13 #ifndef WX_PRECOMP
14 #endif // WX_PRECOMP
15
16 #include "wx/cocoa/NSTabView.h"
17
18 #include <AppKit/NSTabView.h>
19
20 // ============================================================================
21 // @class wxNSTabViewDelegate
22 // ============================================================================
23 @interface wxNSTabViewDelegate : NSObject
24 {
25 }
26
27 - (void)tabView:(NSTabView*)tabView didSelectTabViewItem:(NSTabViewItem*)tabViewItem;
28 - (BOOL)tabView:(NSTabView*)tabView shouldSelectTabViewItem:(NSTabViewItem*)tabViewItem;
29 @end // interface wxNSTabViewDelegate : NSObject
30
31 @implementation wxNSTabViewDelegate : NSObject
32 - (void)tabView:(NSTabView*)tabView didSelectTabViewItem:(NSTabViewItem*)tabViewItem
33 {
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);
37
38 }
39
40 - (BOOL)tabView:(NSTabView*)tabView shouldSelectTabViewItem:(NSTabViewItem*)tabViewItem
41 {
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);
45 }
46
47 @end // implementation wxNSTabViewDelegate : NSObject
48
49 // ============================================================================
50 // class wxCocoaNSTabView
51 // ============================================================================
52 WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSTabView)
53
54 wxObjcAutoRefFromAlloc<struct objc_object*> wxCocoaNSTabView::sm_cocoaDelegate = [[wxNSTabViewDelegate alloc] init];
55
56 void wxCocoaNSTabView::AssociateNSTabView(WX_NSTabView cocoaNSTabView)
57 {
58 if(cocoaNSTabView)
59 {
60 sm_cocoaHash.insert(wxCocoaNSTabViewHash::value_type(cocoaNSTabView,this));
61 [cocoaNSTabView setDelegate: sm_cocoaDelegate];
62 }
63 }
64
65 void wxCocoaNSTabView::DisassociateNSTabView(WX_NSTabView cocoaNSTabView)
66 {
67 if(cocoaNSTabView)
68 {
69 [cocoaNSTabView setDelegate: nil];
70 sm_cocoaHash.erase(cocoaNSTabView);
71 }
72 }
73