| 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" |
| 11 #include "ui/views/view.h" | 11 #include "ui/views/view.h" |
| 12 | 12 |
| 13 using base::ASCIIToUTF16; | 13 using base::ASCIIToUTF16; |
| 14 using base::WideToUTF16; | 14 using base::WideToUTF16; |
| 15 | 15 |
| 16 namespace views { | 16 namespace views { |
| 17 namespace examples { | 17 namespace examples { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 // A Label with a constrained preferred size to demonstrate eliding or wrapping. | 21 // A Label with a constrained preferred size to demonstrate eliding or wrapping. |
| 22 class PreferredSizeLabel : public Label { | 22 class PreferredSizeLabel : public Label { |
| 23 public: | 23 public: |
| 24 PreferredSizeLabel(); | 24 PreferredSizeLabel(); |
| 25 virtual ~PreferredSizeLabel(); | 25 virtual ~PreferredSizeLabel(); |
| 26 | 26 |
| 27 // Label: | 27 // Label: |
| 28 virtual gfx::Size GetPreferredSize() OVERRIDE; | 28 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
| 29 | 29 |
| 30 private: | 30 private: |
| 31 DISALLOW_COPY_AND_ASSIGN(PreferredSizeLabel); | 31 DISALLOW_COPY_AND_ASSIGN(PreferredSizeLabel); |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 PreferredSizeLabel::PreferredSizeLabel() : Label() { | 34 PreferredSizeLabel::PreferredSizeLabel() : Label() { |
| 35 SetBorder(Border::CreateSolidBorder(2, SK_ColorCYAN)); | 35 SetBorder(Border::CreateSolidBorder(2, SK_ColorCYAN)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 PreferredSizeLabel::~PreferredSizeLabel() {} | 38 PreferredSizeLabel::~PreferredSizeLabel() {} |
| 39 | 39 |
| 40 gfx::Size PreferredSizeLabel::GetPreferredSize() { return gfx::Size(100, 40); } | 40 gfx::Size PreferredSizeLabel::GetPreferredSize() const { |
| 41 return gfx::Size(100, 40); |
| 42 } |
| 41 | 43 |
| 42 } // namespace | 44 } // namespace |
| 43 | 45 |
| 44 LabelExample::LabelExample() : ExampleBase("Label") {} | 46 LabelExample::LabelExample() : ExampleBase("Label") {} |
| 45 | 47 |
| 46 LabelExample::~LabelExample() {} | 48 LabelExample::~LabelExample() {} |
| 47 | 49 |
| 48 void LabelExample::CreateExampleView(View* container) { | 50 void LabelExample::CreateExampleView(View* container) { |
| 49 // A very simple label example, followed by additional helpful examples. | 51 // A very simple label example, followed by additional helpful examples. |
| 50 container->SetLayoutManager(new BoxLayout(BoxLayout::kVertical, 0, 0, 10)); | 52 container->SetLayoutManager(new BoxLayout(BoxLayout::kVertical, 0, 0, 10)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 label->SetMultiLine(true); | 85 label->SetMultiLine(true); |
| 84 container->AddChildView(label); | 86 container->AddChildView(label); |
| 85 | 87 |
| 86 label = new Label(WideToUTF16(L"Password!")); | 88 label = new Label(WideToUTF16(L"Password!")); |
| 87 label->SetObscured(true); | 89 label->SetObscured(true); |
| 88 container->AddChildView(label); | 90 container->AddChildView(label); |
| 89 } | 91 } |
| 90 | 92 |
| 91 } // namespace examples | 93 } // namespace examples |
| 92 } // namespace views | 94 } // namespace views |
| OLD | NEW |