| 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 #include "chrome/browser/views/wrench_menu.h" | 5 #include "chrome/browser/views/wrench_menu.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 } | 676 } |
| 677 } | 677 } |
| 678 } | 678 } |
| 679 | 679 |
| 680 MenuItemView* WrenchMenu::AppendMenuItem(MenuItemView* parent, | 680 MenuItemView* WrenchMenu::AppendMenuItem(MenuItemView* parent, |
| 681 MenuModel* model, | 681 MenuModel* model, |
| 682 int index, | 682 int index, |
| 683 MenuModel::ItemType menu_type, | 683 MenuModel::ItemType menu_type, |
| 684 int* next_id) { | 684 int* next_id) { |
| 685 int id = (*next_id)++; | 685 int id = (*next_id)++; |
| 686 SkBitmap icon; | |
| 687 std::wstring label; | |
| 688 MenuItemView::Type type; | |
| 689 switch (menu_type) { | |
| 690 case MenuModel::TYPE_COMMAND: | |
| 691 model->GetIconAt(index, &icon); | |
| 692 type = MenuItemView::NORMAL; | |
| 693 label = UTF16ToWide(model->GetLabelAt(index)); | |
| 694 break; | |
| 695 case MenuModel::TYPE_CHECK: | |
| 696 type = MenuItemView::CHECKBOX; | |
| 697 label = UTF16ToWide(model->GetLabelAt(index)); | |
| 698 break; | |
| 699 case MenuModel::TYPE_RADIO: | |
| 700 type = MenuItemView::RADIO; | |
| 701 label = UTF16ToWide(model->GetLabelAt(index)); | |
| 702 break; | |
| 703 case MenuModel::TYPE_SEPARATOR: | |
| 704 type = MenuItemView::SEPARATOR; | |
| 705 break; | |
| 706 case MenuModel::TYPE_SUBMENU: | |
| 707 type = MenuItemView::SUBMENU; | |
| 708 label = UTF16ToWide(model->GetLabelAt(index)); | |
| 709 break; | |
| 710 default: | |
| 711 NOTREACHED(); | |
| 712 type = MenuItemView::NORMAL; | |
| 713 break; | |
| 714 } | |
| 715 | 686 |
| 716 id_to_entry_[id].first = model; | 687 id_to_entry_[id].first = model; |
| 717 id_to_entry_[id].second = index; | 688 id_to_entry_[id].second = index; |
| 718 | 689 |
| 719 MenuItemView* menu_item = parent->AppendMenuItemImpl(id, label, icon, type); | 690 MenuItemView* menu_item = parent->AppendMenuItemFromModel(model, index, id); |
| 720 | 691 |
| 721 if (menu_item) | 692 if (menu_item) |
| 722 menu_item->SetVisible(model->IsVisibleAt(index)); | 693 menu_item->SetVisible(model->IsVisibleAt(index)); |
| 723 | 694 |
| 724 if (menu_type == MenuModel::TYPE_COMMAND && model->HasIcons()) { | 695 if (menu_type == MenuModel::TYPE_COMMAND && model->HasIcons()) { |
| 725 SkBitmap icon; | 696 SkBitmap icon; |
| 726 if (model->GetIconAt(index, &icon)) | 697 if (model->GetIconAt(index, &icon)) |
| 727 menu_item->SetIcon(icon); | 698 menu_item->SetIcon(icon); |
| 728 } | 699 } |
| 729 | 700 |
| 730 return menu_item; | 701 return menu_item; |
| 731 } | 702 } |
| 732 | 703 |
| 733 void WrenchMenu::CancelAndEvaluate(MenuModel* model, int index) { | 704 void WrenchMenu::CancelAndEvaluate(MenuModel* model, int index) { |
| 734 selected_menu_model_ = model; | 705 selected_menu_model_ = model; |
| 735 selected_index_ = index; | 706 selected_index_ = index; |
| 736 root_->Cancel(); | 707 root_->Cancel(); |
| 737 } | 708 } |
| OLD | NEW |