File:  [mozdev] / chimera / MJExtendedTabView.m
Revision 1.4: download - view: text, annotated - select for diffs - revision graph
Tue Mar 5 10:16:08 2002 UTC (15 years, 7 months ago) by macserv
Branches: MAIN
CVS tags: HEAD
Having some issues with the setting for autohiding.  Removing conditional.  Also, updating Chimera DL location.

#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]) ) {
        autoHides = 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 ( autoHides == YES ) {
        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>