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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 void UpdateCursor(); | 316 void UpdateCursor(); |
317 | 317 |
318 // Repaint the cursor. | 318 // Repaint the cursor. |
319 void RepaintCursor(); | 319 void RepaintCursor(); |
320 | 320 |
321 void PaintTextAndCursor(gfx::Canvas* canvas); | 321 void PaintTextAndCursor(gfx::Canvas* canvas); |
322 | 322 |
323 // Helper function to call MoveCursorTo on the TextfieldModel. | 323 // Helper function to call MoveCursorTo on the TextfieldModel. |
324 void MoveCursorTo(const gfx::Point& point, bool select); | 324 void MoveCursorTo(const gfx::Point& point, bool select); |
325 | 325 |
| 326 // Helper function to update the selection on a mouse drag. |
| 327 void SelectThroughLastDragLocation(); |
| 328 |
326 // Convenience method to notify the InputMethod and TouchSelectionController. | 329 // Convenience method to notify the InputMethod and TouchSelectionController. |
327 void OnCaretBoundsChanged(); | 330 void OnCaretBoundsChanged(); |
328 | 331 |
329 // Convenience method to call TextfieldController::OnBeforeUserAction(); | 332 // Convenience method to call TextfieldController::OnBeforeUserAction(); |
330 void OnBeforeUserAction(); | 333 void OnBeforeUserAction(); |
331 | 334 |
332 // Convenience method to call TextfieldController::OnAfterUserAction(); | 335 // Convenience method to call TextfieldController::OnAfterUserAction(); |
333 void OnAfterUserAction(); | 336 void OnAfterUserAction(); |
334 | 337 |
335 // Calls |model_->Cut()| and notifies TextfieldController on success. | 338 // Calls |model_->Cut()| and notifies TextfieldController on success. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 | 374 |
372 // True if this Textfield cannot accept input and is read-only. | 375 // True if this Textfield cannot accept input and is read-only. |
373 bool read_only_; | 376 bool read_only_; |
374 | 377 |
375 // The default number of average characters for the width of this text field. | 378 // The default number of average characters for the width of this text field. |
376 // This will be reported as the "desired size". Defaults to 0. | 379 // This will be reported as the "desired size". Defaults to 0. |
377 int default_width_in_chars_; | 380 int default_width_in_chars_; |
378 | 381 |
379 scoped_ptr<Painter> focus_painter_; | 382 scoped_ptr<Painter> focus_painter_; |
380 | 383 |
381 // Text color. Only used if |use_default_text_color_| is false. | 384 // Flags indicating whether text and background system colors should be used, |
| 385 // and the actual color values used if the corresponding flags are set false. |
382 SkColor text_color_; | 386 SkColor text_color_; |
383 | |
384 // Should we use the system text color instead of |text_color_|? | |
385 bool use_default_text_color_; | 387 bool use_default_text_color_; |
386 | |
387 // Background color. Only used if |use_default_background_color_| is false. | |
388 SkColor background_color_; | 388 SkColor background_color_; |
389 | |
390 // Should we use the system background color instead of |background_color_|? | |
391 bool use_default_background_color_; | 389 bool use_default_background_color_; |
392 | 390 |
393 // Text to display when empty. | 391 // Text to display when empty. |
394 base::string16 placeholder_text_; | 392 base::string16 placeholder_text_; |
395 | 393 |
396 // Placeholder text color. | 394 // Placeholder text color. |
397 SkColor placeholder_text_color_; | 395 SkColor placeholder_text_color_; |
398 | 396 |
399 // The accessible name of the text field. | 397 // The accessible name of the text field. |
400 base::string16 accessible_name_; | 398 base::string16 accessible_name_; |
401 | 399 |
402 // The input type of this text field. | 400 // The input type of this text field. |
403 ui::TextInputType text_input_type_; | 401 ui::TextInputType text_input_type_; |
404 | 402 |
405 // The duration and timer to reveal the last typed password character. | 403 // The duration and timer to reveal the last typed password character. |
406 base::TimeDelta password_reveal_duration_; | 404 base::TimeDelta password_reveal_duration_; |
407 base::OneShotTimer<Textfield> password_reveal_timer_; | 405 base::OneShotTimer<Textfield> password_reveal_timer_; |
408 | 406 |
409 // Keeps track of whether currently performing a user action (i.e. when | 407 // Tracks whether a user action is being performed; i.e. OnBeforeUserAction() |
410 // OnBeforeUserAction() has been called, but OnAfterUserAction() is yet to be | 408 // has been called, but OnAfterUserAction() has not yet been called. |
411 // called). | |
412 bool performing_user_action_; | 409 bool performing_user_action_; |
413 | 410 |
414 // True if InputMethod::CancelComposition() should not be called. | 411 // True if InputMethod::CancelComposition() should not be called. |
415 bool skip_input_method_cancel_composition_; | 412 bool skip_input_method_cancel_composition_; |
416 | 413 |
417 // The text editing cursor repaint timer and visibility. | 414 // The text editing cursor repaint timer and visibility. |
418 base::RepeatingTimer<Textfield> cursor_repaint_timer_; | 415 base::RepeatingTimer<Textfield> cursor_repaint_timer_; |
419 bool cursor_visible_; | 416 bool cursor_visible_; |
420 | 417 |
421 // The drop cursor is a visual cue for where dragged text will be dropped. | 418 // The drop cursor is a visual cue for where dragged text will be dropped. |
422 bool drop_cursor_visible_; | 419 bool drop_cursor_visible_; |
423 gfx::SelectionModel drop_cursor_position_; | 420 gfx::SelectionModel drop_cursor_position_; |
424 | 421 |
425 // Is the user potentially dragging and dropping from this view? | 422 // Is the user potentially dragging and dropping from this view? |
426 bool initiating_drag_; | 423 bool initiating_drag_; |
427 | 424 |
| 425 // A timer and point used to modify the selection when dragging. |
| 426 base::RepeatingTimer<Textfield> drag_selection_timer_; |
| 427 gfx::Point last_drag_location_; |
| 428 |
428 // State variables used to track double and triple clicks. | 429 // State variables used to track double and triple clicks. |
429 size_t aggregated_clicks_; | 430 size_t aggregated_clicks_; |
430 base::TimeDelta last_click_time_; | 431 base::TimeDelta last_click_time_; |
431 gfx::Point last_click_location_; | 432 gfx::Point last_click_location_; |
432 gfx::Range double_click_word_; | 433 gfx::Range double_click_word_; |
433 | 434 |
434 scoped_ptr<ui::TouchSelectionController> touch_selection_controller_; | 435 scoped_ptr<ui::TouchSelectionController> touch_selection_controller_; |
435 | 436 |
436 // Context menu related members. | 437 // Context menu related members. |
437 scoped_ptr<ui::SimpleMenuModel> context_menu_contents_; | 438 scoped_ptr<ui::SimpleMenuModel> context_menu_contents_; |
438 scoped_ptr<views::MenuRunner> context_menu_runner_; | 439 scoped_ptr<views::MenuRunner> context_menu_runner_; |
439 | 440 |
440 // Used to bind callback functions to this object. | 441 // Used to bind callback functions to this object. |
441 base::WeakPtrFactory<Textfield> weak_ptr_factory_; | 442 base::WeakPtrFactory<Textfield> weak_ptr_factory_; |
442 | 443 |
443 DISALLOW_COPY_AND_ASSIGN(Textfield); | 444 DISALLOW_COPY_AND_ASSIGN(Textfield); |
444 }; | 445 }; |
445 | 446 |
446 } // namespace views | 447 } // namespace views |
447 | 448 |
448 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 449 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
OLD | NEW |