]> Creatis software - creaImageIO.git/blob - src2/creaImageIOWxTreeView.h
bf13312cd896460e95a2f0e4afbbcb9bffc43ecd
[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 for first item edition
46           void OnBeginLabelEdit(wxListEvent& event);
47
48           /// Callback when first item edition ends
49           void OnEndLabelEdit(wxListEvent& event);
50
51     private:
52       /// The struct holding the data for one level
53       /// Holds the wx control and other data
54       /// such as the vector of attribute keys corresponding to the columns
55       struct LevelType
56       {
57         // The List Control
58         wxListCtrl* wxCtrl;
59         wxSplitterWindow* wxSplitter;
60         std::vector<std::string> key;
61       };
62       /// The vector of levels : one for each level of the tree      
63       std::vector<LevelType> mLevelList;
64       
65       /// return the wxListCtrl of one level
66       wxListCtrl* GetCtrl(int l) { return mLevelList[l].wxCtrl; }
67       /// return the wxSplitter of one level
68       wxSplitterWindow* GetSplitter(int l) { return mLevelList[l].wxSplitter; }
69           //Returns the maximum number of levels
70           int GetNumberOfLevels(){ return mLevelList.size(); }
71           /// Gets the user selected data from the level passed as a parameter
72       std::vector<tree::Node*> GetSelected(int level);
73           ///Validates the selected images
74       void ValidateSelectedImages(bool isSelection);   
75           ///Gets selected filenames
76           void GetSelectedAsString(std::vector<std::string>&s);
77             /// Gets the next nodes on the list, be it up(true) or down(false).
78       void GetNodes(std::vector<tree::Node*>& nodes, bool direction);
79       /// Updates the view of a level given the selected items of upper level
80       /// Recursive method
81       virtual void RecursiveUpdateLevel( int );
82           ///Sets the color of a selected item
83           void SetColor(int level, int item);
84           ///Creates the color palette for the first level
85           void CreateColorPalette();
86           ///Selects the lowest level (images)
87           void SelectLowerLevel();
88
89
90       /// Currently Selected Column
91           int mColumnSelected;
92           ///Boolean that defines the direction of the organization
93           ///True is ascending order and false is descending
94           bool mDirection;
95           ///The last selected item on the list
96           long mLastSelected;
97           ///The last selection of nodes (for every level, except the last)
98           std::vector<tree::Node*> mSelected;
99           ///The last selection of nodes (for the last level)
100           std::vector<tree::Node*> mLastLevelSelected;
101           ///The color map
102           typedef std::map<tree::Node*,wxColour> ColorMap;
103           typedef std::pair<tree::Node*,wxColour> NodeColorPair;
104       ColorMap mColorMap;
105           ///Initial color palette
106           std::vector<std::string> mColorPalette;
107           ///Boolean declaring if the last level selection has been made
108           bool mSelectionMade;
109           bool mProcess;
110
111       DECLARE_EVENT_TABLE()
112     };
113     // EO class WxTreeView
114     //=====================================================================
115
116
117
118 } // EO namespace creaImageIO
119
120
121 #endif // USE_WIDGETS
122 // EOF
123 #endif