]> Creatis software - bbtk.git/commitdiff
*** empty log message ***
authorguigues <guigues>
Tue, 25 Mar 2008 15:47:53 +0000 (15:47 +0000)
committerguigues <guigues>
Tue, 25 Mar 2008 15:47:53 +0000 (15:47 +0000)
14 files changed:
kernel/data/icons/wxart_delete.xpm [new file with mode: 0644]
kernel/data/icons/wxart_down.xpm [new file with mode: 0644]
kernel/data/icons/wxart_eldel.xpm [new file with mode: 0644]
kernel/data/icons/wxart_eldown.xpm [new file with mode: 0644]
kernel/data/icons/wxart_exefile.xpm [new file with mode: 0644]
kernel/data/icons/wxart_fileopen.xpm [new file with mode: 0644]
kernel/data/icons/wxart_filesave.xpm [new file with mode: 0644]
kernel/data/icons/wxart_filesaveas.xpm [new file with mode: 0644]
kernel/data/icons/wxart_new.xpm [new file with mode: 0644]
kernel/src/bbtkInterpreter.cxx
kernel/src/bbtkWxGUIScriptingInterface.cxx
kernel/src/bbtkWxGUIScriptingInterface.h
kernel/src/bbtkWxGUITextEditor.cxx
kernel/src/bbtkWxGUITextEditor.h

