| 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 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_control_u
tils.h" | 5 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_control_u
tils.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "skia/ext/skia_utils_mac.h" | 8 #include "skia/ext/skia_utils_mac.h" |
| 9 | 9 |
| 10 namespace constrained_window { | 10 namespace constrained_window { |
| 11 | 11 |
| 12 NSTextField* CreateLabel() { | 12 NSTextField* CreateLabel() { |
| 13 NSTextField* label = | 13 NSTextField* label = |
| 14 [[[NSTextField alloc] initWithFrame:NSZeroRect] autorelease]; | 14 [[[NSTextField alloc] initWithFrame:NSZeroRect] autorelease]; |
| 15 [label setEditable:NO]; | 15 [label setEditable:NO]; |
| 16 [label setSelectable:NO]; | 16 [label setSelectable:NO]; |
| 17 [label setBezeled:NO]; | 17 [label setBezeled:NO]; |
| 18 [label setDrawsBackground:NO]; | 18 [label setDrawsBackground:NO]; |
| 19 return label; | 19 return label; |
| 20 } | 20 } |
| 21 | 21 |
| 22 NSAttributedString* GetAttributedLabelString( | 22 NSAttributedString* GetAttributedLabelString( |
| 23 NSString* string, | 23 NSString* string, |
| 24 ui::ResourceBundle::FontStyle fontStyle, | 24 ui::ResourceBundle::FontStyle fontStyle, |
| 25 NSTextAlignment alignment, | 25 NSTextAlignment alignment, |
| 26 NSLineBreakMode lineBreakMode) { | 26 NSLineBreakMode lineBreakMode) { |
| 27 if (!string) | 27 if (!string) |
| 28 return nil; | 28 return nil; |
| 29 | 29 |
| 30 const gfx::Font& font = | 30 const gfx::Font& font = |
| 31 ui::ResourceBundle::GetSharedInstance().GetFont(fontStyle); | 31 ui::ResourceBundle::GetSharedInstance().GetFont(fontStyle); |
| 32 scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( | 32 base::scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( |
| 33 [[NSMutableParagraphStyle alloc] init]); | 33 [[NSMutableParagraphStyle alloc] init]); |
| 34 [paragraphStyle setAlignment:alignment]; | 34 [paragraphStyle setAlignment:alignment]; |
| 35 [paragraphStyle setLineBreakMode:lineBreakMode]; | 35 [paragraphStyle setLineBreakMode:lineBreakMode]; |
| 36 | 36 |
| 37 NSDictionary* attributes = @{ | 37 NSDictionary* attributes = @{ |
| 38 NSFontAttributeName: font.GetNativeFont(), | 38 NSFontAttributeName: font.GetNativeFont(), |
| 39 NSParagraphStyleAttributeName: paragraphStyle.get() | 39 NSParagraphStyleAttributeName: paragraphStyle.get() |
| 40 }; | 40 }; |
| 41 return [[[NSAttributedString alloc] initWithString:string | 41 return [[[NSAttributedString alloc] initWithString:string |
| 42 attributes:attributes] autorelease]; | 42 attributes:attributes] autorelease]; |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // namespace constrained_window | 45 } // namespace constrained_window |
| OLD | NEW |