OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/tree_view_example.h" | 5 #include "ui/views/examples/tree_view_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/menu/menu_model_adapter.h" | 9 #include "ui/views/controls/menu/menu_model_adapter.h" |
10 #include "ui/views/controls/menu/menu_runner.h" | 10 #include "ui/views/controls/menu/menu_runner.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 model_.GetRoot()->Add(sheep_node, 0); | 38 model_.GetRoot()->Add(sheep_node, 0); |
39 sheep_node->Add(new NodeType(ASCIIToUTF16("Sheep 1"), 1), 0); | 39 sheep_node->Add(new NodeType(ASCIIToUTF16("Sheep 1"), 1), 0); |
40 sheep_node->Add(new NodeType(ASCIIToUTF16("Sheep 2"), 1), 1); | 40 sheep_node->Add(new NodeType(ASCIIToUTF16("Sheep 2"), 1), 1); |
41 | 41 |
42 tree_view_ = new TreeView(); | 42 tree_view_ = new TreeView(); |
43 tree_view_->set_context_menu_controller(this); | 43 tree_view_->set_context_menu_controller(this); |
44 tree_view_->SetRootShown(false); | 44 tree_view_->SetRootShown(false); |
45 tree_view_->SetModel(&model_); | 45 tree_view_->SetModel(&model_); |
46 tree_view_->SetController(this); | 46 tree_view_->SetController(this); |
47 add_ = new LabelButton(this, ASCIIToUTF16("Add")); | 47 add_ = new LabelButton(this, ASCIIToUTF16("Add")); |
48 add_->set_focusable(true); | 48 add_->SetFocusable(true); |
49 remove_ = new LabelButton(this, ASCIIToUTF16("Remove")); | 49 remove_ = new LabelButton(this, ASCIIToUTF16("Remove")); |
50 remove_->set_focusable(true); | 50 remove_->SetFocusable(true); |
51 change_title_ = new LabelButton(this, ASCIIToUTF16("Change Title")); | 51 change_title_ = new LabelButton(this, ASCIIToUTF16("Change Title")); |
52 change_title_->set_focusable(true); | 52 change_title_->SetFocusable(true); |
53 | 53 |
54 GridLayout* layout = new GridLayout(container); | 54 GridLayout* layout = new GridLayout(container); |
55 container->SetLayoutManager(layout); | 55 container->SetLayoutManager(layout); |
56 | 56 |
57 const int tree_view_column = 0; | 57 const int tree_view_column = 0; |
58 ColumnSet* column_set = layout->AddColumnSet(tree_view_column); | 58 ColumnSet* column_set = layout->AddColumnSet(tree_view_column); |
59 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, | 59 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, |
60 1.0f, GridLayout::USE_PREF, 0, 0); | 60 1.0f, GridLayout::USE_PREF, 0, 0); |
61 layout->StartRow(1 /* expand */, tree_view_column); | 61 layout->StartRow(1 /* expand */, tree_view_column); |
62 layout->AddView(tree_view_->CreateParentIfNecessary()); | 62 layout->AddView(tree_view_->CreateParentIfNecessary()); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 case ID_ADD: | 163 case ID_ADD: |
164 AddNewNode(); | 164 AddNewNode(); |
165 break; | 165 break; |
166 default: | 166 default: |
167 NOTREACHED(); | 167 NOTREACHED(); |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 } // namespace examples | 171 } // namespace examples |
172 } // namespace views | 172 } // namespace views |
OLD | NEW |