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