]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/NSTabView.mm
New eventb based Drag interface for wxDataViewCtrl
[wxWidgets.git] / src / cocoa / NSTabView.mm
CommitLineData
78480884
DE
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
065e208e 9// Licence: wxWidgets licence
78480884
DE
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13#ifndef WX_PRECOMP
14#endif // WX_PRECOMP
15
16#include "wx/cocoa/NSTabView.h"
17
e7e1ad7d
DE
18#include "wx/cocoa/objc/objc_uniquifying.h"
19
78480884
DE
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
e7e1ad7d 32WX_DECLARE_GET_OBJC_CLASS(wxNSTabViewDelegate,NSObject)
78480884
DE
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
e7e1ad7d 51WX_IMPLEMENT_GET_OBJC_CLASS(wxNSTabViewDelegate,NSObject)
78480884
DE
52
53// ============================================================================
54// class wxCocoaNSTabView
55// ============================================================================
56WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSTabView)
57
e7e1ad7d 58wxObjcAutoRefFromAlloc<struct objc_object*> wxCocoaNSTabView::sm_cocoaDelegate = [[WX_GET_OBJC_CLASS(wxNSTabViewDelegate) alloc] init];
78480884
DE
59
60void 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
69void wxCocoaNSTabView::DisassociateNSTabView(WX_NSTabView cocoaNSTabView)
70{
71 if(cocoaNSTabView)
72 {
73 [cocoaNSTabView setDelegate: nil];
74 sm_cocoaHash.erase(cocoaNSTabView);
75 }
76}
77