diff --git a/kernel/data/icons/wxart_delete.xpm b/kernel/data/icons/wxart_delete.xpm
new file mode 100644 (file)
index 0000000..b7ecf3a
--- /dev/null
@@ -0,0 +1,42 @@
+/* XPM */
+static char *delete_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 15 21 1",
+"2 c #A5AEBD",
+"* c #5478B4",
+"< c #95A3BB",
+"O c #9AA7BC",
+"; c #758EB7",
+"$ c #6986B6",
+"# c #4971B2",
+"& c #8A9CBA",
+"X c #8598B9",
+"  c None",
+"o c #ABB2BE",
+"- c #7F95B9",
+"= c #4E74B3",
+"1 c #A0ABBC",
+"+ c #6F8AB7",
+". c #B5B9BF",
+"@ c #3E69B1",
+", c #90A0BA",
+": c #6483B5",
+"> c #5A7BB4",
+"% c #5F7FB5",
+/* pixels */
+"                ",
+"    .Xo      OO ",
+"    +@#.    $@% ",
+"    &@@X  .*@*o ",
+"     =@= .*@*.  ",
+"     -@@X*@*.   ",
+"     .#@@@$.    ",
+"      ;@@:      ",
+"     ;@@@+      ",
+"   .>@#%@@.     ",
+"  o*@*oO@@,     ",
+" <#@*. .@@=     ",
+"&@@$    :@@1    ",
+";#&     2#>.    ",
+"                "
+};
diff --git a/kernel/data/icons/wxart_down.xpm b/kernel/data/icons/wxart_down.xpm
new file mode 100644 (file)
index 0000000..f03819e
--- /dev/null
@@ -0,0 +1,21 @@
+/* XPM */
+static char * down_xpm[] = {
+"16 15 3 1",
+"      c None",
+".     c Black",
+"X     c Gray100",
+"                ",
+"     ......     ",
+"     .XXXX.     ",
+"     .XXXX.     ",
+"     .XXXX.     ",
+"     .XXXX.     ",
+"     .XXXX.     ",
+"     .XXXX.     ",
+"  ....XXXX....  ",
+"   .XXXXXXXX.   ",
+"    .XXXXXX.    ",
+"     .XXXX.     ",
+"      .XX.      ",
+"       ..       ",
+"                "};
diff --git a/kernel/data/icons/wxart_eldel.xpm b/kernel/data/icons/wxart_eldel.xpm
new file mode 100644 (file)
index 0000000..9b83bb0
--- /dev/null
@@ -0,0 +1,22 @@
+/* XPM */
+static char * eldel_xpm[] = {
+"16 16 3 1",
+"      c None",
+".     c #7F0000",
+"+     c #FFFFFF",
+"                ",
+"                ",
+"                ",
+" ..+        ..+ ",
+" ....+     ..+  ",
+"  ....+   ..+   ",
+"    ...+ .+     ",
+"     .....+     ",
+"      ...+      ",
+"     .....+     ",
+"    ...+ ..+    ",
+"   ...+   ..+   ",
+"  ...+     .+   ",
+"  ...+      .+  ",
+"   .         .  ",
+"                "};
diff --git a/kernel/data/icons/wxart_eldown.xpm b/kernel/data/icons/wxart_eldown.xpm
new file mode 100644 (file)
index 0000000..656cb9c
--- /dev/null
@@ -0,0 +1,21 @@
+/* XPM */
+static char * eldown_xpm[] = {
+"16 16 2 1",
+"      c None",
+".     c #000000",
+"                ",
+"                ",
+"         ...    ",
+"        ...     ",
+"       ...      ",
+"       ...      ",
+"       ...      ",
+"       ...      ",
+"   ...........  ",
+"    .........   ",
+"     .......    ",
+"      .....     ",
+"       ...      ",
+"        .       ",
+"                ",
+"                "};
diff --git a/kernel/data/icons/wxart_exefile.xpm b/kernel/data/icons/wxart_exefile.xpm
new file mode 100644 (file)
index 0000000..4defb73
--- /dev/null
@@ -0,0 +1,73 @@
+/* XPM */
+static char *exefile_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 51 1",
+"% c #E8E8EC",
+"= c #E8E8ED",
+"z c #CACAD4",
+"8 c #D9D9E1",
+"p c #D2D2DA",
+"u c #E1E1E7",
+"a c #D2D2DB",
+"< c #E9E9ED",
+"q c #DADAE1",
+"+ c #F1F1F4",
+"g c #D3D3DB",
+"1 c #E2E2E8",
+"x c #D3D3DC",
+"5 c #00A5FF",
+"$ c #EAEAEE",
+"4 c #DBDBE2",
+"h c #CCCCD6",
+"y c #D4D4DC",
+"r c #E3E3E9",
+"d c #D4D4DD",
+"7 c #DCDCE2",
+": c #EBEBEF",
+"0 c #DCDCE3",
+"  c None",
+"O c #F3F3F5",
+"> c #E4E4E9",
+"& c #F3F3F6",
+"j c #D5D5DD",
+"6 c #E4E4EA",
+". c #C6C6D5",
+"# c #ECECF0",
+"f c #CECED7",
+"l c #CECED8",
+"e c #D6D6DE",
+"; c #EDEDF0",
+"3 c #DEDEE4",
+", c #EDEDF1",
+"c c #CFCFD8",
+"o c #F5F5F7",
+"- c #E6E6EB",
+"w c #D7D7DF",
+"v c #C8C8D3",
+"i c #DFDFE5",
+"@ c #EEEEF2",
+"s c #D0D0D9",
+"X c #9494AD",
+"9 c #D8D8DF",
+"t c #D8D8E0",
+"* c #EFEFF2",
+"2 c #E0E0E6",
+"k c #D1D1DA",
+/* pixels */
+"  ........X     ",
+"  .oO+@#$%XX    ",
+"  .&+*#$=-XXX   ",
+"  .+*;:=->XXXX  ",
+"  .*,:<->1234X  ",
+"  .,5:5612378X  ",
+"  5,5559530qwX  ",
+"  55555550q9eX  ",
+" 5555r5555teyX  ",
+"  55rui559eypX  ",
+" 5555i5555yasX  ",
+"  5555555dasfX  ",
+"  5355595gsfhX  ",
+"  .3595jgklhzX  ",
+"  .0qwjxkchzvX  ",
+"  XXXXXXXXXXXX  "
+};
diff --git a/kernel/data/icons/wxart_fileopen.xpm b/kernel/data/icons/wxart_fileopen.xpm
new file mode 100644 (file)
index 0000000..50724a8
--- /dev/null
@@ -0,0 +1,57 @@
+/* XPM */
+static char *fileopen_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 15 36 1",
+"6 c #9BACC2",
+"< c #9AEA53",
+"9 c #94A5BD",
+"5 c #839CB5",
+"; c #4D7492",
+". c #376485",
+"$ c #7F99B4",
+"r c #D1D9E5",
+"7 c #EAEDF3",
+"@ c #CAD2DC",
+"% c #718BA7",
+"t c #BECAD9",
+"& c #65839D",
+"0 c #DCE2EA",
+"4 c #F5F6F7",
+"w c #597B9A",
+"O c #8DA0B9",
+"  c None",
+"+ c #467291",
+"u c #305F81",
+"= c #B4C4D3",
+"# c #CAE2AA",
+"1 c #FAFCFE",
+"3 c #A8B6CA",
+"q c #E4E9ED",
+"8 c #EEF1F3",
+"X c #215579",
+"2 c #7F97B0",
+": c #B3BFD1",
+"y c #7A90AC",
+", c #C2CBDB",
+"- c #ADD668",
+"* c #B6D791",
+"e c #CAD6E1",
+"o c #DFF0D0",
+"> c #BBC4D6",
+/* pixels */
+"                ",
+"     ....       ",
+"XXXXX .oo.      ",
+"XOOOO+@.#o.     ",
+"XOOOO$%&.*oXXX  ",
+"XOOOOOOO.*oX=X  ",
+"XOXXXX...-oXXXX;",
+"XOX:>,.<<<<<oX1;",
+"X2X3:>,.<<<oX4=;",
+"XX563:>>.<oX78; ",
+"XXO963:>>.X0q7; ",
+"Xw2O963:>>er0t; ",
+"X&y2O963:>,er;  ",
+"uXXXXXXXXXXXX;  ",
+"                "
+};
diff --git a/kernel/data/icons/wxart_filesave.xpm b/kernel/data/icons/wxart_filesave.xpm
new file mode 100644 (file)
index 0000000..5c63fcf
--- /dev/null
@@ -0,0 +1,42 @@
+/* XPM */
+static char *filesave_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 15 21 1",
+"O c #FFFFFF",
+"> c #D5D6D8",
+"; c #446A8C",
+"1 c #CAD2DC",
+": c #C0C7D1",
+"  c #5F666D",
+"% c #A5B0BA",
+"o c #65839D",
+", c #DCE2EA",
+"< c #C3C5C8",
+"- c #E1E6EE",
+"* c #C6CCD3",
+". c None",
+"$ c #305F81",
+"2 c #D6DFE7",
+"= c #D2D9E0",
+"& c #B7BFC7",
+"X c #1B4467",
+"# c #BCBDBE",
+"@ c #7A90AC",
+"+ c #5D7C93",
+/* pixels */
+"               .",
+" XoOOOOOOOOO+X .",
+" @oO#######O+@ .",
+" @oOOOOOOOOO+@ .",
+" @oO#######O+@ .",
+" @oOOOOOOOOO+@ .",
+" @@+++++++++@@ .",
+" @@@@@@@@@@@@@ .",
+" @@@$$$$$$$$@@ .",
+" @@$%%%&*=-O$@ .",
+" @@$%X;;*=-O$@ .",
+" @@$%X;;:>,O$@ .",
+" @@$%X;;<12O$@ .",
+" @@$<<2OOOOO$@ .",
+".             .."
+};
diff --git a/kernel/data/icons/wxart_filesaveas.xpm b/kernel/data/icons/wxart_filesaveas.xpm
new file mode 100644 (file)
index 0000000..9fb5fca
--- /dev/null
@@ -0,0 +1,44 @@
+/* XPM */
+static char *filesaveas_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 15 23 1",
+"X c Black",
+"+ c #FFFFFF",
+"< c #D5D6D8",
+"> c #446A8C",
+"3 c #CAD2DC",
+", c #C0C7D1",
+"  c #5F666D",
+"* c #A5B0BA",
+"O c #65839D",
+"1 c #DCE2EA",
+"2 c #C3C5C8",
+": c #E1E6EE",
+". c #FFFF00",
+"- c #C6CCD3",
+"@ c None",
+"& c #305F81",
+"4 c #D6DFE7",
+"; c #D2D9E0",
+"= c #B7BFC7",
+"o c #1B4467",
+"$ c #BCBDBE",
+"# c #7A90AC",
+"% c #5D7C93",
+/* pixels */
+"         .X .XX.",
+" oO+++++++.X.X.@",
+" #O+$$$$$XX...XX",
+" #O++++++.......",
+" #O+$$$$$XX...XX",
+" #O+++++++.X.X.@",
+" ##%%%%%%.X%.X .",
+" ############# @",
+" ###&&&&&&&&## @",
+" ##&***=-;:+&# @",
+" ##&*o>>-;:+&# @",
+" ##&*o>>,<1+&# @",
+" ##&*o>>234+&# @",
+" ##&224+++++&# @",
+"@             @@"
+};
diff --git a/kernel/data/icons/wxart_new.xpm b/kernel/data/icons/wxart_new.xpm
new file mode 100644 (file)
index 0000000..4c2641c
--- /dev/null
@@ -0,0 +1,50 @@
+/* XPM */
+static char *new_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 15 29 1",
+"* c #97C4E7",
+"- c #72A8D2",
+": c #FFFFFF",
+"9 c #839CB5",
+"o c #6B98B8",
+"X c #5A89A6",
+"# c #3A749C",
+", c #D1E5F5",
+"0 c #85A7BC",
+"$ c #C3DDF1",
+"8 c #749BB4",
+"; c #5F9BC8",
+"  c None",
+"+ c #538DB3",
+"= c #85BBE2",
+"3 c #EFF6FC",
+"O c #6591AE",
+"5 c #F7FBFD",
+"7 c #FAFCFE",
+"< c #DAEAF7",
+"4 c #E9F3FA",
+"6 c #FDFDFE",
+"1 c #E2EFF8",
+". c #8EA9BC",
+"% c #B6D5EE",
+"& c #A5CCEA",
+"> c #ACE95B",
+"2 c #F4F9FD",
+"@ c #4581AA",
+/* pixels */
+"   .XoOO+@#.    ",
+"   .$$%&*=O-;   ",
+"  @@@@$%&*O:*o  ",
+"  @>>@$$%&O::*o ",
+"@@@>>@@@$%OOoO+ ",
+"@>>>>>>@,$%&*=+ ",
+"@>>>>>>@<,$%&*+ ",
+"@@@>>@@@1<,$%&O ",
+"  @>>@2341<,$%O ",
+"  @@@@52341<,$o ",
+"   .:6752341<,8 ",
+"   .::6752341<8 ",
+"   .:::67523419 ",
+"   .::::6752340 ",
+"   ............ "
+};
index 67370a9100f084697e921e7f39bc4b05a17db25e..2840b1223a038ab5e17bc550f511d0bb817fe37a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.cxx,v $ $
   Language:  C++
