| 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.h" | 5 #include "ui/views/controls/menu/menu.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "ui/gfx/image/image_skia.h" | 8 #include "ui/gfx/image/image_skia.h" |
| 9 | 9 |
| 10 namespace views { | 10 namespace views { |
| 11 | 11 |
| 12 bool Menu::Delegate::IsItemChecked(int id) const { | 12 bool Menu::Delegate::IsItemChecked(int id) const { |
| 13 return false; | 13 return false; |
| 14 } | 14 } |
| 15 | 15 |
| 16 bool Menu::Delegate::IsItemDefault(int id) const { | 16 bool Menu::Delegate::IsItemDefault(int id) const { |
| 17 return false; | 17 return false; |
| 18 } | 18 } |
| 19 | 19 |
| 20 string16 Menu::Delegate::GetLabel(int id) const { | 20 base::string16 Menu::Delegate::GetLabel(int id) const { |
| 21 return string16(); | 21 return base::string16(); |
| 22 } | 22 } |
| 23 | 23 |
| 24 bool Menu::Delegate::GetAcceleratorInfo(int id, ui::Accelerator* accel) { | 24 bool Menu::Delegate::GetAcceleratorInfo(int id, ui::Accelerator* accel) { |
| 25 return false; | 25 return false; |
| 26 } | 26 } |
| 27 | 27 |
| 28 const gfx::ImageSkia& Menu::Delegate::GetIcon(int id) const { | 28 const gfx::ImageSkia& Menu::Delegate::GetIcon(int id) const { |
| 29 return GetEmptyIcon(); | 29 return GetEmptyIcon(); |
| 30 } | 30 } |
| 31 | 31 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 42 } | 42 } |
| 43 | 43 |
| 44 bool Menu::Delegate::SupportsCommand(int id) const { | 44 bool Menu::Delegate::SupportsCommand(int id) const { |
| 45 return true; | 45 return true; |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool Menu::Delegate::IsCommandEnabled(int id) const { | 48 bool Menu::Delegate::IsCommandEnabled(int id) const { |
| 49 return true; | 49 return true; |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool Menu::Delegate::GetContextualLabel(int id, string16* out) const { | 52 bool Menu::Delegate::GetContextualLabel(int id, base::string16* out) const { |
| 53 return false; | 53 return false; |
| 54 } | 54 } |
| 55 | 55 |
| 56 bool Menu::Delegate::IsRightToLeftUILayout() const { | 56 bool Menu::Delegate::IsRightToLeftUILayout() const { |
| 57 return base::i18n::IsRTL(); | 57 return base::i18n::IsRTL(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 const gfx::ImageSkia& Menu::Delegate::GetEmptyIcon() const { | 60 const gfx::ImageSkia& Menu::Delegate::GetEmptyIcon() const { |
| 61 static const gfx::ImageSkia* empty_icon = new gfx::ImageSkia(); | 61 static const gfx::ImageSkia* empty_icon = new gfx::ImageSkia(); |
| 62 return *empty_icon; | 62 return *empty_icon; |
| 63 } | 63 } |
| 64 | 64 |
| 65 Menu::Menu(Delegate* delegate, AnchorPoint anchor) | 65 Menu::Menu(Delegate* delegate, AnchorPoint anchor) |
| 66 : delegate_(delegate), | 66 : delegate_(delegate), |
| 67 anchor_(anchor) { | 67 anchor_(anchor) { |
| 68 } | 68 } |
| 69 | 69 |
| 70 Menu::Menu(Menu* parent) | 70 Menu::Menu(Menu* parent) |
| 71 : delegate_(parent->delegate_), | 71 : delegate_(parent->delegate_), |
| 72 anchor_(parent->anchor_) { | 72 anchor_(parent->anchor_) { |
| 73 } | 73 } |
| 74 | 74 |
| 75 Menu::~Menu() { | 75 Menu::~Menu() { |
| 76 } | 76 } |
| 77 | 77 |
| 78 void Menu::AppendMenuItem(int item_id, | 78 void Menu::AppendMenuItem(int item_id, |
| 79 const string16& label, | 79 const base::string16& label, |
| 80 MenuItemType type) { | 80 MenuItemType type) { |
| 81 AddMenuItem(-1, item_id, label, type); | 81 AddMenuItem(-1, item_id, label, type); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void Menu::AddMenuItem(int index, | 84 void Menu::AddMenuItem(int index, |
| 85 int item_id, | 85 int item_id, |
| 86 const string16& label, | 86 const base::string16& label, |
| 87 MenuItemType type) { | 87 MenuItemType type) { |
| 88 if (type == SEPARATOR) | 88 if (type == SEPARATOR) |
| 89 AddSeparator(index); | 89 AddSeparator(index); |
| 90 else | 90 else |
| 91 AddMenuItemInternal(index, item_id, label, gfx::ImageSkia(), type); | 91 AddMenuItemInternal(index, item_id, label, gfx::ImageSkia(), type); |
| 92 } | 92 } |
| 93 | 93 |
| 94 Menu* Menu::AppendSubMenu(int item_id, const string16& label) { | 94 Menu* Menu::AppendSubMenu(int item_id, const base::string16& label) { |
| 95 return AddSubMenu(-1, item_id, label); | 95 return AddSubMenu(-1, item_id, label); |
| 96 } | 96 } |
| 97 | 97 |
| 98 Menu* Menu::AddSubMenu(int index, int item_id, const string16& label) { | 98 Menu* Menu::AddSubMenu(int index, int item_id, const base::string16& label) { |
| 99 return AddSubMenuWithIcon(index, item_id, label, gfx::ImageSkia()); | 99 return AddSubMenuWithIcon(index, item_id, label, gfx::ImageSkia()); |
| 100 } | 100 } |
| 101 | 101 |
| 102 Menu* Menu::AppendSubMenuWithIcon(int item_id, | 102 Menu* Menu::AppendSubMenuWithIcon(int item_id, |
| 103 const string16& label, | 103 const base::string16& label, |
| 104 const gfx::ImageSkia& icon) { | 104 const gfx::ImageSkia& icon) { |
| 105 return AddSubMenuWithIcon(-1, item_id, label, icon); | 105 return AddSubMenuWithIcon(-1, item_id, label, icon); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void Menu::AppendMenuItemWithLabel(int item_id, const string16& label) { | 108 void Menu::AppendMenuItemWithLabel(int item_id, const base::string16& label) { |
| 109 AddMenuItemWithLabel(-1, item_id, label); | 109 AddMenuItemWithLabel(-1, item_id, label); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void Menu::AddMenuItemWithLabel(int index, | 112 void Menu::AddMenuItemWithLabel(int index, |
| 113 int item_id, | 113 int item_id, |
| 114 const string16& label) { | 114 const base::string16& label) { |
| 115 AddMenuItem(index, item_id, label, Menu::NORMAL); | 115 AddMenuItem(index, item_id, label, Menu::NORMAL); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void Menu::AppendDelegateMenuItem(int item_id) { | 118 void Menu::AppendDelegateMenuItem(int item_id) { |
| 119 AddDelegateMenuItem(-1, item_id); | 119 AddDelegateMenuItem(-1, item_id); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void Menu::AddDelegateMenuItem(int index, int item_id) { | 122 void Menu::AddDelegateMenuItem(int index, int item_id) { |
| 123 AddMenuItem(index, item_id, string16(), Menu::NORMAL); | 123 AddMenuItem(index, item_id, base::string16(), Menu::NORMAL); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void Menu::AppendSeparator() { | 126 void Menu::AppendSeparator() { |
| 127 AddSeparator(-1); | 127 AddSeparator(-1); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void Menu::AppendMenuItemWithIcon(int item_id, | 130 void Menu::AppendMenuItemWithIcon(int item_id, |
| 131 const string16& label, | 131 const base::string16& label, |
| 132 const gfx::ImageSkia& icon) { | 132 const gfx::ImageSkia& icon) { |
| 133 AddMenuItemWithIcon(-1, item_id, label, icon); | 133 AddMenuItemWithIcon(-1, item_id, label, icon); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void Menu::AddMenuItemWithIcon(int index, | 136 void Menu::AddMenuItemWithIcon(int index, |
| 137 int item_id, | 137 int item_id, |
| 138 const string16& label, | 138 const base::string16& label, |
| 139 const gfx::ImageSkia& icon) { | 139 const gfx::ImageSkia& icon) { |
| 140 AddMenuItemInternal(index, item_id, label, icon, Menu::NORMAL); | 140 AddMenuItemInternal(index, item_id, label, icon, Menu::NORMAL); |
| 141 } | 141 } |
| 142 | 142 |
| 143 Menu::Menu() : delegate_(NULL), anchor_(TOPLEFT) { | 143 Menu::Menu() : delegate_(NULL), anchor_(TOPLEFT) { |
| 144 } | 144 } |
| 145 | 145 |
| 146 } // namespace views | 146 } // namespace views |
| OLD | NEW |