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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
10 | 10 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 bool save_original_selection); | 77 bool save_original_selection); |
78 virtual bool OnInlineAutocompleteTextMaybeChanged( | 78 virtual bool OnInlineAutocompleteTextMaybeChanged( |
79 const string16& display_text, size_t user_text_length); | 79 const string16& display_text, size_t user_text_length); |
80 virtual void OnStartingIME(); | 80 virtual void OnStartingIME(); |
81 virtual void OnRevertTemporaryText(); | 81 virtual void OnRevertTemporaryText(); |
82 virtual void OnBeforePossibleChange(); | 82 virtual void OnBeforePossibleChange(); |
83 virtual bool OnAfterPossibleChange(); | 83 virtual bool OnAfterPossibleChange(); |
84 virtual gfx::NativeView GetNativeView() const; | 84 virtual gfx::NativeView GetNativeView() const; |
85 virtual CommandUpdater* GetCommandUpdater(); | 85 virtual CommandUpdater* GetCommandUpdater(); |
86 virtual void SetInstantSuggestion(const string16& input); | 86 virtual void SetInstantSuggestion(const string16& input); |
| 87 virtual string16 GetInstantSuggestion() const; |
87 virtual int TextWidth() const; | 88 virtual int TextWidth() const; |
88 virtual bool IsImeComposing() const; | 89 virtual bool IsImeComposing() const; |
89 | 90 |
90 // Implement the AutocompleteTextFieldObserver interface. | 91 // Implement the AutocompleteTextFieldObserver interface. |
91 virtual NSRange SelectionRangeForProposedRange(NSRange proposed_range); | 92 virtual NSRange SelectionRangeForProposedRange(NSRange proposed_range); |
92 virtual void OnControlKeyChanged(bool pressed); | 93 virtual void OnControlKeyChanged(bool pressed); |
93 virtual bool CanCopy(); | 94 virtual bool CanCopy(); |
94 virtual void CopyToPasteboard(NSPasteboard* pboard); | 95 virtual void CopyToPasteboard(NSPasteboard* pboard); |
95 virtual void OnPaste(); | 96 virtual void OnPaste(); |
96 virtual bool CanPasteAndGo(); | 97 virtual bool CanPasteAndGo(); |
97 virtual int GetPasteActionStringId(); | 98 virtual int GetPasteActionStringId(); |
98 virtual void OnPasteAndGo(); | 99 virtual void OnPasteAndGo(); |
99 virtual void OnFrameChanged(); | 100 virtual void OnFrameChanged(); |
100 virtual void OnDidBeginEditing(); | 101 virtual void OnDidBeginEditing(); |
101 virtual void OnDidChange(); | 102 virtual void OnDidChange(); |
102 virtual void OnDidEndEditing(); | 103 virtual void OnDidEndEditing(); |
103 virtual bool OnDoCommandBySelector(SEL cmd); | 104 virtual bool OnDoCommandBySelector(SEL cmd); |
104 virtual void OnSetFocus(bool control_down); | 105 virtual void OnSetFocus(bool control_down); |
105 virtual void OnKillFocus(); | 106 virtual void OnKillFocus(); |
106 | 107 |
107 bool CommitSuggestText(); | |
108 | |
109 // Helper for LocationBarViewMac. Optionally selects all in |field_|. | 108 // Helper for LocationBarViewMac. Optionally selects all in |field_|. |
110 void FocusLocation(bool select_all); | 109 void FocusLocation(bool select_all); |
111 | 110 |
112 // Helper to get appropriate contents from |clipboard|. Returns | 111 // Helper to get appropriate contents from |clipboard|. Returns |
113 // empty string if no appropriate data is found on |clipboard|. | 112 // empty string if no appropriate data is found on |clipboard|. |
114 static string16 GetClipboardText(ui::Clipboard* clipboard); | 113 static string16 GetClipboardText(ui::Clipboard* clipboard); |
115 | 114 |
116 // Helper to get the font to use in the field, exposed for the | 115 // Helper to get the font to use in the field, exposed for the |
117 // popup. | 116 // popup. |
118 static NSFont* GetFieldFont(); | 117 static NSFont* GetFieldFont(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // setting the display text. Most callers should use |SetText()| instead. | 152 // setting the display text. Most callers should use |SetText()| instead. |
154 void SetTextInternal(const string16& display_text); | 153 void SetTextInternal(const string16& display_text); |
155 | 154 |
156 // Update the field with |display_text| and set the selection. | 155 // Update the field with |display_text| and set the selection. |
157 void SetTextAndSelectedRange(const string16& display_text, | 156 void SetTextAndSelectedRange(const string16& display_text, |
158 const NSRange range); | 157 const NSRange range); |
159 | 158 |
160 // Returns the non-suggest portion of |field_|'s string value. | 159 // Returns the non-suggest portion of |field_|'s string value. |
161 NSString* GetNonSuggestTextSubstring() const; | 160 NSString* GetNonSuggestTextSubstring() const; |
162 | 161 |
| 162 // Returns the suggest portion of |field_|'s string value. |
| 163 NSString* GetSuggestTextSubstring() const; |
| 164 |
163 // Pass the current content of |field_| to SetText(), maintaining | 165 // Pass the current content of |field_| to SetText(), maintaining |
164 // any selection. Named to be consistent with GTK and Windows, | 166 // any selection. Named to be consistent with GTK and Windows, |
165 // though here we cannot really do the in-place operation they do. | 167 // though here we cannot really do the in-place operation they do. |
166 void EmphasizeURLComponents(); | 168 void EmphasizeURLComponents(); |
167 | 169 |
168 // Calculates text attributes according to |display_text| and applies them | 170 // Calculates text attributes according to |display_text| and applies them |
169 // to the given |as| object. | 171 // to the given |as| object. |
170 void ApplyTextAttributes(const string16& display_text, | 172 void ApplyTextAttributes(const string16& display_text, |
171 NSMutableAttributedString* as); | 173 NSMutableAttributedString* as); |
172 | 174 |
| 175 // Return the number of UTF-16 units in the current buffer, excluding the |
| 176 // suggested text. |
| 177 NSUInteger GetTextLength() const; |
| 178 |
| 179 // Places the caret at the given position. This clears any selection. |
| 180 void PlaceCaretAt(NSUInteger pos); |
| 181 |
| 182 // Returns true if the caret is at the end of the content. |
| 183 bool IsCaretAtEnd() const; |
| 184 |
173 scoped_ptr<AutocompleteEditModel> model_; | 185 scoped_ptr<AutocompleteEditModel> model_; |
174 scoped_ptr<AutocompletePopupViewMac> popup_view_; | 186 scoped_ptr<AutocompletePopupViewMac> popup_view_; |
175 | 187 |
176 AutocompleteEditController* controller_; | 188 AutocompleteEditController* controller_; |
177 ToolbarModel* toolbar_model_; | 189 ToolbarModel* toolbar_model_; |
178 | 190 |
179 // The object that handles additional command functionality exposed on the | 191 // The object that handles additional command functionality exposed on the |
180 // edit, such as invoking the keyword editor. | 192 // edit, such as invoking the keyword editor. |
181 CommandUpdater* command_updater_; | 193 CommandUpdater* command_updater_; |
182 | 194 |
(...skipping 19 matching lines...) Expand all Loading... |
202 // Was the delete key pressed with an empty selection at the end of the edit? | 214 // Was the delete key pressed with an empty selection at the end of the edit? |
203 bool delete_at_end_pressed_; | 215 bool delete_at_end_pressed_; |
204 | 216 |
205 // The maximum/standard line height for the displayed text. | 217 // The maximum/standard line height for the displayed text. |
206 CGFloat line_height_; | 218 CGFloat line_height_; |
207 | 219 |
208 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewMac); | 220 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewMac); |
209 }; | 221 }; |
210 | 222 |
211 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ | 223 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ |
OLD | NEW |