| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/examples/tabbed_pane_example.h" | 5 #include "ui/views/examples/tabbed_pane_example.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "ui/views/controls/button/label_button.h" | 8 #include "ui/views/controls/button/label_button.h" |
| 9 #include "ui/views/controls/tabbed_pane/tabbed_pane.h" | 9 #include "ui/views/controls/tabbed_pane/tabbed_pane.h" |
| 10 #include "ui/views/layout/grid_layout.h" | 10 #include "ui/views/layout/grid_layout.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 const int tabbed_pane_column = 0; | 33 const int tabbed_pane_column = 0; |
| 34 ColumnSet* column_set = layout->AddColumnSet(tabbed_pane_column); | 34 ColumnSet* column_set = layout->AddColumnSet(tabbed_pane_column); |
| 35 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, | 35 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, |
| 36 1.0f, GridLayout::USE_PREF, 0, 0); | 36 1.0f, GridLayout::USE_PREF, 0, 0); |
| 37 layout->StartRow(1 /* expand */, tabbed_pane_column); | 37 layout->StartRow(1 /* expand */, tabbed_pane_column); |
| 38 layout->AddView(tabbed_pane_); | 38 layout->AddView(tabbed_pane_); |
| 39 | 39 |
| 40 // Create a few tabs with a button first. | 40 // Create a few tabs with a button first. |
| 41 AddButton("Tab 1"); | 41 AddButton("Tab 1"); |
| 42 AddButton("Tab 2"); | 42 AddButton("Tab 2"); |
| 43 AddButton("Tab 3"); |
| 43 | 44 |
| 44 // Add control buttons horizontally. | 45 // Add control buttons horizontally. |
| 45 const int button_column = 1; | 46 const int button_column = 1; |
| 46 column_set = layout->AddColumnSet(button_column); | 47 column_set = layout->AddColumnSet(button_column); |
| 47 for (int i = 0; i < 3; i++) { | 48 for (int i = 0; i < 3; i++) { |
| 48 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, | 49 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, |
| 49 1.0f, GridLayout::USE_PREF, 0, 0); | 50 1.0f, GridLayout::USE_PREF, 0, 0); |
| 50 } | 51 } |
| 51 | 52 |
| 52 layout->StartRow(0 /* no expand */, button_column); | 53 layout->StartRow(0 /* no expand */, button_column); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 69 } | 70 } |
| 70 | 71 |
| 71 void TabbedPaneExample::TabSelectedAt(int index) { | 72 void TabbedPaneExample::TabSelectedAt(int index) { |
| 72 // Just print the status when selection changes. | 73 // Just print the status when selection changes. |
| 73 PrintStatus(); | 74 PrintStatus(); |
| 74 } | 75 } |
| 75 | 76 |
| 76 void TabbedPaneExample::PrintStatus() { | 77 void TabbedPaneExample::PrintStatus() { |
| 77 ExampleBase::PrintStatus("Tab Count:%d, Selected Tab:%d", | 78 ExampleBase::PrintStatus("Tab Count:%d, Selected Tab:%d", |
| 78 tabbed_pane_->GetTabCount(), | 79 tabbed_pane_->GetTabCount(), |
| 79 tabbed_pane_->selected_tab_index()); | 80 tabbed_pane_->GetSelectedTabIndex()); |
| 80 } | 81 } |
| 81 | 82 |
| 82 void TabbedPaneExample::AddButton(const std::string& label) { | 83 void TabbedPaneExample::AddButton(const std::string& label) { |
| 83 LabelButton* button = new LabelButton(NULL, ASCIIToUTF16(label)); | 84 LabelButton* button = new LabelButton(NULL, ASCIIToUTF16(label)); |
| 84 tabbed_pane_->AddTab(ASCIIToUTF16(label), button); | 85 tabbed_pane_->AddTab(ASCIIToUTF16(label), button); |
| 85 } | 86 } |
| 86 | 87 |
| 87 } // namespace examples | 88 } // namespace examples |
| 88 } // namespace views | 89 } // namespace views |
| OLD | NEW |