| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/multiline_example.h" | 5 #include "ui/views/examples/multiline_example.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "ui/events/event.h" | 11 #include "ui/events/event.h" |
| 12 #include "ui/gfx/render_text.h" | 12 #include "ui/gfx/render_text.h" |
| 13 #include "ui/views/background.h" | 13 #include "ui/views/background.h" |
| 14 #include "ui/views/border.h" | 14 #include "ui/views/border.h" |
| 15 #include "ui/views/controls/button/checkbox.h" | 15 #include "ui/views/controls/button/checkbox.h" |
| 16 #include "ui/views/controls/label.h" | 16 #include "ui/views/controls/label.h" |
| 17 #include "ui/views/controls/textfield/textfield.h" | 17 #include "ui/views/controls/textfield/textfield.h" |
| 18 #include "ui/views/layout/grid_layout.h" | 18 #include "ui/views/layout/grid_layout.h" |
| 19 #include "ui/views/view.h" | 19 #include "ui/views/view.h" |
| 20 | 20 |
| 21 using base::ASCIIToUTF16; | 21 using base::ASCIIToUTF16; |
| 22 | 22 |
| 23 namespace views { | 23 namespace views { |
| 24 namespace examples { | 24 namespace examples { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 gfx::Range ClampRange(gfx::Range range, size_t max) { | 28 gfx::Range ClampRange(gfx::Range range, uint32_t max) { |
| 29 range.set_start(std::min(range.start(), max)); | 29 range.set_start(std::min(range.start(), max)); |
| 30 range.set_end(std::min(range.end(), max)); | 30 range.set_end(std::min(range.end(), max)); |
| 31 return range; | 31 return range; |
| 32 } | 32 } |
| 33 | 33 |
| 34 // A Label with a clamped preferred width to demonstrate wrapping. | 34 // A Label with a clamped preferred width to demonstrate wrapping. |
| 35 class PreferredSizeLabel : public Label { | 35 class PreferredSizeLabel : public Label { |
| 36 public: | 36 public: |
| 37 PreferredSizeLabel() : Label() {} | 37 PreferredSizeLabel() : Label() {} |
| 38 ~PreferredSizeLabel() override {} | 38 ~PreferredSizeLabel() override {} |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 void MultilineExample::ButtonPressed(Button* sender, const ui::Event& event) { | 185 void MultilineExample::ButtonPressed(Button* sender, const ui::Event& event) { |
| 186 DCHECK_EQ(sender, label_checkbox_); | 186 DCHECK_EQ(sender, label_checkbox_); |
| 187 label_->SetText(label_checkbox_->checked() ? textfield_->text() : | 187 label_->SetText(label_checkbox_->checked() ? textfield_->text() : |
| 188 base::string16()); | 188 base::string16()); |
| 189 container()->Layout(); | 189 container()->Layout(); |
| 190 container()->SchedulePaint(); | 190 container()->SchedulePaint(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 } // namespace examples | 193 } // namespace examples |
| 194 } // namespace views | 194 } // namespace views |
| OLD | NEW |