Diff for /chimera/BookmarksToolbar.mm between versions 1.6 and 1.7

version 1.6, 2002/04/17 10:30:13 version 1.7, 2002/04/17 22:57:07
Line 78 Line 78
   [self reflowButtons];    [self 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];
     for (int i = 0; i < count; i++) {
       BookmarksButton* button = [mButtons objectAtIndex: i];
       if ([button element] == aElt) {
         [mButtons removeObjectAtIndex: i];
         [button removeFromSuperview];
         if (count > i)
           [self reflowButtonsStartingAtIndex: i];
         break;
       }
     }
   }
   
 -(void)reflowButtons  -(void)reflowButtons
 {  {
     [self reflowButtonsStartingAtIndex: 0];
   }
   
   -(void)reflowButtonsStartingAtIndex: (int)aIndex
   {
   int count = [mButtons count];    int count = [mButtons count];
   int prevX = 2;    int prevX = 2;
  for (int i = 0; i < count; i++) {  if (aIndex > 0) {
     BookmarksButton* prevButton = [mButtons objectAtIndex: (aIndex-1)];
     prevX += [prevButton frame].origin.x + [prevButton frame].size.width;
   }
   for (int i = aIndex; i < count; i++) {
     BookmarksButton* button = [mButtons objectAtIndex: i];      BookmarksButton* button = [mButtons objectAtIndex: i];
     [button sizeToFit];      [button sizeToFit];
     int width = [button frame].size.width;      int width = [button frame].size.width;
       int 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, [button frame].origin.y, width, height)];
 
     prevX += [button frame].size.width + 2;      prevX += [button frame].size.width + 2;
   }    }
 }  }

Removed from v.1.6  
changed lines
  Added in v.1.7


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