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

version 1.3, 2002/04/17 07:38:31 version 1.6, 2002/04/17 10:30:13
Line 9 Line 9
 #import "BookmarksButton.h"  #import "BookmarksButton.h"
 #import "BookmarksToolbar.h"  #import "BookmarksToolbar.h"
 #import "BookmarksService.h"  #import "BookmarksService.h"
   #include "nsIDOMElement.h"
   
 @implementation BookmarksToolbar  @implementation BookmarksToolbar
   
Line 16 Line 17
   self = [super initWithFrame:frame];    self = [super initWithFrame:frame];
   if (self) {    if (self) {
     mBookmarks = nsnull;      mBookmarks = nsnull;
       mButtons = [[NSMutableArray alloc] init];
   }    }
   
   // Create a sample button.  
 /*  BookmarksButton* testButton = [[[BookmarksButton alloc] initWithFrame: NSMakeRect(2, 1, 100, 17)] autorelease];  
   [testButton setTitle: @"Gamespot - Gaming Site"];  
   [self addSubview: testButton];   
   */  
     
   return self;    return self;
 }  }
   
Line 32 Line 27
   // Initialization code here.    // Initialization code here.
   mBookmarks = new BookmarksService(self);    mBookmarks = new BookmarksService(self);
   mBookmarks->AddObserver();    mBookmarks->AddObserver();
  mBookmarks->ConstructBookmarksToolbar();  mBookmarks->EnsureToolbarRoot();
   [self buildButtonList];
 }  }
   
 -(void) dealloc  -(void) dealloc
 {  {
     [mButtons autorelease];
   mBookmarks->RemoveObserver();    mBookmarks->RemoveObserver();
   delete mBookmarks;    delete mBookmarks;
   [super dealloc];    [super dealloc];
Line 44 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];
//  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 53 Line 50
       [self bounds].size.height) {        [self bounds].size.height) {
     // 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.92 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, aRect.origin.y, aRect.size.width, 2));
   }    }
   
   // The buttons will paint themselves.    // The buttons will paint themselves.
 }  }
   
   -(void)buildButtonList
   {
     // Build the buttons, and then lay them all out.
     nsCOMPtr<nsIDOMNode> child;
     BookmarksService::gToolbarRoot->GetFirstChild(getter_AddRefs(child));
     while (child) {
       nsCOMPtr<nsIDOMElement> childElt(do_QueryInterface(child));
       if (childElt) {
         BookmarksButton* button = [[[BookmarksButton alloc] initWithFrame: NSMakeRect(2, 1, 100, 17)] autorelease];
         [button setElement: childElt];
         [self addSubview: button];
         [mButtons addObject: button];
       }
   
       nsCOMPtr<nsIDOMNode> temp = child;
       temp->GetNextSibling(getter_AddRefs(child));
     }
   
     [self reflowButtons];
   }
   
   -(void)reflowButtons
   {
     int count = [mButtons count];
     int prevX = 2;
     for (int i = 0; i < count; i++) {
       BookmarksButton* button = [mButtons objectAtIndex: i];
       [button sizeToFit];
       int width = [button frame].size.width;
       if (width > 150)
         width = 150;
       [button setFrame: NSMakeRect(prevX, [button frame].origin.y, width, [button frame].size.height)];
       prevX += [button frame].size.width + 2;
     }
   }
 @end  @end

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


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