| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
| 6 #define UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 6 #define UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "ui/base/models/menu_separator_types.h" | 15 #include "ui/base/models/menu_separator_types.h" |
| 16 #include "ui/gfx/image/image_skia.h" | 16 #include "ui/gfx/image/image_skia.h" |
| 17 #include "ui/views/controls/menu/menu_config.h" | 17 #include "ui/views/controls/menu/menu_config.h" |
| 18 #include "ui/views/controls/menu/menu_types.h" |
| 18 #include "ui/views/view.h" | 19 #include "ui/views/view.h" |
| 19 | 20 |
| 20 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
| 21 #include <windows.h> | 22 #include <windows.h> |
| 22 | 23 |
| 23 #include "ui/native_theme/native_theme.h" | 24 #include "ui/native_theme/native_theme.h" |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 26 namespace gfx { | 27 namespace gfx { |
| 27 class FontList; | 28 class FontList; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // menus that is only used internally. | 77 // menus that is only used internally. |
| 77 enum Type { | 78 enum Type { |
| 78 NORMAL, | 79 NORMAL, |
| 79 SUBMENU, | 80 SUBMENU, |
| 80 CHECKBOX, | 81 CHECKBOX, |
| 81 RADIO, | 82 RADIO, |
| 82 SEPARATOR, | 83 SEPARATOR, |
| 83 EMPTY | 84 EMPTY |
| 84 }; | 85 }; |
| 85 | 86 |
| 86 // Where the menu should be anchored to for non-RTL languages. The | |
| 87 // opposite position will be used if base::i18n:IsRTL() is true. | |
| 88 // The BUBBLE flags are used when the menu should get enclosed by a bubble. | |
| 89 // Note that BUBBLE flags should only be used with menus which have no | |
| 90 // children. | |
| 91 enum AnchorPosition { | |
| 92 TOPLEFT, | |
| 93 TOPRIGHT, | |
| 94 BOTTOMCENTER, | |
| 95 BUBBLE_LEFT, | |
| 96 BUBBLE_RIGHT, | |
| 97 BUBBLE_ABOVE, | |
| 98 BUBBLE_BELOW | |
| 99 }; | |
| 100 | |
| 101 // Where the menu should be drawn, above or below the bounds (when | 87 // Where the menu should be drawn, above or below the bounds (when |
| 102 // the bounds is non-empty). POSITION_BEST_FIT (default) positions | 88 // the bounds is non-empty). POSITION_BEST_FIT (default) positions |
| 103 // the menu below the bounds unless the menu does not fit on the | 89 // the menu below the bounds unless the menu does not fit on the |
| 104 // screen and the re is more space above. | 90 // screen and the re is more space above. |
| 105 enum MenuPosition { | 91 enum MenuPosition { |
| 106 POSITION_BEST_FIT, | 92 POSITION_BEST_FIT, |
| 107 POSITION_ABOVE_BOUNDS, | 93 POSITION_ABOVE_BOUNDS, |
| 108 POSITION_BELOW_BOUNDS | 94 POSITION_BELOW_BOUNDS |
| 109 }; | 95 }; |
| 110 | 96 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 136 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; | 122 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; |
| 137 | 123 |
| 138 // Returns the preferred height of menu items. This is only valid when the | 124 // Returns the preferred height of menu items. This is only valid when the |
| 139 // menu is about to be shown. | 125 // menu is about to be shown. |
| 140 static int pref_menu_height() { return pref_menu_height_; } | 126 static int pref_menu_height() { return pref_menu_height_; } |
| 141 | 127 |
| 142 // X-coordinate of where the label starts. | 128 // X-coordinate of where the label starts. |
| 143 static int label_start() { return label_start_; } | 129 static int label_start() { return label_start_; } |
| 144 | 130 |
| 145 // Returns if a given |anchor| is a bubble or not. | 131 // Returns if a given |anchor| is a bubble or not. |
| 146 static bool IsBubble(MenuItemView::AnchorPosition anchor); | 132 static bool IsBubble(MenuAnchorPosition anchor); |
| 147 | 133 |
| 148 // Returns the accessible name to be used with screen readers. Mnemonics are | 134 // Returns the accessible name to be used with screen readers. Mnemonics are |
| 149 // removed and the menu item accelerator text is appended. | 135 // removed and the menu item accelerator text is appended. |
| 150 static base::string16 GetAccessibleNameForMenuItem( | 136 static base::string16 GetAccessibleNameForMenuItem( |
| 151 const base::string16& item_text, const base::string16& accelerator_text); | 137 const base::string16& item_text, const base::string16& accelerator_text); |
| 152 | 138 |
| 153 // Hides and cancels the menu. This does nothing if the menu is not open. | 139 // Hides and cancels the menu. This does nothing if the menu is not open. |
| 154 void Cancel(); | 140 void Cancel(); |
| 155 | 141 |
| 156 // Add an item to the menu at a specified index. ChildrenChanged() should | 142 // Add an item to the menu at a specified index. ChildrenChanged() should |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 // If set to false, the right margin will be removed for menu lines | 511 // If set to false, the right margin will be removed for menu lines |
| 526 // containing other elements. | 512 // containing other elements. |
| 527 bool use_right_margin_; | 513 bool use_right_margin_; |
| 528 | 514 |
| 529 DISALLOW_COPY_AND_ASSIGN(MenuItemView); | 515 DISALLOW_COPY_AND_ASSIGN(MenuItemView); |
| 530 }; | 516 }; |
| 531 | 517 |
| 532 } // namespace views | 518 } // namespace views |
| 533 | 519 |
| 534 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 520 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
| OLD | NEW |