ToolMap
Loading...
Searching...
No Matches
tocctrlmodel.h
1#ifndef FEATURE_TOC_TOCCTRLMODEL_H
2#define FEATURE_TOC_TOCCTRLMODEL_H
3
4#include "wx/wxprec.h"
5#ifndef WX_PRECOMP
6#include "wx/wx.h"
7#endif
8
9#include <wx/dataview.h>
10
11#include "tmlayerproperties.h"
12
14
15WX_DEFINE_ARRAY_PTR(TocCtrlModelNode*, TocCtrlModelNodePtrArray);
16
21 public:
23
25
26 void GetAllChildRecursive(TocCtrlModelNodePtrArray& node_array, TocCtrlModelNode* startnode = nullptr);
27 bool IsMyChildren(TocCtrlModelNode* node);
28
29 bool IsContainer() const;
30
31 TocCtrlModelNode* GetParent();
32
33 TocCtrlModelNodePtrArray& GetChildren();
34
35 void Insert(TocCtrlModelNode* child, unsigned int n);
36
37 void Append(TocCtrlModelNode* child);
38
39 unsigned int GetChildCount() const;
40
41 // public to avoid getters/setters
42 bool m_Container;
43 tmLayerProperties* m_LayerProp;
44
45 private:
46 TocCtrlModelNode* m_Parent;
47 TocCtrlModelNodePtrArray m_Children;
48};
49
53class TocCtrlModel : public wxDataViewModel {
54 public:
56
58 delete m_Root;
59 }
60
61 bool IsChecked(const wxDataViewItem& item) const;
62 void SetChecked(const wxDataViewItem& item, bool check = true);
63
64 wxString NodeGetTitle(TocCtrlModelNode* node);
65 bool NodeSetTitle(TocCtrlModelNode* node, const wxString& title);
66
68 TocCtrlModelNode* NodeInsert(TocCtrlModelNode* parent, tmLayerProperties* layerprop, int index = 0);
69 bool NodeMove(wxDataViewItemArray& selectedItems, TocCtrlModelNode* destination, int proposedIndex = wxNOT_FOUND);
70 void NodeRecursiveAdd(TocCtrlModelNode* parent, TocCtrlModelNode* start);
71 void NodeRecursiveRemove(TocCtrlModelNode* start);
72
73 // model function
74 void Delete(const wxDataViewItem& item);
75
76 void Clear();
77
78 virtual void GetValue(wxVariant& variant, const wxDataViewItem& item, unsigned int col) const wxOVERRIDE;
79
80 virtual bool SetValue(const wxVariant& variant, const wxDataViewItem& item, unsigned int col) wxOVERRIDE;
81
82 virtual bool IsEnabled(const wxDataViewItem& item, unsigned int col) const wxOVERRIDE;
83
84 virtual wxDataViewItem GetParent(const wxDataViewItem& item) const wxOVERRIDE;
85
86 wxDataViewItem GetRoot() const;
87
88 virtual bool IsContainer(const wxDataViewItem& item) const wxOVERRIDE;
89
90 virtual unsigned int GetChildren(const wxDataViewItem& parent, wxDataViewItemArray& array) const wxOVERRIDE;
91
92 virtual unsigned int GetColumnCount() const wxOVERRIDE;
93 virtual wxString GetColumnType(unsigned int) const wxOVERRIDE;
94
95 static wxDataViewItem ConvertFromNode(const TocCtrlModelNode* node);
96 static TocCtrlModelNode* ConvertFromDataViewItem(const wxDataViewItem& item);
97
98 private:
99 TocCtrlModelNode* m_Root;
100 wxImageList m_ImageList;
101};
102
103#endif // FEATURE_TOC_TOCCTRLMODEL_H
Node for TocCtrlModel.
Definition tocctrlmodel.h:20
Model for TocCtrl.
Definition tocctrlmodel.h:53
wxString NodeGetTitle(TocCtrlModelNode *node)
Definition tocctrlmodel.cpp:299
TocCtrlModelNode * NodeAdd(TocCtrlModelNode *parent, tmLayerProperties *layerprop)
Definition tocctrlmodel.cpp:254
bool NodeMove(wxDataViewItemArray &selectedItems, TocCtrlModelNode *destination, int proposedIndex=wxNOT_FOUND)
Definition tocctrlmodel.cpp:325
TocCtrlModel()
TocCtrlModel.
Definition tocctrlmodel.cpp:82
bool NodeSetTitle(TocCtrlModelNode *node, const wxString &title)
Definition tocctrlmodel.cpp:310
Storing object of layer type.
Definition tmlayerproperties.h:47