#ifndef UI_VIEWS_EXAMPLES_TREE_VIEW_EXAMPLE_H_
#define UI_VIEWS_EXAMPLES_TREE_VIEW_EXAMPLE_H_
#include "base/macros.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/base/models/tree_node_model.h"
#include "ui/views/context_menu_controller.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/tree/tree_view_controller.h"
#include "ui/views/examples/example_base.h"
namespace views {
class MenuRunner;
class TreeView;
namespace examples {
class VIEWS_EXAMPLES_EXPORT TreeViewExample
: public ExampleBase,
public ButtonListener,
public TreeViewController,
public ContextMenuController,
public ui::SimpleMenuModel::Delegate {
public:
TreeViewExample();
virtual ~TreeViewExample();
virtual void CreateExampleView(View* container) OVERRIDE;
private:
enum MenuIDs {
ID_EDIT,
ID_REMOVE,
ID_ADD
};
void AddNewNode();
bool IsCommandIdEnabled(int command_id);
virtual void ButtonPressed(Button* sender, const ui::Event& event) OVERRIDE;
virtual void OnTreeViewSelectionChanged(TreeView* tree_view) OVERRIDE;
virtual bool CanEdit(TreeView* tree_view, ui::TreeModelNode* node) OVERRIDE;
virtual void ShowContextMenuForView(View* source,
const gfx::Point& point,
ui::MenuSourceType source_type) OVERRIDE;
virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
virtual bool GetAcceleratorForCommandId(
int command_id,
ui::Accelerator* accelerator) OVERRIDE;
virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
TreeView* tree_view_;
Button* add_;
Button* remove_;
Button* change_title_;
typedef ui::TreeNodeWithValue<int> NodeType;
ui::TreeNodeModel<NodeType> model_;
scoped_ptr<MenuRunner> context_menu_runner_;
DISALLOW_COPY_AND_ASSIGN(TreeViewExample);
};
}
}
#endif