BWToolkit / BWTabViewController.h

//
//  KSTabViewController.h
//
//  Created by Mike Abdullah on 17/08/2009.
//  Copyright 2009 Karelia Software. All rights reserved.
//

#import "BWViewController.h"


/*! A neat way to intelligently associate an array of view controllers with the items of an NSTabView.
 */

#ifndef MAC_OS_X_VERSION_10_6
@protocol NSTabViewDelegate <NSObject> @end
#endif


@interface BWTabViewController : BWViewController <NSTabViewDelegate, NSCoding>
{
  @private
    NSTabView       *_tabView;
    NSTabViewType   _tabViewType;
    
    NSMutableArray      *_viewControllers;
    NSMutableArray      *_tabViewItems;
    NSViewController    *_selectedViewController;
}


#pragma mark Lifecycle

// If you're not loading from a nib, this is handy to specify the most basic tabview property
- (id)initWithTabViewType:(NSTabViewType)type;  // designated initializer
- (id)init; // the default top tabs look

- (void)close;  // sends -close message to any .viewControllers that respond to it


#pragma mark View Properties

@property(nonatomic, retain) IBOutlet NSTabView *tabView;   // separate to -view. Do NOT rely on them being the same.
@property(nonatomic, readonly, getter=isTabViewLoaded) BOOL tabViewLoaded;


#pragma mark Managing the View Controllers

@property(nonatomic, copy, readonly) NSArray *viewControllers;
- (NSUInteger)countOfViewControllers;  // improves efficiency & eases leak hunting

- (void)insertViewController:(NSViewController *)controller atIndex:(NSUInteger)index;
- (void)addViewController:(NSViewController *)controller;
- (void)removeViewController:(NSViewController *)controller;

- (NSViewController *)viewControllerWithIdentifier:(NSString *)identifier;


#pragma mark Managing the Selected Tab

//  Both are KVO-compliant
@property(nonatomic, assign) NSViewController *selectedViewController;
@property(nonatomic) NSUInteger selectedIndex;

//  For subclasses to know when selection is changing without needing KVO. Default implementation does nothing.
- (void)willSelectViewController:(NSViewController *)controller;
- (void)didSelectViewController;

//  NSTabViewDelegate methods that KSTabViewController implements, so be sure to call super if you override them
- (void)tabView:(NSTabView *)tabView willSelectTabViewItem:(NSTabViewItem *)tabViewItem;


#pragma mark Layout

// To answer the question: "If I wanted to display content of x size, what size would I have to make receiver's view?"
// Note the result is in the reciever's view's coordinate system
- (NSSize)viewSizeForContentSize:(NSSize)contentSize;

@end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.