Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / location_bar / autocomplete_text_field_cell.h
bloba59dbca1ccefbd6067cbb0681e34d0410b903b89
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 // These messages are passed down from the AutocompleteTextField, where they are
83 // received from tracking areas registered for decorations that act as buttons.
84 - (void)mouseEntered:(NSEvent*)theEvent
85 inView:(AutocompleteTextField*)controlView;
86 - (void)mouseExited:(NSEvent*)theEvent
87 inView:(AutocompleteTextField*)controlView;
89 // Setup tracking areas for the decorations that are part of this cell, so they
90 // can receive |mouseEntered:| and |mouseExited:| events.
91 - (void)setUpTrackingAreasInRect:(NSRect)frame
92 ofView:(AutocompleteTextField*)view;
94 // Overridden from StyledTextFieldCell to include decorations adjacent
95 // to the text area which don't handle mouse clicks themselves.
96 // Keyword-search bubble, for instance.
97 - (NSRect)textCursorFrameForFrame:(NSRect)cellFrame;
99 // Setup decoration tooltips on |controlView| by calling
100 // |-addToolTip:forRect:|.
101 - (void)updateToolTipsInRect:(NSRect)cellFrame
102 ofView:(AutocompleteTextField*)controlView;
104 // Gets and sets |hideFocusState|. This allows the text field to have focus but
105 // to appear unfocused.
106 - (BOOL)hideFocusState;
107 - (void)setHideFocusState:(BOOL)hideFocusState
108 ofView:(AutocompleteTextField*)controlView;
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;
116 @end