| 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" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 gfx::Range bold_range = ClampRange(gfx::Range(4, 10), range_max); | 94 gfx::Range bold_range = ClampRange(gfx::Range(4, 10), range_max); |
| 95 gfx::Range italic_range = ClampRange(gfx::Range(7, 13), range_max); | 95 gfx::Range italic_range = ClampRange(gfx::Range(7, 13), range_max); |
| 96 | 96 |
| 97 render_text_->SetText(new_contents); | 97 render_text_->SetText(new_contents); |
| 98 render_text_->SetColor(SK_ColorBLACK); | 98 render_text_->SetColor(SK_ColorBLACK); |
| 99 render_text_->ApplyColor(0xFFFF0000, color_range); | 99 render_text_->ApplyColor(0xFFFF0000, color_range); |
| 100 render_text_->SetStyle(gfx::DIAGONAL_STRIKE, false); | 100 render_text_->SetStyle(gfx::DIAGONAL_STRIKE, false); |
| 101 render_text_->ApplyStyle(gfx::DIAGONAL_STRIKE, true, color_range); | 101 render_text_->ApplyStyle(gfx::DIAGONAL_STRIKE, true, color_range); |
| 102 render_text_->SetStyle(gfx::UNDERLINE, false); | 102 render_text_->SetStyle(gfx::UNDERLINE, false); |
| 103 render_text_->ApplyStyle(gfx::UNDERLINE, true, color_range); | 103 render_text_->ApplyStyle(gfx::UNDERLINE, true, color_range); |
| 104 render_text_->ApplyStyle(gfx::BOLD, true, bold_range); | |
| 105 render_text_->ApplyStyle(gfx::ITALIC, true, italic_range); | 104 render_text_->ApplyStyle(gfx::ITALIC, true, italic_range); |
| 105 render_text_->ApplyWeight(gfx::Font::Weight::BOLD, bold_range); |
| 106 InvalidateLayout(); | 106 InvalidateLayout(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void SetMaxLines(int max_lines) { | 109 void SetMaxLines(int max_lines) { |
| 110 render_text_->SetMaxLines(max_lines); | 110 render_text_->SetMaxLines(max_lines); |
| 111 render_text_->SetElideBehavior(max_lines ? gfx::ELIDE_TAIL : gfx::NO_ELIDE); | 111 render_text_->SetElideBehavior(max_lines ? gfx::ELIDE_TAIL : gfx::NO_ELIDE); |
| 112 } | 112 } |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 void OnBoundsChanged(const gfx::Rect& previous_bounds) override { | 115 void OnBoundsChanged(const gfx::Rect& previous_bounds) override { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 : base::string16()); | 201 : base::string16()); |
| 202 } else if (sender == elision_checkbox_) { | 202 } else if (sender == elision_checkbox_) { |
| 203 render_text_view_->SetMaxLines(elision_checkbox_->checked() ? 3 : 0); | 203 render_text_view_->SetMaxLines(elision_checkbox_->checked() ? 3 : 0); |
| 204 } | 204 } |
| 205 container()->Layout(); | 205 container()->Layout(); |
| 206 container()->SchedulePaint(); | 206 container()->SchedulePaint(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 } // namespace examples | 209 } // namespace examples |
| 210 } // namespace views | 210 } // namespace views |
| OLD | NEW |