Version: 0.6.0
gxtreeview.h
1 /******************************************************************************
2  * Project: wxGIS (GIS Catalog)
3  * Purpose: wxGxTreeView class.
4  * Author: Dmitry Baryshnikov (aka Bishop), polimax@mail.ru
5  ******************************************************************************
6 * Copyright (C) 2009-2013 Dmitry Baryshnikov
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  ****************************************************************************/
21 #pragma once
22 
23 #include "wxgis/catalogui/gxview.h"
24 #include "wxgis/catalogui/gxcatalogui.h"
25 #include "wxgis/catalog/gxevent.h"
26 #include "wxgis/catalogui/gxeventui.h"
27 #include "wxgis/catalogui/gxapplication.h"
28 
29 #include "wx/treectrl.h"
30 #include "wx/imaglist.h"
31 
32 class wxGxApplication;
33 
41 class wxGxTreeItemData : public wxTreeItemData
42 {
43 public:
44  wxGxTreeItemData(long nObjectID, int smallimage_index, bool bExpandedOnce)
45  {
46  m_nObjectID = nObjectID;
47  m_smallimage_index = smallimage_index;
48  m_bExpandedOnce = bExpandedOnce;
49  }
50 
51  ~wxGxTreeItemData(void)
52  {
53  }
54 
55  long m_nObjectID;
56  int m_smallimage_index;
57  bool m_bExpandedOnce;
58 };
59 
64 class WXDLLIMPEXP_GIS_CLU wxGxTreeViewBase :
65  public wxTreeCtrl,
66  public wxGxView
67 {
68  DECLARE_CLASS(wxGxTreeViewBase)
69 public:
70  wxGxTreeViewBase(void);
71  wxGxTreeViewBase(wxWindow* parent, wxWindowID id = TREECTRLID, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTR_HAS_BUTTONS | wxTR_TWIST_BUTTONS );
72  virtual ~wxGxTreeViewBase(void);
73  virtual void AddTreeItem(wxGxObject* pGxObject, wxTreeItemId hParent);
74  virtual void RefreshAll(void);
75 //wxGxView
76  virtual bool Create(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTR_HAS_BUTTONS | wxTR_TWIST_BUTTONS, const wxString& name = wxT("TreeView"));
77  virtual bool Activate(IApplication* const pApplication, wxXmlNode* const pConf);
78  virtual void Deactivate(void);
79  virtual void BeginRename(long nObjectID = wxNOT_FOUND){};
80  virtual void Refresh(void){wxTreeCtrl::Refresh();};
81 //wxTreeCtrl
82  virtual int OnCompareItems(const wxTreeItemId& item1, const wxTreeItemId& item2);
83 
84  typedef std::map<long, wxTreeItemId> wxTreeItemMap;
85  typedef struct _icondata
86  {
87  wxIcon oIcon;
88  int iImageIndex;
89  } ICONDATA;
90 protected:
91  virtual void AddRoot(wxGxObject* pGxObject);
92 protected:
93 //events
94  virtual void OnItemExpanding(wxTreeEvent& event);
95  virtual void OnItemRightClick(wxTreeEvent& event);
96  virtual void OnChar(wxKeyEvent& event);
97  virtual void OnObjectRefreshed(wxGxCatalogEvent& event);
98  virtual void OnObjectAdded(wxGxCatalogEvent& event);
99  virtual void OnObjectChanged(wxGxCatalogEvent& event);
100  virtual void OnObjectDeleted(wxGxCatalogEvent& event);
101  virtual void OnSelectionChanged(wxGxSelectionEvent& event);
102  //
103  virtual void UpdateGxSelection(void);
104 protected:
105  wxImageList m_TreeImageList;
106  wxTreeItemMap m_TreeMap;
107  wxGISApplicationBase* m_pApp;
108  wxGxApplication *m_pGxApp;
109  long m_ConnectionPointCatalogCookie, m_ConnectionPointSelectionCookie;
110  wxGxSelection* m_pSelection;
111  wxGxCatalogUI* m_pCatalog;
112  wxGISCommand* m_pDeleteCmd;
113  wxVector<ICONDATA> m_IconsArray;
114 private:
115  DECLARE_EVENT_TABLE()
116 };
117 
121 class WXDLLIMPEXP_GIS_CLU wxGxTreeView :
122  public wxGxTreeViewBase,
123  public IViewDropTarget
124 {
125  DECLARE_DYNAMIC_CLASS(wxGxTreeView)
126 public:
127  wxGxTreeView(void);
128  wxGxTreeView(wxWindow* parent, wxWindowID id = TREECTRLID, long style = wxTR_HAS_BUTTONS | wxTR_TWIST_BUTTONS | wxBORDER_NONE | wxTR_EDIT_LABELS );//wxTR_MULTIPLE| wxTR_LINES_AT_ROOT
129  virtual ~wxGxTreeView(void);
130 //IGxDropTarget
131  virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
132  virtual bool OnDropObjects(wxCoord x, wxCoord y, const wxArrayString& GxObjects, bool bIsControlOn);
133  virtual void OnLeave();
134  virtual bool CanPaste(void);
135 //events
136  virtual void OnBeginLabelEdit(wxTreeEvent& event);
137  virtual void OnEndLabelEdit(wxTreeEvent& event);
138  virtual void OnSelChanged(wxTreeEvent& event);
139  virtual void OnItemRightClick(wxTreeEvent& event);
140  virtual void OnBeginDrag(wxTreeEvent& event);
141  virtual void OnActivated(wxTreeEvent& event);
142 //wxGxTreeViewBase
143  virtual void OnObjectAdded(wxGxCatalogEvent& event);
144 //wxGxTreeView
145  virtual void BeginRename(long nObjectID = wxNOT_FOUND);
146 protected:
147  wxTreeItemId m_HighLightItemId;
148 private:
149  DECLARE_EVENT_TABLE()
150 };
Definition: gxtreeview.h:41
The GxSelection class event.
Definition: gxeventui.h:37
Definition: applicationbase.h:65
Definition: gxtreeview.h:85
The Network event.
Definition: gxevent.h:39
Definition: command.h:53
Definition: gxview.h:35
The tree view in Catalog.
Definition: gxtreeview.h:121
Definition: gxcatalogui.h:34
The base class for tree view of gxObjects.
Definition: gxtreeview.h:64
The GxObject Selection class.
Definition: gxselection.h:30
Definition: framework.h:59
Definition: app.h:32
Definition: gxapplication.h:41
Definition: gxobject.h:37