00001 00011 #ifndef __TOOLLIST__H__ 00012 #define __TOOLLIST__H__ 00013 00014 #include <wx/wx.h> 00015 #include <wx/dnd.h> 00016 #include <wx/imaglist.h> 00017 00018 #include <vector> 00019 00020 #include "../common.h" 00021 #include "../configs/ConfigProcessor.h" 00022 #include "../objects/Object.h" 00023 #include "Canvas.h" 00024 00025 // A part of the GUI 00026 namespace GUI { 00027 00033 class ToolList : public wxListCtrl { 00034 public: 00044 ToolList(wxWindow * parent, const wxWindowID id, const wxPoint& pos, 00045 const wxSize& size, long style, string pdp); 00046 00050 ~ToolList(); 00051 00056 bool IndexInVector(int i) { 00057 #if DEBUG_PALETTE 00058 cerr << "DEBUG_PALETTE: ToolList::IndexInVector" << endl; 00059 #endif 00060 00061 if (i >= 0 && i < static_cast<int>(paletteVector.size())) { 00062 return true; 00063 } 00064 else { 00065 return false; 00066 } 00067 } 00068 00073 void SetCanvas(Canvas * c) { 00074 #if DEBUG_PALETTE 00075 cerr << "DEBUG_PALETTE: ToolList::SetCanvas" << endl; 00076 #endif 00077 00078 canvas = c; 00079 } 00080 00084 void SetCanvasNULL() { 00085 #if DEBUG_PALETTE 00086 cerr << "DEBUG_PALETTE: ToolList::SetCanvasNULL" << endl; 00087 #endif 00088 00089 canvas = 0; 00090 } 00091 00096 void PaletteVectorPushBack(Object::Config * config) { 00097 #if DEBUG_PALETTE 00098 cerr << "DEBUG_PALETTE: ToolList::PaletteVectorPushBack" << endl; 00099 #endif 00100 00101 if (config != 0) { 00102 paletteVector.push_back(config); 00103 } 00104 } 00105 00110 void UploadOneObjectConfig(string path); 00111 00117 void DownloadOneObjectConfig(string path, Object::Config * config); 00118 00123 void UploadPaletteVectorFromDirectory(string directory); 00124 00129 void DownloadPaletteVectorIntoDirectory(string directory); 00130 00134 void CreateToolListFromVector(); 00135 00140 string ObjectName2FileName(const string & objectName) const; 00141 00142 private: 00143 // Event handlers 00144 void OnRightClick(wxMouseEvent& event); 00145 void OnSelected(wxListEvent& event); 00146 void OnEraseSelectedRight(wxCommandEvent & event); 00147 void OnSaveSelectedRight(wxCommandEvent & event); 00148 void OnEditSelectedRight(wxCommandEvent & event); 00149 00150 DECLARE_EVENT_TABLE() 00151 00152 00153 wxImageList toolListImages; 00155 string paletteDirectoryPath; 00157 typedef std::vector<Object::Config *> TObjectConfigVector; 00159 TObjectConfigVector paletteVector; 00161 int currentItemIndex; 00163 int editedItemIndex; 00165 Canvas * canvas; 00167 static const int PALETTEIMAGESIZE = 32; 00168 }; 00169 00170 } /* namespace GUI */ 00171 00172 #endif /* #ifndef __TOOLLIST__H__ */ 00173 00174 /* End of file ToolList.h */