1 // Copyright (c) 2011 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/wrench_menu/wrench_menu_button_cell.h"
7 #include "base/mac/scoped_nsobject.h"
8 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
10 @implementation WrenchMenuButtonCell
12 - (void)drawBezelWithFrame:(NSRect)frame inView:(NSView*)controlView {
13 gfx::ScopedNSGraphicsContextSaveGState scopedGState;
15 // Inset the rect to match the appearance of the layout of interface builder.
16 // The bounding rect of buttons is actually larger than the display rect shown
18 frame = NSInsetRect(frame, 0.0, 1.0);
20 // Stroking the rect gives a weak stroke. Filling and insetting gives a
21 // strong, un-anti-aliased border.
22 [[NSColor colorWithDeviceWhite:0.663 alpha:1.0] set];
24 frame = NSInsetRect(frame, 1.0, 1.0);
26 // The default state should be a subtle gray gradient.
27 if (![self isHighlighted]) {
28 NSColor* end = [NSColor colorWithDeviceWhite:0.922 alpha:1.0];
29 base::scoped_nsobject<NSGradient> gradient(
30 [[NSGradient alloc] initWithStartingColor:[NSColor whiteColor]
32 [gradient drawInRect:frame angle:90.0];
34 // |+selectedMenuItemColor| appears to be a gradient, so just filling the
35 // rect with that color produces the desired effect.
36 [[NSColor selectedMenuItemColor] set];
41 - (NSBackgroundStyle)interiorBackgroundStyle {
42 if ([self isHighlighted])
43 return NSBackgroundStyleDark;
44 return [super interiorBackgroundStyle];