1 #include <creaImageIOWxAttributeSelectionPanel.h>
2 #include <creaImageIOSystem.h>
4 #include <creaImageIOGimmick.h>
10 const int ID_COMBO = 180;
12 WxAttributeSelectionPanel::WxAttributeSelectionPanel(wxWindow *parent,
15 std::vector<std::string> sAtts,
16 std::vector<std::string> nsAtts,
19 -1, wxDefaultPosition,
33 GimmickDebugMessage(1,"WxCustomizeConfigPanel::WxCustomizeConfigPanel"
35 /// \TODO fix warning: unused variable aa
36 wxStaticText * aa = new wxStaticText(this,-1,_T(" Currently shown attributes for level: "), wxPoint(5,10));
38 std::stringstream out;
39 for(int i=1;i<=numLev;i++)
42 as.Add(crea::std2wx(out.str()));
45 levels=new wxComboBox(this, ID_COMBO,_T("1"),wxPoint(190, 5),wxDefaultSize,as);
46 /// \TODO fix warning: unused variable na
47 wxStaticText * na=new wxStaticText(this,-1,_T(" Currently hidden attributes: "), wxPoint(255,10));
49 shownAtts=new wxListCtrl(this, wxID_ANY, wxPoint(5,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER );
51 shownAtts->InsertColumn(0,
54 shownAtts->SetColumnWidth(0,155);
57 wxButton *add = new wxButton(this,wxID_ANY,_T(">>"), wxPoint(170,50) );
58 Connect( add->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnAdd );
60 wxButton *remove = new wxButton(this,wxID_ANY,_T("<<"), wxPoint(170,70) );
61 Connect( remove->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnRemove );
63 notShownAtts=new wxListCtrl(this, wxID_ANY, wxPoint(255,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER );
65 notShownAtts->InsertColumn(0,
68 notShownAtts->SetColumnWidth(0,155);
72 wxButton *save = new wxButton(this,wxID_ANY,_T("Save Changes"), wxPoint(5,130) );
73 Connect( save->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnSaveConfig );
79 WxAttributeSelectionPanel::~WxAttributeSelectionPanel()
81 GimmickDebugMessage(1,"WxAttributeSelectionPanel::~WxAttributeSelectionPanel"
85 void WxAttributeSelectionPanel::OnSaveConfig(wxCommandEvent& event)
87 int n=levels->GetSelection();
89 mView->OnAttributesChanged(notShownA,n);
93 void WxAttributeSelectionPanel::OnAdd(wxCommandEvent& event)
98 item = shownAtts->GetNextItem(item,
100 wxLIST_STATE_SELECTED);
104 std::string change = crea::wx2std(shownAtts->GetItemText(item));
105 std::vector<std::string>::iterator it;
107 for(it=shownA.begin();it!=shownA.end()&&!found;++it)
109 if((*it).compare(change)==0)
115 notShownA.push_back(change);
121 void WxAttributeSelectionPanel::OnRemove(wxCommandEvent& event)
127 item = notShownAtts->GetNextItem(item,
129 wxLIST_STATE_SELECTED);
133 std::string change = crea::wx2std(notShownAtts->GetItemText(item));
134 std::vector<std::string>::iterator it;
136 for(it=notShownA.begin();it!=notShownA.end()&&!found;++it)
138 if((*it).compare(change)==0)
143 notShownA.erase(it-1);
144 shownA.push_back(change);
152 void WxAttributeSelectionPanel::LoadCtrls()
156 item.SetMask(wxLIST_MASK_STATE |
158 // wxLIST_MASK_IMAGE |
160 // wxLIST_MASK_WIDTH |
163 std::vector<std::string>::iterator it;
164 shownAtts->DeleteAllItems();
165 notShownAtts->DeleteAllItems();
166 for(it=shownA.begin();it!=shownA.end();++it)
168 item.SetText(crea::std2wx(*it));
169 shownAtts->InsertItem(item);
173 for(it=notShownA.begin();it!=notShownA.end();++it)
175 item.SetText(crea::std2wx(*it));
176 notShownAtts->InsertItem(item);
180 void WxAttributeSelectionPanel::OnComboChange(wxCommandEvent& event)
182 int n=levels->GetSelection()+1;
183 mView->GetVisibleAttributes(shownA,notShownA,n);
187 //======================================================================
188 BEGIN_EVENT_TABLE(WxAttributeSelectionPanel, wxPanel)
189 EVT_COMBOBOX (ID_COMBO,WxAttributeSelectionPanel::OnComboChange)
191 //======================================================================
193 } // EO namespace creaImageIO