]> Creatis software - bbtk.git/blob - kernel/src/bbtkWxGUIScriptingInterface.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkWxGUIScriptingInterface.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbtkWxGUIScriptingInterface.cxx,v $
5   Language:  C++
6   Date:      $Date: 2008/10/15 15:09:45 $
7   Version:   $Revision: 1.27 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*//**
18  * \brief Short description in one line
19  * 
20  * Long description which 
21  * can span multiple lines
22  */
23 /**
24  * \file 
25  * \brief 
26  */
27 /**
28  * \class bbtk::
29  * \brief 
30  */
31
32
33 #ifdef _USE_WXWIDGETS_
34
35 #include <iostream>     
36 #include "bbtkWxGUIScriptingInterface.h"
37 #include "bbtkWxBlackBox.h"
38 #include "bbtkConfigurationFile.h"
39 #include "bbtkWxStreamRedirector.h"
40 #include "bbtkUtilities.h"
41
42 #include <wx/tipwin.h>
43
44 //#include "icons/cc_run.xpm"
45
46 namespace bbtk
47 {
48
49     enum
50     {
51       ID_Menu_Quit = 1,
52       ID_Menu_About,
53       ID_Menu_EditConfig,
54       ID_Menu_CreatePackage,
55       ID_Menu_CreateBlackBox,
56       ID_Menu_ShowImageGraph,
57       ID_Menu_RegeneratePackageDoc,
58       ID_Menu_RegenerateBoxesLists,
59       ID_Menu_RegenerateAll,
60       ID_Menu_PlugPackage,
61       ID_Menu_Windows_Files,
62       ID_Menu_Windows_Help,
63       ID_Menu_Windows_Messages,
64       ID_Menu_Windows_Command,
65       ID_Menu_Windows_Save,
66       ID_Menu_Windows_PackageBrowser
67       //      ID_Button_Run
68     };
69     
70   
71   //================================================================
72   WxGUIScriptingInterface::WxGUIScriptingInterface( wxWindow *parent )
73     : wxFrame((wxFrame *)parent, -1, _T("bbStudio"), 
74               wxDefaultPosition, wxSize(1200,800) )
75   {     
76     //    m_mgr = new wxAuiManager(this);
77     m_mgr.SetManagedWindow(this);
78     
79     mInterpreter = bbtk::Interpreter::New();
80     mInterpreter->SetUser(this);
81     mInterpreter->SetCommandLine(true);
82     mInterpreter->SetThrow(true);
83     
84     //==============
85     // Menu
86     wxInitAllImageHandlers();
87     
88     wxMenu *menuFile = new wxMenu;
89     menuFile->Append( ID_Menu_EditConfig, _T("Open bbtk &Config file") );
90     menuFile->Append( ID_Menu_Quit, _T("&Quit") );
91     
92     wxMenu *menuAbout = new wxMenu;
93     menuAbout->Append( ID_Menu_About, _T("&About...") );
94
95     wxMenu *menuTools = new wxMenu;
96     menuTools->Append( ID_Menu_CreatePackage, _T("Create &package") );
97     menuTools->Append( ID_Menu_CreateBlackBox, _T("Create &black box") );
98     menuTools->Append( ID_Menu_PlugPackage, _T("&Plug package") );
99     menuTools->AppendSeparator();
100     menuTools->Append( ID_Menu_RegeneratePackageDoc,_T("Regenerate package &doc") );
101     menuTools->Append( ID_Menu_RegenerateBoxesLists,_T("Regenerate boxes &lists") );
102     menuTools->Append( ID_Menu_RegenerateAll,_T("Regenerate &all") );
103     menuTools->AppendSeparator();
104     menuTools->Append( ID_Menu_ShowImageGraph, _T("&Show last image graph") );
105
106     wxMenu *menuWindows = new wxMenu;
107     menuWindows->AppendCheckItem(ID_Menu_Windows_Files,
108                                  _T("Show 'files' panel") )->Check();
109     menuWindows->AppendCheckItem(ID_Menu_Windows_Help,
110                                  _T("Show 'help' panel") )->Check();
111     menuWindows->AppendCheckItem(ID_Menu_Windows_Messages,
112                                  _T("Show 'messages' panel") )->Check();
113     menuWindows->AppendCheckItem(ID_Menu_Windows_Command,
114                                  _T("Show 'command' panel") )->Check();
115     menuWindows->AppendSeparator();
116     menuWindows->Append( ID_Menu_Windows_PackageBrowser, _T("Launch Package &Browser") );
117     
118     //    menuWindows->AppendSeparator();
119     //    menuWindows->Append ( ID_Menu_Windows_Save, _T("Save interface configuration"));
120
121     wxMenu *menuOptions = new wxMenu;
122     mwxMenuItemReset = menuOptions->AppendCheckItem(-1,
123                                                     _T("Reset before running") );
124     mwxMenuItemReset->Check();
125
126     wxMenuBar *menuBar = new wxMenuBar;
127     menuBar->Append( menuFile, _T("&File") );
128     menuBar->Append( menuTools, _T("&Tools") );
129     menuBar->Append( menuOptions, _T("&Options") );
130     menuBar->Append( menuWindows, _T("&Windows") );
131     menuBar->Append( menuAbout, _T("About") );
132     
133     SetMenuBar( menuBar );
134     
135     //=== 
136     // Status bar
137     CreateStatusBar();
138     SetStatusText( _T("Welcome to bbStudio !") );
139     
140     //===
141     // Panes (Files, Messages, Help, Command)
142     mWxGUITextEditor = new WxGUITextEditor(this,this);
143     mWxGUITextEditor->SetFileNameFilter("*.bbs");
144         
145     mWxGUIHtmlBrowser = new WxGUIHtmlBrowser(this,wxSize(200,0),this);
146
147     mWxGUIOutputMessages = new WxGUIOutputMessages(this);
148
149     mWxGUICommand = new WxGUICommand(this,this);
150    
151     mWxGUICommand->SetFocus();
152
153  
154 #if NOTEBOOK
155
156     mwxNotebook = new wxAuiNotebook(this,  
157                                     -1,
158                                     wxPoint(0, 0),
159                                     wxSize(500,500),
160                                     wxAUI_NB_TAB_SPLIT 
161                                     | wxAUI_NB_TAB_MOVE
162                                     | wxAUI_NB_TAB_EXTERNAL_MOVE
163                                     //| wxAUI_NB_WINDOWLIST_BUTTON
164                                     //|wxAUI_NB_SCROLL_BUTTONS
165                                     // | wxAUI_NB_CLOSE_BUTTON 
166                                     //| wxAUI_NB_CLOSE_ON_ACTIVE_TAB
167                                     //| wxAUI_NB_CLOSE_ON_ALL_TABS
168                                     | wxNO_BORDER);
169   
170
171     mwxNotebook->AddPage(mWxGUITextEditor,_T("Files"),true);
172     mwxNotebook->AddPage(mWxGUIHtmlBrowser,_T("Help"),true);
173
174     mwxNotebook->AddPage(mWxGUIOutputMessages,_T("Messages"),true);
175
176     mwxNotebook->AddPage(mWxGUICommand,_T("Command"),true);
177
178
179     m_mgr.AddPane(mwxNotebook,
180                   wxAuiPaneInfo().Name(wxT("nb"))
181                   .CaptionVisible(false)
182                   .MinimizeButton(false)
183                   .MaximizeButton(false)
184                   .Center()
185                   //              .MinSize(wxSize(100,100))
186                   );   
187 #else 
188
189     //
190     m_mgr.AddPane(mWxGUITextEditor,
191                   wxAuiPaneInfo().Name(wxT("editor_content"))
192                   .Caption(wxT("Files"))
193                   .MinimizeButton(true)
194                   .MaximizeButton(true)
195                   .Center()
196                   .MinSize(wxSize(100,100))
197                   );   
198   
199     m_mgr.AddPane(mWxGUIHtmlBrowser,
200                   wxAuiPaneInfo().Name(wxT("browser_content"))
201                   .Caption(wxT("Help"))
202                   .MinimizeButton(true)
203                   .MaximizeButton(true)
204                   .Right()
205                   .Layer(2)
206                   .MinSize(wxSize(400,100))
207                   );
208
209     m_mgr.AddPane(mWxGUIOutputMessages,
210                   wxAuiPaneInfo().Name(wxT("messages_content"))
211                   .Caption(wxT("Messages"))
212                   .MinimizeButton(true)
213                   .MaximizeButton(true)
214                   .Bottom()
215                   .MinSize(wxSize(100,100))
216                   );
217     m_mgr.AddPane(mWxGUICommand,
218                   wxAuiPaneInfo().Name(wxT("command_content"))
219                   .Caption(wxT("Command"))
220                   .MinimizeButton(true)
221                   .MaximizeButton(true)
222                   .Bottom()
223                   .Layer(1)
224                   .MinSize(wxSize(100,100))
225                   );     
226 #endif
227
228     // parent window of all bbtk windows will be a child of this
229     Wx::SetTopWindowParent(this);
230     // Add the method OnWxSignal as a Wx::Signal observer 
231     //bbtkAddWxSignalObserver(WxGUIPackageBrowser2Window::OnWxSignal);
232
233     //.PaneBorder(false)); 
234     // Load the interface appearance saved on last closing
235     LoadPerspective();
236
237     // Done in LoadPerspective
238     //    m_mgr.Update();
239         
240     SetAutoLayout(true);
241     Layout();
242     //    mwxNotebook->SetSelection(1);
243     mWxGUIHtmlBrowser->GoHome();
244 //    Refresh();
245     m_mgr.Update();
246     //   LoadPerspective();
247
248
249     wxTipWindow* tip = new wxTipWindow(this,
250                                        _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);
251     tip->CenterOnParent();
252     tip->Show();
253   }
254   //================================================================
255
256  //================================================================
257   WxGUIScriptingInterface::~WxGUIScriptingInterface()
258   {
259     SavePerspective();
260     m_mgr.UnInit();
261   }
262   //================================================================
263
264   //================================================================
265   void WxGUIScriptingInterface::Open(const std::string& filename)
266   {
267     mWxGUITextEditor->Open(filename);
268   }
269   //================================================================
270   
271 #define CATCH_MACRO                                                     \
272   catch (QuitException e)                                               \
273     {                                                                   \
274       std::cout << "* quit exception caught"<<std::endl;                \
275     }                                                                   \
276   catch (InterpreterError e)                                            \
277     {                                                                   \
278       std::cerr << "* IERROR : "<<e.GetErrorMessage()<<std::endl;               \
279       if (e.IsInScriptFile())                                           \
280         std::cerr << "* FILE   : '"<<e.GetScriptFile()<<"'"<<std::endl; \
281       std::cerr << "* LINE   : "<<e.GetScriptLine()<<std::endl;         \
282       int lev = bbtk::MessageManager::GetMessageLevel("Error");         \
283       if (lev > 0) {                                                    \
284         std::cerr << "* Exception thrown : "<<std::endl;                \
285         std::cerr << "*  OBJECT : " <<e.GetObject()<<std::endl;         \
286         std::cerr << "*  FILE   : " <<e.GetSourceFile()<<std::endl;     \
287       }                                                                 \
288     }
289   
290   //================================================================
291   void WxGUIScriptingInterface::WxGUICommandEnter(const std::string& command)
292   {
293     std::string s("> ");
294     s += command + "\n";
295     mWxGUIOutputMessages->Print(s,wxRED);
296     
297     try
298       {
299         mInterpreter->InterpretLine( command );
300       }
301     CATCH_MACRO;
302   }
303   //================================================================
304   
305   //================================================================
306   /// Runs the interpretation of a file
307   bool WxGUIScriptingInterface::InterpretFile( const std::string& filename) 
308   { 
309     try
310       {
311         mInterpreter->InterpretFile(filename);
312       }
313     CATCH_MACRO;
314     return true;
315   }
316   //================================================================
317  
318   //================================================================
319   void WxGUIScriptingInterface::WxGUITextEditorRun()
320   {
321     //    wxString temp = mWxGUIHtmlBrowser->GetCurrentPage();
322     std::stringstream* buf = new std::stringstream;
323     (*buf) << mWxGUITextEditor->GetCurrentPage()->GetText();
324     try 
325       {
326         //      std::cout << "RUN"<<std::endl;
327         if (mwxMenuItemReset->IsChecked()) WxGUICommandEnter("reset");
328         mInterpreter->InterpretBuffer(buf);
329         //      std::cout << "EO RUN"<<std::endl;
330       }
331     CATCH_MACRO;
332     //    std::cout << "EO RUN 3"<<std::endl;
333   }
334   //================================================================  
335
336   //================================================================
337   void WxGUIScriptingInterface::OnMenuQuit(wxCommandEvent& WXUNUSED(event))
338   {
339     if (!mWxGUITextEditor->CloseAllPages()) return;
340     Close(true);
341   }
342   //================================================================
343
344
345   //================================================================
346   void WxGUIScriptingInterface::OnMenuAbout(wxCommandEvent& WXUNUSED(event))
347   {
348     m_mgr.Update();
349         Refresh();
350     wxMessageBox(_T("  bbStudio\nThe Black Box Toolkit Development Studio\n(c) CREATIS-LRMN 2008"),
351                  _T("About ..."), wxOK | wxICON_INFORMATION,
352                  this);
353   }
354   //================================================================
355
356
357   //================================================================
358   void WxGUIScriptingInterface::OnMenuEditConfig(wxCommandEvent& WXUNUSED(event))
359   {
360     std::string configFile = 
361       ConfigurationFile::GetInstance().Get_config_xml_full_path();
362     Open(configFile);
363   }
364   //================================================================
365
366   //================================================================
367   void WxGUIScriptingInterface::OnMenuWindowsPackageBrowser(wxCommandEvent& WXUNUSED(event))
368   {
369     wxBusyCursor wait;
370     WxGUIPackageBrowser2Window *helpbrowser = new
371       WxGUIPackageBrowser2Window(this,_T("Package Browser"), wxSize(600,600) );
372     helpbrowser->Show();
373     
374     /*
375     wxBusyCursor wait;
376     WxGUIPackageBrowser2 *browser = new WxGUIPackageBrowser2(this);
377     browser->IncludeAll();
378     */
379 #if NOTEBOOK
380     //     mwxNotebook->AddPage(browser,_T("Package Browser"),true);
381 #else
382      /*
383      m_mgr.AddPane(browser,
384                    wxAuiPaneInfo().Name(wxT("package_brower"))
385                    .Caption(wxT("Package browser"))
386                    .MinimizeButton(true)
387                    .MaximizeButton(true)
388                    .Bottom()
389                    .Position(1)
390                    .MinSize(wxSize(100,100))
391                    );     
392      */
393 #endif
394   }
395   //================================================================
396
397
398
399   //================================================================
400   void WxGUIScriptingInterface::OnMenuCreatePackage(wxCommandEvent& WXUNUSED(event))
401   {
402
403     std::string command("toolsbbtk/appli/GUICreatePackage");
404     bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
405     
406     Interpreter::Pointer I = Interpreter::New();    
407     I->InterpretFile(command);
408
409   }
410   //================================================================
411
412
413   //================================================================
414   void WxGUIScriptingInterface::OnMenuCreateBlackBox(wxCommandEvent& WXUNUSED(event))
415   {
416     std::string command("toolsbbtk/appli/GUICreateBlackBox");
417     bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
418     
419     Interpreter::Pointer I = Interpreter::New();    
420     I->InterpretFile(command);
421   }
422   //================================================================
423   
424   //================================================================
425   void WxGUIScriptingInterface::OnMenuShowImageGraph(wxCommandEvent& WXUNUSED(event))
426   {
427     std::string default_temp_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
428
429 #if defined(WIN32)
430     std::string strappli="start ";
431 #else
432     std::string strappli="gnome-open ";
433 #endif
434     std::string strcommand = strappli +default_temp_dir+"/temp_dir/workspace_workspacePrototype.png";
435     //  std::cout << "system: " << strcommand << std::endl;
436     system ( strcommand.c_str() );
437
438   }
439   //================================================================
440
441   void WxGUIScriptingInterface::DoRegeneratePackageDoc( const std::string& pack )
442   {
443             std::string command;
444 #if defined(WIN32)
445         command = "\"";
446 #endif
447         command += ConfigurationFile::GetInstance().Get_bin_path();
448     command += ConfigurationFile::GetInstance().Get_file_separator();
449     command += "bbRegeneratePackageDoc";
450 #if defined(WIN32)
451         command += "\"";
452 #endif
453         command += " " + pack + " -q";
454     bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
455     
456
457     if ( ! system ( command.c_str() ) )
458       {
459         wxMessageBox(_T("Done !"),_T("Regenerate package '")+pack+_T("' doc"),
460                      wxOK | wxICON_INFORMATION);
461       }
462     else 
463       {
464         wxString err(_T("An error occured while running '"));
465         err +=  bbtk::std2wx(command) + _T("'");
466         wxMessageBox(err,_T("Regenerate package doc"),wxOK | wxICON_ERROR);      
467       }
468   }
469
470
471   //================================================================
472   void WxGUIScriptingInterface::OnMenuRegeneratePackageDoc(wxCommandEvent& WXUNUSED(event))
473   {
474     wxString name = wxGetTextFromUser(_T("Enter package name (-a for all)"),
475                                       _T("Regenerate package doc"),
476                                       _T(""));
477     if (name.IsEmpty()) return;
478     std::string pack = bbtk::wx2std(name);
479     
480         DoRegeneratePackageDoc(pack);
481   }
482   //================================================================
483
484
485   void WxGUIScriptingInterface::DoRegenerateBoxesLists()
486   {
487     std::string command;
488 #if defined(WIN32)
489         command = "\"";
490 #endif
491     command += ConfigurationFile::GetInstance().Get_bin_path();
492     command += ConfigurationFile::GetInstance().Get_file_separator();
493     command += "bbRegenerateBoxesLists";
494 #if defined(WIN32)
495         command += "\"";
496 #endif
497         command += " -q";
498         bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
499
500         if ( ! system ( command.c_str() ) )
501     {
502        wxMessageBox(_T("Done !"),_T("Regenerate boxes lists"),
503                     wxOK | wxICON_INFORMATION);
504      }
505    else 
506      {
507        wxString err(_T("An error occured while running '"));
508        err +=  bbtk::std2wx(command) + _T("'");
509        wxMessageBox(err,_T("Regenerate boxes lists"),wxOK | wxICON_ERROR);      
510      }
511   }
512
513   //================================================================
514   void WxGUIScriptingInterface::OnMenuRegenerateBoxesLists(wxCommandEvent& WXUNUSED(event))
515   {
516         DoRegenerateBoxesLists();
517   }
518   //================================================================
519
520   //================================================================
521   void WxGUIScriptingInterface::OnMenuRegenerateAll(wxCommandEvent& WXUNUSED(event))
522   {
523         
524     DoRegeneratePackageDoc("-a");       
525         DoRegenerateBoxesLists();
526   }
527   //================================================================
528
529  
530   //================================================================
531   void WxGUIScriptingInterface::OnMenuPlugPackage(wxCommandEvent& WXUNUSED(event))
532   {
533     long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
534     wxDirDialog* FD = 
535       new wxDirDialog( 0, 
536                        _T("Select package directory"),
537                        _T(""),
538                        style);
539     
540     if (FD->ShowModal()==wxID_OK)
541       {
542         std::string path = wx2std (FD->GetPath()) ;
543         std::string fname = path + "/bbtkPackage"; 
544         if ( ! Utilities::FileExists( fname ) )
545           {
546             wxString err(_T("The directory does not contain a 'bbtkPackage' file"));
547             wxMessageBox(err,_T("Plug package"),wxOK | wxICON_ERROR);      
548             return;
549           }
550         
551         std::ifstream f;
552         f.open(fname.c_str());
553         std::string pname;
554         f >> pname;
555         f.close();
556         
557         
558         bbtk::ConfigurationFile::GetInstance().AddPackagePathsAndWrite( path );
559         
560         DoRegeneratePackageDoc(pname);
561         DoRegenerateBoxesLists();
562
563           }     
564   }
565   //================================================================
566
567   //================================================================
568   void WxGUIScriptingInterface::InterpreterUserViewHtmlPage(const std::string& page)
569   {
570     std::string s(page);
571     //  std::cout << "WxGUIScriptingInterface::ShowHtmlPage('"<<page<<"')"<<std::endl;
572     if (mWxGUIHtmlBrowser->GoTo(s)) 
573       {
574 //EED   mwxNotebook->ChangeSelection(1);
575 //      mwxNotebook->SetSelection(1);
576       }
577     else 
578       {
579          // std::cout << "ERROR html"<<std::endl;
580       }
581   } 
582   //================================================================  
583   
584   //================================================================  
585   bool WxGUIScriptingInterface::WxGUIHtmlBrowserUserOnLinkClicked(const std::string& target)
586   {
587     size_t s = target.length();
588     if ((s>3) && (target[s-1]=='s')
589         && (target[s-2]=='b')
590         && (target[s-3]=='b')
591         && (target[s-4]=='.'))
592       {
593         mWxGUITextEditor->Open(target);
594 #if NOTEBOOK
595         mwxNotebook->SetSelection(0);
596 #endif
597         mWxGUITextEditor->SetFocus();
598         return false;
599       }
600     return true;
601   }
602   //================================================================  
603
604   void WxGUIScriptingInterface::OnMenuWindowsCheck( wxCommandEvent& event, 
605                                                     wxWindow* w)
606   {
607     bool checked = event.IsChecked();
608     bool shown = m_mgr.GetPane(w).IsShown();
609     //    std::cout << "checked = "<<checked<<" - shown = "<<shown<<std::endl;
610     if (checked ^ shown) 
611       {
612         m_mgr.GetPane(w).Show(checked);
613         m_mgr.Update();
614       }
615   }
616
617
618   //================================================================  
619   void WxGUIScriptingInterface::OnMenuWindowsFiles(wxCommandEvent& event)
620   {
621     OnMenuWindowsCheck(event,mWxGUITextEditor);
622   }
623   //================================================================  
624
625   //================================================================  
626   void  WxGUIScriptingInterface::OnMenuWindowsHelp(wxCommandEvent& event)
627   {
628     OnMenuWindowsCheck(event,mWxGUIHtmlBrowser);
629   }
630   //================================================================  
631
632   //================================================================  
633   void  WxGUIScriptingInterface::OnMenuWindowsMessages(wxCommandEvent& event)
634   {
635     OnMenuWindowsCheck(event,mWxGUIOutputMessages);
636   }
637   //================================================================  
638
639   //================================================================  
640   void  WxGUIScriptingInterface::OnMenuWindowsCommand(wxCommandEvent& event)
641   {
642     OnMenuWindowsCheck(event,mWxGUICommand);
643   }
644   //================================================================  
645
646   //================================================================  
647   void WxGUIScriptingInterface::OnMenuWindowsSave( wxCommandEvent& WXUNUSED(event))
648   {
649     SavePerspective();
650   }
651   //================================================================  
652
653   //================================================================  
654   void WxGUIScriptingInterface::SavePerspective()
655   {
656     //    std::cout  << "Saving configuration..."<<std::endl;
657     std::string conf = wx2std(m_mgr.SavePerspective());
658     std::string fname = Utilities::MakeUserSettingsFullFileName("bbStudio.aui");
659     std::ofstream f;
660     f.open(fname.c_str(), std::ios::out );
661     f << conf << std::endl;
662
663     //    int x,y;
664     //    GetPosition(&x,&y);
665     //    f << x << "  " << y << std::endl;
666
667
668     int w,h;
669     GetSize(&w,&h);
670
671     f << w << " " << h << std::endl;
672
673     f.close();
674   }
675   //================================================================  
676
677   //================================================================  
678   void WxGUIScriptingInterface::LoadPerspective()
679   {
680     std::string fname = 
681       Utilities::MakeUserSettingsFullFileName("bbStudio.aui");
682     if ( Utilities::FileExists( fname ))
683       {
684         //      std::cout  << "Loading configuration..."<<std::endl;
685
686         std::ifstream f;
687         f.open(fname.c_str());
688         std::string conf;
689         f >> conf;
690
691         //      int x,y;
692         //      f >> x >> y ;
693
694         int w,h;
695         f >> w >> h ;
696
697         f.close();
698         
699         //      std::cout << conf << std::endl;
700
701         //      Move(x,y);
702         SetSize(w,h);
703         m_mgr.LoadPerspective(std2wx(conf));
704       }
705     else 
706       {
707         m_mgr.Update();
708       }
709   }
710   //================================================================  
711
712   //================================================================  
713   void WxGUIScriptingInterface::OnPaneClose(wxAuiManagerEvent& evt)
714   {
715     std::cout  << "Closing panel '"<<evt.pane->name<<"'"<<std::endl;
716     // TO DO : Uncheck 
717     //    OnMenuWindowsCheck( wxCommandEvent& event, wxWindow* w);
718   }
719   //================================================================  
720
721   
722   //================================================================  
723   BEGIN_EVENT_TABLE(WxGUIScriptingInterface, wxFrame)
724     EVT_MENU(ID_Menu_Quit, WxGUIScriptingInterface::OnMenuQuit)
725     EVT_MENU(ID_Menu_About, WxGUIScriptingInterface::OnMenuAbout)
726     EVT_MENU(ID_Menu_EditConfig, WxGUIScriptingInterface::OnMenuEditConfig)
727     EVT_MENU(ID_Menu_CreatePackage, WxGUIScriptingInterface::OnMenuCreatePackage)
728     EVT_MENU(ID_Menu_CreateBlackBox, WxGUIScriptingInterface::OnMenuCreateBlackBox)
729     EVT_MENU(ID_Menu_ShowImageGraph, WxGUIScriptingInterface::OnMenuShowImageGraph)
730     EVT_MENU(ID_Menu_RegeneratePackageDoc, WxGUIScriptingInterface::OnMenuRegeneratePackageDoc)
731     EVT_MENU(ID_Menu_RegenerateBoxesLists, WxGUIScriptingInterface::OnMenuRegenerateBoxesLists)
732     EVT_MENU(ID_Menu_RegenerateAll, WxGUIScriptingInterface::OnMenuRegenerateAll)
733     EVT_MENU(ID_Menu_PlugPackage, WxGUIScriptingInterface::OnMenuPlugPackage)
734     EVT_MENU(ID_Menu_Windows_Files, WxGUIScriptingInterface::OnMenuWindowsFiles)
735     EVT_MENU(ID_Menu_Windows_Help, WxGUIScriptingInterface::OnMenuWindowsHelp)
736     EVT_MENU(ID_Menu_Windows_Messages, WxGUIScriptingInterface::OnMenuWindowsMessages)
737     EVT_MENU(ID_Menu_Windows_Command, WxGUIScriptingInterface::OnMenuWindowsCommand)
738     EVT_MENU(ID_Menu_Windows_Save, WxGUIScriptingInterface::OnMenuWindowsSave)
739     EVT_MENU(ID_Menu_Windows_PackageBrowser, WxGUIScriptingInterface::OnMenuWindowsPackageBrowser)
740     EVT_AUI_PANE_CLOSE(WxGUIScriptingInterface::OnPaneClose)
741   //    EVT_BUTTON(ID_Button_Run, WxGUIScriptingInterface::OnButtonRun )
742     END_EVENT_TABLE()
743   //================================================================
744
745 } // namespace bbtk
746
747
748 #endif //_USE_WXWIDGETS_