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