00001 #include <creaImageIOWxEditFieldsPanel.h>
00002 #include <creaImageIOSystem.h>
00003 #include <wx/arrstr.h>
00004
00005
00006 namespace creaImageIO
00007 {
00008 const int ID_COMBO = 140;
00009
00010 WxEditFieldsPanel::WxEditFieldsPanel(wxWindow *parent, wxDialog* dial, WxGimmickView* view, tree::Node* nod,
00011 const std::vector<std::string> name,
00012 const std::vector<std::string> key)
00013 : wxPanel( parent,
00014 -1, wxDefaultPosition,
00015 wxDefaultSize,
00016 wxRESIZE_BORDER |
00017 wxSYSTEM_MENU |
00018 wxCLOSE_BOX |
00019 wxMAXIMIZE_BOX |
00020 wxMINIMIZE_BOX |
00021 wxCAPTION
00022 ),
00023 dialog(dial),
00024 node (nod),
00025 names(name),
00026 keys(key),
00027 mView(view)
00028 {
00029 GimmickDebugMessage(1,"WxCustomizeConfigPanel::WxCustomizeConfigPanel"
00030 <<std::endl);
00031 wxStaticText * cp=new wxStaticText(this,-1,_T(" Attribute to change: "), wxPoint(5,10));
00032 wxArrayString as;
00033 std::vector<std::string>::const_iterator it;
00034 for(it=names.begin();it!=names.end();++it)
00035 {
00036 as.Add(crea::std2wx(*it));
00037 }
00038 attributes=new wxComboBox(this, ID_COMBO, crea::std2wx(names.front()), wxPoint(110, 10), wxDefaultSize,as);
00039 std::string val=node->GetAttribute(keys[0]);
00040 if(val.compare("")==0){val="?";}
00041
00042 wxStaticText * av=new wxStaticText(this,-1,_T(" Current Value: "), wxPoint(5,40));
00043 actualVal=new wxStaticText(this,-1,crea::std2wx(val), wxPoint(110,40));
00044
00045 wxStaticText * nv=new wxStaticText(this,-1,_T(" New Value: "), wxPoint(5,70));
00046 newVal=new wxTextCtrl(this, wxID_ANY, crea::std2wx(val), wxPoint(110,70), wxSize(220,20));
00047
00048 wxButton *save = new wxButton(this,wxID_ANY,_T("Save Changes"), wxPoint(5,100) );
00049 Connect( save->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxEditFieldsPanel::OnEdit );
00050
00051 Layout();
00052 }
00053
00055 WxEditFieldsPanel::~WxEditFieldsPanel()
00056 {
00057 GimmickDebugMessage(1,"WxEditFieldsPanel::~WxEditFieldsPanel"
00058 <<std::endl);
00059 }
00060
00061 void WxEditFieldsPanel::OnEdit(wxCommandEvent& event)
00062 {
00063 std::string val=crea::wx2std(newVal->GetValue());
00064 int sel=attributes->GetSelection();
00065 if(sel==-1)
00066 {
00067 sel=0;
00068 }
00069 mView->OnFieldsEdited(node,names[sel],keys[sel],val);
00070 dialog->Destroy();
00071 }
00072
00073 void WxEditFieldsPanel::OnComboChange(wxCommandEvent& event)
00074 {
00075 std::string val=node->GetAttribute(keys[attributes->GetSelection()]);
00076 if(val.compare("")==0){val="?";}
00077 actualVal->SetLabel(crea::std2wx(val));
00078 newVal->SetValue(crea::std2wx(val));
00079 }
00080
00081
00082 BEGIN_EVENT_TABLE(WxEditFieldsPanel, wxPanel)
00083 EVT_COMBOBOX (ID_COMBO,WxEditFieldsPanel::OnComboChange)
00084 END_EVENT_TABLE()
00085
00086
00087 }
00088