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 wxStaticText * aa=new wxStaticText(this,-1,_T(" Currently shown attributes for level: "), wxPoint(5,10));
37 std::stringstream out;
38 for(int i=1;i<=numLev;i++)
41 as.Add(crea::std2wx(out.str()));
44 levels=new wxComboBox(this, ID_COMBO,_T("1"),wxPoint(190, 5),wxDefaultSize,as);
45 wxStaticText * na=new wxStaticText(this,-1,_T(" Currently hidden attributes: "), wxPoint(255,10));
47 shownAtts=new wxListCtrl(this, wxID_ANY, wxPoint(5,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER );
49 shownAtts->InsertColumn(0,
52 shownAtts->SetColumnWidth(0,155);
55 wxButton *add = new wxButton(this,wxID_ANY,_T(">>"), wxPoint(170,50) );
56 Connect( add->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnAdd );
58 wxButton *remove = new wxButton(this,wxID_ANY,_T("<<"), wxPoint(170,70) );
59 Connect( remove->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnRemove );
61 notShownAtts=new wxListCtrl(this, wxID_ANY, wxPoint(255,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER );
63 notShownAtts->InsertColumn(0,
66 notShownAtts->SetColumnWidth(0,155);
70 wxButton *save = new wxButton(this,wxID_ANY,_T("Save Changes"), wxPoint(5,130) );
71 Connect( save->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnSaveConfig );
77 WxAttributeSelectionPanel::~WxAttributeSelectionPanel()
79 GimmickDebugMessage(1,"WxAttributeSelectionPanel::~WxAttributeSelectionPanel"
83 void WxAttributeSelectionPanel::OnSaveConfig(wxCommandEvent& event)
85 int n=levels->GetSelection();
87 mView->OnAttributesChanged(notShownA,n);
91 void WxAttributeSelectionPanel::OnAdd(wxCommandEvent& event)
96 item = shownAtts->GetNextItem(item,
98 wxLIST_STATE_SELECTED);
102 std::string change = crea::wx2std(shownAtts->GetItemText(item));
103 std::vector<std::string>::iterator it;
105 for(it=shownA.begin();it!=shownA.end()&&!found;++it)
107 if((*it).compare(change)==0)
113 notShownA.push_back(change);
119 void WxAttributeSelectionPanel::OnRemove(wxCommandEvent& event)
125 item = notShownAtts->GetNextItem(item,
127 wxLIST_STATE_SELECTED);
131 std::string change = crea::wx2std(notShownAtts->GetItemText(item));
132 std::vector<std::string>::iterator it;
134 for(it=notShownA.begin();it!=notShownA.end()&&!found;++it)
136 if((*it).compare(change)==0)
141 notShownA.erase(it-1);
142 shownA.push_back(change);
150 void WxAttributeSelectionPanel::LoadCtrls()
154 item.SetMask(wxLIST_MASK_STATE |
156 // wxLIST_MASK_IMAGE |
158 // wxLIST_MASK_WIDTH |
161 std::vector<std::string>::iterator it;
162 shownAtts->DeleteAllItems();
163 notShownAtts->DeleteAllItems();
164 for(it=shownA.begin();it!=shownA.end();++it)
166 item.SetText(crea::std2wx(*it));
167 shownAtts->InsertItem(item);
171 for(it=notShownA.begin();it!=notShownA.end();++it)
173 item.SetText(crea::std2wx(*it));
174 notShownAtts->InsertItem(item);
178 void WxAttributeSelectionPanel::OnComboChange(wxCommandEvent& event)
180 int n=levels->GetSelection()+1;
181 mView->GetVisibleAttributes(shownA,notShownA,n);
185 //======================================================================
186 BEGIN_EVENT_TABLE(WxAttributeSelectionPanel, wxPanel)
187 EVT_COMBOBOX (ID_COMBO,WxAttributeSelectionPanel::OnComboChange)
189 //======================================================================
191 } // EO namespace creaImageIO