| 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 |
| 11 #include <memory> |
| 11 #include <string> | 12 #include <string> |
| 12 | 13 |
| 13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
| 18 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
| 19 #include "third_party/skia/include/core/SkColor.h" | 19 #include "third_party/skia/include/core/SkColor.h" |
| 20 #include "ui/base/ime/text_input_client.h" | 20 #include "ui/base/ime/text_input_client.h" |
| 21 #include "ui/base/ime/text_input_type.h" | 21 #include "ui/base/ime/text_input_type.h" |
| 22 #include "ui/base/models/simple_menu_model.h" | 22 #include "ui/base/models/simple_menu_model.h" |
| 23 #include "ui/base/touch/touch_editing_controller.h" | 23 #include "ui/base/touch/touch_editing_controller.h" |
| 24 #include "ui/events/keycodes/keyboard_codes.h" | 24 #include "ui/events/keycodes/keyboard_codes.h" |
| 25 #include "ui/gfx/font_list.h" | 25 #include "ui/gfx/font_list.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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. | 206 // Performs the action associated with the specified command id. |
| 207 void ExecuteCommand(int command_id); | 207 void ExecuteCommand(int command_id); |
| 208 | 208 |
| 209 void SetFocusPainter(scoped_ptr<Painter> focus_painter); | 209 void SetFocusPainter(std::unique_ptr<Painter> focus_painter); |
| 210 | 210 |
| 211 // Returns whether there is a drag operation originating from the textfield. | 211 // Returns whether there is a drag operation originating from the textfield. |
| 212 bool HasTextBeingDragged(); | 212 bool HasTextBeingDragged(); |
| 213 | 213 |
| 214 // View overrides: | 214 // View overrides: |
| 215 gfx::Insets GetInsets() const override; | 215 gfx::Insets GetInsets() const override; |
| 216 int GetBaseline() const override; | 216 int GetBaseline() const override; |
| 217 gfx::Size GetPreferredSize() const override; | 217 gfx::Size GetPreferredSize() const override; |
| 218 const char* GetClassName() const override; | 218 const char* GetClassName() const override; |
| 219 gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override; | 219 gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 | 385 |
| 386 void CreateTouchSelectionControllerAndNotifyIt(); | 386 void CreateTouchSelectionControllerAndNotifyIt(); |
| 387 | 387 |
| 388 // Updates the selection clipboard to any non-empty text selection. | 388 // Updates the selection clipboard to any non-empty text selection. |
| 389 void UpdateSelectionClipboard() const; | 389 void UpdateSelectionClipboard() const; |
| 390 | 390 |
| 391 // Pastes the selection clipboard for the specified mouse event. | 391 // Pastes the selection clipboard for the specified mouse event. |
| 392 void PasteSelectionClipboard(const ui::MouseEvent& event); | 392 void PasteSelectionClipboard(const ui::MouseEvent& event); |
| 393 | 393 |
| 394 // The text model. | 394 // The text model. |
| 395 scoped_ptr<TextfieldModel> model_; | 395 std::unique_ptr<TextfieldModel> model_; |
| 396 | 396 |
| 397 // This is the current listener for events from this Textfield. | 397 // This is the current listener for events from this Textfield. |
| 398 TextfieldController* controller_; | 398 TextfieldController* controller_; |
| 399 | 399 |
| 400 // If non-zero, an edit command to execute on the next key event. When set, | 400 // If non-zero, an edit command to execute on the next key event. When set, |
| 401 // the key event is still passed to |controller_|, but otherwise ignored in | 401 // the key event is still passed to |controller_|, but otherwise ignored in |
| 402 // favor of the edit command. Set via SetEditCommandForNextKeyEvent() during | 402 // favor of the edit command. Set via SetEditCommandForNextKeyEvent() during |
| 403 // dispatch of that key event (see comment in TextInputClient). | 403 // dispatch of that key event (see comment in TextInputClient). |
| 404 int scheduled_edit_command_; | 404 int scheduled_edit_command_; |
| 405 | 405 |
| 406 // True if this Textfield cannot accept input and is read-only. | 406 // True if this Textfield cannot accept input and is read-only. |
| 407 bool read_only_; | 407 bool read_only_; |
| 408 | 408 |
| 409 // The default number of average characters for the width of this text field. | 409 // The default number of average characters for the width of this text field. |
| 410 // This will be reported as the "desired size". Defaults to 0. | 410 // This will be reported as the "desired size". Defaults to 0. |
| 411 int default_width_in_chars_; | 411 int default_width_in_chars_; |
| 412 | 412 |
| 413 scoped_ptr<Painter> focus_painter_; | 413 std::unique_ptr<Painter> focus_painter_; |
| 414 | 414 |
| 415 // Flags indicating whether various system colors should be used, and if not, | 415 // Flags indicating whether various system colors should be used, and if not, |
| 416 // what overriding color values should be used instead. | 416 // what overriding color values should be used instead. |
| 417 bool use_default_text_color_; | 417 bool use_default_text_color_; |
| 418 bool use_default_background_color_; | 418 bool use_default_background_color_; |
| 419 bool use_default_selection_text_color_; | 419 bool use_default_selection_text_color_; |
| 420 bool use_default_selection_background_color_; | 420 bool use_default_selection_background_color_; |
| 421 SkColor text_color_; | 421 SkColor text_color_; |
| 422 SkColor background_color_; | 422 SkColor background_color_; |
| 423 SkColor selection_text_color_; | 423 SkColor selection_text_color_; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 // A timer and point used to modify the selection when dragging. | 463 // A timer and point used to modify the selection when dragging. |
| 464 base::RepeatingTimer drag_selection_timer_; | 464 base::RepeatingTimer drag_selection_timer_; |
| 465 gfx::Point last_drag_location_; | 465 gfx::Point last_drag_location_; |
| 466 | 466 |
| 467 // State variables used to track double and triple clicks. | 467 // State variables used to track double and triple clicks. |
| 468 size_t aggregated_clicks_; | 468 size_t aggregated_clicks_; |
| 469 base::TimeDelta last_click_time_; | 469 base::TimeDelta last_click_time_; |
| 470 gfx::Point last_click_location_; | 470 gfx::Point last_click_location_; |
| 471 gfx::Range double_click_word_; | 471 gfx::Range double_click_word_; |
| 472 | 472 |
| 473 scoped_ptr<ui::TouchEditingControllerDeprecated> touch_selection_controller_; | 473 std::unique_ptr<ui::TouchEditingControllerDeprecated> |
| 474 touch_selection_controller_; |
| 474 | 475 |
| 475 // Used to track touch drag starting location and offset to enable touch | 476 // Used to track touch drag starting location and offset to enable touch |
| 476 // scrolling. | 477 // scrolling. |
| 477 gfx::Point drag_start_location_; | 478 gfx::Point drag_start_location_; |
| 478 int drag_start_display_offset_; | 479 int drag_start_display_offset_; |
| 479 | 480 |
| 480 // Tracks if touch editing handles are hidden because user has started | 481 // Tracks if touch editing handles are hidden because user has started |
| 481 // scrolling. If |true|, handles are shown after scrolling ends. | 482 // scrolling. If |true|, handles are shown after scrolling ends. |
| 482 bool touch_handles_hidden_due_to_scroll_; | 483 bool touch_handles_hidden_due_to_scroll_; |
| 483 | 484 |
| 484 // Context menu related members. | 485 // Context menu related members. |
| 485 scoped_ptr<ui::SimpleMenuModel> context_menu_contents_; | 486 std::unique_ptr<ui::SimpleMenuModel> context_menu_contents_; |
| 486 scoped_ptr<views::MenuRunner> context_menu_runner_; | 487 std::unique_ptr<views::MenuRunner> context_menu_runner_; |
| 487 | 488 |
| 488 // Used to bind callback functions to this object. | 489 // Used to bind callback functions to this object. |
| 489 base::WeakPtrFactory<Textfield> weak_ptr_factory_; | 490 base::WeakPtrFactory<Textfield> weak_ptr_factory_; |
| 490 | 491 |
| 491 DISALLOW_COPY_AND_ASSIGN(Textfield); | 492 DISALLOW_COPY_AND_ASSIGN(Textfield); |
| 492 }; | 493 }; |
| 493 | 494 |
| 494 } // namespace views | 495 } // namespace views |
| 495 | 496 |
| 496 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 497 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
| OLD | NEW |