creaImageIOWxTreeView.h

Go to the documentation of this file.
00001 #ifndef __creaImageIOWxTreeView_h_INCLUDED__
00002 #define __creaImageIOWxTreeView_h_INCLUDED__
00003 
00004 #ifdef USE_WXWIDGETS
00005 
00006 #include <creaImageIOTreeView.h>
00007 #include <creaWx.h>
00008 
00009 #include <wx/listctrl.h>
00010 #include <wx/splitter.h>
00011 //#include <vector>
00012 const std::string empty_string("");
00013 namespace creaImageIO
00014 {
00015 
00016           //=====================================================================
00018   struct ItemData
00019   {
00020     ItemData() : node(0), id(-1), attr(&empty_string) {}
00021     // The corresponding Node
00022     tree::Node* node;
00023     // The id ?
00024     int id;
00025     // The pointer on the current attribute string to sort on
00026     const std::string* attr;
00027     // Was the item previously selected ?
00028     // Useful for reselecting the item after sort
00029     bool selected;
00030   };
00034   //=====================================================================
00035   
00036   //=====================================================================
00038   class WxTreeView : public wxPanel, virtual public TreeView
00039     {
00040     public:
00042       WxTreeView(TreeHandler*, GimmickView*, 
00043                  wxWindow* parent, const wxWindowID id);
00045       virtual ~WxTreeView();
00046 
00047       
00049       virtual void UpdateLevel( int );
00050 
00052           virtual void RemoveSelected(std::string &i_save);
00053 
00055           virtual unsigned int GetLastSelectedLevel(){return mLastLevel;}
00056 
00058       void OnItemSelected(wxListEvent& event);
00059 
00061       void OnItemDeSelected(wxListEvent& event);
00062       
00064       void OnColClick(wxListEvent& event);
00065       
00067       void OnPopupSort(wxCommandEvent& event);
00068       
00070       void OnPopupFilter(wxCommandEvent& event);
00071 
00073       void OnLocalCopy(wxCommandEvent& event);
00074 
00075 
00077       void OnAnonymizer(wxCommandEvent& event);
00078 
00079 
00081       void OnEditField(wxCommandEvent& event);
00082 
00084           void OnDumpTags(wxCommandEvent &event);
00085       
00087           void OnExportToStorage(wxCommandEvent &event);
00088       
00090       void OnMouseClick(wxMouseEvent& event);
00091 
00093           void OnItemMenu(wxListEvent &event);
00094           
00096           void GetAttributes(std::vector<std::string>& areShown, std::vector<std::string>& notShown, int level);
00097 
00099           void SetNonVisibleAttributes(const std::vector<std::string>& notShown, int level);
00100 
00102           void CreateCtrl(std::vector<std::string>& notShown, int nlevel);
00103   
00105           bool IsAttributeVisible(const std::string& val, int level);
00106       
00109       //      void ProcessItem
00110     private:
00111                 wxBoxSizer      *msizer;
00115       struct LevelType
00116       {
00117         // The List Control
00118         wxListCtrl* wxCtrl;
00119         wxSplitterWindow* wxSplitter;
00120         std::vector<std::string> key;
00121         // The vector of currently selected nodes of the level
00122         std::vector<tree::Node*> Selected;
00123         // True iff the vector Selected is up to date
00124         bool SelectedUpToDate;
00125         // The column used for sorting
00126         unsigned int SortColumn;
00129         bool SortAscending;
00130         //The vector of not shown attributes
00131         std::vector<std::string> notShownAtts; 
00132       };
00134       std::vector<LevelType> mLevelList;
00135       
00137       wxListCtrl* GetCtrl(int l) { return mLevelList[l].wxCtrl; }
00139       wxSplitterWindow* GetSplitter(int l) { return mLevelList[l].wxSplitter; }
00140       //Returns the maximum number of levels
00141       int GetNumberOfLevels(){ return mLevelList.size(); }
00144       const std::vector<tree::Node*>& GetSelected(int level);
00146       void SetSelectedUpToDate(int l, bool v) { mLevelList[l].SelectedUpToDate = v; }
00148       bool GetSelectedUpToDate(int l) { return mLevelList[l].SelectedUpToDate; }
00150       void ValidateSelectedImages(bool isSelection);   
00152       void GetSelectedAsString(std::vector<std::string>&s);
00154           void GetFilenamesAsString(const std::vector<tree::Node*>& nodes, std::vector<std::string>&s);
00156       void GetNodes(std::vector<tree::Node*>& nodes, bool direction);
00159       virtual void RecursiveUpdateLevel( int );
00161       void SelectAll(int level);
00163       void UnSelectAll(int level);
00164 
00165           void OnKeyDown(wxListEvent &event);
00167       void SortLevel(int level);
00168       
00170       int mColumnSelected;
00172       long mLastSelected;
00173 
00175           long mLastRightSelected;
00176 
00178           int mLastRightLevel;
00180       typedef std::map<tree::Node*,wxColour> ColorMap;
00181       typedef std::pair<tree::Node*,wxColour> NodeColorPair;
00182       ColorMap mColorMap;
00184       std::vector<std::string> mColorPalette;
00185 
00186       wxMenu* menu;
00187           
00188       wxObject* senderCtrl;
00189       int mAscendingID;
00190       int mDescendingID;
00191       int mFilterID;
00192       unsigned int mLastLevel;
00193       
00194           wxMenu* menuItem;
00195           wxMenu *subExportMenu;
00196           int mAnonymizingID;
00197           int mLocalCopyID;
00198           int mEditFieldID;
00199           int mDumpID;
00200           int mExportID;
00201           int mExport2StorageID;
00202           
00203       // If set to true then OnSelectedChanged returns immediately.
00204       // Used to do avoid useless process during multiple selections 
00205       // or sorting
00206       bool mIgnoreSelectedChanged;
00207 
00208       DECLARE_EVENT_TABLE()
00209     };
00210     // EO class WxTreeView
00211     //=====================================================================
00212 
00213         class RemoveAlertDlg : public wxDialog
00214         {
00215         public:
00216                 RemoveAlertDlg(wxWindow *parent, 
00217                                                wxString title,    
00218                                                    const wxSize& size);
00219                 ~RemoveAlertDlg();
00220 
00221                 bool isChecked();
00222 
00223         private :
00224                 void onCheck(wxCommandEvent &Event);
00225                 bool mSave;
00226                 wxCheckBox *mcheck;
00227 
00228         };
00229 
00230 
00231 } // EO namespace creaImageIO
00232 
00233 
00234 #endif // USE_WIDGETS
00235 // EOF
00236 #endif