]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/NSTabView.mm
Fix scrolling bug where client size was reported wrong
[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
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// ============================================================================
52WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSTabView)
53
54wxObjcAutoRefFromAlloc<struct objc_object*> wxCocoaNSTabView::sm_cocoaDelegate = [[wxNSTabViewDelegate alloc] init];
55
56void 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
65void wxCocoaNSTabView::DisassociateNSTabView(WX_NSTabView cocoaNSTabView)
66{
67 if(cocoaNSTabView)
68 {
69 [cocoaNSTabView setDelegate: nil];
70 sm_cocoaHash.erase(cocoaNSTabView);
71 }
72}
73