| 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/examples/textfield_example.h" | 5 #include "ui/views/examples/textfield_example.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "ui/events/event.h" | 8 #include "ui/events/event.h" |
| 9 #include "ui/gfx/range/range.h" | 9 #include "ui/gfx/range/range.h" |
| 10 #include "ui/gfx/render_text.h" | 10 #include "ui/gfx/render_text.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 layout->AddView(clear_all_); | 70 layout->AddView(clear_all_); |
| 71 layout->StartRow(0, 0); | 71 layout->StartRow(0, 0); |
| 72 layout->AddView(append_); | 72 layout->AddView(append_); |
| 73 layout->StartRow(0, 0); | 73 layout->StartRow(0, 0); |
| 74 layout->AddView(set_); | 74 layout->AddView(set_); |
| 75 layout->StartRow(0, 0); | 75 layout->StartRow(0, 0); |
| 76 layout->AddView(set_style_); | 76 layout->AddView(set_style_); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void TextfieldExample::ContentsChanged(Textfield* sender, | 79 void TextfieldExample::ContentsChanged(Textfield* sender, |
| 80 const string16& new_contents) { | 80 const base::string16& new_contents) { |
| 81 if (sender == name_) { | 81 if (sender == name_) { |
| 82 PrintStatus("Name [%s]", UTF16ToUTF8(new_contents).c_str()); | 82 PrintStatus("Name [%s]", UTF16ToUTF8(new_contents).c_str()); |
| 83 } else if (sender == password_) { | 83 } else if (sender == password_) { |
| 84 PrintStatus("Password [%s]", UTF16ToUTF8(new_contents).c_str()); | 84 PrintStatus("Password [%s]", UTF16ToUTF8(new_contents).c_str()); |
| 85 } else if (sender == read_only_) { | 85 } else if (sender == read_only_) { |
| 86 PrintStatus("Read Only [%s]", UTF16ToUTF8(new_contents).c_str()); | 86 PrintStatus("Read Only [%s]", UTF16ToUTF8(new_contents).c_str()); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 bool TextfieldExample::HandleKeyEvent(Textfield* sender, | 90 bool TextfieldExample::HandleKeyEvent(Textfield* sender, |
| 91 const ui::KeyEvent& key_event) { | 91 const ui::KeyEvent& key_event) { |
| 92 return false; | 92 return false; |
| 93 } | 93 } |
| 94 | 94 |
| 95 bool TextfieldExample::HandleMouseEvent(Textfield* sender, | 95 bool TextfieldExample::HandleMouseEvent(Textfield* sender, |
| 96 const ui::MouseEvent& mouse_event) { | 96 const ui::MouseEvent& mouse_event) { |
| 97 PrintStatus("HandleMouseEvent click count=%d", mouse_event.GetClickCount()); | 97 PrintStatus("HandleMouseEvent click count=%d", mouse_event.GetClickCount()); |
| 98 return false; | 98 return false; |
| 99 } | 99 } |
| 100 | 100 |
| 101 void TextfieldExample::ButtonPressed(Button* sender, const ui::Event& event) { | 101 void TextfieldExample::ButtonPressed(Button* sender, const ui::Event& event) { |
| 102 if (sender == show_password_) { | 102 if (sender == show_password_) { |
| 103 PrintStatus("Password [%s]", UTF16ToUTF8(password_->text()).c_str()); | 103 PrintStatus("Password [%s]", UTF16ToUTF8(password_->text()).c_str()); |
| 104 } else if (sender == clear_all_) { | 104 } else if (sender == clear_all_) { |
| 105 string16 empty; | 105 base::string16 empty; |
| 106 name_->SetText(empty); | 106 name_->SetText(empty); |
| 107 password_->SetText(empty); | 107 password_->SetText(empty); |
| 108 read_only_->SetText(empty); | 108 read_only_->SetText(empty); |
| 109 } else if (sender == append_) { | 109 } else if (sender == append_) { |
| 110 name_->AppendText(ASCIIToUTF16("[append]")); | 110 name_->AppendText(ASCIIToUTF16("[append]")); |
| 111 password_->AppendText(ASCIIToUTF16("[append]")); | 111 password_->AppendText(ASCIIToUTF16("[append]")); |
| 112 read_only_->AppendText(ASCIIToUTF16("[append]")); | 112 read_only_->AppendText(ASCIIToUTF16("[append]")); |
| 113 } else if (sender == set_) { | 113 } else if (sender == set_) { |
| 114 name_->SetText(ASCIIToUTF16("[set]")); | 114 name_->SetText(ASCIIToUTF16("[set]")); |
| 115 password_->SetText(ASCIIToUTF16("[set]")); | 115 password_->SetText(ASCIIToUTF16("[set]")); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 131 name_->ApplyStyle(gfx::UNDERLINE, false, small_range); | 131 name_->ApplyStyle(gfx::UNDERLINE, false, small_range); |
| 132 name_->ApplyStyle(gfx::DIAGONAL_STRIKE, true, small_range); | 132 name_->ApplyStyle(gfx::DIAGONAL_STRIKE, true, small_range); |
| 133 name_->ApplyColor(SK_ColorRED, small_range); | 133 name_->ApplyColor(SK_ColorRED, small_range); |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace examples | 139 } // namespace examples |
| 140 } // namespace views | 140 } // namespace views |
| OLD | NEW |