| 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/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" |
| 14 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 16 #include "ui/base/models/menu_separator_types.h" | 17 #include "ui/base/models/menu_separator_types.h" |
| 17 #include "ui/gfx/image/image_skia.h" | 18 #include "ui/gfx/image/image_skia.h" |
| 18 #include "ui/views/controls/menu/menu_config.h" | 19 #include "ui/views/controls/menu/menu_config.h" |
| 20 #include "ui/views/controls/menu/menu_controller.h" |
| 19 #include "ui/views/controls/menu/menu_types.h" | 21 #include "ui/views/controls/menu/menu_types.h" |
| 20 #include "ui/views/view.h" | 22 #include "ui/views/view.h" |
| 21 | 23 |
| 22 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
| 23 #include <windows.h> | 25 #include <windows.h> |
| 24 | 26 |
| 25 #include "ui/native_theme/native_theme.h" | 27 #include "ui/native_theme/native_theme.h" |
| 26 #endif | 28 #endif |
| 27 | 29 |
| 28 namespace gfx { | 30 namespace gfx { |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 // Get the horizontal position at which to draw the menu item's label. | 413 // Get the horizontal position at which to draw the menu item's label. |
| 412 int GetLabelStartForThisItem() const; | 414 int GetLabelStartForThisItem() const; |
| 413 | 415 |
| 414 // Used by MenuController to cache the menu position in use by the | 416 // Used by MenuController to cache the menu position in use by the |
| 415 // active menu. | 417 // active menu. |
| 416 MenuPosition actual_menu_position() const { return actual_menu_position_; } | 418 MenuPosition actual_menu_position() const { return actual_menu_position_; } |
| 417 void set_actual_menu_position(MenuPosition actual_menu_position) { | 419 void set_actual_menu_position(MenuPosition actual_menu_position) { |
| 418 actual_menu_position_ = actual_menu_position; | 420 actual_menu_position_ = actual_menu_position; |
| 419 } | 421 } |
| 420 | 422 |
| 421 void set_controller(MenuController* controller) { controller_ = controller; } | 423 void set_controller(MenuController* controller) { |
| 424 if (controller) |
| 425 controller_ = controller->AsWeakPtr(); |
| 426 else |
| 427 controller_.reset(); |
| 428 } |
| 422 | 429 |
| 423 // Returns true if this MenuItemView contains a single child | 430 // Returns true if this MenuItemView contains a single child |
| 424 // that is responsible for rendering the content. | 431 // that is responsible for rendering the content. |
| 425 bool IsContainer() const; | 432 bool IsContainer() const; |
| 426 | 433 |
| 427 // Returns number of child views excluding icon_view. | 434 // Returns number of child views excluding icon_view. |
| 428 int NonIconChildViewsCount() const; | 435 int NonIconChildViewsCount() const; |
| 429 | 436 |
| 430 // Returns the max icon width; recurses over submenus. | 437 // Returns the max icon width; recurses over submenus. |
| 431 int GetMaxIconViewWidth() const; | 438 int GetMaxIconViewWidth() const; |
| 432 | 439 |
| 433 // Returns true if the menu has items with a checkbox or a radio button. | 440 // Returns true if the menu has items with a checkbox or a radio button. |
| 434 bool HasChecksOrRadioButtons() const; | 441 bool HasChecksOrRadioButtons() const; |
| 435 | 442 |
| 436 void invalidate_dimensions() { dimensions_.height = 0; } | 443 void invalidate_dimensions() { dimensions_.height = 0; } |
| 437 bool is_dimensions_valid() const { return dimensions_.height > 0; } | 444 bool is_dimensions_valid() const { return dimensions_.height > 0; } |
| 438 | 445 |
| 439 // The delegate. This is only valid for the root menu item. You shouldn't | 446 // The delegate. This is only valid for the root menu item. You shouldn't |
| 440 // use this directly, instead use GetDelegate() which walks the tree as | 447 // use this directly, instead use GetDelegate() which walks the tree as |
| 441 // as necessary. | 448 // as necessary. |
| 442 MenuDelegate* delegate_; | 449 MenuDelegate* delegate_; |
| 443 | 450 |
| 444 // The controller for the run operation, or NULL if the menu isn't showing. | 451 // The controller for the run operation, or NULL if the menu isn't showing. |
| 445 MenuController* controller_; | 452 base::WeakPtr<MenuController> controller_; |
| 446 | 453 |
| 447 // Used to detect when Cancel was invoked. | 454 // Used to detect when Cancel was invoked. |
| 448 bool canceled_; | 455 bool canceled_; |
| 449 | 456 |
| 450 // Our parent. | 457 // Our parent. |
| 451 MenuItemView* parent_menu_item_; | 458 MenuItemView* parent_menu_item_; |
| 452 | 459 |
| 453 // Type of menu. NOTE: MenuItemView doesn't itself represent SEPARATOR, | 460 // Type of menu. NOTE: MenuItemView doesn't itself represent SEPARATOR, |
| 454 // that is handled by an entirely different view class. | 461 // that is handled by an entirely different view class. |
| 455 Type type_; | 462 Type type_; |
| (...skipping 69 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 | 532 // If set to false, the right margin will be removed for menu lines |
| 526 // containing other elements. | 533 // containing other elements. |
| 527 bool use_right_margin_; | 534 bool use_right_margin_; |
| 528 | 535 |
| 529 DISALLOW_COPY_AND_ASSIGN(MenuItemView); | 536 DISALLOW_COPY_AND_ASSIGN(MenuItemView); |
| 530 }; | 537 }; |
| 531 | 538 |
| 532 } // namespace views | 539 } // namespace views |
| 533 | 540 |
| 534 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 541 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
| OLD | NEW |