2
* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; version 2 of the
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
// included in wbpublic.wr because of dependency on TreeModel
22
#ifndef _WF_GRTTREEVIEW_H_
23
#define _WF_GRTTREEVIEW_H_
25
#include "grt/tree_model.h"
27
#include "mforms/grttreeview.h"
33
using namespace System;
34
using namespace Windows::Forms;
35
using namespace System::Collections::Generic;
37
using namespace Aga::Controls::Tree;
38
using namespace Aga::Controls::Tree::NodeControls;
43
private ref struct ColumnEntry
45
NodeControl^ nodeControl;
50
ColumnEntry(NodeControl^ control, int column, bool editable, bool isIcon)
52
this->nodeControl= control;
54
this->editable= editable;
60
* Helper class to forward double clicks on the node icon.
62
private ref class SwitchNodeIcon : public NodeIcon
65
virtual void MouseDoubleClick(TreeNodeAdvMouseEventArgs^ args) override;
69
* Helper class to show our own expand icons.
71
private ref class TriangleNodeControl : public NodeControl
74
System::Drawing::Bitmap^ _expanded_icon;
75
System::Drawing::Bitmap^ _collapsed_icon;
76
System::Drawing::Size _size;
78
TriangleNodeControl();
80
virtual System::Drawing::Size MeasureSize(TreeNodeAdv^ node, DrawContext context) override;
81
virtual void Draw(TreeNodeAdv^ node, DrawContext context) override;
82
virtual void MouseDown(TreeNodeAdvMouseEventArgs^ args) override;
83
virtual void MouseDoubleClick(TreeNodeAdvMouseEventArgs^ args) override;
87
* Helper class to forward double clicks for non-editable node texts.
89
private ref class SwitchNodeText : public NodeTextBox
92
virtual void OnDrawText(DrawEventArgs^ args) override;
94
virtual void MouseDoubleClick(TreeNodeAdvMouseEventArgs^ args) override;
98
* Wrapper for a native .NET treeview control with GRT bec::TreeModel data.
99
* We use the TreeViewAdv control as we need multicolumn support.
101
public ref class GRTTreeViewImpl : public ViewImpl
104
MySQL::Grt::TreeModel^ _tree_model;
105
MySQL::Grt::SimpleGrtTreeModel^ _model;
106
List<ColumnEntry^> _columns;
108
void add_node_control(NodeControl^ control, int column, bool editable, bool isIcon);
111
static void SelectionChanged(System::Object^ sender, EventArgs^ e);
112
static void OnMouseDown(System::Object^ sender, MouseEventArgs^ e);
115
static bool create(::mforms::GRTTreeView *self, mforms::TreeOptions options);
117
static void set_model(::mforms::GRTTreeView* self, bec::TreeModel* model);
119
static int add_column(::mforms::GRTTreeView *self, ::mforms::GRTTreeColumnType type, int model_column, const std::string &title);
120
static int add_column_editable(::mforms::GRTTreeView *self, ::mforms::GRTTreeColumnType type, int model_column, const std::string &title);
122
static void refresh(mforms::GRTTreeView* self, const bec::NodeId& node);
123
static void set_column_width(mforms::GRTTreeView* self, int column, int width);
124
static bool get_selected_node(mforms::GRTTreeView* self, bec::NodeId& node);
125
static int get_selection(mforms::GRTTreeView* self, std::vector<bec::NodeId>& nodes);
126
static void set_expanded(mforms::GRTTreeView* self, const bec::NodeId& node, bool expanded);
127
static void enable_asynch_loading(mforms::GRTTreeView* self, bool enabled);
129
static void set_allow_multi_selection(mforms::GRTTreeView *self, bool flag);
130
static void row_count_changed(mforms::GRTTreeView *self, const bec::NodeId& node, int old_count);
132
void set_model(bec::TreeModel*);
134
GRTTreeViewImpl(::mforms::GRTTreeView *self);
137
int add_column(::mforms::GRTTreeColumnType type, int model_column, String ^name, bool editable);
139
static void init(Manager ^mgr)
141
::mforms::ControlFactory *f= ::mforms::ControlFactory::get_instance();
143
DEF_CALLBACK2(bool, ::mforms::GRTTreeView*, mforms::TreeOptions, mgr, f->_grttreeview_impl, GRTTreeViewImpl, create);
144
DEF_CALLBACK2(void, ::mforms::GRTTreeView*, bec::TreeModel*, mgr, f->_grttreeview_impl, GRTTreeViewImpl, set_model);
145
DEF_CALLBACK4(int, ::mforms::GRTTreeView*, ::mforms::GRTTreeColumnType, int, const std::string&, mgr, f->_grttreeview_impl, GRTTreeViewImpl, add_column);
146
DEF_CALLBACK4(int, ::mforms::GRTTreeView*, ::mforms::GRTTreeColumnType, int, const std::string&, mgr, f->_grttreeview_impl, GRTTreeViewImpl, add_column_editable);
147
DEF_CALLBACK2(void, ::mforms::GRTTreeView*, const bec::NodeId &, mgr, f->_grttreeview_impl, GRTTreeViewImpl, refresh);
148
DEF_CALLBACK3(void, ::mforms::GRTTreeView*, int, int, mgr, f->_grttreeview_impl, GRTTreeViewImpl, set_column_width);
149
DEF_CALLBACK2(bool, ::mforms::GRTTreeView*, bec::NodeId&, mgr, f->_grttreeview_impl, GRTTreeViewImpl, get_selected_node);
150
DEF_CALLBACK2(int, ::mforms::GRTTreeView*, std::vector<bec::NodeId>&, mgr, f->_grttreeview_impl, GRTTreeViewImpl, get_selection);
151
DEF_CALLBACK2(void, ::mforms::GRTTreeView*, bool, mgr, f->_grttreeview_impl, GRTTreeViewImpl, set_allow_multi_selection);
152
DEF_CALLBACK3(void, ::mforms::GRTTreeView*, const bec::NodeId&, int, mgr, f->_grttreeview_impl, GRTTreeViewImpl, row_count_changed);
153
DEF_CALLBACK3(void, ::mforms::GRTTreeView*, const bec::NodeId&, bool, mgr, f->_grttreeview_impl, GRTTreeViewImpl, set_expanded);
154
DEF_CALLBACK2(void, ::mforms::GRTTreeView*, bool, mgr, f->_grttreeview_impl, GRTTreeViewImpl, enable_asynch_loading);
160
#endif // _WF_GRTTREEVIEW_H_
b'\\ No newline at end of file'