OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "base/scoped_nsobject.h" | 7 #include "base/scoped_nsobject.h" |
8 | 8 |
9 // AutocompleteTextFieldCell customizes the look of the Omnibox text | 9 // AutocompleteTextFieldCell customizes the look of the Omnibox text |
10 // field. The border and focus ring are modified, as is the font | 10 // field. The border and focus ring are modified, as is the font |
11 // baseline. | 11 // baseline. |
12 | 12 |
13 // The cell also provides support for certain decorations to be | 13 // The cell also provides support for certain decorations to be |
14 // applied to the field. These are the search hint ("Type to search" | 14 // applied to the field. These are the search hint ("Type to search" |
15 // on the right-hand side), the keyword hint ("Press [Tab] to search | 15 // on the right-hand side), the keyword hint ("Press [Tab] to search |
16 // Engine" on the right-hand side), and keyword mode ("Search Engine:" | 16 // Engine" on the right-hand side), and keyword mode ("Search Engine:" |
17 // in a button-like token on the left-hand side). | 17 // in a button-like token on the left-hand side). |
18 // | |
19 // The cell arranges the field-editor's placement via the standard | |
20 // -editWithFrame:* and -selectWithFrame:* methods. When the visible | |
21 // decoration changes, the cell's look may change, and if the cell is | |
22 // currently being edited the field editor will require adjustment. | |
23 // The cell signals this requirement by returning YES for | |
24 // -fieldEditorNeedsReset, which is used by AutocompleteTextField's | |
25 // -resetFieldEditorFrameIfNeeded in testing if re-layout is needed. | |
26 | 18 |
27 @interface AutocompleteTextFieldCell : NSTextFieldCell { | 19 @interface AutocompleteTextFieldCell : NSTextFieldCell { |
28 @private | 20 @private |
29 // Set if there is a string to display in a rounded rect on the | 21 // Set if there is a string to display in a rounded rect on the |
30 // left-hand side of the field. Exclusive WRT |hintString_|. | 22 // left-hand side of the field. Exclusive WRT |hintString_|. |
31 scoped_nsobject<NSAttributedString> keywordString_; | 23 scoped_nsobject<NSAttributedString> keywordString_; |
32 | 24 |
33 // Set if there is a string to display as a hint on the right-hand | 25 // Set if there is a string to display as a hint on the right-hand |
34 // side of the field. Exclusive WRT |keywordString_|; | 26 // side of the field. Exclusive WRT |keywordString_|; |
35 scoped_nsobject<NSAttributedString> hintString_; | 27 scoped_nsobject<NSAttributedString> hintString_; |
36 | 28 |
37 // YES if the info cell has been changed in a way which would result | |
38 // in the cell needing to be laid out again. | |
39 BOOL fieldEditorNeedsReset_; | |
40 | |
41 // Icon that represents the state of the SSL connection | 29 // Icon that represents the state of the SSL connection |
42 scoped_nsobject<NSImage> hintIcon_; | 30 scoped_nsobject<NSImage> hintIcon_; |
43 | 31 |
44 // Optional text that appears to the right of the hint icon which | 32 // Optional text that appears to the right of the hint icon which |
45 // appears only alongside the icon (i.e., it's possible to display a | 33 // appears only alongside the icon (i.e., it's possible to display a |
46 // hintIcon without an hintIconLabel, but not vice-versa). | 34 // hintIcon without an hintIconLabel, but not vice-versa). |
47 scoped_nsobject<NSAttributedString> hintIconLabel_; | 35 scoped_nsobject<NSAttributedString> hintIconLabel_; |
48 } | 36 } |
49 | 37 |
50 @property BOOL fieldEditorNeedsReset; | |
51 | |
52 // The following setup |keywordString_| or |hintString_| based on the | |
53 // input, and set |fieldEditorNeedsReset_| if the layout of the field | |
54 // changed. | |
55 | |
56 // Chooses |partialString| if |width| won't fit |fullString|. Strings | 38 // Chooses |partialString| if |width| won't fit |fullString|. Strings |
57 // must be non-nil. | 39 // must be non-nil. |
58 - (void)setKeywordString:(NSString*)fullString | 40 - (void)setKeywordString:(NSString*)fullString |
59 partialString:(NSString*)partialString | 41 partialString:(NSString*)partialString |
60 availableWidth:(CGFloat)width; | 42 availableWidth:(CGFloat)width; |
61 | 43 |
62 // Chooses |anImage| only if all pieces won't fit w/in |width|. | 44 // Chooses |anImage| only if all pieces won't fit w/in |width|. |
63 // Inputs must be non-nil. | 45 // Inputs must be non-nil. |
64 - (void)setKeywordHintPrefix:(NSString*)prefixString | 46 - (void)setKeywordHintPrefix:(NSString*)prefixString |
65 image:(NSImage*)anImage | 47 image:(NSImage*)anImage |
(...skipping 24 matching lines...) Expand all Loading... |
90 | 72 |
91 // Internal methods here exposed for unit testing. | 73 // Internal methods here exposed for unit testing. |
92 @interface AutocompleteTextFieldCell (UnitTesting) | 74 @interface AutocompleteTextFieldCell (UnitTesting) |
93 | 75 |
94 @property(readonly) NSAttributedString* keywordString; | 76 @property(readonly) NSAttributedString* keywordString; |
95 @property(readonly) NSAttributedString* hintString; | 77 @property(readonly) NSAttributedString* hintString; |
96 @property(readonly) NSImage* hintIcon; | 78 @property(readonly) NSImage* hintIcon; |
97 @property(readonly) NSAttributedString* hintIconLabel; | 79 @property(readonly) NSAttributedString* hintIconLabel; |
98 | 80 |
99 @end | 81 @end |
OLD | NEW |