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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 layout->StartRow(0 /* no expand */, button_column); | 50 layout->StartRow(0 /* no expand */, button_column); |
51 layout->AddView(add_); | 51 layout->AddView(add_); |
52 layout->AddView(add_at_); | 52 layout->AddView(add_at_); |
53 layout->AddView(select_at_); | 53 layout->AddView(select_at_); |
54 } | 54 } |
55 | 55 |
56 void TabbedPaneExample::ButtonPressed(Button* sender, const ui::Event& event) { | 56 void TabbedPaneExample::ButtonPressed(Button* sender, const ui::Event& event) { |
57 if (sender == add_) { | 57 if (sender == add_) { |
58 AddButton("Added"); | 58 AddButton("Added"); |
59 } else if (sender == add_at_) { | 59 } else if (sender == add_at_) { |
60 const string16 label = ASCIIToUTF16("Added at 1"); | 60 const base::string16 label = ASCIIToUTF16("Added at 1"); |
61 tabbed_pane_->AddTabAtIndex(1, label, new LabelButton(NULL, label)); | 61 tabbed_pane_->AddTabAtIndex(1, label, new LabelButton(NULL, label)); |
62 } else if (sender == select_at_) { | 62 } else if (sender == select_at_) { |
63 if (tabbed_pane_->GetTabCount() > 1) | 63 if (tabbed_pane_->GetTabCount() > 1) |
64 tabbed_pane_->SelectTabAt(1); | 64 tabbed_pane_->SelectTabAt(1); |
65 } | 65 } |
66 PrintStatus(); | 66 PrintStatus(); |
67 } | 67 } |
68 | 68 |
69 void TabbedPaneExample::TabSelectedAt(int index) { | 69 void TabbedPaneExample::TabSelectedAt(int index) { |
70 // Just print the status when selection changes. | 70 // Just print the status when selection changes. |
71 PrintStatus(); | 71 PrintStatus(); |
72 } | 72 } |
73 | 73 |
74 void TabbedPaneExample::PrintStatus() { | 74 void TabbedPaneExample::PrintStatus() { |
75 ExampleBase::PrintStatus("Tab Count:%d, Selected Tab:%d", | 75 ExampleBase::PrintStatus("Tab Count:%d, Selected Tab:%d", |
76 tabbed_pane_->GetTabCount(), | 76 tabbed_pane_->GetTabCount(), |
77 tabbed_pane_->selected_tab_index()); | 77 tabbed_pane_->selected_tab_index()); |
78 } | 78 } |
79 | 79 |
80 void TabbedPaneExample::AddButton(const std::string& label) { | 80 void TabbedPaneExample::AddButton(const std::string& label) { |
81 LabelButton* button = new LabelButton(NULL, ASCIIToUTF16(label)); | 81 LabelButton* button = new LabelButton(NULL, ASCIIToUTF16(label)); |
82 tabbed_pane_->AddTab(ASCIIToUTF16(label), button); | 82 tabbed_pane_->AddTab(ASCIIToUTF16(label), button); |
83 } | 83 } |
84 | 84 |
85 } // namespace examples | 85 } // namespace examples |
86 } // namespace views | 86 } // namespace views |
OLD | NEW |