| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_WRAPPER_H_ | 5 #ifndef VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_WRAPPER_H_ |
| 6 #define VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_WRAPPER_H_ | 6 #define VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_WRAPPER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/string16.h" | 9 #include "base/string16.h" |
| 10 #include "gfx/native_widget_types.h" | 10 #include "gfx/native_widget_types.h" |
| 11 | 11 |
| 12 namespace gfx { | 12 namespace gfx { |
| 13 class Insets; | 13 class Insets; |
| 14 } // namespace gfx | 14 } // namespace gfx |
| 15 | 15 |
| 16 namespace views { | 16 namespace views { |
| 17 | 17 |
| 18 class KeyEvent; | 18 class KeyEvent; |
| 19 class Textfield; | 19 class Textfield; |
| 20 class TextRange; |
| 20 class View; | 21 class View; |
| 21 | 22 |
| 22 // An interface implemented by an object that provides a platform-native | 23 // An interface implemented by an object that provides a platform-native |
| 23 // text field. | 24 // text field. |
| 24 class NativeTextfieldWrapper { | 25 class NativeTextfieldWrapper { |
| 25 public: | 26 public: |
| 26 // The Textfield calls this when it is destroyed to clean up the wrapper | 27 // The Textfield calls this when it is destroyed to clean up the wrapper |
| 27 // object. | 28 // object. |
| 28 virtual ~NativeTextfieldWrapper() {} | 29 virtual ~NativeTextfieldWrapper() {} |
| 29 | 30 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 85 |
| 85 // Retrieves the views::View that hosts the native control. | 86 // Retrieves the views::View that hosts the native control. |
| 86 virtual View* GetView() = 0; | 87 virtual View* GetView() = 0; |
| 87 | 88 |
| 88 // Returns a handle to the underlying native view for testing. | 89 // Returns a handle to the underlying native view for testing. |
| 89 virtual gfx::NativeView GetTestingHandle() const = 0; | 90 virtual gfx::NativeView GetTestingHandle() const = 0; |
| 90 | 91 |
| 91 // Returns whether or not an IME is composing text. | 92 // Returns whether or not an IME is composing text. |
| 92 virtual bool IsIMEComposing() const = 0; | 93 virtual bool IsIMEComposing() const = 0; |
| 93 | 94 |
| 95 // Gets the selected range. |
| 96 virtual void GetSelectedRange(TextRange* range) const = 0; |
| 97 |
| 98 // Selects the text given by |range|. |
| 99 virtual void SelectRange(const TextRange& range) = 0; |
| 100 |
| 101 // Returns the currnet cursor position. |
| 102 virtual size_t GetCursorPosition() const = 0; |
| 103 |
| 94 // Following methods are to forward key/focus related events to the | 104 // Following methods are to forward key/focus related events to the |
| 95 // views wrapper so that TextfieldViews can handle key inputs without | 105 // views wrapper so that TextfieldViews can handle key inputs without |
| 96 // having focus. | 106 // having focus. |
| 97 | 107 |
| 98 // Invoked when a key is pressed/release on Textfield. Subclasser | 108 // Invoked when a key is pressed/release on Textfield. Subclasser |
| 99 // should return true if the event has been processed and false | 109 // should return true if the event has been processed and false |
| 100 // otherwise. | 110 // otherwise. |
| 101 // See also View::OnKeyPressed/OnKeyReleased. | 111 // See also View::OnKeyPressed/OnKeyReleased. |
| 102 virtual bool HandleKeyPressed(const views::KeyEvent& e) = 0; | 112 virtual bool HandleKeyPressed(const views::KeyEvent& e) = 0; |
| 103 virtual bool HandleKeyReleased(const views::KeyEvent& e) = 0; | 113 virtual bool HandleKeyReleased(const views::KeyEvent& e) = 0; |
| 104 | 114 |
| 105 // Invoked when focus is being moved from or to the Textfield. | 115 // Invoked when focus is being moved from or to the Textfield. |
| 106 // See also View::WillGainFocus/DidGainFocus/WillLoseFocus. | 116 // See also View::WillGainFocus/DidGainFocus/WillLoseFocus. |
| 107 virtual void HandleWillGainFocus() = 0; | 117 virtual void HandleWillGainFocus() = 0; |
| 108 virtual void HandleDidGainFocus() = 0; | 118 virtual void HandleDidGainFocus() = 0; |
| 109 virtual void HandleWillLoseFocus() = 0; | 119 virtual void HandleWillLoseFocus() = 0; |
| 110 | 120 |
| 111 // Creates an appropriate NativeTextfieldWrapper for the platform. | 121 // Creates an appropriate NativeTextfieldWrapper for the platform. |
| 112 static NativeTextfieldWrapper* CreateWrapper(Textfield* field); | 122 static NativeTextfieldWrapper* CreateWrapper(Textfield* field); |
| 113 }; | 123 }; |
| 114 | 124 |
| 115 } // namespace views | 125 } // namespace views |
| 116 | 126 |
| 117 #endif // VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_WRAPPER_H_ | 127 #endif // VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_WRAPPER_H_ |
| OLD | NEW |