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