| 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/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "grit/ui_strings.h" | 10 #include "grit/ui_strings.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 int item_id, | 209 int item_id, |
| 210 const string16& label, | 210 const string16& label, |
| 211 const gfx::ImageSkia& icon, | 211 const gfx::ImageSkia& icon, |
| 212 Type type) { | 212 Type type) { |
| 213 DCHECK_NE(type, EMPTY); | 213 DCHECK_NE(type, EMPTY); |
| 214 DCHECK_LE(0, index); | 214 DCHECK_LE(0, index); |
| 215 if (!submenu_) | 215 if (!submenu_) |
| 216 CreateSubmenu(); | 216 CreateSubmenu(); |
| 217 DCHECK_GE(submenu_->child_count(), index); | 217 DCHECK_GE(submenu_->child_count(), index); |
| 218 if (type == SEPARATOR) { | 218 if (type == SEPARATOR) { |
| 219 submenu_->AddChildViewAt(new MenuSeparator(), index); | 219 submenu_->AddChildViewAt(new MenuSeparator(label), index); |
| 220 return NULL; | 220 return NULL; |
| 221 } | 221 } |
| 222 MenuItemView* item = new MenuItemView(this, item_id, type); | 222 MenuItemView* item = new MenuItemView(this, item_id, type); |
| 223 if (label.empty() && GetDelegate()) | 223 if (label.empty() && GetDelegate()) |
| 224 item->SetTitle(GetDelegate()->GetLabel(item_id)); | 224 item->SetTitle(GetDelegate()->GetLabel(item_id)); |
| 225 else | 225 else |
| 226 item->SetTitle(label); | 226 item->SetTitle(label); |
| 227 if (!icon.empty()) | 227 if (!icon.empty()) |
| 228 item->SetIcon(icon); | 228 item->SetIcon(icon); |
| 229 if (type == SUBMENU) | 229 if (type == SUBMENU) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 case ui::MenuModel::TYPE_CHECK: | 299 case ui::MenuModel::TYPE_CHECK: |
| 300 type = MenuItemView::CHECKBOX; | 300 type = MenuItemView::CHECKBOX; |
| 301 label = model->GetLabelAt(index); | 301 label = model->GetLabelAt(index); |
| 302 break; | 302 break; |
| 303 case ui::MenuModel::TYPE_RADIO: | 303 case ui::MenuModel::TYPE_RADIO: |
| 304 type = MenuItemView::RADIO; | 304 type = MenuItemView::RADIO; |
| 305 label = model->GetLabelAt(index); | 305 label = model->GetLabelAt(index); |
| 306 break; | 306 break; |
| 307 case ui::MenuModel::TYPE_SEPARATOR: | 307 case ui::MenuModel::TYPE_SEPARATOR: |
| 308 type = MenuItemView::SEPARATOR; | 308 type = MenuItemView::SEPARATOR; |
| 309 // This can be one of the separator styles. |
| 310 label = model->GetLabelAt(index); |
| 309 break; | 311 break; |
| 310 case ui::MenuModel::TYPE_SUBMENU: | 312 case ui::MenuModel::TYPE_SUBMENU: |
| 311 model->GetIconAt(index, &icon); | 313 model->GetIconAt(index, &icon); |
| 312 type = MenuItemView::SUBMENU; | 314 type = MenuItemView::SUBMENU; |
| 313 label = model->GetLabelAt(index); | 315 label = model->GetLabelAt(index); |
| 314 break; | 316 break; |
| 315 default: | 317 default: |
| 316 NOTREACHED(); | 318 NOTREACHED(); |
| 317 type = MenuItemView::NORMAL; | 319 type = MenuItemView::NORMAL; |
| 318 break; | 320 break; |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 temp_width = menu_item->GetMaxIconViewWidth(); | 848 temp_width = menu_item->GetMaxIconViewWidth(); |
| 847 } else if (menu_item->icon_view()) { | 849 } else if (menu_item->icon_view()) { |
| 848 temp_width = menu_item->icon_view()->GetPreferredSize().width(); | 850 temp_width = menu_item->icon_view()->GetPreferredSize().width(); |
| 849 } | 851 } |
| 850 width = std::max(width, temp_width); | 852 width = std::max(width, temp_width); |
| 851 } | 853 } |
| 852 return width; | 854 return width; |
| 853 } | 855 } |
| 854 | 856 |
| 855 } // namespace views | 857 } // namespace views |
| OLD | NEW |