]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/NSTabView.mm
Reflect changes in stc.cpp in stc.cpp.in from which it's generated.
[wxWidgets.git] / src / cocoa / NSTabView.mm
CommitLineData
78480884 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/cocoa/NSTabView.mm
78480884
DE
3// Purpose: wxCocoaNSTabView
4// Author: David Elliott
5// Modified by:
6// Created: 2004/04/08
78480884 7// Copyright: (c) 2004 David Elliott
526954c5 8// Licence: wxWindows licence
78480884
DE
9/////////////////////////////////////////////////////////////////////////////
10
11#include "wx/wxprec.h"
12#ifndef WX_PRECOMP
13#endif // WX_PRECOMP
14
15#include "wx/cocoa/NSTabView.h"
16
e7e1ad7d
DE
17#include "wx/cocoa/objc/objc_uniquifying.h"
18
78480884
DE
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
e7e1ad7d 31WX_DECLARE_GET_OBJC_CLASS(wxNSTabViewDelegate,NSObject)
78480884
DE
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
e7e1ad7d 50WX_IMPLEMENT_GET_OBJC_CLASS(wxNSTabViewDelegate,NSObject)
78480884
DE
51
52// ============================================================================
53// class wxCocoaNSTabView
54// ============================================================================
55WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSTabView)
56
e7e1ad7d 57wxObjcAutoRefFromAlloc<struct objc_object*> wxCocoaNSTabView::sm_cocoaDelegate = [[WX_GET_OBJC_CLASS(wxNSTabViewDelegate) alloc] init];
78480884
DE
58
59void 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
68void wxCocoaNSTabView::DisassociateNSTabView(WX_NSTabView cocoaNSTabView)
69{
70 if(cocoaNSTabView)
71 {
72 [cocoaNSTabView setDelegate: nil];
73 sm_cocoaHash.erase(cocoaNSTabView);
74 }
75}
76