| 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_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> |
| 10 |
| 9 #if defined(OS_WIN) | 11 #if defined(OS_WIN) |
| 10 #include <windows.h> | 12 #include <windows.h> |
| 11 #endif | 13 #endif |
| 12 | 14 |
| 13 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
| 14 #include "views/view.h" | 16 #include "views/view.h" |
| 15 | 17 |
| 16 #if defined(OS_WIN) | 18 #if defined(OS_WIN) |
| 17 #include "gfx/native_theme_win.h" | 19 #include "gfx/native_theme_win.h" |
| 18 #endif | 20 #endif |
| (...skipping 28 matching lines...) Expand all Loading... |
| 47 // 1. Use RunMenuAt. This blocks the caller, executing the selected command | 49 // 1. Use RunMenuAt. This blocks the caller, executing the selected command |
| 48 // on success. | 50 // on success. |
| 49 // 2. Use RunMenuForDropAt. This is intended for use during a drop session | 51 // 2. Use RunMenuForDropAt. This is intended for use during a drop session |
| 50 // and does NOT block the caller. Instead the delegate is notified when the | 52 // and does NOT block the caller. Instead the delegate is notified when the |
| 51 // menu closes via the DropMenuClosed method. | 53 // menu closes via the DropMenuClosed method. |
| 52 | 54 |
| 53 class MenuItemView : public View { | 55 class MenuItemView : public View { |
| 54 public: | 56 public: |
| 55 friend class MenuController; | 57 friend class MenuController; |
| 56 | 58 |
| 59 // The menu item view's class name. |
| 60 static const char kViewClassName[]; |
| 61 |
| 57 // ID used to identify menu items. | 62 // ID used to identify menu items. |
| 58 static const int kMenuItemViewID; | 63 static const int kMenuItemViewID; |
| 59 | 64 |
| 60 // ID used to identify empty menu items. | 65 // ID used to identify empty menu items. |
| 61 static const int kEmptyMenuItemViewID; | 66 static const int kEmptyMenuItemViewID; |
| 62 | 67 |
| 63 // Different types of menu items. | 68 // Different types of menu items. |
| 64 enum Type { | 69 enum Type { |
| 65 NORMAL, | 70 NORMAL, |
| 66 SUBMENU, | 71 SUBMENU, |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 int GetAcceleratorTextWidth(); | 263 int GetAcceleratorTextWidth(); |
| 259 | 264 |
| 260 // Returns true if the menu has mnemonics. This only useful on the root menu | 265 // Returns true if the menu has mnemonics. This only useful on the root menu |
| 261 // item. | 266 // item. |
| 262 bool has_mnemonics() const { return has_mnemonics_; } | 267 bool has_mnemonics() const { return has_mnemonics_; } |
| 263 | 268 |
| 264 protected: | 269 protected: |
| 265 // Creates a MenuItemView. This is used by the various AddXXX methods. | 270 // Creates a MenuItemView. This is used by the various AddXXX methods. |
| 266 MenuItemView(MenuItemView* parent, int command, Type type); | 271 MenuItemView(MenuItemView* parent, int command, Type type); |
| 267 | 272 |
| 273 virtual std::string GetClassName() const; |
| 274 |
| 268 private: | 275 private: |
| 269 // Calculates all sizes that we can from the OS. | 276 // Calculates all sizes that we can from the OS. |
| 270 // | 277 // |
| 271 // This is invoked prior to Running a menu. | 278 // This is invoked prior to Running a menu. |
| 272 static void UpdateMenuPartSizes(bool has_icons); | 279 static void UpdateMenuPartSizes(bool has_icons); |
| 273 | 280 |
| 274 // Called by the two constructors to initialize this menu item. | 281 // Called by the two constructors to initialize this menu item. |
| 275 void Init(MenuItemView* parent, | 282 void Init(MenuItemView* parent, |
| 276 int command, | 283 int command, |
| 277 MenuItemView::Type type, | 284 MenuItemView::Type type, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 | 392 |
| 386 // Preferred height of menu items. Reset every time a menu is run. | 393 // Preferred height of menu items. Reset every time a menu is run. |
| 387 static int pref_menu_height_; | 394 static int pref_menu_height_; |
| 388 | 395 |
| 389 DISALLOW_COPY_AND_ASSIGN(MenuItemView); | 396 DISALLOW_COPY_AND_ASSIGN(MenuItemView); |
| 390 }; | 397 }; |
| 391 | 398 |
| 392 } // namespace views | 399 } // namespace views |
| 393 | 400 |
| 394 #endif // VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 401 #endif // VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
| OLD | NEW |