OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_SUBMENU_VIEW_H_ | 5 #ifndef VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_ |
6 #define VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_ | 6 #define VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include <string> |
| 10 |
9 #include "views/controls/menu/menu_delegate.h" | 11 #include "views/controls/menu/menu_delegate.h" |
10 #include "views/view.h" | 12 #include "views/view.h" |
11 | 13 |
12 namespace views { | 14 namespace views { |
13 | 15 |
14 class MenuHost; | 16 class MenuHost; |
15 class MenuItemView; | 17 class MenuItemView; |
16 class MenuScrollViewContainer; | 18 class MenuScrollViewContainer; |
17 | 19 |
18 // SubmenuView is the parent of all menu items. | 20 // SubmenuView is the parent of all menu items. |
19 // | 21 // |
20 // SubmenuView has the following responsibilities: | 22 // SubmenuView has the following responsibilities: |
21 // . It positions and sizes all child views (any type of View may be added, | 23 // . It positions and sizes all child views (any type of View may be added, |
22 // not just MenuItemViews). | 24 // not just MenuItemViews). |
23 // . Forwards the appropriate events to the MenuController. This allows the | 25 // . Forwards the appropriate events to the MenuController. This allows the |
24 // MenuController to update the selection as the user moves the mouse around. | 26 // MenuController to update the selection as the user moves the mouse around. |
25 // . Renders the drop indicator during a drop operation. | 27 // . Renders the drop indicator during a drop operation. |
26 // . Shows and hides the window (a WidgetWin) when the menu is shown on | 28 // . Shows and hides the window (a WidgetWin) when the menu is shown on |
27 // screen. | 29 // screen. |
28 // | 30 // |
29 // SubmenuView is itself contained in a MenuScrollViewContainer. | 31 // SubmenuView is itself contained in a MenuScrollViewContainer. |
30 // MenuScrollViewContainer handles showing as much of the SubmenuView as the | 32 // MenuScrollViewContainer handles showing as much of the SubmenuView as the |
31 // screen allows. If the SubmenuView is taller than the screen, scroll buttons | 33 // screen allows. If the SubmenuView is taller than the screen, scroll buttons |
32 // are provided that allow the user to see all the menu items. | 34 // are provided that allow the user to see all the menu items. |
33 class SubmenuView : public View { | 35 class SubmenuView : public View { |
34 public: | 36 public: |
| 37 // The submenu's class name. |
| 38 static const char kViewClassName[]; |
| 39 |
35 // Creates a SubmenuView for the specified menu item. | 40 // Creates a SubmenuView for the specified menu item. |
36 explicit SubmenuView(MenuItemView* parent); | 41 explicit SubmenuView(MenuItemView* parent); |
37 ~SubmenuView(); | 42 ~SubmenuView(); |
38 | 43 |
39 // Returns the number of child views that are MenuItemViews. | 44 // Returns the number of child views that are MenuItemViews. |
40 // MenuItemViews are identified by ID. | 45 // MenuItemViews are identified by ID. |
41 int GetMenuItemCount(); | 46 int GetMenuItemCount(); |
42 | 47 |
43 // Returns the MenuItemView at the specified index. | 48 // Returns the MenuItemView at the specified index. |
44 MenuItemView* GetMenuItemAt(int index); | 49 MenuItemView* GetMenuItemAt(int index); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // references to the MenuHost as the MenuHost is about to be deleted. | 131 // references to the MenuHost as the MenuHost is about to be deleted. |
127 void MenuHostDestroyed(); | 132 void MenuHostDestroyed(); |
128 | 133 |
129 // Max width of accelerators in child menu items. This doesn't include | 134 // Max width of accelerators in child menu items. This doesn't include |
130 // children's children, only direct children. | 135 // children's children, only direct children. |
131 int max_accelerator_width() const { return max_accelerator_width_; } | 136 int max_accelerator_width() const { return max_accelerator_width_; } |
132 | 137 |
133 // Padding around the edges of the submenu. | 138 // Padding around the edges of the submenu. |
134 static const int kSubmenuBorderSize; | 139 static const int kSubmenuBorderSize; |
135 | 140 |
| 141 protected: |
| 142 virtual std::string GetClassName() const; |
| 143 |
136 private: | 144 private: |
137 // Paints the drop indicator. This is only invoked if item is non-NULL and | 145 // Paints the drop indicator. This is only invoked if item is non-NULL and |
138 // position is not DROP_NONE. | 146 // position is not DROP_NONE. |
139 void PaintDropIndicator(gfx::Canvas* canvas, | 147 void PaintDropIndicator(gfx::Canvas* canvas, |
140 MenuItemView* item, | 148 MenuItemView* item, |
141 MenuDelegate::DropPosition position); | 149 MenuDelegate::DropPosition position); |
142 | 150 |
143 void SchedulePaintForDropIndicator(MenuItemView* item, | 151 void SchedulePaintForDropIndicator(MenuItemView* item, |
144 MenuDelegate::DropPosition position); | 152 MenuDelegate::DropPosition position); |
145 | 153 |
(...skipping 20 matching lines...) Expand all Loading... |
166 | 174 |
167 // See description above getter. | 175 // See description above getter. |
168 int max_accelerator_width_; | 176 int max_accelerator_width_; |
169 | 177 |
170 DISALLOW_COPY_AND_ASSIGN(SubmenuView); | 178 DISALLOW_COPY_AND_ASSIGN(SubmenuView); |
171 }; | 179 }; |
172 | 180 |
173 } // namespace views | 181 } // namespace views |
174 | 182 |
175 #endif // VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_ | 183 #endif // VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_ |
OLD | NEW |