| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 #include <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/mac/scoped_nsobject.h" |
| 9 #import "chrome/browser/ui/cocoa/styled_text_field_cell.h" | 10 #import "chrome/browser/ui/cocoa/styled_text_field_cell.h" |
| 10 | 11 |
| 11 @class AutocompleteTextField; | 12 @class AutocompleteTextField; |
| 12 class LocationBarDecoration; | 13 class LocationBarDecoration; |
| 13 | 14 |
| 14 // AutocompleteTextFieldCell extends StyledTextFieldCell to provide support for | 15 // AutocompleteTextFieldCell extends StyledTextFieldCell to provide support for |
| 15 // certain decorations to be applied to the field. These are the search hint | 16 // certain decorations to be applied to the field. These are the search hint |
| 16 // ("Type to search" on the right-hand side), the keyword hint ("Press [Tab] to | 17 // ("Type to search" on the right-hand side), the keyword hint ("Press [Tab] to |
| 17 // search Engine" on the right-hand side), and keyword mode ("Search Engine:" in | 18 // search Engine" on the right-hand side), and keyword mode ("Search Engine:" in |
| 18 // a button-like token on the left-hand side). | 19 // a button-like token on the left-hand side). |
| 19 @interface AutocompleteTextFieldCell : StyledTextFieldCell { | 20 @interface AutocompleteTextFieldCell : StyledTextFieldCell { |
| 20 @private | 21 @private |
| 21 // Decorations which live to the left and right of the text, ordered | 22 // Decorations which live to the left and right of the text, ordered |
| 22 // from outside in. Decorations are owned by |LocationBarViewMac|. | 23 // from outside in. Decorations are owned by |LocationBarViewMac|. |
| 23 std::vector<LocationBarDecoration*> leftDecorations_; | 24 std::vector<LocationBarDecoration*> leftDecorations_; |
| 24 std::vector<LocationBarDecoration*> rightDecorations_; | 25 std::vector<LocationBarDecoration*> rightDecorations_; |
| 25 | 26 |
| 26 // If YES then the text field will not draw a focus ring or show the insertion | 27 // If YES then the text field will not draw a focus ring or show the insertion |
| 27 // pointer. | 28 // pointer. |
| 28 BOOL hideFocusState_; | 29 BOOL hideFocusState_; |
| 29 | 30 |
| 30 // YES if this field is shown in a popup window. | 31 // YES if this field is shown in a popup window. |
| 31 BOOL isPopupMode_; | 32 BOOL isPopupMode_; |
| 33 |
| 34 // Retains the NSEvent that caused the controlView to become firstResponder. |
| 35 base::scoped_nsobject<NSEvent> focusEvent_; |
| 32 } | 36 } |
| 33 | 37 |
| 34 @property(assign, nonatomic) BOOL isPopupMode; | 38 @property(assign, nonatomic) BOOL isPopupMode; |
| 35 | 39 |
| 36 // Line height used for text in this cell. | 40 // Line height used for text in this cell. |
| 37 - (CGFloat)lineHeight; | 41 - (CGFloat)lineHeight; |
| 38 | 42 |
| 39 // Clear |leftDecorations_| and |rightDecorations_|. | 43 // Clear |leftDecorations_| and |rightDecorations_|. |
| 40 - (void)clearDecorations; | 44 - (void)clearDecorations; |
| 41 | 45 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // |-addToolTip:forRect:|. | 100 // |-addToolTip:forRect:|. |
| 97 - (void)updateToolTipsInRect:(NSRect)cellFrame | 101 - (void)updateToolTipsInRect:(NSRect)cellFrame |
| 98 ofView:(AutocompleteTextField*)controlView; | 102 ofView:(AutocompleteTextField*)controlView; |
| 99 | 103 |
| 100 // Gets and sets |hideFocusState|. This allows the text field to have focus but | 104 // Gets and sets |hideFocusState|. This allows the text field to have focus but |
| 101 // to appear unfocused. | 105 // to appear unfocused. |
| 102 - (BOOL)hideFocusState; | 106 - (BOOL)hideFocusState; |
| 103 - (void)setHideFocusState:(BOOL)hideFocusState | 107 - (void)setHideFocusState:(BOOL)hideFocusState |
| 104 ofView:(AutocompleteTextField*)controlView; | 108 ofView:(AutocompleteTextField*)controlView; |
| 105 | 109 |
| 110 // Handles the |event| that caused |controlView| to become firstResponder. |
| 111 // If it is a mouse click on a ButtonDecoration, focus notifications are |
| 112 // postponed until the ButtonDecoration's OnMousePressed() was invoked. |
| 113 // Otherwise, they are called immediately. |
| 114 - (void)handleFocusEvent:(NSEvent*)event |
| 115 ofView:(AutocompleteTextField*)controlView; |
| 106 @end | 116 @end |
| OLD | NEW |