]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/NSTabView.mm
first attempt at adding the minimal set needed for dead-key support, see #15345
[wxWidgets.git] / src / cocoa / NSTabView.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/cocoa/NSTabView.mm
3 // Purpose: wxCocoaNSTabView
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2004/04/08
7 // Copyright: (c) 2004 David Elliott
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #include "wx/wxprec.h"
12 #ifndef WX_PRECOMP
13 #endif // WX_PRECOMP
14
15 #include "wx/cocoa/NSTabView.h"
16
17 #include "wx/cocoa/objc/objc_uniquifying.h"
18
19 #include <AppKit/NSTabView.h>
20
21 // ============================================================================
22 // @class wxNSTabViewDelegate
23 // ============================================================================
24 @interface wxNSTabViewDelegate : NSObject
25 {
26 }
27
28 - (void)tabView:(NSTabView*)tabView didSelectTabViewItem:(NSTabViewItem*)tabViewItem;
29 - (BOOL)tabView:(NSTabView*)tabView shouldSelectTabViewItem:(NSTabViewItem*)tabViewItem;
30 @end // interface wxNSTabViewDelegate : NSObject
31 WX_DECLARE_GET_OBJC_CLASS(wxNSTabViewDelegate,NSObject)
32
33 @implementation wxNSTabViewDelegate : NSObject
34 - (void)tabView:(NSTabView*)tabView didSelectTabViewItem:(NSTabViewItem*)tabViewItem
35 {
36 wxCocoaNSTabView *notebook = wxCocoaNSTabView::GetFromCocoa(tabView);
37 wxCHECK_RET(notebook, wxT("This delegate is for use only with wxCocoa NSTabViews"));
38 notebook->CocoaDelegate_tabView_didSelectTabViewItem(tabViewItem);
39
40 }
41
42 - (BOOL)tabView:(NSTabView*)tabView shouldSelectTabViewItem:(NSTabViewItem*)tabViewItem
43 {
44 wxCocoaNSTabView *notebook = wxCocoaNSTabView::GetFromCocoa(tabView);
45 wxCHECK_MSG(notebook, true, wxT("This delegate is for use only with wxCocoa NSTabViews"));
46 return notebook->CocoaDelegate_tabView_shouldSelectTabViewItem(tabViewItem);
47 }
48
49 @end // implementation wxNSTabViewDelegate : NSObject
50 WX_IMPLEMENT_GET_OBJC_CLASS(wxNSTabViewDelegate,NSObject)
51
52 // ============================================================================
53 // class wxCocoaNSTabView
54 // ============================================================================
55 WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSTabView)
56
57 wxObjcAutoRefFromAlloc<struct objc_object*> wxCocoaNSTabView::sm_cocoaDelegate = [[WX_GET_OBJC_CLASS(wxNSTabViewDelegate) alloc] init];
58
59 void wxCocoaNSTabView::AssociateNSTabView(WX_NSTabView cocoaNSTabView)
60 {
61 if(cocoaNSTabView)
62 {
63 sm_cocoaHash.insert(wxCocoaNSTabViewHash::value_type(cocoaNSTabView,this));
64 [cocoaNSTabView setDelegate: sm_cocoaDelegate];
65 }
66 }
67
68 void wxCocoaNSTabView::DisassociateNSTabView(WX_NSTabView cocoaNSTabView)
69 {
70 if(cocoaNSTabView)
71 {
72 [cocoaNSTabView setDelegate: nil];
73 sm_cocoaHash.erase(cocoaNSTabView);
74 }
75 }
76