| 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 #ifndef UI_VIEWS_EXAMPLES_TREE_VIEW_EXAMPLE_H_ | 5 #ifndef UI_VIEWS_EXAMPLES_TREE_VIEW_EXAMPLE_H_ |
| 6 #define UI_VIEWS_EXAMPLES_TREE_VIEW_EXAMPLE_H_ | 6 #define UI_VIEWS_EXAMPLES_TREE_VIEW_EXAMPLE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "ui/base/models/simple_menu_model.h" | 9 #include "ui/base/models/simple_menu_model.h" |
| 10 #include "ui/base/models/tree_node_model.h" | 10 #include "ui/base/models/tree_node_model.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 : public ExampleBase, | 24 : public ExampleBase, |
| 25 public ButtonListener, | 25 public ButtonListener, |
| 26 public TreeViewController, | 26 public TreeViewController, |
| 27 public ContextMenuController, | 27 public ContextMenuController, |
| 28 public ui::SimpleMenuModel::Delegate { | 28 public ui::SimpleMenuModel::Delegate { |
| 29 public: | 29 public: |
| 30 TreeViewExample(); | 30 TreeViewExample(); |
| 31 virtual ~TreeViewExample(); | 31 virtual ~TreeViewExample(); |
| 32 | 32 |
| 33 // ExampleBase: | 33 // ExampleBase: |
| 34 virtual void CreateExampleView(View* container) OVERRIDE; | 34 virtual void CreateExampleView(View* container) override; |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 // IDs used by the context menu. | 37 // IDs used by the context menu. |
| 38 enum MenuIDs { | 38 enum MenuIDs { |
| 39 ID_EDIT, | 39 ID_EDIT, |
| 40 ID_REMOVE, | 40 ID_REMOVE, |
| 41 ID_ADD | 41 ID_ADD |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 // Adds a new node. | 44 // Adds a new node. |
| 45 void AddNewNode(); | 45 void AddNewNode(); |
| 46 | 46 |
| 47 // Non-const version of IsCommandIdEnabled. | 47 // Non-const version of IsCommandIdEnabled. |
| 48 bool IsCommandIdEnabled(int command_id); | 48 bool IsCommandIdEnabled(int command_id); |
| 49 | 49 |
| 50 // ButtonListener: | 50 // ButtonListener: |
| 51 virtual void ButtonPressed(Button* sender, const ui::Event& event) OVERRIDE; | 51 virtual void ButtonPressed(Button* sender, const ui::Event& event) override; |
| 52 | 52 |
| 53 // TreeViewController: | 53 // TreeViewController: |
| 54 virtual void OnTreeViewSelectionChanged(TreeView* tree_view) OVERRIDE; | 54 virtual void OnTreeViewSelectionChanged(TreeView* tree_view) override; |
| 55 virtual bool CanEdit(TreeView* tree_view, ui::TreeModelNode* node) OVERRIDE; | 55 virtual bool CanEdit(TreeView* tree_view, ui::TreeModelNode* node) override; |
| 56 | 56 |
| 57 // ContextMenuController: | 57 // ContextMenuController: |
| 58 virtual void ShowContextMenuForView(View* source, | 58 virtual void ShowContextMenuForView(View* source, |
| 59 const gfx::Point& point, | 59 const gfx::Point& point, |
| 60 ui::MenuSourceType source_type) OVERRIDE; | 60 ui::MenuSourceType source_type) override; |
| 61 | 61 |
| 62 // SimpleMenuModel::Delegate: | 62 // SimpleMenuModel::Delegate: |
| 63 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 63 virtual bool IsCommandIdChecked(int command_id) const override; |
| 64 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 64 virtual bool IsCommandIdEnabled(int command_id) const override; |
| 65 virtual bool GetAcceleratorForCommandId( | 65 virtual bool GetAcceleratorForCommandId( |
| 66 int command_id, | 66 int command_id, |
| 67 ui::Accelerator* accelerator) OVERRIDE; | 67 ui::Accelerator* accelerator) override; |
| 68 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; | 68 virtual void ExecuteCommand(int command_id, int event_flags) override; |
| 69 | 69 |
| 70 // The tree view to be tested. | 70 // The tree view to be tested. |
| 71 TreeView* tree_view_; | 71 TreeView* tree_view_; |
| 72 | 72 |
| 73 // Control buttons to modify the model. | 73 // Control buttons to modify the model. |
| 74 Button* add_; | 74 Button* add_; |
| 75 Button* remove_; | 75 Button* remove_; |
| 76 Button* change_title_; | 76 Button* change_title_; |
| 77 | 77 |
| 78 typedef ui::TreeNodeWithValue<int> NodeType; | 78 typedef ui::TreeNodeWithValue<int> NodeType; |
| 79 | 79 |
| 80 ui::TreeNodeModel<NodeType> model_; | 80 ui::TreeNodeModel<NodeType> model_; |
| 81 | 81 |
| 82 scoped_ptr<MenuRunner> context_menu_runner_; | 82 scoped_ptr<MenuRunner> context_menu_runner_; |
| 83 | 83 |
| 84 DISALLOW_COPY_AND_ASSIGN(TreeViewExample); | 84 DISALLOW_COPY_AND_ASSIGN(TreeViewExample); |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 } // namespace examples | 87 } // namespace examples |
| 88 } // namespace views | 88 } // namespace views |
| 89 | 89 |
| 90 #endif // UI_VIEWS_EXAMPLES_TREE_VIEW_EXAMPLE_H_ | 90 #endif // UI_VIEWS_EXAMPLES_TREE_VIEW_EXAMPLE_H_ |
| OLD | NEW |