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 #include "ui/views/examples/textfield_example.h" | 5 #include "ui/views/examples/textfield_example.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "ui/base/range/range.h" | 8 #include "ui/base/range/range.h" |
9 #include "ui/gfx/render_text.h" | 9 #include "ui/gfx/render_text.h" |
10 #include "ui/views/controls/label.h" | 10 #include "ui/views/controls/label.h" |
11 #include "ui/views/controls/textfield/textfield.h" | 11 #include "ui/views/controls/textfield/textfield.h" |
12 #include "ui/views/layout/grid_layout.h" | 12 #include "ui/views/layout/grid_layout.h" |
13 #include "ui/views/view.h" | 13 #include "ui/views/view.h" |
14 | 14 |
15 namespace views { | 15 namespace views { |
16 namespace examples { | 16 namespace examples { |
17 | 17 |
18 TextfieldExample::TextfieldExample() : ExampleBase("Textfield") { | 18 TextfieldExample::TextfieldExample() : ExampleBase("Textfield") { |
19 } | 19 } |
20 | 20 |
21 TextfieldExample::~TextfieldExample() { | 21 TextfieldExample::~TextfieldExample() { |
22 } | 22 } |
23 | 23 |
24 void TextfieldExample::CreateExampleView(View* container) { | 24 void TextfieldExample::CreateExampleView(View* container) { |
25 name_ = new Textfield(); | 25 name_ = new Textfield(); |
26 password_ = new Textfield(Textfield::STYLE_PASSWORD); | 26 password_ = new Textfield(Textfield::STYLE_OBSCURED); |
27 password_->set_text_to_display_when_empty(ASCIIToUTF16("password")); | 27 password_->set_text_to_display_when_empty(ASCIIToUTF16("password")); |
28 show_password_ = new TextButton(this, ASCIIToUTF16("Show password")); | 28 show_password_ = new TextButton(this, ASCIIToUTF16("Show password")); |
29 clear_all_ = new TextButton(this, ASCIIToUTF16("Clear All")); | 29 clear_all_ = new TextButton(this, ASCIIToUTF16("Clear All")); |
30 append_ = new TextButton(this, ASCIIToUTF16("Append")); | 30 append_ = new TextButton(this, ASCIIToUTF16("Append")); |
31 set_ = new TextButton(this, ASCIIToUTF16("Set")); | 31 set_ = new TextButton(this, ASCIIToUTF16("Set")); |
32 set_style_ = new TextButton(this, ASCIIToUTF16("Set Styles")); | 32 set_style_ = new TextButton(this, ASCIIToUTF16("Set Styles")); |
33 name_->SetController(this); | 33 name_->SetController(this); |
34 password_->SetController(this); | 34 password_->SetController(this); |
35 | 35 |
36 GridLayout* layout = new GridLayout(container); | 36 GridLayout* layout = new GridLayout(container); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 strike.foreground = SK_ColorRED; | 105 strike.foreground = SK_ColorRED; |
106 strike.range = ui::Range(2 * fifth, 3 * fifth); | 106 strike.range = ui::Range(2 * fifth, 3 * fifth); |
107 name_->ApplyStyleRange(strike); | 107 name_->ApplyStyleRange(strike); |
108 } | 108 } |
109 } | 109 } |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 } // namespace examples | 113 } // namespace examples |
114 } // namespace views | 114 } // namespace views |
OLD | NEW |