Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: ui/views/examples/tree_view_example.cc

Issue 16979002: Add ContextMenuSourceType to views::ContextMenuController::ShowContextMenuForView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/examples/tree_view_example.h ('k') | ui/views/view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 remove_->SetEnabled(false); 116 remove_->SetEnabled(false);
117 } 117 }
118 } 118 }
119 119
120 bool TreeViewExample::CanEdit(TreeView* tree_view, 120 bool TreeViewExample::CanEdit(TreeView* tree_view,
121 ui::TreeModelNode* node) { 121 ui::TreeModelNode* node) {
122 return true; 122 return true;
123 } 123 }
124 124
125 void TreeViewExample::ShowContextMenuForView(View* source, 125 void TreeViewExample::ShowContextMenuForView(View* source,
126 const gfx::Point& point) { 126 const gfx::Point& point,
127 ui::MenuSourceType source_type) {
127 ui::SimpleMenuModel context_menu_model(this); 128 ui::SimpleMenuModel context_menu_model(this);
128 context_menu_model.AddItem(ID_EDIT, ASCIIToUTF16("Edit")); 129 context_menu_model.AddItem(ID_EDIT, ASCIIToUTF16("Edit"));
129 context_menu_model.AddItem(ID_REMOVE, ASCIIToUTF16("Remove")); 130 context_menu_model.AddItem(ID_REMOVE, ASCIIToUTF16("Remove"));
130 context_menu_model.AddItem(ID_ADD, ASCIIToUTF16("Add")); 131 context_menu_model.AddItem(ID_ADD, ASCIIToUTF16("Add"));
131 context_menu_runner_.reset(new MenuRunner(&context_menu_model)); 132 context_menu_runner_.reset(new MenuRunner(&context_menu_model));
132 if (context_menu_runner_->RunMenuAt(source->GetWidget(), NULL, 133 if (context_menu_runner_->RunMenuAt(source->GetWidget(), NULL,
133 gfx::Rect(point, gfx::Size()), MenuItemView::TOPLEFT, 0) == 134 gfx::Rect(point, gfx::Size()), MenuItemView::TOPLEFT, source_type, 0) ==
134 MenuRunner::MENU_DELETED) 135 MenuRunner::MENU_DELETED)
135 return; 136 return;
136 } 137 }
137 138
138 bool TreeViewExample::IsCommandIdChecked(int command_id) const { 139 bool TreeViewExample::IsCommandIdChecked(int command_id) const {
139 return false; 140 return false;
140 } 141 }
141 142
142 bool TreeViewExample::IsCommandIdEnabled(int command_id) const { 143 bool TreeViewExample::IsCommandIdEnabled(int command_id) const {
143 return const_cast<TreeViewExample*>(this)->IsCommandIdEnabled(command_id); 144 return const_cast<TreeViewExample*>(this)->IsCommandIdEnabled(command_id);
(...skipping 18 matching lines...) Expand all
162 case ID_ADD: 163 case ID_ADD:
163 AddNewNode(); 164 AddNewNode();
164 break; 165 break;
165 default: 166 default:
166 NOTREACHED(); 167 NOTREACHED();
167 } 168 }
168 } 169 }
169 170
170 } // namespace examples 171 } // namespace examples
171 } // namespace views 172 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/examples/tree_view_example.h ('k') | ui/views/view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698