| 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/label_example.h" | 5 #include "ui/views/examples/label_example.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "ui/gfx/geometry/vector2d.h" | 10 #include "ui/gfx/geometry/vector2d.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 label->SetText(ASCIIToUTF16("A multi-line label will wrap onto subsequent " | 108 label->SetText(ASCIIToUTF16("A multi-line label will wrap onto subsequent " |
| 109 "lines if the text's width exceeds the label's available width, which is " | 109 "lines if the text's width exceeds the label's available width, which is " |
| 110 "helpful for extemely long text used to demonstrate line wrapping.")); | 110 "helpful for extemely long text used to demonstrate line wrapping.")); |
| 111 label->SetMultiLine(true); | 111 label->SetMultiLine(true); |
| 112 container->AddChildView(label); | 112 container->AddChildView(label); |
| 113 | 113 |
| 114 label = new Label(ASCIIToUTF16("Label with thick border")); | 114 label = new Label(ASCIIToUTF16("Label with thick border")); |
| 115 label->SetBorder(Border::CreateSolidBorder(20, SK_ColorRED)); | 115 label->SetBorder(Border::CreateSolidBorder(20, SK_ColorRED)); |
| 116 container->AddChildView(label); | 116 container->AddChildView(label); |
| 117 | 117 |
| 118 label = new Label( |
| 119 ASCIIToUTF16("A selectable label with custom colors for text.")); |
| 120 label->SetSelectionTextColor(SK_ColorBLUE); |
| 121 label->SetSelectionBackgroundColor(SK_ColorYELLOW); |
| 122 label->SetEnabledColor(SK_ColorRED); |
| 123 label->SetSelectable(true); |
| 124 container->AddChildView(label); |
| 125 |
| 118 AddCustomLabel(container); | 126 AddCustomLabel(container); |
| 119 } | 127 } |
| 120 | 128 |
| 121 void LabelExample::ButtonPressed(Button* button, const ui::Event& event) { | 129 void LabelExample::ButtonPressed(Button* button, const ui::Event& event) { |
| 122 if (button == multiline_) { | 130 if (button == multiline_) { |
| 123 custom_label_->SetMultiLine(multiline_->checked()); | 131 custom_label_->SetMultiLine(multiline_->checked()); |
| 124 } else if (button == shadows_) { | 132 } else if (button == shadows_) { |
| 125 gfx::ShadowValues shadows; | 133 gfx::ShadowValues shadows; |
| 126 if (shadows_->checked()) { | 134 if (shadows_->checked()) { |
| 127 shadows.push_back(gfx::ShadowValue(gfx::Vector2d(), 1, SK_ColorRED)); | 135 shadows.push_back(gfx::ShadowValue(gfx::Vector2d(), 1, SK_ColorRED)); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 example_combobox_models_.push_back(base::WrapUnique(model)); | 222 example_combobox_models_.push_back(base::WrapUnique(model)); |
| 215 Combobox* combobox = new Combobox(model); | 223 Combobox* combobox = new Combobox(model); |
| 216 combobox->SetSelectedIndex(0); | 224 combobox->SetSelectedIndex(0); |
| 217 combobox->set_listener(this); | 225 combobox->set_listener(this); |
| 218 layout->AddView(combobox); | 226 layout->AddView(combobox); |
| 219 return combobox; | 227 return combobox; |
| 220 } | 228 } |
| 221 | 229 |
| 222 } // namespace examples | 230 } // namespace examples |
| 223 } // namespace views | 231 } // namespace views |
| OLD | NEW |