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 #ifndef NSINTEGER_DEFINED
16 // NSInteger was introduced in 10.5
17 # if __LP64__ || NS_BUILD_32_LIKE_64
18 typedef long NSInteger
;
19 typedef unsigned long NSUInteger
;
21 typedef int NSInteger
;
22 typedef unsigned int NSUInteger
;
24 # define NSINTEGER_DEFINED 1
27 #define kPSMTabBarControlHeight 22
28 // internal cell border
31 // padding between objects
32 #define kPSMTabBarCellPadding 4
34 #define kPSMMinimumTitleWidth 30
35 #define kPSMTabBarIndicatorWidth 16.0
36 #define kPSMTabBarIconWidth 16.0
37 #define kPSMHideAnimationSteps 2.0
39 @
class PSMOverflowPopUpButton
;
40 @
class PSMRolloverButton
;
42 @protocol PSMTabStyle
;
45 PSMTab_SelectedMask
= 1 << 1,
46 PSMTab_LeftIsSelectedMask
= 1 << 2,
47 PSMTab_RightIsSelectedMask
= 1 << 3,
48 PSMTab_PositionLeftMask
= 1 << 4,
49 PSMTab_PositionMiddleMask
= 1 << 5,
50 PSMTab_PositionRightMask
= 1 << 6,
51 PSMTab_PositionSingleMask
= 1 << 7
54 @interface PSMTabBarControl
: NSControl
55 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
56 // 10.6 has turned delegate messages into formal protocols
62 NSMutableArray
*_cells
; // the cells that draw the tabs
63 IBOutlet NSTabView
*tabView
; // the tab view being navigated
64 PSMOverflowPopUpButton
*_overflowPopUpButton
; // for too many tabs
65 PSMRolloverButton
*_addTabButton
;
68 id
<PSMTabStyle
> style
;
69 BOOL _canCloseOnlyTab
;
70 BOOL _hideForSingleTab
;
71 BOOL _showAddTabButton
;
77 int _cellOptimumWidth
;
79 // animation for hide/show
83 IBOutlet id partnerView
; // gets resized when hide/show
84 BOOL _awakenedFromNib
;
87 NSEvent
*_lastMouseDownEvent
; // keep this for dragging reference
88 BOOL _allowsDragBetweenWindows
;
89 BOOL _delegateHandlingDrag
;
90 NSDragOperation _delegateInitialDragOperation
;
96 // control characteristics
99 // control configuration
100 - (BOOL
)canCloseOnlyTab
;
101 - (void)setCanCloseOnlyTab
:(BOOL
)value
;
102 - (NSString
*)styleName
;
103 - (void)setStyleNamed
:(NSString
*)name
;
104 - (BOOL
)hideForSingleTab
;
105 - (void)setHideForSingleTab
:(BOOL
)value
;
106 - (BOOL
)showAddTabButton
;
107 - (void)setShowAddTabButton
:(BOOL
)value
;
109 - (void)setCellMinWidth
:(int)value
;
111 - (void)setCellMaxWidth
:(int)value
;
112 - (int)cellOptimumWidth
;
113 - (void)setCellOptimumWidth
:(int)value
;
114 - (BOOL
)sizeCellsToFit
;
115 - (void)setSizeCellsToFit
:(BOOL
)value
;
116 - (BOOL
)allowsDragBetweenWindows
;
117 - (void)setAllowsDragBetweenWindows
:(BOOL
)flag
;
120 - (void)setToolTip
:(NSString
*)value forTabViewItem
:(NSTabViewItem
*)tvi
;
123 - (NSTabView
*)tabView
;
124 - (void)setTabView
:(NSTabView
*)view
;
126 - (void)setDelegate
:(id
)object
;
128 - (void)setPartnerView
:(id
)view
;
131 - (PSMRolloverButton
*)addTabButton
;
132 - (PSMOverflowPopUpButton
*)overflowPopUpButton
;
133 - (NSMutableArray
*)representedTabViewItems
;
136 - (void)hideTabBar
:(BOOL
)hide animate
:(BOOL
)animate
;
141 @interface
NSObject (TabBarControlDelegateMethods
)
142 - (BOOL
)tabView
:(NSTabView
*)aTabView shouldCloseTabViewItem
:(NSTabViewItem
*)tabViewItem
;
143 - (void)tabView
:(NSTabView
*)aTabView willCloseTabViewItem
:(NSTabViewItem
*)tabViewItem
;
144 - (void)tabView
:(NSTabView
*)aTabView didCloseTabViewItem
:(NSTabViewItem
*)tabViewItem
;
145 - (void)tabView
:(NSTabView
*)aTabView didDragTabViewItem
:(NSTabViewItem
*)tabViewItem toIndex
:(int)idx
;
147 - (NSDragOperation
)tabBarControl
:(PSMTabBarControl
*)theTabBarControl draggingEntered
:(id
<NSDraggingInfo
>)sender forTabAtIndex
:(NSUInteger
)tabIndex
;
148 - (NSDragOperation
)tabBarControl
:(PSMTabBarControl
*)theTabBarControl draggingUpdated
:(id
<NSDraggingInfo
>)sender forTabAtIndex
:(NSUInteger
)tabIndex
;
149 - (void)tabBarControl
:(PSMTabBarControl
*)theTabBarControl draggingExited
:(id
<NSDraggingInfo
>)sender forTabAtIndex
:(NSUInteger
)tabIndex
;
150 - (BOOL
)tabBarControl
:(PSMTabBarControl
*)theTabBarControl prepareForDragOperation
:(id
<NSDraggingInfo
>)sender forTabAtIndex
:(NSUInteger
)tabIndex
;
151 - (BOOL
)tabBarControl
:(PSMTabBarControl
*)theTabBarControl performDragOperation
:(id
<NSDraggingInfo
>)sender forTabAtIndex
:(NSUInteger
)tabIndex
;
152 - (void)tabBarControl
:(PSMTabBarControl
*)theTabBarControl concludeDragOperation
:(id
<NSDraggingInfo
>)sender forTabAtIndex
:(NSUInteger
)tabIndex
;