]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkWxConsole.cxx
Created a bbs editor : bbed
[bbtk.git] / kernel / src / bbtkWxConsole.cxx
index 00267a92dff8b0f3d0f29f332a2d1f104ad26745..b425facebed4882d0859c7842b63e8b3b01ba706 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxConsole.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/07 11:37:48 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2008/03/18 12:51:26 $
+  Version:   $Revision: 1.16 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include "bbtkWxConsole.h"
 #include "bbtkWxBlackBox.h"
 #include "bbtkConfigurationFile.h"
+#include "bbtkWxStreamRedirector.h"
 
 namespace bbtk
 {
 
 
-// On Windows when compiling a dll, wx prevents the compilation
-// of the class wxStreamToTextRedirector (why ? it is a nightmare...)
-// The blocking symbol is wxHAS_TEXT_WINDOW_STREAM.
-// Note also that wxStreamToTextRedirector use the fact that wx is 
-// compiled with the option WX_USE_STD_STREAMS in which case 
-// wxTextCtrl inherits from std::streambuf and the redirection 
-// can be done simply by setting the std::cout buffer to the 
-// one of the wxTextCtrl. 
-// So on windows, we have to redirect manually std::cout to mwxTextHistory.  
-// Finally, on all systems we made our redirection class to redirect both to
-// the WxConsole and to printf in order to get a console trace when 
-// the appli crashes (we could also imagine to log in a file...)
-// This is why we finally wrote our own redirection which is crossplatform
-// (drawback : not optimal on Unix platform; we could think of 
-// a particular implementation...).
-
-  //================================================================
-  /// Redirects std::cout to a wxTextCtrl and optionally to printf also
-  class WxTextCtrlStreamRedirector   : public std::streambuf
-  {      
-    
-  public:
-    
-    WxTextCtrlStreamRedirector(std::ostream& redirect,
-                                wxTextCtrl *text, 
-                                const wxColour& colour = *wxBLACK,
-                                bool doprintf=true,
-                                int bufferSize=1000)
-      : mText(text),
-       mPrintf(doprintf),
-       m_ostr(redirect),
-       mColour(colour)
-    {
-      if (bufferSize)
-        {
-         char *ptr = new char[bufferSize];
-         setp(ptr, ptr + bufferSize);
-        }
-      else
-       setp(0, 0);
-      
-      m_sbufOld = m_ostr.rdbuf();
-      m_ostr.rdbuf(this);
-    }
-    
-    ~WxTextCtrlStreamRedirector()
-    {
-      sync();
-      delete[] pbase();
-      m_ostr.rdbuf(m_sbufOld);
-    }
-  
-   virtual void writeString(const std::string &str) 
-    {
-      const wxTextAttr& style = mText->GetDefaultStyle();
-      mText->SetDefaultStyle(mColour);
-      mText->AppendText(std2wx(str));
-      mText->SetDefaultStyle(style);
-     
-      if (mPrintf) 
-       {
-         printf("%s",str.c_str());
-       }
-    }
-    
-  
-  private:
-    wxTextCtrl* mText;
-    // 
-    bool mPrintf;
-    // the stream we're redirecting
-    std::ostream&   m_ostr;
-    // the old streambuf (before we changed it)
-    std::streambuf *m_sbufOld;
-    //
-    wxColour mColour;
-    
-  private:
-    int        overflow(int c)
-    {
-      sync();
-      
-      if (c != EOF)
-        {
-         if (pbase() == epptr())
-            {
-             std::string temp;
-             temp += char(c);
-             writeString(temp);
-            }
-         else
-           sputc(c);
-        }
-      
-      return 0;
-    }
-    
-    int        sync()
-    {
-      if (pbase() != pptr())
-        {
-         int len = int(pptr() - pbase());
-         std::string temp(pbase(), len);
-         writeString(temp);
-         setp(pbase(), epptr());
-        }
-      return 0;
-    }
-  };
-  //================================================================
-
-  
   
   //================================================================
   WxConsole::WxConsole( wxWindow *parent, wxString title, wxSize size)
     : wxFrame((wxFrame *)parent, -1, title, wxDefaultPosition, size)
   {    
+//    m_mgr = new wxAuiManager(this);
+       m_mgr.SetManagedWindow(this);
    
     mInterpreter = new bbtk::Interpreter();
     mInterpreter->SetWxConsole(this);
@@ -174,9 +64,11 @@ namespace bbtk
     menuAbout->Append( ID_Menu_About, _T("&About...") );
 
     wxMenu *menuTools = new wxMenu;
-    menuTools->Append( ID_Menu_CreatePackage, _T("&Create package") );
-    menuTools->Append( ID_Menu_CreateBlackBox, _T("&Create blackbox") );
+    menuTools->Append( ID_Menu_EditConfig, _T("&Edit bbtk config") );
+    menuTools->Append( ID_Menu_CreatePackage, _T("Create &package") );
+    menuTools->Append( ID_Menu_CreateBlackBox, _T("Create &blackbox") );
     menuTools->Append( ID_Menu_ShowImageGraph, _T("&Show last image graph") );
+    menuTools->Append( ID_Menu_CreateIndex, _T("&Generate index") );
     
     
     wxMenuBar *menuBar = new wxMenuBar;
@@ -197,23 +89,14 @@ namespace bbtk
 //EED    wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
 //    mwxNotebook = new wxNotebook(this,-1,wxDefaultPosition, wxDefaultSize, 0);
     mwxNotebook = new wxAuiNotebook(this,  
-                                                               -1, 
-                                                               wxPoint(0, 0), 
-                                                               wxSize(500,500),
-                                                               wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER);
-    
-    mwxPageCommand = new wxPanel(mwxNotebook,-1);    
-    mwxNotebook->AddPage( mwxPageCommand, _T("Command"));
+                                    -1,
+                                    wxPoint(0, 0),
+                                    wxSize(500,500),
+                                    wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER);
     
+    mwxPageCommand = new wxPanel(mwxNotebook,-1);        
     mwxPageHelp = new wxPanel(mwxNotebook,-1);    
-    mwxNotebook->AddPage( mwxPageHelp, _T("Help"));
     
-
-
-//EED    sizer->Add ( mwxNotebook, 1, wxEXPAND /*| wxALIGN_BOTTOM*/ );
-    wxAuiManager *m_mgr = new wxAuiManager(this);
-       m_mgr->AddPane(mwxNotebook, wxAuiPaneInfo().Name(wxT("notebook_content")).CenterPane().PaneBorder(false)); 
-    m_mgr->Update();
     
     wxBoxSizer *cmdsizer = new wxBoxSizer(wxVERTICAL);
     
@@ -242,17 +125,17 @@ namespace bbtk
 
     mwxTextHistory = 
       new wxTextCtrl(mwxPageCommand,
-                    ID_Text_History,
-                    _T(""),wxDefaultPosition,
-                    wxDefaultSize, //HistorySize,
-                    wxTE_READONLY |
-                    wxTE_MULTILINE );
+                     ID_Text_History,
+                     _T(""),wxDefaultPosition,
+                     wxDefaultSize, //HistorySize,
+                     wxTE_READONLY |
+                     wxTE_MULTILINE );
  
     wxFont* FixedFont = new wxFont(10,
-                                  wxFONTFAMILY_MODERN,
-                                  wxFONTSTYLE_NORMAL,
-                                  wxFONTWEIGHT_NORMAL,
-                                  false);
+                                   wxFONTFAMILY_MODERN,
+                                   wxFONTSTYLE_NORMAL,
+                                   wxFONTWEIGHT_NORMAL,
+                                   false);
 
    mwxTextHistoryAttr = new wxTextAttr;
    mwxTextHistoryAttr->SetFont(*FixedFont);
