]>
Commit | Line | Data |
---|---|---|
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 "wx/cocoa/objc/objc_uniquifying.h" | |
19 | ||
20 | #include <AppKit/NSTabView.h> | |
21 | ||
22 | // ============================================================================ | |
23 | // @class wxNSTabViewDelegate | |
24 | // ============================================================================ | |
25 | @interface wxNSTabViewDelegate : NSObject | |
26 | { | |
27 | } | |
28 | ||
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) | |
33 | ||
34 | @implementation wxNSTabViewDelegate : NSObject | |
35 | - (void)tabView:(NSTabView*)tabView didSelectTabViewItem:(NSTabViewItem*)tabViewItem | |
36 | { | |
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); | |
40 | ||
41 | } | |
42 | ||
43 | - (BOOL)tabView:(NSTabView*)tabView shouldSelectTabViewItem:(NSTabViewItem*)tabViewItem | |
44 | { | |
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); | |
48 | } | |
49 | ||
50 | @end // implementation wxNSTabViewDelegate : NSObject | |
51 | WX_IMPLEMENT_GET_OBJC_CLASS(wxNSTabViewDelegate,NSObject) | |
52 | ||
53 | // ============================================================================ | |
54 | // class wxCocoaNSTabView | |
55 | // ============================================================================ | |
56 | WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSTabView) | |
57 | ||
58 | wxObjcAutoRefFromAlloc<struct objc_object*> wxCocoaNSTabView::sm_cocoaDelegate = [[WX_GET_OBJC_CLASS(wxNSTabViewDelegate) alloc] init]; | |
59 | ||
60 | void wxCocoaNSTabView::AssociateNSTabView(WX_NSTabView cocoaNSTabView) | |
61 | { | |
62 | if(cocoaNSTabView) | |
63 | { | |
64 | sm_cocoaHash.insert(wxCocoaNSTabViewHash::value_type(cocoaNSTabView,this)); | |
65 | [cocoaNSTabView setDelegate: sm_cocoaDelegate]; | |
66 | } | |
67 | } | |
68 | ||
69 | void wxCocoaNSTabView::DisassociateNSTabView(WX_NSTabView cocoaNSTabView) | |
70 | { | |
71 | if(cocoaNSTabView) | |
72 | { | |
73 | [cocoaNSTabView setDelegate: nil]; | |
74 | sm_cocoaHash.erase(cocoaNSTabView); | |
75 | } | |
76 | } | |
77 |