| 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 "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "ui/events/event.h" | 8 #include "ui/events/event.h" |
| 9 #include "ui/gfx/render_text.h" | 9 #include "ui/gfx/render_text.h" |
| 10 #include "ui/views/background.h" | 10 #include "ui/views/background.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 DISALLOW_COPY_AND_ASSIGN(PreferredSizeLabel); | 43 DISALLOW_COPY_AND_ASSIGN(PreferredSizeLabel); |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 } // namespace | 46 } // namespace |
| 47 | 47 |
| 48 // A simple View that hosts a RenderText object. | 48 // A simple View that hosts a RenderText object. |
| 49 class MultilineExample::RenderTextView : public View { | 49 class MultilineExample::RenderTextView : public View { |
| 50 public: | 50 public: |
| 51 RenderTextView() : render_text_(gfx::RenderText::CreateInstance()) { | 51 RenderTextView() : render_text_(gfx::RenderText::CreateInstanceForEditing()) { |
| 52 render_text_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 52 render_text_->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 53 render_text_->SetColor(SK_ColorBLACK); | 53 render_text_->SetColor(SK_ColorBLACK); |
| 54 render_text_->SetMultiline(true); | 54 render_text_->SetMultiline(true); |
| 55 SetBorder(Border::CreateSolidBorder(2, SK_ColorGRAY)); | 55 SetBorder(Border::CreateSolidBorder(2, SK_ColorGRAY)); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void OnPaint(gfx::Canvas* canvas) override { | 58 void OnPaint(gfx::Canvas* canvas) override { |
| 59 View::OnPaint(canvas); | 59 View::OnPaint(canvas); |
| 60 render_text_->Draw(canvas); | 60 render_text_->Draw(canvas); |
| 61 } | 61 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 void MultilineExample::ButtonPressed(Button* sender, const ui::Event& event) { | 182 void MultilineExample::ButtonPressed(Button* sender, const ui::Event& event) { |
| 183 DCHECK_EQ(sender, label_checkbox_); | 183 DCHECK_EQ(sender, label_checkbox_); |
| 184 label_->SetText(label_checkbox_->checked() ? textfield_->text() : | 184 label_->SetText(label_checkbox_->checked() ? textfield_->text() : |
| 185 base::string16()); | 185 base::string16()); |
| 186 container()->Layout(); | 186 container()->Layout(); |
| 187 container()->SchedulePaint(); | 187 container()->SchedulePaint(); |
| 188 } | 188 } |
| 189 | 189 |
| 190 } // namespace examples | 190 } // namespace examples |
| 191 } // namespace views | 191 } // namespace views |
| OLD | NEW |