| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_PREFIX_SELECTOR_H_ | 5 #ifndef UI_VIEWS_CONTROLS_PREFIX_SELECTOR_H_ |
| 6 #define UI_VIEWS_CONTROLS_PREFIX_SELECTOR_H_ | 6 #define UI_VIEWS_CONTROLS_PREFIX_SELECTOR_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "ui/base/ime/text_input_client.h" | 14 #include "ui/base/ime/text_input_client.h" |
| 15 #include "ui/views/views_export.h" | 15 #include "ui/views/views_export.h" |
| 16 | 16 |
| 17 namespace views { | 17 namespace views { |
| 18 | 18 |
| 19 class PrefixDelegate; | 19 class PrefixDelegate; |
| 20 class View; |
| 20 | 21 |
| 21 // PrefixSelector is used to change the selection in a view as the user | 22 // PrefixSelector is used to change the selection in a view as the user |
| 22 // types characters. | 23 // types characters. |
| 23 class VIEWS_EXPORT PrefixSelector : public ui::TextInputClient { | 24 class VIEWS_EXPORT PrefixSelector : public ui::TextInputClient { |
| 24 public: | 25 public: |
| 25 explicit PrefixSelector(PrefixDelegate* delegate); | 26 PrefixSelector(PrefixDelegate* delegate, View* host_view); |
| 26 ~PrefixSelector() override; | 27 ~PrefixSelector() override; |
| 27 | 28 |
| 28 // Invoked from the view when it loses focus. | 29 // Invoked from the view when it loses focus. |
| 29 void OnViewBlur(); | 30 void OnViewBlur(); |
| 30 | 31 |
| 31 // ui::TextInputClient: | 32 // ui::TextInputClient: |
| 32 void SetCompositionText(const ui::CompositionText& composition) override; | 33 void SetCompositionText(const ui::CompositionText& composition) override; |
| 33 void ConfirmCompositionText() override; | 34 void ConfirmCompositionText() override; |
| 34 void ClearCompositionText() override; | 35 void ClearCompositionText() override; |
| 35 void InsertText(const base::string16& text) override; | 36 void InsertText(const base::string16& text) override; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 64 void OnTextInput(const base::string16& text); | 65 void OnTextInput(const base::string16& text); |
| 65 | 66 |
| 66 // Returns true if the text of the node at |row| starts with |lower_text|. | 67 // Returns true if the text of the node at |row| starts with |lower_text|. |
| 67 bool TextAtRowMatchesText(int row, const base::string16& lower_text); | 68 bool TextAtRowMatchesText(int row, const base::string16& lower_text); |
| 68 | 69 |
| 69 // Clears |current_text_| and resets |time_of_last_key_|. | 70 // Clears |current_text_| and resets |time_of_last_key_|. |
| 70 void ClearText(); | 71 void ClearText(); |
| 71 | 72 |
| 72 PrefixDelegate* prefix_delegate_; | 73 PrefixDelegate* prefix_delegate_; |
| 73 | 74 |
| 75 View* host_view_; |
| 76 |
| 74 // Time OnTextInput() was last invoked. | 77 // Time OnTextInput() was last invoked. |
| 75 base::TimeTicks time_of_last_key_; | 78 base::TimeTicks time_of_last_key_; |
| 76 | 79 |
| 77 base::string16 current_text_; | 80 base::string16 current_text_; |
| 78 | 81 |
| 79 DISALLOW_COPY_AND_ASSIGN(PrefixSelector); | 82 DISALLOW_COPY_AND_ASSIGN(PrefixSelector); |
| 80 }; | 83 }; |
| 81 | 84 |
| 82 } // namespace views | 85 } // namespace views |
| 83 | 86 |
| 84 #endif // UI_VIEWS_CONTROLS_PREFIX_SELECTOR_H_ | 87 #endif // UI_VIEWS_CONTROLS_PREFIX_SELECTOR_H_ |
| OLD | NEW |