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 #include "ui/views/controls/menu/menu_item_view.h" | 5 #include "ui/views/controls/menu/menu_item_view.h" |
6 | 6 |
7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
580 right_icon_margin_(0), | 580 right_icon_margin_(0), |
581 requested_menu_position_(POSITION_BEST_FIT), | 581 requested_menu_position_(POSITION_BEST_FIT), |
582 actual_menu_position_(requested_menu_position_), | 582 actual_menu_position_(requested_menu_position_), |
583 use_right_margin_(true) { | 583 use_right_margin_(true) { |
584 Init(parent, command, type, NULL); | 584 Init(parent, command, type, NULL); |
585 } | 585 } |
586 | 586 |
587 MenuItemView::~MenuItemView() { | 587 MenuItemView::~MenuItemView() { |
588 delete submenu_; | 588 delete submenu_; |
589 STLDeleteElements(&removed_items_); | 589 STLDeleteElements(&removed_items_); |
590 if (lifecycle_observer_) { | |
591 lifecycle_observer_->OnDeleted(this); | |
592 } | |
Finnur
2014/02/10 10:41:41
nit: When the body of an if clause is only 1 line
| |
590 } | 593 } |
591 | 594 |
592 const char* MenuItemView::GetClassName() const { | 595 const char* MenuItemView::GetClassName() const { |
593 return kViewClassName; | 596 return kViewClassName; |
594 } | 597 } |
595 | 598 |
596 // Calculates all sizes that we can from the OS. | 599 // Calculates all sizes that we can from the OS. |
597 // | 600 // |
598 // This is invoked prior to Running a menu. | 601 // This is invoked prior to Running a menu. |
599 void MenuItemView::UpdateMenuPartSizes() { | 602 void MenuItemView::UpdateMenuPartSizes() { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
634 canceled_ = false; | 637 canceled_ = false; |
635 parent_menu_item_ = parent; | 638 parent_menu_item_ = parent; |
636 type_ = type; | 639 type_ = type; |
637 selected_ = false; | 640 selected_ = false; |
638 command_ = command; | 641 command_ = command; |
639 submenu_ = NULL; | 642 submenu_ = NULL; |
640 show_mnemonics_ = false; | 643 show_mnemonics_ = false; |
641 // Assign our ID, this allows SubmenuItemView to find MenuItemViews. | 644 // Assign our ID, this allows SubmenuItemView to find MenuItemViews. |
642 set_id(kMenuItemViewID); | 645 set_id(kMenuItemViewID); |
643 has_icons_ = false; | 646 has_icons_ = false; |
647 lifecycle_observer_ = NULL; | |
Finnur
2014/02/10 10:41:41
Looks like the convention in this class is to null
Finnur
2014/02/12 11:19:52
Hmmm... Now that I look at this again I realize th
| |
644 | 648 |
645 // Don't request enabled status from the root menu item as it is just | 649 // Don't request enabled status from the root menu item as it is just |
646 // a container for real items. EMPTY items will be disabled. | 650 // a container for real items. EMPTY items will be disabled. |
647 MenuDelegate* root_delegate = GetDelegate(); | 651 MenuDelegate* root_delegate = GetDelegate(); |
648 if (parent && type != EMPTY && root_delegate) | 652 if (parent && type != EMPTY && root_delegate) |
649 SetEnabled(root_delegate->IsCommandEnabled(command)); | 653 SetEnabled(root_delegate->IsCommandEnabled(command)); |
650 } | 654 } |
651 | 655 |
652 void MenuItemView::PrepareForRun(bool is_first_menu, | 656 void MenuItemView::PrepareForRun(bool is_first_menu, |
653 bool has_mnemonics, | 657 bool has_mnemonics, |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1060 } else { | 1064 } else { |
1061 const Type& type = menu_item->GetType(); | 1065 const Type& type = menu_item->GetType(); |
1062 if (type == CHECKBOX || type == RADIO) | 1066 if (type == CHECKBOX || type == RADIO) |
1063 return true; | 1067 return true; |
1064 } | 1068 } |
1065 } | 1069 } |
1066 return false; | 1070 return false; |
1067 } | 1071 } |
1068 | 1072 |
1069 } // namespace views | 1073 } // namespace views |
OLD | NEW |