]> Creatis software - creaImageIO.git/blob - src2/creaImageIOWxTreeView.h
Validation changed and added number of children to the database.
[creaImageIO.git] / src2 / creaImageIOWxTreeView.h
1 #ifndef __creaImageIOWxTreeView_h_INCLUDED__
2 #define __creaImageIOWxTreeView_h_INCLUDED__
3
4 #ifdef USE_WXWIDGETS
5
6 #include <creaImageIOTreeView.h>
7 #include <creaWx.h>
8
9 #include <wx/listctrl.h>
10 #include <wx/splitter.h>
11 //#include <vector>
12
13 namespace creaImageIO
14 {
15
16   /**
17    * \ingroup View
18    */
19   //=====================================================================
20   
21   //=====================================================================
22   /// Abstract class that handles the view of a Tree through its TreeHandler
23   class WxTreeView : public wxPanel, virtual public TreeView
24     {
25     public:
26       /// Ctor
27       WxTreeView(TreeHandler*, GimmickView*, 
28                  wxWindow* parent, const wxWindowID id);
29       /// Virtual destructor
30       virtual ~WxTreeView();
31
32       
33       /// Updates the view of a level given the selected items of upper level
34       virtual void UpdateLevel( int );
35
36           ///Removes selected nodes on given level
37           virtual void RemoveSelected( int );
38
39           /// Callback for selection change
40       void OnSelectedChanged(wxListEvent& event);
41
42           /// Callback for column click
43       void OnColClick(wxListEvent& event);
44
45           /// Callback when the user needs the items sorted
46           void OnPopupSort(wxCommandEvent& event);
47
48           ///Callback when the user need the items filtered
49            void OnPopupFilter(wxCommandEvent& event);
50
51            ///Callback on mouse click
52            void OnMouseClick(wxMouseEvent& event);
53  
54
55     private:
56       /// The struct holding the data for one level
57       /// Holds the wx control and other data
58       /// such as the vector of attribute keys corresponding to the columns
59       struct LevelType
60       {
61         // The List Control
62         wxListCtrl* wxCtrl;
63         wxSplitterWindow* wxSplitter;
64         std::vector<std::string> key;
65       };
66       /// The vector of levels : one for each level of the tree      
67       std::vector<LevelType> mLevelList;
68       
69       /// return the wxListCtrl of one level
70       wxListCtrl* GetCtrl(int l) { return mLevelList[l].wxCtrl; }
71       /// return the wxSplitter of one level
72       wxSplitterWindow* GetSplitter(int l) { return mLevelList[l].wxSplitter; }
73           //Returns the maximum number of levels
74           int GetNumberOfLevels(){ return mLevelList.size(); }
75           /// Gets the user selected data from the level passed as a parameter
76       std::vector<tree::Node*> GetSelected(int level);
77           ///Validates the selected images
78       void ValidateSelectedImages(bool isSelection);   
79           ///Gets selected filenames
80           void GetSelectedAsString(std::vector<std::string>&s);
81             /// Gets the next nodes on the list, be it up(true) or down(false).
82       void GetNodes(std::vector<tree::Node*>& nodes, bool direction);
83       /// Updates the view of a level given the selected items of upper level
84       /// Recursive method
85       virtual void RecursiveUpdateLevel( int );
86           ///Sets the color of a selected item
87           void SetColor(int level, int item);
88           ///Creates the color palette for the first level
89           void CreateColorPalette();
90           ///Selects the lowest level (images)
91           void SelectLowerLevel();
92           ///Sorts items
93           void OnSort(int level);
94
95
96
97       /// Currently Selected Column
98           int mColumnSelected;
99           ///Boolean that defines the direction of the organization
100           ///True is ascending order and false is descending
101           bool mDirection;
102           ///The last selected item on the list
103           long mLastSelected;
104           ///The color map
105           typedef std::map<tree::Node*,wxColour> ColorMap;
106           typedef std::pair<tree::Node*,wxColour> NodeColorPair;
107       ColorMap mColorMap;
108           ///Initial color palette
109           std::vector<std::string> mColorPalette;
110           ///Boolean declaring if the last level selection has been made
111           bool mSelectionMade;
112           bool mProcess;
113           wxMenu* menu;
114           wxObject* senderCtrl;
115           int mAscendingID;
116           int mDescendingID;
117           int mFilterID;
118
119       DECLARE_EVENT_TABLE()
120     };
121     // EO class WxTreeView
122     //=====================================================================
123
124
125
126 } // EO namespace creaImageIO
127
128
129 #endif // USE_WIDGETS
130 // EOF
131 #endif