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