OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/profiles/avatar_label_button.h" | 5 #import "chrome/browser/ui/cocoa/profiles/avatar_label_button.h" |
6 | 6 |
7 #include "chrome/browser/themes/theme_properties.h" | 7 #include "chrome/browser/themes/theme_properties.h" |
8 #include "chrome/browser/ui/cocoa/themed_window.h" | 8 #include "chrome/browser/ui/cocoa/themed_window.h" |
9 #include "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
10 #include "grit/theme_resources.h" | 10 #include "grit/theme_resources.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 // the label text. | 30 // the label text. |
31 const CGFloat kLabelTextBottomSpacing = 4; | 31 const CGFloat kLabelTextBottomSpacing = 4; |
32 | 32 |
33 } // namespace | 33 } // namespace |
34 | 34 |
35 @implementation AvatarLabelButton | 35 @implementation AvatarLabelButton |
36 | 36 |
37 - (id)initWithFrame:(NSRect)frameRect { | 37 - (id)initWithFrame:(NSRect)frameRect { |
38 if ((self = [super initWithFrame:frameRect])) { | 38 if ((self = [super initWithFrame:frameRect])) { |
39 [self setBezelStyle:NSSmallSquareBezelStyle]; | 39 [self setBezelStyle:NSSmallSquareBezelStyle]; |
40 [self setTitle:l10n_util::GetNSString(IDS_MANAGED_USER_AVATAR_LABEL)]; | 40 [self setTitle:l10n_util::GetNSString(IDS_SUPERVISED_USER_AVATAR_LABEL)]; |
41 [self setFont:[NSFont labelFontOfSize:12.0]]; | 41 [self setFont:[NSFont labelFontOfSize:12.0]]; |
42 // Increase the frame by the size of the label to be displayed. | 42 // Increase the frame by the size of the label to be displayed. |
43 NSSize textSize = [[self cell] labelTextSize]; | 43 NSSize textSize = [[self cell] labelTextSize]; |
44 frameRect.size = NSMakeSize(frameRect.size.width + textSize.width, | 44 frameRect.size = NSMakeSize(frameRect.size.width + textSize.width, |
45 frameRect.size.height + textSize.height); | 45 frameRect.size.height + textSize.height); |
46 [self setFrame:frameRect]; | 46 [self setFrame:frameRect]; |
47 } | 47 } |
48 return self; | 48 return self; |
49 } | 49 } |
50 | 50 |
51 + (Class)cellClass { | 51 + (Class)cellClass { |
52 return [AvatarLabelButtonCell class]; | 52 return [AvatarLabelButtonCell class]; |
53 } | 53 } |
54 | 54 |
55 @end | 55 @end |
56 | 56 |
57 @implementation AvatarLabelButtonCell | 57 @implementation AvatarLabelButtonCell |
58 | 58 |
59 - (NSSize)labelTextSize { | 59 - (NSSize)labelTextSize { |
60 NSSize size = [[self attributedTitle] size]; | 60 NSSize size = [[self attributedTitle] size]; |
61 size.width += kLabelTextLeftSpacing + kLabelTextRightSpacing; | 61 size.width += kLabelTextLeftSpacing + kLabelTextRightSpacing; |
62 size.height += kLabelTextTopSpacing + kLabelTextBottomSpacing; | 62 size.height += kLabelTextTopSpacing + kLabelTextBottomSpacing; |
63 return size; | 63 return size; |
64 } | 64 } |
65 | 65 |
66 - (void)drawBezelWithFrame:(NSRect)frame inView:(NSView*)controlView { | 66 - (void)drawBezelWithFrame:(NSRect)frame inView:(NSView*)controlView { |
67 ui::NinePartImageIds imageIds = IMAGE_GRID(IDR_MANAGED_USER_LABEL); | 67 ui::NinePartImageIds imageIds = IMAGE_GRID(IDR_SUPERVISED_USER_LABEL); |
68 ui::DrawNinePartImage(frame, imageIds, NSCompositeSourceOver, 1.0, true); | 68 ui::DrawNinePartImage(frame, imageIds, NSCompositeSourceOver, 1.0, true); |
69 } | 69 } |
70 | 70 |
71 - (NSRect)titleRectForBounds:(NSRect)theRect { | 71 - (NSRect)titleRectForBounds:(NSRect)theRect { |
72 theRect.origin = NSMakePoint(kLabelTextLeftSpacing, kLabelTextBottomSpacing); | 72 theRect.origin = NSMakePoint(kLabelTextLeftSpacing, kLabelTextBottomSpacing); |
73 theRect.size = [[self attributedTitle] size]; | 73 theRect.size = [[self attributedTitle] size]; |
74 return theRect; | 74 return theRect; |
75 } | 75 } |
76 | 76 |
77 - (NSRect)drawTitle:(NSAttributedString*)title | 77 - (NSRect)drawTitle:(NSAttributedString*)title |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 path = [NSBezierPath bezierPathWithRoundedRect:backgroundRect | 126 path = [NSBezierPath bezierPathWithRoundedRect:backgroundRect |
127 xRadius:2.0 | 127 xRadius:2.0 |
128 yRadius:2.0]; | 128 yRadius:2.0]; |
129 [backgroundColor set]; | 129 [backgroundColor set]; |
130 [path fill]; | 130 [path fill]; |
131 } | 131 } |
132 [super drawInteriorWithFrame:cellFrame inView:controlView]; | 132 [super drawInteriorWithFrame:cellFrame inView:controlView]; |
133 } | 133 } |
134 | 134 |
135 @end | 135 @end |
OLD | NEW |