OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ui/views/controls/textfield/textfield.h" | 5 #include "ui/views/controls/textfield/textfield.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
23 #include "base/win/win_util.h" | 23 #include "base/win/win_util.h" |
24 // TODO(beng): this should be removed when the OS_WIN hack from | 24 // TODO(beng): this should be removed when the OS_WIN hack from |
25 // ViewHierarchyChanged is removed. | 25 // ViewHierarchyChanged is removed. |
26 #include "ui/views/controls/textfield/native_textfield_views.h" | 26 #include "ui/views/controls/textfield/native_textfield_views.h" |
27 #include "ui/views/controls/textfield/native_textfield_win.h" | 27 #include "ui/views/controls/textfield/native_textfield_win.h" |
28 #endif | 28 #endif |
29 | 29 |
30 namespace views { | 30 namespace views { |
31 | 31 |
| 32 // Default placeholder text color. |
| 33 const SkColor kDefaultPlaceholderTextColor = SK_ColorLTGRAY; |
| 34 |
32 // static | 35 // static |
33 const char Textfield::kViewClassName[] = "views/Textfield"; | 36 const char Textfield::kViewClassName[] = "views/Textfield"; |
34 | 37 |
35 ///////////////////////////////////////////////////////////////////////////// | 38 ///////////////////////////////////////////////////////////////////////////// |
36 // Textfield | 39 // Textfield |
37 | 40 |
38 Textfield::Textfield() | 41 Textfield::Textfield() |
39 : native_wrapper_(NULL), | 42 : native_wrapper_(NULL), |
40 controller_(NULL), | 43 controller_(NULL), |
41 style_(STYLE_DEFAULT), | 44 style_(STYLE_DEFAULT), |
42 read_only_(false), | 45 read_only_(false), |
43 default_width_in_chars_(0), | 46 default_width_in_chars_(0), |
44 draw_border_(true), | 47 draw_border_(true), |
45 text_color_(SK_ColorBLACK), | 48 text_color_(SK_ColorBLACK), |
46 use_default_text_color_(true), | 49 use_default_text_color_(true), |
47 background_color_(SK_ColorWHITE), | 50 background_color_(SK_ColorWHITE), |
48 use_default_background_color_(true), | 51 use_default_background_color_(true), |
49 cursor_color_(SK_ColorBLACK), | 52 cursor_color_(SK_ColorBLACK), |
50 use_default_cursor_color_(true), | 53 use_default_cursor_color_(true), |
51 initialized_(false), | 54 initialized_(false), |
52 horizontal_margins_were_set_(false), | 55 horizontal_margins_were_set_(false), |
53 vertical_margins_were_set_(false), | 56 vertical_margins_were_set_(false), |
| 57 placeholder_text_color_(kDefaultPlaceholderTextColor), |
54 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) { | 58 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) { |
55 set_focusable(true); | 59 set_focusable(true); |
56 } | 60 } |
57 | 61 |
58 Textfield::Textfield(StyleFlags style) | 62 Textfield::Textfield(StyleFlags style) |
59 : native_wrapper_(NULL), | 63 : native_wrapper_(NULL), |
60 controller_(NULL), | 64 controller_(NULL), |
61 style_(style), | 65 style_(style), |
62 read_only_(false), | 66 read_only_(false), |
63 default_width_in_chars_(0), | 67 default_width_in_chars_(0), |
64 draw_border_(true), | 68 draw_border_(true), |
65 text_color_(SK_ColorBLACK), | 69 text_color_(SK_ColorBLACK), |
66 use_default_text_color_(true), | 70 use_default_text_color_(true), |
67 background_color_(SK_ColorWHITE), | 71 background_color_(SK_ColorWHITE), |
68 use_default_background_color_(true), | 72 use_default_background_color_(true), |
69 cursor_color_(SK_ColorBLACK), | 73 cursor_color_(SK_ColorBLACK), |
70 use_default_cursor_color_(true), | 74 use_default_cursor_color_(true), |
71 initialized_(false), | 75 initialized_(false), |
72 horizontal_margins_were_set_(false), | 76 horizontal_margins_were_set_(false), |
73 vertical_margins_were_set_(false), | 77 vertical_margins_were_set_(false), |
| 78 placeholder_text_color_(kDefaultPlaceholderTextColor), |
74 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) { | 79 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) { |
75 set_focusable(true); | 80 set_focusable(true); |
76 if (IsObscured()) | 81 if (IsObscured()) |
77 SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); | 82 SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
78 } | 83 } |
79 | 84 |
80 Textfield::~Textfield() { | 85 Textfield::~Textfield() { |
81 } | 86 } |
82 | 87 |
83 void Textfield::SetController(TextfieldController* controller) { | 88 void Textfield::SetController(TextfieldController* controller) { |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 static_cast<NativeTextfieldWin*>(native_wrapper_)->AttachHack(); | 458 static_cast<NativeTextfieldWin*>(native_wrapper_)->AttachHack(); |
454 #endif | 459 #endif |
455 } | 460 } |
456 } | 461 } |
457 | 462 |
458 std::string Textfield::GetClassName() const { | 463 std::string Textfield::GetClassName() const { |
459 return kViewClassName; | 464 return kViewClassName; |
460 } | 465 } |
461 | 466 |
462 } // namespace views | 467 } // namespace views |
OLD | NEW |