| 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/examples/menu_example.h" | 5 #include "ui/views/examples/menu_example.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "ui/base/models/simple_menu_model.h" | 10 #include "ui/base/models/simple_menu_model.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 DISALLOW_COPY_AND_ASSIGN(ExampleMenuButton); | 75 DISALLOW_COPY_AND_ASSIGN(ExampleMenuButton); |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 // ExampleMenuModel --------------------------------------------------------- | 78 // ExampleMenuModel --------------------------------------------------------- |
| 79 | 79 |
| 80 ExampleMenuModel::ExampleMenuModel() | 80 ExampleMenuModel::ExampleMenuModel() |
| 81 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), | 81 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), |
| 82 current_encoding_command_id_(COMMAND_SELECT_ASCII) { | 82 current_encoding_command_id_(COMMAND_SELECT_ASCII) { |
| 83 AddItem(COMMAND_DO_SOMETHING, ASCIIToUTF16("Do Something")); | 83 AddItem(COMMAND_DO_SOMETHING, ASCIIToUTF16("Do Something")); |
| 84 AddSeparator(); | 84 AddSeparator(ui::NORMAL_SEPARATOR); |
| 85 AddRadioItem(COMMAND_SELECT_ASCII, ASCIIToUTF16("ASCII"), | 85 AddRadioItem(COMMAND_SELECT_ASCII, ASCIIToUTF16("ASCII"), |
| 86 GROUP_MAKE_DECISION); | 86 GROUP_MAKE_DECISION); |
| 87 AddRadioItem(COMMAND_SELECT_UTF8, ASCIIToUTF16("UTF-8"), | 87 AddRadioItem(COMMAND_SELECT_UTF8, ASCIIToUTF16("UTF-8"), |
| 88 GROUP_MAKE_DECISION); | 88 GROUP_MAKE_DECISION); |
| 89 AddRadioItem(COMMAND_SELECT_UTF16, ASCIIToUTF16("UTF-16"), | 89 AddRadioItem(COMMAND_SELECT_UTF16, ASCIIToUTF16("UTF-16"), |
| 90 GROUP_MAKE_DECISION); | 90 GROUP_MAKE_DECISION); |
| 91 AddSeparator(); | 91 AddSeparator(ui::NORMAL_SEPARATOR); |
| 92 AddCheckItem(COMMAND_CHECK_APPLE, ASCIIToUTF16("Apple")); | 92 AddCheckItem(COMMAND_CHECK_APPLE, ASCIIToUTF16("Apple")); |
| 93 AddCheckItem(COMMAND_CHECK_ORANGE, ASCIIToUTF16("Orange")); | 93 AddCheckItem(COMMAND_CHECK_ORANGE, ASCIIToUTF16("Orange")); |
| 94 AddCheckItem(COMMAND_CHECK_KIWI, ASCIIToUTF16("Kiwi")); | 94 AddCheckItem(COMMAND_CHECK_KIWI, ASCIIToUTF16("Kiwi")); |
| 95 AddSeparator(); | 95 AddSeparator(ui::NORMAL_SEPARATOR); |
| 96 AddItem(COMMAND_GO_HOME, ASCIIToUTF16("Go Home")); | 96 AddItem(COMMAND_GO_HOME, ASCIIToUTF16("Go Home")); |
| 97 | 97 |
| 98 submenu_.reset(new ui::SimpleMenuModel(this)); | 98 submenu_.reset(new ui::SimpleMenuModel(this)); |
| 99 submenu_->AddItem(COMMAND_DO_SOMETHING, ASCIIToUTF16("Do Something 2")); | 99 submenu_->AddItem(COMMAND_DO_SOMETHING, ASCIIToUTF16("Do Something 2")); |
| 100 AddSubMenu(0, ASCIIToUTF16("Submenu"), submenu_.get()); | 100 AddSubMenu(0, ASCIIToUTF16("Submenu"), submenu_.get()); |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool ExampleMenuModel::IsCommandIdChecked(int command_id) const { | 103 bool ExampleMenuModel::IsCommandIdChecked(int command_id) const { |
| 104 // Radio items. | 104 // Radio items. |
| 105 if (command_id == current_encoding_command_id_) | 105 if (command_id == current_encoding_command_id_) |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 void MenuExample::CreateExampleView(View* container) { | 212 void MenuExample::CreateExampleView(View* container) { |
| 213 // We add a button to open a menu. | 213 // We add a button to open a menu. |
| 214 ExampleMenuButton* menu_button = new ExampleMenuButton( | 214 ExampleMenuButton* menu_button = new ExampleMenuButton( |
| 215 ASCIIToUTF16("Open a menu")); | 215 ASCIIToUTF16("Open a menu")); |
| 216 container->SetLayoutManager(new FillLayout); | 216 container->SetLayoutManager(new FillLayout); |
| 217 container->AddChildView(menu_button); | 217 container->AddChildView(menu_button); |
| 218 } | 218 } |
| 219 | 219 |
| 220 } // namespace examples | 220 } // namespace examples |
| 221 } // namespace views | 221 } // namespace views |
| OLD | NEW |