]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
36014fa6e33b89ed3344916f898106d3218289b8
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / bbtkwxGUIEditorGraphicBBS.cxx
1 /*=========================================================================
2  Program:   bbtk
3  Module:    $RCSfile$
4  Language:  C++
5  Date:      $Date$
6  Version:   $Revision$
7  =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11  * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12  * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13  *
14  *  This software is governed by the CeCILL-B license under French law and
15  *  abiding by the rules of distribution of free software. You can  use,
16  *  modify and/ or redistribute the software under the terms of the CeCILL-B
17  *  license as circulated by CEA, CNRS and INRIA at the following URL
18  *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19  *  or in the file LICENSE.txt.
20  *
21  *  As a counterpart to the access to the source code and  rights to copy,
22  *  modify and redistribute granted by the license, users are provided only
23  *  with a limited warranty  and the software's author,  the holder of the
24  *  economic rights,  and the successive licensors  have only  limited
25  *  liability.
26  *
27  *  The fact that you are presently reading this means that you have had
28  *  knowledge of the CeCILL-B license and that you accept its terms.
29  * ------------------------------------------------------------------------ */
30
31 /**
32  *  \file
33  *  \brief Class bbtk::WxInterfaceEditorGraphicBBS .
34  */
35
36 #include "bbtkwxGUIEditorGraphicBBS.h"
37 #include "creaWx.h"
38 #include "creaSystem.h"
39 //must go #include "bbtkUtilities.h"
40 //must go #include "bbtkConfigurationFile.h"
41 #include <wx/defs.h>
42
43 #include <InterpreterBBS.h>
44
45 namespace bbtk {
46
47 //=========================================================================
48 wxGUIEditorGraphicBBS::wxGUIEditorGraphicBBS(wxFrame *parent) :
49                         wxFrame(parent, -1, _T("bbtkGEditor"), wxDefaultPosition, wxSize(
50                                         1200, 800)) {
51
52         _frameAUIMgr = new wxAuiManager(this);
53
54         /*std::string datadir( crea::System::GetExecutablePath() );
55          std::string datadir (".");
56          cout<<"RaC //------------------"<<endl;
57          cout<<"RaC //TODO wxGUIEditorGraphicBBS constructor.Initialize datadir with  crea::System::GetExecutablePath() ."<<endl;
58          cout<<"RaC //------------------"<<endl;
59
60          #ifdef LINUX // assume this is OSX
61          datadir=datadir+"/../share/creaContours";
62          #endif // MACOSX
63
64          #ifdef MACOSX // assume this is OSX
65          datadir=datadir+"/../../../../share/creaContours";
66          #endif // MACOSX
67
68          _dataDir = datadir;*/
69
70         initMenu();
71         initToolbar();
72         initTabPanelsManager();
73         initPackageBrowser();
74         // JGGR & CM  initHelpHTMLBrowser();
75         _helpHtmlBrowser = NULL;
76         CreateStatusBar();
77         _frameAUIMgr->Update();
78         _actualPkgBrowserBoxName = "";
79         _actualPkgBrowserPkgName = "";
80         refreshGUIControls();
81 }
82
83 //=========================================================================
84 wxGUIEditorGraphicBBS::~wxGUIEditorGraphicBBS() {
85
86         printf("EED %p ~wxGUIEditorGraphicBBS()\n", this);
87
88         //EED02JUIN2010         delete _tabsMgr;
89
90         _frameAUIMgr->UnInit();
91         // FCY memory leaks
92         delete _frameAUIMgr;
93         delete _notebook;
94         delete _tabsMgr;
95
96 }
97
98 //=========================================================================
99 void wxGUIEditorGraphicBBS::initToolbar() {
100         wxBitmap bmp_new(new_xpm);
101         wxBitmap bmp_open(open_xpm);
102         wxBitmap bmp_save(save_xpm);
103         wxBitmap bmp_run(run_xpm);
104         wxBitmap bmp_delete(delete_xpm);
105         wxBitmap bmp_centerview(centerview_xpm);
106         wxBitmap bmp_box(box_xpm);
107         wxBitmap bmp_executablebox(executablebox_xpm);
108         wxBitmap bmp_complexbox(complexbox_xpm);
109         wxBitmap bmp_complexinputport(complexinputport_xpm);
110         wxBitmap bmp_complexoutputport(complexoutputport_xpm);
111         wxBitmap bmp_undo(undo_xpm);
112         wxBitmap bmp_redo(redo_xpm);
113         wxBitmap bmp_editProperties(editProperties_xpm);
114         wxToolBar *toolbar = new wxToolBar(this, wxID_ANY);
115
116         //Adds a tool btn to the toolbar
117         toolbar->AddTool(ID_NEW, _T("New"), bmp_new, wxNullBitmap, wxITEM_NORMAL,
118                         _T("New tab"), _T("Create a new panel tab"));
119         toolbar->AddTool(ID_OPEN, _T("Open diagram"), bmp_open, wxNullBitmap,
120                         wxITEM_NORMAL, _T("Open a diagram"), _T("Open a diagram"));
121         toolbar->AddTool(ID_SAVE_DIAGRAM, _T("Save Diagram"), bmp_save,
122                         wxNullBitmap, wxITEM_NORMAL, _T("Saves the current diagram"),
123                         _T("Saves the current diagram")); //DFCH
124         //toolbar->AddTool(ID_SAVE_AS_DIAGRAM,_T("Save Diagram As"),bmp_save, wxNullBitmap, wxITEM_NORMAL,_T("Saves the current diagram"), _T("Saves the current diagram")); //DFCH
125         toolbar->AddTool(ID_RUN, _T("Run"), bmp_run, wxNullBitmap, wxITEM_NORMAL,
126                         _T("Execute actual diagram"), _T("Execute actual diagram"));
127         toolbar->AddTool(ID_DELETEALL, _T("Delete all"), bmp_delete, wxNullBitmap,
128                         wxITEM_NORMAL, _T("Delete all boxes"), _T("Delete all boxes"));
129         toolbar->AddTool(ID_CENTERVIEW, _T("Center view"), bmp_centerview,
130                         wxNullBitmap, wxITEM_NORMAL, _T("Center view"), _T("Center view"));
131         toolbar->AddSeparator();
132         toolbar->AddTool(ID_BTNBOX, _T("New Box"), bmp_box, wxNullBitmap,
133                         wxITEM_NORMAL, _T("New Box"), _T("Nex Box"));
134         toolbar->AddSeparator();
135         toolbar->AddTool(ID_BTEXECUTABLEBOX, _T("Select as executable Box"),
136                         bmp_executablebox, wxNullBitmap, wxITEM_NORMAL,
137                         _T("Select as executable Box"), _T("Select as executable Box"));
138         toolbar->AddSeparator();
139         toolbar->AddTool(ID_BTNCOMPLEXBOX, _T("Complex box"), complexbox_xpm,
140                         wxNullBitmap, wxITEM_NORMAL, _T("Complex box"), _T("Complex box"));
141         toolbar->SetToggle(ID_BTNCOMPLEXBOX, true);
142
143         //toolbar->AddTool(ID_ADDCOMPLEXBOXINPUT, _T("Add input to Complex box"),
144         //              bmp_complexinputport, wxNullBitmap, wxITEM_NORMAL,
145         //              _T("Add input to Complex box"), _T("Add input to Complex box"));
146         toolbar->AddTool(ID_ADDCOMPLEXBOXINPUT, _T("Add external input (Complex box or console app)"),
147                         bmp_complexinputport, wxNullBitmap, wxITEM_NORMAL,
148                         _T("Add external input (Complex box or console app)"), _T("Add external input (Complex box or console app)"));
149
150         toolbar->AddTool(ID_ADDCOMPLEXBOXOUTPUT, _T("Add output to Complex box"),
151                         bmp_complexoutputport, wxNullBitmap, wxITEM_NORMAL,
152                         _T("Add output Complex box"), _T("Add output Complex box"));
153
154         // toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, false); RaC2012 2nd HackFest
155         toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, true);
156
157         toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT, false);
158         toolbar->AddSeparator();
159         toolbar->AddTool(ID_UNDO, _T("Undo"),bmp_undo, wxNullBitmap, wxITEM_NORMAL,     _T("Undo"), _T("Undo"));
160         toolbar->AddTool(ID_REDO, _T("Redo"),bmp_redo, wxNullBitmap, wxITEM_NORMAL,     _T("Redo"), _T("Redo"));
161         toolbar->AddSeparator();
162         toolbar->AddTool(ID_EDITPROPERTIES, _T("Edit diagram properties"),bmp_editProperties, wxNullBitmap, wxITEM_NORMAL,      _T("Edit diagram properties"), _T("Edit diagram properties"));
163         toolbar->EnableTool(ID_EDITPROPERTIES, false);
164         
165         toolbar->EnableTool(ID_UNDO, false);
166         toolbar->EnableTool(ID_REDO, false);
167         toolbar->SetMargins(2, 2);
168         toolbar->Realize();
169         SetToolBar(toolbar);
170
171         
172         // connect command event handlers
173
174         Connect(ID_NEW, wxEVT_COMMAND_TOOL_CLICKED,
175                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab));
176         Connect(ID_OPEN, wxEVT_COMMAND_TOOL_CLICKED,
177                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnOpenDiagram));
178         Connect(ID_SAVE_DIAGRAM, wxEVT_COMMAND_TOOL_CLICKED,
179                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram)); //DFCH
180         Connect(ID_SAVE_AS_DIAGRAM, wxEVT_COMMAND_TOOL_CLICKED,
181                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveAsActualDiagram)); //DFCH
182         Connect(
183                         ID_RUN,
184                         wxEVT_COMMAND_TOOL_CLICKED,
185                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExecuteActualDiagram));
186         Connect(
187                         ID_DELETEALL,
188                         wxEVT_COMMAND_TOOL_CLICKED,
189                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram));
190         Connect(
191                         ID_CENTERVIEW,
192                         wxEVT_COMMAND_TOOL_CLICKED,
193                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCenterViewActualDiagram));
194         Connect(ID_BTNBOX, wxEVT_COMMAND_TOOL_CLICKED,
195                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnClickBtnBox));
196         Connect(
197                         ID_BTEXECUTABLEBOX,
198                         wxEVT_COMMAND_TOOL_CLICKED,
199                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnClickBtnExecutableBox));
200         Connect(ID_BTNCOMPLEXBOX, wxEVT_COMMAND_TOOL_CLICKED,
201                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnClickBtnComplexBox));
202         Connect(ID_ADDCOMPLEXBOXINPUT, wxEVT_COMMAND_TOOL_CLICKED,
203                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnAddComplexBoxInput));
204         Connect(ID_ADDCOMPLEXBOXOUTPUT, wxEVT_COMMAND_TOOL_CLICKED,
205                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnAddComplexBoxOutput));
206         Connect(ID_UNDO,wxEVT_COMMAND_TOOL_CLICKED,     wxCommandEventHandler(wxGUIEditorGraphicBBS::OnUndo));
207         Connect(ID_REDO,wxEVT_COMMAND_TOOL_CLICKED,     wxCommandEventHandler(wxGUIEditorGraphicBBS::OnRedo));
208         Connect(ID_CHANGENAME, wxEVT_COMMAND_RIGHT_CLICK, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnChangeName));
209         Connect(ID_EDITPROPERTIES,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnEditDiagramProperties));
210
211 }
212 //=========================================================================
213 void wxGUIEditorGraphicBBS::initHelpHTMLBrowser() {
214         // JGRR & CM 
215         _helpHtmlBrowser = new WxGUIHtmlBrowser(this, wxSize(200, 0));
216    
217         // EO JGRR & CM 
218         
219 }
220
221 //=========================================================================
222 void wxGUIEditorGraphicBBS::initMenu() {
223         // Create File menu and its items
224         wxMenu *fileMenu = new wxMenu();
225         fileMenu->Append(ID_NEW, _T("New diagram"), _T("New"));
226         fileMenu->Append(ID_SAVE_DIAGRAM, _T("Save Diagram"), _T("Save Diagram")); //DFCH
227         fileMenu->Append(ID_SAVE_AS_DIAGRAM, _T("Save Diagram As"),
228                         _T("Save Diagram As")); //DFCH
229         fileMenu->Append(ID_OPEN_BBS, _T("Open BBS"), _T("Open BBS"));
230         // CM
231         fileMenu->Append(ID_OPEN, _T("Open a diagram"), _T("Open a diagram"));
232         fileMenu->Append(ID_SAVE_AS_BBS, _T("Save BBS"), _T("Save BBS"));
233         fileMenu->Append(ID_SAVE_AS_COMPLEXBOX, _T("Save complex box"),
234                         _T("Save complex box"));
235         fileMenu->Append(wxID_EXIT, _T("E&xit"), _T("Exit"));
236
237         Connect(ID_NEW, wxEVT_COMMAND_MENU_SELECTED,
238                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab));
239         Connect(ID_SAVE_DIAGRAM, wxEVT_COMMAND_MENU_SELECTED,
240                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram)); //DFCH
241         Connect(ID_SAVE_AS_DIAGRAM, wxEVT_COMMAND_MENU_SELECTED,
242                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveAsActualDiagram));
243         Connect(ID_OPEN_BBS, wxEVT_COMMAND_MENU_SELECTED,
244                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnOpenBBS));
245         Connect(ID_SAVE_AS_BBS, wxEVT_COMMAND_MENU_SELECTED,
246                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualBBS));
247         Connect(
248                         ID_SAVE_AS_COMPLEXBOX,
249                         wxEVT_COMMAND_MENU_SELECTED,
250                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualComplexBox));
251         Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED,
252                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExit));
253
254         // Create Help menu and its items
255         wxMenu *editMenu = new wxMenu;
256         editMenu->Append(ID_COPY_TO_COMPLEXDIAGRAM,
257                         _T("Copy selected to complex box"),
258                         _T("Creates a new complex box diagram with selected boxes"));
259
260         Connect(
261                         ID_COPY_TO_COMPLEXDIAGRAM,
262                         wxEVT_COMMAND_MENU_SELECTED,
263                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCopySelectedToComplexDiagram));
264
265         // Create Help menu and its items
266         wxMenu *helpMenu = new wxMenu;
267         helpMenu->Append(wxID_ABOUT, _T("&About..."), _T("About"));
268         helpMenu->Append(ID_HELP_BBEDITOR, _T("&Help..."), _T("Help"));
269         Connect(ID_HELP_BBEDITOR, wxEVT_COMMAND_MENU_SELECTED,
270                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnHelpBBeditor));
271
272         // Create Tool menu
273         wxMenu *menuTools = new wxMenu;
274         menuTools->Append(ID_bbEditor_Tool_Menu_CreatePackage,
275                         _T("Create &package") );
276         menuTools->Append(ID_bbEditor_Tool_Menu_CreateBlackBox,
277                         _T("Create &blackbox") );
278         menuTools->Append(ID_bbEditor_Tool_Menu_PlugPackage, _T("Plug package") );
279         menuTools->Append(ID_bbEditor_Tool_Menu_EditConfig, _T("&Edit bbtk config") );
280         menuTools->Append(ID_bbEditor_Tool_Menu_ShowHTMLDoc,
281                         _T("Show &HTML documentation") );
282         menuTools->Append(ID_bbEditor_Tool_Menu_CreateIndex, _T("&Generate index") );
283
284         Connect(ID_bbEditor_Tool_Menu_CreatePackage, wxEVT_COMMAND_MENU_SELECTED,
285                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreatePackage));
286         Connect(ID_bbEditor_Tool_Menu_CreateBlackBox, wxEVT_COMMAND_MENU_SELECTED,
287                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateBlackBox));
288         Connect(ID_bbEditor_Tool_Menu_PlugPackage, wxEVT_COMMAND_MENU_SELECTED,
289                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnPlugPackage));
290         Connect(ID_bbEditor_Tool_Menu_EditConfig, wxEVT_COMMAND_MENU_SELECTED,
291                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnEditConfig));
292         Connect(ID_bbEditor_Tool_Menu_ShowHTMLDoc, wxEVT_COMMAND_MENU_SELECTED,
293                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnShowHTMLDoc));
294         Connect(ID_bbEditor_Tool_Menu_CreateIndex, wxEVT_COMMAND_MENU_SELECTED,
295                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateIndex));
296
297         // Append the created menu to the menu bar
298         wxMenuBar *menuBar = new wxMenuBar();
299         menuBar->Append(fileMenu, _T("&File") );
300         menuBar->Append(editMenu, _T("&Edit") );
301         menuBar->Append(menuTools, _T("&Tool") );
302         menuBar->Append(helpMenu, _T("&Help") );
303
304         // Attach this menu bar to the frame
305         SetMenuBar(menuBar);
306 }
307
308 //=========================================================================
309 void wxGUIEditorGraphicBBS::initTabPanelsManager() 
310 {
311         _notebook = new wxAuiNotebook(this, wxID_NOTEBOOK, wxDefaultPosition,
312                         wxDefaultSize, wxAUI_NB_TOP | wxAUI_NB_TAB_MOVE
313                                         | wxAUI_NB_CLOSE_ON_ACTIVE_TAB | wxAUI_NB_TAB_FIXED_WIDTH
314                                         | wxAUI_NB_WINDOWLIST_BUTTON);
315         _tabsMgr = new wxTabPanelsManager(this);
316         _frameAUIMgr->AddPane(_notebook, wxAuiPaneInfo().CenterPane());
317 }
318
319 //=========================================================================
320 void wxGUIEditorGraphicBBS::initPackageBrowser() 
321 {
322         _pkgBrowser = new WxGUIPackageBrowser2(this);
323         _pkgBrowser->IncludeAll();
324         _frameAUIMgr->AddPane(_pkgBrowser, wxAuiPaneInfo().Left().MinSize(30, 500).BestSize(750,500).CloseButton(false));
325 }
326
327 //================================================================
328
329 void wxGUIEditorGraphicBBS::DoRegeneratePackageDoc(const std::string& pack) 
330 {
331         std::string mess("Regenerating doc for package '");
332         if (pack != "-a") {
333                 mess += pack + "'";
334         } else {
335                 mess = "Regenerating doc for all packages";
336         }
337
338         mess += " ... please wait";
339
340         SetStatusText(std2wx(mess));
341
342         //BBTK_BUSY_CURSOR;
343
344         std::string command;
345 #if defined(WIN32)
346         command = "\"";
347 #endif
348         command += ConfigurationFile::GetInstance().Get_bin_path();
349         command += ConfigurationFile::GetInstance().Get_file_separator();
350         command += "bbRegeneratePackageDoc";
351 #if defined(WIN32)
352         command += "\"";
353 #endif
354
355         command += " " + pack + " -q";
356         bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
357
358         if (!system(command.c_str())) {
359                 SetStatusText(_T("Done !"));
360                 /*
361                  wxMessageBox(_T("Done !"),_T("Regenerate package '")
362                  +std2wx(pack)+_T("' doc"),
363                  wxOK | wxICON_INFORMATION);
364                  */
365         } else {
366                 SetStatusText(_T("Done !"));
367                 wxString err(_T("An error occured while running '"));
368                 err += bbtk::std2wx(command) + _T("'");
369                 wxMessageBox(err, _T("Regenerate package doc"), wxOK | wxICON_ERROR);
370         }
371 }
372
373 //================================================================
374 void wxGUIEditorGraphicBBS::DoRegenerateBoxesLists() {
375         SetStatusText(_T("Regenerating boxes lists ... please wait"));
376         //BBTK_BUSY_CURSOR ;
377
378         std::string command;
379 #if defined(WIN32)
380         command = "\"";
381 #endif
382         command += ConfigurationFile::GetInstance().Get_bin_path();
383         command += ConfigurationFile::GetInstance().Get_file_separator();
384         command += "bbRegenerateBoxesLists";
385
386 #if defined(WIN32)
387         command += "\"";
388 #endif
389         command += " -q";
390
391         bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
392
393         if (!system(command.c_str())) {
394                 SetStatusText(_T("Done !"));
395                 /*
396                  wxMessageBox(_T("Done !"),_T("Regenerate boxes lists"),
397                  wxOK | wxICON_INFORMATION);
398                  */
399         } else {
400                 SetStatusText(_T("Done !"));
401                 wxString err(_T("An error occured while running '"));
402                 err += bbtk::std2wx(command) + _T("'");
403                 wxMessageBox(err, _T("Regenerate boxes lists"), wxOK | wxICON_ERROR);
404         }
405 }
406
407 //================================================================
408 void wxGUIEditorGraphicBBS::RegenerateAll() {
409         DoRegeneratePackageDoc("-a");
410         DoRegenerateBoxesLists();
411 }
412
413 //================================================================
414
415 wxAuiNotebook* wxGUIEditorGraphicBBS::getAuiNotebook() {
416         return _notebook;
417 }
418
419 //================================================================
420
421 void wxGUIEditorGraphicBBS::displayBlackBoxInfo(std::string packageName,
422                 std::string boxName) {
423         if (_actualPkgBrowserPkgName != packageName || _actualPkgBrowserBoxName
424                         != boxName) {
425                 _actualPkgBrowserPkgName = packageName;
426                 _actualPkgBrowserBoxName = boxName;
427
428                 BlackBoxDescriptor::Pointer descriptor =
429                                 GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(
430                                                 packageName, boxName);
431                 _pkgBrowser->WxGUIBlackBoxListUserOnSelected(descriptor.get());
432         }
433 }
434
435 //=========================================================================
436
437 void wxGUIEditorGraphicBBS::editBlackBox(GBlackBoxModel *bbmodel) {
438         wxBlackBoxEditionDialog* dialog =
439                         new wxBlackBoxEditionDialog(this, bbmodel);
440         dialog->Show();
441 }
442
443 //=========================================================================
444
445 bool wxGUIEditorGraphicBBS::boxNameExists(std::string boxname) {
446  
447         return this->_tabsMgr->getActualTabPanel()->getSceneManager()->boxExist(boxname);
448 }
449
450 //=========================================================================
451
452 void wxGUIEditorGraphicBBS::updateStatusBar(std::string textStatus) {
453         SetStatusText(crea::std2wx(textStatus));
454 }
455
456 //=========================================================================
457
458 void wxGUIEditorGraphicBBS::executeScript(std::string script) {
459         std::string separator =
460                         ConfigurationFile::GetInstance().Get_file_separator();
461         std::string dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
462         std::string filename = dir + separator + "tmp_bbtk.bbs";
463
464         ofstream tempFile;
465         tempFile.open(filename.c_str());
466         tempFile << script;
467         tempFile.close();
468
469         std::string command = "";
470
471 #ifdef WIN32
472         command += "start /b ";
473 #endif
474
475         //              command += "\""+ crea::System::GetExecutablePath();
476         //#ifdef MACOSX
477         //              command += separator + "../../../bbi.app/Contents/MacOS";
478         //#endif
479
480         command += "bbi ";
481         command += "\"" + filename + "\"";
482
483 #ifndef WIN32
484         command += " & ";
485 #endif
486
487         printf("RaC wxGUIEditorGraphicBBS::executeScript %s \n", command.c_str());
488         system(command.c_str());
489 }
490
491 //=========================================================================
492 std::string wxGUIEditorGraphicBBS::CheckExtension(std::string filename, std::string extension) {
493         if(filename.size() > extension.size() ){
494                 if( (filename.compare(filename.size()-extension.size(), extension.size(),extension)) !=0 ){
495                         filename.append(extension);
496                 }
497         }else{
498                 filename.append(extension);
499         }
500         return filename;
501 }
502 //=========================================================================
503 // EVENT HANDLERS
504 //=========================================================================
505
506 void wxGUIEditorGraphicBBS::OnCreateNewTab(wxCommandEvent& event) {
507         _tabsMgr->addNewTab();
508         refreshGUIControls();
509 }
510
511 void wxGUIEditorGraphicBBS::OnUndo(wxCommandEvent& event) {
512         unsigned short disable;
513         std::string stundo;
514         std::string stredo;
515
516         _tabsMgr->loadTempDiagram(0);
517         disable = _tabsMgr->getUndoState(stundo);
518         if(disable == 0)
519         {
520                 std::string name = _tabsMgr->GetNameTabPanel();
521                 if(name[name.length() - 1] == '*')
522                 {
523                         name =name.substr(0,name.length()-1);
524                 }
525                 _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8));
526         }
527
528         GetToolBar()->EnableTool(ID_UNDO,disable);
529         GetToolBar()->SetToolShortHelp(ID_UNDO,crea::std2wx(stundo));
530         GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState(stredo));
531         GetToolBar()->SetToolShortHelp(ID_REDO,crea::std2wx(stredo));
532         refreshGUIControls();
533 }
534
535 //=========================================================================
536
537 void wxGUIEditorGraphicBBS::OnRedo(wxCommandEvent& event) {
538         unsigned short disable;
539         std::string stundo;
540         std::string stredo;
541
542         _tabsMgr->loadTempDiagram(1);
543         std::string name = _tabsMgr->GetNameTabPanel();
544         if(name[name.length() - 1] != '*')
545                 name +="*";
546         _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8));
547         GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState(stundo));
548         GetToolBar()->SetToolShortHelp(ID_UNDO,crea::std2wx(stundo));
549         GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState(stredo));
550         GetToolBar()->SetToolShortHelp(ID_REDO,crea::std2wx(stredo));
551         refreshGUIControls();
552 }
553
554 void wxGUIEditorGraphicBBS::OnChangeName(wxCommandEvent& event){
555 }
556
557 //=========================================================================
558
559 void wxGUIEditorGraphicBBS::OnEditDiagramProperties(wxCommandEvent& event)
560 {
561         wxDiagramPropertiesEditionDialog* dialog =
562                                 new wxDiagramPropertiesEditionDialog(this);
563         dialog->Show();
564 }
565
566 //=========================================================================
567
568 void wxGUIEditorGraphicBBS::OnExecuteActualDiagram(wxCommandEvent& event) {
569         std::string script1 = _tabsMgr->getActualDiagramBBS(true);
570         cout << endl << "RaC wxGUIEditorGraphicBBS::executeActualDiagram SCRIPT"
571                         << endl << endl;
572         cout << script1 << endl;
573
574         std::string script2 = _tabsMgr->getActualDiagramBBS(false);
575         executeScript(script2);
576 }
577
578 //=========================================================================
579 // HANDLERS
580 //=========================================================================
581 void wxGUIEditorGraphicBBS::OnOpenBBS(wxCommandEvent& event) {
582         wxFileDialog * openFileDialog = new wxFileDialog(this, wxT("Open BBS"),
583                         wxEmptyString, wxT("NewBBS"), wxT("*.bbs"), wxOPEN);
584         if (openFileDialog->ShowModal() == wxID_OK) {
585                 wxString fileName = openFileDialog->GetPath();
586
587                 _tabsMgr->addNewTab(openFileDialog->GetFilename());
588
589                 bbtk::InterpreterBBS::Pointer I = bbtk::InterpreterBBS::New(
590                                 this->_tabsMgr->getActualTabPanel()->getSceneManager(),
591                                 _pkgBrowser->GetFactory());
592
593                 // We tell the interpreter to throw exceptions on error
594                 I->SetThrow(true);
595                 // Interpret the file supposed to define a box called 'Processing'
596                 I->InterpretFile((const char*) (fileName.mb_str()));
597         }
598         refreshGUIControls();
599 }
600
601 void wxGUIEditorGraphicBBS::SaveActualBBS(std::string filename) {
602         ofstream file;
603
604         //EED           file.open(fileName.c_str());
605         file.open(filename.c_str());
606         std::string content = "";
607         // writing file header
608         content += "# ----------------------------------\n";
609         content += "# - BBTKGEditor v 1.3 BBS BlackBox Script\n";
610         content += "# - ";
611         content += filename;
612         content += "\n";
613         content += "# ----------------------------------\n";
614         content += "\n";
615         content += _tabsMgr->getActualDiagramBBS();
616         file << content;
617         file.close();
618 }
619
620 void wxGUIEditorGraphicBBS::OnSaveActualBBS(wxCommandEvent& event) {
621         wxFileDialog * saveFileDialog = new wxFileDialog(this,
622                         wxT("Save  actual BBS"), wxEmptyString, wxT("NewBBS"),
623                         wxT("*.bbs"), wxSAVE | wxOVERWRITE_PROMPT);
624         if (saveFileDialog->ShowModal() == wxID_OK) {
625                 wxString fileName = saveFileDialog->GetPath();
626                 std::string filename = (const char*) (fileName.mb_str());
627                 filename=CheckExtension (filename, ".bbs");
628                 SaveActualBBS(filename);
629         }
630
631 }
632
633 void wxGUIEditorGraphicBBS::AskComplexBoxConfiguration() {
634         std::string cbName = _tabsMgr->GetCbName();
635         std::string paName = _tabsMgr->GetCbPackageName();
636
637         wxTextEntryDialog *cbNameDialog = new wxTextEntryDialog(this,
638                         wxT("Complex Box name"));
639         wxTextEntryDialog *paNameDialog = new wxTextEntryDialog(this,
640                         wxT("Package name"));
641
642         cbNameDialog->SetValue(wxString(cbName.c_str(), wxConvUTF8));
643         paNameDialog->SetValue(wxString(paName.c_str(), wxConvUTF8));
644
645         if (cbNameDialog->ShowModal() == wxID_OK) {
646                 wxString complexboxname = cbNameDialog->GetValue();
647                 cbName = (const char*) (complexboxname.mb_str());
648         }
649
650         if (paNameDialog->ShowModal() == wxID_OK) {
651                 wxString packagename = paNameDialog->GetValue();
652                 paName = (const char*) (packagename.mb_str());
653         }
654
655         _tabsMgr->SetCbName(cbName);
656         _tabsMgr->SetCbPackageName(paName);
657 }
658
659 //=========================================================================
660
661 void wxGUIEditorGraphicBBS::SaveActualComplexBox(std::string filename) {
662         ofstream file;
663         file.open(filename.c_str());
664
665         std::string content = "";
666
667         // writing file header
668         content += "# ----------------------------------\n";
669         content += "# - BBTKGEditor v 1.3 BBS BlackBox Script (Complex Box)\n";
670         content += "# - ";
671         content += filename;
672         content += "\n";
673         content += "# ----------------------------------\n";
674         content += "\n";
675         content += _tabsMgr->getActualComplexBoxBBS();
676         file << content;
677         file.close();
678 }
679
680 //=========================================================================
681
682 void wxGUIEditorGraphicBBS::OnSaveActualComplexBox(wxCommandEvent& event) {
683         wxFileDialog * saveFileDialog = new wxFileDialog(this,
684                         wxT("Save Complex Box BBS"), wxEmptyString,
685                         _T("ComplexBoxName"), wxT("*.bbs"), wxSAVE
686                                         | wxOVERWRITE_PROMPT);
687         if (saveFileDialog->ShowModal() == wxID_OK) {
688                 wxString fileName = saveFileDialog->GetPath();
689                 std::string filename = (const char*) (fileName.mb_str());
690                 filename=CheckExtension (filename, ".bbs");
691                 SaveActualComplexBox(filename);
692         }
693 }
694
695 //=========================================================================
696 void wxGUIEditorGraphicBBS::SaveActualDiagram(std::string filename) {
697         ofstream file;
698         file.open(filename.c_str());
699
700         std::string content = "";
701
702         // writing file header
703         content += "# ----------------------------------\n";
704         content += "# - BBTKGEditor v 1.3 BBG BlackBox Diagram file\n";
705         content += "# - ";
706
707         content += filename;
708
709         content += "\n";
710         content += "# ----------------------------------\n";
711         content += "\n";
712         content += "APP_START\n";
713         _tabsMgr->saveActualDiagram(content, filename); //DFCH
714         content += "APP_END\n";
715         file << content;
716         file.close();
717 }
718
719 //=========================================================================
720 void wxGUIEditorGraphicBBS::SaveTempActualDiagram(const std::string &action) 
721 {
722         std::string stundo;
723         std::string stredo;
724         std::string name = _tabsMgr->GetNameTabPanel();
725         if(name[name.length() - 1] != '*')
726                 name +="*";
727         _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8));
728         _tabsMgr->saveTempActualDiagram(action);
729         GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState(stundo));
730         GetToolBar()->SetToolShortHelp(ID_UNDO,crea::std2wx(stundo));
731         GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState(stredo));
732         GetToolBar()->SetToolShortHelp(ID_REDO,crea::std2wx(stredo));
733 }
734
735 //=========================================================================
736
737 //The following method allows to save the current diagram asking the filename
738 //DFCH
739 void wxGUIEditorGraphicBBS::SaveCurrentDiagramAs() {
740         wxFileDialog * saveFileDialog = new wxFileDialog(this,
741                         wxT("Save current diagram"), wxEmptyString, wxT("NewDiagram"),
742                         wxT("*.bbg"), wxSAVE | wxOVERWRITE_PROMPT);
743         if (saveFileDialog->ShowModal() == wxID_OK) {
744                 //_tabsMgr->SetNameTabPanel(saveFileDialog->GetFilename());
745                 wxString pathfileName = saveFileDialog->GetPath();
746                 std::string pathfilename = (const char*) (pathfileName.mb_str());
747                 pathfilename=CheckExtension (pathfilename, ".bbg");
748
749                 //modify the tab name accordingly
750                 wxString fileName = saveFileDialog->GetFilename();
751                 std::string filename = (const char*) (fileName.mb_str());
752                 filename=CheckExtension (filename, ".bbg");
753                 _tabsMgr->SetNameTabPanel( wxString (filename.c_str(), wxConvUTF8) );
754
755                 std::string pathfilenamebbs = pathfilename;
756                 pathfilenamebbs[pathfilenamebbs.length() - 1] = 's';
757                 if (_tabsMgr->isActualDiagramComplexBox() == false) {
758                         SaveActualDiagram(pathfilename);
759                         SaveActualBBS(pathfilenamebbs);
760                 } else {
761                         AskComplexBoxConfiguration();
762                         SaveActualDiagram(pathfilename);
763                         SaveActualComplexBox(pathfilenamebbs);
764                 } //if isActualDiagramComplexBox
765         } // if saveFileDialog
766 }
767 //=========================================================================
768 //DFCH
769 void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event) {
770         std::string pathfilename = _tabsMgr->GetCurrentTabPanelPath();
771         if (pathfilename.empty()) {
772                 SaveCurrentDiagramAs();
773         } else {
774                 std::string pathfilenamebbs = pathfilename;
775                 pathfilenamebbs[pathfilenamebbs.length() - 1] = 's';
776                 
777                 if (_tabsMgr->isActualDiagramComplexBox() == false) {
778                         std::string name = _tabsMgr->GetNameTabPanel();
779                         if(name[name.length() - 1] == '*')
780                         {
781                                 name =name.substr(0,name.length()-1);
782                         }
783                         _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8));
784                         SaveActualDiagram(pathfilename);
785                         SaveActualBBS(pathfilenamebbs);
786                 } else {
787                         AskComplexBoxConfiguration();
788                         SaveActualDiagram(pathfilename);
789                         SaveActualComplexBox(pathfilenamebbs);
790                 } //if isActualDiagramComplexBox
791         }
792 }
793 //=========================================================================
794 //DFCH
795 void wxGUIEditorGraphicBBS::OnSaveAsActualDiagram(wxCommandEvent& event) {
796         SaveCurrentDiagramAs();
797 }
798 //=========================================================================
799
800 void wxGUIEditorGraphicBBS::refreshGUIControls() {
801         std::string stundo;
802         std::string stredo;
803         //RaC2012 2ndHackFest Next line seems weird ... To keep in mind for other devels
804         wxToolBar* toolbar = GetToolBar();
805         if (_tabsMgr->isActualDiagramComplexBox()) {
806                 toolbar->ToggleTool(ID_BTNCOMPLEXBOX, true);
807                 toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, true);
808                 toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT, true);
809
810                 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX, true);
811                 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS, false);
812         } else {
813                 toolbar->ToggleTool(ID_BTNCOMPLEXBOX, false);
814                 toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, false);
815                 toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT, false);
816
817                 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX, false);
818                 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS, true);
819         }
820
821         //RaC2012 2ndHackFest
822         GetToolBar()->EnableTool(ID_EDITPROPERTIES,true);
823
824         GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState(stundo));
825         GetToolBar()->SetToolShortHelp(ID_UNDO,crea::std2wx(stundo));
826         GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState(stredo));
827         GetToolBar()->SetToolShortHelp(ID_REDO,crea::std2wx(stredo));
828
829         if (_tabsMgr->getNumActualSelectedObjects() > 0) {
830                 GetMenuBar()->GetMenu(1)->Enable(ID_COPY_TO_COMPLEXDIAGRAM, true);
831         } else {
832                 ///TODO Fix the possibility to say from the SceneManager to the GUI to refresh the options
833                 GetMenuBar()->GetMenu(1)->Enable(ID_COPY_TO_COMPLEXDIAGRAM, true);
834         }
835
836 }
837
838 //=========================================================================
839
840 void wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram(wxCommandEvent& event) {
841         wxMessageDialog *dial = new wxMessageDialog(NULL,
842                         wxT("Are you sure to delete all boxes of the diagram?"),
843                         wxT("Delete all boxes"), wxYES_NO | wxNO_DEFAULT
844                                         | wxICON_QUESTION);
845         if (dial->ShowModal() == wxID_YES) {
846                 _tabsMgr->deleteAllBoxesActualDiagram();
847         }
848 }
849
850 //=========================================================================
851
852 void wxGUIEditorGraphicBBS::OnCenterViewActualDiagram(wxCommandEvent& event) {
853         _tabsMgr->centerViewActualDiagram();
854 }
855
856 //=========================================================================
857
858 void wxGUIEditorGraphicBBS::OnOpenDiagram(wxCommandEvent& event) {
859         wxFileDialog * openFileDialog = new wxFileDialog(this, wxT("Open diagram"),
860                         wxEmptyString, wxT(""), wxT("*.bbg"), wxOPEN | wxFILE_MUST_EXIST);
861         printf("SCP: wxGUIEditorGraphicBBS::OnOpenDiagram  \n");
862         if (openFileDialog->ShowModal() == wxID_OK) {
863                 wxString fileName = openFileDialog->GetPath();
864                 ifstream inputStream;
865                 std::string fName = (const char*) (fileName.mb_str());
866
867                 inputStream.open(fName.c_str());
868                 assert(inputStream.good()); // fails
869                 _tabsMgr->addNewTab(openFileDialog->GetFilename());
870                 _tabsMgr->loadDiagram(inputStream, fName);
871                 _tabsMgr->saveTempActualDiagram("load diagram");
872                 GetToolBar()->EnableTool(ID_UNDO, false);
873                 GetToolBar()->EnableTool(ID_UNDO, false);
874                 inputStream.close();
875         }
876         refreshGUIControls();
877 }
878
879 //=========================================================================
880
881
882 void wxGUIEditorGraphicBBS::OnClickBtnBox(wxCommandEvent& event) {
883         BlackBoxDescriptor *bbDes = _pkgBrowser->GetActualSelected();
884         if (bbDes != NULL) {
885                 std::string typeName = bbDes->GetTypeName();
886                 std::string packageName = bbDes->GetPackage()->GetName();
887
888                 wxGEditorTabPanel *pnl = this->_tabsMgr->getActualTabPanel();
889                 
890
891                 if (pnl != NULL) {
892                         wxVtkSceneManager *scn = pnl->getSceneManager();
893                         scn->createGBlackBox(50, 50, packageName, typeName);
894                         scn->refresh();
895                 }
896
897                 SaveTempActualDiagram("New Box");
898                 // if pnl
899         }// if bbDes
900 }
901
902 //=========================================================================
903
904 void wxGUIEditorGraphicBBS::OnClickBtnExecutableBox(wxCommandEvent& event) {
905         //DFCH
906         wxGEditorTabPanel *pnl = this->_tabsMgr->getActualTabPanel();
907
908         if (pnl != NULL) {
909                 wxVtkSceneManager *scn = pnl->getSceneManager();
910                 if( scn->MakeBoxExecutable() )
911                         std::cout<<"DFCH: wxGUIEditorGraphicBBS::OnClickBtnExecutableBox...successful"<<std::endl;
912                 else
913                         std::cout<<"DFCH: wxGUIEditorGraphicBBS::OnClickBtnExecutableBox...Error!!"<<std::endl;
914         }
915         //DFCH
916
917 }
918
919 //=========================================================================
920
921 void wxGUIEditorGraphicBBS::OnClickBtnComplexBox(wxCommandEvent& event) {
922         wxToolBar* toolbar = GetToolBar();
923         bool temp = toolbar->GetToolState(ID_BTNCOMPLEXBOX);
924         if (temp) {
925                 enableComplexBox();
926         } else {
927                 disableComplexBox();
928         }
929 }
930
931 //=========================================================================
932
933 void wxGUIEditorGraphicBBS::OnAddComplexBoxInput(wxCommandEvent& event) {
934         wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,
935                         wxT("Name of input port"));
936         if (nameDialog->ShowModal() == wxID_OK) {
937                 wxString fileName = nameDialog->GetValue();
938                 if (!fileName.IsEmpty()) {
939                         std::string portName = (const char*) (fileName.mb_str());
940                         _tabsMgr->addActualDiagramComplexInputPort(portName);
941                 }
942         }
943 }
944
945 //=========================================================================
946
947 void wxGUIEditorGraphicBBS::OnAddComplexBoxOutput(wxCommandEvent& event) {
948         wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,
949                         wxT("Name of output port"));
950         if (nameDialog->ShowModal() == wxID_OK) {
951                 wxString fileName = nameDialog->GetValue();
952                 if (!fileName.IsEmpty()) {
953                         std::string portName = (const char*) (fileName.mb_str());
954                         _tabsMgr->addActualDiagramComplexOutputPort(portName);
955                 }
956         }
957 }
958
959 //=========================================================================
960
961 void wxGUIEditorGraphicBBS::OnCopySelectedToComplexDiagram(
962                 wxCommandEvent& event) {
963         _tabsMgr->copySelectedBBoxesToComplexDiagram();
964 }
965
966 void wxGUIEditorGraphicBBS::OnHelpBBeditor(wxCommandEvent& event) {
967         printf("wxGUIEditorGraphicBBS::OnHelpBBeditor ....not implemented..\n");
968 }
969
970 //=========================================================================
971 void wxGUIEditorGraphicBBS::OnCreatePackage(wxCommandEvent& event) {
972
973         bbtkSystemTools::CreatePackage();
974 }
975
976 //=========================================================================
977 void wxGUIEditorGraphicBBS::OnCreateBlackBox(wxCommandEvent& event) {
978         bbtkSystemTools::CreateBlackBox();
979 }
980 //=========================================================================
981 void wxGUIEditorGraphicBBS::OnPlugPackage(wxCommandEvent& event) {
982         //DFGO2012 Plug Package functionnalities
983         long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
984         wxDirDialog* FD =
985           new wxDirDialog( 0,
986                            _T("Select package directory"),
987                            _T(""),
988                            style);
989         long userResponse;
990         do
991         {
992                 userResponse = FD->ShowModal();
993                 if(userResponse==wxID_OK)
994                 {
995                         std::string path = wx2std (FD->GetPath()) ;
996                         std::string fname = path + "/bbtkPackage";
997                         std::cout << "Path chosen = \"" << FD->GetPath() << "\"" << std::endl;
998                         if ( Utilities::FileExists( fname ) )
999                         {
1000                                 std::ifstream f;
1001                                 f.open(fname.c_str());
1002                                 std::string pname;
1003                                 f >> pname;
1004                                 f.close();
1005
1006                                 bbtk::ConfigurationFile::GetInstance().AddPackagePathsAndWrite( path );
1007
1008                                 DoRegeneratePackageDoc(pname);
1009                                 DoRegenerateBoxesLists();
1010
1011                                 _pkgBrowser->RebuildList();
1012
1013                                 wxMessageBox(_T("Package successfully plugged. Please restart bbEditor to see the new package in the package browser."),_T("Plug package"),wxOK | wxICON_INFORMATION);
1014                                 userResponse = wxID_CANCEL;
1015                         }
1016                         else
1017                         {
1018                                 std::string err = "The directory \"" + path + "\" does not contain a 'bbtkPackage' file.";
1019                                 #ifndef WIN32
1020                                         #ifndef MACOSX
1021                                                 err += "\nNote: If you are on Linux please select the folder and click \"Open\", don't enter in it.";
1022                                         #endif
1023                                 #endif
1024
1025                                 wxMessageBox(crea::std2wx(err), _T("Plug package"),wxOK | wxICON_ERROR);
1026                                 // THE FOLLOWING LINE GIVES ERRORS BECAUSE IT IS NECESSARY TO USE std2wx
1027                                 //wxMessageBox( _T( err) , _T("Plug package"),wxOK | wxICON_ERROR);
1028                         }
1029                 }
1030         }while(userResponse != wxID_CANCEL);
1031
1032 }
1033 //=========================================================================
1034 void wxGUIEditorGraphicBBS::OnEditConfig(wxCommandEvent& event) {
1035         std::string commandStr;
1036             std::string configFile = ConfigurationFile::GetInstance().Get_config_xml_full_path();
1037         #ifdef WIN32
1038                 commandStr = "notepad.exe ";
1039         #else
1040                 commandStr = "gedit ";
1041         #endif
1042                 commandStr = commandStr + configFile;
1043                 std::cout << "system: " << commandStr << std::endl;
1044                 system ( commandStr.c_str() );
1045     }
1046     //=========================================================================
1047
1048     void wxGUIEditorGraphicBBS::OnShowHTMLDoc(wxCommandEvent& event) {
1049         // JGRR & CM WH
1050         if (_helpHtmlBrowser != NULL){
1051              _frameAUIMgr->DetachPane(_helpHtmlBrowser);
1052             _helpHtmlBrowser->Destroy();   
1053         }
1054         initHelpHTMLBrowser();
1055         _frameAUIMgr->AddPane(_helpHtmlBrowser, wxAuiPaneInfo().Right().MinSize(200, 200));
1056         _frameAUIMgr->Update();
1057         refreshGUIControls();
1058         
1059         // EO JGRR    & CM WH       
1060 }
1061 //=========================================================================
1062 void wxGUIEditorGraphicBBS::OnCreateIndex(wxCommandEvent& event) {
1063         printf("EED wxGUIEditorGraphicBBS::OnCreateIndex ... not implemented ..\n");
1064 }
1065
1066 //=========================================================================
1067
1068 void wxGUIEditorGraphicBBS::OnExit(wxCommandEvent& event) {
1069         Close(true);
1070 }
1071
1072 //=========================================================================
1073
1074 void wxGUIEditorGraphicBBS::enableComplexBox() {
1075         _tabsMgr->setActualDiagramComplexBox(true);
1076         refreshGUIControls();
1077 }
1078
1079 //=========================================================================
1080
1081 void wxGUIEditorGraphicBBS::disableComplexBox() {
1082         _tabsMgr->setActualDiagramComplexBox(false);
1083         refreshGUIControls();
1084 }
1085
1086 //=========================================================================
1087
1088 void wxGUIEditorGraphicBBS::setCurrentDiagramDescription(std::string description)
1089 {
1090         _tabsMgr->SetDescription(description);
1091 }
1092
1093 //=========================================================================
1094
1095 void wxGUIEditorGraphicBBS::setCurrentDiagramAuthor(std::string author)
1096 {
1097         _tabsMgr->SetAuthor(author);
1098 }
1099
1100 //=========================================================================
1101
1102 void wxGUIEditorGraphicBBS::setCurrentDiagramCategory(std::string category)
1103 {
1104         _tabsMgr->SetCategory(category);
1105 }
1106
1107 //=========================================================================
1108
1109 std::string wxGUIEditorGraphicBBS::getCurrentDiagramDescription()
1110 {
1111         return _tabsMgr->GetDescription();
1112 }
1113
1114 //=========================================================================
1115
1116 std::string wxGUIEditorGraphicBBS::getCurrentDiagramAuthor()
1117 {
1118         return _tabsMgr->GetAuthor();
1119 }
1120
1121 //=========================================================================
1122
1123
1124 std::string wxGUIEditorGraphicBBS::getCurrentDiagramCategory()
1125 {
1126         return _tabsMgr->GetCategory();
1127 }
1128
1129 //=========================================================================
1130
1131 bool wxGUIEditorGraphicBBS::isCurrentDiagramComplexBox()
1132 {
1133         return _tabsMgr->isActualDiagramComplexBox();
1134 }
1135
1136
1137 } // EO namespace bbtk
1138
1139 // EOF
1140