5 // Created by John Pannell on 10/13/05.
6 // Copyright 2005 Positive Spin Media. All rights reserved.
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
19 // padding between objects
20 #define kPSMTabBarCellPadding 4
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
;
30 @protocol PSMTabStyle
;
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
{
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
;
51 id
<PSMTabStyle
> style
;
52 BOOL _canCloseOnlyTab
;
53 BOOL _hideForSingleTab
;
54 BOOL _showAddTabButton
;
60 int _cellOptimumWidth
;
62 // animation for hide/show
66 IBOutlet id partnerView
; // gets resized when hide/show
67 BOOL _awakenedFromNib
;
70 NSEvent
*_lastMouseDownEvent
; // keep this for dragging reference
71 BOOL _allowsDragBetweenWindows
;
77 // control characteristics
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
;
90 - (void)setCellMinWidth
:(int)value
;
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
;
101 - (NSTabView
*)tabView
;
102 - (void)setTabView
:(NSTabView
*)view
;
104 - (void)setDelegate
:(id
)object
;
106 - (void)setPartnerView
:(id
)view
;
109 - (PSMRolloverButton
*)addTabButton
;
110 - (PSMOverflowPopUpButton
*)overflowPopUpButton
;
111 - (NSMutableArray
*)representedTabViewItems
;
114 - (void)hideTabBar
:(BOOL
)hide animate
:(BOOL
)animate
;
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
;