| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 return true; | 124 return true; |
| 125 } | 125 } |
| 126 | 126 |
| 127 void TreeViewExample::ShowContextMenuForView(View* source, | 127 void TreeViewExample::ShowContextMenuForView(View* source, |
| 128 const gfx::Point& point, | 128 const gfx::Point& point, |
| 129 ui::MenuSourceType source_type) { | 129 ui::MenuSourceType source_type) { |
| 130 ui::SimpleMenuModel context_menu_model(this); | 130 ui::SimpleMenuModel context_menu_model(this); |
| 131 context_menu_model.AddItem(ID_EDIT, ASCIIToUTF16("Edit")); | 131 context_menu_model.AddItem(ID_EDIT, ASCIIToUTF16("Edit")); |
| 132 context_menu_model.AddItem(ID_REMOVE, ASCIIToUTF16("Remove")); | 132 context_menu_model.AddItem(ID_REMOVE, ASCIIToUTF16("Remove")); |
| 133 context_menu_model.AddItem(ID_ADD, ASCIIToUTF16("Add")); | 133 context_menu_model.AddItem(ID_ADD, ASCIIToUTF16("Add")); |
| 134 context_menu_runner_.reset(new MenuRunner(&context_menu_model)); | 134 context_menu_runner_.reset(new MenuRunner(&context_menu_model, 0)); |
| 135 if (context_menu_runner_->RunMenuAt(source->GetWidget(), | 135 if (context_menu_runner_->RunMenuAt(source->GetWidget(), |
| 136 NULL, | 136 NULL, |
| 137 gfx::Rect(point, gfx::Size()), | 137 gfx::Rect(point, gfx::Size()), |
| 138 MENU_ANCHOR_TOPLEFT, | 138 MENU_ANCHOR_TOPLEFT, |
| 139 source_type, | 139 source_type) == |
| 140 0) == MenuRunner::MENU_DELETED) { | 140 MenuRunner::MENU_DELETED) { |
| 141 return; | 141 return; |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 bool TreeViewExample::IsCommandIdChecked(int command_id) const { | 145 bool TreeViewExample::IsCommandIdChecked(int command_id) const { |
| 146 return false; | 146 return false; |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool TreeViewExample::IsCommandIdEnabled(int command_id) const { | 149 bool TreeViewExample::IsCommandIdEnabled(int command_id) const { |
| 150 return const_cast<TreeViewExample*>(this)->IsCommandIdEnabled(command_id); | 150 return const_cast<TreeViewExample*>(this)->IsCommandIdEnabled(command_id); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 169 case ID_ADD: | 169 case ID_ADD: |
| 170 AddNewNode(); | 170 AddNewNode(); |
| 171 break; | 171 break; |
| 172 default: | 172 default: |
| 173 NOTREACHED(); | 173 NOTREACHED(); |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 | 176 |
| 177 } // namespace examples | 177 } // namespace examples |
| 178 } // namespace views | 178 } // namespace views |
| OLD | NEW |