File:  [mozdev] / chimera / MJExtendedTabView.m
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Sun Mar 3 09:34:52 2002 UTC (15 years, 7 months ago) by macserv
Branches: MAIN
CVS tags: HEAD
Intermediary checkin: Groundwork for the icon colorization server object, most of a new specialized version of my extended tab view class, changes to the browser window's controller, and nib, and of course, to the project itself.

#import "MJExtendedTabView.h"

//////////////////////////
//     NEEDS IMPLEMENTED : Implement drag tracking for moving tabs around.
//  Implementation hints : Track drags ;)
//                       : Change tab controlTint to indicate drag location?
//				   		 : Move tab titles around when dragging.
//////////////////////////

@interface MJExtendedTabView (Private)
- (void)showOrHideTabsAsAppropriate;
@end

@implementation MJExtendedTabView

/******************************************/
/*** Initialization                     ***/
/******************************************/

- (id)initWithFrame:(NSRect)frameRect
{
    if ( (self = [super initWithFrame:frameRect]) ) {
        [self setAutoHides:YES];
    }
    return self;
}

- (void)awakeFromNib
{
    [self showOrHideTabsAsAppropriate];
}

/******************************************/
/*** Overridden Methods                 ***/
/******************************************/

- (BOOL)isOpaque
{
    if ( ([self tabViewType] == NSNoTabsBezelBorder) && (NSAppKitVersionNumber < 633) ) {
        return NO;
    } else {
        return [super isOpaque];
    }
}

- (void)addTabViewItem:(NSTabViewItem *)tabViewItem
{
    [super addTabViewItem:tabViewItem];
    [self showOrHideTabsAsAppropriate];
}

- (void)removeTabViewItem:(NSTabViewItem *)tabViewItem
{
    [super removeTabViewItem:tabViewItem];
    [self showOrHideTabsAsAppropriate];
}

- (void)insertTabViewItem:(NSTabViewItem *)tabViewItem atIndex:(int)index
{
    [super insertTabViewItem:tabViewItem atIndex:index];
    [self showOrHideTabsAsAppropriate];
}

/******************************************/
/*** Accessor Methods                   ***/
/******************************************/

- (BOOL)autoHides
{
    return _autoHides;
}

- (void)setAutoHides:(BOOL)newSetting
{
    _autoHides = newSetting;
}


/******************************************/
/*** Instance Methods                   ***/
/******************************************/

- (void)showOrHideTabsAsAppropriate
{
    NSLog(@"%d", [[self tabViewItems] count]);

    if ( [[self tabViewItems] count] < 2) {
        [self setTabViewType:NSNoTabsBezelBorder];
        //ADD 10 to the frame height.
    } else {
        [self setTabViewType:NSTopTabsBezelBorder];
        //SUBTRACT 10 from the frame height.
    }

    [self display];
}



@end

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>