OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "chrome/browser/ui/cocoa/autofill/down_arrow_popup_menu_cell.h" | 5 #include "chrome/browser/ui/cocoa/autofill/down_arrow_popup_menu_cell.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h" | 9 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h" |
10 | 10 |
11 @implementation DownArrowPopupMenuCell | 11 @implementation DownArrowPopupMenuCell |
12 | 12 |
13 - (NSSize)imageSize { | 13 - (NSSize)imageSize { |
14 image_button_cell::ButtonState state = image_button_cell::kDefaultState; | 14 image_button_cell::ButtonState state = image_button_cell::kDefaultState; |
15 NSView* controlView = [self controlView]; | 15 NSView* controlView = [self controlView]; |
16 NSImage* image = [self imageForState:state view:controlView]; | 16 NSImage* image = [self imageForState:state view:controlView]; |
17 return [image size]; | 17 return [image size]; |
18 } | 18 } |
19 | 19 |
20 - (NSSize)cellSize { | 20 - (NSSize)cellSize { |
21 NSSize imageSize = [self imageSize]; | 21 NSSize imageSize = [self imageSize]; |
22 | 22 |
23 NSAttributedString* title = [self attributedTitle]; | 23 NSAttributedString* title = [self attributedTitle]; |
24 NSSize size = [title size]; | 24 NSSize size = [title size]; |
25 size.height = std::max(size.height, imageSize.height); | 25 size.height = std::max(size.height, imageSize.height); |
26 size.width += kButtonGap + imageSize.width; | 26 size.width += autofill::kButtonGap + imageSize.width; |
27 | 27 |
28 return size; | 28 return size; |
29 } | 29 } |
30 | 30 |
31 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { | 31 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { |
32 NSRect imageRect, titleRect; | 32 NSRect imageRect, titleRect; |
33 NSDivideRect( | 33 NSDivideRect( |
34 cellFrame, &imageRect, &titleRect, [self imageSize].width, NSMaxXEdge); | 34 cellFrame, &imageRect, &titleRect, [self imageSize].width, NSMaxXEdge); |
35 [super drawWithFrame:imageRect inView:controlView]; | 35 [super drawWithFrame:imageRect inView:controlView]; |
36 | 36 |
37 NSAttributedString* title = [self attributedTitle]; | 37 NSAttributedString* title = [self attributedTitle]; |
38 if ([title length]) | 38 if ([title length]) |
39 [self drawTitle:title withFrame:titleRect inView:controlView]; | 39 [self drawTitle:title withFrame:titleRect inView:controlView]; |
40 } | 40 } |
41 | 41 |
42 @end | 42 @end |
43 | 43 |
OLD | NEW |