Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: ui/views/controls/textfield/textfield.cc

Issue 10310131: Support placeholder text in NativeTextfieldViews. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for comments in #3 Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/examples/textfield_example.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "ui/base/accessibility/accessible_view_state.h" 11 #include "ui/base/accessibility/accessible_view_state.h"
12 #include "ui/base/ime/text_input_type.h" 12 #include "ui/base/ime/text_input_type.h"
13 #include "ui/base/keycodes/keyboard_codes.h" 13 #include "ui/base/keycodes/keyboard_codes.h"
14 #include "ui/base/range/range.h" 14 #include "ui/base/range/range.h"
15 #include "ui/gfx/insets.h" 15 #include "ui/gfx/insets.h"
16 #include "ui/gfx/selection_model.h" 16 #include "ui/gfx/selection_model.h"
17 #include "ui/views/controls/native/native_view_host.h" 17 #include "ui/views/controls/native/native_view_host.h"
18 #include "ui/views/controls/textfield/native_textfield_wrapper.h" 18 #include "ui/views/controls/textfield/native_textfield_wrapper.h"
19 #include "ui/views/controls/textfield/textfield_controller.h" 19 #include "ui/views/controls/textfield/textfield_controller.h"
20 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
21 21
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 {
31
32 // Default placeholder text color.
33 const SkColor kDefaultPlaceholderTextColor = SK_ColorLTGRAY;
34
35 } // namespace
36
30 namespace views { 37 namespace views {
31 38
32 // static 39 // static
33 const char Textfield::kViewClassName[] = "views/Textfield"; 40 const char Textfield::kViewClassName[] = "views/Textfield";
34 41
35 ///////////////////////////////////////////////////////////////////////////// 42 /////////////////////////////////////////////////////////////////////////////
36 // Textfield 43 // Textfield
37 44
38 Textfield::Textfield() 45 Textfield::Textfield()
39 : native_wrapper_(NULL), 46 : native_wrapper_(NULL),
40 controller_(NULL), 47 controller_(NULL),
41 style_(STYLE_DEFAULT), 48 style_(STYLE_DEFAULT),
42 read_only_(false), 49 read_only_(false),
43 default_width_in_chars_(0), 50 default_width_in_chars_(0),
44 draw_border_(true), 51 draw_border_(true),
45 text_color_(SK_ColorBLACK), 52 text_color_(SK_ColorBLACK),
46 use_default_text_color_(true), 53 use_default_text_color_(true),
47 background_color_(SK_ColorWHITE), 54 background_color_(SK_ColorWHITE),
48 use_default_background_color_(true), 55 use_default_background_color_(true),
49 cursor_color_(SK_ColorBLACK), 56 cursor_color_(SK_ColorBLACK),
50 use_default_cursor_color_(true), 57 use_default_cursor_color_(true),
51 initialized_(false), 58 initialized_(false),
52 horizontal_margins_were_set_(false), 59 horizontal_margins_were_set_(false),
53 vertical_margins_were_set_(false), 60 vertical_margins_were_set_(false),
61 placeholder_text_color_(kDefaultPlaceholderTextColor),
54 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) { 62 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) {
55 set_focusable(true); 63 set_focusable(true);
56 } 64 }
57 65
58 Textfield::Textfield(StyleFlags style) 66 Textfield::Textfield(StyleFlags style)
59 : native_wrapper_(NULL), 67 : native_wrapper_(NULL),
60 controller_(NULL), 68 controller_(NULL),
61 style_(style), 69 style_(style),
62 read_only_(false), 70 read_only_(false),
63 default_width_in_chars_(0), 71 default_width_in_chars_(0),
64 draw_border_(true), 72 draw_border_(true),
65 text_color_(SK_ColorBLACK), 73 text_color_(SK_ColorBLACK),
66 use_default_text_color_(true), 74 use_default_text_color_(true),
67 background_color_(SK_ColorWHITE), 75 background_color_(SK_ColorWHITE),
68 use_default_background_color_(true), 76 use_default_background_color_(true),
69 cursor_color_(SK_ColorBLACK), 77 cursor_color_(SK_ColorBLACK),
70 use_default_cursor_color_(true), 78 use_default_cursor_color_(true),
71 initialized_(false), 79 initialized_(false),
72 horizontal_margins_were_set_(false), 80 horizontal_margins_were_set_(false),
73 vertical_margins_were_set_(false), 81 vertical_margins_were_set_(false),
82 placeholder_text_color_(kDefaultPlaceholderTextColor),
74 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) { 83 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) {
75 set_focusable(true); 84 set_focusable(true);
76 if (IsObscured()) 85 if (IsObscured())
77 SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 86 SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
78 } 87 }
79 88
80 Textfield::~Textfield() { 89 Textfield::~Textfield() {
81 } 90 }
82 91
83 void Textfield::SetController(TextfieldController* controller) { 92 void Textfield::SetController(TextfieldController* controller) {
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 static_cast<NativeTextfieldWin*>(native_wrapper_)->AttachHack(); 462 static_cast<NativeTextfieldWin*>(native_wrapper_)->AttachHack();
454 #endif 463 #endif
455 } 464 }
456 } 465 }
457 466
458 std::string Textfield::GetClassName() const { 467 std::string Textfield::GetClassName() const {
459 return kViewClassName; 468 return kViewClassName;
460 } 469 }
461 470
462 } // namespace views 471 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/examples/textfield_example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698