creaImageIO_lib
creaImageIOWxEditFieldsPanel.cpp
Go to the documentation of this file.
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # pour la Santé)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 #
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
16 #
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
21 # liability.
22 #
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
26 */
27 
28 
30 #include <creaImageIOSystem.h>
31 #include <wx/arrstr.h>
32 
33 //using namespace tree;
34 namespace creaImageIO
35 {
36  const int ID_COMBO = 140;
37  // CTor
38  WxEditFieldsPanel::WxEditFieldsPanel(wxWindow *parent, wxDialog* dial, WxGimmickView* view, tree::Node* nod,
39  const std::vector<std::string> name,
40  const std::vector<std::string> key)
41  : wxPanel( parent,
42  -1, wxDefaultPosition,
43  wxDefaultSize,
44  wxRESIZE_BORDER |
45  wxSYSTEM_MENU |
46  wxCLOSE_BOX |
47  wxMAXIMIZE_BOX |
48  wxMINIMIZE_BOX |
49  wxCAPTION
50  ),
51  dialog(dial),
52  node (nod),
53  names(name),
54  keys(key),
55  mView(view)
56  {
57  GimmickDebugMessage(1,"WxCustomizeConfigPanel::WxCustomizeConfigPanel"
58  <<std::endl);
60  wxStaticText * cp=new wxStaticText(this,-1,_T(" Attribute to change: "), wxPoint(5,10));
61  wxArrayString as;
62  std::vector<std::string>::const_iterator it;
63  for(it=names.begin();it!=names.end();++it)
64  {
65  as.Add(crea::std2wx(*it));
66  }
67  attributes=new wxComboBox(this, ID_COMBO, crea::std2wx(names.front()), wxPoint(110, 10), wxDefaultSize,as);
68  std::string val=node->GetAttribute(keys[0]);
69  if(val.compare("")==0){val="?";}
70 
72  wxStaticText * av=new wxStaticText(this,-1,_T(" Current Value: "), wxPoint(5,40));
73  actualVal=new wxStaticText(this,-1,crea::std2wx(val), wxPoint(110,40));
74 
76  wxStaticText * nv=new wxStaticText(this,-1,_T(" New Value: "), wxPoint(5,70));
77  newVal=new wxTextCtrl(this, wxID_ANY, crea::std2wx(val), wxPoint(110,70), wxSize(220,20));
78 
79  wxButton *save = new wxButton(this,wxID_ANY,_T("Save Changes"), wxPoint(5,100) );
80  Connect( save->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxEditFieldsPanel::OnEdit );
81 
82  Layout();
83  }
84 
87  {
88  GimmickDebugMessage(1,"WxEditFieldsPanel::~WxEditFieldsPanel"
89  <<std::endl);
90  }
91 
92  void WxEditFieldsPanel::OnEdit(wxCommandEvent& event)
93  {
94  std::string val=crea::wx2std(newVal->GetValue());
95  int sel=attributes->GetSelection();
96  if(sel==-1)
97  {
98  sel=0;
99  }
100  mView->OnFieldsEdited(node,names[sel],keys[sel],val);
101  dialog->Destroy();
102  }
103 
104  void WxEditFieldsPanel::OnComboChange(wxCommandEvent& event)
105  {
106  std::string val=node->GetAttribute(keys[attributes->GetSelection()]);
107  if(val.compare("")==0){val="?";}
108  actualVal->SetLabel(crea::std2wx(val));
109  newVal->SetValue(crea::std2wx(val));
110  }
111 
112 //======================================================================
113 BEGIN_EVENT_TABLE(WxEditFieldsPanel, wxPanel)
114 EVT_COMBOBOX (ID_COMBO,WxEditFieldsPanel::OnComboChange)
115 END_EVENT_TABLE()
116 //======================================================================
117 
118 } // EO namespace creaImageIO
119