Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: views/examples/tabbed_pane_example.cc

Issue 6283008: views: Move the implementation of TabbedPaneExample from the header file to the source file. (Closed)
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « views/examples/tabbed_pane_example.h ('k') | views/views.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "views/examples/tabbed_pane_example.h"
6
7 namespace examples {
8
9 TabbedPaneExample::TabbedPaneExample(ExamplesMain* main)
10 : ExampleBase(main) {
11 }
12
13 TabbedPaneExample::~TabbedPaneExample() {
14 }
15
16 std::wstring TabbedPaneExample::GetExampleTitle() {
17 return L"Tabbed Pane";
18 }
19
20 void TabbedPaneExample::CreateExampleView(views::View* container) {
21 tabbed_pane_ = new views::TabbedPane();
22 add_ = new views::TextButton(this, L"Add");
23 add_at_ = new views::TextButton(this, L"Add At 1");
24 remove_at_ = new views::TextButton(this, L"Remove At 1");
25 select_at_ = new views::TextButton(this, L"Select At 1");
26
27 views::GridLayout* layout = new views::GridLayout(container);
28 container->SetLayoutManager(layout);
29
30 const int tabbed_pane_column = 0;
31 views::ColumnSet* column_set = layout->AddColumnSet(tabbed_pane_column);
32 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL,
33 1.0f, views::GridLayout::USE_PREF, 0, 0);
34 layout->StartRow(1 /* expand */, tabbed_pane_column);
35 layout->AddView(tabbed_pane_);
36
37 // Create a few tabs with a button first.
38 AddButton(L"Tab 1");
39 AddButton(L"Tab 2");
40
41 // Add control buttons horizontally.
42 const int button_column = 1;
43 column_set = layout->AddColumnSet(button_column);
44 for (int i = 0; i < 4; i++) {
45 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL,
46 1.0f, views::GridLayout::USE_PREF, 0, 0);
47 }
48
49 layout->StartRow(0 /* no expand */, button_column);
50 layout->AddView(add_);
51 layout->AddView(add_at_);
52 layout->AddView(remove_at_);
53 layout->AddView(select_at_);
54 }
55
56 void TabbedPaneExample::ButtonPressed(views::Button* sender,
57 const views::Event& sender) {
58 if (sender == add_) {
59 AddButton(L"Added");
60 } else if (sender == add_at_) {
61 const std::wstring label = L"Added at 1";
62 tabbed_pane_->AddTabAtIndex(1, label,
63 new views::TextButton(NULL, label), true);
64 } else if (sender == remove_at_) {
65 if (tabbed_pane_->GetTabCount() > 1)
66 delete tabbed_pane_->RemoveTabAtIndex(1);
67 } else if (sender == select_at_) {
68 if (tabbed_pane_->GetTabCount() > 1)
69 tabbed_pane_->SelectTabAt(1);
70 }
71 PrintStatus();
72 }
73
74 void TabbedPaneExample::TabSelectedAt(int index) {
75 // Just print the status when selection changes.
76 PrintStatus();
77 }
78
79 void TabbedPaneExample::PrintStatus() {
80 ExampleBase::PrintStatus(L"Tab Count:%d, Selected Tab:%d",
81 tabbed_pane_->GetTabCount(),
82 tabbed_pane_->GetSelectedTabIndex());
83 }
84
85 void TabbedPaneExample::AddButton(const std::wstring& label) {
86 views::TextButton* button = new views::TextButton(NULL, label);
87 tabbed_pane_->AddTab(label, button);
88 }
89
90 } // namespace examples
OLDNEW
« no previous file with comments | « views/examples/tabbed_pane_example.h ('k') | views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698