/
PSMTabBarControl.h
130 lines (108 loc) · 3.95 KB
/
PSMTabBarControl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//
// PSMTabBarControl.h
// PSMTabBarControl
//
// Created by John Pannell on 10/13/05.
// Copyright 2005 Positive Spin Media. All rights reserved.
//
// Hacked by Martin Hedenfalk on 2008-11-30.
//
/*
This view provides a control interface to manage a regular NSTabView.
It looks and works like the tabbed browsing interface of many popular
browsers.
*/
#import <Cocoa/Cocoa.h>
#define kPSMTabBarControlHeight 22
// internal cell border
#define MARGIN_X 6
#define MARGIN_Y 3
// padding between objects
#define kPSMTabBarCellPadding 4
// fixed size objects
#define kPSMMinimumTitleWidth 30
#define kPSMTabBarIndicatorWidth 16.0
#define kPSMTabBarIconWidth 16.0
#define kPSMHideAnimationSteps 2.0
#import "PSMOverflowPopUpButton.h"
#import "PSMRolloverButton.h"
@class PSMOverflowPopUpButton;
@class PSMRolloverButton;
@class PSMTabBarCell;
@protocol PSMTabStyle;
enum {
PSMTab_SelectedMask = 1 << 1,
PSMTab_LeftIsSelectedMask = 1 << 2,
PSMTab_RightIsSelectedMask = 1 << 3,
PSMTab_PositionLeftMask = 1 << 4,
PSMTab_PositionMiddleMask = 1 << 5,
PSMTab_PositionRightMask = 1 << 6,
PSMTab_PositionSingleMask = 1 << 7
};
@interface PSMTabBarControl : NSControl {
// control basics
NSMutableArray *_cells; // the cells that draw the tabs
IBOutlet NSTabView *tabView; // the tab view being navigated
PSMOverflowPopUpButton *_overflowPopUpButton; // for too many tabs
PSMRolloverButton *_addTabButton;
// drawing style
id<PSMTabStyle> style;
BOOL _canCloseOnlyTab;
BOOL _hideForSingleTab;
BOOL _showAddTabButton;
BOOL _sizeCellsToFit;
// cell width
int _cellMinWidth;
int _cellMaxWidth;
int _cellOptimumWidth;
// animation for hide/show
int _currentStep;
BOOL _isHidden;
BOOL _hideIndicators;
IBOutlet id partnerView; // gets resized when hide/show
BOOL _awakenedFromNib;
BOOL _animate;
// drag and drop
NSEvent *_lastMouseDownEvent; // keep this for dragging reference
BOOL _allowsDragBetweenWindows;
// MVC help
IBOutlet id __unsafe_unretained delegate;
}
@property(nonatomic,readwrite, strong) NSTabView *tabView;
@property(nonatomic,readwrite, unsafe_unretained) id delegate;
@property(nonatomic,readwrite, strong) id partnerView;
// control characteristics
+ (NSBundle *)bundle;
// control configuration
- (BOOL)canCloseOnlyTab;
- (void)setCanCloseOnlyTab:(BOOL)value;
- (NSString *)styleName;
- (void)setStyleNamed:(NSString *)name;
- (BOOL)hideForSingleTab;
- (void)setHideForSingleTab:(BOOL)value;
- (BOOL)showAddTabButton;
- (void)setShowAddTabButton:(BOOL)value;
- (int)cellMinWidth;
- (void)setCellMinWidth:(int)value;
- (int)cellMaxWidth;
- (void)setCellMaxWidth:(int)value;
- (int)cellOptimumWidth;
- (void)setCellOptimumWidth:(int)value;
- (BOOL)sizeCellsToFit;
- (void)setSizeCellsToFit:(BOOL)value;
- (BOOL)allowsDragBetweenWindows;
- (void)setAllowsDragBetweenWindows:(BOOL)flag;
- (void)disableAnimations;
- (void)enableAnimations;
// the buttons
- (PSMRolloverButton *)addTabButton;
- (PSMOverflowPopUpButton *)overflowPopUpButton;
- (NSMutableArray *)representedTabViewItems;
// special effects
- (void)hideTabBar:(BOOL)hide animate:(BOOL)animate;
@end
@interface NSObject (TabBarControlDelegateMethods)
- (BOOL)tabView:(NSTabView *)aTabView shouldCloseTabViewItem:(NSTabViewItem *)tabViewItem;
- (void)tabView:(NSTabView *)aTabView willCloseTabViewItem:(NSTabViewItem *)tabViewItem;
- (void)tabView:(NSTabView *)aTabView didCloseTabViewItem:(NSTabViewItem *)tabViewItem;
@end