Annotation of chimera/BookmarksButton.mm, revision 1.4

1.1       hyatt       1: //
                      2: //  BookmarksButton.mm
                      3: //  Chimera
                      4: //
                      5: //  Created by David Hyatt on Mon Apr 15 2002.
                      6: //  Copyright (c) 2001 __MyCompanyName__. All rights reserved.
                      7: //
                      8: 
                      9: #import "BookmarksButton.h"
1.2       hyatt      10: #include "nsIDOMElement.h"
                     11: #include "nsString.h"
1.1       hyatt      12: 
                     13: @implementation BookmarksButton
                     14: 
                     15: - (id)initWithFrame:(NSRect)frame {
                     16:   self = [super initWithFrame:frame];
                     17:   if (self) {
                     18:     // Initialization code here.
1.2       hyatt      19:     mElement = nsnull;
                     20:     [self setBezelStyle: NSRegularSquareBezelStyle];
                     21:     [self setBordered: NO];
                     22:     [self setImagePosition: NSImageLeft];
                     23:     [self setRefusesFirstResponder: YES];
                     24:     [self setFont: [NSFont labelFontOfSize: 11.0]];
1.1       hyatt      25:   }
1.2       hyatt      26:   return self;
                     27: }
1.1       hyatt      28: 
1.3       hyatt      29: -(IBAction)openBookmark:(id)aSender
                     30: {
                     31:   printf("Yo?\n");
                     32:   
                     33:   // Get the href attribute.  This is the URL we want to load.
                     34:   nsAutoString href;
                     35:   mElement->GetAttribute(NS_LITERAL_STRING("href"), href);
                     36:   nsCAutoString cref; cref.AssignWithConversion(href);
                     37:   if (cref.IsEmpty())
                     38:     return;
                     39: 
                     40:   NSString* url = [NSString stringWithCString: cref.get()];
                     41: 
                     42:   // Now load the URL in the window.
                     43:   [[[self window] windowController] loadURL:[NSURL URLWithString: url]];
                     44: 
                     45:   // Focus and activate our content area.
                     46:   [[[[[self window] windowController] getMyBrowserView] getBrowserView] setActive: YES];
                     47: }
                     48: 
1.4     ! hyatt      49: -(BOOL)isOpaque
        !            50: {
        !            51:   return NO;
        !            52: }
        !            53: 
1.2       hyatt      54: -(void)setElement: (nsIDOMElement*)aElt
                     55: {
                     56:   mElement = aElt;
                     57:   nsAutoString tag;
                     58:   mElement->GetLocalName(tag);
                     59:   if (tag.Equals(NS_LITERAL_STRING("folder")))
                     60:     [self setImage: [NSImage imageNamed: @"folder"]];
1.3       hyatt      61:   else {
1.2       hyatt      62:     [self setImage: [NSImage imageNamed: @"smallbookmark"]];
1.3       hyatt      63:     [self setAction: @selector(openBookmark:)];
                     64:     [self setTarget: self];
                     65:   }
                     66:   
1.2       hyatt      67:   nsAutoString name;
                     68:   mElement->GetAttribute(NS_LITERAL_STRING("name"), name);
                     69:   [self setTitle: [NSString stringWithCharacters: name.get() length: nsCRT::strlen(name.get())]];
1.1       hyatt      70: }
                     71: 
                     72: @end

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