-  Date:      $Date: 2008/03/25 06:22:53 $
-  Version:   $Revision: 1.53 $
+  Date:      $Date: 2008/03/25 15:47:54 $
+  Version:   $Revision: 1.54 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -331,7 +331,8 @@ bufferNb =0;
          if (fs!=0) in_script = true;    
          file = mFileName.back();
          line = mLine.back();
-       }    
+       }   
+       CloseAllFiles();
        throw InterpreterError(e,in_script,file,line);
       }
     else
@@ -361,7 +362,8 @@ bufferNb =0;
          file = mFileName.back();
          line = mLine.back();
        }    
-       throw InterpreterError(e.what(),in_script,file,line);
+       CloseAllFiles();
+       throw InterpreterError(e.what(),in_script,file,line);
       }
     else
       {
@@ -390,7 +392,8 @@ bufferNb =0;
          file = mFileName.back();
          line = mLine.back();
        }    
-       throw InterpreterError("Unknown exception caught",
+       CloseAllFiles();
+       throw InterpreterError("Unknown exception caught",
                                   in_script,file,line);
       }
     else
index a1d274df8542aba28916fae0ea479290d022067d..136986a640ac2fd3068c3d85fe13a0851115974d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUIScriptingInterface.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/25 10:31:18 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2008/03/25 15:47:54 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -72,6 +72,7 @@ namespace bbtk
     mInterpreter = new bbtk::Interpreter();
     mInterpreter->SetUser(this);
     mInterpreter->SetCommandLine(true);
