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/utf_string_conversions.h" | 7 #include "base/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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 void LabelExample::CreateExampleView(View* container) { | 45 void LabelExample::CreateExampleView(View* container) { |
46 // A very simple label example, followed by additional helpful examples. | 46 // A very simple label example, followed by additional helpful examples. |
47 container->SetLayoutManager(new BoxLayout(BoxLayout::kVertical, 0, 0, 10)); | 47 container->SetLayoutManager(new BoxLayout(BoxLayout::kVertical, 0, 0, 10)); |
48 Label* label = new Label(ASCIIToUTF16("Hello world!")); | 48 Label* label = new Label(ASCIIToUTF16("Hello world!")); |
49 container->AddChildView(label); | 49 container->AddChildView(label); |
50 | 50 |
51 const wchar_t hello_world_hebrew[] = | 51 const wchar_t hello_world_hebrew[] = |
52 L"\x5e9\x5dc\x5d5\x5dd \x5d4\x5e2\x5d5\x5dc\x5dd!"; | 52 L"\x5e9\x5dc\x5d5\x5dd \x5d4\x5e2\x5d5\x5dc\x5dd!"; |
53 label = new Label(WideToUTF16(hello_world_hebrew)); | 53 label = new Label(WideToUTF16(hello_world_hebrew)); |
54 label->SetHorizontalAlignment(Label::ALIGN_RIGHT); | 54 label->SetHorizontalAlignment(gfx::ALIGN_RIGHT); |
55 container->AddChildView(label); | 55 container->AddChildView(label); |
56 | 56 |
57 label = new Label(WideToUTF16(L"A UTF16 surrogate pair: \x5d0\x5b0")); | 57 label = new Label(WideToUTF16(L"A UTF16 surrogate pair: \x5d0\x5b0")); |
58 label->SetHorizontalAlignment(Label::ALIGN_RIGHT); | 58 label->SetHorizontalAlignment(gfx::ALIGN_RIGHT); |
59 container->AddChildView(label); | 59 container->AddChildView(label); |
60 | 60 |
61 label = new Label(ASCIIToUTF16("A left-aligned blue label.")); | 61 label = new Label(ASCIIToUTF16("A left-aligned blue label.")); |
62 label->SetHorizontalAlignment(Label::ALIGN_LEFT); | 62 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
63 label->SetEnabledColor(SK_ColorBLUE); | 63 label->SetEnabledColor(SK_ColorBLUE); |
64 container->AddChildView(label); | 64 container->AddChildView(label); |
65 | 65 |
66 label = new Label(ASCIIToUTF16("A Courier-18 label with a shadow.")); | 66 label = new Label(ASCIIToUTF16("A Courier-18 label with a shadow.")); |
67 label->SetFont(gfx::Font("Courier", 18)); | 67 label->SetFont(gfx::Font("Courier", 18)); |
68 label->SetShadowColors(SK_ColorGRAY, SK_ColorLTGRAY); | 68 label->SetShadowColors(SK_ColorGRAY, SK_ColorLTGRAY); |
69 label->SetShadowOffset(1, 1); | 69 label->SetShadowOffset(1, 1); |
70 container->AddChildView(label); | 70 container->AddChildView(label); |
71 | 71 |
72 label = new PreferredSizeLabel(); | 72 label = new PreferredSizeLabel(); |
73 label->SetText(ASCIIToUTF16("A long label will elide toward its logical end " | 73 label->SetText(ASCIIToUTF16("A long label will elide toward its logical end " |
74 "if the text's width exceeds the label's available width.")); | 74 "if the text's width exceeds the label's available width.")); |
75 container->AddChildView(label); | 75 container->AddChildView(label); |
76 | 76 |
77 label = new PreferredSizeLabel(); | 77 label = new PreferredSizeLabel(); |
78 label->SetText(ASCIIToUTF16("A multi-line label will wrap onto subsequent " | 78 label->SetText(ASCIIToUTF16("A multi-line label will wrap onto subsequent " |
79 "lines if the text's width exceeds the label's available width.")); | 79 "lines if the text's width exceeds the label's available width.")); |
80 label->SetMultiLine(true); | 80 label->SetMultiLine(true); |
81 container->AddChildView(label); | 81 container->AddChildView(label); |
82 } | 82 } |
83 | 83 |
84 } // namespace examples | 84 } // namespace examples |
85 } // namespace views | 85 } // namespace views |
OLD | NEW |