2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbtkWxGUIScriptingInterface.cxx,v $
32 Date: $Date: 2012/11/16 08:49:01 $
33 Version: $Revision: 1.49 $
34 =========================================================================*/
40 * \brief Short description in one line
42 * Long description which
43 * can span multiple lines
55 #ifdef _USE_WXWIDGETS_
58 #include "bbtkWxGUIScriptingInterface.h"
59 #include "bbtkWxBlackBox.h"
60 #include "bbtkConfigurationFile.h"
61 #include "bbtkWxStreamRedirector.h"
62 #include "bbtkUtilities.h"
66 #include <wx/tipwin.h>
67 #include <wx/splash.h>
70 //#include "icons/cc_run.xpm"
80 ID_Menu_CreatePackage,
81 ID_Menu_CreateBlackBox,
82 ID_Menu_ShowImageGraph,
83 ID_Menu_RegeneratePackageDoc,
84 ID_Menu_RegenerateBoxesLists,
85 ID_Menu_RegenerateAll,
87 ID_Menu_Windows_Files,
89 ID_Menu_Windows_Messages,
90 ID_Menu_Windows_Command,
92 ID_Menu_Windows_PackageBrowser
97 //================================================================
98 WxGUIScriptingInterface::WxGUIScriptingInterface( wxWindow *parent )
99 : wxFrame((wxFrame *)parent, -1, _T("bbStudio"),
100 wxDefaultPosition, wxSize(1200,800) )
102 m_mgr.SetManagedWindow(this);
104 mInterpreter = bbtk::Interpreter::New();
105 mInterpreter->SetUser(this);
106 mInterpreter->SetCommandLine(true);
107 mInterpreter->SetThrow(true);
108 // mInterpreter->AddBreakObserver
109 //boost::bind( &WxGUIScriptingInterface::InterpreterUserOnBreak, this ));
112 wxInitAllImageHandlers();
114 wxMenu *menuFile = new wxMenu;
115 menuFile->Append( ID_Menu_EditConfig, _T("Open bbtk &Config file") );
116 menuFile->Append( ID_Menu_Quit, _T("&Quit") );
118 wxMenu *menuAbout = new wxMenu;
119 menuAbout->Append( ID_Menu_About, _T("&About...") );
121 wxMenu *menuTools = new wxMenu;
122 menuTools->Append( ID_Menu_CreatePackage, _T("Create &package") );
123 menuTools->Append( ID_Menu_CreateBlackBox, _T("Create &black box") );
124 menuTools->Append( ID_Menu_PlugPackage, _T("&Plug package") );
125 menuTools->AppendSeparator();
126 menuTools->Append( ID_Menu_RegeneratePackageDoc,_T("Regenerate package &doc") );
127 menuTools->Append( ID_Menu_RegenerateBoxesLists,_T("Regenerate boxes &lists") );
128 menuTools->Append( ID_Menu_RegenerateAll, _T("Regenerate &all") );
129 menuTools->AppendSeparator();
130 menuTools->Append( ID_Menu_ShowImageGraph, _T("&Show last graph") );
132 wxMenu *menuWindows = new wxMenu;
133 menuWindows->AppendCheckItem(ID_Menu_Windows_Files,
134 _T("Show 'files' panel") )->Check();
135 menuWindows->AppendCheckItem(ID_Menu_Windows_Help,
136 _T("Show 'help' panel") )->Check();
137 menuWindows->AppendCheckItem(ID_Menu_Windows_Messages,
138 _T("Show 'messages' panel") )->Check();
139 menuWindows->AppendCheckItem(ID_Menu_Windows_Command,
140 _T("Show 'command' panel") )->Check();
141 menuWindows->AppendSeparator();
142 menuWindows->Append( ID_Menu_Windows_PackageBrowser, _T("Start Package &Browser") );
144 // menuWindows->AppendSeparator();
145 // menuWindows->Append ( ID_Menu_Windows_Save, _T("Save interface configuration"));
147 wxMenu *menuOptions = new wxMenu;
148 mwxMenuItemReset = menuOptions->AppendCheckItem(-1,
149 _T("Reset before running") );
150 mwxMenuItemReset->Check();
152 wxMenuBar *menuBar = new wxMenuBar;
153 menuBar->Append( menuFile, _T("&File") );
154 menuBar->Append( menuTools, _T("&Tools") );
155 menuBar->Append( menuOptions, _T("&Options") );
156 menuBar->Append( menuWindows, _T("&Windows") );
157 menuBar->Append( menuAbout, _T("About") );
159 SetMenuBar( menuBar );
164 SetStatusText( _T("Welcome to bbStudio !") );
167 // Panes (Files, Messages, Help, Command)
168 mWxGUITextEditor = new WxGUITextEditor(this,this);
169 mWxGUITextEditor->SetFileNameFilter("*.bbs");
171 mWxGUIHtmlBrowser = new WxGUIHtmlBrowser(this,wxSize(200,0),this);
173 mWxGUIOutputMessages = new WxGUIOutputMessages(this);
175 mWxGUICommand = new WxGUICommand(this,this);
177 mWxGUICommand->SetFocus();
182 mwxNotebook = new wxAuiNotebook(this,
188 | wxAUI_NB_TAB_EXTERNAL_MOVE
189 //| wxAUI_NB_WINDOWLIST_BUTTON
190 //|wxAUI_NB_SCROLL_BUTTONS
191 // | wxAUI_NB_CLOSE_BUTTON
192 //| wxAUI_NB_CLOSE_ON_ACTIVE_TAB
193 //| wxAUI_NB_CLOSE_ON_ALL_TABS
197 mwxNotebook->AddPage(mWxGUITextEditor,_T("Files"),true);
198 mwxNotebook->AddPage(mWxGUIHtmlBrowser,_T("Help"),true);
200 mwxNotebook->AddPage(mWxGUIOutputMessages,_T("Messages"),true);
202 mwxNotebook->AddPage(mWxGUICommand,_T("Command"),true);
205 m_mgr.AddPane(mwxNotebook,
206 wxAuiPaneInfo().Name(wxT("nb"))
207 .CaptionVisible(false)
208 .MinimizeButton(false)
209 .MaximizeButton(false)
211 // .MinSize(wxSize(100,100))
216 m_mgr.AddPane(mWxGUITextEditor,
217 wxAuiPaneInfo().Name(wxT("editor_content"))
218 .Caption(wxT("Files"))
219 .MinimizeButton(true)
220 .MaximizeButton(true)
222 .MinSize(wxSize(100,100))
225 m_mgr.AddPane(mWxGUIHtmlBrowser,
226 wxAuiPaneInfo().Name(wxT("browser_content"))
227 .Caption(wxT("Help"))
228 .MinimizeButton(true)
229 .MaximizeButton(true)
232 .MinSize(wxSize(400,100))
235 m_mgr.AddPane(mWxGUIOutputMessages,
236 wxAuiPaneInfo().Name(wxT("messages_content"))
237 .Caption(wxT("Messages"))
238 .MinimizeButton(true)
239 .MaximizeButton(true)
241 .MinSize(wxSize(100,100))
244 m_mgr.AddPane(mWxGUICommand,
245 wxAuiPaneInfo().Name(wxT("command_content"))
246 .Caption(wxT("Command"))
247 .MinimizeButton(true)
248 .MaximizeButton(true)
251 .MinSize(wxSize(100,100))
255 // parent window of all bbtk windows will be a child of this
256 // Wx::SetTopWindowParent(this);
257 Wx::SetTopWindow(this);
258 // Wx::SetAutoDestroyTopWindow(false);
259 // Add the method OnWxSignal as a Wx::Signal observer
260 //bbtkAddWxSignalObserver(WxGUIPackageBrowser2Window::OnWxSignal);
262 //.PaneBorder(false));
263 // Load the interface appearance saved on last closing
266 // Done in LoadPerspective
271 // mwxNotebook->SetSelection(1);
272 mWxGUIHtmlBrowser->GoHome();
275 // LoadPerspective();
280 wxSplashScreen* splash;
281 long style = wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT;
282 if (ConfigurationFile::GetInstance().DotBbtkIsNew())
283 style = wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT;
284 std::string splash_file = ConfigurationFile::GetInstance().Get_data_path();
285 splash_file += "/kernel/icons/bbStudioSplashScreen.png";
287 if (bitmap.LoadFile(std2wx(splash_file),wxBITMAP_TYPE_PNG))
289 new wxSplashScreen(bitmap,
291 1000, 0, -1, wxDefaultPosition, wxDefaultSize,
292 wxSIMPLE_BORDER|wxSTAY_ON_TOP);
294 if (ConfigurationFile::GetInstance().DotBbtkIsNew())
297 DoRegeneratePackageDoc("-a");
298 DoRegenerateBoxesLists();
301 wxTipWindow* tip = new wxTipWindow(this,
302 _T("\n Welcome to bbStudio !\n\n To run a demo or example:\n 1. click on the 'Demos' or 'Examples' link\n 2. select a demo or example\n 3. click on the '[source]' link : the source file is loaded in bbStudio\n 4. click on the 'Run' button (the arrow at the bottom right of the source file) \n"),1000);
303 tip->CenterOnParent();
306 if (splash) splash->Destroy();
310 //================================================================
312 //================================================================
313 WxGUIScriptingInterface::~WxGUIScriptingInterface()
315 bbtkDebugMessage("widget",9,"bbStudio::~bbStudio()"<<std::endl);
319 //================================================================
321 //================================================================
322 void WxGUIScriptingInterface::OnClose(wxCloseEvent& event)
324 bbtkDebugMessage("widget",9,"bbStudio::OnClose()"<<std::endl);
325 //Wx::SetWindowsHaveBeenDestroyedByParent();
326 //mInterpreter.reset();
327 wxWindowList& list = GetChildren();
328 wxWindowList::iterator iter;
329 for (iter = list.begin(); iter != list.end(); ++iter)
335 //================================================================
338 //================================================================
339 void WxGUIScriptingInterface::Open(const std::string& filename)
341 mWxGUITextEditor->Open(filename);
343 //================================================================
345 catch (BreakException e) \
347 std::cout << "* BREAK"<<std::endl; \
348 if (e.IsInScriptFile()) \
349 std::cout << "* FILE : '"<<e.GetScriptFile()<<"'"<<std::endl; \
350 std::cout << "* LINE : "<<e.GetScriptLine()<<std::endl; \
352 catch (QuitException e) \
354 std::cout << "* QUIT"<<std::endl; \
355 if (e.IsInScriptFile()) \
356 std::cout << "* FILE : '"<<e.GetScriptFile()<<"'"<<std::endl; \
357 std::cout << "* LINE : "<<e.GetScriptLine()<<std::endl; \
361 #define CATCH_MACRO \
362 catch (InterpreterException e) \
364 if (e.GetErrorMessage()=="quit") \
366 std::cerr << "* QUIT ENCOUNTERED"<<std::endl; \
367 if (e.IsInScriptFile()) \
368 std::cerr << "* FILE : '"<<e.GetScriptFile()<<"'"<<std::endl; \
369 std::cerr << "* LINE : "<<e.GetScriptLine()<<std::endl; \
371 else if (e.GetErrorMessage()=="break") \
374 std::cerr << "* BREAK"<<std::endl; \
375 if (e.IsInScriptFile()) \
376 std::cerr << "* FILE : '"<<e.GetScriptFile()<<"'"<<std::endl; \
377 std::cerr << "* LINE : "<<e.GetScriptLine()<<std::endl; \
381 std::cerr << "* ERROR : "<<e.GetErrorMessage()<<std::endl; \
382 if (e.IsInScriptFile()) \
383 std::cerr << "* FILE : '"<<e.GetScriptFile()<<"'"<<std::endl; \
384 std::cerr << "* LINE : "<<e.GetScriptLine()<<std::endl; \
385 int lev = bbtk::MessageManager::GetMessageLevel("Error"); \
387 std::cerr << "* Exception thrown : "<<std::endl; \
388 std::cerr << "* OBJECT : " <<e.GetObject()<<std::endl; \
389 std::cerr << "* FILE : " <<e.GetSourceFile()<<std::endl; \
394 //================================================================
395 void WxGUIScriptingInterface::WxGUICommandEnter(const std::string& command)
399 mWxGUIOutputMessages->Print(s,wxRED);
403 mInterpreter->InterpretLine( command );
407 //================================================================
409 //================================================================
410 /// Runs the interpretation of a file
411 bool WxGUIScriptingInterface::InterpretFile( const std::string& filename)
415 mInterpreter->InterpretFile(filename);
420 //================================================================
423 //================================================================
424 void WxGUIScriptingInterface::WxGUITextEditorGraphSimple()
426 WxGUICommandEnter("exec freeze_no_error");
427 WxGUITextEditorRun();
428 WxGUICommandEnter("exec unfreeze");
429 WxGUICommandEnter("graph");
431 //================================================================
433 //================================================================
434 void WxGUIScriptingInterface::WxGUITextEditorGraphDetail()
436 WxGUICommandEnter("exec freeze_no_error");
437 WxGUITextEditorRun();
438 WxGUICommandEnter("exec unfreeze");
439 WxGUICommandEnter("graph . 1");
441 //================================================================
444 //================================================================
445 void WxGUIScriptingInterface::WxGUITextEditorRunBBI()
447 std::string separator = ConfigurationFile::GetInstance().Get_file_separator ();
448 std::string dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
449 std::string filename = dir + separator + "tmp_bbtk.bbs";
450 mWxGUITextEditor->GetCurrentPage()->SaveFile(filename);
452 std::string command = "\"";
458 command += ConfigurationFile::GetInstance().Get_bin_path();
460 command += separator + "bbi.app/Contents/MacOS/bbi\" ";
462 command += separator + "bbi\" ";
464 command += "\""+filename + "\"";
472 printf ("EED WxGUIScriptingInterface::WxGUITextEditorRunBBI %s \n" , command.c_str() );
473 system( command.c_str() );
475 //================================================================
478 //================================================================
479 void WxGUIScriptingInterface::WxGUITextEditorRun()
481 // wxString temp = mWxGUIHtmlBrowser->GetCurrentPage();
482 std::stringstream* buf = new std::stringstream;
483 (*buf) << mWxGUITextEditor->GetCurrentPage()->GetText();
488 if (mwxMenuItemReset->IsChecked()) WxGUICommandEnter("reset");
489 mInterpreter->InterpretBuffer(buf);
494 mInterpreter->InterpretCurrentStreams();
496 // std::cout << "EO RUN"<<std::endl;
499 // std::cout << "EO RUN 3"<<std::endl;
501 //================================================================
503 //================================================================
504 void WxGUIScriptingInterface::OnMenuQuit(wxCommandEvent& WXUNUSED(event))
506 if (!mWxGUITextEditor->CloseAllPages()) return;
509 //================================================================
512 //================================================================
513 void WxGUIScriptingInterface::OnMenuAbout(wxCommandEvent& WXUNUSED(event))
517 wxMessageBox(_T(" bbStudio\nThe Black Box Toolkit Development Studio\n(c) CREATIS 2008\n\n http://www.creatis.insa-lyon.fr/site/en/CreaTools_home"),
518 _T("About ..."), wxOK | wxICON_INFORMATION,
521 //================================================================
524 //================================================================
525 void WxGUIScriptingInterface::OnMenuEditConfig(wxCommandEvent& WXUNUSED(event))
528 std::string configFile =
529 ConfigurationFile::GetInstance().Get_config_xml_full_path();
531 wxMessageDialog ww(NULL,_T("If you change the bbtk_config.xml, you have to restart this appliaction..."), _T("Alert !"), wxOK);
534 //================================================================
536 //================================================================
537 void WxGUIScriptingInterface::OnMenuWindowsPackageBrowser(wxCommandEvent& WXUNUSED(event))
540 WxGUIPackageBrowser2Window *helpbrowser = new
541 WxGUIPackageBrowser2Window(this,_T("Package Browser"), wxSize(600,600) );
546 WxGUIPackageBrowser2 *browser = new WxGUIPackageBrowser2(this);
547 browser->IncludeAll();
550 // mwxNotebook->AddPage(browser,_T("Package Browser"),true);
553 m_mgr.AddPane(browser,
554 wxAuiPaneInfo().Name(wxT("package_brower"))
555 .Caption(wxT("Package browser"))
556 .MinimizeButton(true)
557 .MaximizeButton(true)
560 .MinSize(wxSize(100,100))
565 //================================================================
569 //================================================================
570 void WxGUIScriptingInterface::OnMenuCreatePackage(wxCommandEvent& WXUNUSED(event))
573 std::string command("toolsbbtk/appli/GUICreatePackage");
574 bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
576 Interpreter::Pointer I = Interpreter::New();
577 I->InterpretFile(command);
579 std::string command("reset");
580 mWxGUICommand->SendCommand(command);
581 command = "include toolsbbtk/appli/GUICreatePackage";
582 bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
583 mWxGUICommand->SendCommand(command);
585 //================================================================
588 //================================================================
589 void WxGUIScriptingInterface::OnMenuCreateBlackBox(wxCommandEvent& WXUNUSED(event))
592 std::string command("toolsbbtk/appli/GUICreateBlackBox");
593 bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
595 Interpreter::Pointer I = Interpreter::New();
596 I->InterpretFile(command);
598 std::string command("reset");
599 mWxGUICommand->SendCommand(command);
600 command = "include toolsbbtk/appli/GUICreateBlackBox";
601 bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
602 mWxGUICommand->SendCommand(command);
604 //================================================================
606 //================================================================
607 void WxGUIScriptingInterface::OnMenuShowImageGraph(wxCommandEvent& WXUNUSED(event))
610 std::string doc_path = bbtk::ConfigurationFile::GetInstance().Get_doc_path();
611 doc_path += bbtk::ConfigurationFile::GetInstance().Get_file_separator();
613 doc_path += bbtk::ConfigurationFile::GetInstance().Get_file_separator();
615 std::string pack_name("User");
616 std::string pack_path = doc_path + pack_name;
619 std::string strappli="start ";
622 std::string strappli="open ";
624 std::string strappli="gnome-open ";
627 std::string strcommand = strappli +pack_path+"/workspace_workspacePrototype.png";
628 // std::cout << "system: " << strcommand << std::endl;
629 system ( strcommand.c_str() );
632 //================================================================
634 void WxGUIScriptingInterface::DoRegeneratePackageDoc( const std::string& pack )
636 std::string mess("Regenerating doc for package '");
640 mess = "Regenerating doc for all packages";
641 mess += " ... please wait";
643 SetStatusText( std2wx(mess) );
651 command += ConfigurationFile::GetInstance().Get_bin_path();
652 command += ConfigurationFile::GetInstance().Get_file_separator();
653 command += "bbRegeneratePackageDoc";
657 command += " " + pack + " -q";
658 bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
661 if ( ! system ( command.c_str() ) )
663 SetStatusText( _T("Done !"));
665 wxMessageBox(_T("Done !"),_T("Regenerate package '")
666 +std2wx(pack)+_T("' doc"),
667 wxOK | wxICON_INFORMATION);
672 SetStatusText( _T("Done !"));
673 wxString err(_T("An error occured while running '"));
674 err += bbtk::std2wx(command) + _T("'");
675 wxMessageBox(err,_T("Regenerate package doc"),wxOK | wxICON_ERROR);
680 //================================================================
681 void WxGUIScriptingInterface::OnMenuRegeneratePackageDoc(wxCommandEvent& WXUNUSED(event))
683 wxString name = wxGetTextFromUser(_T("Enter package name (-a for all)"),
684 _T("Regenerate package doc"),
686 if (name.IsEmpty()) return;
687 std::string pack = bbtk::wx2std(name);
689 DoRegeneratePackageDoc(pack);
691 //================================================================
694 //================================================================
695 void WxGUIScriptingInterface::DoRegenerateBoxesLists()
697 SetStatusText( _T("Regenerating boxes lists ... please wait") );
704 command += ConfigurationFile::GetInstance().Get_bin_path();
705 command += ConfigurationFile::GetInstance().Get_file_separator();
706 command += "bbRegenerateBoxesLists";
711 bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
713 std::cout << "==========================================================================================================" << command.c_str() << std::endl;
714 if ( ! system ( command.c_str() ) )
716 SetStatusText( _T("Done !"));
718 wxMessageBox(_T("Done !"),_T("Regenerate boxes lists"),
719 wxOK | wxICON_INFORMATION);
724 SetStatusText( _T("Done !"));
725 wxString err(_T("An error occured while running '"));
726 err += bbtk::std2wx(command) + _T("'");
727 wxMessageBox(err,_T("Regenerate boxes lists"),wxOK | wxICON_ERROR);
730 //================================================================
733 //================================================================
734 void WxGUIScriptingInterface::OnMenuRegenerateBoxesLists(wxCommandEvent& WXUNUSED(event))
736 DoRegenerateBoxesLists();
738 //================================================================
740 //================================================================
741 void WxGUIScriptingInterface::OnMenuRegenerateAll(wxCommandEvent& WXUNUSED(event))
744 DoRegeneratePackageDoc("-a");
745 DoRegenerateBoxesLists();
747 //================================================================
750 //================================================================
752 * Event Handler for the plug package menu.
753 * This method prompts the user for the directory where the bbtkPackage file is
754 * located and associates the related package with the configuration file.
755 * @param event event not used.
759 void WxGUIScriptingInterface::OnMenuPlugPackage(wxCommandEvent& WXUNUSED(event))
761 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
764 _T("Select package directory"),
770 userResponse = FD->ShowModal();
771 if(userResponse==wxID_OK)
773 std::string path = wx2std (FD->GetPath()) ;
774 std::string fname = path + "/bbtkPackage";
775 std::cout << "Path chosen = \"" << FD->GetPath() << "\"" << std::endl;
776 if ( Utilities::FileExists( fname ) )
779 f.open(fname.c_str());
784 bbtk::ConfigurationFile::GetInstance().AddPackagePathsAndWrite( path );
786 DoRegeneratePackageDoc(pname);
787 DoRegenerateBoxesLists();
789 wxMessageBox(_T("Package successfully plugged"),_T("Plug package"),wxOK | wxICON_INFORMATION);
791 userResponse = wxID_CANCEL;
795 std::string err = "The directory \"" + path + "\" does not contain a 'bbtkPackage' file.";
798 err += "\nNote: If you are on Linux please select the folder and click \"Open\", don't enter in it.";
803 wxMessageBox(crea::std2wx(err),_T("Plug package"),wxOK | wxICON_ERROR);
806 }while(userResponse != wxID_CANCEL);
808 //================================================================
810 //================================================================
811 void WxGUIScriptingInterface::InterpreterUserViewHtmlPage(const std::string& page)
814 // std::cout << "WxGUIScriptingInterface::ShowHtmlPage('"<<page<<"')"<<std::endl;
815 if (mWxGUIHtmlBrowser->GoTo(s))
817 //EED mwxNotebook->ChangeSelection(1);
818 // mwxNotebook->SetSelection(1);
822 // std::cout << "ERROR html"<<std::endl;
825 //================================================================
828 //================================================================
829 void WxGUIScriptingInterface::InterpreterUserOnBreak()
831 // std::cout << "Break" << std::endl;
834 //================================================================
837 //================================================================
838 bool WxGUIScriptingInterface::WxGUIHtmlBrowserUserOnLinkClicked(const std::string& target)
840 size_t s = target.length();
841 if ((s>3) && (target[s-1]=='s')
842 && (target[s-2]=='b')
843 && (target[s-3]=='b')
844 && (target[s-4]=='.'))
846 mWxGUITextEditor->Open(target);
848 mwxNotebook->SetSelection(0);
850 mWxGUITextEditor->SetFocus();
854 if ((s>3) && (target[s-1]=='f')
855 && (target[s-2]=='d')
856 && (target[s-3]=='p')
857 && (target[s-4]=='.'))
865 // Open pdf in windows
866 int size=target.size();
867 int pos=target.rfind("\\");
868 std::string commandStart("start ");
869 std::string commandPath("/D \""+target.substr(0,pos) +"\"");
870 std::string commandPDF( target.substr(pos+1,size-pos+1) );
872 printf("EED WxGUIScriptingInterface::WxGUIHtmlBrowserUserOnLinkClicked cc %s \n",commandPath.c_str() );
874 while ((int)commandPath.rfind("\\\\")!=-1 )
876 commandPath.erase( commandPath.rfind("\\\\") , 1 );
877 printf("EED WxGUIScriptingInterface::WxGUIHtmlBrowserUserOnLinkClicked cc %s \n",commandPath.c_str() );
880 std::string command = commandStart+commandPath+" "+commandPDF;
881 printf("EED WxGUIScriptingInterface::WxGUIHtmlBrowserUserOnLinkClicked BB %s \n",command.c_str() );
882 system( command.c_str() );
887 //================================================================
889 void WxGUIScriptingInterface::OnMenuWindowsCheck( wxCommandEvent& event,
892 bool checked = event.IsChecked();
893 bool shown = m_mgr.GetPane(w).IsShown();
894 // std::cout << "checked = "<<checked<<" - shown = "<<shown<<std::endl;
897 m_mgr.GetPane(w).Show(checked);
902 //================================================================
903 void WxGUIScriptingInterface::OnMenuWindowsFiles(wxCommandEvent& event)
905 OnMenuWindowsCheck(event,mWxGUITextEditor);
907 //================================================================
909 //================================================================
910 void WxGUIScriptingInterface::OnMenuWindowsHelp(wxCommandEvent& event)
912 OnMenuWindowsCheck(event,mWxGUIHtmlBrowser);
914 //================================================================
916 //================================================================
917 void WxGUIScriptingInterface::OnMenuWindowsMessages(wxCommandEvent& event)
919 OnMenuWindowsCheck(event,mWxGUIOutputMessages);
921 //================================================================
923 //================================================================
924 void WxGUIScriptingInterface::OnMenuWindowsCommand(wxCommandEvent& event)
926 OnMenuWindowsCheck(event,mWxGUICommand);
928 //================================================================
930 //================================================================
931 void WxGUIScriptingInterface::OnMenuWindowsSave( wxCommandEvent& WXUNUSED(event))
935 //================================================================
937 //================================================================
938 void WxGUIScriptingInterface::SavePerspective()
940 // std::cout << "Saving configuration..."<<std::endl;
941 std::string conf = wx2std(m_mgr.SavePerspective());
942 std::string fname = Utilities::MakeUserSettingsFullFileName("bbStudio.aui");
944 f.open(fname.c_str(), std::ios::out );
945 f << conf << std::endl;
948 // GetPosition(&x,&y);
949 // f << x << " " << y << std::endl;
955 f << w << " " << h << std::endl;
959 //================================================================
961 //================================================================
962 void WxGUIScriptingInterface::LoadPerspective()
965 Utilities::MakeUserSettingsFullFileName("bbStudio.aui");
966 if ( Utilities::FileExists( fname ))
968 // std::cout << "Loading configuration..."<<std::endl;
971 f.open(fname.c_str());
983 // std::cout << conf << std::endl;
987 m_mgr.LoadPerspective(std2wx(conf));
994 //================================================================
996 //================================================================
997 void WxGUIScriptingInterface::OnPaneClose(wxAuiManagerEvent& evt)
999 std::cout << "Closing panel '"<<evt.pane->name<<"'"<<std::endl;
1001 // OnMenuWindowsCheck( wxCommandEvent& event, wxWindow* w);
1003 //================================================================
1006 //================================================================
1007 BEGIN_EVENT_TABLE(WxGUIScriptingInterface, wxFrame)
1008 EVT_CLOSE( WxGUIScriptingInterface::OnClose)
1009 EVT_MENU(ID_Menu_Quit, WxGUIScriptingInterface::OnMenuQuit)
1010 EVT_MENU(ID_Menu_About, WxGUIScriptingInterface::OnMenuAbout)
1011 EVT_MENU(ID_Menu_EditConfig, WxGUIScriptingInterface::OnMenuEditConfig)
1012 EVT_MENU(ID_Menu_CreatePackage, WxGUIScriptingInterface::OnMenuCreatePackage)
1013 EVT_MENU(ID_Menu_CreateBlackBox, WxGUIScriptingInterface::OnMenuCreateBlackBox)
1014 EVT_MENU(ID_Menu_ShowImageGraph, WxGUIScriptingInterface::OnMenuShowImageGraph)
1015 EVT_MENU(ID_Menu_RegeneratePackageDoc, WxGUIScriptingInterface::OnMenuRegeneratePackageDoc)
1016 EVT_MENU(ID_Menu_RegenerateBoxesLists, WxGUIScriptingInterface::OnMenuRegenerateBoxesLists)
1017 EVT_MENU(ID_Menu_RegenerateAll, WxGUIScriptingInterface::OnMenuRegenerateAll)
1018 EVT_MENU(ID_Menu_PlugPackage, WxGUIScriptingInterface::OnMenuPlugPackage)
1019 EVT_MENU(ID_Menu_Windows_Files, WxGUIScriptingInterface::OnMenuWindowsFiles)
1020 EVT_MENU(ID_Menu_Windows_Help, WxGUIScriptingInterface::OnMenuWindowsHelp)
1021 EVT_MENU(ID_Menu_Windows_Messages, WxGUIScriptingInterface::OnMenuWindowsMessages)
1022 EVT_MENU(ID_Menu_Windows_Command, WxGUIScriptingInterface::OnMenuWindowsCommand)
1023 EVT_MENU(ID_Menu_Windows_Save, WxGUIScriptingInterface::OnMenuWindowsSave)
1024 EVT_MENU(ID_Menu_Windows_PackageBrowser, WxGUIScriptingInterface::OnMenuWindowsPackageBrowser)
1025 EVT_AUI_PANE_CLOSE(WxGUIScriptingInterface::OnPaneClose)
1026 // EVT_BUTTON(ID_Button_Run, WxGUIScriptingInterface::OnButtonRun )
1028 //================================================================
1033 #endif //_USE_WXWIDGETS_