| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/cocoa/bookmarks/bookmark_button_cell.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #import "chrome/browser/bookmarks/bookmark_model.h" | 9 #import "chrome/browser/bookmarks/bookmark_model.h" |
| 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" | 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 208 |
| 209 - (void)setTextColor:(NSColor*)color { | 209 - (void)setTextColor:(NSColor*)color { |
| 210 if ([textColor_ isEqualTo:color]) | 210 if ([textColor_ isEqualTo:color]) |
| 211 return; | 211 return; |
| 212 textColor_.reset([color copy]); | 212 textColor_.reset([color copy]); |
| 213 [self applyTextColor]; | 213 [self applyTextColor]; |
| 214 } | 214 } |
| 215 | 215 |
| 216 // We must reapply the text color after any setTitle: call | 216 // We must reapply the text color after any setTitle: call |
| 217 - (void)applyTextColor { | 217 - (void)applyTextColor { |
| 218 scoped_nsobject<NSMutableParagraphStyle> style([NSMutableParagraphStyle new]); | 218 base::scoped_nsobject<NSMutableParagraphStyle> style( |
| 219 [NSMutableParagraphStyle new]); |
| 219 [style setAlignment:NSLeftTextAlignment]; | 220 [style setAlignment:NSLeftTextAlignment]; |
| 220 NSDictionary* dict = [NSDictionary | 221 NSDictionary* dict = [NSDictionary |
| 221 dictionaryWithObjectsAndKeys:textColor_, | 222 dictionaryWithObjectsAndKeys:textColor_, |
| 222 NSForegroundColorAttributeName, | 223 NSForegroundColorAttributeName, |
| 223 [self font], NSFontAttributeName, | 224 [self font], NSFontAttributeName, |
| 224 style.get(), NSParagraphStyleAttributeName, | 225 style.get(), NSParagraphStyleAttributeName, |
| 225 [NSNumber numberWithFloat:0.2], NSKernAttributeName, | 226 [NSNumber numberWithFloat:0.2], NSKernAttributeName, |
| 226 nil]; | 227 nil]; |
| 227 scoped_nsobject<NSAttributedString> ats([[NSAttributedString alloc] | 228 base::scoped_nsobject<NSAttributedString> ats( |
| 228 initWithString:[self title] | 229 [[NSAttributedString alloc] initWithString:[self title] attributes:dict]); |
| 229 attributes:dict]); | |
| 230 [self setAttributedTitle:ats.get()]; | 230 [self setAttributedTitle:ats.get()]; |
| 231 } | 231 } |
| 232 | 232 |
| 233 // To implement "hover open a bookmark button to open the folder" | 233 // To implement "hover open a bookmark button to open the folder" |
| 234 // which feels like menus, we override NSButtonCell's mouseEntered: | 234 // which feels like menus, we override NSButtonCell's mouseEntered: |
| 235 // and mouseExited:, then and pass them along to our owning control. | 235 // and mouseExited:, then and pass them along to our owning control. |
| 236 // Note: as verified in a debugger, mouseEntered: does NOT increase | 236 // Note: as verified in a debugger, mouseEntered: does NOT increase |
| 237 // the retainCount of the cell or its owning control. | 237 // the retainCount of the cell or its owning control. |
| 238 - (void)mouseEntered:(NSEvent*)event { | 238 - (void)mouseEntered:(NSEvent*)event { |
| 239 [super mouseEntered:event]; | 239 [super mouseEntered:event]; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 respectFlipped:YES | 291 respectFlipped:YES |
| 292 hints:nil]; | 292 hints:nil]; |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 | 295 |
| 296 - (int)verticalTextOffset { | 296 - (int)verticalTextOffset { |
| 297 return 0; | 297 return 0; |
| 298 } | 298 } |
| 299 | 299 |
| 300 @end | 300 @end |
| OLD | NEW |