1 #include <creaImageIOWxAttributeSelectionPanel.h>
2 #include <creaImageIOSystem.h>
6 const int ID_COMBO = 180;
8 WxAttributeSelectionPanel::WxAttributeSelectionPanel(wxWindow *parent,
11 std::vector<std::string> sAtts,
12 std::vector<std::string> nsAtts,
15 -1, wxDefaultPosition,
29 GimmickDebugMessage(1,"WxCustomizeConfigPanel::WxCustomizeConfigPanel"
31 wxStaticText * aa=new wxStaticText(this,-1,_T(" Currently shown attributes for level: "), wxPoint(5,10));
33 std::stringstream out;
34 for(int i=1;i<=numLev;i++)
37 as.Add(crea::std2wx(out.str()));
40 levels=new wxComboBox(this, ID_COMBO,_T("1"),wxPoint(190, 5),wxDefaultSize,as);
41 wxStaticText * na=new wxStaticText(this,-1,_T(" Currently hidden attributes: "), wxPoint(255,10));
43 shownAtts=new wxListCtrl(this, wxID_ANY, wxPoint(5,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER );
45 shownAtts->InsertColumn(0,
48 shownAtts->SetColumnWidth(0,155);
51 wxButton *add = new wxButton(this,wxID_ANY,_T(">>"), wxPoint(170,50) );
52 Connect( add->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnAdd );
54 wxButton *remove = new wxButton(this,wxID_ANY,_T("<<"), wxPoint(170,70) );
55 Connect( remove->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnRemove );
57 notShownAtts=new wxListCtrl(this, wxID_ANY, wxPoint(255,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER );
59 notShownAtts->InsertColumn(0,
62 notShownAtts->SetColumnWidth(0,155);
66 wxButton *save = new wxButton(this,wxID_ANY,_T("Save Changes"), wxPoint(5,130) );
67 Connect( save->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnSaveConfig );
73 WxAttributeSelectionPanel::~WxAttributeSelectionPanel()
75 GimmickDebugMessage(1,"WxAttributeSelectionPanel::~WxAttributeSelectionPanel"
79 void WxAttributeSelectionPanel::OnSaveConfig(wxCommandEvent& event)
81 int n=levels->GetSelection();
83 mView->OnAttributesChanged(notShownA,n);
87 void WxAttributeSelectionPanel::OnAdd(wxCommandEvent& event)
92 item = shownAtts->GetNextItem(item,
94 wxLIST_STATE_SELECTED);
98 std::string change = crea::wx2std(shownAtts->GetItemText(item));
99 std::vector<std::string>::iterator it;
101 for(it=shownA.begin();it!=shownA.end()&&!found;++it)
103 if((*it).compare(change)==0)
109 notShownA.push_back(change);
115 void WxAttributeSelectionPanel::OnRemove(wxCommandEvent& event)
121 item = notShownAtts->GetNextItem(item,
123 wxLIST_STATE_SELECTED);
127 std::string change = crea::wx2std(notShownAtts->GetItemText(item));
128 std::vector<std::string>::iterator it;
130 for(it=notShownA.begin();it!=notShownA.end()&&!found;++it)
132 if((*it).compare(change)==0)
137 notShownA.erase(it-1);
138 shownA.push_back(change);
146 void WxAttributeSelectionPanel::LoadCtrls()
150 item.SetMask(wxLIST_MASK_STATE |
152 // wxLIST_MASK_IMAGE |
154 // wxLIST_MASK_WIDTH |
157 std::vector<std::string>::iterator it;
158 shownAtts->DeleteAllItems();
159 notShownAtts->DeleteAllItems();
160 for(it=shownA.begin();it!=shownA.end();++it)
162 item.SetText(crea::std2wx(*it));
163 shownAtts->InsertItem(item);
167 for(it=notShownA.begin();it!=notShownA.end();++it)
169 item.SetText(crea::std2wx(*it));
170 notShownAtts->InsertItem(item);
174 void WxAttributeSelectionPanel::OnComboChange(wxCommandEvent& event)
176 int n=levels->GetSelection()+1;
177 mView->GetVisibleAttributes(shownA,notShownA,n);
181 //======================================================================
182 BEGIN_EVENT_TABLE(WxAttributeSelectionPanel, wxPanel)
183 EVT_COMBOBOX (ID_COMBO,WxAttributeSelectionPanel::OnComboChange)
185 //======================================================================
187 } // EO namespace creaImageIO