1 /*=========================================================================
3 Module: $RCSfile: bbtkWxGUIScriptingInterface.cxx,v $
5 Date: $Date: 2010/03/30 07:33:43 $
6 Version: $Revision: 1.43 $
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"
57 #include <wx/tipwin.h>
58 #include <wx/splash.h>
61 //#include "icons/cc_run.xpm"
71 ID_Menu_CreatePackage,
72 ID_Menu_CreateBlackBox,
73 ID_Menu_ShowImageGraph,
74 ID_Menu_RegeneratePackageDoc,
75 ID_Menu_RegenerateBoxesLists,
76 ID_Menu_RegenerateAll,
78 ID_Menu_Windows_Files,
80 ID_Menu_Windows_Messages,
81 ID_Menu_Windows_Command,
83 ID_Menu_Windows_PackageBrowser
88 //================================================================
89 WxGUIScriptingInterface::WxGUIScriptingInterface( wxWindow *parent )
90 : wxFrame((wxFrame *)parent, -1, _T("bbStudio"),
91 wxDefaultPosition, wxSize(1200,800) )
93 m_mgr.SetManagedWindow(this);
95 mInterpreter = bbtk::Interpreter::New();
96 mInterpreter->SetUser(this);
97 mInterpreter->SetCommandLine(true);
98 mInterpreter->SetThrow(true);
99 // mInterpreter->AddBreakObserver
100 //boost::bind( &WxGUIScriptingInterface::InterpreterUserOnBreak, this ));
103 wxInitAllImageHandlers();
105 wxMenu *menuFile = new wxMenu;
106 menuFile->Append( ID_Menu_EditConfig, _T("Open bbtk &Config file") );
107 menuFile->Append( ID_Menu_Quit, _T("&Quit") );
109 wxMenu *menuAbout = new wxMenu;
110 menuAbout->Append( ID_Menu_About, _T("&About...") );
112 wxMenu *menuTools = new wxMenu;
113 menuTools->Append( ID_Menu_CreatePackage, _T("Create &package") );
114 menuTools->Append( ID_Menu_CreateBlackBox, _T("Create &black box") );
115 menuTools->Append( ID_Menu_PlugPackage, _T("&Plug package") );
116 menuTools->AppendSeparator();
117 menuTools->Append( ID_Menu_RegeneratePackageDoc,_T("Regenerate package &doc") );
118 menuTools->Append( ID_Menu_RegenerateBoxesLists,_T("Regenerate boxes &lists") );
119 menuTools->Append( ID_Menu_RegenerateAll,_T("Regenerate &all") );
120 menuTools->AppendSeparator();
121 menuTools->Append( ID_Menu_ShowImageGraph, _T("&Show last graph") );
123 wxMenu *menuWindows = new wxMenu;
124 menuWindows->AppendCheckItem(ID_Menu_Windows_Files,
125 _T("Show 'files' panel") )->Check();
126 menuWindows->AppendCheckItem(ID_Menu_Windows_Help,
127 _T("Show 'help' panel") )->Check();
128 menuWindows->AppendCheckItem(ID_Menu_Windows_Messages,
129 _T("Show 'messages' panel") )->Check();
130 menuWindows->AppendCheckItem(ID_Menu_Windows_Command,
131 _T("Show 'command' panel") )->Check();
132 menuWindows->AppendSeparator();
133 menuWindows->Append( ID_Menu_Windows_PackageBrowser, _T("Start Package &Browser") );
135 // menuWindows->AppendSeparator();
136 // menuWindows->Append ( ID_Menu_Windows_Save, _T("Save interface configuration"));
138 wxMenu *menuOptions = new wxMenu;
139 mwxMenuItemReset = menuOptions->AppendCheckItem(-1,
140 _T("Reset before running") );
141 mwxMenuItemReset->Check();
143 wxMenuBar *menuBar = new wxMenuBar;
144 menuBar->Append( menuFile, _T("&File") );
145 menuBar->Append( menuTools, _T("&Tools") );
146 menuBar->Append( menuOptions, _T("&Options") );
147 menuBar->Append( menuWindows, _T("&Windows") );
148 menuBar->Append( menuAbout, _T("About") );
150 SetMenuBar( menuBar );
155 SetStatusText( _T("Welcome to bbStudio !") );
158 // Panes (Files, Messages, Help, Command)
159 mWxGUITextEditor = new WxGUITextEditor(this,this);
160 mWxGUITextEditor->SetFileNameFilter("*.bbs");
162 mWxGUIHtmlBrowser = new WxGUIHtmlBrowser(this,wxSize(200,0),this);
164 mWxGUIOutputMessages = new WxGUIOutputMessages(this);
166 mWxGUICommand = new WxGUICommand(this,this);
168 mWxGUICommand->SetFocus();
173 mwxNotebook = new wxAuiNotebook(this,
179 | wxAUI_NB_TAB_EXTERNAL_MOVE
180 //| wxAUI_NB_WINDOWLIST_BUTTON
181 //|wxAUI_NB_SCROLL_BUTTONS
182 // | wxAUI_NB_CLOSE_BUTTON
183 //| wxAUI_NB_CLOSE_ON_ACTIVE_TAB
184 //| wxAUI_NB_CLOSE_ON_ALL_TABS
188 mwxNotebook->AddPage(mWxGUITextEditor,_T("Files"),true);
189 mwxNotebook->AddPage(mWxGUIHtmlBrowser,_T("Help"),true);
191 mwxNotebook->AddPage(mWxGUIOutputMessages,_T("Messages"),true);
193 mwxNotebook->AddPage(mWxGUICommand,_T("Command"),true);
196 m_mgr.AddPane(mwxNotebook,
197 wxAuiPaneInfo().Name(wxT("nb"))
198 .CaptionVisible(false)
199 .MinimizeButton(false)
200 .MaximizeButton(false)
202 // .MinSize(wxSize(100,100))
207 m_mgr.AddPane(mWxGUITextEditor,
208 wxAuiPaneInfo().Name(wxT("editor_content"))
209 .Caption(wxT("Files"))
210 .MinimizeButton(true)
211 .MaximizeButton(true)
213 .MinSize(wxSize(100,100))
216 m_mgr.AddPane(mWxGUIHtmlBrowser,
217 wxAuiPaneInfo().Name(wxT("browser_content"))
218 .Caption(wxT("Help"))
219 .MinimizeButton(true)
220 .MaximizeButton(true)
223 .MinSize(wxSize(400,100))
226 m_mgr.AddPane(mWxGUIOutputMessages,
227 wxAuiPaneInfo().Name(wxT("messages_content"))
228 .Caption(wxT("Messages"))
229 .MinimizeButton(true)
230 .MaximizeButton(true)
232 .MinSize(wxSize(100,100))
235 m_mgr.AddPane(mWxGUICommand,
236 wxAuiPaneInfo().Name(wxT("command_content"))
237 .Caption(wxT("Command"))
238 .MinimizeButton(true)
239 .MaximizeButton(true)
242 .MinSize(wxSize(100,100))
246 // parent window of all bbtk windows will be a child of this
247 // Wx::SetTopWindowParent(this);
248 Wx::SetTopWindow(this);
249 // Wx::SetAutoDestroyTopWindow(false);
250 // Add the method OnWxSignal as a Wx::Signal observer
251 //bbtkAddWxSignalObserver(WxGUIPackageBrowser2Window::OnWxSignal);
253 //.PaneBorder(false));
254 // Load the interface appearance saved on last closing
257 // Done in LoadPerspective
262 // mwxNotebook->SetSelection(1);
263 mWxGUIHtmlBrowser->GoHome();
266 // LoadPerspective();
271 wxSplashScreen* splash;
272 long style = wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT;
273 if (ConfigurationFile::GetInstance().DotBbtkIsNew())
274 style = wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT;
275 std::string splash_file = ConfigurationFile::GetInstance().Get_data_path();
276 splash_file += "/kernel/icons/bbStudioSplashScreen.png";
278 if (bitmap.LoadFile(std2wx(splash_file),wxBITMAP_TYPE_PNG))
280 new wxSplashScreen(bitmap,
282 1000, 0, -1, wxDefaultPosition, wxDefaultSize,
283 wxSIMPLE_BORDER|wxSTAY_ON_TOP);
286 if (ConfigurationFile::GetInstance().DotBbtkIsNew())
289 DoRegeneratePackageDoc("-a");
290 DoRegenerateBoxesLists();
293 wxTipWindow* tip = new wxTipWindow(this,
294 _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);
295 tip->CenterOnParent();
298 if (splash) splash->Destroy();
302 //================================================================
304 //================================================================
305 WxGUIScriptingInterface::~WxGUIScriptingInterface()
307 bbtkDebugMessage("widget",9,"bbStudio::~bbStudio()"<<std::endl);
311 //================================================================
313 //================================================================
314 void WxGUIScriptingInterface::OnClose(wxCloseEvent& event)
316 bbtkDebugMessage("widget",9,"bbStudio::OnClose()"<<std::endl);
317 //Wx::SetWindowsHaveBeenDestroyedByParent();
318 //mInterpreter.reset();
319 wxWindowList& list = GetChildren();
320 wxWindowList::iterator iter;
321 for (iter = list.begin(); iter != list.end(); ++iter)
327 //================================================================
330 //================================================================
331 void WxGUIScriptingInterface::Open(const std::string& filename)
333 mWxGUITextEditor->Open(filename);
335 //================================================================
337 catch (BreakException e) \
339 std::cout << "* BREAK"<<std::endl; \
340 if (e.IsInScriptFile()) \
341 std::cout << "* FILE : '"<<e.GetScriptFile()<<"'"<<std::endl; \
342 std::cout << "* LINE : "<<e.GetScriptLine()<<std::endl; \
344 catch (QuitException e) \
346 std::cout << "* QUIT"<<std::endl; \
347 if (e.IsInScriptFile()) \
348 std::cout << "* FILE : '"<<e.GetScriptFile()<<"'"<<std::endl; \
349 std::cout << "* LINE : "<<e.GetScriptLine()<<std::endl; \
353 #define CATCH_MACRO \
354 catch (InterpreterException e) \
356 if (e.GetErrorMessage()=="quit") \
358 std::cerr << "* QUIT ENCOUNTERED"<<std::endl; \
359 if (e.IsInScriptFile()) \
360 std::cerr << "* FILE : '"<<e.GetScriptFile()<<"'"<<std::endl; \
361 std::cerr << "* LINE : "<<e.GetScriptLine()<<std::endl; \
363 else if (e.GetErrorMessage()=="break") \
366 std::cerr << "* BREAK"<<std::endl; \
367 if (e.IsInScriptFile()) \
368 std::cerr << "* FILE : '"<<e.GetScriptFile()<<"'"<<std::endl; \
369 std::cerr << "* LINE : "<<e.GetScriptLine()<<std::endl; \
373 std::cerr << "* ERROR : "<<e.GetErrorMessage()<<std::endl; \
374 if (e.IsInScriptFile()) \
375 std::cerr << "* FILE : '"<<e.GetScriptFile()<<"'"<<std::endl; \
376 std::cerr << "* LINE : "<<e.GetScriptLine()<<std::endl; \
377 int lev = bbtk::MessageManager::GetMessageLevel("Error"); \
379 std::cerr << "* Exception thrown : "<<std::endl; \
380 std::cerr << "* OBJECT : " <<e.GetObject()<<std::endl; \
381 std::cerr << "* FILE : " <<e.GetSourceFile()<<std::endl; \
386 //================================================================
387 void WxGUIScriptingInterface::WxGUICommandEnter(const std::string& command)
391 mWxGUIOutputMessages->Print(s,wxRED);
395 mInterpreter->InterpretLine( command );
399 //================================================================
401 //================================================================
402 /// Runs the interpretation of a file
403 bool WxGUIScriptingInterface::InterpretFile( const std::string& filename)
407 mInterpreter->InterpretFile(filename);
412 //================================================================
415 //================================================================
416 void WxGUIScriptingInterface::WxGUITextEditorGraphSimple()
418 WxGUICommandEnter("exec freeze_no_error");
419 WxGUITextEditorRun();
420 WxGUICommandEnter("exec unfreeze");
421 WxGUICommandEnter("graph");
423 //================================================================
425 //================================================================
426 void WxGUIScriptingInterface::WxGUITextEditorGraphDetail()
428 WxGUICommandEnter("exec freeze_no_error");
429 WxGUITextEditorRun();
430 WxGUICommandEnter("exec unfreeze");
431 WxGUICommandEnter("graph . 1");
433 //================================================================
436 //================================================================
437 void WxGUIScriptingInterface::WxGUITextEditorRunBBI()
439 std::string separator = ConfigurationFile::GetInstance().Get_file_separator ();
440 std::string dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
441 std::string filename = dir + separator + "tmp_bbtk.bbs";
442 mWxGUITextEditor->GetCurrentPage()->SaveFile(filename);
444 std::string command = "\"";
450 command += ConfigurationFile::GetInstance().Get_bin_path();
452 command += separator + "bbi.app/Contents/MacOS/bbi\" ";
454 command += separator + "bbi\" ";
456 command += "\""+filename + "\"";
464 printf ("EED WxGUIScriptingInterface::WxGUITextEditorRunBBI %s \n" , command.c_str() );
465 system( command.c_str() );
467 //================================================================
470 //================================================================
471 void WxGUIScriptingInterface::WxGUITextEditorRun()
473 // wxString temp = mWxGUIHtmlBrowser->GetCurrentPage();
474 std::stringstream* buf = new std::stringstream;
475 (*buf) << mWxGUITextEditor->GetCurrentPage()->GetText();
480 if (mwxMenuItemReset->IsChecked()) WxGUICommandEnter("reset");
481 mInterpreter->InterpretBuffer(buf);
486 mInterpreter->InterpretCurrentStreams();
488 // std::cout << "EO RUN"<<std::endl;
491 // std::cout << "EO RUN 3"<<std::endl;
493 //================================================================
495 //================================================================
496 void WxGUIScriptingInterface::OnMenuQuit(wxCommandEvent& WXUNUSED(event))
498 if (!mWxGUITextEditor->CloseAllPages()) return;
501 //================================================================
504 //================================================================
505 void WxGUIScriptingInterface::OnMenuAbout(wxCommandEvent& WXUNUSED(event))
509 wxMessageBox(_T(" bbStudio\nThe Black Box Toolkit Development Studio\n(c) CREATIS-LRMN 2008\n\n http://www.creatis.insa-lyon.fr/creatools"),
510 _T("About ..."), wxOK | wxICON_INFORMATION,
513 //================================================================
516 //================================================================
517 void WxGUIScriptingInterface::OnMenuEditConfig(wxCommandEvent& WXUNUSED(event))
520 std::string configFile =
521 ConfigurationFile::GetInstance().Get_config_xml_full_path();
523 wxMessageDialog ww(NULL,_T("If you change the bbtk_config.xml, you have to restart this appliaction..."), _T("Alert !"), wxOK);
526 //================================================================
528 //================================================================
529 void WxGUIScriptingInterface::OnMenuWindowsPackageBrowser(wxCommandEvent& WXUNUSED(event))
532 WxGUIPackageBrowser2Window *helpbrowser = new
533 WxGUIPackageBrowser2Window(this,_T("Package Browser"), wxSize(600,600) );
538 WxGUIPackageBrowser2 *browser = new WxGUIPackageBrowser2(this);
539 browser->IncludeAll();
542 // mwxNotebook->AddPage(browser,_T("Package Browser"),true);
545 m_mgr.AddPane(browser,
546 wxAuiPaneInfo().Name(wxT("package_brower"))
547 .Caption(wxT("Package browser"))
548 .MinimizeButton(true)
549 .MaximizeButton(true)
552 .MinSize(wxSize(100,100))
557 //================================================================
561 //================================================================
562 void WxGUIScriptingInterface::OnMenuCreatePackage(wxCommandEvent& WXUNUSED(event))
565 std::string command("toolsbbtk/appli/GUICreatePackage");
566 bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
568 Interpreter::Pointer I = Interpreter::New();
569 I->InterpretFile(command);
571 std::string command("reset");
572 mWxGUICommand->SendCommand(command);
573 command = "include toolsbbtk/appli/GUICreatePackage";
574 bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
575 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;
613 std::string strappli="start ";
616 std::string strappli="open ";
618 std::string strappli="gnome-open ";
622 std::string strcommand = strappli +pack_path+"/workspace_workspacePrototype.png";
623 // std::cout << "system: " << strcommand << std::endl;
624 system ( strcommand.c_str() );
627 //================================================================
629 void WxGUIScriptingInterface::DoRegeneratePackageDoc( const std::string& pack )
631 std::string mess("Regenerating doc for package '");
635 mess = "Regenerating doc for all packages";
636 mess += " ... please wait";
638 SetStatusText( std2wx(mess) );
646 command += ConfigurationFile::GetInstance().Get_bin_path();
647 command += ConfigurationFile::GetInstance().Get_file_separator();
648 command += "bbRegeneratePackageDoc";
652 command += " " + pack + " -q";
653 bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
656 if ( ! system ( command.c_str() ) )
658 SetStatusText( _T("Done !"));
660 wxMessageBox(_T("Done !"),_T("Regenerate package '")
661 +std2wx(pack)+_T("' doc"),
662 wxOK | wxICON_INFORMATION);
667 SetStatusText( _T("Done !"));
668 wxString err(_T("An error occured while running '"));
669 err += bbtk::std2wx(command) + _T("'");
670 wxMessageBox(err,_T("Regenerate package doc"),wxOK | wxICON_ERROR);
678 //================================================================
679 void WxGUIScriptingInterface::OnMenuRegeneratePackageDoc(wxCommandEvent& WXUNUSED(event))
681 wxString name = wxGetTextFromUser(_T("Enter package name (-a for all)"),
682 _T("Regenerate package doc"),
684 if (name.IsEmpty()) return;
685 std::string pack = bbtk::wx2std(name);
687 DoRegeneratePackageDoc(pack);
689 //================================================================
692 //================================================================
693 void WxGUIScriptingInterface::DoRegenerateBoxesLists()
695 SetStatusText( _T("Regenerating boxes lists ... please wait") );
702 command += ConfigurationFile::GetInstance().Get_bin_path();
703 command += ConfigurationFile::GetInstance().Get_file_separator();
704 command += "bbRegenerateBoxesLists";
709 bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
711 if ( ! system ( command.c_str() ) )
713 SetStatusText( _T("Done !"));
715 wxMessageBox(_T("Done !"),_T("Regenerate boxes lists"),
716 wxOK | wxICON_INFORMATION);
721 SetStatusText( _T("Done !"));
722 wxString err(_T("An error occured while running '"));
723 err += bbtk::std2wx(command) + _T("'");
724 wxMessageBox(err,_T("Regenerate boxes lists"),wxOK | wxICON_ERROR);
727 //================================================================
730 //================================================================
731 void WxGUIScriptingInterface::OnMenuRegenerateBoxesLists(wxCommandEvent& WXUNUSED(event))
733 DoRegenerateBoxesLists();
735 //================================================================
737 //================================================================
738 void WxGUIScriptingInterface::OnMenuRegenerateAll(wxCommandEvent& WXUNUSED(event))
741 DoRegeneratePackageDoc("-a");
742 DoRegenerateBoxesLists();
744 //================================================================
747 //================================================================
748 void WxGUIScriptingInterface::OnMenuPlugPackage(wxCommandEvent& WXUNUSED(event))
750 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
753 _T("Select package directory"),
757 if (FD->ShowModal()==wxID_OK)
759 std::string path = wx2std (FD->GetPath()) ;
760 std::string fname = path + "/bbtkPackage";
761 if ( ! Utilities::FileExists( fname ) )
763 wxString err(_T("The directory does not contain a 'bbtkPackage' file"));
764 wxMessageBox(err,_T("Plug package"),wxOK | wxICON_ERROR);
769 f.open(fname.c_str());
775 bbtk::ConfigurationFile::GetInstance().AddPackagePathsAndWrite( path );
777 DoRegeneratePackageDoc(pname);
778 DoRegenerateBoxesLists();
782 //================================================================
784 //================================================================
785 void WxGUIScriptingInterface::InterpreterUserViewHtmlPage(const std::string& page)
788 // std::cout << "WxGUIScriptingInterface::ShowHtmlPage('"<<page<<"')"<<std::endl;
789 if (mWxGUIHtmlBrowser->GoTo(s))
791 //EED mwxNotebook->ChangeSelection(1);
792 // mwxNotebook->SetSelection(1);
796 // std::cout << "ERROR html"<<std::endl;
799 //================================================================
802 //================================================================
803 void WxGUIScriptingInterface::InterpreterUserOnBreak()
805 // std::cout << "Break" << std::endl;
808 //================================================================
811 //================================================================
812 bool WxGUIScriptingInterface::WxGUIHtmlBrowserUserOnLinkClicked(const std::string& target)
814 size_t s = target.length();
815 if ((s>3) && (target[s-1]=='s')
816 && (target[s-2]=='b')
817 && (target[s-3]=='b')
818 && (target[s-4]=='.'))
820 mWxGUITextEditor->Open(target);
822 mwxNotebook->SetSelection(0);
824 mWxGUITextEditor->SetFocus();
828 if ((s>3) && (target[s-1]=='f')
829 && (target[s-2]=='d')
830 && (target[s-3]=='p')
831 && (target[s-4]=='.'))
839 // Open pdf in windows
840 int size=target.size();
841 int pos=target.rfind("\\");
842 std::string commandStart("start ");
843 std::string commandPath("/D \""+target.substr(0,pos) +"\"");
844 std::string commandPDF( target.substr(pos+1,size-pos+1) );
846 printf("EED WxGUIScriptingInterface::WxGUIHtmlBrowserUserOnLinkClicked cc %s \n",commandPath.c_str() );
848 while (commandPath.rfind("\\\\")!=-1 )
850 commandPath.erase( commandPath.rfind("\\\\") , 1 );
851 printf("EED WxGUIScriptingInterface::WxGUIHtmlBrowserUserOnLinkClicked cc %s \n",commandPath.c_str() );
854 std::string command = commandStart+commandPath+" "+commandPDF;
855 printf("EED WxGUIScriptingInterface::WxGUIHtmlBrowserUserOnLinkClicked BB %s \n",command.c_str() );
856 system( command.c_str() );
861 //================================================================
863 void WxGUIScriptingInterface::OnMenuWindowsCheck( wxCommandEvent& event,
866 bool checked = event.IsChecked();
867 bool shown = m_mgr.GetPane(w).IsShown();
868 // std::cout << "checked = "<<checked<<" - shown = "<<shown<<std::endl;
871 m_mgr.GetPane(w).Show(checked);
877 //================================================================
878 void WxGUIScriptingInterface::OnMenuWindowsFiles(wxCommandEvent& event)
880 OnMenuWindowsCheck(event,mWxGUITextEditor);
882 //================================================================
884 //================================================================
885 void WxGUIScriptingInterface::OnMenuWindowsHelp(wxCommandEvent& event)
887 OnMenuWindowsCheck(event,mWxGUIHtmlBrowser);
889 //================================================================
891 //================================================================
892 void WxGUIScriptingInterface::OnMenuWindowsMessages(wxCommandEvent& event)
894 OnMenuWindowsCheck(event,mWxGUIOutputMessages);
896 //================================================================
898 //================================================================
899 void WxGUIScriptingInterface::OnMenuWindowsCommand(wxCommandEvent& event)
901 OnMenuWindowsCheck(event,mWxGUICommand);
903 //================================================================
905 //================================================================
906 void WxGUIScriptingInterface::OnMenuWindowsSave( wxCommandEvent& WXUNUSED(event))
910 //================================================================
912 //================================================================
913 void WxGUIScriptingInterface::SavePerspective()
915 // std::cout << "Saving configuration..."<<std::endl;
916 std::string conf = wx2std(m_mgr.SavePerspective());
917 std::string fname = Utilities::MakeUserSettingsFullFileName("bbStudio.aui");
919 f.open(fname.c_str(), std::ios::out );
920 f << conf << std::endl;
923 // GetPosition(&x,&y);
924 // f << x << " " << y << std::endl;
930 f << w << " " << h << std::endl;
934 //================================================================
936 //================================================================
937 void WxGUIScriptingInterface::LoadPerspective()
940 Utilities::MakeUserSettingsFullFileName("bbStudio.aui");
941 if ( Utilities::FileExists( fname ))
943 // std::cout << "Loading configuration..."<<std::endl;
946 f.open(fname.c_str());
958 // std::cout << conf << std::endl;
962 m_mgr.LoadPerspective(std2wx(conf));
969 //================================================================
971 //================================================================
972 void WxGUIScriptingInterface::OnPaneClose(wxAuiManagerEvent& evt)
974 std::cout << "Closing panel '"<<evt.pane->name<<"'"<<std::endl;
976 // OnMenuWindowsCheck( wxCommandEvent& event, wxWindow* w);
978 //================================================================
981 //================================================================
982 BEGIN_EVENT_TABLE(WxGUIScriptingInterface, wxFrame)
983 EVT_CLOSE( WxGUIScriptingInterface::OnClose)
984 EVT_MENU(ID_Menu_Quit, WxGUIScriptingInterface::OnMenuQuit)
985 EVT_MENU(ID_Menu_About, WxGUIScriptingInterface::OnMenuAbout)
986 EVT_MENU(ID_Menu_EditConfig, WxGUIScriptingInterface::OnMenuEditConfig)
987 EVT_MENU(ID_Menu_CreatePackage, WxGUIScriptingInterface::OnMenuCreatePackage)
988 EVT_MENU(ID_Menu_CreateBlackBox, WxGUIScriptingInterface::OnMenuCreateBlackBox)
989 EVT_MENU(ID_Menu_ShowImageGraph, WxGUIScriptingInterface::OnMenuShowImageGraph)
990 EVT_MENU(ID_Menu_RegeneratePackageDoc, WxGUIScriptingInterface::OnMenuRegeneratePackageDoc)
991 EVT_MENU(ID_Menu_RegenerateBoxesLists, WxGUIScriptingInterface::OnMenuRegenerateBoxesLists)
992 EVT_MENU(ID_Menu_RegenerateAll, WxGUIScriptingInterface::OnMenuRegenerateAll)
993 EVT_MENU(ID_Menu_PlugPackage, WxGUIScriptingInterface::OnMenuPlugPackage)
994 EVT_MENU(ID_Menu_Windows_Files, WxGUIScriptingInterface::OnMenuWindowsFiles)
995 EVT_MENU(ID_Menu_Windows_Help, WxGUIScriptingInterface::OnMenuWindowsHelp)
996 EVT_MENU(ID_Menu_Windows_Messages, WxGUIScriptingInterface::OnMenuWindowsMessages)
997 EVT_MENU(ID_Menu_Windows_Command, WxGUIScriptingInterface::OnMenuWindowsCommand)
998 EVT_MENU(ID_Menu_Windows_Save, WxGUIScriptingInterface::OnMenuWindowsSave)
999 EVT_MENU(ID_Menu_Windows_PackageBrowser, WxGUIScriptingInterface::OnMenuWindowsPackageBrowser)
1000 EVT_AUI_PANE_CLOSE(WxGUIScriptingInterface::OnPaneClose)
1001 // EVT_BUTTON(ID_Button_Run, WxGUIScriptingInterface::OnButtonRun )
1003 //================================================================
1008 #endif //_USE_WXWIDGETS_