OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import "chrome/browser/ui/cocoa/autofill/autofill_pop_up_button.h" | 5 #import "chrome/browser/ui/cocoa/autofill/autofill_pop_up_button.h" |
6 | 6 |
7 #include <ApplicationServices/ApplicationServices.h> | 7 #include <ApplicationServices/ApplicationServices.h> |
8 | 8 |
9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
10 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 10 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 @implementation AutofillPopUpCell | 81 @implementation AutofillPopUpCell |
82 | 82 |
83 @synthesize invalid = invalid_; | 83 @synthesize invalid = invalid_; |
84 @synthesize defaultValue = defaultValue_; | 84 @synthesize defaultValue = defaultValue_; |
85 | 85 |
86 // Draw a bezel that's highlighted. | 86 // Draw a bezel that's highlighted. |
87 - (void)drawBezelWithFrame:(NSRect)frame inView:(NSView*)controlView { | 87 - (void)drawBezelWithFrame:(NSRect)frame inView:(NSView*)controlView { |
88 [super drawBezelWithFrame:frame inView:controlView]; | 88 [super drawBezelWithFrame:frame inView:controlView]; |
89 if (invalid_) { | 89 if (invalid_) { |
90 // Mimic the rounded rect of default popup bezel in size, outline in red. | 90 // Mimic the rounded rect of default popup bezel in size, outline in red. |
91 NSBezierPath* path = [NSBezierPath | 91 NSRect outlineRect = NSOffsetRect(NSInsetRect(frame, 3.0, 3.5), -.5, -1.0); |
92 bezierPathWithRoundedRect: | 92 NSBezierPath* path = [NSBezierPath bezierPathWithRoundedRect:outlineRect |
93 NSOffsetRect( | 93 xRadius:3.5 |
94 NSInsetRect(NSIntegralRect(frame), 3.5, 3.5), -1.0, -1.0) | 94 yRadius:3.5]; |
95 xRadius:4.0 | |
96 yRadius:4.0]; | |
97 [path setLineWidth:0]; | 95 [path setLineWidth:0]; |
98 [[NSColor redColor] setStroke]; | 96 [[NSColor redColor] setStroke]; |
99 [path stroke]; | 97 [path stroke]; |
100 } | 98 } |
101 } | 99 } |
102 | 100 |
103 - (NSString*)fieldValue { | 101 - (NSString*)fieldValue { |
104 if (![self selectedItem]) | 102 if (![self selectedItem]) |
105 return defaultValue_; | 103 return defaultValue_; |
106 return [self titleOfSelectedItem]; | 104 return [self titleOfSelectedItem]; |
107 } | 105 } |
108 | 106 |
109 - (void)setFieldValue:(NSString*)fieldValue { | 107 - (void)setFieldValue:(NSString*)fieldValue { |
110 [self selectItemWithTitle:fieldValue]; | 108 [self selectItemWithTitle:fieldValue]; |
111 if (![self selectedItem]) | 109 if (![self selectedItem]) |
112 [self selectItemWithTitle:defaultValue_]; | 110 [self selectItemWithTitle:defaultValue_]; |
113 if (![self selectedItem]) | 111 if (![self selectedItem]) |
114 [self selectItemAtIndex:0]; | 112 [self selectItemAtIndex:0]; |
115 } | 113 } |
116 | 114 |
117 @end | 115 @end |
OLD | NEW |