Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef VIEWS_CONTROLS_MENU_MENU_DELEGATE_H_ | 5 #ifndef VIEWS_CONTROLS_MENU_MENU_DELEGATE_H_ |
| 6 #define VIEWS_CONTROLS_MENU_MENU_DELEGATE_H_ | 6 #define VIEWS_CONTROLS_MENU_MENU_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <set> | |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "app/drag_drop_types.h" | 11 #include "app/drag_drop_types.h" |
| 12 #include "app/os_exchange_data.h" | |
| 11 #include "base/logging.h" | 13 #include "base/logging.h" |
| 12 #include "views/controls/menu/controller.h" | 14 #include "views/controls/menu/controller.h" |
| 13 #include "views/event.h" | 15 #include "views/event.h" |
| 14 | 16 |
| 15 class OSExchangeData; | |
| 16 | |
| 17 namespace views { | 17 namespace views { |
| 18 | 18 |
| 19 class DropTargetEvent; | 19 class DropTargetEvent; |
| 20 class MenuItemView; | 20 class MenuItemView; |
| 21 | 21 |
| 22 // MenuDelegate -------------------------------------------------------------- | 22 // MenuDelegate -------------------------------------------------------------- |
| 23 | 23 |
| 24 // Delegate for a menu. This class is used as part of MenuItemView, see it | 24 // Delegate for a menu. This class is used as part of MenuItemView, see it |
| 25 // for details. | 25 // for details. |
| 26 // TODO(sky): merge this with Menu2Model. | 26 // TODO(sky): merge this with Menu2Model. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 // a drop can occur on any of the child items of the item. For example, | 102 // a drop can occur on any of the child items of the item. For example, |
| 103 // consider the following menu structure: | 103 // consider the following menu structure: |
| 104 // | 104 // |
| 105 // A | 105 // A |
| 106 // B | 106 // B |
| 107 // C | 107 // C |
| 108 // | 108 // |
| 109 // Where A has a submenu with children B and C. This is ONLY invoked for | 109 // Where A has a submenu with children B and C. This is ONLY invoked for |
| 110 // A, not B and C. | 110 // A, not B and C. |
| 111 // | 111 // |
| 112 | |
|
jcampan
2009/09/08 20:27:36
Nit: remove empty line
| |
| 112 // To restrict which children can be dropped on override GetDropOperation. | 113 // To restrict which children can be dropped on override GetDropOperation. |
| 113 virtual bool CanDrop(MenuItemView* menu, const OSExchangeData& data) { | 114 virtual bool CanDrop(MenuItemView* menu, const OSExchangeData& data) { |
| 114 return false; | 115 return false; |
| 115 } | 116 } |
| 116 | 117 |
| 118 // See view for a description of this method. | |
| 119 virtual bool GetDropFormats( | |
| 120 MenuItemView* menu, | |
| 121 int* formats, | |
| 122 std::set<OSExchangeData::CustomFormat>* custom_formats) { | |
| 123 return false; | |
| 124 } | |
| 125 | |
| 126 // See view for a description of this method. | |
| 127 virtual bool AreDropTypesRequired(MenuItemView* menu) { | |
| 128 return false; | |
| 129 } | |
| 130 | |
| 117 // Returns the drop operation for the specified target menu item. This is | 131 // Returns the drop operation for the specified target menu item. This is |
| 118 // only invoked if CanDrop returned true for the parent menu. position | 132 // only invoked if CanDrop returned true for the parent menu. position |
| 119 // is set based on the location of the mouse, reset to specify a different | 133 // is set based on the location of the mouse, reset to specify a different |
| 120 // position. | 134 // position. |
| 121 // | 135 // |
| 122 // If a drop should not be allowed, returned DragDropTypes::DRAG_NONE. | 136 // If a drop should not be allowed, returned DragDropTypes::DRAG_NONE. |
| 123 virtual int GetDropOperation(MenuItemView* item, | 137 virtual int GetDropOperation(MenuItemView* item, |
| 124 const DropTargetEvent& event, | 138 const DropTargetEvent& event, |
| 125 DropPosition* position) { | 139 DropPosition* position) { |
| 126 NOTREACHED() << "If you override CanDrop, you need to override this too"; | 140 NOTREACHED() << "If you override CanDrop, you need to override this too"; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 } | 178 } |
| 165 | 179 |
| 166 // Notification that the user has highlighted the specified item. | 180 // Notification that the user has highlighted the specified item. |
| 167 virtual void SelectionChanged(MenuItemView* menu) { | 181 virtual void SelectionChanged(MenuItemView* menu) { |
| 168 } | 182 } |
| 169 }; | 183 }; |
| 170 | 184 |
| 171 } // namespace views | 185 } // namespace views |
| 172 | 186 |
| 173 #endif // VIEWS_CONTROLS_MENU_MENU_DELEGATE_H_ | 187 #endif // VIEWS_CONTROLS_MENU_MENU_DELEGATE_H_ |
| OLD | NEW |