OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #import "chrome/browser/cocoa/bookmark_button_cell.h" | 5 #import "chrome/browser/cocoa/bookmark_button_cell.h" |
6 #import "third_party/GTM/AppKit/GTMTheme.h" | 6 #import "third_party/GTM/AppKit/GTMTheme.h" |
7 | 7 |
8 @implementation BookmarkButtonCell | 8 @implementation BookmarkButtonCell |
9 | 9 |
10 - (id)initTextCell:(NSString *)string { | 10 - (id)initTextCell:(NSString *)string { |
(...skipping 16 matching lines...) Expand all Loading... |
27 return self; | 27 return self; |
28 } | 28 } |
29 | 29 |
30 - (NSSize)cellSizeForBounds:(NSRect)aRect { | 30 - (NSSize)cellSizeForBounds:(NSRect)aRect { |
31 NSSize size = [super cellSizeForBounds:aRect]; | 31 NSSize size = [super cellSizeForBounds:aRect]; |
32 size.width += 2; | 32 size.width += 2; |
33 size.height += 4; | 33 size.height += 4; |
34 return size; | 34 return size; |
35 } | 35 } |
36 | 36 |
| 37 - (void)setBookmarkCellText:(NSString*)title |
| 38 image:(NSImage*)image { |
| 39 title = [title stringByReplacingOccurrencesOfString:@"\n" |
| 40 withString:@" "]; |
| 41 title = [title stringByReplacingOccurrencesOfString:@"\r" |
| 42 withString:@" "]; |
| 43 if (image) { |
| 44 [self setImage:image]; |
| 45 if ([title length] < 1) { |
| 46 [self setImagePosition:NSImageOnly]; |
| 47 } else { |
| 48 [self setImagePosition:NSImageLeft]; |
| 49 } |
| 50 } |
| 51 [self setTitle:title]; |
| 52 } |
| 53 |
37 // We share the context menu among all bookmark buttons. To allow us | 54 // We share the context menu among all bookmark buttons. To allow us |
38 // to disambiguate when needed (e.g. "open bookmark"), we set the | 55 // to disambiguate when needed (e.g. "open bookmark"), we set the |
39 // menu's delegate to be us. We (the cell) have the bookmark encoded | 56 // menu's delegate to be us. We (the cell) have the bookmark encoded |
40 // in our represented object. | 57 // in our represented object. |
41 // Convention needed in -[BookmarkBarController openBookmarkIn***] calls. | 58 // Convention needed in -[BookmarkBarController openBookmarkIn***] calls. |
42 - (NSMenu*)menu { | 59 - (NSMenu*)menu { |
43 NSMenu* menu = [super menu]; | 60 NSMenu* menu = [super menu]; |
44 [menu setDelegate:self]; | 61 [menu setDelegate:self]; |
45 return menu; | 62 return menu; |
46 } | 63 } |
47 | 64 |
48 @end | 65 @end |
OLD | NEW |