1 #include <creaImageIOWxAttributeSelectionPanel.h>
2 #include <creaImageIOSystem.h>
7 const int ID_COMBO = 180;
9 WxAttributeSelectionPanel::WxAttributeSelectionPanel(wxWindow *parent,
12 std::vector<std::string> sAtts,
13 std::vector<std::string> nsAtts,
16 -1, wxDefaultPosition,
30 GimmickDebugMessage(1,"WxCustomizeConfigPanel::WxCustomizeConfigPanel"
32 wxStaticText * aa=new wxStaticText(this,-1,_T(" Currently shown attributes for level: "), wxPoint(5,10));
34 std::stringstream out;
35 for(int i=1;i<=numLev;i++)
38 as.Add(crea::std2wx(out.str()));
41 levels=new wxComboBox(this, ID_COMBO,_T("1"),wxPoint(190, 5),wxDefaultSize,as);
42 wxStaticText * na=new wxStaticText(this,-1,_T(" Currently hidden attributes: "), wxPoint(255,10));
44 shownAtts=new wxListCtrl(this, wxID_ANY, wxPoint(5,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER );
46 shownAtts->InsertColumn(0,
49 shownAtts->SetColumnWidth(0,155);
52 wxButton *add = new wxButton(this,wxID_ANY,_T(">>"), wxPoint(170,50) );
53 Connect( add->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnAdd );
55 wxButton *remove = new wxButton(this,wxID_ANY,_T("<<"), wxPoint(170,70) );
56 Connect( remove->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnRemove );
58 notShownAtts=new wxListCtrl(this, wxID_ANY, wxPoint(255,30), wxSize(160,90), wxLC_REPORT | wxLC_NO_HEADER );
60 notShownAtts->InsertColumn(0,
63 notShownAtts->SetColumnWidth(0,155);
67 wxButton *save = new wxButton(this,wxID_ANY,_T("Save Changes"), wxPoint(5,130) );
68 Connect( save->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAttributeSelectionPanel::OnSaveConfig );
74 WxAttributeSelectionPanel::~WxAttributeSelectionPanel()
76 GimmickDebugMessage(1,"WxAttributeSelectionPanel::~WxAttributeSelectionPanel"
80 void WxAttributeSelectionPanel::OnSaveConfig(wxCommandEvent& event)
82 int n=levels->GetSelection();
84 mView->OnAttributesChanged(notShownA,n);
88 void WxAttributeSelectionPanel::OnAdd(wxCommandEvent& event)
93 item = shownAtts->GetNextItem(item,
95 wxLIST_STATE_SELECTED);
99 std::string change = crea::wx2std(shownAtts->GetItemText(item));
100 std::vector<std::string>::iterator it;
102 for(it=shownA.begin();it!=shownA.end()&&!found;++it)
104 if((*it).compare(change)==0)
110 notShownA.push_back(change);
116 void WxAttributeSelectionPanel::OnRemove(wxCommandEvent& event)
122 item = notShownAtts->GetNextItem(item,
124 wxLIST_STATE_SELECTED);
128 std::string change = crea::wx2std(notShownAtts->GetItemText(item));
129 std::vector<std::string>::iterator it;
131 for(it=notShownA.begin();it!=notShownA.end()&&!found;++it)
133 if((*it).compare(change)==0)
138 notShownA.erase(it-1);
139 shownA.push_back(change);
147 void WxAttributeSelectionPanel::LoadCtrls()
151 item.SetMask(wxLIST_MASK_STATE |
153 // wxLIST_MASK_IMAGE |
155 // wxLIST_MASK_WIDTH |
158 std::vector<std::string>::iterator it;
159 shownAtts->DeleteAllItems();
160 notShownAtts->DeleteAllItems();
161 for(it=shownA.begin();it!=shownA.end();++it)
163 item.SetText(crea::std2wx(*it));
164 shownAtts->InsertItem(item);
168 for(it=notShownA.begin();it!=notShownA.end();++it)
170 item.SetText(crea::std2wx(*it));
171 notShownAtts->InsertItem(item);
175 void WxAttributeSelectionPanel::OnComboChange(wxCommandEvent& event)
177 int n=levels->GetSelection()+1;
178 mView->GetVisibleAttributes(shownA,notShownA,n);
182 //======================================================================
183 BEGIN_EVENT_TABLE(WxAttributeSelectionPanel, wxPanel)
184 EVT_COMBOBOX (ID_COMBO,WxAttributeSelectionPanel::OnComboChange)
186 //======================================================================
188 } // EO namespace creaImageIO