OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 5 #ifndef UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
6 #define UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 // Empty and invalid ranges are ignored. | 196 // Empty and invalid ranges are ignored. |
197 void SetStyle(gfx::TextStyle style, bool value); | 197 void SetStyle(gfx::TextStyle style, bool value); |
198 void ApplyStyle(gfx::TextStyle style, bool value, const gfx::Range& range); | 198 void ApplyStyle(gfx::TextStyle style, bool value, const gfx::Range& range); |
199 | 199 |
200 // Clears Edit history. | 200 // Clears Edit history. |
201 void ClearEditHistory(); | 201 void ClearEditHistory(); |
202 | 202 |
203 // Set the accessible name of the text field. | 203 // Set the accessible name of the text field. |
204 void SetAccessibleName(const base::string16& name); | 204 void SetAccessibleName(const base::string16& name); |
205 | 205 |
206 // Performs the action associated with the specified command id. | |
207 void ExecuteCommand(int command_id); | |
208 | |
209 // Returns whether there is a drag operation originating from the textfield. | 206 // Returns whether there is a drag operation originating from the textfield. |
210 bool HasTextBeingDragged(); | 207 bool HasTextBeingDragged(); |
211 | 208 |
212 // View overrides: | 209 // View overrides: |
213 gfx::Insets GetInsets() const override; | 210 gfx::Insets GetInsets() const override; |
214 int GetBaseline() const override; | 211 int GetBaseline() const override; |
215 gfx::Size GetPreferredSize() const override; | 212 gfx::Size GetPreferredSize() const override; |
216 const char* GetClassName() const override; | 213 const char* GetClassName() const override; |
217 gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override; | 214 gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override; |
218 bool OnMousePressed(const ui::MouseEvent& event) override; | 215 bool OnMousePressed(const ui::MouseEvent& event) override; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 bool GetSelectionRange(gfx::Range* range) const override; | 296 bool GetSelectionRange(gfx::Range* range) const override; |
300 bool SetSelectionRange(const gfx::Range& range) override; | 297 bool SetSelectionRange(const gfx::Range& range) override; |
301 bool DeleteRange(const gfx::Range& range) override; | 298 bool DeleteRange(const gfx::Range& range) override; |
302 bool GetTextFromRange(const gfx::Range& range, | 299 bool GetTextFromRange(const gfx::Range& range, |
303 base::string16* text) const override; | 300 base::string16* text) const override; |
304 void OnInputMethodChanged() override; | 301 void OnInputMethodChanged() override; |
305 bool ChangeTextDirectionAndLayoutAlignment( | 302 bool ChangeTextDirectionAndLayoutAlignment( |
306 base::i18n::TextDirection direction) override; | 303 base::i18n::TextDirection direction) override; |
307 void ExtendSelectionAndDelete(size_t before, size_t after) override; | 304 void ExtendSelectionAndDelete(size_t before, size_t after) override; |
308 void EnsureCaretInRect(const gfx::Rect& rect) override; | 305 void EnsureCaretInRect(const gfx::Rect& rect) override; |
309 bool IsEditCommandEnabled(int command_id) override; | 306 bool IsEditCommandEnabled(ui::TextEditCommand command) const override; |
310 void SetEditCommandForNextKeyEvent(int command_id) override; | 307 void SetEditCommandForNextKeyEvent(ui::TextEditCommand command) override; |
311 | 308 |
312 protected: | 309 protected: |
313 // Inserts or appends a character in response to an IME operation. | 310 // Inserts or appends a character in response to an IME operation. |
314 virtual void DoInsertChar(base::char16 ch); | 311 virtual void DoInsertChar(base::char16 ch); |
315 | 312 |
316 // Returns the TextfieldModel's text/cursor/selection rendering model. | 313 // Returns the TextfieldModel's text/cursor/selection rendering model. |
317 gfx::RenderText* GetRenderText() const; | 314 gfx::RenderText* GetRenderText() const; |
318 | 315 |
319 gfx::Point last_click_location() const { return last_click_location_; } | 316 gfx::Point last_click_location() const { return last_click_location_; } |
320 | 317 |
321 // Get the text from the selection clipboard. | 318 // Get the text from the selection clipboard. |
322 virtual base::string16 GetSelectionClipboardText() const; | 319 virtual base::string16 GetSelectionClipboardText() const; |
323 | 320 |
| 321 ui::TextEditCommand scheduled_edit_command() const { |
| 322 return scheduled_edit_command_; |
| 323 } |
| 324 |
| 325 void reset_scheduled_edit_command() { |
| 326 scheduled_edit_command_ = ui::TextEditCommand::INVALID_COMMAND; |
| 327 } |
| 328 |
| 329 // Performs the given |command|. |
| 330 virtual void ExecuteEditCommand(ui::TextEditCommand command); |
| 331 |
324 private: | 332 private: |
325 friend class TextfieldTestApi; | 333 friend class TextfieldTestApi; |
326 | 334 |
327 // Handles a request to change the value of this text field from software | 335 // Handles a request to change the value of this text field from software |
328 // using an accessibility API (typically automation software, screen readers | 336 // using an accessibility API (typically automation software, screen readers |
329 // don't normally use this). Sets the value and clears the selection. | 337 // don't normally use this). Sets the value and clears the selection. |
330 void AccessibilitySetValue(const base::string16& new_value); | 338 void AccessibilitySetValue(const base::string16& new_value); |
331 | 339 |
332 // Updates the painted background color. | 340 // Updates the painted background color. |
333 void UpdateBackgroundColor(); | 341 void UpdateBackgroundColor(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 | 396 |
389 // Pastes the selection clipboard for the specified mouse event. | 397 // Pastes the selection clipboard for the specified mouse event. |
390 void PasteSelectionClipboard(const ui::MouseEvent& event); | 398 void PasteSelectionClipboard(const ui::MouseEvent& event); |
391 | 399 |
392 // The text model. | 400 // The text model. |
393 std::unique_ptr<TextfieldModel> model_; | 401 std::unique_ptr<TextfieldModel> model_; |
394 | 402 |
395 // This is the current listener for events from this Textfield. | 403 // This is the current listener for events from this Textfield. |
396 TextfieldController* controller_; | 404 TextfieldController* controller_; |
397 | 405 |
398 // If non-zero, an edit command to execute on the next key event. When set, | 406 // An edit command to execute on the next key event. When set to a valid |
399 // the key event is still passed to |controller_|, but otherwise ignored in | 407 // command, the key event is still passed to |controller_|, but otherwise |
400 // favor of the edit command. Set via SetEditCommandForNextKeyEvent() during | 408 // ignored in favor of the edit command. Set via |
401 // dispatch of that key event (see comment in TextInputClient). | 409 // SetEditCommandForNextKeyEvent() during dispatch of that key event (see |
402 int scheduled_edit_command_; | 410 // comment in TextInputClient). |
| 411 ui::TextEditCommand scheduled_edit_command_; |
403 | 412 |
404 // True if this Textfield cannot accept input and is read-only. | 413 // True if this Textfield cannot accept input and is read-only. |
405 bool read_only_; | 414 bool read_only_; |
406 | 415 |
407 // The default number of average characters for the width of this text field. | 416 // The default number of average characters for the width of this text field. |
408 // This will be reported as the "desired size". Defaults to 0. | 417 // This will be reported as the "desired size". Defaults to 0. |
409 int default_width_in_chars_; | 418 int default_width_in_chars_; |
410 | 419 |
411 // Flags indicating whether various system colors should be used, and if not, | 420 // Flags indicating whether various system colors should be used, and if not, |
412 // what overriding color values should be used instead. | 421 // what overriding color values should be used instead. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 | 493 |
485 // Used to bind callback functions to this object. | 494 // Used to bind callback functions to this object. |
486 base::WeakPtrFactory<Textfield> weak_ptr_factory_; | 495 base::WeakPtrFactory<Textfield> weak_ptr_factory_; |
487 | 496 |
488 DISALLOW_COPY_AND_ASSIGN(Textfield); | 497 DISALLOW_COPY_AND_ASSIGN(Textfield); |
489 }; | 498 }; |
490 | 499 |
491 } // namespace views | 500 } // namespace views |
492 | 501 |
493 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 502 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
OLD | NEW |