1 /*=========================================================================
3 Module: $RCSfile: bbtkWxGUIScriptingInterface.cxx,v $
5 Date: $Date: 2012/11/12 16:18:38 $
6 Version: $Revision: 1.48 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
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.
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
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 * ------------------------------------------------------------------------ */
33 * \brief Short description in one line
35 * Long description which
36 * can span multiple lines
48 #ifdef _USE_WXWIDGETS_
51 #include "bbtkWxGUIScriptingInterface.h"
52 #include "bbtkWxBlackBox.h"
53 #include "bbtkConfigurationFile.h"
54 #include "bbtkWxStreamRedirector.h"
55 #include "bbtkUtilities.h"
59 #include <wx/tipwin.h>
60 #include <wx/splash.h>
63 //#include "icons/cc_run.xpm"
73 ID_Menu_CreatePackage,
74 ID_Menu_CreateBlackBox,
75 ID_Menu_ShowImageGraph,
76 ID_Menu_RegeneratePackageDoc,
77 ID_Menu_RegenerateBoxesLists,
78 ID_Menu_RegenerateAll,
80 ID_Menu_Windows_Files,
82 ID_Menu_Windows_Messages,
83 ID_Menu_Windows_Command,
85 ID_Menu_Windows_PackageBrowser
90 //================================================================
91 WxGUIScriptingInterface::WxGUIScriptingInterface( wxWindow *parent )
92 : wxFrame((wxFrame *)parent, -1, _T("bbStudio"),
93 wxDefaultPosition, wxSize(1200,800) )
95 m_mgr.SetManagedWindow(this);
97 mInterpreter = bbtk::Interpreter::New();
98 mInterpreter->SetUser(this);
99 mInterpreter->SetCommandLine(true);
100 mInterpreter->SetThrow(true);
101 // mInterpreter->AddBreakObserver
102 //boost::bind( &WxGUIScriptingInterface::InterpreterUserOnBreak, this ));
105 wxInitAllImageHandlers();
107 wxMenu *menuFile = new wxMenu;
108 menuFile->Append( ID_Menu_EditConfig, _T("Open bbtk &Config file") );
109 menuFile->Append( ID_Menu_Quit, _T("&Quit") );
111 wxMenu *menuAbout = new wxMenu;
112 menuAbout->Append( ID_Menu_About, _T("&About...") );
114 wxMenu *menuTools = new wxMenu;
115 menuTools->Append( ID_Menu_CreatePackage, _T("Create &package") );
116 menuTools->Append( ID_Menu_CreateBlackBox, _T("Create &black box") );
117 menuTools->Append( ID_Menu_PlugPackage, _T("&Plug package") );
118 menuTools->AppendSeparator();
119 menuTools->Append( ID_Menu_RegeneratePackageDoc,_T("Regenerate package &doc") );
120 menuTools->Append( ID_Menu_RegenerateBoxesLists,_T("Regenerate boxes &lists") );
121 menuTools->Append( ID_Menu_RegenerateAll, _T("Regenerate &all") );
122 menuTools->AppendSeparator();
123 menuTools->Append( ID_Menu_ShowImageGraph, _T("&Show last graph") );
125 wxMenu *menuWindows = new wxMenu;
126 menuWindows->AppendCheckItem(ID_Menu_Windows_Files,
127 _T("Show 'files' panel") )->Check();
128 menuWindows->AppendCheckItem(ID_Menu_Windows_Help,
129 _T("Show 'help' panel") )->Check();
130 menuWindows->AppendCheckItem(ID_Menu_Windows_Messages,
131 _T("Show 'messages' panel") )->Check();
132 menuWindows->AppendCheckItem(ID_Menu_Windows_Command,
133 _T("Show 'command' panel") )->Check();
134 menuWindows->AppendSeparator();
135 menuWindows->Append( ID_Menu_Windows_PackageBrowser, _T("Start Package &Browser") );
137 // menuWindows->AppendSeparator();
138 // menuWindows->Append ( ID_Menu_Windows_Save, _T("Save interface configuration"));
140 wxMenu *menuOptions = new wxMenu;
141 mwxMenuItemReset = menuOptions->AppendCheckItem(-1,
142 _T("Reset before running") );
143 mwxMenuItemReset->Check();
145 wxMenuBar *menuBar = new wxMenuBar;
146 menuBar->Append( menuFile, _T("&File") );
147 menuBar->Append( menuTools, _T("&Tools") );
148 menuBar->Append( menuOptions, _T("&Options") );
149 menuBar->Append( menuWindows, _T("&Windows") );
150 menuBar->Append( menuAbout, _T("About") );
152 SetMenuBar( menuBar );
157 SetStatusText( _T("Welcome to bbStudio !") );
160 // Panes (Files, Messages, Help, Command)
161 mWxGUITextEditor = new WxGUITextEditor(this,this);
162 mWxGUITextEditor->SetFileNameFilter("*.bbs");
164 mWxGUIHtmlBrowser = new WxGUIHtmlBrowser(this,wxSize(200,0),this);
166 mWxGUIOutputMessages = new WxGUIOutputMessages(this);
168 mWxGUICommand = new WxGUICommand(this,this);
170 mWxGUICommand->SetFocus();
175 mwxNotebook = new wxAuiNotebook(this,
181 | wxAUI_NB_TAB_EXTERNAL_MOVE
182 //| wxAUI_NB_WINDOWLIST_BUTTON
183 //|wxAUI_NB_SCROLL_BUTTONS
184 // | wxAUI_NB_CLOSE_BUTTON
185 //| wxAUI_NB_CLOSE_ON_ACTIVE_TAB
186 //| wxAUI_NB_CLOSE_ON_ALL_TABS
190 mwxNotebook->AddPage(mWxGUITextEditor,_T("Files"),true);
191 mwxNotebook->AddPage(mWxGUIHtmlBrowser,_T("Help"),true);
193 mwxNotebook->AddPage(mWxGUIOutputMessages,_T("Messages"),true);
195 mwxNotebook->AddPage(mWxGUICommand,_T("Command"),true);
198 m_mgr.AddPane(mwxNotebook,
199 wxAuiPaneInfo().Name(wxT("nb"))
200 .CaptionVisible(false)
201 .MinimizeButton(false)
202 .MaximizeButton(false)
204 // .MinSize(wxSize(100,100))
209 m_mgr.AddPane(mWxGUITextEditor,
210 wxAuiPaneInfo().Name(wxT("editor_content"))
211 .Caption(wxT("Files"))
212 .MinimizeButton(true)
213 .MaximizeButton(true)
215 .MinSize(wxSize(100,100))
218 m_mgr.AddPane(mWxGUIHtmlBrowser,
219 wxAuiPaneInfo().Name(wxT("browser_content"))
220 .Caption(wxT("Help"))
221 .MinimizeButton(true)
222 .MaximizeButton(true)
225 .MinSize(wxSize(400,100))
228 m_mgr.AddPane(mWxGUIOutputMessages,
229 wxAuiPaneInfo().Name(wxT("messages_content"))
230 .Caption(wxT("Messages"))
231 .MinimizeButton(true)
232 .MaximizeButton(true)
234 .MinSize(wxSize(100,100))
237 m_mgr.AddPane(mWxGUICommand,
238 wxAuiPaneInfo().Name(wxT("command_content"))
239 .Caption(wxT("Command"))
240 .MinimizeButton(true)
241 .MaximizeButton(true)
244 .MinSize(wxSize(100,100))
248 // parent window of all bbtk windows will be a child of this
249 // Wx::SetTopWindowParent(this);
250 Wx::SetTopWindow(this);
251 // Wx::SetAutoDestroyTopWindow(false);
252 // Add the method OnWxSignal as a Wx::Signal observer
253 //bbtkAddWxSignalObserver(WxGUIPackageBrowser2Window::OnWxSignal);
255 //.PaneBorder(false));
256 // Load the interface appearance saved on last closing
259 // Done in LoadPerspective
264 // mwxNotebook->SetSelection(1);
265 mWxGUIHtmlBrowser->GoHome();
268 // LoadPerspective();
273 wxSplashScreen* splash;
274 long style = wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT;
275 if (ConfigurationFile::GetInstance().DotBbtkIsNew())
276 style = wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT;
277 std::string splash_file = ConfigurationFile::GetInstance().Get_data_path();
278 splash_file += "/kernel/icons/bbStudioSplashScreen.png";
280 if (bitmap.LoadFile(std2wx(splash_file),wxBITMAP_TYPE_PNG))
282 new wxSplashScreen(bitmap,
284 1000, 0, -1, wxDefaultPosition, wxDefaultSize,
285 wxSIMPLE_BORDER|wxSTAY_ON_TOP);
287 if (ConfigurationFile::GetInstance().DotBbtkIsNew())
290 DoRegeneratePackageDoc("-a");
291 DoRegenerateBoxesLists();
294 wxTipWindow* tip = new wxTipWindow(this,
295 _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);
296 tip->CenterOnParent();
299 if (splash) splash->Destroy();
303 //================================================================
305 //================================================================
306 WxGUIScriptingInterface::~WxGUIScriptingInterface()
308 bbtkDebugMessage("widget",9,"bbStudio::~bbStudio()"<<std::endl);
312 //================================================================
314 //================================================================
315 void WxGUIScriptingInterface::OnClose(wxCloseEvent& event)
317 bbtkDebugMessage("widget",9,"bbStudio::OnClose()"<<std::endl);
318 //Wx::SetWindowsHaveBeenDestroyedByParent();
319 //mInterpreter.reset();
320 wxWindowList& list = GetChildren();
321 wxWindowList::iterator iter;
322 for (iter = list.begin(); iter != list.end(); ++iter)
328 //================================================================
331 //================================================================
332 void WxGUIScriptingInterface::Open(const std::string& filename)
334 mWxGUITextEditor->Open(filename);
336 //================================================================
338 catch (BreakException e) \
340 std::cout << "* BREAK"<<std::endl; \
341 if (e.IsInScriptFile()) \
342 std::cout << "* FILE : '"<<e.GetScriptFile()<<"'"<<std::endl; \
343 std::cout << "* LINE : "<<e.GetScriptLine()<<std::endl; \
345 catch (QuitException e) \
347 std::cout << "* QUIT"<<std::endl; \
348 if (e.IsInScriptFile()) \
349 std::cout << "* FILE : '"<<e.GetScriptFile()<<"'"<<std::endl; \
350 std::cout << "* LINE : "<<e.GetScriptLine()<<std::endl; \
354 #define CATCH_MACRO \
355 catch (InterpreterException e) \
357 if (e.GetErrorMessage()=="quit") \
359 std::cerr << "* QUIT ENCOUNTERED"<<std::endl; \
360 if (e.IsInScriptFile()) \
361 std::cerr << "* FILE : '"<<e.GetScriptFile()<<"'"<<std::endl; \
362 std::cerr << "* LINE : "<<e.GetScriptLine()<<std::endl; \
364 else if (e.GetErrorMessage()=="break") \
367 std::cerr << "* BREAK"<<std::endl; \
368 if (e.IsInScriptFile()) \
369 std::cerr << "* FILE : '"<<e.GetScriptFile()<<"'"<<std::endl; \
370 std::cerr << "* LINE : "<<e.GetScriptLine()<<std::endl; \
374 std::cerr << "* ERROR : "<<e.GetErrorMessage()<<std::endl; \
375 if (e.IsInScriptFile()) \
376 std::cerr << "* FILE : '"<<e.GetScriptFile()<<"'"<<std::endl; \
377 std::cerr << "* LINE : "<<e.GetScriptLine()<<std::endl; \
378 int lev = bbtk::MessageManager::GetMessageLevel("Error"); \
380 std::cerr << "* Exception thrown : "<<std::endl; \
381 std::cerr << "* OBJECT : " <<e.GetObject()<<std::endl; \
382 std::cerr << "* FILE : " <<e.GetSourceFile()<<std::endl; \
387 //================================================================
388 void WxGUIScriptingInterface::WxGUICommandEnter(const std::string& command)
392 mWxGUIOutputMessages->Print(s,wxRED);
396 mInterpreter->InterpretLine( command );
400 //================================================================
402 //================================================================
403 /// Runs the interpretation of a file
404 bool WxGUIScriptingInterface::InterpretFile( const std::string& filename)
408 mInterpreter->InterpretFile(filename);
413 //================================================================
416 //================================================================
417 void WxGUIScriptingInterface::WxGUITextEditorGraphSimple()
419 WxGUICommandEnter("exec freeze_no_error");
420 WxGUITextEditorRun();
421 WxGUICommandEnter("exec unfreeze");
422 WxGUICommandEnter("graph");
424 //================================================================
426 //================================================================
427 void WxGUIScriptingInterface::WxGUITextEditorGraphDetail()
429 WxGUICommandEnter("exec freeze_no_error");
430 WxGUITextEditorRun();
431 WxGUICommandEnter("exec unfreeze");
432 WxGUICommandEnter("graph . 1");
434 //================================================================
437 //================================================================
438 void WxGUIScriptingInterface::WxGUITextEditorRunBBI()
440 std::string separator = ConfigurationFile::GetInstance().Get_file_separator ();
441 std::string dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
442 std::string filename = dir + separator + "tmp_bbtk.bbs";
443 mWxGUITextEditor->GetCurrentPage()->SaveFile(filename);
445 std::string command = "\"";
451 command += ConfigurationFile::GetInstance().Get_bin_path();
453 command += separator + "bbi.app/Contents/MacOS/bbi\" ";
455 command += separator + "bbi\" ";
457 command += "\""+filename + "\"";
465 printf ("EED WxGUIScriptingInterface::WxGUITextEditorRunBBI %s \n" , command.c_str() );
466 system( command.c_str() );
468 //================================================================
471 //================================================================
472 void WxGUIScriptingInterface::WxGUITextEditorRun()
474 // wxString temp = mWxGUIHtmlBrowser->GetCurrentPage();
475 std::stringstream* buf = new std::stringstream;
476 (*buf) << mWxGUITextEditor->GetCurrentPage()->GetText();
481 if (mwxMenuItemReset->IsChecked()) WxGUICommandEnter("reset");
482 mInterpreter->InterpretBuffer(buf);
487 mInterpreter->InterpretCurrentStreams();
489 // std::cout << "EO RUN"<<std::endl;
492 // std::cout << "EO RUN 3"<<std::endl;
494 //================================================================
496 //================================================================
497 void WxGUIScriptingInterface::OnMenuQuit(wxCommandEvent& WXUNUSED(event))
499 if (!mWxGUITextEditor->CloseAllPages()) return;
502 //================================================================
505 //================================================================
506 void WxGUIScriptingInterface::OnMenuAbout(wxCommandEvent& WXUNUSED(event))
510 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"),
511 _T("About ..."), wxOK | wxICON_INFORMATION,
514 //================================================================
517 //================================================================
518 void WxGUIScriptingInterface::OnMenuEditConfig(wxCommandEvent& WXUNUSED(event))
521 std::string configFile =
522 ConfigurationFile::GetInstance().Get_config_xml_full_path();
524 wxMessageDialog ww(NULL,_T("If you change the bbtk_config.xml, you have to restart this appliaction..."), _T("Alert !"), wxOK);
527 //================================================================
529 //================================================================
530 void WxGUIScriptingInterface::OnMenuWindowsPackageBrowser(wxCommandEvent& WXUNUSED(event))
533 WxGUIPackageBrowser2Window *helpbrowser = new
534 WxGUIPackageBrowser2Window(this,_T("Package Browser"), wxSize(600,600) );
539 WxGUIPackageBrowser2 *browser = new WxGUIPackageBrowser2(this);
540 browser->IncludeAll();
543 // mwxNotebook->AddPage(browser,_T("Package Browser"),true);
546 m_mgr.AddPane(browser,
547 wxAuiPaneInfo().Name(wxT("package_brower"))
548 .Caption(wxT("Package browser"))
549 .MinimizeButton(true)
550 .MaximizeButton(true)
553 .MinSize(wxSize(100,100))
558 //================================================================
562 //================================================================
563 void WxGUIScriptingInterface::OnMenuCreatePackage(wxCommandEvent& WXUNUSED(event))
566 std::string command("toolsbbtk/appli/GUICreatePackage");
567 bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
569 Interpreter::Pointer I = Interpreter::New();
570 I->InterpretFile(command);
572 std::string command("reset");
573 mWxGUICommand->SendCommand(command);
574 command = "include toolsbbtk/appli/GUICreatePackage";
575 bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
576 mWxGUICommand->SendCommand(command);
578 //================================================================
581 //================================================================
582 void WxGUIScriptingInterface::OnMenuCreateBlackBox(wxCommandEvent& WXUNUSED(event))
585 std::string command("toolsbbtk/appli/GUICreateBlackBox");
586 bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
588 Interpreter::Pointer I = Interpreter::New();
589 I->InterpretFile(command);
591 std::string command("reset");
592 mWxGUICommand->SendCommand(command);
593 command = "include toolsbbtk/appli/GUICreateBlackBox";
594 bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
595 mWxGUICommand->SendCommand(command);
597 //================================================================
599 //================================================================
600 void WxGUIScriptingInterface::OnMenuShowImageGraph(wxCommandEvent& WXUNUSED(event))
603 std::string doc_path = bbtk::ConfigurationFile::GetInstance().Get_doc_path();
604 doc_path += bbtk::ConfigurationFile::GetInstance().Get_file_separator();
606 doc_path += bbtk::ConfigurationFile::GetInstance().Get_file_separator();
608 std::string pack_name("User");
609 std::string pack_path = doc_path + pack_name;
612 std::string strappli="start ";
615 std::string strappli="open ";
617 std::string strappli="gnome-open ";
620 std::string strcommand = strappli +pack_path+"/workspace_workspacePrototype.png";
621 // std::cout << "system: " << strcommand << std::endl;
622 system ( strcommand.c_str() );
625 //================================================================
627 void WxGUIScriptingInterface::DoRegeneratePackageDoc( const std::string& pack )
629 std::string mess("Regenerating doc for package '");
633 mess = "Regenerating doc for all packages";
634 mess += " ... please wait";
636 SetStatusText( std2wx(mess) );
644 command += ConfigurationFile::GetInstance().Get_bin_path();
645 command += ConfigurationFile::GetInstance().Get_file_separator();
646 command += "bbRegeneratePackageDoc";
650 command += " " + pack + " -q";
651 bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
654 if ( ! system ( command.c_str() ) )
656 SetStatusText( _T("Done !"));
658 wxMessageBox(_T("Done !"),_T("Regenerate package '")
659 +std2wx(pack)+_T("' doc"),
660 wxOK | wxICON_INFORMATION);
665 SetStatusText( _T("Done !"));
666 wxString err(_T("An error occured while running '"));
667 err += bbtk::std2wx(command) + _T("'");
668 wxMessageBox(err,_T("Regenerate package doc"),wxOK | wxICON_ERROR);
673 //================================================================
674 void WxGUIScriptingInterface::OnMenuRegeneratePackageDoc(wxCommandEvent& WXUNUSED(event))
676 wxString name = wxGetTextFromUser(_T("Enter package name (-a for all)"),
677 _T("Regenerate package doc"),
679 if (name.IsEmpty()) return;
680 std::string pack = bbtk::wx2std(name);
682 DoRegeneratePackageDoc(pack);
684 //================================================================
687 //================================================================
688 void WxGUIScriptingInterface::DoRegenerateBoxesLists()
690 SetStatusText( _T("Regenerating boxes lists ... please wait") );
697 command += ConfigurationFile::GetInstance().Get_bin_path();
698 command += ConfigurationFile::GetInstance().Get_file_separator();
699 command += "bbRegenerateBoxesLists";
704 bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
706 std::cout << "==========================================================================================================" << command.c_str() << std::endl;
707 if ( ! system ( command.c_str() ) )
709 SetStatusText( _T("Done !"));
711 wxMessageBox(_T("Done !"),_T("Regenerate boxes lists"),
712 wxOK | wxICON_INFORMATION);
717 SetStatusText( _T("Done !"));
718 wxString err(_T("An error occured while running '"));
719 err += bbtk::std2wx(command) + _T("'");
720 wxMessageBox(err,_T("Regenerate boxes lists"),wxOK | wxICON_ERROR);
723 //================================================================
726 //================================================================
727 void WxGUIScriptingInterface::OnMenuRegenerateBoxesLists(wxCommandEvent& WXUNUSED(event))
729 DoRegenerateBoxesLists();
731 //================================================================
733 //================================================================
734 void WxGUIScriptingInterface::OnMenuRegenerateAll(wxCommandEvent& WXUNUSED(event))
737 DoRegeneratePackageDoc("-a");
738 DoRegenerateBoxesLists();
740 //================================================================
743 //================================================================
745 * Event Handler for the plug package menu.
746 * This method prompts the user for the directory where the bbtkPackage file is
747 * located and associates the related package with the configuration file.
748 * @param event event not used.
752 void WxGUIScriptingInterface::OnMenuPlugPackage(wxCommandEvent& WXUNUSED(event))
754 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
757 _T("Select package directory"),
763 userResponse = FD->ShowModal();
764 if(userResponse==wxID_OK)
766 std::string path = wx2std (FD->GetPath()) ;
767 std::string fname = path + "/bbtkPackage";
768 std::cout << "Path chosen = \"" << FD->GetPath() << "\"" << std::endl;
769 if ( Utilities::FileExists( fname ) )
772 f.open(fname.c_str());
777 bbtk::ConfigurationFile::GetInstance().AddPackagePathsAndWrite( path );
779 DoRegeneratePackageDoc(pname);
780 DoRegenerateBoxesLists();
782 wxMessageBox(_T("Package successfully plugged"),_T("Plug package"),wxOK | wxICON_INFORMATION);
784 userResponse = wxID_CANCEL;
788 std::string err = "The directory \"" + path + "\" does not contain a 'bbtkPackage' file.";
791 err += "\nNote: If you are on Linux please select the folder and click \"Open\", don't enter in it.";
796 wxMessageBox(crea::std2wx(err),_T("Plug package"),wxOK | wxICON_ERROR);
799 }while(userResponse != wxID_CANCEL);
801 //================================================================
803 //================================================================
804 void WxGUIScriptingInterface::InterpreterUserViewHtmlPage(const std::string& page)
807 // std::cout << "WxGUIScriptingInterface::ShowHtmlPage('"<<page<<"')"<<std::endl;
808 if (mWxGUIHtmlBrowser->GoTo(s))
810 //EED mwxNotebook->ChangeSelection(1);
811 // mwxNotebook->SetSelection(1);
815 // std::cout << "ERROR html"<<std::endl;
818 //================================================================
821 //================================================================
822 void WxGUIScriptingInterface::InterpreterUserOnBreak()
824 // std::cout << "Break" << std::endl;
827 //================================================================
830 //================================================================
831 bool WxGUIScriptingInterface::WxGUIHtmlBrowserUserOnLinkClicked(const std::string& target)
833 size_t s = target.length();
834 if ((s>3) && (target[s-1]=='s')
835 && (target[s-2]=='b')
836 && (target[s-3]=='b')
837 && (target[s-4]=='.'))
839 mWxGUITextEditor->Open(target);
841 mwxNotebook->SetSelection(0);
843 mWxGUITextEditor->SetFocus();
847 if ((s>3) && (target[s-1]=='f')
848 && (target[s-2]=='d')
849 && (target[s-3]=='p')
850 && (target[s-4]=='.'))
858 // Open pdf in windows
859 int size=target.size();
860 int pos=target.rfind("\\");
861 std::string commandStart("start ");
862 std::string commandPath("/D \""+target.substr(0,pos) +"\"");
863 std::string commandPDF( target.substr(pos+1,size-pos+1) );
865 printf("EED WxGUIScriptingInterface::WxGUIHtmlBrowserUserOnLinkClicked cc %s \n",commandPath.c_str() );
867 while (commandPath.rfind("\\\\")!=-1 )
869 commandPath.erase( commandPath.rfind("\\\\") , 1 );
870 printf("EED WxGUIScriptingInterface::WxGUIHtmlBrowserUserOnLinkClicked cc %s \n",commandPath.c_str() );
873 std::string command = commandStart+commandPath+" "+commandPDF;
874 printf("EED WxGUIScriptingInterface::WxGUIHtmlBrowserUserOnLinkClicked BB %s \n",command.c_str() );
875 system( command.c_str() );
880 //================================================================
882 void WxGUIScriptingInterface::OnMenuWindowsCheck( wxCommandEvent& event,
885 bool checked = event.IsChecked();
886 bool shown = m_mgr.GetPane(w).IsShown();
887 // std::cout << "checked = "<<checked<<" - shown = "<<shown<<std::endl;
890 m_mgr.GetPane(w).Show(checked);
895 //================================================================
896 void WxGUIScriptingInterface::OnMenuWindowsFiles(wxCommandEvent& event)
898 OnMenuWindowsCheck(event,mWxGUITextEditor);
900 //================================================================
902 //================================================================
903 void WxGUIScriptingInterface::OnMenuWindowsHelp(wxCommandEvent& event)
905 OnMenuWindowsCheck(event,mWxGUIHtmlBrowser);
907 //================================================================
909 //================================================================
910 void WxGUIScriptingInterface::OnMenuWindowsMessages(wxCommandEvent& event)
912 OnMenuWindowsCheck(event,mWxGUIOutputMessages);
914 //================================================================
916 //================================================================
917 void WxGUIScriptingInterface::OnMenuWindowsCommand(wxCommandEvent& event)
919 OnMenuWindowsCheck(event,mWxGUICommand);
921 //================================================================
923 //================================================================
924 void WxGUIScriptingInterface::OnMenuWindowsSave( wxCommandEvent& WXUNUSED(event))
928 //================================================================
930 //================================================================
931 void WxGUIScriptingInterface::SavePerspective()
933 // std::cout << "Saving configuration..."<<std::endl;
934 std::string conf = wx2std(m_mgr.SavePerspective());
935 std::string fname = Utilities::MakeUserSettingsFullFileName("bbStudio.aui");
937 f.open(fname.c_str(), std::ios::out );
938 f << conf << std::endl;
941 // GetPosition(&x,&y);
942 // f << x << " " << y << std::endl;
948 f << w << " " << h << std::endl;
952 //================================================================
954 //================================================================
955 void WxGUIScriptingInterface::LoadPerspective()
958 Utilities::MakeUserSettingsFullFileName("bbStudio.aui");
959 if ( Utilities::FileExists( fname ))
961 // std::cout << "Loading configuration..."<<std::endl;
964 f.open(fname.c_str());
976 // std::cout << conf << std::endl;
980 m_mgr.LoadPerspective(std2wx(conf));
987 //================================================================
989 //================================================================
990 void WxGUIScriptingInterface::OnPaneClose(wxAuiManagerEvent& evt)
992 std::cout << "Closing panel '"<<evt.pane->name<<"'"<<std::endl;
994 // OnMenuWindowsCheck( wxCommandEvent& event, wxWindow* w);
996 //================================================================
999 //================================================================
1000 BEGIN_EVENT_TABLE(WxGUIScriptingInterface, wxFrame)
1001 EVT_CLOSE( WxGUIScriptingInterface::OnClose)
1002 EVT_MENU(ID_Menu_Quit, WxGUIScriptingInterface::OnMenuQuit)
1003 EVT_MENU(ID_Menu_About, WxGUIScriptingInterface::OnMenuAbout)
1004 EVT_MENU(ID_Menu_EditConfig, WxGUIScriptingInterface::OnMenuEditConfig)
1005 EVT_MENU(ID_Menu_CreatePackage, WxGUIScriptingInterface::OnMenuCreatePackage)
1006 EVT_MENU(ID_Menu_CreateBlackBox, WxGUIScriptingInterface::OnMenuCreateBlackBox)
1007 EVT_MENU(ID_Menu_ShowImageGraph, WxGUIScriptingInterface::OnMenuShowImageGraph)
1008 EVT_MENU(ID_Menu_RegeneratePackageDoc, WxGUIScriptingInterface::OnMenuRegeneratePackageDoc)
1009 EVT_MENU(ID_Menu_RegenerateBoxesLists, WxGUIScriptingInterface::OnMenuRegenerateBoxesLists)
1010 EVT_MENU(ID_Menu_RegenerateAll, WxGUIScriptingInterface::OnMenuRegenerateAll)
1011 EVT_MENU(ID_Menu_PlugPackage, WxGUIScriptingInterface::OnMenuPlugPackage)
1012 EVT_MENU(ID_Menu_Windows_Files, WxGUIScriptingInterface::OnMenuWindowsFiles)
1013 EVT_MENU(ID_Menu_Windows_Help, WxGUIScriptingInterface::OnMenuWindowsHelp)
1014 EVT_MENU(ID_Menu_Windows_Messages, WxGUIScriptingInterface::OnMenuWindowsMessages)
1015 EVT_MENU(ID_Menu_Windows_Command, WxGUIScriptingInterface::OnMenuWindowsCommand)
1016 EVT_MENU(ID_Menu_Windows_Save, WxGUIScriptingInterface::OnMenuWindowsSave)
1017 EVT_MENU(ID_Menu_Windows_PackageBrowser, WxGUIScriptingInterface::OnMenuWindowsPackageBrowser)
1018 EVT_AUI_PANE_CLOSE(WxGUIScriptingInterface::OnPaneClose)
1019 // EVT_BUTTON(ID_Button_Run, WxGUIScriptingInterface::OnButtonRun )
1021 //================================================================
1026 #endif //_USE_WXWIDGETS_