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/constrained_window/constrained_window_button.h" | 5 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" |
6 | 6 |
7 #include "base/memory/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
8 #import "chrome/browser/ui/cocoa/key_equivalent_constants.h" | 8 #import "chrome/browser/ui/cocoa/key_equivalent_constants.h" |
9 #include "skia/ext/skia_utils_mac.h" | 9 #include "skia/ext/skia_utils_mac.h" |
10 #import "third_party/molokocacao/NSBezierPath+MCAdditions.h" | 10 #import "third_party/molokocacao/NSBezierPath+MCAdditions.h" |
11 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 11 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 enum ButtonState { | 15 enum ButtonState { |
16 BUTTON_NORMAL, | 16 BUTTON_NORMAL, |
17 BUTTON_HOVER, | 17 BUTTON_HOVER, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 NSAttributedString* GetButtonAttributedString(NSString* title, | 82 NSAttributedString* GetButtonAttributedString(NSString* title, |
83 NSString* key_equivalent, | 83 NSString* key_equivalent, |
84 ButtonState button_state) { | 84 ButtonState button_state) { |
85 const SkColor text_color[] = {0xFF333333, 0XFF000000, 0xFF000000, 0xFFAAAAAA}; | 85 const SkColor text_color[] = {0xFF333333, 0XFF000000, 0xFF000000, 0xFFAAAAAA}; |
86 // The shadow color should be 0xFFF0F0F0 but that doesn't show up so use | 86 // The shadow color should be 0xFFF0F0F0 but that doesn't show up so use |
87 // pure white instead. | 87 // pure white instead. |
88 const SkColor shadow_color[] = | 88 const SkColor shadow_color[] = |
89 {0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF}; | 89 {0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF}; |
90 | 90 |
91 scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); | 91 base::scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); |
92 [shadow setShadowColor: | 92 [shadow setShadowColor: |
93 gfx::SkColorToCalibratedNSColor(shadow_color[button_state])]; | 93 gfx::SkColorToCalibratedNSColor(shadow_color[button_state])]; |
94 [shadow setShadowOffset:NSMakeSize(0, -1)]; | 94 [shadow setShadowOffset:NSMakeSize(0, -1)]; |
95 [shadow setShadowBlurRadius:0]; | 95 [shadow setShadowBlurRadius:0]; |
96 | 96 |
97 scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( | 97 base::scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( |
98 [[NSMutableParagraphStyle alloc] init]); | 98 [[NSMutableParagraphStyle alloc] init]); |
99 [paragraphStyle setAlignment:NSCenterTextAlignment]; | 99 [paragraphStyle setAlignment:NSCenterTextAlignment]; |
100 | 100 |
101 NSFont* font = nil; | 101 NSFont* font = nil; |
102 if ([key_equivalent isEqualToString:kKeyEquivalentReturn]) | 102 if ([key_equivalent isEqualToString:kKeyEquivalentReturn]) |
103 font = [NSFont boldSystemFontOfSize:12]; | 103 font = [NSFont boldSystemFontOfSize:12]; |
104 else | 104 else |
105 font = [NSFont systemFontOfSize:12]; | 105 font = [NSFont systemFontOfSize:12]; |
106 | 106 |
107 NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys: | 107 NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys: |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 if (![self isEnabled]) | 238 if (![self isEnabled]) |
239 return BUTTON_DISABLED; | 239 return BUTTON_DISABLED; |
240 if ([self isHighlighted]) | 240 if ([self isHighlighted]) |
241 return BUTTON_PRESSED; | 241 return BUTTON_PRESSED; |
242 if (isMouseInside_) | 242 if (isMouseInside_) |
243 return BUTTON_HOVER; | 243 return BUTTON_HOVER; |
244 return BUTTON_NORMAL; | 244 return BUTTON_NORMAL; |
245 } | 245 } |
246 | 246 |
247 @end | 247 @end |
OLD | NEW |