• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "ui/views/controls/menu/menu_delegate.h"
6 
7 #include "ui/events/event.h"
8 #include "ui/views/controls/menu/menu_config.h"
9 
10 namespace views {
11 
~MenuDelegate()12 MenuDelegate::~MenuDelegate() {}
13 
IsItemChecked(int id) const14 bool MenuDelegate::IsItemChecked(int id) const {
15   return false;
16 }
17 
GetLabel(int id) const18 base::string16 MenuDelegate::GetLabel(int id) const {
19   return base::string16();
20 }
21 
GetLabelFontList(int id) const22 const gfx::FontList* MenuDelegate::GetLabelFontList(int id) const {
23   return NULL;
24 }
25 
GetShouldUseDisabledEmphasizedForegroundColor(int command_id) const26 bool MenuDelegate::GetShouldUseDisabledEmphasizedForegroundColor(
27     int command_id) const {
28   return false;
29 }
30 
GetBackgroundColor(int command_id,bool is_hovered,SkColor * override_color) const31 bool MenuDelegate::GetBackgroundColor(int command_id,
32                                       bool is_hovered,
33                                       SkColor* override_color) const {
34   return false;
35 }
36 
GetForegroundColor(int command_id,bool is_hovered,SkColor * override_color) const37 bool MenuDelegate::GetForegroundColor(int command_id,
38                                       bool is_hovered,
39                                       SkColor* override_color) const {
40   return false;
41 }
42 
GetTooltipText(int id,const gfx::Point & screen_loc) const43 base::string16 MenuDelegate::GetTooltipText(int id,
44                                       const gfx::Point& screen_loc) const {
45   return base::string16();
46 }
47 
GetAccelerator(int id,ui::Accelerator * accelerator) const48 bool MenuDelegate::GetAccelerator(int id, ui::Accelerator* accelerator) const {
49   return false;
50 }
51 
ShowContextMenu(MenuItemView * source,int id,const gfx::Point & p,ui::MenuSourceType source_type)52 bool MenuDelegate::ShowContextMenu(MenuItemView* source,
53                                    int id,
54                                    const gfx::Point& p,
55                                    ui::MenuSourceType source_type) {
56   return false;
57 }
58 
SupportsCommand(int id) const59 bool MenuDelegate::SupportsCommand(int id) const {
60   return true;
61 }
62 
IsCommandEnabled(int id) const63 bool MenuDelegate::IsCommandEnabled(int id) const {
64   return true;
65 }
66 
IsCommandVisible(int id) const67 bool MenuDelegate::IsCommandVisible(int id) const {
68   return true;
69 }
70 
GetContextualLabel(int id,base::string16 * out) const71 bool MenuDelegate::GetContextualLabel(int id, base::string16* out) const {
72   return false;
73 }
74 
ShouldCloseAllMenusOnExecute(int id)75 bool MenuDelegate::ShouldCloseAllMenusOnExecute(int id) {
76   return true;
77 }
78 
ExecuteCommand(int id,int mouse_event_flags)79 void MenuDelegate::ExecuteCommand(int id, int mouse_event_flags) {
80   ExecuteCommand(id);
81 }
82 
ShouldExecuteCommandWithoutClosingMenu(int id,const ui::Event & e)83 bool MenuDelegate::ShouldExecuteCommandWithoutClosingMenu(int id,
84                                                           const ui::Event& e) {
85   return false;
86 }
87 
IsTriggerableEvent(MenuItemView * source,const ui::Event & e)88 bool MenuDelegate::IsTriggerableEvent(MenuItemView* source,
89                                       const ui::Event& e) {
90   return e.type() == ui::ET_GESTURE_TAP ||
91          e.type() == ui::ET_GESTURE_TAP_DOWN ||
92          (e.IsMouseEvent() && (e.flags() &
93               (ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON)));
94 }
95 
CanDrop(MenuItemView * menu,const OSExchangeData & data)96 bool MenuDelegate::CanDrop(MenuItemView* menu, const OSExchangeData& data) {
97   return false;
98 }
99 
GetDropFormats(MenuItemView * menu,int * formats,std::set<OSExchangeData::CustomFormat> * custom_formats)100 bool MenuDelegate::GetDropFormats(
101     MenuItemView* menu,
102     int* formats,
103     std::set<OSExchangeData::CustomFormat>* custom_formats) {
104   return false;
105 }
106 
AreDropTypesRequired(MenuItemView * menu)107 bool MenuDelegate::AreDropTypesRequired(MenuItemView* menu) {
108   return false;
109 }
110 
GetDropOperation(MenuItemView * item,const ui::DropTargetEvent & event,DropPosition * position)111 int MenuDelegate::GetDropOperation(MenuItemView* item,
112                                    const ui::DropTargetEvent& event,
113                                    DropPosition* position) {
114   NOTREACHED() << "If you override CanDrop, you need to override this too";
115   return ui::DragDropTypes::DRAG_NONE;
116 }
117 
OnPerformDrop(MenuItemView * menu,DropPosition position,const ui::DropTargetEvent & event)118 int MenuDelegate::OnPerformDrop(MenuItemView* menu,
119                                 DropPosition position,
120                                 const ui::DropTargetEvent& event) {
121   NOTREACHED() << "If you override CanDrop, you need to override this too";
122   return ui::DragDropTypes::DRAG_NONE;
123 }
124 
CanDrag(MenuItemView * menu)125 bool MenuDelegate::CanDrag(MenuItemView* menu) {
126   return false;
127 }
128 
WriteDragData(MenuItemView * sender,OSExchangeData * data)129 void MenuDelegate::WriteDragData(MenuItemView* sender, OSExchangeData* data) {
130   NOTREACHED() << "If you override CanDrag, you must override this too.";
131 }
132 
GetDragOperations(MenuItemView * sender)133 int MenuDelegate::GetDragOperations(MenuItemView* sender) {
134   NOTREACHED() << "If you override CanDrag, you must override this too.";
135   return 0;
136 }
137 
ShouldCloseOnDragComplete()138 bool MenuDelegate::ShouldCloseOnDragComplete() {
139   return true;
140 }
141 
GetSiblingMenu(MenuItemView * menu,const gfx::Point & screen_point,MenuAnchorPosition * anchor,bool * has_mnemonics,MenuButton ** button)142 MenuItemView* MenuDelegate::GetSiblingMenu(MenuItemView* menu,
143                                            const gfx::Point& screen_point,
144                                            MenuAnchorPosition* anchor,
145                                            bool* has_mnemonics,
146                                            MenuButton** button) {
147   return NULL;
148 }
149 
GetMaxWidthForMenu(MenuItemView * menu)150 int MenuDelegate::GetMaxWidthForMenu(MenuItemView* menu) {
151   // NOTE: this needs to be large enough to accommodate the wrench menu with
152   // big fonts.
153   return 800;
154 }
155 
WillShowMenu(MenuItemView * menu)156 void MenuDelegate::WillShowMenu(MenuItemView* menu) {
157 }
158 
WillHideMenu(MenuItemView * menu)159 void MenuDelegate::WillHideMenu(MenuItemView* menu) {
160 }
161 
GetHorizontalIconMargins(int command_id,int icon_size,int * left_margin,int * right_margin) const162 void MenuDelegate::GetHorizontalIconMargins(int command_id,
163                                             int icon_size,
164                                             int* left_margin,
165                                             int* right_margin) const {
166   *left_margin = 0;
167   *right_margin = 0;
168 }
169 
ShouldReserveSpaceForSubmenuIndicator() const170 bool MenuDelegate::ShouldReserveSpaceForSubmenuIndicator() const {
171   return true;
172 }
173 
174 }  // namespace views
175