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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #import "chrome/browser/cocoa/styled_text_field_cell.h" | 7 #import "chrome/browser/cocoa/styled_text_field_cell.h" |
8 | 8 |
9 #include "base/scoped_nsobject.h" | 9 #include "base/scoped_nsobject.h" |
10 #include "chrome/browser/cocoa/location_bar/location_bar_view_mac.h" | 10 #include "chrome/browser/cocoa/location_bar/location_bar_view_mac.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 @end | 47 @end |
48 | 48 |
49 // AutocompleteTextFieldCell extends StyledTextFieldCell to provide support for | 49 // AutocompleteTextFieldCell extends StyledTextFieldCell to provide support for |
50 // certain decorations to be applied to the field. These are the search hint | 50 // certain decorations to be applied to the field. These are the search hint |
51 // ("Type to search" on the right-hand side), the keyword hint ("Press [Tab] to | 51 // ("Type to search" on the right-hand side), the keyword hint ("Press [Tab] to |
52 // search Engine" on the right-hand side), and keyword mode ("Search Engine:" in | 52 // search Engine" on the right-hand side), and keyword mode ("Search Engine:" in |
53 // a button-like token on the left-hand side). | 53 // a button-like token on the left-hand side). |
54 @interface AutocompleteTextFieldCell : StyledTextFieldCell { | 54 @interface AutocompleteTextFieldCell : StyledTextFieldCell { |
55 @private | 55 @private |
56 // Decorations which live to the left of the text. Owned by | 56 // Decorations which live to the left and right of the text, ordered |
57 // |LocationBarViewMac|. | 57 // from outside in. Decorations are owned by |LocationBarViewMac|. |
58 std::vector<LocationBarDecoration*> leftDecorations_; | 58 std::vector<LocationBarDecoration*> leftDecorations_; |
| 59 std::vector<LocationBarDecoration*> rightDecorations_; |
59 | 60 |
60 // Set if there is a string to display as a hint on the right-hand | 61 // Set if there is a string to display as a hint on the right-hand |
61 // side of the field. Exclusive WRT |keywordString_|; | 62 // side of the field. Exclusive WRT |keywordString_|; |
62 scoped_nsobject<NSAttributedString> hintString_; | 63 scoped_nsobject<NSAttributedString> hintString_; |
63 | 64 |
64 // The star icon sits at the right-hand side of the field when an | |
65 // URL is being shown. | |
66 LocationBarViewMac::LocationBarImageView* starIconView_; | |
67 | |
68 // List of views showing visible Page Actions. Owned by the location bar. | 65 // List of views showing visible Page Actions. Owned by the location bar. |
69 // Display is exclusive WRT the |hintString_| and |keywordString_|. | 66 // Display is exclusive WRT the |hintString_| and |keywordString_|. |
70 // This may be NULL during testing. | 67 // This may be NULL during testing. |
71 LocationBarViewMac::PageActionViewList* page_action_views_; | 68 LocationBarViewMac::PageActionViewList* page_action_views_; |
72 | 69 |
73 // List of content blocked icons. This may be NULL during testing. | 70 // List of content blocked icons. This may be NULL during testing. |
74 LocationBarViewMac::ContentSettingViews* content_setting_views_; | 71 LocationBarViewMac::ContentSettingViews* content_setting_views_; |
75 } | 72 } |
76 | 73 |
77 // Chooses |anImage| only if all pieces won't fit w/in |width|. | 74 // Chooses |anImage| only if all pieces won't fit w/in |width|. |
78 // Inputs must be non-nil. | 75 // Inputs must be non-nil. |
79 - (void)setKeywordHintPrefix:(NSString*)prefixString | 76 - (void)setKeywordHintPrefix:(NSString*)prefixString |
80 image:(NSImage*)anImage | 77 image:(NSImage*)anImage |
81 suffix:(NSString*)suffixString | 78 suffix:(NSString*)suffixString |
82 availableWidth:(CGFloat)width; | 79 availableWidth:(CGFloat)width; |
83 | 80 |
84 // Suppresses hint entirely if |aString| won't fit w/in |width|. | 81 // Suppresses hint entirely if |aString| won't fit w/in |width|. |
85 // String must be non-nil. | 82 // String must be non-nil. |
86 - (void)setSearchHintString:(NSString*)aString | 83 - (void)setSearchHintString:(NSString*)aString |
87 availableWidth:(CGFloat)width; | 84 availableWidth:(CGFloat)width; |
88 - (void)clearHint; | 85 - (void)clearHint; |
89 | 86 |
90 // Clear |leftDecorations_|. | 87 // Clear |leftDecorations_| and |rightDecorations_|. |
91 - (void)clearDecorations; | 88 - (void)clearDecorations; |
92 | 89 |
93 // Add a new left-side decoration to the right of the existing | 90 // Add a new left-side decoration to the right of the existing |
94 // left-side decorations. | 91 // left-side decorations. |
95 - (void)addLeftDecoration:(LocationBarDecoration*)decoration; | 92 - (void)addLeftDecoration:(LocationBarDecoration*)decoration; |
96 | 93 |
| 94 // Add a new right-side decoration to the left of the existing |
| 95 // right-side decorations. |
| 96 - (void)addRightDecoration:(LocationBarDecoration*)decoration; |
| 97 |
97 // The width available after accounting for decorations. | 98 // The width available after accounting for decorations. |
98 - (CGFloat)availableWidthInFrame:(const NSRect)frame; | 99 - (CGFloat)availableWidthInFrame:(const NSRect)frame; |
99 | 100 |
100 - (void)setStarIconView:(LocationBarViewMac::LocationBarImageView*)view; | |
101 - (void)setPageActionViewList:(LocationBarViewMac::PageActionViewList*)list; | 101 - (void)setPageActionViewList:(LocationBarViewMac::PageActionViewList*)list; |
102 - (void)setContentSettingViewsList: | 102 - (void)setContentSettingViewsList: |
103 (LocationBarViewMac::ContentSettingViews*)views; | 103 (LocationBarViewMac::ContentSettingViews*)views; |
104 | 104 |
105 // Returns an array of the visible AutocompleteTextFieldIcon objects. Returns | 105 // Returns an array of the visible AutocompleteTextFieldIcon objects. Returns |
106 // only visible icons. | 106 // only visible icons. |
107 - (NSArray*)layedOutIcons:(NSRect)cellFrame; | 107 - (NSArray*)layedOutIcons:(NSRect)cellFrame; |
108 | 108 |
109 // Return the rectangle the star is being shown in, for purposes of | |
110 // positioning the bookmark bubble. | |
111 - (NSRect)starIconFrameForFrame:(NSRect)cellFrame; | |
112 | |
113 // Return the frame for |aDecoration| if the cell is in |cellFrame|. | 109 // Return the frame for |aDecoration| if the cell is in |cellFrame|. |
114 // Returns |NSZeroRect| for decorations which are not currently | 110 // Returns |NSZeroRect| for decorations which are not currently |
115 // visible. | 111 // visible. |
116 - (NSRect)frameForDecoration:(const LocationBarDecoration*)aDecoration | 112 - (NSRect)frameForDecoration:(const LocationBarDecoration*)aDecoration |
117 inFrame:(NSRect)cellFrame; | 113 inFrame:(NSRect)cellFrame; |
118 | 114 |
119 // Returns the portion of the cell to use for displaying the Page | 115 // Returns the portion of the cell to use for displaying the Page |
120 // Action icon at the given index. May be NSZeroRect if the index's | 116 // Action icon at the given index. May be NSZeroRect if the index's |
121 // action is not visible. This does a linear walk over all page | 117 // action is not visible. This does a linear walk over all page |
122 // actions, so do not call this in a loop to get the position of all | 118 // actions, so do not call this in a loop to get the position of all |
(...skipping 29 matching lines...) Expand all Loading... |
152 // Internal methods here exposed for unit testing. | 148 // Internal methods here exposed for unit testing. |
153 @interface AutocompleteTextFieldCell (UnitTesting) | 149 @interface AutocompleteTextFieldCell (UnitTesting) |
154 | 150 |
155 @property(nonatomic, readonly) NSAttributedString* hintString; | 151 @property(nonatomic, readonly) NSAttributedString* hintString; |
156 @property(nonatomic, readonly) NSAttributedString* hintIconLabel; | 152 @property(nonatomic, readonly) NSAttributedString* hintIconLabel; |
157 | 153 |
158 // Returns the total number of installed Page Actions, visible or not. | 154 // Returns the total number of installed Page Actions, visible or not. |
159 - (size_t)pageActionCount; | 155 - (size_t)pageActionCount; |
160 | 156 |
161 @end | 157 @end |
OLD | NEW |