Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / location_bar / autocomplete_text_field_cell.h
blobf8c4320d06d3c023f7dabfa5c12b12613b014e01
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.
5 #include <vector>
7 #import <Cocoa/Cocoa.h>
9 #include "base/mac/scoped_nsobject.h"
10 #import "chrome/browser/ui/cocoa/styled_text_field_cell.h"
12 @class AutocompleteTextField;
13 class LocationBarDecoration;
15 // AutocompleteTextFieldCell extends StyledTextFieldCell to provide support for
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
18 // search Engine" on the right-hand side), and keyword mode ("Search Engine:" in
19 // a button-like token on the left-hand side).
20 @interface AutocompleteTextFieldCell : StyledTextFieldCell {
21 @private
22 // Decorations which live to the left and right of the text, ordered
23 // from outside in. Decorations are owned by |LocationBarViewMac|.
24 std::vector<LocationBarDecoration*> leftDecorations_;
25 std::vector<LocationBarDecoration*> rightDecorations_;
27 // If YES then the text field will not draw a focus ring or show the insertion
28 // pointer.
29 BOOL hideFocusState_;
31 // YES if this field is shown in a popup window.
32 BOOL isPopupMode_;
34 // Retains the NSEvent that caused the controlView to become firstResponder.
35 base::scoped_nsobject<NSEvent> focusEvent_;
38 @property(assign, nonatomic) BOOL isPopupMode;
40 // Line height used for text in this cell.
41 - (CGFloat)lineHeight;
43 // Clear |leftDecorations_| and |rightDecorations_|.
44 - (void)clearDecorations;
46 // Add a new left-side decoration to the right of the existing
47 // left-side decorations.
48 - (void)addLeftDecoration:(LocationBarDecoration*)decoration;
50 // Add a new right-side decoration to the left of the existing
51 // right-side decorations.
52 - (void)addRightDecoration:(LocationBarDecoration*)decoration;
54 // The width available after accounting for decorations.
55 - (CGFloat)availableWidthInFrame:(const NSRect)frame;
57 // Return the frame for |aDecoration| if the cell is in |cellFrame|.
58 // Returns |NSZeroRect| for decorations which are not currently
59 // visible.
60 - (NSRect)frameForDecoration:(const LocationBarDecoration*)aDecoration
61 inFrame:(NSRect)cellFrame;
63 // Find the decoration under the event. |NULL| if |theEvent| is not
64 // over anything.
65 - (LocationBarDecoration*)decorationForEvent:(NSEvent*)theEvent
66 inRect:(NSRect)cellFrame
67 ofView:(AutocompleteTextField*)field;
69 // Return the appropriate menu for any decorations under event.
70 // Returns nil if no menu is present for the decoration, or if the
71 // event is not over a decoration.
72 - (NSMenu*)decorationMenuForEvent:(NSEvent*)theEvent
73 inRect:(NSRect)cellFrame
74 ofView:(AutocompleteTextField*)controlView;
76 // Called by |AutocompleteTextField| to let page actions intercept
77 // clicks. Returns |YES| if the click has been intercepted.
78 - (BOOL)mouseDown:(NSEvent*)theEvent
79 inRect:(NSRect)cellFrame
80 ofView:(AutocompleteTextField*)controlView;
82 // Overridden from StyledTextFieldCell to include decorations adjacent
83 // to the text area which don't handle mouse clicks themselves.
84 // Keyword-search bubble, for instance.
85 - (NSRect)textCursorFrameForFrame:(NSRect)cellFrame;
87 // Setup decoration tooltips on |controlView| by calling
88 // |-addToolTip:forRect:|.
89 - (void)updateToolTipsInRect:(NSRect)cellFrame
90 ofView:(AutocompleteTextField*)controlView;
92 // Gets and sets |hideFocusState|. This allows the text field to have focus but
93 // to appear unfocused.
94 - (BOOL)hideFocusState;
95 - (void)setHideFocusState:(BOOL)hideFocusState
96 ofView:(AutocompleteTextField*)controlView;
98 // Handles the |event| that caused |controlView| to become firstResponder.
99 - (void)handleFocusEvent:(NSEvent*)event
100 ofView:(AutocompleteTextField*)controlView;
101 @end