2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
8 # This software is governed by the CeCILL-B license under French law and
9 # abiding by the rules of distribution of free software. You can use,
10 # modify and/ or redistribute the software under the terms of the CeCILL-B
11 # license as circulated by CEA, CNRS and INRIA at the following URL
12 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
13 # or in the file LICENSE.txt.
15 # As a counterpart to the access to the source code and rights to copy,
16 # modify and redistribute granted by the license, users are provided only
17 # with a limited warranty and the software's author, the holder of the
18 # economic rights, and the successive licensors have only limited
21 # The fact that you are presently reading this means that you have had
22 # knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------
26 /*=========================================================================
32 =========================================================================*/
34 /* ---------------------------------------------------------------------
36 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
37 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux, Ricardo A Corredor
39 * This software is governed by the CeCILL-B license under French law and
40 * abiding by the rules of distribution of free software. You can use,
41 * modify and/ or redistribute the software under the terms of the CeCILL-B
42 * license as circulated by CEA, CNRS and INRIA at the following URL
43 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
44 * or in the file LICENSE.txt.
46 * As a counterpart to the access to the source code and rights to copy,
47 * modify and redistribute granted by the license, users are provided only
48 * with a limited warranty and the software's author, the holder of the
49 * economic rights, and the successive licensors have only limited
52 * The fact that you are presently reading this means that you have had
53 * knowledge of the CeCILL-B license and that you accept its terms.
54 * ------------------------------------------------------------------------ */
58 * \brief Class bbtk::wxDiagramPropertiesEditionDialog .
61 #include "wxDiagramPropertiesEditionDialog.h"
67 //=========================================================================
69 wxDiagramPropertiesEditionDialog::wxDiagramPropertiesEditionDialog(wxGUIEditorGraphicBBS *parent, NodeTreeC tree):wxDialog(parent,wxID_ANY,_T("Diagram Properties"), wxDefaultPosition, wxSize(600, 750),wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
73 constructDiagramPropertiesEditionDialog();
76 //=========================================================================
79 wxDiagramPropertiesEditionDialog::~wxDiagramPropertiesEditionDialog()
84 //=========================================================================
86 void wxDiagramPropertiesEditionDialog::constructBoxTree(NodeTreeC nodeTree, wxTreeItemId itemId)
89 for(int i = 0 ; i < nodeTree.childs.size() ; i++)
91 string spc = nodeTree.childs[i].data;
92 const char* ccc = spc.c_str();
93 wxString pc = wxString::FromUTF8 (ccc);
94 wxTreeItemId iId = _treeBox->AppendItem(itemId, pc, -1, -1, NULL);
95 constructBoxTree(nodeTree.childs[i], iId );
99 //==================================================================================
101 void wxDiagramPropertiesEditionDialog::constructDiagramPropertiesEditionDialog()
103 const int ID_COMBO = 1;
104 wxPanel *panel = new wxPanel(this, -1);
105 wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
106 wxFlexGridSizer *fgsizer = new wxFlexGridSizer(9, 2, 9, 25);
109 wxStaticText *tree = new wxStaticText(panel, -1, wxT("Tree of Box"));
111 string sp = _tree.data;
112 const char* cc = sp.c_str();
113 wxString p = wxString::FromUTF8 (cc);
116 // _treeBox = new wxTreeCtrl (this, wxID_ANY, wxPoint(0,0), wxSize(320,300), wxTR_HAS_BUTTONS | wxTR_SINGLE );
117 _treeBox = new wxTreeCtrl (panel, wxID_ANY, wxPoint(0,0), wxSize(320,300), wxTR_HAS_BUTTONS | wxTR_SINGLE );
118 wxTreeItemId itemId = _treeBox->AddRoot(p, -1,-1,NULL);
120 constructBoxTree(_tree, itemId);
121 _treeBox->ExpandAll();
126 //COMBOBOX OF MESSAGE
129 Interpreter 0 Messages of the interpreter
130 all 0 Minimum level for all kind of messages
131 change 0 Box i/o changes related messages
132 code 0 If positive then codes of the messages are displayed
133 config 0 Configuration related messages
134 connection 0 Connections related messages
135 data 0 Data related messages
136 debug 0 Debug messages
137 echo 1 Level>0 : Prints the output of the 'print' commands of the user.
138 Level>1 : Prints the command being interpreted
139 error 0 Error messages
140 gui 0 Graphical user interface related messages
142 kernel 0 Messages generated by the core classes of the lib
143 max 9 Maximum level for all kind of messages
144 object 0 object memory related messages
145 output 1 Output messages
146 package 0 Packages related messages
147 process 0 Messages related to box processing
148 qt 0 Qt related messages
149 warning 1 Warning messages
150 widget 0 Widgets related messages
153 _diagramMessageKind = new wxComboBox(panel, -1, wxT("-"), wxDefaultPosition, wxSize(100,-1) );
154 _diagramMessageKind->Append (wxT("-"));
155 _diagramMessageKind->Append (wxT("Interpreter"));
156 _diagramMessageKind->Append (wxT("all"));
157 _diagramMessageKind->Append (wxT("change"));
158 _diagramMessageKind->Append (wxT("code"));
159 _diagramMessageKind->Append (wxT("config"));
160 _diagramMessageKind->Append (wxT("connection"));
161 _diagramMessageKind->Append (wxT("data"));
162 _diagramMessageKind->Append (wxT("debug"));
163 _diagramMessageKind->Append (wxT("echo"));
164 _diagramMessageKind->Append (wxT("error"));
165 _diagramMessageKind->Append (wxT("gui"));
166 _diagramMessageKind->Append (wxT("help"));
167 _diagramMessageKind->Append (wxT("kernel"));
168 _diagramMessageKind->Append (wxT("max"));
169 _diagramMessageKind->Append (wxT("object"));
170 _diagramMessageKind->Append (wxT("output"));
171 _diagramMessageKind->Append (wxT("package"));
172 _diagramMessageKind->Append (wxT("process"));
173 _diagramMessageKind->Append (wxT("qt"));
174 _diagramMessageKind->Append (wxT("warning"));
175 _diagramMessageKind->Append (wxT("widget"));
176 _diagramMessageKind->Append (wxT("wx"));
177 _diagramMessageKind->SetEditable(false);
179 _diagramMessageLevel = new wxComboBox(panel, -1, wxT("-"), wxDefaultPosition, wxSize(100,-1) );
180 _diagramMessageLevel->Append (wxT("-"));
181 _diagramMessageLevel->Append (wxT("0"));
182 _diagramMessageLevel->Append (wxT("1"));
183 _diagramMessageLevel->Append (wxT("2"));
184 _diagramMessageLevel->Append (wxT("3"));
185 _diagramMessageLevel->Append (wxT("4"));
186 _diagramMessageLevel->Append (wxT("5"));
187 _diagramMessageLevel->Append (wxT("6"));
188 _diagramMessageLevel->Append (wxT("7"));
189 _diagramMessageLevel->Append (wxT("8"));
190 _diagramMessageLevel->Append (wxT("9"));
191 _diagramMessageLevel->SetEditable(false);
194 _exportFormatCB = new wxComboBox(panel, -1, wxT("bbs"), wxDefaultPosition, wxSize(100,-1) );
195 _exportFormatCB->Append (wxT("bbs"));
196 _exportFormatCB->Append (wxT("All (bbs Pyyhon JavaScript)"));
197 _exportFormatCB->Append (wxT("bbs Python"));
198 _exportFormatCB->Append (wxT("bbs JavaScript"));
199 _exportFormatCB->SetEditable(false);
200 _exportFormatCB->Select( _parent->getCurrentDiagramExportFormat() );
205 // SELECTION CONSTANTS
208 _diagramType = new wxComboBox(panel, -1, wxEmptyString, wxDefaultPosition, wxSize(100,-1) );
209 _diagramType->Append (wxT("Application"));
210 _diagramType->Append (wxT("Complex box"));
211 _diagramType->SetEditable(false);
212 //_diagramType->Enable(false);
214 Connect(ID_COMBO, wxEVT_COMMAND_COMBOBOX_SELECTED,
215 wxCommandEventHandler(wxDiagramPropertiesEditionDialog::OnComboBoxSelected));
217 int currentType = (_parent->isCurrentDiagramComplexBox()==false)? 0 : 1;
218 _diagramType->Select(currentType);
219 std::string currentKindStr = _parent->getCurrentDiagramMessageKind();
220 int currentKind=0; // "-"
221 if (currentKindStr =="Interpreter") { currentKind = 1; }
222 if (currentKindStr == "all") { currentKind = 2; }
223 if (currentKindStr == "change") { currentKind = 3; }
224 if (currentKindStr == "code") { currentKind = 4; }
225 if (currentKindStr == "config") { currentKind = 5; }
226 if (currentKindStr == "connection") { currentKind = 6; }
227 if (currentKindStr == "data") { currentKind = 7; }
228 if (currentKindStr == "debug") { currentKind = 8; }
229 if (currentKindStr == "echo") { currentKind = 9; }
230 if (currentKindStr == "error") { currentKind = 10; }
231 if (currentKindStr == "gui") { currentKind = 11; }
232 if (currentKindStr == "help") { currentKind = 12; }
233 if (currentKindStr == "kernel") { currentKind = 13; }
234 if (currentKindStr == "max") { currentKind = 14; }
235 if (currentKindStr == "object") { currentKind = 15; }
236 if (currentKindStr == "output") { currentKind = 16; }
237 if (currentKindStr == "package") { currentKind = 17; }
238 if (currentKindStr == "process") { currentKind = 18; }
239 if (currentKindStr == "qt" ) { currentKind = 19; }
240 if (currentKindStr == "warning") { currentKind = 20; }
241 if (currentKindStr == "widget") { currentKind = 21; }
242 if (currentKindStr == "wx" ) { currentKind = 22; }
243 _diagramMessageKind->Select(currentKind);
245 std::string currentLevelStr = _parent->getCurrentDiagramMessageLevel();
246 int currentLevel = 0;
247 if (currentLevelStr == "0" ) { currentLevel = 1; }
248 if (currentLevelStr == "1" ) { currentLevel = 2; }
249 if (currentLevelStr == "2" ) { currentLevel = 3; }
250 if (currentLevelStr == "3" ) { currentLevel = 4; }
251 if (currentLevelStr == "4" ) { currentLevel = 5; }
252 if (currentLevelStr == "5" ) { currentLevel = 6; }
253 if (currentLevelStr == "6" ) { currentLevel = 7; }
254 if (currentLevelStr == "7" ) { currentLevel = 8; }
255 if (currentLevelStr == "8" ) { currentLevel = 9; }
256 if (currentLevelStr == "9" ) { currentLevel = 10;}
257 _diagramMessageLevel->Select(currentLevel);
259 wxStaticText *type = new wxStaticText(panel, -1, wxT("Type"));
260 wxStaticText *exportFormat = new wxStaticText(panel, -1, wxT("Export Format"));
261 wxStaticText *author = new wxStaticText(panel, -1, wxT("Author"));
262 wxStaticText *category = new wxStaticText(panel, -1, wxT("Categories"));
263 wxStaticText *description = new wxStaticText(panel, -1, wxT("Description"));
264 wxStaticText *messageKind = new wxStaticText(panel, -1, wxT("Message kind"));
265 wxStaticText *messageLevel = new wxStaticText(panel, -1, wxT("Message level"));
267 _txtAuthor = new wxTextCtrl(panel, -1);
268 _txtCategory = new wxTextCtrl(panel, -1);
269 _txtDescription = new wxTextCtrl(panel, -1, wxT(""), wxPoint(-1, -1), wxSize(-1, -1), wxTE_MULTILINE);
270 wxButton *okButton = new wxButton(panel, -1, _T("Ok"),wxDefaultPosition, wxSize(-1, -1));
271 wxButton *closeButton = new wxButton(panel, -1, _T("Close"), wxDefaultPosition, wxSize(-1, -1));
273 // connect command event handlers
274 Connect(okButton->GetId(),wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxDiagramPropertiesEditionDialog::onClickOk));
275 Connect(closeButton->GetId(),wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxDiagramPropertiesEditionDialog::onClickClose));
277 // Assign loaded values
278 _txtAuthor->SetValue(crea::std2wx(_parent->getCurrentDiagramAuthor()));
279 _txtCategory->SetValue(crea::std2wx(_parent->getCurrentDiagramCategory()));
280 _txtDescription->SetValue(crea::std2wx(_parent->getCurrentDiagramDescription()));
283 fgsizer->Add(_diagramType , 1, wxEXPAND);
284 fgsizer->Add(author);
285 fgsizer->Add(_txtAuthor , 1, wxEXPAND);
286 fgsizer->Add(exportFormat);
287 fgsizer->Add(_exportFormatCB , 1, wxEXPAND);
288 fgsizer->Add(category);
289 fgsizer->Add(_txtCategory, 1, wxEXPAND);
290 fgsizer->Add(description, 1, wxEXPAND);
291 fgsizer->Add(_txtDescription, 1, wxEXPAND);
293 fgsizer->Add(messageKind);
294 fgsizer->Add(_diagramMessageKind, 1, wxEXPAND);
295 fgsizer->Add(messageLevel);
296 fgsizer->Add(_diagramMessageLevel, 1, wxEXPAND);
298 fgsizer->Add(_treeBox, 1, wxEXPAND);
300 fgsizer->Add(okButton, 1, wxEXPAND);
301 fgsizer->Add(closeButton, 1, wxEXPAND);
303 fgsizer->AddGrowableRow(3, 1);
304 fgsizer->AddGrowableCol(1, 1);
306 hbox->Add(fgsizer, 1, wxALL | wxEXPAND, 15);
307 panel->SetSizerAndFit(hbox);
313 // Assign loaded values
314 _txtAuthor->SetValue(crea::std2wx(_parent->getCurrentDiagramAuthor()));
315 _txtCategory->SetValue(crea::std2wx(_parent->getCurrentDiagramCategory()));
316 _txtDescription->SetValue(crea::std2wx(_parent->getCurrentDiagramDescription()));
319 //=========================================================================
321 void wxDiagramPropertiesEditionDialog::onClickOk(wxCommandEvent& event)
323 std::string txtAuthor = wx2std(_txtAuthor->GetValue());
324 std::string txtCategory = wx2std(_txtCategory->GetValue());
325 std::string txtDescription = wx2std(_txtDescription->GetValue());
326 _parent->setCurrentDiagramAuthor(txtAuthor);
327 _parent->setCurrentDiagramCategory(txtCategory);
328 _parent->setCurrentDiagramDescription(txtDescription);
330 // SELECTION CONSTANTS
333 int selection = _diagramType->GetSelection();
336 _parent->disableComplexBox();
340 _parent->enableComplexBox();
344 // Export Formats constants
346 // 1 - ALL - bbs & py & js
349 _parent->setCurrentDiagramExportFormat( _exportFormatCB->GetSelection() );
353 std::string kindSelected = wx2std(_diagramMessageKind->GetStringSelection());
354 std::string levelSelected = wx2std(_diagramMessageLevel->GetStringSelection());
355 _parent->setCurrentDiagramMessageKind(kindSelected);
356 _parent->setCurrentDiagramMessageLevel(levelSelected);
360 //=========================================================================
362 void wxDiagramPropertiesEditionDialog::onClickClose(wxCommandEvent& event)
364 printf("RaC wxDiagramPropertiesEditionDialog::onClickClose\n");
368 //=========================================================================
370 void wxDiagramPropertiesEditionDialog::OnComboBoxSelected(wxCommandEvent& event)
372 // TODO Show info to edit complex boxes
375 //=========================================================================
380 } // EO namespace bbtk