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