+    mInterpreter->SetThrow(true);
     //==============
     // Menu
     wxInitAllImageHandlers();
@@ -102,9 +103,15 @@ namespace bbtk
     menuWindows->AppendSeparator();
     menuWindows->Append ( ID_Menu_Windows_Save, _T("Save interface configuration"));
 
+    wxMenu *menuOptions = new wxMenu;
+    mwxMenuItemReset = menuOptions->AppendCheckItem(-1,
+                                                   _T("Reset before running") );
+    mwxMenuItemReset->Check();
+
     wxMenuBar *menuBar = new wxMenuBar;
     menuBar->Append( menuFile, _T("&File") );
     menuBar->Append( menuTools, _T("&Tools") );
+    menuBar->Append( menuOptions, _T("&Options") );
     menuBar->Append( menuWindows, _T("&Windows") );
     menuBar->Append( menuAbout, _T("About") );
     
@@ -197,31 +204,46 @@ namespace bbtk
     mWxGUITextEditor->Open(filename);
   }
   //================================================================
-
+  
+#define CATCH_MACRO                                                    \
+  catch (InterpreterError e)                                           \
+    {                                                                  \
+      std::cerr << "* IERROR : "<<e.GetMessage()<<std::endl;           \
+      if (e.IsInScriptFile())                                          \
+       std::cerr << "* FILE   : '"<<e.GetScriptFile()<<"'"<<std::endl; \
+      std::cerr << "* LINE   : "<<e.GetScriptLine()<<std::endl;                \
+      int lev = bbtk::MessageManager::GetMessageLevel("Error");                \
+      if (lev > 0) {                                                   \
+       std::cerr << "* Exception thrown : "<<std::endl;                \
+       std::cerr << "*  OBJECT : " <<e.GetObject()<<std::endl;         \
+       std::cerr << "*  FILE   : " <<e.GetSourceFile()<<std::endl;     \
+      }                                                                        \
+    }
+  
   //================================================================
   void WxGUIScriptingInterface::WxGUICommandEnter(const std::string& command)
   {
     std::string s("> ");
     s += command + "\n";
     mWxGUIOutputMessages->Print(s,wxRED);
-
-    if (  mInterpreter->InterpretLine( command ) == 
-         Interpreter::Interpreter_QUIT )
+    
+    try
       {
-       Close(true); 
+       mInterpreter->InterpretLine( command );
       }
+    CATCH_MACRO;
   }
   //================================================================
