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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/cocoa/autofill/down_arrow_popup_menu_cell.h"
9 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h"
11 const int kSidePadding = 2.0;
13 @implementation DownArrowPopupMenuCell
16 image_button_cell::ButtonState state = image_button_cell::kDefaultState;
17 NSView* controlView = [self controlView];
18 NSImage* image = [self imageForState:state view:controlView];
23 NSSize imageSize = [self imageSize];
25 NSAttributedString* title = [self attributedTitle];
26 NSSize size = [title size];
27 size.height = std::max(size.height, imageSize.height);
28 size.width += 2 * kSidePadding + autofill::kButtonGap + imageSize.width;
33 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
34 NSRect imageRect, titleRect;
35 NSRect contentRect = NSInsetRect(cellFrame, kSidePadding, 0);
37 contentRect, &imageRect, &titleRect, [self imageSize].width, NSMaxXEdge);
38 [super drawImageWithFrame:imageRect inView:controlView];
40 NSAttributedString* title = [self attributedTitle];
42 [self drawTitle:title withFrame:titleRect inView:controlView];
44 // Only draw custom focus ring if the 10.7 focus ring APIs are not available.
45 // TODO(groby): Remove once we build against the 10.7 SDK.
46 if (![self respondsToSelector:@selector(drawFocusRingMaskWithFrame:inView:)])
47 [super drawFocusRingWithFrame:cellFrame inView:controlView];