| Index: views/examples/example_base.cc
|
| diff --git a/views/examples/example_base.cc b/views/examples/example_base.cc
|
| index 70185b5d23202aced0fb550ee8fe879e1d25b391..149ea52ef1c545f27950edaaf45adb26aaeafb1e 100644
|
| --- a/views/examples/example_base.cc
|
| +++ b/views/examples/example_base.cc
|
| @@ -10,9 +10,52 @@
|
| #include "base/string_util.h"
|
| #include "views/controls/button/text_button.h"
|
| #include "views/controls/tabbed_pane/tabbed_pane.h"
|
| +#include "views/examples/examples_main.h"
|
| +
|
| +namespace {
|
| +
|
| +using views::View;
|
| +
|
| +// Some of GTK based view classes require WidgetGTK in the view
|
| +// parent chain. This class is used to defer the creation of such
|
| +// views until a WidgetGTK is added to the view hierarchy.
|
| +class ContainerView : public View {
|
| + public:
|
| + explicit ContainerView(examples::ExampleBase* base)
|
| + : example_view_created_(false),
|
| + example_base_(base) {
|
| + }
|
| +
|
| + protected:
|
| + // views::View overrides:
|
| + virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child) {
|
| + View::ViewHierarchyChanged(is_add, parent, child);
|
| + // We're not using child == this because a Widget may not be
|
| + // availalbe when this is added to the hierarchy.
|
| + if (is_add && GetWidget() && !example_view_created_) {
|
| + example_view_created_ = true;
|
| + example_base_->CreateExampleView(this);
|
| + }
|
| + }
|
| +
|
| + private:
|
| + // true if the example view has already been created, or false otherwise.
|
| + bool example_view_created_;
|
| +
|
| + examples::ExampleBase* example_base_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ContainerView);
|
| +};
|
| +
|
| +} // namespace
|
|
|
| namespace examples {
|
|
|
| +ExampleBase::ExampleBase(ExamplesMain* main)
|
| + : main_(main) {
|
| + container_ = new ContainerView(this);
|
| +}
|
| +
|
| // Prints a message in the status area, at the bottom of the window.
|
| void ExampleBase::PrintStatus(const wchar_t* format, ...) {
|
| va_list ap;
|
|
|