File:  [mozdev] / chimera / MJExtendedTabView.m
Revision 1.3: download - view: text, annotated - select for diffs - revision graph
Mon Mar 4 12:55:22 2002 UTC (17 years, 8 months ago) by macserv
Branches: MAIN
CVS tags: HEAD
Adding the ability to turn an MJExtendedTabView's autohiding off with a set method.

    1: #import "MJExtendedTabView.h"
    2: 
    3: //////////////////////////
    4: //     NEEDS IMPLEMENTED : Implement drag tracking for moving tabs around.
    5: //  Implementation hints : Track drags ;)
    6: //                       : Change tab controlTint to indicate drag location?
    7: //				   		 : Move tab titles around when dragging.
    8: //////////////////////////
    9: 
   10: @interface MJExtendedTabView (Private)
   11: - (void)showOrHideTabsAsAppropriate;
   12: @end
   13: 
   14: @implementation MJExtendedTabView
   15: 
   16: /******************************************/
   17: /*** Initialization                     ***/
   18: /******************************************/
   19: 
   20: - (id)initWithFrame:(NSRect)frameRect
   21: {
   22:     if ( (self = [super initWithFrame:frameRect]) ) {
   23:         [self setAutoHides:YES];
   24:     }
   25:     return self;
   26: }
   27: 
   28: - (void)awakeFromNib
   29: {
   30:     [self showOrHideTabsAsAppropriate];
   31: }
   32: 
   33: /******************************************/
   34: /*** Overridden Methods                 ***/
   35: /******************************************/
   36: 
   37: - (BOOL)isOpaque
   38: {
   39:     if ( ([self tabViewType] == NSNoTabsBezelBorder) && (NSAppKitVersionNumber < 633) ) {
   40:         return NO;
   41:     } else {
   42:         return [super isOpaque];
   43:     }
   44: }
   45: 
   46: - (void)addTabViewItem:(NSTabViewItem *)tabViewItem
   47: {
   48:     [super addTabViewItem:tabViewItem];
   49:     [self showOrHideTabsAsAppropriate];
   50: }
   51: 
   52: - (void)removeTabViewItem:(NSTabViewItem *)tabViewItem
   53: {
   54:     [super removeTabViewItem:tabViewItem];
   55:     [self showOrHideTabsAsAppropriate];
   56: }
   57: 
   58: - (void)insertTabViewItem:(NSTabViewItem *)tabViewItem atIndex:(int)index
   59: {
   60:     [super insertTabViewItem:tabViewItem atIndex:index];
   61:     [self showOrHideTabsAsAppropriate];
   62: }
   63: 
   64: /******************************************/
   65: /*** Accessor Methods                   ***/
   66: /******************************************/
   67: 
   68: - (BOOL)autoHides
   69: {
   70:     return _autoHides;
   71: }
   72: 
   73: - (void)setAutoHides:(BOOL)newSetting
   74: {
   75:     _autoHides = newSetting;
   76: }
   77: 
   78: 
   79: /******************************************/
   80: /*** Instance Methods                   ***/
   81: /******************************************/
   82: 
   83: // 03-03-2002 mlj: Modifies tab view size and type appropriately... Fragile.
   84: // Only to be used with the 2 types of tab view which we use in Chimera.
   85: - (void)showOrHideTabsAsAppropriate
   86: {
   87:     if ( [self autohides] ) {
   88:         if ( [[self tabViewItems] count] < 2) {
   89:             if ( [self tabViewType] != NSNoTabsBezelBorder ) {
   90:                 [self setFrameSize:NSMakeSize( NSWidth([self frame]), NSHeight([self frame]) + 10 )];
   91:             }
   92:             [self setTabViewType:NSNoTabsBezelBorder];
   93:         } else {
   94:             if ( [self tabViewType] != NSTopTabsBezelBorder ) {
   95:                 [self setFrameSize:NSMakeSize( NSWidth([self frame]), NSHeight([self frame]) - 10 )];
   96:             }
   97:             [self setTabViewType:NSTopTabsBezelBorder];
   98:         }
   99:         [self display];
  100:     }
  101: }
  102: 
  103: 
  104: 
  105: @end

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