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