]> Creatis software - creaImageIO.git/blob - src2/creaImageIOWxEditFieldsPanel.cpp
aa48137b812eac39b68b8c799e4c0a2e15fd4eec
[creaImageIO.git] / src2 / creaImageIOWxEditFieldsPanel.cpp
1 #include <creaImageIOWxEditFieldsPanel.h>
2 #include <creaImageIOSystem.h>
3 #include <wx/arrstr.h>
4 //using namespace tree;
5 namespace creaImageIO
6 {
7         const int  ID_COMBO             = 140;
8   // CTor
9         WxEditFieldsPanel::WxEditFieldsPanel(wxWindow *parent, wxDialog* dial, WxGimmickView* view, tree::Node* nod, 
10                 const std::vector<std::string> name,
11                 const std::vector<std::string> key)
12  :   wxPanel( parent, 
13                   -1, wxDefaultPosition, 
14                   wxDefaultSize,
15                   wxRESIZE_BORDER | 
16               wxSYSTEM_MENU  |
17                   wxCLOSE_BOX |
18                   wxMAXIMIZE_BOX | 
19                   wxMINIMIZE_BOX | 
20                   wxCAPTION  
21                ),       
22                    dialog(dial),
23                    node (nod), 
24                    names(name), 
25                    keys(key),
26                    mView(view)
27   {
28     GimmickDebugMessage(1,"WxCustomizeConfigPanel::WxCustomizeConfigPanel"
29                         <<std::endl);
30         wxStaticText * cp=new wxStaticText(this,-1,_T(" Attribute to change: "), wxPoint(5,10));
31         wxArrayString as;
32         std::vector<std::string>::const_iterator it;
33         for(it=names.begin();it!=names.end();++it)
34         {
35                 as.Add(*it);
36         }
37         attributes=new wxComboBox(this, ID_COMBO,names.front(),wxPoint(110, 10),wxDefaultSize,as);
38         std::string val=node->GetAttribute(keys[0]);
39         if(val.compare("")==0){val="?";}
40
41         wxStaticText * av=new wxStaticText(this,-1,_T(" Actual Value: "), wxPoint(5,40));
42         actualVal=new wxStaticText(this,-1,_T(val), wxPoint(110,40));
43
44         wxStaticText * nv=new wxStaticText(this,-1,_T(" New Value: "), wxPoint(5,70));
45         newVal=new wxTextCtrl(this, wxID_ANY, _T(val), wxPoint(110,70), wxSize(220,20));
46
47         wxButton *save = new wxButton(this,wxID_ANY,_T("Save Changes"), wxPoint(5,100) );
48         Connect( save->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxEditFieldsPanel::OnEdit ); 
49       
50     Layout(); 
51   }
52
53   /// Destructor
54   WxEditFieldsPanel::~WxEditFieldsPanel()
55   {
56     GimmickDebugMessage(1,"WxEditFieldsPanel::~WxEditFieldsPanel"
57                         <<std::endl);
58   }
59
60   void WxEditFieldsPanel::OnEdit(wxCommandEvent& event)
61   {
62           std::string val=crea::wx2std(newVal->GetValue());
63           mView->OnFieldsEdited(node,names[attributes->GetSelection()],keys[attributes->GetSelection()],val);
64           dialog->Destroy();
65   }
66
67   void WxEditFieldsPanel::OnComboChange(wxCommandEvent& event)
68   {
69           std::string val=node->GetAttribute(keys[attributes->GetSelection()]);
70           if(val.compare("")==0){val="?";}
71           actualVal->SetLabel(crea::std2wx(val));
72           newVal->SetValue(crea::std2wx(val));
73   }
74   
75 //======================================================================
76 BEGIN_EVENT_TABLE(WxEditFieldsPanel, wxPanel)
77 EVT_COMBOBOX  (ID_COMBO,WxEditFieldsPanel::OnComboChange)
78 END_EVENT_TABLE()
79 //====================================================================== 
80
81 } // EO namespace creaImageIO
82
83
84
85