@@ -274,10 +157,11 @@ namespace bbtk
    mwxTextCommand = 
      new wxComboBox(mwxPageCommand,
                    ID_Text_Command,
-                   _T("")
-//                 wxDefaultPosition,
-//                 wxDefaultSize,
-//                 wxTE_PROCESS_ENTER
+                   _T(""),
+                   wxDefaultPosition,
+                   wxDefaultSize,
+                       0, NULL,
+                   wxTE_PROCESS_ENTER
 //                 | wxTE_PROCESS_TAB 
 //                 | wxWANTS_CHARS 
 //                 //|  wxTAB_TRAVERSAL
@@ -311,10 +195,10 @@ namespace bbtk
     // Events connection
     // COMMAND
     // ENTER
-    /*
     Connect( mwxTextCommand->GetId(),
             wxEVT_COMMAND_TEXT_ENTER,
             (wxObjectEventFunction)& WxConsole::OnCommandEnter );
+    /*
     Connect( mwxTextCommand->GetId(),
             wxEVT_CHAR,
             //wxEVT_COMMAND_TEXT_UPDATED,
@@ -325,26 +209,43 @@ namespace bbtk
 
     // Redirection of std::cout to mwxTextHistory and printf
     mRedirect_cout = 
-      new WxTextCtrlStreamRedirector(std::cout,mwxTextHistory,*wxBLACK,true);
+      new WxStreamRedirector(std::cout,mwxTextHistory,*wxBLACK,true);
     mRedirect_cerr = 
-      new WxTextCtrlStreamRedirector(std::cerr,mwxTextHistory,*wxGREEN,true); 
+      new WxStreamRedirector(std::cerr,mwxTextHistory,*wxGREEN,true); 
         
-    // Sets the console as the parent window of all bbtk windows
-    wxFrame* top = new wxFrame(this,-1,_T("invisible"));
+    // Creates and sets the parent window of all bbtk windows
+    wxWindow* top = new wxPanel(this,-1);//,_T("top"));
+    top->Hide();
+    //new wxFrame(this,-1,_T("bbtk"),
+    //                        wxDefaultPosition,
+    //                        wxSize(0,0),
+    //                        wxFRAME_TOOL_WINDOW) ;//wxMINIMIZE_BOX);
+
     Wx::SetTopWindow(top);
 
+    //    top->Show();
+    
 
     // Layout
 //EED    SetSizer(sizer);
-    SetAutoLayout(true);
-    Layout();
 
+       mwxNotebook->AddPage( mwxPageCommand, _T("Command"));
+    mwxNotebook->AddPage( mwxPageHelp, _T("Help"));
+       m_mgr.AddPane(mwxNotebook, wxAuiPaneInfo().Name(wxT("notebook_content")).CenterPane().PaneBorder(false)); 
+    m_mgr.Update();
+
+       
+       SetAutoLayout(true);
+    Layout();
+//    Refresh();
+//    m_mgr.Update();
   }
   //================================================================
 
  //================================================================
   WxConsole::~WxConsole()
   {
+       m_mgr.UnInit();
     delete mRedirect_cout;
     delete mRedirect_cerr;
   }
@@ -370,14 +271,14 @@ namespace bbtk
   //================================================================
   void WxConsole::CommandString(wxString line )
   {
-printf("WxConsole::CommandString 01 \n");
+    //printf("WxConsole::CommandString 01 \n");
     wxString s = _T("> ") + line + _T("\n");
     mwxTextHistoryAttr->SetTextColour(*wxRED);
     mwxTextHistory->SetDefaultStyle(*mwxTextHistoryAttr);
     mwxTextHistory->AppendText(s);
     // send to standard console also 
-printf("WxConsole::CommandString 02 \n");
-    printf("%s",wx2std(s).c_str());
+    //printf("WxConsole::CommandString 02 \n");
+    //    printf("%s",wx2std(s).c_str());
 //EED    mwxTextCommand->Clear();
     mwxTextCommand->SetValue(_T(""));
        mwxTextCommand->Append(line);
@@ -386,32 +287,31 @@ printf("WxConsole::CommandString 02 \n");
     mwxTextHistoryAttr->SetTextColour(*wxBLACK);
     mwxTextHistory->SetDefaultStyle(*mwxTextHistoryAttr);
 
-printf("WxConsole::CommandString 03 \n");
+    //printf("WxConsole::CommandString 03 \n");
     try 
     {
       bool insideComment = false;
-printf("WxConsole::CommandString 04 \n");
-          mInterpreter->InterpretLine( wx2std(line), insideComment );
-printf("WxConsole::CommandString 05 \n");
+
+      mInterpreter->InterpretLine( wx2std(line), insideComment );
     }
     catch (bbtk::QuitException)
     {
-          Close(true); 
+       Close(true); 
     }
     catch (bbtk::Exception e) 
     {
-          e.Print();
+       e.Print();
     }
     catch (std::exception& e) 
     {
-          std::cout << "* ERROR : "<<e.what()<<" (not in bbtk)"<<std::endl;
+       std::cout << "* ERROR : "<<e.what()<<" (not in bbtk)"<<std::endl;
     }
     catch (...)
     {
-          std::cout << "* UNDEFINED ERROR (not a bbtk nor a std exception)"
-                         << std::endl;
+       std::cout << "* UNDEFINED ERROR (not a bbtk nor a std exception)"
+                 << std::endl;
     }
-printf("WxConsole::CommandString 06 \n");
+    //printf("WxConsole::CommandString 06 \n");
   }
   //================================================================
 
@@ -427,21 +327,40 @@ printf("WxConsole::CommandString 06 \n");
   //================================================================
   void WxConsole::OnMenuAbout(wxCommandEvent& WXUNUSED(event))
   {
-    
-    wxMessageBox(_T("  bbi\nThe Black Box Toolkit interpreter\n(c) CREATIS-LRMN 2007"),
-                _T("About ..."), wxOK | wxICON_INFORMATION, 
-                this);
+    m_mgr.Update();
+       Refresh();
+    wxMessageBox(_T("  bbi\nThe Black Box Toolkit interpreter\n(c) CREATIS-LRMN 2008"),
+                 _T("About ..."), wxOK | wxICON_INFORMATION,
+                 this);
   }
   //================================================================
 
-  
+
+  //================================================================
+  void WxConsole::OnMenuEditConfig(wxCommandEvent& WXUNUSED(event))
+  {
+       std::string commandStr;
+    std::string configFile = ConfigurationFile::GetInstance().Get_config_xml_full_path();
+#ifdef WIN32
+       commandStr = "notepad.exe ";
+#else
+       commandStr = "gedit ";
+#endif 
+       commandStr = commandStr + configFile;
+       std::cout << "system: " << commandStr << std::endl;
+       system ( commandStr.c_str() );
+  }
+  //================================================================
+
+
   //================================================================
   void WxConsole::OnMenuCreatePackage(wxCommandEvent& WXUNUSED(event))
   {
-    
-    wxMessageBox(_T("  Creating Package"),
-                _T("Creating Package ..."), wxOK | wxICON_INFORMATION, 
-                this);
+    std::string command("toolsbbtk/appli/CreatePackage");
+    bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
+    Interpreter* I = new Interpreter;    
+    I->InterpretFile(command);
+    delete I;
   }
   //================================================================
 
@@ -449,29 +368,56 @@ printf("WxConsole::CommandString 06 \n");
   //================================================================
   void WxConsole::OnMenuCreateBlackBox(wxCommandEvent& WXUNUSED(event))
   {
-    
-    wxMessageBox(_T("  Creating blackbox"),
-                _T("Creating blackbox ..."), wxOK | wxICON_INFORMATION, 
-                this);
+    std::string command("toolsbbtk/appli/CreateBlackBox");
+    bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
+    Interpreter* I = new Interpreter;    
+    I->InterpretFile(command);
+    delete I;
   }
   //================================================================
   
   //================================================================
   void WxConsole::OnMenuShowImageGraph(wxCommandEvent& WXUNUSED(event))
   {
-    std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
+    std::string default_temp_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
 
 #if defined(WIN32)
     std::string strappli="start ";
 #else
     std::string strappli="gnome-open ";
 #endif
-    std::string strcommand = strappli +default_doc_dir+"/temp_dir/workspace_workspacePrototype.png";
+    std::string strcommand = strappli +default_temp_dir+"/temp_dir/workspace_workspacePrototype.png";
+       std::cout << "system: " << strcommand << std::endl;
     system ( strcommand.c_str() );
+
   }
   //================================================================
 
-  
+
+  //================================================================
+  void WxConsole::OnMenuCreateIndex(wxCommandEvent& WXUNUSED(event))
+  {
+    std::string doc_path = ConfigurationFile::GetInstance().Get_doc_path();
+    std::string filepath = doc_path+"/bbdoc/make-index.bbs";
+    Interpreter* I = new Interpreter;    
+
+//EED  std::cout << "bbi: include "<<filepath<<std::endl;
+//EED  I->InterpretFile( filepath );
+
+    bool insideComment = false; // for multiline comment
+       I->InterpretLine( "exec freeze" ,insideComment );
+       I->InterpretLine( "include *" ,insideComment );
+       I->InterpretLine( "index "+doc_path+"/bbdoc/index-alpha.html Initials" ,insideComment );
+       I->InterpretLine( "index "+doc_path+"/bbdoc/index-package.html Packages" ,insideComment );
+       I->InterpretLine( "index "+doc_path+"/bbdoc/index-category.html Categories" ,insideComment );
+       I->InterpretLine( "index "+doc_path+"/bbdoc/index-adaptors.html Adaptors",insideComment  );
+
+    delete I;
+  }
+  //================================================================
+
+
+
   
   //================================================================
   void WxConsole::OnCommandChar(wxCommandEvent& event)
@@ -521,7 +467,7 @@ printf("WxConsole::CommandString 06 \n");
       }
     else 
       {
-       //      std::cout << "ERROR html"<<std::endl;
+         // std::cout << "ERROR html"<<std::endl;
       }
   } 
 
@@ -530,16 +476,16 @@ printf("WxConsole::CommandString 06 \n");
   //================================================================  
   wxPanel* WxConsole::CreateBtnsCtrlPanel(wxWindow *parent)
   {
-         wxPanel *btnsCtrlPanel        = new wxPanel(parent,-1);
-         wxBoxSizer *btnsSizer         = new wxBoxSizer(wxHORIZONTAL);
-         
-         wxButton *btnInclude  = new wxButton( btnsCtrlPanel,-1,_T("Include")  );
-         wxButton *btnReset    = new wxButton( btnsCtrlPanel,-1,_T("Reset")            );
-         wxButton *btnConfig   = new wxButton( btnsCtrlPanel,-1,_T("Config")           );
-         wxButton *btnGraphS   = new wxButton( btnsCtrlPanel,-1,_T("Graph S.") );
-         wxButton *btnGraphD   = new wxButton( btnsCtrlPanel,-1,_T("Graph D.") );
-         wxButton *btnHelp     = new wxButton( btnsCtrlPanel,-1,_T("Help")             );
+     wxPanel *btnsCtrlPanel = new wxPanel(parent,-1);
+     wxBoxSizer *btnsSizer     = new wxBoxSizer(wxHORIZONTAL);
          
+     wxButton *btnInclude  = new wxButton( btnsCtrlPanel,-1,_T("Include")  );
+     wxButton *btnReset    = new wxButton( btnsCtrlPanel,-1,_T("Reset")    );
+     wxButton *btnConfig   = new wxButton( btnsCtrlPanel,-1,_T("Config")   );
+     wxButton *btnGraphS   = new wxButton( btnsCtrlPanel,-1,_T("Graph simple") );
+     wxButton *btnGraphD   = new wxButton( btnsCtrlPanel,-1,_T("Graph detailed") );
+     wxButton *btnHelp     = new wxButton( btnsCtrlPanel,-1,_T("Help")     );
+
          btnsSizer->Add( btnInclude    );
          btnsSizer->Add( btnReset              );
          btnsSizer->Add( btnConfig             );
@@ -562,20 +508,20 @@ printf("WxConsole::CommandString 06 \n");
   //================================================================  
   void WxConsole::OnBtnInclude(wxCommandEvent& event)
   {
-           std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
-           std::string stdDir = default_doc_dir+"/share/bbtk/bbs";
-           wxString defaultDir(stdDir.c_str(), wxConvUTF8);
-           
-               wxFileDialog dialog(this, _T("Choose a file"),defaultDir, _T(""), _T("*.bbs"), wxOPEN );
-               if (dialog.ShowModal() == wxID_OK)
-               {
-//                     std::string command(_T("include "));
-//                     std::string pathfilename                = (const char *)(dialog.GetFilename().mb_str());
-                       wxString command(_T("include "));
-                       wxString pathfilename = dialog.GetPath();
-                       command += pathfilename;
-                       CommandString( command );
-               }
+     std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
+     std::string stdDir = default_doc_dir+"/share/bbtk/bbs";
+     wxString defaultDir(stdDir.c_str(), wxConvUTF8);
+
+     wxFileDialog dialog(this, _T("Choose a file"),defaultDir, _T(""), _T("*.bbs"), wxOPEN );
+     if (dialog.ShowModal() == wxID_OK)
+     {
+        // std::string command(_T("include "));
+        // std::string pathfilename = (const char *)(dialog.GetFilename().mb_str());
+        wxString command(_T("include "));
+        wxString pathfilename = dialog.GetPath();
+        command += pathfilename;
+        CommandString( command );
+     }
 
   }
   //================================================================  
@@ -584,9 +530,7 @@ printf("WxConsole::CommandString 06 \n");
   //================================================================  
   void WxConsole::OnBtnReset(wxCommandEvent& event)
   {
-printf("WxConsole::OnBtnReset 01 \n");
-         CommandString(_T("reset"));
-printf("WxConsole::OnBtnReset 02 \n");
+     CommandString(_T("reset"));
   }
   //================================================================  
 
@@ -594,7 +538,7 @@ printf("WxConsole::OnBtnReset 02 \n");
   //================================================================  
   void WxConsole::OnBtnConfig(wxCommandEvent& event)
   {
-         CommandString(_T("config"));
+     CommandString(_T("config"));
   }
   //================================================================  
 
@@ -603,21 +547,21 @@ printf("WxConsole::OnBtnReset 02 \n");
   //================================================================  
   void WxConsole::OnBtnGraphS(wxCommandEvent& event)
   {
-         CommandString(_T("graph"));
+     CommandString(_T("graph"));
   }
   //================================================================  
 
   //================================================================  
   void WxConsole::OnBtnGraphD(wxCommandEvent& event)
   {
-         CommandString(_T("graph . 1"));
+     CommandString(_T("graph . 1"));
   }
   //================================================================  
 
   //================================================================  
   void WxConsole::OnBtnHelp(wxCommandEvent& event)
   {
-         CommandString(_T("help"));
+     CommandString(_T("help"));
   }
   //================================================================  
 
@@ -626,11 +570,13 @@ printf("WxConsole::OnBtnReset 02 \n");
   BEGIN_EVENT_TABLE(WxConsole, wxFrame)
     EVT_MENU(WxConsole::ID_Menu_Quit, WxConsole::OnMenuQuit)
     EVT_MENU(WxConsole::ID_Menu_About, WxConsole::OnMenuAbout)
+    EVT_MENU(WxConsole::ID_Menu_EditConfig, WxConsole::OnMenuEditConfig)
     EVT_MENU(WxConsole::ID_Menu_CreatePackage, WxConsole::OnMenuCreatePackage)
     EVT_MENU(WxConsole::ID_Menu_CreateBlackBox, WxConsole::OnMenuCreateBlackBox)
     EVT_MENU(WxConsole::ID_Menu_ShowImageGraph, WxConsole::OnMenuShowImageGraph)
+    EVT_MENU(WxConsole::ID_Menu_CreateIndex, WxConsole::OnMenuCreateIndex)
     EVT_TEXT_ENTER(WxConsole::ID_Text_Command, WxConsole::OnCommandEnter)
-  //    EVT_CHAR(WxConsole::ID_Text_Command, WxConsole::OnCommandChar)
+//      EVT_CHAR(WxConsole::ID_Text_Command, WxConsole::OnCommandChar)
     END_EVENT_TABLE()
   //================================================================