This source file includes following definitions.
- example_base_
- ViewHierarchyChanged
- PrintStatus
#include "ui/views/examples/example_base.h"
#include <stdarg.h>
#include "base/strings/stringprintf.h"
#include "ui/views/view.h"
namespace views {
namespace examples {
void LogStatus(const std::string& status);
namespace {
class ContainerView : public View {
public:
explicit ContainerView(ExampleBase* base)
: example_view_created_(false),
example_base_(base) {
}
private:
virtual void ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) OVERRIDE {
View::ViewHierarchyChanged(details);
if (details.is_add && GetWidget() && !example_view_created_) {
example_view_created_ = true;
example_base_->CreateExampleView(this);
}
}
bool example_view_created_;
ExampleBase* example_base_;
DISALLOW_COPY_AND_ASSIGN(ContainerView);
};
}
ExampleBase::~ExampleBase() {}
ExampleBase::ExampleBase(const char* title) : example_title_(title) {
container_ = new ContainerView(this);
}
void ExampleBase::PrintStatus(const char* format, ...) {
va_list ap;
va_start(ap, format);
std::string msg;
base::StringAppendV(&msg, format, ap);
LogStatus(msg);
}
}
}