Index: ui/views/examples/multiline_example.h |
diff --git a/ui/views/examples/multiline_example.h b/ui/views/examples/multiline_example.h |
index a4c3ba56ea0d3de17867b20677d2cc3eb56e0307..10d13409b1baa0537d902c817c875294f7096473 100644 |
--- a/ui/views/examples/multiline_example.h |
+++ b/ui/views/examples/multiline_example.h |
@@ -10,6 +10,10 @@ |
#include "ui/views/controls/textfield/textfield_controller.h" |
#include "ui/views/examples/example_base.h" |
+namespace gfx { |
+class RenderText; |
+} |
+ |
namespace views { |
class Checkbox; |
@@ -22,7 +26,7 @@ class VIEWS_EXAMPLES_EXPORT MultilineExample : public ExampleBase, |
public TextfieldController, |
public ButtonListener { |
public: |
- MultilineExample(); |
+ explicit MultilineExample(const char* name); |
~MultilineExample() override; |
// ExampleBase: |
@@ -31,13 +35,16 @@ class VIEWS_EXAMPLES_EXPORT MultilineExample : public ExampleBase, |
// ButtonListener: |
void ButtonPressed(Button* sender, const ui::Event& event) override; |
- private: |
+ protected: |
class RenderTextView; |
+ virtual RenderTextView* CreateTextView(); |
+ |
// TextfieldController: |
void ContentsChanged(Textfield* sender, |
const base::string16& new_contents) override; |
+ private: |
RenderTextView* render_text_view_; |
Label* label_; |
Textfield* textfield_; |
@@ -48,6 +55,27 @@ class VIEWS_EXAMPLES_EXPORT MultilineExample : public ExampleBase, |
DISALLOW_COPY_AND_ASSIGN(MultilineExample); |
}; |
+// A simple View that hosts a RenderText object. |
+class MultilineExample::RenderTextView : public View { |
+ public: |
+ RenderTextView(); |
+ ~RenderTextView() override; |
+ |
+ void SetText(const base::string16& new_contents); |
+ gfx::RenderText* render_text() { return render_text_.get(); } |
+ |
+ // View: |
+ void OnPaint(gfx::Canvas* canvas) override; |
+ gfx::Size GetPreferredSize() const override; |
+ int GetHeightForWidth(int w) const override; |
+ void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
+ |
+ private: |
+ std::unique_ptr<gfx::RenderText> render_text_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(RenderTextView); |
+}; |
+ |
} // namespace examples |
} // namespace views |