| 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/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "ui/base/models/simple_menu_model.h" | 10 #include "ui/base/models/simple_menu_model.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 namespace examples { | 21 namespace examples { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 class ExampleMenuModel : public ui::SimpleMenuModel, | 25 class ExampleMenuModel : public ui::SimpleMenuModel, |
| 26 public ui::SimpleMenuModel::Delegate { | 26 public ui::SimpleMenuModel::Delegate { |
| 27 public: | 27 public: |
| 28 ExampleMenuModel(); | 28 ExampleMenuModel(); |
| 29 | 29 |
| 30 // ui::SimpleMenuModel::Delegate: | 30 // ui::SimpleMenuModel::Delegate: |
| 31 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 31 virtual bool IsCommandIdChecked(int command_id) const override; |
| 32 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 32 virtual bool IsCommandIdEnabled(int command_id) const override; |
| 33 virtual bool GetAcceleratorForCommandId( | 33 virtual bool GetAcceleratorForCommandId( |
| 34 int command_id, | 34 int command_id, |
| 35 ui::Accelerator* accelerator) OVERRIDE; | 35 ui::Accelerator* accelerator) override; |
| 36 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; | 36 virtual void ExecuteCommand(int command_id, int event_flags) override; |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 enum GroupID { | 39 enum GroupID { |
| 40 GROUP_MAKE_DECISION, | 40 GROUP_MAKE_DECISION, |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 enum CommandID { | 43 enum CommandID { |
| 44 COMMAND_DO_SOMETHING, | 44 COMMAND_DO_SOMETHING, |
| 45 COMMAND_SELECT_ASCII, | 45 COMMAND_SELECT_ASCII, |
| 46 COMMAND_SELECT_UTF8, | 46 COMMAND_SELECT_UTF8, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 class ExampleMenuButton : public MenuButton, public MenuButtonListener { | 61 class ExampleMenuButton : public MenuButton, public MenuButtonListener { |
| 62 public: | 62 public: |
| 63 explicit ExampleMenuButton(const base::string16& test); | 63 explicit ExampleMenuButton(const base::string16& test); |
| 64 virtual ~ExampleMenuButton(); | 64 virtual ~ExampleMenuButton(); |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 // MenuButtonListener: | 67 // MenuButtonListener: |
| 68 virtual void OnMenuButtonClicked(View* source, | 68 virtual void OnMenuButtonClicked(View* source, |
| 69 const gfx::Point& point) OVERRIDE; | 69 const gfx::Point& point) override; |
| 70 | 70 |
| 71 ui::SimpleMenuModel* GetMenuModel(); | 71 ui::SimpleMenuModel* GetMenuModel(); |
| 72 | 72 |
| 73 scoped_ptr<ExampleMenuModel> menu_model_; | 73 scoped_ptr<ExampleMenuModel> menu_model_; |
| 74 scoped_ptr<MenuRunner> menu_runner_; | 74 scoped_ptr<MenuRunner> menu_runner_; |
| 75 | 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(ExampleMenuButton); | 76 DISALLOW_COPY_AND_ASSIGN(ExampleMenuButton); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 // ExampleMenuModel --------------------------------------------------------- | 79 // ExampleMenuModel --------------------------------------------------------- |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 void MenuExample::CreateExampleView(View* container) { | 216 void MenuExample::CreateExampleView(View* container) { |
| 217 // We add a button to open a menu. | 217 // We add a button to open a menu. |
| 218 ExampleMenuButton* menu_button = new ExampleMenuButton( | 218 ExampleMenuButton* menu_button = new ExampleMenuButton( |
| 219 ASCIIToUTF16("Open a menu")); | 219 ASCIIToUTF16("Open a menu")); |
| 220 container->SetLayoutManager(new FillLayout); | 220 container->SetLayoutManager(new FillLayout); |
| 221 container->AddChildView(menu_button); | 221 container->AddChildView(menu_button); |
| 222 } | 222 } |
| 223 | 223 |
| 224 } // namespace examples | 224 } // namespace examples |
| 225 } // namespace views | 225 } // namespace views |
| OLD | NEW |