-
+  
   //================================================================
   /// Runs the interpretation of a file
   bool WxGUIScriptingInterface::InterpretFile( const std::string& filename) 
   { 
-    if ( mInterpreter->InterpretFile(filename) ==
-        Interpreter::Interpreter_ERROR ) 
+    try
       {
-       return false;
+       mInterpreter->InterpretFile(filename);
       }
+    CATCH_MACRO;
     return true;
   }
   //================================================================
@@ -232,55 +254,19 @@ namespace bbtk
     //    wxString temp = mWxGUIHtmlBrowser->GetCurrentPage();
     std::stringstream* buf = new std::stringstream;
     (*buf) << mWxGUITextEditor->GetCurrentPage()->GetText();
-
-    mInterpreter->SetThrow(true);
     try 
       {
+       if (mwxMenuItemReset->IsChecked()) WxGUICommandEnter("reset");
        mInterpreter->InterpretBuffer(buf);
       }
-    catch (InterpreterError e)
-      {
-       std::cerr << "* IERROR : "<<e.GetMessage()<<std::endl; 
-       if (e.IsInScriptFile())  
-         std::cerr << "* FILE   : '"<<e.GetScriptFile()<<"'"<<std::endl;
-       std::cerr << "* LINE   : "<<e.GetScriptLine()<<std::endl;
-       int lev = bbtk::MessageManager::GetMessageLevel("Error");
-       if (lev > 0) {
-         std::cerr << "* Exception thrown : "<<std::endl;
-         std::cerr << "*  OBJECT : " <<e.GetObject()<<std::endl;
-         std::cerr << "*  FILE   : " <<e.GetSourceFile()<<std::endl;
-       }         
-      }
-    /*
-   //    wxString temp = mWxGUIHtmlBrowser->GetCurrentPage();
-    std::string filename = mWxGUITextEditor->GetCurrentPage();//wx2std(temp);
-    size_t s = filename.length();
-
-    Interpreter* I = new Interpreter;
-    
-    if ((s>3) && (filename[s-1]=='s')
-       && (filename[s-2]=='b')
-       && (filename[s-3]=='b')
-       && (filename[s-4]=='.'))
-      {
-        std::string tmp("Executing ");
-        tmp += filename;
-       SetStatusText(std2wx(tmp));
-       I->InterpretFile(filename);
-      }
-    else
-      {
-       SetStatusText(_T("The current page is not a bbs file : cannot execute it"));
-      }
-    
-    delete I;
-    */
+    CATCH_MACRO
   }
   //================================================================  
 
   //================================================================
   void WxGUIScriptingInterface::OnMenuQuit(wxCommandEvent& WXUNUSED(event))
   {
+    if (!mWxGUITextEditor->CloseAllPages()) return;
     Close(true);
   }
   //================================================================
index 44c04dcb8340e36380d21444c8b57b14f24841bb..e817bcb78430b24f2ce87f757204c1e0dbe38699 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUIScriptingInterface.h,v $
   Language:  C++
-  Date:      $Date: 2008/03/25 10:31:18 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2008/03/25 15:47:54 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -103,7 +103,6 @@ namespace bbtk
     void OnMenuWindowsSave( wxCommandEvent& WXUNUSED(event));
     void OnMenuWindowsCheck( wxCommandEvent& event, 
                             wxWindow* w);
-   
     void OnPaneClose(wxAuiManagerEvent& evt);
    
 
@@ -135,6 +134,7 @@ namespace bbtk
     WxGUIHtmlBrowser* mWxGUIHtmlBrowser;
     WxGUITextEditor* mWxGUITextEditor;
 
+    wxMenuItem* mwxMenuItemReset;
     //    wxButton* mwxButtonRun;
 
   public:
index b4f10c49ddc768a76a2b50b180e6a5bc91673f0c..56a5a97d56cfea3d7f7dea82c6b76fc879d99c0d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUITextEditor.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/25 10:31:18 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2008/03/25 15:47:54 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include "icons/cc_run.xpm"
 #include "icons/cc_exit.xpm"
 
+#include "../data/icons/wxart_new.xpm"
+#include "../data/icons/wxart_fileopen.xpm"
+#include "../data/icons/wxart_filesave.xpm"
+#include "../data/icons/wxart_filesaveas.xpm"
+#include "../data/icons/wxart_exefile.xpm"
+#include "../data/icons/wxart_delete.xpm"
+#include "../data/icons/wxart_down.xpm"
+#include "../data/icons/wxart_eldel.xpm"
 
 namespace bbtk
 {
@@ -240,25 +248,42 @@ namespace bbtk
     // BUTTONS
     wxPanel *btnsCtrlPanel = new wxPanel(this,-1);
     wxBoxSizer *btnsSizer  = new wxBoxSizer(wxHORIZONTAL);
-    
+    /*   
     wxBitmap bmp_new(cc_new_xpm);
-    mwxButtonNew = new wxBitmapButton( btnsCtrlPanel,ID_ButtonNew,bmp_new);//_T("New")  );
-    btnsSizer->Add( mwxButtonNew );
     wxBitmap bmp_open(cc_open_xpm);
-    mwxButtonOpen = new wxBitmapButton( btnsCtrlPanel,ID_ButtonOpen,bmp_open);//,_T("Open")  );
-    btnsSizer->Add( mwxButtonOpen );
     wxBitmap bmp_close(cc_stop_xpm);
-    mwxButtonClose = new wxBitmapButton( btnsCtrlPanel,ID_ButtonClose,bmp_close);//,_T("Open")  );
-    btnsSizer->Add( mwxButtonClose );
     wxBitmap bmp_save(cc_save_xpm);
-    mwxButtonSave = new wxBitmapButton( btnsCtrlPanel,ID_ButtonSave,bmp_save);//_T("Save")  );
-    btnsSizer->Add( mwxButtonSave );
     wxBitmap bmp_saveas(cc_save_as_xpm);
-    mwxButtonSaveAs = new wxBitmapButton( btnsCtrlPanel,ID_ButtonSaveAs,bmp_saveas);//_T("Save")  );
+    wxBitmap bmp_run(cc_run_xpm);
+    */
+    wxBitmap bmp_new(new_xpm);
+    wxBitmap bmp_open(fileopen_xpm);
+    wxBitmap bmp_close(eldel_xpm);
+    wxBitmap bmp_save(filesave_xpm);
+    wxBitmap bmp_saveas(filesaveas_xpm);
+    wxBitmap bmp_run(down_xpm);
+
+
+    wxSize btn_size(32,32);
+    mwxButtonNew = new wxBitmapButton( btnsCtrlPanel,ID_ButtonNew,bmp_new
+                                      ,wxDefaultPosition, btn_size);
+    btnsSizer->Add( mwxButtonNew );
+
+    mwxButtonOpen = new wxBitmapButton( btnsCtrlPanel,ID_ButtonOpen,bmp_open ,wxDefaultPosition, btn_size);//,_T("Open")  );
+    btnsSizer->Add( mwxButtonOpen );
+
+    mwxButtonClose = new wxBitmapButton( btnsCtrlPanel,ID_ButtonClose,bmp_close ,wxDefaultPosition, btn_size);//,_T("Open")  );
+    btnsSizer->Add( mwxButtonClose );
+
+    mwxButtonSave = new wxBitmapButton( btnsCtrlPanel,ID_ButtonSave,bmp_save ,wxDefaultPosition, btn_size);//_T("Save")  );
+    btnsSizer->Add( mwxButtonSave );
+
+    mwxButtonSaveAs = new wxBitmapButton( btnsCtrlPanel,ID_ButtonSaveAs,bmp_saveas ,wxDefaultPosition, btn_size);//_T("Save")  );
     btnsSizer->Add( mwxButtonSaveAs );
 
-    wxBitmap bmp_run(cc_run_xpm);
-    mwxButtonRun = new wxBitmapButton( btnsCtrlPanel,ID_ButtonRun,bmp_run);//_T("Run")  );
+
+    mwxButtonRun = new wxBitmapButton( btnsCtrlPanel,ID_ButtonRun,bmp_run ,wxDefaultPosition, btn_size);//_T("Run")  );
     btnsSizer->Add( mwxButtonRun );
     /*
     wxBitmap bmp_quit(cc_exit_xpm);
@@ -287,6 +312,7 @@ namespace bbtk
   WxGUITextEditor::~WxGUITextEditor()
   {
     m_mgr.UnInit();
+
     //    delete mInterpreter;
   }
   //================================================================
@@ -363,19 +389,28 @@ namespace bbtk
   //================================================================  
   void WxGUITextEditor::OnButtonClose(wxCommandEvent& event) 
   { 
+    CloseCurrentPage();
+  } 
+  //================================================================  
+
+  //================================================================  
+  bool WxGUITextEditor::CloseCurrentPage()
+  {
     std::cout << "-------------- CLOSE ---------------"<<std::endl;
-    if (mwxNotebook->GetPageCount()==0) return;
+    if (mwxNotebook->GetPageCount()==0) return true;
     if (GetCurrentPage()->IsModified()) 
       {
+       wxString mess = std2wx(GetCurrentPage()->GetPageName());
+       mess += _T(" modified. Save it ?");
        wxMessageDialog* d = 
          new wxMessageDialog(this,
-                             _T("Buffer modified. Save it ?")
+                             mess
                              _T("Save buffer"), 
                              wxYES_NO | wxCANCEL | wxICON_QUESTION);
        switch (d->ShowModal())
          {
          case wxID_CANCEL : 
-           return;
+           return false;
            break;
          case wxID_YES : 
            GetCurrentPage()->Save(mFileNameFilter); 
@@ -385,17 +420,33 @@ namespace bbtk
       } 
     mwxNotebook->DeletePage(mwxNotebook->GetSelection());
     FocusOnCurrentPage();
-  } 
+    return true;
+  }
+  //================================================================  
+
+  //================================================================  
+  bool WxGUITextEditor::CloseAllPages()
+  {
+    bool ok = true;
+    while (mwxNotebook->GetPageCount()!=0)
+      {
+       if (!CloseCurrentPage()) 
+         {
+           ok = false;
+           break;
+         }
+      }
+    return ok;
+  }
   //================================================================  
 
   //================================================================  
   void WxGUITextEditor::OnButtonSave(wxCommandEvent& event) 
   { 
-    Save();
+    SaveCurrentPage();
   } 
-  void WxGUITextEditor::Save()
+  void WxGUITextEditor::SaveCurrentPage()
   {
-    std::cout << "-------------- SAVE ---------------"<<std::endl;
     if (mwxNotebook->GetPageCount()==0) return;  
     GetCurrentPage()->Save(mFileNameFilter);
     mwxNotebook->SetPageText(mwxNotebook->GetSelection(),
@@ -408,7 +459,7 @@ namespace bbtk
   { 
     if (mwxNotebook->GetPageCount()==0) return;  
     GetCurrentPage()->SetAskFilename(true);
-    Save();
+    SaveCurrentPage();
   } 
   //================================================================  
 
@@ -416,6 +467,9 @@ namespace bbtk
   void WxGUITextEditor::OnPageClose(wxAuiNotebookEvent& evt)
   {
     std::cout << "-------------- CLOSE ---------------"<<std::endl;
+    if (!CloseCurrentPage()) evt.Veto();
+
+    /*
     if (mwxNotebook->GetPageCount()==0) return;
     if (GetCurrentPage()->IsModified()) 
       {
@@ -435,7 +489,7 @@ namespace bbtk
          case wxID_NO : ;
          }       
       }
-    
+    */
   }
   //================================================================
 
@@ -559,7 +613,7 @@ namespace bbtk
        switch (event.GetKeyCode())
          {
          case 'n': case 'N' : New(); break;
-         case 's': case 'S' : Save(); break;
+         case 's': case 'S' : SaveCurrentPage(); break;
          case 'o': case 'O' : Open(); break;
            //    case 'r': case 'R' : Run(); break;
            //    case 'q': case 'Q' : Quit(); break;
index cf97f648bbca3d574d6982eef221ad8ad12debe1..9c0d0d5264fdd98c0dd3505c7d301d70a1d394bd 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUITextEditor.h,v $
   Language:  C++
-  Date:      $Date: 2008/03/25 10:31:18 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2008/03/25 15:47:54 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -126,7 +126,9 @@ namespace bbtk
     void New();
     void Open();
     void Open(const std::string& filename);
-    void Save();
+    void SaveCurrentPage();
+    bool CloseCurrentPage();
+    bool CloseAllPages();
     //   void Run();
     //    void Quit();