]> Creatis software - bbtk.git/blob - kernel/src/bbtkWxGUITextEditor.cxx
d94d6bdc26d3ee872e70331127a6655d97d412c3
[bbtk.git] / kernel / src / bbtkWxGUITextEditor.cxx
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkWxGUITextEditor.cxx,v $
4   Language:  C++
5   Date:      $Date: 2009/12/04 10:48:34 $
6   Version:   $Revision: 1.21 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
14 *  This software is governed by the CeCILL-B license under French law and 
15 *  abiding by the rules of distribution of free software. You can  use, 
16 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
17 *  license as circulated by CEA, CNRS and INRIA at the following URL 
18 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
19 *  or in the file LICENSE.txt.
20 *
21 *  As a counterpart to the access to the source code and  rights to copy,
22 *  modify and redistribute granted by the license, users are provided only
23 *  with a limited warranty  and the software's author,  the holder of the
24 *  economic rights,  and the successive licensors  have only  limited
25 *  liability. 
26 *
27 *  The fact that you are presently reading this means that you have had
28 *  knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */                                                                         
30
31
32 /**
33  * \brief Short description in one line
34  * 
35  * Long description which 
36  * can span multiple lines
37  */
38 /**
39  * \file 
40  * \brief 
41  */
42 /**
43  * \class bbtk::
44  * \brief 
45  */
46
47
48 #ifdef _USE_WXWIDGETS_
49
50 #include <iostream>     
51 #include "bbtkWxGUITextEditor.h"
52 #include "bbtkWxBlackBox.h"
53 #include "bbtkConfigurationFile.h"
54 #include "bbtkUtilities.h"
55
56 //#include "icons/cc_new.xpm"
57 //#include "icons/cc_open.xpm"
58 //#include "icons/cc_stop.xpm"
59 //#include "icons/cc_save.xpm"
60 //#include "icons/cc_save_as.xpm"
61 //#include "icons/cc_run.xpm"
62 //#include "icons/cc_exit.xpm"
63
64 #include "../data/icons/wxart_new.xpm"
65 #include "../data/icons/wxart_fileopen.xpm"
66 #include "../data/icons/wxart_filesave.xpm"
67 #include "../data/icons/wxart_filesaveas.xpm"
68 //#include "../data/icons/wxart_exefile.xpm"
69 //#include "../data/icons/wxart_delete.xpm"
70 //#include "../data/icons/wxart_down.xpm"
71 #include "../data/icons/wxart_run.xpm"
72 #include "../data/icons/wxart_runbbi.xpm"
73 #include "../data/icons/wxart_graphsimple.xpm"
74 #include "../data/icons/wxart_graphdetail.xpm"
75 #include "../data/icons/wxart_eldel.xpm"
76
77 namespace bbtk
78 {
79
80
81   //================================================================
82   class WxTextCtrlGettingKeyEvents : public wxTextCtrl
83   {
84   public:
85     WxTextCtrlGettingKeyEvents(wxWindow *parent, wxWindowID id, const wxString &value,
86                                const wxPoint &pos, const wxSize &size, int style = 0)
87       : wxTextCtrl(parent, id, value, pos, size, style)
88     {
89     }
90     
91     void SetWxGUITextEditor(WxGUITextEditor* e) 
92     { mWxGUITextEditor = e; }
93     
94     void OnKeyDown(wxKeyEvent& event);
95     void OnKeyUp(wxKeyEvent& event);
96     void OnChar(wxKeyEvent& event);
97   private :
98     WxGUITextEditor* mWxGUITextEditor;
99     
100     DECLARE_EVENT_TABLE()
101       };
102   
103   BEGIN_EVENT_TABLE(WxTextCtrlGettingKeyEvents, wxTextCtrl)
104     EVT_KEY_DOWN(WxTextCtrlGettingKeyEvents::OnKeyDown)
105     EVT_KEY_UP(WxTextCtrlGettingKeyEvents::OnKeyUp)
106     EVT_CHAR(WxTextCtrlGettingKeyEvents::OnChar)
107     END_EVENT_TABLE()
108     
109     
110     void WxTextCtrlGettingKeyEvents::OnChar(wxKeyEvent& event)
111   {
112     event.Skip();
113   }
114   
115   void WxTextCtrlGettingKeyEvents::OnKeyUp(wxKeyEvent& event)
116   {
117     mWxGUITextEditor->OnKeyUp(event);
118     event.Skip();
119   }
120   
121   void WxTextCtrlGettingKeyEvents::OnKeyDown(wxKeyEvent& event)
122   {
123     mWxGUITextEditor->OnKeyDown(event);
124     event.Skip();
125   }
126   //================================================================
127   
128   
129   //================================================================  
130   /*  BEGIN_EVENT_TABLE(WxGUITextEditorPage, wxPanel)
131     EVT_CLOSE(WxGUITextEditorPage::OnClose)
132     END_EVENT_TABLE()
133   */
134  
135   //================================================================
136   WxGUITextEditorPage::WxGUITextEditorPage(wxWindow* parent,
137                                                WxGUITextEditor* editor)
138     : wxPanel(parent,-1),
139       mEditor(editor),
140       mName(""),
141       mAskFilename(true)
142   {  
143
144           //      std::cout << "WxGUITextEditorPage::WxGUITextEditorPage("<<mName<<")"<<std::endl;
145
146     wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
147  
148     mwxInputText = 
149                 
150       new WxTextCtrlGettingKeyEvents(this,
151                                      -1, //ID_InputText,
152                                      _T(""),
153                                      wxDefaultPosition,
154                                      wxDefaultSize,
155                                      wxTE_MULTILINE 
156                                      //    |wxTE_PROCESS_ENTER
157                                      //| wxTE_PROCESS_TAB 
158                                      //             | wxWANTS_CHARS 
159                                     // |  wxTAB_TRAVERSAL
160                                      );
161     mwxInputText->SetWxGUITextEditor(mEditor);
162     /*
163         new wxTextCtrl(this,-1,_T(""),
164                 wxDefaultPosition,
165                                              wxDefaultSize,
166                                              wxTE_MULTILINE 
167                                              //    |wxTE_PROCESS_ENTER
168                                         //       | wxTE_PROCESS_TAB 
169                                 //                  | wxWANTS_CHARS 
170                                  //    |  wxTAB_TRAVERSAL
171                                      );
172                                          */
173     mFixedFont = new wxFont(10,
174                                    wxFONTFAMILY_MODERN,
175                                    wxFONTSTYLE_NORMAL,
176                                    wxFONTWEIGHT_NORMAL,
177                                    false);
178     
179     mwxInputTextAttr = new wxTextAttr;
180     mwxInputTextAttr->SetFont(*mFixedFont);
181    
182     sizer->Add(mwxInputText,1,wxGROW);
183     SetSizer(sizer);
184     SetAutoLayout(true);
185     Layout();
186   }
187   //================================================================
188
189   //================================================================
190   WxGUITextEditorPage::~WxGUITextEditorPage()
191   {
192           delete mwxInputTextAttr;
193           delete mFixedFont;
194   }
195   //================================================================
196
197   bool WxGUITextEditorPage::IsModified()
198    { return mwxInputText->IsModified(); }
199
200   std::string WxGUITextEditorPage::GetText()
201   {
202     return wx2std(GetTextCtrl()->GetValue());
203   }
204
205   //================================================================
206   void WxGUITextEditorPage::Load(const std::string& filename)
207   {
208     //    std::cout << "-------------- LOAD ---------------"<<std::endl;
209     //    std::cout << "'" << filename << "'"<<std::endl;
210     //std::string oldFilename = mFilename;
211     mName = filename;
212     mAskFilename = false;
213     mwxInputText->LoadFile(std2wx(mName));
214   }
215   //================================================================
216
217   //================================================================
218   void WxGUITextEditorPage::Save(const std::string& filter)
219   {
220     //    std::cout << "-------------- SAVE ---------------"<<std::endl;
221     if (mAskFilename)
222       {
223         wxFileDialog* fd = new wxFileDialog(this,_T("Save file"),_T(""),
224                                             _T(""),std2wx(filter),
225                                             wxSAVE | wxOVERWRITE_PROMPT );
226         int result_fd = fd->ShowModal();
227     
228         // This line is need it by windows // EED
229         fd->SetReturnCode( result_fd );
230
231         if (fd->GetReturnCode()==wxID_OK)
232           {
233             mName = wx2std(fd->GetPath());
234             mAskFilename = false;
235           }
236         else 
237           {
238             //      std::cout << "-------------- CANCELLED ---------------"
239             //                <<std::endl;
240             return;
241           } 
242       }
243     //    std::cout << "file [" << mName << "]" <<std::endl;
244 //    mwxInputText->SaveFile(std2wx(mName));
245         SaveFile(mName);
246     mwxInputText->SetModified(false);
247   }
248   //================================================================
249   
250
251         //================================================================
252         void WxGUITextEditorPage::SaveFile(const std::string& filename)
253         {
254                 mwxInputText->SaveFile( std2wx(filename) );
255         }
256         //================================================================
257         
258         
259
260
261
262
263
264
265
266
267
268
269   //================================================================
270   // WxGUITextEditor
271   //================================================================
272
273
274   //================================================================
275   WxGUITextEditor::WxGUITextEditor( wxWindow *parent,
276                                     WxGUITextEditorUser* user )
277     : wxPanel(parent, -1),
278       mUser(user),
279       mFileNameFilter("*.*")
280   {
281   //  m_mgr.SetManagedWindow(this);
282                     //    wxInitAllImageHandlers();
283      
284         //  std::cout << "WxGUITextEditor::WxGUITextEditor"<<std::endl;
285
286       wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
287
288     mwxNotebook = new wxNotebook(this,-1,
289                 wxDefaultPosition, wxDefaultSize, 
290                 wxNB_TOP 
291
292                 
293                 );
294                 
295    sizer->Add(mwxNotebook,1,wxGROW);
296
297                 
298                 /*
299    mwxNotebook =                new wxAuiNotebook(this,  
300                                     -1,
301                                     wxPoint(0, 0),
302                                     wxSize(500,500),
303                                     wxAUI_NB_TAB_SPLIT 
304                                     | wxAUI_NB_TAB_MOVE
305                                     | wxAUI_NB_TAB_EXTERNAL_MOVE
306                                     | wxAUI_NB_WINDOWLIST_BUTTON
307                                     |wxAUI_NB_SCROLL_BUTTONS
308                                     // | wxAUI_NB_CLOSE_BUTTON 
309                                     | wxAUI_NB_CLOSE_ON_ACTIVE_TAB
310                                     //| wxAUI_NB_CLOSE_ON_ALL_TABS
311                                     | wxNO_BORDER);
312     
313     m_mgr.AddPane(mwxNotebook,
314                   wxAuiPaneInfo().Name(wxT("notebook"))
315                   .Caption(wxT(""))
316                   .CaptionVisible(false)
317                   .MinimizeButton(false)
318                   .MaximizeButton(false)
319                   .CloseButton(false)
320                   //              .Dockable(false).Float()
321                   .Center()
322                   .MinSize(wxSize(100,50))
323                   );   
324 */
325  
326     /*   
327     wxBitmap bmp_new(cc_new_xpm);
328     wxBitmap bmp_open(cc_open_xpm);
329     wxBitmap bmp_close(cc_stop_xpm);
330     wxBitmap bmp_save(cc_save_xpm);
331     wxBitmap bmp_saveas(cc_save_as_xpm);
332     wxBitmap bmp_run(cc_run_xpm);
333     */
334     wxBitmap bmp_new(new_xpm);
335     wxBitmap bmp_open(fileopen_xpm);
336     wxBitmap bmp_close(eldel_xpm);
337     wxBitmap bmp_save(filesave_xpm);
338     wxBitmap bmp_saveas(filesaveas_xpm);
339     wxBitmap bmp_run(wxart_run_xpm);
340     wxBitmap bmp_runbbi(wxart_runbbi_xpm);
341     wxBitmap bmp_graphsimple(wxart_graphsimple_xpm);
342         wxBitmap bmp_graphdetail(wxart_graphdetail_xpm);
343
344     mwxToolBar = new wxToolBar(this, wxID_ANY, 
345                                wxDefaultPosition, wxDefaultSize,
346                                wxTB_FLAT | wxTB_NODIVIDER);
347     
348     mwxToolBar->AddTool(ID_ButtonNew, _T("New"),
349                      bmp_new, wxNullBitmap, wxITEM_NORMAL,
350                      _T("New file"), _T("Create a new file"));
351     mwxToolBar->AddTool(ID_ButtonOpen, _T("Open"),
352                      bmp_open, wxNullBitmap, wxITEM_NORMAL,
353                      _T("Open file"), _T("This is help for new file tool"));
354     mwxToolBar->AddTool(ID_ButtonClose, _T("Close"),
355                      bmp_close, wxNullBitmap, wxITEM_NORMAL,
356                      _T("Close file"), _T("Close current file"));
357     mwxToolBar->AddTool(ID_ButtonSave, _T("New"),
358                      bmp_save, wxNullBitmap, wxITEM_NORMAL,
359                      _T("Save file"), _T("Save current file"));
360     mwxToolBar->AddTool(ID_ButtonSaveAs, _T("New"),
361                      bmp_saveas, wxNullBitmap, wxITEM_NORMAL,
362                      _T("Save file as"), _T("Save current file as"));
363     mwxToolBar->AddTool(ID_ButtonRun, _T("Run"),
364                      bmp_run, wxNullBitmap, wxITEM_NORMAL,
365                      _T("Run file"), _T("Run current file"));
366
367           
368         mwxToolBar->AddTool(ID_ButtonGraphSimple, _T("Graph (simple)"),
369                                                   bmp_graphsimple, wxNullBitmap, wxITEM_NORMAL,
370                                                   _T("Graph simple"), _T("Simple graph of actual script"));
371
372         mwxToolBar->AddTool(ID_ButtonGraphDetail, _T("Graph (detail)"),
373                                                   bmp_graphdetail, wxNullBitmap, wxITEM_NORMAL,
374                                                   _T("Graph (detail)"), _T("Detail graph of actual script"));
375           
376         mwxToolBar->AddTool(ID_ButtonRunBBI, _T("Run external bbi "),
377                                                   bmp_runbbi, wxNullBitmap, wxITEM_NORMAL,
378                                                   _T("Run external bbi"), _T("Run external bbi"));
379           
380           
381           
382     mwxToolBar->AddSeparator();
383     mwxPosition = new wxStaticText ( mwxToolBar, -1, _T(""));
384     mwxToolBar->AddControl(mwxPosition);
385     mwxToolBar->Realize();
386
387           sizer->Add(mwxToolBar,0,wxGROW);
388
389         /*
390     m_mgr.AddPane(mwxToolBar, 
391                   wxAuiPaneInfo().Name(wxT("toolBar"))
392                   .Caption(wxT(""))
393                   .ToolbarPane()
394                   .Bottom()
395                   .MinSize(wxSize(100,50))
396                   .LeftDockable(false).RightDockable(false)
397                   );   
398 */
399   SetSizer(sizer);
400   
401     
402 //    m_mgr.Update();
403     SetAutoLayout(true);
404     Layout();
405
406     NewPage("");
407     UpdateInfo();
408
409   }
410   //================================================================
411   
412   //================================================================
413   WxGUITextEditor::~WxGUITextEditor()
414   {
415   //  m_mgr.UnInit();
416
417     //    delete mInterpreter;
418   }
419   //================================================================
420
421   //================================================================
422   void WxGUITextEditor::NewPage(const std::string& filename)
423   {
424    WxGUITextEditorPage* page = 
425       new WxGUITextEditorPage(mwxNotebook,this);
426     std::string name("untitled");
427     if (filename.size()!=0) 
428       {
429         name = filename;
430         page->Load(name);
431       }
432     page->SetPageName(name);
433     std::string fname = Utilities::get_file_name(name);
434     mwxNotebook->AddPage(page,std2wx(fname),true);
435     FocusOnCurrentPage();
436   }
437   //================================================================
438
439   //================================================================
440   WxGUITextEditorPage* WxGUITextEditor::GetCurrentPage()
441   {
442     return (WxGUITextEditorPage*)
443       mwxNotebook->GetPage(mwxNotebook->GetSelection());
444   }
445   //================================================================
446
447   //================================================================
448   void WxGUITextEditor::FocusOnCurrentPage()
449   {
450     if (mwxNotebook->GetPageCount()==0) return;
451     GetCurrentPage()->SetFocus();    
452   }
453   //================================================================
454
455   //================================================================  
456   void WxGUITextEditor::OnToolLeftClick(wxCommandEvent& event)
457   {
458     switch (event.GetId())
459       {
460       case ID_ButtonNew :
461         New(); 
462         FocusOnCurrentPage();
463         break;
464       case ID_ButtonOpen :
465         Open(); 
466         FocusOnCurrentPage();
467         break;
468       case ID_ButtonClose :
469         CloseCurrentPage();
470         break;
471       case ID_ButtonSave :
472         SaveCurrentPage();
473         break;
474       case ID_ButtonSaveAs :
475         if (mwxNotebook->GetPageCount()==0) break;  
476         GetCurrentPage()->SetAskFilename(true);
477         SaveCurrentPage();
478         break;
479       case ID_ButtonRun :
480         if ((mUser!=0) && (mwxNotebook->GetPageCount()>0)) 
481           mUser->WxGUITextEditorRun();
482         FocusOnCurrentPage();
483         break;
484                           
485                   case ID_ButtonGraphSimple :
486                           if ((mUser!=0) && (mwxNotebook->GetPageCount()>0)) 
487                                   mUser->WxGUITextEditorGraphSimple();
488                           FocusOnCurrentPage();
489                           break;
490
491                   case ID_ButtonGraphDetail :
492                           if ((mUser!=0) && (mwxNotebook->GetPageCount()>0)) 
493                                   mUser->WxGUITextEditorGraphDetail();
494                           FocusOnCurrentPage();
495                           break;
496                           
497                   case ID_ButtonRunBBI :
498                           if ((mUser!=0) && (mwxNotebook->GetPageCount()>0)) 
499                                   mUser->WxGUITextEditorRunBBI();
500                           FocusOnCurrentPage();
501                           break;
502                           
503       }
504   }
505   //================================================================  
506
507   //================================================================  
508   void WxGUITextEditor::OnToolRightClick(wxCommandEvent& event)
509   {
510   }
511   //================================================================  
512
513   //================================================================  
514   void WxGUITextEditor::New()
515   {
516     NewPage("");
517     UpdateInfo();
518   }
519   //================================================================
520
521   //================================================================  
522   void WxGUITextEditor::Open()
523   {
524     //    std::cout << "-------------- OPEN ---------------"<<std::endl;
525
526     wxFileDialog* fd = new wxFileDialog(this,_T("Open file"),_T(""),
527                                         _T(""),std2wx(mFileNameFilter),
528                                         wxOPEN | wxFILE_MUST_EXIST );
529     int result_fd = fd->ShowModal();
530
531         // This line is need it by windows //EED
532         fd->SetReturnCode( result_fd );
533
534     if (fd->GetReturnCode()==wxID_OK)
535       {
536         std::string filename = wx2std(fd->GetPath());
537         std::cout << "file [" << filename << "]" <<std::endl;
538         Open(filename);
539       }
540     else 
541       {
542         //      std::cout << "-------------- CANCELLED ---------------"<<std::endl;
543       }
544   }
545   //================================================================  
546   
547   //================================================================  
548   void WxGUITextEditor::Open(const std::string& filename)
549   {
550     NewPage(filename);
551     UpdateInfo();
552   }
553   //================================================================  
554
555
556   //================================================================  
557   bool WxGUITextEditor::CloseCurrentPage()
558   {
559     if (mwxNotebook->GetPageCount()==0) return true;
560
561     if (GetCurrentPage()->IsModified()) 
562       {
563         wxString mess = std2wx(GetCurrentPage()->GetPageName());
564         mess += _T(" modified. Save it ?");
565         wxMessageDialog* d = 
566           new wxMessageDialog(this,
567                               mess, 
568                               _T("Save buffer"), 
569                               wxYES_NO | wxCANCEL | wxICON_QUESTION);
570         switch (d->ShowModal())
571           {
572           case wxID_CANCEL : 
573             return false;
574             break;
575           case wxID_YES : 
576             GetCurrentPage()->Save(mFileNameFilter); 
577             break;
578           case wxID_NO : ;
579           }       
580       } 
581     mwxNotebook->DeletePage(mwxNotebook->GetSelection());
582     FocusOnCurrentPage();
583     return true;
584   }
585   //================================================================  
586
587   //================================================================  
588   bool WxGUITextEditor::CloseAllPages()
589   {
590     bool ok = true;
591     while (mwxNotebook->GetPageCount()!=0)
592       {
593         if (!CloseCurrentPage()) 
594           {
595             ok = false;
596             break;
597           }
598       }
599     return ok;
600   }
601   //================================================================  
602
603   //================================================================  
604   void WxGUITextEditor::SaveCurrentPage()
605   {
606     if (mwxNotebook->GetPageCount()==0) return;  
607     GetCurrentPage()->Save(mFileNameFilter);
608     mwxNotebook->SetPageText(mwxNotebook->GetSelection(),
609                              std2wx(GetCurrentPage()->GetPageName()));
610   }
611   //================================================================  
612
613
614   //================================================================  
615   void WxGUITextEditor::OnPageClose(wxAuiNotebookEvent& evt)
616   {
617     if (!CloseCurrentPage()) evt.Veto();
618   }
619   //================================================================
620
621
622
623   /*
624   //================================================================  
625   void WxGUITextEditor::OnButtonQuit(wxCommandEvent& event) 
626   { 
627     Quit(); 
628     FocusOnCurrentPage();
629   }
630   void WxGUITextEditor::Quit()
631   {
632     std::cout << "-------------- QUIT ---------------"<<std::endl;
633     if (AskSave()) GetParent()->Close();
634   }
635   //================================================================  
636   */
637
638   //================================================================  
639
640   /*
641   void WxGUITextEditor::Run()
642   {
643     std::cout << "-------------- RUN ---------------"<<std::endl;
644
645     if (!mwxSplit->IsSplit()) 
646       {
647         int size = -100;
648         int minsize = - (int)(mwxInputText->GetSize().GetHeight() / 2.);
649         if (size<minsize) size = minsize;
650         mwxSplit->SplitHorizontally( mwxInputText, mwxOutputText, size);
651       }
652
653     std::stringstream* buffer = new std::stringstream(bbtk::wx2std(mwxInputText->GetValue()));
654     mInterpreter->InterpretLine("reset");
655     try 
656       {
657         mInterpreter->InterpretBuffer(buffer);
658       }
659     catch (...)
660       {
661       }
662   } 
663   //================================================================  
664 */
665   
666  
667   
668   //================================================================
669   
670
671   //================================================================
672   void WxGUITextEditor::UpdateInfo()
673   {
674     if (mwxNotebook->GetPageCount()==0) return;
675     WxTextCtrlGettingKeyEvents* text = GetCurrentPage()->GetTextCtrl();
676     
677     long line, column, pos;
678     pos = text->GetInsertionPoint();
679     text->PositionToXY(pos, &column, &line);
680     
681     
682     //                wxLogMessage(_T("Current position: %ld\nCurrent line, column: (%ld, %ld)\nNumber of lines: %ld\nCurrent line length: %ld\nTotal text length: %u (%ld)"),
683     
684     
685     char mess[200];
686     sprintf(mess,"%ld:%ld/%ld:%ld",
687             line+1,column+1,
688             (long)text->GetNumberOfLines(),
689             (long)text->GetLineLength(line)+1);
690     //       pos+1,
691     //       (long)mwxInputText->GetValue().length())+1;
692     
693    // mwxPosition->SetLabel(wxString(mess));
694     mwxPosition->SetLabel(std2wx(mess));    
695     mwxPosition->Show();
696     
697     if (text->IsModified()) 
698       {
699         std::string title("*");
700         title += GetCurrentPage()->GetPageName();
701         mwxNotebook->SetPageText(mwxNotebook->GetSelection(),std2wx(title));
702       }
703   }
704   //================================================================
705   //================================================================
706   void WxGUITextEditor::OnKeyUp(wxKeyEvent& event)
707   {
708   //    std::cout << "U" << std::endl;
709     UpdateInfo();
710   }
711   //================================================================
712
713   //================================================================
714   void WxGUITextEditor::OnKeyDown(wxKeyEvent& event)
715   {
716      //   std::cout << "D" << std::endl;
717     // std::cout << "Key="<<event.GetKeyCode()<<std::endl;
718     if ( event.ControlDown() )
719       {
720         switch (event.GetKeyCode())
721           {
722           case 'n': case 'N' : New(); break;
723           case 's': case 'S' : SaveCurrentPage(); break;
724           case 'o': case 'O' : Open(); break;
725             //    case 'r': case 'R' : Run(); break;
726             //    case 'q': case 'Q' : Quit(); break;
727           }
728       }
729   }
730   //================================================================
731   
732   //================================================================  
733   BEGIN_EVENT_TABLE(WxGUITextEditor, wxPanel)
734     EVT_MENU(wxID_ANY,  WxGUITextEditor::OnToolLeftClick)
735     EVT_TOOL_RCLICKED(wxID_ANY,  WxGUITextEditor::OnToolRightClick)
736     EVT_AUINOTEBOOK_PAGE_CLOSE(wxID_ANY, WxGUITextEditor::OnPageClose)
737     END_EVENT_TABLE()
738   //================================================================
739     
740
741
742
743   
744   //================================================================
745   WxGUITextEditorWindow::WxGUITextEditorWindow( wxWindow *parent, 
746                                                     wxString title, 
747                                                     wxSize size)
748     : wxFrame((wxFrame *)parent, -1, title, wxDefaultPosition, size)
749   {     
750     
751     
752     wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
753
754     mEditor = new WxGUITextEditor(this);
755     sizer->Add(mEditor,1,wxGROW);
756     
757     //    WxGUICommand* com = new WxGUICommand(this,this);
758     //    sizer->Add(com);
759     
760     SetSizer(sizer);
761
762     // parent window of all bbtk windows will be a child of this
763     //    Wx::SetTopWindowParent(this);
764     Wx::SetTopWindow(this);
765     // Add the method OnWxSignal as a Wx::Signal observer 
766     //bbtkAddWxSignalObserver(WxGUITextEditorWindow::OnWxSignal);
767     
768    
769     SetAutoLayout(true);
770     Layout();
771   }
772   //================================================================
773
774   //================================================================
775   WxGUITextEditorWindow::~WxGUITextEditorWindow()
776   {
777   }
778   //================================================================
779
780
781 } // namespace bbtk
782
783
784 #endif //_USE_WXWIDGETS_