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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "ui/views/border.h" | 8 #include "ui/views/border.h" |
9 #include "ui/views/controls/label.h" | 9 #include "ui/views/controls/label.h" |
10 #include "ui/views/layout/box_layout.h" | 10 #include "ui/views/layout/box_layout.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 label = new Label(WideToUTF16(L"A UTF16 surrogate pair: \x5d0\x5b0")); | 56 label = new Label(WideToUTF16(L"A UTF16 surrogate pair: \x5d0\x5b0")); |
57 label->SetHorizontalAlignment(gfx::ALIGN_RIGHT); | 57 label->SetHorizontalAlignment(gfx::ALIGN_RIGHT); |
58 container->AddChildView(label); | 58 container->AddChildView(label); |
59 | 59 |
60 label = new Label(ASCIIToUTF16("A left-aligned blue label.")); | 60 label = new Label(ASCIIToUTF16("A left-aligned blue label.")); |
61 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 61 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
62 label->SetEnabledColor(SK_ColorBLUE); | 62 label->SetEnabledColor(SK_ColorBLUE); |
63 container->AddChildView(label); | 63 container->AddChildView(label); |
64 | 64 |
65 label = new Label(ASCIIToUTF16("A Courier-18 label with a halo and shadow.")); | 65 label = new Label(ASCIIToUTF16("A Courier-18 label with shadows.")); |
66 label->SetFontList(gfx::FontList("Courier, 18px")); | 66 label->SetFontList(gfx::FontList("Courier, 18px")); |
67 label->set_shadows(gfx::ShadowValues(1, | 67 gfx::ShadowValues shadows(1, gfx::ShadowValue(gfx::Point(), 1, SK_ColorRED)); |
68 gfx::ShadowValue(gfx::Point(2, 2), 0, SK_ColorGRAY))); | 68 gfx::ShadowValue shadow(gfx::Point(2, 2), 0, SK_ColorGRAY); |
69 label->set_halo_color(SK_ColorGREEN); | 69 shadows.push_back(shadow); |
| 70 label->set_shadows(shadows); |
70 container->AddChildView(label); | 71 container->AddChildView(label); |
71 | 72 |
72 label = new PreferredSizeLabel(); | 73 label = new PreferredSizeLabel(); |
73 label->SetText(ASCIIToUTF16("A long label will elide toward its logical end " | 74 label->SetText(ASCIIToUTF16("A long label will elide toward its logical end " |
74 "if the text's width exceeds the label's available width.")); | 75 "if the text's width exceeds the label's available width.")); |
75 container->AddChildView(label); | 76 container->AddChildView(label); |
76 | 77 |
77 label = new PreferredSizeLabel(); | 78 label = new PreferredSizeLabel(); |
78 label->SetElideBehavior(gfx::FADE_TAIL); | 79 label->SetElideBehavior(gfx::FADE_TAIL); |
79 label->SetText(ASCIIToUTF16("Some long labels will fade, rather than elide, " | 80 label->SetText(ASCIIToUTF16("Some long labels will fade, rather than elide, " |
80 "if the text's width exceeds the label's available width.")); | 81 "if the text's width exceeds the label's available width.")); |
81 container->AddChildView(label); | 82 container->AddChildView(label); |
82 | 83 |
83 label = new PreferredSizeLabel(); | 84 label = new PreferredSizeLabel(); |
84 label->SetText(ASCIIToUTF16("A multi-line label will wrap onto subsequent " | 85 label->SetText(ASCIIToUTF16("A multi-line label will wrap onto subsequent " |
85 "lines if the text's width exceeds the label's available width.")); | 86 "lines if the text's width exceeds the label's available width.")); |
86 label->SetMultiLine(true); | 87 label->SetMultiLine(true); |
87 container->AddChildView(label); | 88 container->AddChildView(label); |
88 | 89 |
89 label = new Label(WideToUTF16(L"Password!")); | 90 label = new Label(WideToUTF16(L"Password!")); |
90 label->SetObscured(true); | 91 label->SetObscured(true); |
91 container->AddChildView(label); | 92 container->AddChildView(label); |
92 } | 93 } |
93 | 94 |
94 } // namespace examples | 95 } // namespace examples |
95 } // namespace views | 96 } // namespace views |
OLD | NEW |