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_TEXTFIELD_H_ | 5 #ifndef VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
6 #define VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 6 #define VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
7 | 7 |
8 #if defined (OS_LINUX) | 8 #if defined (OS_LINUX) |
9 #include <gdk/gdk.h> | 9 #include <gdk/gdk.h> |
10 #endif | 10 #endif |
11 | 11 |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "app/gfx/font.h" | 14 #include "app/gfx/font.h" |
15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
16 #include "base/keyboard_codes.h" | 16 #include "base/keyboard_codes.h" |
| 17 #include "base/logging.h" |
17 #include "base/string16.h" | 18 #include "base/string16.h" |
18 #include "views/view.h" | 19 #include "views/view.h" |
19 #include "third_party/skia/include/core/SkColor.h" | 20 #include "third_party/skia/include/core/SkColor.h" |
20 | 21 |
21 #ifdef UNIT_TEST | 22 #ifdef UNIT_TEST |
22 #include "gfx/native_widget_types.h" | 23 #include "gfx/native_widget_types.h" |
23 #include "views/controls/textfield/native_textfield_wrapper.h" | 24 #include "views/controls/textfield/native_textfield_wrapper.h" |
24 #endif | 25 #endif |
25 | 26 |
26 namespace views { | 27 namespace views { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 // 32 bit number, so the left and right margins are effectively 16 bits. | 172 // 32 bit number, so the left and right margins are effectively 16 bits. |
172 void SetHorizontalMargins(int left, int right); | 173 void SetHorizontalMargins(int left, int right); |
173 | 174 |
174 // Should only be called on a multi-line text field. Sets how many lines of | 175 // Should only be called on a multi-line text field. Sets how many lines of |
175 // text can be displayed at once by this text field. | 176 // text can be displayed at once by this text field. |
176 void SetHeightInLines(int num_lines); | 177 void SetHeightInLines(int num_lines); |
177 | 178 |
178 // Sets the default width of the text control. See default_width_in_chars_. | 179 // Sets the default width of the text control. See default_width_in_chars_. |
179 void set_default_width_in_chars(int default_width) { | 180 void set_default_width_in_chars(int default_width) { |
180 default_width_in_chars_ = default_width; | 181 default_width_in_chars_ = default_width; |
| 182 #if !defined(OS_LINUX) |
| 183 NOTIMPLEMENTED(); |
| 184 #endif |
181 } | 185 } |
182 | 186 |
183 // Removes the border from the edit box, giving it a 2D look. | 187 // Removes the border from the edit box, giving it a 2D look. |
184 bool draw_border() const { return draw_border_; } | 188 bool draw_border() const { return draw_border_; } |
185 void RemoveBorder(); | 189 void RemoveBorder(); |
186 | 190 |
| 191 // Sets the text to display when empty. |
| 192 void set_text_to_display_when_empty(const string16& text) { |
| 193 text_to_display_when_empty_ = text; |
| 194 } |
| 195 const string16& text_to_display_when_empty() { |
| 196 return text_to_display_when_empty_; |
| 197 } |
| 198 |
187 // Updates all properties on the textfield. This is invoked internally. | 199 // Updates all properties on the textfield. This is invoked internally. |
188 // Users of Textfield never need to invoke this directly. | 200 // Users of Textfield never need to invoke this directly. |
189 void UpdateAllProperties(); | 201 void UpdateAllProperties(); |
190 | 202 |
191 // Invoked by the edit control when the value changes. This method set | 203 // Invoked by the edit control when the value changes. This method set |
192 // the text_ member variable to the value contained in edit control. | 204 // the text_ member variable to the value contained in edit control. |
193 // This is important because the edit control can be replaced if it has | 205 // This is important because the edit control can be replaced if it has |
194 // been deleted during a window close. | 206 // been deleted during a window close. |
195 void SyncText(); | 207 void SyncText(); |
196 | 208 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 // The number of lines of text this Textfield displays at once. | 279 // The number of lines of text this Textfield displays at once. |
268 int num_lines_; | 280 int num_lines_; |
269 | 281 |
270 // TODO(beng): remove this once NativeTextfieldWin subclasses | 282 // TODO(beng): remove this once NativeTextfieldWin subclasses |
271 // NativeControlWin. | 283 // NativeControlWin. |
272 bool initialized_; | 284 bool initialized_; |
273 | 285 |
274 // The storage string for the accessibility name associated with this control. | 286 // The storage string for the accessibility name associated with this control. |
275 std::wstring accessible_name_; | 287 std::wstring accessible_name_; |
276 | 288 |
| 289 // Text to display when empty. |
| 290 string16 text_to_display_when_empty_; |
| 291 |
277 DISALLOW_COPY_AND_ASSIGN(Textfield); | 292 DISALLOW_COPY_AND_ASSIGN(Textfield); |
278 }; | 293 }; |
279 | 294 |
280 } // namespace views | 295 } // namespace views |
281 | 296 |
282 #endif // VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 297 #endif // VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
OLD | NEW |