OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_ITEM_VIEW_H_ | 5 #ifndef VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
6 #define VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 6 #define VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // menus that is only used internally. | 83 // menus that is only used internally. |
84 enum Type { | 84 enum Type { |
85 NORMAL, | 85 NORMAL, |
86 SUBMENU, | 86 SUBMENU, |
87 CHECKBOX, | 87 CHECKBOX, |
88 RADIO, | 88 RADIO, |
89 SEPARATOR, | 89 SEPARATOR, |
90 EMPTY | 90 EMPTY |
91 }; | 91 }; |
92 | 92 |
93 // Where the menu should be anchored to. | 93 // Where the menu should be anchored to for non-RTL languages. The |
| 94 // opposite position will be used if base::i18n:IsRTL() is true. |
94 enum AnchorPosition { | 95 enum AnchorPosition { |
95 TOPLEFT, | 96 TOPLEFT, |
96 TOPRIGHT | 97 TOPRIGHT |
97 }; | 98 }; |
98 | 99 |
99 // Constructor for use with the top level menu item. This menu is never | 100 // Constructor for use with the top level menu item. This menu is never |
100 // shown to the user, rather its use as the parent for all menu items. | 101 // shown to the user, rather its use as the parent for all menu items. |
101 explicit MenuItemView(MenuDelegate* delegate); | 102 explicit MenuItemView(MenuDelegate* delegate); |
102 | 103 |
103 virtual ~MenuItemView(); | 104 virtual ~MenuItemView(); |
(...skipping 11 matching lines...) Expand all Loading... |
115 static int label_start() { return label_start_; } | 116 static int label_start() { return label_start_; } |
116 | 117 |
117 // Returns the accessible name to be used with screen readers. Mnemonics are | 118 // Returns the accessible name to be used with screen readers. Mnemonics are |
118 // removed and the menu item accelerator text is appended. | 119 // removed and the menu item accelerator text is appended. |
119 static string16 GetAccessibleNameForMenuItem( | 120 static string16 GetAccessibleNameForMenuItem( |
120 const string16& item_text, const string16& accelerator_text); | 121 const string16& item_text, const string16& accelerator_text); |
121 | 122 |
122 // Run methods. See description above class for details. Both Run methods take | 123 // Run methods. See description above class for details. Both Run methods take |
123 // a rectangle, which is used to position the menu. |has_mnemonics| indicates | 124 // a rectangle, which is used to position the menu. |has_mnemonics| indicates |
124 // whether the items have mnemonics. Mnemonics are identified by way of the | 125 // whether the items have mnemonics. Mnemonics are identified by way of the |
125 // character following the '&'. | 126 // character following the '&'. The anchor position is specified for non-RTL |
| 127 // languages; the opposite value will be used for RTL. |
126 void RunMenuAt(gfx::NativeWindow parent, | 128 void RunMenuAt(gfx::NativeWindow parent, |
127 MenuButton* button, | 129 MenuButton* button, |
128 const gfx::Rect& bounds, | 130 const gfx::Rect& bounds, |
129 AnchorPosition anchor, | 131 AnchorPosition anchor, |
130 bool has_mnemonics); | 132 bool has_mnemonics); |
131 void RunMenuForDropAt(gfx::NativeWindow parent, | 133 void RunMenuForDropAt(gfx::NativeWindow parent, |
132 const gfx::Rect& bounds, | 134 const gfx::Rect& bounds, |
133 AnchorPosition anchor); | 135 AnchorPosition anchor); |
134 | 136 |
135 // Hides and cancels the menu. This does nothing if the menu is not open. | 137 // Hides and cancels the menu. This does nothing if the menu is not open. |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 // Margins in pixels. | 464 // Margins in pixels. |
463 int top_margin_; | 465 int top_margin_; |
464 int bottom_margin_; | 466 int bottom_margin_; |
465 | 467 |
466 DISALLOW_COPY_AND_ASSIGN(MenuItemView); | 468 DISALLOW_COPY_AND_ASSIGN(MenuItemView); |
467 }; | 469 }; |
468 | 470 |
469 } // namespace views | 471 } // namespace views |
470 | 472 |
471 #endif // VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 473 #endif // VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
OLD | NEW |