OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 Textfield; | 19 class Textfield; |
19 class View; | 20 class View; |
20 | 21 |
21 // An interface implemented by an object that provides a platform-native | 22 // An interface implemented by an object that provides a platform-native |
22 // text field. | 23 // text field. |
23 class NativeTextfieldWrapper { | 24 class NativeTextfieldWrapper { |
24 public: | 25 public: |
25 // The Textfield calls this when it is destroyed to clean up the wrapper | 26 // The Textfield calls this when it is destroyed to clean up the wrapper |
26 // object. | 27 // object. |
27 virtual ~NativeTextfieldWrapper() {} | 28 virtual ~NativeTextfieldWrapper() {} |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 71 |
71 // Returns the insets for the text field. | 72 // Returns the insets for the text field. |
72 virtual gfx::Insets CalculateInsets() = 0; | 73 virtual gfx::Insets CalculateInsets() = 0; |
73 | 74 |
74 // Updates the horizontal margins for the native text field. | 75 // Updates the horizontal margins for the native text field. |
75 virtual void UpdateHorizontalMargins() = 0; | 76 virtual void UpdateHorizontalMargins() = 0; |
76 | 77 |
77 // Updates the vertical margins for the native text field. | 78 // Updates the vertical margins for the native text field. |
78 virtual void UpdateVerticalMargins() = 0; | 79 virtual void UpdateVerticalMargins() = 0; |
79 | 80 |
80 // Sets the focus to the text field. | 81 // Sets the focus to the text field. Returns false if the wrapper |
81 virtual void SetFocus() = 0; | 82 // didn't take focus. |
| 83 virtual bool SetFocus() = 0; |
82 | 84 |
83 // Retrieves the views::View that hosts the native control. | 85 // Retrieves the views::View that hosts the native control. |
84 virtual View* GetView() = 0; | 86 virtual View* GetView() = 0; |
85 | 87 |
86 // Returns a handle to the underlying native view for testing. | 88 // Returns a handle to the underlying native view for testing. |
87 virtual gfx::NativeView GetTestingHandle() const = 0; | 89 virtual gfx::NativeView GetTestingHandle() const = 0; |
88 | 90 |
89 // Returns whether or not an IME is composing text. | 91 // Returns whether or not an IME is composing text. |
90 virtual bool IsIMEComposing() const = 0; | 92 virtual bool IsIMEComposing() const = 0; |
91 | 93 |
| 94 // Following methods are to forward key/focus related events to the |
| 95 // views wrapper so that TextfieldViews can handle key inputs without |
| 96 // having focus. |
| 97 |
| 98 // Invoked when a key is pressed/release on Textfield. Subclasser |
| 99 // should return true if the event has been processed and false |
| 100 // otherwise. |
| 101 // See also View::OnKeyPressed/OnKeyReleased. |
| 102 virtual bool HandleKeyPressed(const views::KeyEvent& e) = 0; |
| 103 virtual bool HandleKeyReleased(const views::KeyEvent& e) = 0; |
| 104 |
| 105 // Invoked when focus is being moved from or to the Textfield. |
| 106 // See also View::WillGainFocus/DidGainFocus/WillLoseFocus. |
| 107 virtual void HandleWillGainFocus() = 0; |
| 108 virtual void HandleDidGainFocus() = 0; |
| 109 virtual void HandleWillLoseFocus() = 0; |
| 110 |
92 // Creates an appropriate NativeTextfieldWrapper for the platform. | 111 // Creates an appropriate NativeTextfieldWrapper for the platform. |
93 static NativeTextfieldWrapper* CreateWrapper(Textfield* field); | 112 static NativeTextfieldWrapper* CreateWrapper(Textfield* field); |
94 }; | 113 }; |
95 | 114 |
96 } // namespace views | 115 } // namespace views |
97 | 116 |
98 #endif // VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_WRAPPER_H_ | 117 #endif // VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_WRAPPER_H_ |
OLD | NEW |