]> Creatis software - creaImageIO.git/blob - src2/creaImageIOWxTreeView.h
7401e90bd8a8c94aacb280c1301009850dcce59c
[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    * \ingroup View
17    */
18   //=====================================================================
19   
20   //=====================================================================
21   /// Abstract class that handles the view of a Tree through its TreeHandler
22   class WxTreeView : public wxPanel, virtual public TreeView
23     {
24     public:
25       /// Ctor
26       WxTreeView(TreeHandler*, wxWindow* parent, const wxWindowID id);
27       /// Virtual destructor
28       virtual ~WxTreeView();
29
30       
31       /// Updates the view of a level given the selected items of upper level
32       virtual void UpdateLevel( int );
33
34           ///Removes selected nodes on given level
35           virtual void RemoveSelected( int );
36
37           /// Callback for selection change
38       void OnSelectedChanged(wxListEvent& event);
39
40           /// Callback for column click
41       void OnColClick(wxListEvent& event);
42
43         private:
44       /// The struct holding the data for one level
45       /// Holds the wx control and other data
46       /// such as the vector of attribute keys corresponding to the columns
47       struct LevelType
48       {
49         // The List Control
50         wxListCtrl* wxCtrl;
51         wxSplitterWindow* wxSplitter;
52         std::vector<std::string> key;
53       };
54       /// The vector of levels : one for each level of the tree      
55       std::vector<LevelType> mLevelList;
56       
57       /// return the wxListCtrl of one level
58       wxListCtrl* GetCtrl(int l) { return mLevelList[l].wxCtrl; }
59       /// return the wxSplitter of one level
60       wxSplitterWindow* GetSplitter(int l) { return mLevelList[l].wxSplitter; }
61           //Returns the maximum number of levels
62           int GetNumberOfLevels(){ return mLevelList.size(); }
63           /// Gets the user selected data from the level passed as a parameter
64       std::vector<tree::Node*> GetSelected(int level);
65           ///Validates the selected images
66       void ValidateSelectedImages();   
67           ///Gets selected filenames
68           void GetSelectedAsString(std::vector<std::string>&s);
69             /// Gets the next nodes on the list, be it up(true) or down(false).
70       void GetNodes(std::vector<tree::Node*>& nodes, bool direction);
71       /// Updates the view of a level given the selected items of upper level
72       /// Recursive method
73       virtual void RecursiveUpdateLevel( int );
74
75
76       /// Currently Selected Column
77           int mColumnSelected;
78           ///Boolean that defines the direction of the organization
79           ///True is ascending order and false is descending
80           bool mDirection;
81           ///The last selected item on the list
82           long mLastSelected;
83         
84           
85
86       DECLARE_EVENT_TABLE()
87     };
88     // EO class WxTreeView
89     //=====================================================================
90
91
92
93 } // EO namespace creaImageIO
94
95
96 #endif // USE_WIDGETS
97 // EOF
98 #endif