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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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)); |
135 if (context_menu_runner_->RunMenuAt(source->GetWidget(), NULL, | 135 if (context_menu_runner_->RunMenuAt(source->GetWidget(), |
136 gfx::Rect(point, gfx::Size()), MenuItemView::TOPLEFT, source_type, 0) == | 136 NULL, |
137 MenuRunner::MENU_DELETED) | 137 gfx::Rect(point, gfx::Size()), |
| 138 MENU_ANCHOR_TOPLEFT, |
| 139 source_type, |
| 140 0) == MenuRunner::MENU_DELETED) { |
138 return; | 141 return; |
| 142 } |
139 } | 143 } |
140 | 144 |
141 bool TreeViewExample::IsCommandIdChecked(int command_id) const { | 145 bool TreeViewExample::IsCommandIdChecked(int command_id) const { |
142 return false; | 146 return false; |
143 } | 147 } |
144 | 148 |
145 bool TreeViewExample::IsCommandIdEnabled(int command_id) const { | 149 bool TreeViewExample::IsCommandIdEnabled(int command_id) const { |
146 return const_cast<TreeViewExample*>(this)->IsCommandIdEnabled(command_id); | 150 return const_cast<TreeViewExample*>(this)->IsCommandIdEnabled(command_id); |
147 } | 151 } |
148 | 152 |
(...skipping 16 matching lines...) Expand all Loading... |
165 case ID_ADD: | 169 case ID_ADD: |
166 AddNewNode(); | 170 AddNewNode(); |
167 break; | 171 break; |
168 default: | 172 default: |
169 NOTREACHED(); | 173 NOTREACHED(); |
170 } | 174 } |
171 } | 175 } |
172 | 176 |
173 } // namespace examples | 177 } // namespace examples |
174 } // namespace views | 178 } // namespace views |
OLD | NEW |