1 #ifndef __creaImageIOWxTreeView_h_INCLUDED__
2 #define __creaImageIOWxTreeView_h_INCLUDED__
6 #include <creaImageIOTreeView.h>
9 #include <wx/listctrl.h>
10 #include <wx/splitter.h>
19 //=====================================================================
21 //=====================================================================
22 /// Abstract class that handles the view of a Tree through its TreeHandler
23 class WxTreeView : public wxPanel, virtual public TreeView
27 WxTreeView(TreeHandler*, GimmickView*,
28 wxWindow* parent, const wxWindowID id);
29 /// Virtual destructor
30 virtual ~WxTreeView();
33 /// Updates the view of a level given the selected items of upper level
34 virtual void UpdateLevel( int );
36 ///Removes selected nodes on given level
37 virtual void RemoveSelected();
39 ///Returns the last selected level
40 virtual unsigned int GetLastSelectedLevel(){return mLastLevel;}
42 /// Callback for item selection
43 void OnItemSelected(wxListEvent& event);
45 /// Callback for item deselection
46 void OnItemDeSelected(wxListEvent& event);
48 /// Callback for column click
49 void OnColClick(wxListEvent& event);
51 /// Callback when the user needs the items sorted
52 void OnPopupSort(wxCommandEvent& event);
54 ///Callback when the user need the items filtered
55 void OnPopupFilter(wxCommandEvent& event);
57 ///Callback when the user needs the item copied to the local disk
58 void OnLocalCopy(wxCommandEvent& event);
60 ///Callback when the user needs to edit a field
61 void OnEditField(wxCommandEvent& event);
63 ///Callback on mouse click
64 void OnMouseClick(wxMouseEvent& event);
66 /// Displays a menu for items
67 void OnItemMenu(wxListEvent &event);
69 /// Gets the attributes that are being shown and the ones that have been blocked on a specific level
70 void GetAttributes(std::vector<std::string>& areShown, std::vector<std::string>& notShown, int level);
72 /// Actual processing of item selection/deselection
73 /// Called by OnItemSelected and OnItemDeSelected
76 /// The struct holding the data for one level
77 /// Holds the wx control and other data
78 /// such as the vector of attribute keys corresponding to the columns
83 wxSplitterWindow* wxSplitter;
84 std::vector<std::string> key;
85 //The vector of not shown attributes
86 std::vector<std::string> notShownAtts;
87 // The vector of currently selected nodes of the level
88 std::vector<tree::Node*> Selected;
89 // True iff the vector Selected is up to date
90 bool SelectedUpToDate;
91 // The column used for sorting
92 unsigned int SortColumn;
93 ///Boolean that defines the direction of the sort
94 ///True is ascending order and false is descending
98 /// The vector of levels : one for each level of the tree
99 std::vector<LevelType> mLevelList;
101 /// return the wxListCtrl of one level
102 wxListCtrl* GetCtrl(int l) { return mLevelList[l].wxCtrl; }
103 /// return the wxSplitter of one level
104 wxSplitterWindow* GetSplitter(int l) { return mLevelList[l].wxSplitter; }
105 //Returns the maximum number of levels
106 int GetNumberOfLevels(){ return mLevelList.size(); }
107 /// Gets the user selected data from the level passed as a parameter
108 /// Updates the vector if necessary
109 const std::vector<tree::Node*>& GetSelected(int level);
110 /// Set the bool SelectedUpToDate for level l
111 void SetSelectedUpToDate(int l, bool v) { mLevelList[l].SelectedUpToDate = v; }
112 /// Get the bool SelectedUpToDate for level l
113 bool GetSelectedUpToDate(int l) { return mLevelList[l].SelectedUpToDate; }
114 ///Validates the selected images
115 void ValidateSelectedImages(bool isSelection);
116 ///Gets selected filenames
117 void GetSelectedAsString(std::vector<std::string>&s);
118 ///Gets the filenames of the given nodes and returns them on the given vector. Is recursive.
119 void GetFilenamesAsString(const std::vector<tree::Node*>& nodes, std::vector<std::string>&s);
120 /// Gets the next nodes on the list, be it up(true) or down(false).
121 void GetNodes(std::vector<tree::Node*>& nodes, bool direction);
122 /// Updates the view of a level given the selected items of upper level
124 virtual void RecursiveUpdateLevel( int );
125 ///Sets the color of a selected item
126 void SetColor(int level, int item);
127 ///Creates the color palette for the first level
128 void CreateColorPalette();
129 ///Selects all the elements of a level
130 void SelectAll(int level);
131 ///UnSelects all the elements of a level
132 void UnSelectAll(int level);
134 void OnKeyDown(wxListEvent &event);
136 void SortLevel(int level);
138 /// Currently Selected Column
140 ///The last selected item on the list (left click)
143 ///The last selected item on the list (right click)
144 long mLastRightSelected;
146 ///The last selected level (by right click)
149 typedef std::map<tree::Node*,wxColour> ColorMap;
150 typedef std::pair<tree::Node*,wxColour> NodeColorPair;
152 ///Initial color palette
153 std::vector<std::string> mColorPalette;
157 wxObject* senderCtrl;
161 unsigned int mLastLevel;
168 // If set to true then OnSelectedChanged returns immediately.
169 // Used to do avoid useless process during multiple selections
171 bool mIgnoreSelectedChanged;
174 DECLARE_EVENT_TABLE()
176 // EO class WxTreeView
177 //=====================================================================
181 } // EO namespace creaImageIO
184 #endif // USE_WIDGETS