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