Diff for /chimera/BookmarksToolbar.mm between versions 1.5 and 1.10

version 1.5, 2002/04/17 08:56:57 version 1.10, 2002/04/19 01:08:30
Line 41 Line 41
   
 - (void)drawRect:(NSRect)aRect {  - (void)drawRect:(NSRect)aRect {
   // Fill the background with our background color.    // Fill the background with our background color.
  [[NSColor colorWithCalibratedWhite: 0.98 alpha: 1.0] set];  //[[NSColor colorWithCalibratedWhite: 0.98 alpha: 1.0] set];
  NSRectFill(aRect);  //NSRectFill(aRect);
   
   //printf("The rect is: %f %f %f %f\n", aRect.origin.x, aRect.origin.y, aRect.size.width, aRect.size.height);    //printf("The rect is: %f %f %f %f\n", aRect.origin.x, aRect.origin.y, aRect.size.width, aRect.size.height);
       
Line 51 Line 51
     // The personal toolbar is 21 pixels tall.  The bottom two pixels      // The personal toolbar is 21 pixels tall.  The bottom two pixels
     // are a separator.      // are a separator.
     [[NSColor colorWithCalibratedWhite: 0.90 alpha: 1.0] set];      [[NSColor colorWithCalibratedWhite: 0.90 alpha: 1.0] set];
    NSRectFill(NSMakeRect(aRect.origin.x, aRect.origin.y, aRect.size.width, 2));    NSRectFill(NSMakeRect(aRect.origin.x, [self bounds].size.height-2, aRect.size.width, [self bounds].size.height));
   }    }
   
  // The buttons will paint themselves.  // The buttons will paint themselves. Just call our base class method.
   [super drawRect: aRect];
 }  }
   
 -(void)buildButtonList  -(void)buildButtonList
Line 78 Line 79
   [self reflowButtons];    [self reflowButtons];
 }  }
   
-(void)reflowButtons-(void)addButton: (nsIDOMElement*)aElt atIndex: (int)aIndex
 {
   BookmarksButton* button = [[[BookmarksButton alloc] initWithFrame: NSMakeRect(2, 1, 100, 17)] autorelease];
   [button setElement: aElt];
   [self addSubview: button];
   [mButtons insertObject: button atIndex: aIndex];
   [self reflowButtonsStartingAtIndex: aIndex];
 }
 
 -(void)removeButton: (nsIDOMElement*)aElt
 {  {
   int count = [mButtons count];    int count = [mButtons count];
   int prevX = 2;  
   for (int i = 0; i < count; i++) {    for (int i = 0; i < count; i++) {
     BookmarksButton* button = [mButtons objectAtIndex: i];      BookmarksButton* button = [mButtons objectAtIndex: i];
       if ([button element] == aElt) {
         [mButtons removeObjectAtIndex: i];
         [button removeFromSuperview];
         if (count > i)
           [self reflowButtonsStartingAtIndex: i];
         break;
       }
     }
   
     [self setNeedsDisplay: YES];
   }
   
   -(void)reflowButtons
   {
     [self reflowButtonsStartingAtIndex: 0];
   }
   
   -(void)reflowButtonsStartingAtIndex: (int)aIndex
   {
     float sizeChange = 0;
     int count = [mButtons count];
     float currY = 1.0;
     float prevX = 2.0;
     if (aIndex > 0) {
       BookmarksButton* prevButton = [mButtons objectAtIndex: (aIndex-1)];
       prevX += [prevButton frame].origin.x + [prevButton frame].size.width;
       currY = [prevButton frame].origin.y;
     }
     for (int i = aIndex; i < count; i++) {
       BookmarksButton* button = [mButtons objectAtIndex: i];
     [button sizeToFit];      [button sizeToFit];
    int width = [button frame].size.width;    float width = [button frame].size.width;
     float height = [button frame].size.height;
     if (width > 150)      if (width > 150)
       width = 150;        width = 150;
    [button setFrame: NSMakeRect(prevX, [button frame].origin.y, width, [button frame].size.height)];    if (height < 16)
       height = 16; // Our folder tiff is only 15 pixels for some reason.
     [button setFrame: NSMakeRect(prevX, currY, width, height)];
 
     prevX += [button frame].size.width + 2;      prevX += [button frame].size.width + 2;
   
       if ([self bounds].size.width < prevX) {
         // The previous button didn't fit.  We need to make a new row.
         sizeChange += 18;
         currY += 18;
         [self setFrame: NSMakeRect([self frame].origin.x, [self frame].origin.y - 18.0,
                                    [self frame].size.width, [self frame].size.height + 18.0)];
         [self setNeedsDisplay: YES];
         prevX = 2;
         [button setFrame: NSMakeRect(prevX, currY, width, height)];
       }
       
       [button setNeedsDisplay: YES];
     }
   
     if (sizeChange != 0) {
       // We need to adjust the content area.
       NSView* view = [[[self window] windowController] getTabBrowser];
       [view setFrame: NSMakeRect([view frame].origin.x, [view frame].origin.y,
                                  [view frame].size.width, [view frame].size.height - sizeChange)];
   }    }
 }  }
   
   -(BOOL)isFlipped
   {
     return YES; // Use flipped coords, so we can layout out from top row to bottom row.
   }
   
   -(void)setFrame:(NSRect)aRect
   {
     NSRect oldFrame = [self frame];
     [super setFrame:aRect];
   
     // See if we got bigger or smaller.  We could gain or lose a row.
     
   }
   
 @end  @end

Removed from v.1.5  
changed lines
  Added in v.1.10


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