| 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 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 // Set if there is a string to display as a hint on the right-hand | 33 // Set if there is a string to display as a hint on the right-hand |
| 34 // side of the field. Exclusive WRT |keywordString_|; | 34 // side of the field. Exclusive WRT |keywordString_|; |
| 35 scoped_nsobject<NSAttributedString> hintString_; | 35 scoped_nsobject<NSAttributedString> hintString_; |
| 36 | 36 |
| 37 // YES if the info cell has been changed in a way which would result | 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. | 38 // in the cell needing to be laid out again. |
| 39 BOOL fieldEditorNeedsReset_; | 39 BOOL fieldEditorNeedsReset_; |
| 40 | 40 |
| 41 // Icon that represents the state of the SSL connection | 41 // Icon that represents the state of the SSL connection |
| 42 scoped_nsobject<NSImage> hintIcon_; | 42 scoped_nsobject<NSImage> hintIcon_; |
| 43 |
| 44 // 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 |
| 46 // hintIcon without an hintIconLabel, but not vice-versa). |
| 47 scoped_nsobject<NSAttributedString> hintIconLabel_; |
| 43 } | 48 } |
| 44 | 49 |
| 45 @property BOOL fieldEditorNeedsReset; | 50 @property BOOL fieldEditorNeedsReset; |
| 46 | 51 |
| 47 // TODO(shess): There should be two alternatives for | 52 // TODO(shess): There should be two alternatives for |
| 48 // -setKeywordString:, the normal string and the min string. Min can | 53 // -setKeywordString:, the normal string and the min string. Min can |
| 49 // be used when the text field's contents gets too wide to fit both it | 54 // be used when the text field's contents gets too wide to fit both it |
| 50 // and this. | 55 // and this. |
| 51 | 56 |
| 52 // The following setup |keywordString_| or |hintString_| based on the | 57 // The following setup |keywordString_| or |hintString_| based on the |
| 53 // input, and set |fieldEditorNeedsReset_| if the layout of the field | 58 // input, and set |fieldEditorNeedsReset_| if the layout of the field |
| 54 // changed. | 59 // changed. |
| 55 - (void)setKeywordString:(NSString*)aString; | 60 - (void)setKeywordString:(NSString*)aString; |
| 56 - (void)setKeywordHintPrefix:(NSString*)prefixString | 61 - (void)setKeywordHintPrefix:(NSString*)prefixString |
| 57 image:(NSImage*)anImage | 62 image:(NSImage*)anImage |
| 58 suffix:(NSString*)suffixString; | 63 suffix:(NSString*)suffixString; |
| 59 - (void)setSearchHintString:(NSString*)aString; | 64 - (void)setSearchHintString:(NSString*)aString; |
| 60 - (void)clearKeywordAndHint; | 65 - (void)clearKeywordAndHint; |
| 61 | 66 |
| 62 - (void)setHintIcon:(NSImage*)icon; | 67 // Sets the hint icon and optional icon label. If |icon| is nil, the current |
| 68 // icon is cleared. If |label| is provided, |color| must be provided as well. |
| 69 - (void)setHintIcon:(NSImage*)icon label:(NSString*)label color:(NSColor*)color; |
| 63 | 70 |
| 64 // Return the portion of the cell to show the text cursor over. | 71 // Return the portion of the cell to show the text cursor over. |
| 65 - (NSRect)textCursorFrameForFrame:(NSRect)cellFrame; | 72 - (NSRect)textCursorFrameForFrame:(NSRect)cellFrame; |
| 66 | 73 |
| 67 // Return the portion of the cell to use for text display. This | 74 // Return the portion of the cell to use for text display. This |
| 68 // corresponds to the frame with our added decorations sliced off. | 75 // corresponds to the frame with our added decorations sliced off. |
| 69 - (NSRect)textFrameForFrame:(NSRect)cellFrame; | 76 - (NSRect)textFrameForFrame:(NSRect)cellFrame; |
| 70 | 77 |
| 71 // Return the portion of the cell to use for displaing the |hintIcon_|. | 78 // Return the portion of the cell to use for displaing the |hintIcon_|. |
| 72 - (NSRect)hintImageFrameForFrame:(NSRect)cellFrame; | 79 - (NSRect)hintImageFrameForFrame:(NSRect)cellFrame; |
| 73 | 80 |
| 74 @end | 81 @end |
| 75 | 82 |
| 76 // Internal methods here exposed for unit testing. | 83 // Internal methods here exposed for unit testing. |
| 77 @interface AutocompleteTextFieldCell (UnitTesting) | 84 @interface AutocompleteTextFieldCell (UnitTesting) |
| 78 | 85 |
| 79 @property(readonly) NSAttributedString* keywordString; | 86 @property(readonly) NSAttributedString* keywordString; |
| 80 @property(readonly) NSAttributedString* hintString; | 87 @property(readonly) NSAttributedString* hintString; |
| 81 @property(readonly) NSImage* hintIcon; | 88 @property(readonly) NSImage* hintIcon; |
| 89 @property(readonly) NSAttributedString* hintIconLabel; |
| 82 | 90 |
| 83 @end | 91 @end |
| OLD | NEW |