File:  [mozdev] / chimera / MJExtendedTabView.m
Revision 1.2: download - view: text, annotated - select for diffs - revision graph
Sun Mar 3 10:49:50 2002 UTC (15 years, 7 months ago) by macserv
Branches: MAIN
CVS tags: HEAD
More progress on the autohidden tabs

#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                   ***/
/******************************************/

// 03-03-2002 mlj: Modifies tab view size and type appropriately... Fragile.
// Only to be used with the 2 types of tab view which we use in Chimera.
- (void)showOrHideTabsAsAppropriate
{
    if ( [[self tabViewItems] count] < 2) {
        if ( [self tabViewType] != NSNoTabsBezelBorder ) {
            [self setFrameSize:NSMakeSize( NSWidth([self frame]), NSHeight([self frame]) + 10 )];
        }
        [self setTabViewType:NSNoTabsBezelBorder];
    } else {
        if ( [self tabViewType] != NSTopTabsBezelBorder ) {
            [self setFrameSize:NSMakeSize( NSWidth([self frame]), NSHeight([self frame]) - 10 )];
        }
        [self setTabViewType:NSTopTabsBezelBorder];
    }
    [self display];
}



@end

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