]> Creatis software - bbtk.git/commitdiff
*** empty log message ***
authorguigues <guigues>
Tue, 18 Mar 2008 15:31:51 +0000 (15:31 +0000)
committerguigues <guigues>
Tue, 18 Mar 2008 15:31:51 +0000 (15:31 +0000)
kernel/src/bbtkWxEditor.cxx
kernel/src/bbtkWxEditor.h

index f36e5fa15375e1ca54a312ae437ba09f1a741b6b..ce668461816c736901f81848458ffdedb47cb6af 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxEditor.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/18 13:50:43 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/03/18 15:31:51 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -143,9 +143,15 @@ namespace bbtk
 
     //    wxFlexGridSizer *sizer= new wxFlexGridSizer(2);
     wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
-
+    mwxSplit = new wxSplitterWindow(this,
+                                                  -1,
+                                                  wxDefaultPosition,
+                                                  wxDefaultSize,
+                                                  //wxSize(400,200),
+                                                  wxSP_3D |
+                                                  wxSP_LIVE_UPDATE );
     mwxInputText = 
-      new WxTextCtrlGettingKeyEvents(this,
+      new WxTextCtrlGettingKeyEvents(mwxSplit,
                      ID_InputText,
                      _T(""),
                     wxDefaultPosition,
@@ -168,12 +174,12 @@ namespace bbtk
    mwxInputTextAttr->SetFont(*FixedFont);
 
    //   sizer->AddGrowableCol(0);
-   sizer->Add(mwxInputText,1,wxGROW);
+   //   sizer->Add(mwxInputText,1,wxGROW);
 
    mwxInputText->SetFocus();
 
    mwxOutputText = 
-      new WxTextCtrlGettingKeyEvents(this,
+      new WxTextCtrlGettingKeyEvents(mwxSplit,
                      ID_OutputText,
                      _T(""),wxDefaultPosition,
                      wxDefaultSize, //HistorySize,
@@ -184,9 +190,12 @@ namespace bbtk
 
    mwxOutputTextAttr = new wxTextAttr;
    mwxOutputTextAttr->SetFont(*FixedFont);
+   mwxOutputText->Hide();
+
+   //   sizer->Add(mwxOutputText,1,wxGROW);
+  sizer->Add(mwxSplit,1,wxGROW);
+  mwxSplit->Initialize(mwxInputText);
 
-   sizer->Add(mwxOutputText,1,wxGROW);
-     
    // BUTTONS
    wxPanel *btnsCtrlPanel = new wxPanel(this,-1);
    wxBoxSizer *btnsSizer  = new wxBoxSizer(wxHORIZONTAL);
@@ -207,39 +216,10 @@ namespace bbtk
    mwxButtonQuit = new wxBitmapButton( btnsCtrlPanel,ID_ButtonQuit,bmp_quit);//_T("Quit")  );
    btnsSizer->Add( mwxButtonQuit );
    
-   /*
- toolBarBitmaps[Tool_##bmp] = wxBitmap(bmp##_xpm)
-#else // !USE_XPM_BITMAPS
-    #define INIT_TOOL_BMP(bmp) \
-        toolBarBitmaps[Tool_##bmp] = wxBITMAP(bmp)
-#endif // USE_XPM_BITMAPS/!USE_XPM_BITMAPS
-
-    INIT_TOOL_BMP(new);
-    INIT_TOOL_BMP(open);
-    INIT_TOOL_BMP(save);
-    INIT_TOOL_BMP(copy);
-    INIT_TOOL_BMP(cut);
-    INIT_TOOL_BMP(paste);
-    INIT_TOOL_BMP(print);
-    INIT_TOOL_BMP(help);
-
-    int w = toolBarBitmaps[Tool_new].GetWidth(),
-        h = toolBarBitmaps[Tool_new].GetHeight();
-
-    if ( !m_smallToolbar )
-    {
-        w *= 2;
-        h *= 2;
-
-        for ( size_t n = Tool_new; n < WXSIZEOF(toolBarBitmaps); n++ )
-        {
-            toolBarBitmaps[n] =
-                wxBitmap(toolBarBitmaps[n].ConvertToImage().Scale(w, h));
-
-
-
-   */
-
+   mwxPosition = new wxStaticText ( btnsCtrlPanel, -1, _T(""));
+   btnsSizer->Add( mwxPosition );
+  
 
    btnsCtrlPanel->SetSizer(btnsSizer);
    sizer->Add ( btnsCtrlPanel, 0, wxLEFT | wxRIGHT | wxBOTTOM  //| wxGROW
@@ -342,8 +322,17 @@ namespace bbtk
   void WxEditor::Run()
   {
     std::cout << "-------------- RUN ---------------"<<std::endl;
+
+    if (!mwxSplit->IsSplit()) 
+      {
+       int size = -100;
+       int minsize = - (int)(mwxInputText->GetSize().GetHeight() / 2.);
+       if (size<minsize) size = minsize;
+       mwxSplit->SplitHorizontally( mwxInputText, mwxOutputText, size);
+      }
+
     std::stringstream* buffer = new std::stringstream(bbtk::wx2std(mwxInputText->GetValue()));
-    bool com;
+    bool com = false;
     mInterpreter->InterpretLine("reset",com);
     try 
       {
@@ -387,6 +376,20 @@ namespace bbtk
   //================================================================
   void WxEditor::OnKeyPress(wxKeyEvent& event)
   {
+    long line, column, pos = mwxInputText->GetInsertionPoint();
+     mwxInputText->PositionToXY(pos, &column, &line);
+
+     //                wxLogMessage(_T("Current position: %ld\nCurrent line, column: (%ld, %ld)\nNumber of lines: %ld\nCurrent line length: %ld\nTotal text length: %u (%ld)"),
+
+  
+     char mess[200];
+     sprintf(mess,"%ld:%ld / %ld:%ld (%ld char)",
+            line,column,
+            (long)mwxInputText->GetNumberOfLines(),
+            (long)mwxInputText->GetLineLength(line),
+            (long)mwxInputText->GetValue().length());
+
+     mwxPosition->SetLabel(wxString(mess));
     // std::cout << "Key="<<event.GetKeyCode()<<std::endl;
     if ( event.ControlDown() )
       {
index e21d2f686cb6ab2447a8111be87c9fc9b2ba2a6b..fb5551a2e0d9d59d80a43494cfdf5047ae92c059 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxEditor.h,v $
   Language:  C++
-  Date:      $Date: 2008/03/18 13:50:43 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/03/18 15:31:51 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -40,6 +40,7 @@
 #include "bbtkWx.h"
 
 #include "bbtkInterpreter.h"
+#include <wx/splitter.h>
 
 namespace bbtk
 {
@@ -74,6 +75,7 @@ namespace bbtk
     
   private:
     Interpreter* mInterpreter;
+    wxSplitterWindow* mwxSplit;
     WxTextCtrlGettingKeyEvents* mwxInputText;
     wxTextAttr* mwxInputTextAttr;
     WxTextCtrlGettingKeyEvents* mwxOutputText;
@@ -83,6 +85,7 @@ namespace bbtk
     wxButton *  mwxButtonSave; 
     wxButton *  mwxButtonRun; 
     wxButton *  mwxButtonQuit; 
+    wxStaticText* mwxPosition;
     WxStreamRedirector* mRedirect_cout;
     WxStreamRedirector* mRedirect_cerr;
    public: