diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-20 17:22:48 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-20 17:22:48 +0000 |
commit | e557d64b1d89a5acbe4b185e63c029c428bd217b (patch) | |
tree | adc254b279329bfae6f1a53cc19a03a3cade7a41 /views/examples/tabbed_pane_example.h | |
parent | dd92c8dc5191650d37501f74bf017e4ad4f664a4 (diff) | |
download | chromium_src-e557d64b1d89a5acbe4b185e63c029c428bd217b.zip chromium_src-e557d64b1d89a5acbe4b185e63c029c428bd217b.tar.gz chromium_src-e557d64b1d89a5acbe4b185e63c029c428bd217b.tar.bz2 |
Porting the view examples to Windows.
Some refactoring done to the tests also.
See original review at:
http://codereview.chromium.org/295013/show
BUG=None
TEST=Make sure the view examples build and run on Windows
and Linux.
Review URL: http://codereview.chromium.org/294026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29525 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/examples/tabbed_pane_example.h')
-rw-r--r-- | views/examples/tabbed_pane_example.h | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/views/examples/tabbed_pane_example.h b/views/examples/tabbed_pane_example.h index 283e355..fe622e9 100644 --- a/views/examples/tabbed_pane_example.h +++ b/views/examples/tabbed_pane_example.h @@ -5,10 +5,8 @@ #ifndef VIEWS_EXAMPLES_TABBED_PANE_EXAMPLE_H_ #define VIEWS_EXAMPLES_TABBED_PANE_EXAMPLE_H_ -#include "base/compiler_specific.h" #include "base/string_util.h" #include "views/controls/button/text_button.h" -#include "views/controls/tabbed_pane/tabbed_pane.h" #include "views/examples/example_base.h" namespace examples { @@ -18,22 +16,16 @@ class TabbedPaneExample : protected ExampleBase, private views::ButtonListener, views::TabbedPane::Listener { public: - TabbedPaneExample(views::TabbedPane* parent, views::Label* message) - : ExampleBase(message), - tabbed_pane_(new views::TabbedPane()), - ALLOW_THIS_IN_INITIALIZER_LIST( - add_(new views::TextButton(this, L"Add"))), - ALLOW_THIS_IN_INITIALIZER_LIST( - add_at_(new views::TextButton(this, L"Add At 1"))), - ALLOW_THIS_IN_INITIALIZER_LIST( - remove_at_(new views::TextButton(this, L"Remove At 1"))), - ALLOW_THIS_IN_INITIALIZER_LIST( - select_at_(new views::TextButton(this, L"Select At 1"))) { - views::View* container = new views::View(); - parent->AddTab(L"Tabbed Pane", container); - - views::GridLayout* layout = new views::GridLayout(container); - container->SetLayoutManager(layout); + explicit TabbedPaneExample(ExamplesMain* main) : ExampleBase(main) { + tabbed_pane_ = new views::TabbedPane(); + add_ = new views::TextButton(this, L"Add"); + add_at_ = new views::TextButton(this, L"Add At 1"); + remove_at_ = new views::TextButton(this, L"Remove At 1"); + select_at_ = new views::TextButton(this, L"Select At 1"); + + container_ = new views::View(); + views::GridLayout* layout = new views::GridLayout(container_); + container_->SetLayoutManager(layout); const int tabbed_pane_column = 0; views::ColumnSet* column_set = layout->AddColumnSet(tabbed_pane_column); @@ -43,8 +35,8 @@ class TabbedPaneExample : protected ExampleBase, layout->AddView(tabbed_pane_); // Create a few tabs with a button first. - AddButton(tabbed_pane_, L"Tab 1"); - AddButton(tabbed_pane_, L"Tab 2"); + AddButton(L"Tab 1"); + AddButton(L"Tab 2"); // Add control buttons horizontally. const int button_column = 1; @@ -63,11 +55,19 @@ class TabbedPaneExample : protected ExampleBase, virtual ~TabbedPaneExample() {} + virtual std::wstring GetExampleTitle() { + return L"Tabbed Pane"; + } + + virtual views::View* GetExampleView() { + return container_; + } + private: // ButtonListener overrides. virtual void ButtonPressed(views::Button* sender, const views::Event& event) { if (sender == add_) { - AddButton(tabbed_pane_, L"Added"); + AddButton(L"Added"); } else if (sender == add_at_) { const std::wstring label = L"Added at 1"; tabbed_pane_->AddTabAtIndex(1, label, @@ -95,6 +95,14 @@ class TabbedPaneExample : protected ExampleBase, tabbed_pane_->GetSelectedTabIndex()); } + void AddButton(const std::wstring& label) { + views::TextButton* button = new views::TextButton(NULL, label); + tabbed_pane_->AddTab(label, button); + } + + // The view containing this test's controls. + views::View* container_; + // The tabbed pane to be tested. views::TabbedPane* tabbed_pane_; |