creaImageIOWxCustomizeConfigPanel
creaImageIOWxListenerPanel
creaImageIOWxEditFieldsPanel
+ creaImageIOWxAttributeSelectionPanel
#
BlockScopeWxApp
/// Gets the next nodes on the list, be it up(true) or down(false).
virtual void GetNodes(std::vector<tree::Node*>& nodes, bool direction){ GimmickError("INTERNAL ERROR : TreeView::GetNodes not overloaded"); }
+ /// Gets the attributes that are being shown and the ones that have been blocked on a specific level
+ virtual void GetAttributes(std::vector<std::string>& areShown, std::vector<std::string>& notShown, int level){ GimmickError("INTERNAL ERROR : TreeView::GetAttributes not overloaded"); }
+
protected:
TreeHandler* GetTreeHandler() { return mTreeHandler; }
GimmickView* GetGimmickView() { return mGimmickView; }
--- /dev/null
+#include <creaImageIOWxAttributeSelectionPanel.h>
+#include <creaImageIOSystem.h>
+
+namespace creaImageIO
+{
+ const int ID_COMBO = 180;
+ // CTor
+ WxAttributeSelectionPanel::WxAttributeSelectionPanel(wxWindow *parent,
+ wxDialog* dial,
+ WxGimmickView* view,
+ std::vector<std::string> sAtts,
+ std::vector<std::string> nsAtts,
+ int numLev)
+ : wxPanel( parent,
+ -1, wxDefaultPosition,
+ wxDefaultSize,
+ wxRESIZE_BORDER |
+ wxSYSTEM_MENU |
+ wxCLOSE_BOX |
+ wxMAXIMIZE_BOX |
+ wxMINIMIZE_BOX |
+ wxCAPTION
+ ),
+ dialog(dial),
+ shownA(sAtts),
+ notShownA(nsAtts),
+ mView(view)
+ {
+ GimmickDebugMessage(1,"WxCustomizeConfigPanel::WxCustomizeConfigPanel"
+ <<std::endl);
+ wxStaticText * aa=new wxStaticText(this,-1,_T(" Currently shown attributes for level: "), wxPoint(5,10));
+ wxArrayString as;
+ std::stringstream out;
+ for(int i=1;i<=numLev;i++)
+ {
+ out<<i;
+ as.Add(out.str());
+ out.str("");
+ }
+ levels=new wxComboBox(this, ID_COMBO,"1",wxPoint(190, 5),wxDefaultSize,as);
+ wxStaticText * na=new wxStaticText(this,-1,_T(" Currently hidden attributes: "), wxPoint(255,10));
+
+ shownAtts=new wxListCtrl(this, wxID_ANY, wxPoint(5,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL );
+
+ shownAtts->InsertColumn(0,
+ crea::std2wx(""),
+ wxLIST_FORMAT_LEFT);
+ shownAtts->SetColumnWidth(0,155);
+ shownAtts->Show();
+
+ wxButton *add = new wxButton(this,wxID_ANY,_T(">>"), wxPoint(170,50) );
+ Connect( add->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnAdd );
+
+ wxButton *remove = new wxButton(this,wxID_ANY,_T("<<"), wxPoint(170,70) );
+ Connect( remove->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnRemove );
+
+ notShownAtts=new wxListCtrl(this, wxID_ANY, wxPoint(255,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL );
+
+ notShownAtts->InsertColumn(0,
+ crea::std2wx(""),
+ wxLIST_FORMAT_LEFT);
+ notShownAtts->SetColumnWidth(0,155);
+ notShownAtts->Show();
+ LoadCtrls();
+
+ wxButton *save = new wxButton(this,wxID_ANY,_T("Save Changes"), wxPoint(5,130) );
+ Connect( save->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnSaveConfig );
+
+ Layout();
+ }
+
+ /// Destructor
+ WxAttributeSelectionPanel::~WxAttributeSelectionPanel()
+ {
+ GimmickDebugMessage(1,"WxAttributeSelectionPanel::~WxAttributeSelectionPanel"
+ <<std::endl);
+ }
+
+ void WxAttributeSelectionPanel::OnSaveConfig(wxCommandEvent& event)
+ {
+ /*mView->OnSaveSettingsCallback(crea::wx2std(copyPath->GetValue()),
+ crea::wx2std(dbPath->GetValue()),
+ crea::wx2std(syncEvent->GetValue()),
+ crea::wx2std(syncFrequency->GetValue()));
+ */
+ dialog->Destroy();
+ }
+
+ void WxAttributeSelectionPanel::OnAdd(wxCommandEvent& event)
+ {
+ long item = -1;
+ for ( ;; )
+ {
+ item = shownAtts->GetNextItem(item,
+ wxLIST_NEXT_ALL,
+ wxLIST_STATE_SELECTED);
+ if ( item == -1 )
+ break;
+
+ std::string change=shownAtts->GetItemText(item);
+ std::vector<std::string>::iterator it;
+ bool found=false;
+ for(it=shownA.begin();it!=shownA.end()&&!found;++it)
+ {
+ if((*it).compare(change)==0)
+ {
+ found=true;
+ }
+ }
+ shownA.erase(it-1);
+ notShownA.push_back(change);
+ LoadCtrls();
+
+ }
+
+ }
+
+ void WxAttributeSelectionPanel::OnRemove(wxCommandEvent& event)
+ {
+
+ long item = -1;
+ for ( ;; )
+ {
+ item = notShownAtts->GetNextItem(item,
+ wxLIST_NEXT_ALL,
+ wxLIST_STATE_SELECTED);
+ if ( item == -1 )
+ break;
+
+ std::string change=notShownAtts->GetItemText(item);
+ std::vector<std::string>::iterator it;
+ bool found=false;
+ for(it=notShownA.begin();it!=notShownA.end()&&!found;++it)
+ {
+ if((*it).compare(change)==0)
+ {
+ found=true;
+ }
+ }
+ notShownA.erase(it-1);
+ shownA.push_back(change);
+ LoadCtrls();
+
+ }
+
+ }
+
+
+ void WxAttributeSelectionPanel::LoadCtrls()
+ {
+
+ wxListItem item;
+ item.SetMask(wxLIST_MASK_STATE |
+ wxLIST_MASK_TEXT |
+ // wxLIST_MASK_IMAGE |
+ wxLIST_MASK_DATA |
+ // wxLIST_MASK_WIDTH |
+ wxLIST_MASK_FORMAT
+ );
+ std::vector<std::string>::iterator it;
+ shownAtts->DeleteAllItems();
+ notShownAtts->DeleteAllItems();
+ for(it=shownA.begin();it!=shownA.end();++it)
+ {
+ item.SetText(crea::std2wx(*it));
+ shownAtts->InsertItem(item);
+ }
+
+
+ for(it=notShownA.begin();it!=notShownA.end();++it)
+ {
+ item.SetText(crea::std2wx(*it));
+ notShownAtts->InsertItem(item);
+ }
+
+ }
+ void WxAttributeSelectionPanel::OnComboChange(wxCommandEvent& event)
+ {
+ int n=levels->GetSelection()+1;
+ mView->GetVisibleAttributes(shownA,notShownA,n);
+ LoadCtrls();
+ }
+
+//======================================================================
+BEGIN_EVENT_TABLE(WxAttributeSelectionPanel, wxPanel)
+EVT_COMBOBOX (ID_COMBO,WxAttributeSelectionPanel::OnComboChange)
+END_EVENT_TABLE()
+//======================================================================
+
+} // EO namespace creaImageIO
+
+
--- /dev/null
+#ifndef __creaImageIOWxAttributeSelectionPanel_h_INCLUDED__
+#define __creaImageIOWxAttributeSelectionPanel_h_INCLUDED__
+
+#ifdef USE_WXWIDGETS
+#include <creaWx.h>
+#include <creaImageIOWxGimmickView.h>
+#include <wx/listctrl.h>
+
+
+namespace creaImageIO
+{
+ /**
+ * \ingroup GUI
+ */
+ //=====================================================================
+ //=====================================================================
+ class WxAttributeSelectionPanel : public wxPanel
+ {
+ public:
+ WxAttributeSelectionPanel();
+ WxAttributeSelectionPanel(wxWindow *parent,
+ wxDialog* dial,
+ WxGimmickView* view,
+ std::vector<std::string> sAtts,
+ std::vector<std::string> nsAtts,
+ int numLev);
+
+ ~WxAttributeSelectionPanel();
+ ///Saves the configuration
+ void OnSaveConfig(wxCommandEvent& event);
+ ///Changes items from shown to notShown
+ void OnAdd(wxCommandEvent& event);
+ ///Changes items from notShown to shown
+ void OnRemove(wxCommandEvent& event);
+ void OnComboChange(wxCommandEvent& event);
+
+
+ private :
+ ///Loads the information on the vectors onto the lists
+ void LoadCtrls();
+ std::vector<std::string> shownA;
+ std::vector<std::string> notShownA;
+ wxComboBox* levels;
+ wxListCtrl* shownAtts;
+ wxListCtrl* notShownAtts;
+ wxDialog* dialog;
+ WxGimmickView* mView;
+
+
+ DECLARE_EVENT_TABLE()
+
+ }; // class WxAttributeSelectionPanel
+ //=====================================================================
+
+
+} // EO namespace creaImageIO
+
+
+#endif // USE_WIDGETS
+// EOF
+#endif
\ No newline at end of file
#include <creaImageIOWxCustomizeConfigPanel.h>
#include <creaImageIOWxListenerPanel.h>
#include <creaImageIOWxEditFieldsPanel.h>
+#include <creaImageIOWxAttributeSelectionPanel.h>
using namespace crea;
// Icons
WxListenerPanel* cdWatch=new WxListenerPanel(nb,dial, this, mListener->IsPaused());
nb->AddPage( cdWatch, crea::std2wx("CD/DVD") );
- //Fourth page: Selection of attributes to show (edit)
- wxPanel* attSelection=new wxPanel(nb);
+ //Fourth page: Selection of attributes to show
+ std::vector<std::string> shown;
+ std::vector<std::string> nShown;
+ GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetAttributes(shown,nShown,1);
+ int nLev=GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetNumberOfLevels();
+ WxAttributeSelectionPanel* attSelection=new WxAttributeSelectionPanel(nb,dial,this,shown,nShown,nLev);
nb->AddPage( attSelection, crea::std2wx("Selection of Attributes") );
}
+ //===================================================================
+ void WxGimmickView::GetVisibleAttributes(std::vector<std::string>& shown,
+ std::vector<std::string>& nShown, int level)
+ {
+ GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))]->GetAttributes(shown,nShown,level);
+ }
//===================================================================
void WxGimmickView::OnSaveSettingsCallback(const std::string& copyPath,
const std::string& dbPath,
/// AddProgress Gimmick callback
void WxGimmickView::OnAddProgress( Gimmick::AddProgress& p)
{
-
char mess[200];
-
sprintf(mess,"%i dirs : %i files :\n %i handled - %i added",
p.GetNumberScannedDirs(),
p.GetNumberScannedFiles(),
///Called upon when a field has been edited
void OnFieldsEdited(tree::Node* node, const std::string& name, const std::string& key, const std::string& val);
+
+ ///Called upon to return the visible attributes of the current tab
+ void GetVisibleAttributes(std::vector<std::string>& shown,std::vector<std::string>& nShown, int level);
+
}
+
+ //================================================================
+ void WxTreeView::GetAttributes(std::vector<std::string>& areShown, std::vector<std::string>& notShown, int level)
+ {
+ areShown.clear();
+ notShown.clear();
+ tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
+ for (a = GetTreeHandler()->GetTree().GetAttributeDescriptorList(level).begin();
+ a != GetTreeHandler()->GetTree().GetAttributeDescriptorList(level).end();
+ ++a)
+ {
+ if(a->GetFlags()==creaImageIO::tree::AttributeDescriptor::EDITABLE)
+ {
+ areShown.push_back(a->GetName());
+ }
+ }
+ notShown=mLevelList[level-1].notShownAtts;
+ }
+ //================================================================
//================================================================
BEGIN_EVENT_TABLE(WxTreeView, wxPanel)
/*
///Callback on mouse click
void OnMouseClick(wxMouseEvent& event);
- // Display a menu for items
+ /// Displays a menu for items
void OnItemMenu(wxListEvent &event);
+
+ /// Gets the attributes that are being shown and the ones that have been blocked on a specific level
+ void GetAttributes(std::vector<std::string>& areShown, std::vector<std::string>& notShown, int level);
/// Actual processing of item selection/deselection
/// Called by OnItemSelected and OnItemDeSelected
wxListCtrl* wxCtrl;
wxSplitterWindow* wxSplitter;
std::vector<std::string> key;
+ //The vector of not shown attributes
+ std::vector<std::string> notShownAtts;
// The vector of currently selected nodes of the level
std::vector<tree::Node*> Selected;
// True iff the vector Selected is up to date
void ValidateSelectedImages(bool isSelection);
///Gets selected filenames
void GetSelectedAsString(std::vector<std::string>&s);
- ///Gets the filenames of the given nodes and returns them on the given vector. Is recursive.
+ ///Gets the filenames of the given nodes and returns them on the given vector. Is recursive.
void GetFilenamesAsString(const std::vector<tree::Node*>& nodes, std::vector<std::string>&s);
- /// Gets the next nodes on the list, be it up(true) or down(false).
+ /// Gets the next nodes on the list, be it up(true) or down(false).
void GetNodes(std::vector<tree::Node*>& nodes, bool direction);
/// Updates the view of a level given the selected items of upper level
/// Recursive method