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