| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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. | |
| 4 | |
| 5 #import "chrome/browser/ui/cocoa/wrench_menu_button_cell.h" | |
| 6 | |
| 7 #include "base/scoped_nsobject.h" | |
| 8 | |
| 9 @implementation WrenchMenuButtonCell | |
| 10 | |
| 11 - (void)drawBezelWithFrame:(NSRect)frame inView:(NSView*)controlView { | |
| 12 [NSGraphicsContext saveGraphicsState]; | |
| 13 | |
| 14 // Inset the rect to match the appearance of the layout of interface builder. | |
| 15 // The bounding rect of buttons is actually larger than the display rect shown | |
| 16 // there. | |
| 17 frame = NSInsetRect(frame, 0.0, 1.0); | |
| 18 | |
| 19 // Stroking the rect gives a weak stroke. Filling and insetting gives a | |
| 20 // strong, un-anti-aliased border. | |
| 21 [[NSColor colorWithDeviceWhite:0.663 alpha:1.0] set]; | |
| 22 NSRectFill(frame); | |
| 23 frame = NSInsetRect(frame, 1.0, 1.0); | |
| 24 | |
| 25 // The default state should be a subtle gray gradient. | |
| 26 if (![self isHighlighted]) { | |
| 27 NSColor* end = [NSColor colorWithDeviceWhite:0.922 alpha:1.0]; | |
| 28 scoped_nsobject<NSGradient> gradient( | |
| 29 [[NSGradient alloc] initWithStartingColor:[NSColor whiteColor] | |
| 30 endingColor:end]); | |
| 31 [gradient drawInRect:frame angle:90.0]; | |
| 32 } else { | |
| 33 // |+selectedMenuItemColor| appears to be a gradient, so just filling the | |
| 34 // rect with that color produces the desired effect. | |
| 35 [[NSColor selectedMenuItemColor] set]; | |
| 36 NSRectFill(frame); | |
| 37 } | |
| 38 | |
| 39 [NSGraphicsContext restoreGraphicsState]; | |
| 40 } | |
| 41 | |
| 42 - (NSBackgroundStyle)interiorBackgroundStyle { | |
| 43 if ([self isHighlighted]) | |
| 44 return NSBackgroundStyleDark; | |
| 45 return [super interiorBackgroundStyle]; | |
| 46 } | |
| 47 | |
| 48 @end | |
| OLD | NEW |