| 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 private: | 109 private: |
| 110 void OnBoundsChanged(const gfx::Rect& previous_bounds) override { | 110 void OnBoundsChanged(const gfx::Rect& previous_bounds) override { |
| 111 gfx::Rect bounds = GetLocalBounds(); | 111 gfx::Rect bounds = GetLocalBounds(); |
| 112 bounds.Inset(GetInsets()); | 112 bounds.Inset(GetInsets()); |
| 113 render_text_->SetDisplayRect(bounds); | 113 render_text_->SetDisplayRect(bounds); |
| 114 } | 114 } |
| 115 | 115 |
| (...skipping 69 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 |