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/infobars/infobar_utilities.h" | 5 #import "chrome/browser/ui/cocoa/infobars/infobar_utilities.h" |
6 | 6 |
7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
8 #import "chrome/browser/infobars/infobar.h" | |
9 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 8 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
10 #import "chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h" | 9 #import "chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h" |
11 #import "chrome/browser/ui/cocoa/nsview_additions.h" | 10 #import "chrome/browser/ui/cocoa/nsview_additions.h" |
| 11 #import "components/infobars/core/infobar.h" |
12 | 12 |
13 @interface InfobarLabelTextField : NSTextField | 13 @interface InfobarLabelTextField : NSTextField |
14 @end | 14 @end |
15 | 15 |
16 @implementation InfobarLabelTextField | 16 @implementation InfobarLabelTextField |
17 | 17 |
18 - (void)drawRect:(NSRect)rect { | 18 - (void)drawRect:(NSRect)rect { |
19 NSView* infobarGradientView = [self superview]; | 19 NSView* infobarGradientView = [self superview]; |
20 [self cr_drawUsingAncestor:infobarGradientView inRect:rect]; | 20 [self cr_drawUsingAncestor:infobarGradientView inRect:rect]; |
21 [super drawRect:rect]; | 21 [super drawRect:rect]; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 // Vertically center |toMove| in its container. | 60 // Vertically center |toMove| in its container. |
61 void VerticallyCenterView(NSView* toMove) { | 61 void VerticallyCenterView(NSView* toMove) { |
62 NSRect superViewFrame = [[toMove superview] frame]; | 62 NSRect superViewFrame = [[toMove superview] frame]; |
63 NSRect viewFrame = [toMove frame]; | 63 NSRect viewFrame = [toMove frame]; |
64 // If the superview is the infobar view, then subtract out the anti-spoof | 64 // If the superview is the infobar view, then subtract out the anti-spoof |
65 // height so that the content is centered in the content area of the infobar, | 65 // height so that the content is centered in the content area of the infobar, |
66 // rather than in the total height (which includes the bulge). | 66 // rather than in the total height (which includes the bulge). |
67 CGFloat superHeight = NSHeight(superViewFrame); | 67 CGFloat superHeight = NSHeight(superViewFrame); |
68 if ([[toMove superview] isKindOfClass:[InfoBarGradientView class]]) | 68 if ([[toMove superview] isKindOfClass:[InfoBarGradientView class]]) |
69 superHeight = InfoBar::kDefaultBarTargetHeight; | 69 superHeight = infobars::InfoBar::kDefaultBarTargetHeight; |
70 viewFrame.origin.y = | 70 viewFrame.origin.y = |
71 floor((superHeight - NSHeight(viewFrame)) / 2.0); | 71 floor((superHeight - NSHeight(viewFrame)) / 2.0); |
72 [toMove setFrame:viewFrame]; | 72 [toMove setFrame:viewFrame]; |
73 } | 73 } |
74 | 74 |
75 // Creates a label control in the style we need for the infobar's labels | 75 // Creates a label control in the style we need for the infobar's labels |
76 // within |bounds|. | 76 // within |bounds|. |
77 NSTextField* CreateLabel(NSRect bounds) { | 77 NSTextField* CreateLabel(NSRect bounds) { |
78 NSTextField* ret = [[InfobarLabelTextField alloc] initWithFrame:bounds]; | 78 NSTextField* ret = [[InfobarLabelTextField alloc] initWithFrame:bounds]; |
79 [ret setEditable:NO]; | 79 [ret setEditable:NO]; |
(...skipping 16 matching lines...) Expand all Loading... |
96 [menu addItem:item]; | 96 [menu addItem:item]; |
97 [item setTarget:target]; | 97 [item setTarget:target]; |
98 if (checked) | 98 if (checked) |
99 [item setState:NSOnState]; | 99 [item setState:NSOnState]; |
100 if (!enabled) | 100 if (!enabled) |
101 [item setEnabled:NO]; | 101 [item setEnabled:NO]; |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 } // namespace InfoBarUtilities | 105 } // namespace InfoBarUtilities |
OLD | NEW |