| 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 #include "base/mac/scoped_nsobject.h" |
| 10 #import "chrome/browser/ui/cocoa/styled_text_field_cell.h" | 10 #import "chrome/browser/ui/cocoa/styled_text_field_cell.h" |
| 11 | 11 |
| 12 @class AutocompleteTextField; | 12 @class AutocompleteTextField; |
| 13 class LocationBarDecoration; | 13 class LocationBarDecoration; |
| 14 | 14 |
| 15 // AutocompleteTextFieldCell extends StyledTextFieldCell to provide support for | 15 // AutocompleteTextFieldCell extends StyledTextFieldCell to provide support for |
| 16 // 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 |
| 17 // ("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 |
| 18 // 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 |
| 19 // a button-like token on the left-hand side). | 19 // a button-like token on the left-hand side). |
| 20 @interface AutocompleteTextFieldCell : StyledTextFieldCell { | 20 @interface AutocompleteTextFieldCell : StyledTextFieldCell { |
| 21 @private | 21 @private |
| 22 // 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 |
| 23 // from outside in. Decorations are owned by |LocationBarViewMac|. | 23 // from outside in. Decorations are owned by |LocationBarViewMac|. |
| 24 std::vector<LocationBarDecoration*> leftDecorations_; | 24 std::vector<LocationBarDecoration*> leftDecorations_; |
| 25 std::vector<LocationBarDecoration*> rightDecorations_; | 25 std::vector<LocationBarDecoration*> rightDecorations_; |
| 26 | 26 |
| 27 // Decorations with tracking areas attached to the AutocompleteTextField. |
| 28 std::vector<LocationBarDecoration*> mouseTrackingDecorations_; |
| 29 |
| 27 // If YES then the text field will not draw a focus ring or show the insertion | 30 // If YES then the text field will not draw a focus ring or show the insertion |
| 28 // pointer. | 31 // pointer. |
| 29 BOOL hideFocusState_; | 32 BOOL hideFocusState_; |
| 30 | 33 |
| 31 // YES if this field is shown in a popup window. | 34 // YES if this field is shown in a popup window. |
| 32 BOOL isPopupMode_; | 35 BOOL isPopupMode_; |
| 33 | 36 |
| 34 // Retains the NSEvent that caused the controlView to become firstResponder. | 37 // Retains the NSEvent that caused the controlView to become firstResponder. |
| 35 base::scoped_nsobject<NSEvent> focusEvent_; | 38 base::scoped_nsobject<NSEvent> focusEvent_; |
| 36 | 39 |
| 37 // The coordinate system line width that draws a single pixel line. | 40 // The coordinate system line width that draws a single pixel line. |
| 38 CGFloat singlePixelLineWidth_; | 41 CGFloat singlePixelLineWidth_; |
| 39 } | 42 } |
| 40 | 43 |
| 41 @property(assign, nonatomic) BOOL isPopupMode; | 44 @property(assign, nonatomic) BOOL isPopupMode; |
| 42 @property(assign, nonatomic) CGFloat singlePixelLineWidth; | 45 @property(assign, nonatomic) CGFloat singlePixelLineWidth; |
| 43 | 46 |
| 44 // Line height used for text in this cell. | 47 // Line height used for text in this cell. |
| 45 - (CGFloat)lineHeight; | 48 - (CGFloat)lineHeight; |
| 46 | 49 |
| 50 // Remove all of the tracking areas. |
| 51 - (void)clearTrackingArea; |
| 52 |
| 47 // Clear |leftDecorations_| and |rightDecorations_|. | 53 // Clear |leftDecorations_| and |rightDecorations_|. |
| 48 - (void)clearDecorations; | 54 - (void)clearDecorations; |
| 49 | 55 |
| 50 // Add a new left-side decoration to the right of the existing | 56 // Add a new left-side decoration to the right of the existing |
| 51 // left-side decorations. | 57 // left-side decorations. |
| 52 - (void)addLeftDecoration:(LocationBarDecoration*)decoration; | 58 - (void)addLeftDecoration:(LocationBarDecoration*)decoration; |
| 53 | 59 |
| 54 // Add a new right-side decoration to the left of the existing | 60 // Add a new right-side decoration to the left of the existing |
| 55 // right-side decorations. | 61 // right-side decorations. |
| 56 - (void)addRightDecoration:(LocationBarDecoration*)decoration; | 62 - (void)addRightDecoration:(LocationBarDecoration*)decoration; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 - (NSMenu*)decorationMenuForEvent:(NSEvent*)theEvent | 94 - (NSMenu*)decorationMenuForEvent:(NSEvent*)theEvent |
| 89 inRect:(NSRect)cellFrame | 95 inRect:(NSRect)cellFrame |
| 90 ofView:(AutocompleteTextField*)controlView; | 96 ofView:(AutocompleteTextField*)controlView; |
| 91 | 97 |
| 92 // Called by |AutocompleteTextField| to let page actions intercept | 98 // Called by |AutocompleteTextField| to let page actions intercept |
| 93 // clicks. Returns |YES| if the click has been intercepted. | 99 // clicks. Returns |YES| if the click has been intercepted. |
| 94 - (BOOL)mouseDown:(NSEvent*)theEvent | 100 - (BOOL)mouseDown:(NSEvent*)theEvent |
| 95 inRect:(NSRect)cellFrame | 101 inRect:(NSRect)cellFrame |
| 96 ofView:(AutocompleteTextField*)controlView; | 102 ofView:(AutocompleteTextField*)controlView; |
| 97 | 103 |
| 104 // Called by |AutocompleteTextField| to pass the mouse up event to the omnibox |
| 105 // decorations. |
| 106 - (void)mouseUp:(NSEvent*)theEvent |
| 107 inRect:(NSRect)cellFrame |
| 108 ofView:(AutocompleteTextField*)controlView; |
| 109 |
| 98 // Overridden from StyledTextFieldCell to include decorations adjacent | 110 // Overridden from StyledTextFieldCell to include decorations adjacent |
| 99 // to the text area which don't handle mouse clicks themselves. | 111 // to the text area which don't handle mouse clicks themselves. |
| 100 // Keyword-search bubble, for instance. | 112 // Keyword-search bubble, for instance. |
| 101 - (NSRect)textCursorFrameForFrame:(NSRect)cellFrame; | 113 - (NSRect)textCursorFrameForFrame:(NSRect)cellFrame; |
| 102 | 114 |
| 103 // Setup decoration tooltips on |controlView| by calling | 115 // Setup decoration tooltips and mouse tracking on |controlView| by calling |
| 104 // |-addToolTip:forRect:|. | 116 // |-addToolTip:forRect:| and |SetupTrackingArea()|. |
| 105 - (void)updateToolTipsInRect:(NSRect)cellFrame | 117 - (void)updateMouseTrackingAndToolTipsInRect:(NSRect)cellFrame |
| 106 ofView:(AutocompleteTextField*)controlView; | 118 ofView: |
| 119 (AutocompleteTextField*)controlView; |
| 107 | 120 |
| 108 // Gets and sets |hideFocusState|. This allows the text field to have focus but | 121 // Gets and sets |hideFocusState|. This allows the text field to have focus but |
| 109 // to appear unfocused. | 122 // to appear unfocused. |
| 110 - (BOOL)hideFocusState; | 123 - (BOOL)hideFocusState; |
| 111 - (void)setHideFocusState:(BOOL)hideFocusState | 124 - (void)setHideFocusState:(BOOL)hideFocusState |
| 112 ofView:(AutocompleteTextField*)controlView; | 125 ofView:(AutocompleteTextField*)controlView; |
| 113 | 126 |
| 114 // Handles the |event| that caused |controlView| to become firstResponder. | 127 // Handles the |event| that caused |controlView| to become firstResponder. |
| 115 - (void)handleFocusEvent:(NSEvent*)event | 128 - (void)handleFocusEvent:(NSEvent*)event |
| 116 ofView:(AutocompleteTextField*)controlView; | 129 ofView:(AutocompleteTextField*)controlView; |
| 117 @end | 130 @end |
| 131 |
| 132 // Methods which are either only for testing, or only public for testing. |
| 133 @interface AutocompleteTextFieldCell (TestingAPI) |
| 134 |
| 135 // Returns |mouseTrackingDecorations_|. |
| 136 - (const std::vector<LocationBarDecoration*>&)mouseTrackingDecorations; |
| 137 |
| 138 @end |
| OLD | NEW |