diff options
author | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-21 16:23:40 +0000 |
---|---|---|
committer | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-21 16:23:40 +0000 |
commit | 534c59086c951a0687fce53c2a8de49a2100867e (patch) | |
tree | 22db8743b0b3726e6451822fcdd9c10950193b48 /chrome/browser/cocoa/autocomplete_text_field_cell.h | |
parent | 7edcd61631c5c8a9c55945eded3a5bc48cc3e350 (diff) | |
download | chromium_src-534c59086c951a0687fce53c2a8de49a2100867e.zip chromium_src-534c59086c951a0687fce53c2a8de49a2100867e.tar.gz chromium_src-534c59086c951a0687fce53c2a8de49a2100867e.tar.bz2 |
[Mac] Omnibox keyword, keyword hint, and search hint support.
BUG=http://crbug.com/10944
BUG=http://crbug.com/10943
BUG=http://crbug.com/12285
TEST=With empty field, should see "Type to search" in light text on
the RHS of the omnibox. Type "google" and should see "Press [Tab] to
search Google" in light text on the RHS. Hit TAB, should see a
rounded [Search Google:] item on the left and the cursor is now right
of that. Popup should show "Keyword:" in some entries.
Patch by shess@chromium.org.
Review URL: http://codereview.chromium.org/173194
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23964 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/autocomplete_text_field_cell.h')
-rw-r--r-- | chrome/browser/cocoa/autocomplete_text_field_cell.h | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/chrome/browser/cocoa/autocomplete_text_field_cell.h b/chrome/browser/cocoa/autocomplete_text_field_cell.h index 983e370..3bcbbcf 100644 --- a/chrome/browser/cocoa/autocomplete_text_field_cell.h +++ b/chrome/browser/cocoa/autocomplete_text_field_cell.h @@ -4,8 +4,67 @@ #import <Cocoa/Cocoa.h> -// A cell that draws the autocomplete field. +#include "base/scoped_nsobject.h" + +// AutocompleteTextFieldCell customizes the look of the Omnibox text +// field. The border and focus ring are modified, as is the font +// baseline. + +// The cell also provides support for certain decorations to be +// applied to the field. These are the search hint ("Type to search" +// on the right-hand side), the keyword hint ("Press [Tab] to search +// Engine" on the right-hand side), and keyword mode ("Search Engine:" +// in a button-like token on the left-hand side). +// +// The cell arranges the field-editor's placement via the standard +// -editWithFrame:* and -selectWithFrame:* methods. When the visible +// decoration changes, the cell's look may change, and if the cell is +// currently being edited the field editor will require adjustment. +// The cell signals this requirement by returning YES for +// -fieldEditorNeedsReset, which is used by AutocompleteTextField's +// -resetFieldEditorFrameIfNeeded in testing if re-layout is needed. @interface AutocompleteTextFieldCell : NSTextFieldCell { + @private + // Set if there is a string to display in a rounded rect on the + // left-hand side of the field. Exclusive WRT |hintString_|. + scoped_nsobject<NSAttributedString> keywordString_; + + // Set if there is a string to display as a hint on the right-hand + // side of the field. Exclusive WRT |keywordString_|; + scoped_nsobject<NSAttributedString> hintString_; + + // YES if the info cell has been changed in a way which would result + // in the cell needing to be laid out again. + BOOL fieldEditorNeedsReset_; } + +@property BOOL fieldEditorNeedsReset; + +// TODO(shess): There should be two alternatives for +// -setKeywordString:, the normal string and the min string. Min can +// be used when the text field's contents gets too wide to fit both it +// and this. + +// The following setup |keywordString_| or |hintString_| based on the +// input, and set |fieldEditorNeedsReset_| if the layout of the field +// changed. +- (void)setKeywordString:(NSString*)aString; +- (void)setKeywordHintPrefix:(NSString*)prefixString + image:(NSImage*)anImage + suffix:(NSString*)suffixString; +- (void)setSearchHintString:(NSString*)aString; +- (void)clearKeywordAndHint; + +@end + +// Internal methods here exposed for unit testing. +@interface AutocompleteTextFieldCell (UnitTesting) + +@property(readonly) NSAttributedString* keywordString; +@property(readonly) NSAttributedString* hintString; + +// Return the portion of the cell to use for text display. +- (NSRect)textFrameForFrame:(NSRect)cellFrame; + @end |