summaryrefslogtreecommitdiffstats
path: root/views/examples/scroll_view_example.h
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-30 16:45:34 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-30 16:45:34 +0000
commit4a672db19685df00f748681c57a00ee253a2047e (patch)
tree6c64d27e9cdb0ced677f20c0afa4cf084d25e3ee /views/examples/scroll_view_example.h
parentbab6cac3c2ad3f335a4694f3ea0b33477a98508b (diff)
downloadchromium_src-4a672db19685df00f748681c57a00ee253a2047e.zip
chromium_src-4a672db19685df00f748681c57a00ee253a2047e.tar.gz
chromium_src-4a672db19685df00f748681c57a00ee253a2047e.tar.bz2
Fixed view example. It was failing because some of view classes requires WidgetGTK in
view hierarchy to call methods on it. * added ContainerExamlpeBase that defers the creation of such views after WidgetGTK available. minor fixes * replaced unnecessary includes with forward decls. * make sure we don't try to set negative hight to viewport. BUG=None TEST=build & run view_examples Review URL: http://codereview.chromium.org/347010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30586 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/examples/scroll_view_example.h')
-rw-r--r--views/examples/scroll_view_example.h31
1 files changed, 13 insertions, 18 deletions
diff --git a/views/examples/scroll_view_example.h b/views/examples/scroll_view_example.h
index 2fd2d2f..035c06c 100644
--- a/views/examples/scroll_view_example.h
+++ b/views/examples/scroll_view_example.h
@@ -13,9 +13,18 @@
namespace examples {
-class ScrollViewExample : protected ExampleBase, private views::ButtonListener {
+class ScrollViewExample : public ExampleBase,
+ public views::ButtonListener {
public:
- explicit ScrollViewExample(ExamplesMain* main) : ExampleBase(main) {
+ explicit ScrollViewExample(ExamplesMain* main): ExampleBase(main) {}
+
+ virtual ~ScrollViewExample() {}
+
+ virtual std::wstring GetExampleTitle() {
+ return L"Scroll View";
+ }
+
+ virtual void CreateExampleView(views::View* container) {
wide_ = new views::TextButton(this, L"Wide");
tall_ = new views::TextButton(this, L"Tall");
big_square_ = new views::TextButton(this, L"Big Square");
@@ -27,9 +36,8 @@ class ScrollViewExample : protected ExampleBase, private views::ButtonListener {
scrollable_->SetBounds(0, 0, 1000, 100);
scrollable_->SetColor(SK_ColorYELLOW, SK_ColorCYAN);
- container_ = new views::View();
- views::GridLayout* layout = new views::GridLayout(container_);
- container_->SetLayoutManager(layout);
+ views::GridLayout* layout = new views::GridLayout(container);
+ container->SetLayoutManager(layout);
// Add scroll view.
views::ColumnSet* column_set = layout->AddColumnSet(0);
@@ -52,16 +60,6 @@ class ScrollViewExample : protected ExampleBase, private views::ButtonListener {
layout->AddView(scroll_to_);
}
- virtual ~ScrollViewExample() {}
-
- virtual std::wstring GetExampleTitle() {
- return L"Scroll View";
- }
-
- virtual views::View* GetExampleView() {
- return container_;
- }
-
private:
// ScrollView's content, which draws gradient color on background.
// TODO(oshima): add child views as well.
@@ -108,9 +106,6 @@ class ScrollViewExample : protected ExampleBase, private views::ButtonListener {
scroll_view_->Layout();
}
- // The view containing this test's controls.
- views::View* container_;
-
// Control buttons to change the size of scrollable and jump to
// predefined position.
views::TextButton* wide_, *tall_, *big_square_, *small_square_, *scroll_to_;