Diff for /chimera/BookmarksButton.mm between versions 1.1 and 1.6

version 1.1, 2002/04/16 07:26:07 version 1.6, 2002/04/17 22:57:07
Line 7 Line 7
 //  //
   
 #import "BookmarksButton.h"  #import "BookmarksButton.h"
#include "nsIDOMElement.h"
 #include "nsIContent.h"
 #include "nsString.h"
 #import "BookmarksService.h"
   
 @implementation BookmarksButton  @implementation BookmarksButton
   
Line 15 Line 18
   self = [super initWithFrame:frame];    self = [super initWithFrame:frame];
   if (self) {    if (self) {
     // Initialization code here.      // Initialization code here.
       mElement = nsnull;
       [self setBezelStyle: NSRegularSquareBezelStyle];
       [self setBordered: NO];
       [self setImagePosition: NSImageLeft];
       [self setRefusesFirstResponder: YES];
       [self setFont: [NSFont labelFontOfSize: 11.0]];
   }    }
     return self;
   }
   
  // Create a sample button.-(IBAction)openBookmark:(id)aSender
  [self setBezelStyle: NSRegularSquareBezelStyle];{
  [self setBordered: NO];  printf("Yo?\n");
  [self setImagePosition: NSImageLeft];  
  [self setImage: [NSImage imageNamed: @"smallbookmark"]];  // Get the href attribute.  This is the URL we want to load.
  [self setFont: [NSFont labelFontOfSize: 11.0]];  nsAutoString href;
  [self setRefusesFirstResponder: YES];  mElement->GetAttribute(NS_LITERAL_STRING("href"), href);
  //[[self cell] setHighlightsBy: NSChangeGrayCellMask];  nsCAutoString cref; cref.AssignWithConversion(href);
  [self sizeToFit];  if (cref.IsEmpty())
     return;
   
  return self;  NSString* url = [NSString stringWithCString: cref.get()];
 
   // Now load the URL in the window.
   [[[self window] windowController] loadURL:[NSURL URLWithString: url]];
 
   // Focus and activate our content area.
   [[[[[self window] windowController] getMyBrowserView] getBrowserView] setActive: YES];
 }
 
 -(void)drawRect:(NSRect)aRect
 {
   [super drawRect: aRect];
 }
 
 -(void)mouseDown:(NSEvent*)aEvent
 {
   if (mIsFolder) {
     nsCOMPtr<nsIContent> content(do_QueryInterface(mElement));
     NSMenu* menu = BookmarksService::LocateMenu(content);
     [NSMenu popUpContextMenu: menu withEvent: aEvent forView: self];
   }
   else
     [super mouseDown: aEvent];
 }
 
 -(void)setElement: (nsIDOMElement*)aElt
 {
   mElement = aElt;
   nsAutoString tag;
   mElement->GetLocalName(tag);
   if (tag.Equals(NS_LITERAL_STRING("folder"))) {
     [self setImage: [NSImage imageNamed: @"folder"]];
     mIsFolder = YES;
   }
   else {
     mIsFolder = NO;
     [self setImage: [NSImage imageNamed: @"smallbookmark"]];
     [self setAction: @selector(openBookmark:)];
     [self setTarget: self];
   }
   
   nsAutoString name;
   mElement->GetAttribute(NS_LITERAL_STRING("name"), name);
   [self setTitle: [NSString stringWithCharacters: name.get() length: nsCRT::strlen(name.get())]];
 }
 
 -(nsIDOMElement*)element
 {
   return mElement;
 }  }
   
 @end  @end

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


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