| 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 // Get the horizontal position at which to draw the menu item's label. | 407 // Get the horizontal position at which to draw the menu item's label. |
| 406 int GetLabelStartForThisItem() const; | 408 int GetLabelStartForThisItem() const; |
| 407 | 409 |
| 408 // Used by MenuController to cache the menu position in use by the | 410 // Used by MenuController to cache the menu position in use by the |
| 409 // active menu. | 411 // active menu. |
| 410 MenuPosition actual_menu_position() const { return actual_menu_position_; } | 412 MenuPosition actual_menu_position() const { return actual_menu_position_; } |
| 411 void set_actual_menu_position(MenuPosition actual_menu_position) { | 413 void set_actual_menu_position(MenuPosition actual_menu_position) { |
| 412 actual_menu_position_ = actual_menu_position; | 414 actual_menu_position_ = actual_menu_position; |
| 413 } | 415 } |
| 414 | 416 |
| 415 void set_controller(MenuController* controller) { controller_ = controller; } | 417 void set_controller(MenuController* controller) { |
| 418 if (controller) |
| 419 controller_ = controller->AsWeakPtr(); |
| 420 else |
| 421 controller_.reset(); |
| 422 } |
| 416 | 423 |
| 417 // Returns true if this MenuItemView contains a single child | 424 // Returns true if this MenuItemView contains a single child |
| 418 // that is responsible for rendering the content. | 425 // that is responsible for rendering the content. |
| 419 bool IsContainer() const; | 426 bool IsContainer() const; |
| 420 | 427 |
| 421 // Returns number of child views excluding icon_view. | 428 // Returns number of child views excluding icon_view. |
| 422 int NonIconChildViewsCount() const; | 429 int NonIconChildViewsCount() const; |
| 423 | 430 |
| 424 // Returns the max icon width; recurses over submenus. | 431 // Returns the max icon width; recurses over submenus. |
| 425 int GetMaxIconViewWidth() const; | 432 int GetMaxIconViewWidth() const; |
| 426 | 433 |
| 427 // Returns true if the menu has items with a checkbox or a radio button. | 434 // Returns true if the menu has items with a checkbox or a radio button. |
| 428 bool HasChecksOrRadioButtons() const; | 435 bool HasChecksOrRadioButtons() const; |
| 429 | 436 |
| 430 void invalidate_dimensions() { dimensions_.height = 0; } | 437 void invalidate_dimensions() { dimensions_.height = 0; } |
| 431 bool is_dimensions_valid() const { return dimensions_.height > 0; } | 438 bool is_dimensions_valid() const { return dimensions_.height > 0; } |
| 432 | 439 |
| 433 // The delegate. This is only valid for the root menu item. You shouldn't | 440 // The delegate. This is only valid for the root menu item. You shouldn't |
| 434 // use this directly, instead use GetDelegate() which walks the tree as | 441 // use this directly, instead use GetDelegate() which walks the tree as |
| 435 // as necessary. | 442 // as necessary. |
| 436 MenuDelegate* delegate_; | 443 MenuDelegate* delegate_; |
| 437 | 444 |
| 438 // The controller for the run operation, or NULL if the menu isn't showing. | 445 // The controller for the run operation, or NULL if the menu isn't showing. |
| 439 MenuController* controller_; | 446 base::WeakPtr<MenuController> controller_; |
| 440 | 447 |
| 441 // Used to detect when Cancel was invoked. | 448 // Used to detect when Cancel was invoked. |
| 442 bool canceled_; | 449 bool canceled_; |
| 443 | 450 |
| 444 // Our parent. | 451 // Our parent. |
| 445 MenuItemView* parent_menu_item_; | 452 MenuItemView* parent_menu_item_; |
| 446 | 453 |
| 447 // Type of menu. NOTE: MenuItemView doesn't itself represent SEPARATOR, | 454 // Type of menu. NOTE: MenuItemView doesn't itself represent SEPARATOR, |
| 448 // that is handled by an entirely different view class. | 455 // that is handled by an entirely different view class. |
| 449 Type type_; | 456 Type type_; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 // If set to false, the right margin will be removed for menu lines | 526 // If set to false, the right margin will be removed for menu lines |
| 520 // containing other elements. | 527 // containing other elements. |
| 521 bool use_right_margin_; | 528 bool use_right_margin_; |
| 522 | 529 |
| 523 DISALLOW_COPY_AND_ASSIGN(MenuItemView); | 530 DISALLOW_COPY_AND_ASSIGN(MenuItemView); |
| 524 }; | 531 }; |
| 525 | 532 |
| 526 } // namespace views | 533 } // namespace views |
| 527 | 534 |
| 528 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 535 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
| OLD | NEW |