Home | History | Annotate | Download | only in bookmarks
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BUTTON_CELL_H_
      6 #define CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BUTTON_CELL_H_
      7 
      8 #import "chrome/browser/ui/cocoa/gradient_button_cell.h"
      9 
     10 @class BookmarkContextMenuCocoaController;
     11 class BookmarkNode;
     12 
     13 // A button cell that handles drawing/highlighting of buttons in the
     14 // bookmark bar.  This cell forwards mouseEntered/mouseExited events
     15 // to its control view so that pseudo-menu operations
     16 // (e.g. hover-over to open) can be implemented.
     17 @interface BookmarkButtonCell : GradientButtonCell<NSMenuDelegate> {
     18  @private
     19   // Controller for showing the context menu. Weak, owned by
     20   // BookmarkBarController.
     21   BookmarkContextMenuCocoaController* menuController_;
     22 
     23   BOOL empty_;  // is this an "empty" button placeholder button cell?
     24 
     25   // Starting index of bookmarkFolder children that we care to use.
     26   int startingChildIndex_;
     27 
     28   // Should we draw the folder arrow as needed?  Not used for the bar
     29   // itself but used on the folder windows.
     30   BOOL drawFolderArrow_;
     31 
     32   // Arrow for folders
     33   base::scoped_nsobject<NSImage> arrowImage_;
     34 
     35   // Text color for title.
     36   base::scoped_nsobject<NSColor> textColor_;
     37 }
     38 
     39 @property(nonatomic, readwrite, assign) const BookmarkNode* bookmarkNode;
     40 @property(nonatomic, readwrite, assign) int startingChildIndex;
     41 @property(nonatomic, readwrite, assign) BOOL drawFolderArrow;
     42 
     43 // Create a button cell which draws with a theme.
     44 + (id)buttonCellForNode:(const BookmarkNode*)node
     45                    text:(NSString*)text
     46                   image:(NSImage*)image
     47          menuController:(BookmarkContextMenuCocoaController*)menuController;
     48 
     49 // Create a button cell not attached to any node which draws with a theme.
     50 + (id)buttonCellWithText:(NSString*)text
     51                    image:(NSImage*)image
     52           menuController:(BookmarkContextMenuCocoaController*)menuController;
     53 
     54 // Initialize a button cell which draws with a theme.
     55 // Designated initializer.
     56 - (id)initForNode:(const BookmarkNode*)node
     57              text:(NSString*)text
     58             image:(NSImage*)image
     59    menuController:(BookmarkContextMenuCocoaController*)menuController;
     60 
     61 // Initialize a button cell not attached to any node which draws with a theme.
     62 - (id)initWithText:(NSString*)text
     63              image:(NSImage*)image
     64     menuController:(BookmarkContextMenuCocoaController*)menuController;
     65 
     66 // A button cell is considered empty if it is expected to be attached to a node
     67 // and this node is NULL. If the button was created with
     68 // buttonCellForContextMenu then no node is expected and empty is always NO.
     69 - (BOOL)empty;
     70 - (void)setEmpty:(BOOL)empty;
     71 
     72 // |-setBookmarkCellText:image:| is used to set the text and image of
     73 // a BookmarkButtonCell, and align the image to the left (NSImageLeft)
     74 // if there is text in the title, and centered (NSImageCenter) if
     75 // there is not.  If |title| is nil, do not reset the title.
     76 - (void)setBookmarkCellText:(NSString*)title
     77                       image:(NSImage*)image;
     78 
     79 // Set the color of text in this cell.
     80 - (void)setTextColor:(NSColor*)color;
     81 
     82 - (BOOL)isFolderButtonCell;
     83 
     84 @end
     85 
     86 #endif  // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BUTTON_CELL_H_
     87