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