OLD | NEW |
1 // Copyright (c) 2011 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_TEXTFIELD_H_ | 5 #ifndef VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
6 #define VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 6 #define VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "views/view.h" | 23 #include "views/view.h" |
24 | 24 |
25 #if !defined(OS_LINUX) | 25 #if !defined(OS_LINUX) |
26 #include "base/logging.h" | 26 #include "base/logging.h" |
27 #endif | 27 #endif |
28 #ifdef UNIT_TEST | 28 #ifdef UNIT_TEST |
29 #include "ui/gfx/native_widget_types.h" | 29 #include "ui/gfx/native_widget_types.h" |
30 #include "views/controls/textfield/native_textfield_wrapper.h" | 30 #include "views/controls/textfield/native_textfield_wrapper.h" |
31 #endif | 31 #endif |
32 | 32 |
| 33 namespace gfx { |
| 34 struct StyleRange; |
| 35 } // namespace gfx |
| 36 |
33 namespace ui { | 37 namespace ui { |
34 class Range; | 38 class Range; |
35 } // namespace ui | 39 } // namespace ui |
36 | 40 |
37 namespace views { | 41 namespace views { |
38 | 42 |
39 class KeyEvent; | 43 class KeyEvent; |
40 class NativeTextfieldWrapper; | 44 class NativeTextfieldWrapper; |
41 class TextfieldController; | 45 class TextfieldController; |
42 class TextStyle; | |
43 | 46 |
44 // This class implements a View that wraps a native text (edit) field. | 47 // This class implements a View that wraps a native text (edit) field. |
45 class Textfield : public View { | 48 class Textfield : public View { |
46 public: | 49 public: |
47 // The button's class name. | 50 // The button's class name. |
48 static const char kViewClassName[]; | 51 static const char kViewClassName[]; |
49 | 52 |
50 enum StyleFlags { | 53 enum StyleFlags { |
51 STYLE_DEFAULT = 0, | 54 STYLE_DEFAULT = 0, |
52 STYLE_PASSWORD = 1 << 0, | 55 STYLE_PASSWORD = 1 << 0, |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 void GetSelectedRange(ui::Range* range) const; | 182 void GetSelectedRange(ui::Range* range) const; |
180 | 183 |
181 // Selects the text given by |range|. This is views-implementation only and | 184 // Selects the text given by |range|. This is views-implementation only and |
182 // has to be called after the wrapper is created. | 185 // has to be called after the wrapper is created. |
183 void SelectRange(const ui::Range& range); | 186 void SelectRange(const ui::Range& range); |
184 | 187 |
185 // Returns the current cursor position. This is views-implementation | 188 // Returns the current cursor position. This is views-implementation |
186 // only and has to be called after the wrapper is created. | 189 // only and has to be called after the wrapper is created. |
187 size_t GetCursorPosition() const; | 190 size_t GetCursorPosition() const; |
188 | 191 |
189 // Creates a new TextStyle for this textfield. The object is owned | 192 // Applies |style| to the text specified by its range. The style will be |
190 // by the textfield and gets deleted when the textfield is deleted. | 193 // ignored if range is empty or invalid. This is views-implementation only and |
191 // This is views-implementation only and has to be called after the | 194 // has to be called after the wrapper is created. |
192 // wrapper is created. | 195 void ApplyStyleRange(const gfx::StyleRange& style); |
193 TextStyle* CreateTextStyle(); | |
194 | 196 |
195 // Applies the |style| to the text specified by the |range|. If | 197 // Applies the default style to the textfield. This is views-implementation |
196 // there is already a style applied in the |range|, the style of the | 198 // only and has to be called after the wrapper is created. |
197 // overlapping part will be replaced by this sytle. The style will | 199 void ApplyDefaultStyle(); |
198 // be ignored if range is empty or invalid. This is | |
199 // views-implementation only and has to be called after the wrapper | |
200 // is created. | |
201 void ApplyTextStyle(const TextStyle* style, const ui::Range& range); | |
202 | |
203 // Clears All TextStyles. | |
204 // This is views-implementation only and has to be called after the | |
205 // wrapper is created. | |
206 void ClearAllTextStyles(); | |
207 | 200 |
208 // Clears Edit history. | 201 // Clears Edit history. |
209 void ClearEditHistory(); | 202 void ClearEditHistory(); |
210 | 203 |
211 // Set the accessible name of the text field. | 204 // Set the accessible name of the text field. |
212 void SetAccessibleName(const string16& name); | 205 void SetAccessibleName(const string16& name); |
213 | 206 |
214 #ifdef UNIT_TEST | 207 #ifdef UNIT_TEST |
215 gfx::NativeView GetTestingHandle() const { | 208 gfx::NativeView GetTestingHandle() const { |
216 return native_wrapper_ ? native_wrapper_->GetTestingHandle() : NULL; | 209 return native_wrapper_ ? native_wrapper_->GetTestingHandle() : NULL; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 | 294 |
302 // The accessible name of the text field. | 295 // The accessible name of the text field. |
303 string16 accessible_name_; | 296 string16 accessible_name_; |
304 | 297 |
305 DISALLOW_COPY_AND_ASSIGN(Textfield); | 298 DISALLOW_COPY_AND_ASSIGN(Textfield); |
306 }; | 299 }; |
307 | 300 |
308 } // namespace views | 301 } // namespace views |
309 | 302 |
310 #endif // VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 303 #endif // VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
OLD | NEW |