From 28300312b87bd50ca689d497c5a500ad4d343d5d Mon Sep 17 00:00:00 2001 From: guigues Date: Thu, 20 Mar 2008 09:51:28 +0000 Subject: [PATCH] *** empty log message *** --- kernel/appli/bbi/bbi.cxx | 26 +- kernel/src/bbtkInterpreter.cxx | 67 +- kernel/src/bbtkInterpreter.h | 35 +- kernel/src/bbtkMessageManager.cxx | 12 +- kernel/src/bbtkWxBrowser.h | 81 --- kernel/src/bbtkWxConsole.cxx | 586 ------------------ kernel/src/bbtkWxEditor.cxx | 34 +- kernel/src/bbtkWxEditor.h | 14 +- kernel/src/bbtkWxGUICommand.cxx | 187 ++++++ kernel/src/bbtkWxGUICommand.h | 101 +++ kernel/src/bbtkWxGUIConsole.cxx | 376 +++++++++++ .../{bbtkWxConsole.h => bbtkWxGUIConsole.h} | 92 ++- ...WxBrowser.cxx => bbtkWxGUIHtmlBrowser.cxx} | 151 ++--- kernel/src/bbtkWxGUIHtmlBrowser.h | 123 ++++ kernel/src/bbtkWxGUIOutputMessages.cxx | 104 ++++ kernel/src/bbtkWxGUIOutputMessages.h | 98 +++ 16 files changed, 1215 insertions(+), 872 deletions(-) delete mode 100644 kernel/src/bbtkWxBrowser.h delete mode 100644 kernel/src/bbtkWxConsole.cxx create mode 100644 kernel/src/bbtkWxGUICommand.cxx create mode 100644 kernel/src/bbtkWxGUICommand.h create mode 100644 kernel/src/bbtkWxGUIConsole.cxx rename kernel/src/{bbtkWxConsole.h => bbtkWxGUIConsole.h} (62%) rename kernel/src/{bbtkWxBrowser.cxx => bbtkWxGUIHtmlBrowser.cxx} (71%) create mode 100644 kernel/src/bbtkWxGUIHtmlBrowser.h create mode 100644 kernel/src/bbtkWxGUIOutputMessages.cxx create mode 100644 kernel/src/bbtkWxGUIOutputMessages.h diff --git a/kernel/appli/bbi/bbi.cxx b/kernel/appli/bbi/bbi.cxx index 5404d6e..1d92d7e 100644 --- a/kernel/appli/bbi/bbi.cxx +++ b/kernel/appli/bbi/bbi.cxx @@ -5,7 +5,7 @@ //========================================================================== #include "bbtkInterpreter.h" #include "bbtkWxBlackBox.h" -#include "bbtkWxConsole.h" +#include "bbtkWxGUIConsole.h" #include #include @@ -20,7 +20,8 @@ static const wxCmdLineEntryDesc cmdLineDesc[] = { wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("print help") }, { wxCMD_LINE_SWITCH, _T("g"), _T("graphical-dialog"), _T("prompts the user for the parameters values using dialog boxes") }, { wxCMD_LINE_SWITCH, _T("t"), _T("text-dialog"), _T("prompts the user for the parameters values in text mode") }, - { wxCMD_LINE_SWITCH, _T("n"), _T("no-command"), _T("do not show command window") }, + { wxCMD_LINE_SWITCH, _T("n"), _T("no-command"), _T("do not show command window except on error") }, + { wxCMD_LINE_SWITCH, _T("N"), _T("no-command-at-all"), _T("do not show command window even on error") }, { wxCMD_LINE_PARAM, NULL, NULL, _T("input_file"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE }, { wxCMD_LINE_NONE } }; @@ -48,6 +49,7 @@ public: bool graphical_dialog; bool text_dialog; bool no_command; + bool no_command_at_all; std::map param_map; std::vector input_file; @@ -69,7 +71,9 @@ bool wxBBIApp::OnCmdLineParsed(wxCmdLineParser& parser) help = ( parser.Found(_T("h")) ); graphical_dialog = ( parser.Found(_T("g")) ); text_dialog = ( parser.Found(_T("t")) ); - no_command = ( parser.Found(_T("n")) ); + no_command_at_all = ( parser.Found(_T("N")) ); + no_command = ( parser.Found(_T("n")) || no_command_at_all ); + // parse the arguments and consider those which contain a "=" // as set input commands, other as files @@ -128,7 +132,7 @@ bool wxBBIApp::OnInit( ) if (debug) bbtk::MessageManager::SetMessageLevel("All",9); - bbtk::WxConsole *I = new bbtk::WxConsole(0,_T("bbi"),wxSize(800,600)); + bbtk::WxGUIConsole *I = new bbtk::WxGUIConsole(0,_T("bbi"),wxSize(800,600)); SetTopWindow(I); if (!no_command) I->Show(true); @@ -141,7 +145,16 @@ bool wxBBIApp::OnInit( ) if (text_dialog) I->SetDialogMode(bbtk::Executer::TextDialog); std::vector::const_iterator i; - for (i=input_file.begin(); i!=input_file.end(); ++i) I->InterpretFile(*i); + bool error = false; + + for (i=input_file.begin(); i!=input_file.end(); ++i) + { + error = ! I->InterpretFile(*i); + if (error) break; + } + bool show_on_error = error && ! no_command_at_all; + if (show_on_error) I->Show(); + I->SetNoExecMode(false); if (help_on_script) @@ -149,7 +162,8 @@ bool wxBBIApp::OnInit( ) std::string package; I->GetInterpreter()->GetExecuter()->GetFactory()->HelpBlackBox("workspace",package,false); } - if (!(command || bbtk::Wx::IsSomeWindowShown() )) + + if (!(show_on_error || command || bbtk::Wx::IsSomeWindowShown() )) { I->Close(); } diff --git a/kernel/src/bbtkInterpreter.cxx b/kernel/src/bbtkInterpreter.cxx index 674513f..690ddb8 100644 --- a/kernel/src/bbtkInterpreter.cxx +++ b/kernel/src/bbtkInterpreter.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkInterpreter.cxx,v $ $ Language: C++ - Date: $Date: 2008/03/19 14:58:13 $ - Version: $Revision: 1.47 $ + Date: $Date: 2008/03/20 09:51:28 $ + Version: $Revision: 1.48 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -23,7 +23,6 @@ #include "bbtkInterpreter.h" #include "bbtkMessageManager.h" #include "bbtkConfigurationFile.h" -#include "bbtkWxConsole.h" #include "bbtkUtilities.h" #include #include @@ -45,9 +44,7 @@ namespace bbtk */ Interpreter::Interpreter() : -#ifdef _USE_WXWIDGETS_ - mWxConsole(0), -#endif + mUser(0), mCommandLine(false) { bufferNb =0; @@ -1327,50 +1324,46 @@ void Interpreter::Help(const std::vector& words) try { GetExecuter()->GetFactory()->HelpPackage(words[1]); -#ifdef _USE_WXWIDGETS_ - if ( mWxConsole != 0 ) + if ( mUser != 0 ) { std::string url = ConfigurationFile::GetInstance().Get_doc_path(); url += "/bbdoc/" + words[1] + "/index.html"; if (Utilities::FileExists(url)) { - mWxConsole->ShowHtmlPage(url); + mUser->InterpreterUserViewHtmlPage(url); } } -#endif } catch (bbtk::Exception f) { - try - { - std::string package; - GetExecuter()->GetFactory()->HelpBlackBox(words[1],package); -#ifdef _USE_WXWIDGETS_ - if ( mWxConsole != 0 ) + try + { + std::string package; + GetExecuter()->GetFactory()->HelpBlackBox(words[1],package); + if ( mUser != 0 ) { std::string url = ConfigurationFile::GetInstance().Get_doc_path(); url += "/bbdoc/" + package + "/index.html"; - if (Utilities::FileExists(url)) + if (Utilities::FileExists(url)) { url += "#" + words[1]; - mWxConsole->ShowHtmlPage(url); + mUser->InterpreterUserViewHtmlPage(url); } } -#endif - } - catch (bbtk::Exception g) - { - try - { - GetExecuter()->ShowRelations(words[1],"0","9999"); - } - catch (bbtk::Exception h){ - bbtkError("\""<ShowRelations(words[1],"0","9999"); + } + catch (bbtk::Exception h){ + bbtkError("\""<& words) std::string page; bool system_display = true; -#ifdef _USE_WXWIDGETS_ - if ( mWxConsole != 0 ) system_display = false; -#endif + if ( ( mUser != 0 ) && ( mUser->InterpreterUserHasOwnHtmlPageViewer() ) ) + system_display = false; if (words.size()==1) { @@ -1786,10 +1778,9 @@ void Interpreter::Graph(const std::vector& words) page = mExecuter->ShowGraph(words[1],words[2],words[3],words[4],words[5],words[6],system_display); } -#ifdef _USE_WXWIDGETS_ - if ( mWxConsole != 0 ) - mWxConsole->ShowHtmlPage(page); -#endif + if ( ( mUser != 0 ) && ( mUser->InterpreterUserHasOwnHtmlPageViewer() ) ) + mUser->InterpreterUserViewHtmlPage(page); + } //======================================================================= diff --git a/kernel/src/bbtkInterpreter.h b/kernel/src/bbtkInterpreter.h index ea2f77a..f3ca4b6 100644 --- a/kernel/src/bbtkInterpreter.h +++ b/kernel/src/bbtkInterpreter.h @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkInterpreter.h,v $ $ Language: C++ - Date: $Date: 2008/03/19 14:58:13 $ - Version: $Revision: 1.16 $ + Date: $Date: 2008/03/20 09:51:28 $ + Version: $Revision: 1.17 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -41,6 +41,18 @@ namespace bbtk class WxConsole; #endif + class BBTK_EXPORT InterpreterUser + { + public: + InterpreterUser() {}; + ~InterpreterUser() {}; + + virtual bool InterpreterUserHasOwnHtmlPageViewer() { return false; } + virtual void InterpreterUserViewHtmlPage(const std::string&) {} + + + }; + class BBTK_EXPORT Interpreter { @@ -142,12 +154,13 @@ namespace bbtk #ifdef _USE_WXWIDGETS_ - /// Sets the WxConsole that created the interpreter (if any) - void SetWxConsole(WxConsole* c) { mWxConsole = c; } - /// Gets the WxConsole that created the interpreter (if any) - WxConsole* GetWxConsole() { return mWxConsole; } - /// Gets the WxConsole that created the interpreter (if any) - const - const WxConsole* GetWxConsole() const { return mWxConsole; } + /// Sets the user of the interpreter (if any) + void SetUser(InterpreterUser* c) { mUser = c; } + /// Gets the InterpreterUser of this + InterpreterUser* GetUser() { return mUser; } + /// Gets the InterpreterUser of this (const) + const InterpreterUser* GetUser() const { return mUser; } + #endif /// Gets the Executer @@ -224,10 +237,8 @@ namespace bbtk /// The command executer used bbtk::VirtualExec* mExecuter; -#ifdef _USE_WXWIDGETS_ - /// The WxConsole which uses the interpreter (0 if none) - bbtk::WxConsole* mWxConsole; -#endif + /// The user of the interpreter (0 if none) + bbtk::InterpreterUser* mUser; /// Vector of open files / buffers (can be stringstream) std::vector mFile; diff --git a/kernel/src/bbtkMessageManager.cxx b/kernel/src/bbtkMessageManager.cxx index 1314b06..21b0e53 100644 --- a/kernel/src/bbtkMessageManager.cxx +++ b/kernel/src/bbtkMessageManager.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkMessageManager.cxx,v $ Language: C++ - Date: $Date: 2008/02/05 13:23:46 $ - Version: $Revision: 1.3 $ + Date: $Date: 2008/03/20 09:51:28 $ + 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 @@ -61,7 +61,7 @@ namespace bbtk mMessageLevel[key] = 0; mMessageHelp[key] = "Configuration related messages"; if (mMaxMessageLength - -namespace bbtk -{ - - class WxBrowser; - - class WxHtmlWindow : public virtual wxHtmlWindow - { - public: - WxHtmlWindow( wxWindow *parent, int id, WxBrowser* browser, wxSize size) - : wxHtmlWindow(parent, id, - wxDefaultPosition, - size, - wxHW_SCROLLBAR_AUTO, - _T("bbtk::WxBrowser")), - mBrowser(browser) - { - - } - // wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,const wxString& url, wxString *redirect); -//EED virtual void OnLinkClicked(const wxHtmlLinkInfo& link); - - private: - WxBrowser* mBrowser; - - - }; - - - - class WxConsole; - - class WxBrowser : public wxPanel - { - public: - WxBrowser ( wxWindow *parent, wxSize size ); - - bool GoTo(std::string&); - void GoHome(); - - void OnBackButton(wxCommandEvent& ); - void OnForwardButton(wxCommandEvent& ); - void OnHomeButton(wxCommandEvent& ); - void OnReloadButton(wxCommandEvent& ); - void OnIncludeFileButton(wxCommandEvent& ); - void OnLinkClicked(wxHtmlLinkEvent& ); - void OnURLEnter( wxCommandEvent&); - void UpdateURL(); - // void OnCell(wxHtmlCellEvent& ); - - void SetSize( wxSize ); - - void SetWxConsole( WxConsole* c ) { mWxConsole = c; } - - private: - WxHtmlWindow* mwxHtmlWindow; - wxTextCtrl* mwxURL; - wxButton* mwxBackButton; - wxButton* mwxForwardButton; - wxButton* mwxHomeButton; - wxButton* mwxReloadButton; - wxButton* mwxIncludeFileButton; - - WxConsole* mWxConsole; - - // any class wishing to process wxWidgets events must use this macro - DECLARE_EVENT_TABLE() - }; - -} -#endif - -#endif diff --git a/kernel/src/bbtkWxConsole.cxx b/kernel/src/bbtkWxConsole.cxx deleted file mode 100644 index dc7dc1d..0000000 --- a/kernel/src/bbtkWxConsole.cxx +++ /dev/null @@ -1,586 +0,0 @@ -/*========================================================================= - - Program: bbtk - Module: $RCSfile: bbtkWxConsole.cxx,v $ - Language: C++ - Date: $Date: 2008/03/19 14:58:13 $ - Version: $Revision: 1.18 $ - - Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de - l'Image). All rights reserved. See Doc/License.txt or - http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*//** - * \brief Short description in one line - * - * Long description which - * can span multiple lines - */ -/** - * \file - * \brief - */ -/** - * \class bbtk:: - * \brief - */ - - -#ifdef _USE_WXWIDGETS_ - -#include -#include "bbtkWxConsole.h" -#include "bbtkWxBlackBox.h" -#include "bbtkConfigurationFile.h" -#include "bbtkWxStreamRedirector.h" - -namespace bbtk -{ - - - - //================================================================ - 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); - mInterpreter->SetCommandLine(true); - //============== - // Menu - wxInitAllImageHandlers(); - - wxMenu *menuFile = new wxMenu; - menuFile->Append( ID_Menu_Quit, _T("&Quit") ); - - wxMenu *menuAbout = new wxMenu; - menuAbout->Append( ID_Menu_About, _T("&About...") ); - - wxMenu *menuTools = new wxMenu; - 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; - menuBar->Append( menuFile, _T("&File") ); - menuBar->Append( menuTools, _T("&Tools") ); - menuBar->Append( menuAbout, _T("About") ); - - SetMenuBar( menuBar ); - - CreateStatusBar(); - SetStatusText( _T("Welcome to bbi !") ); - - //============== - // Notebook - - // wxFlexGridSizer *sizer = new wxFlexGridSizer(1); - -//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); - mwxPageHelp = new wxPanel(mwxNotebook,-1); - - - wxBoxSizer *cmdsizer = new wxBoxSizer(wxVERTICAL); - - mwxPageCommand->SetAutoLayout(true); - mwxPageCommand->SetSizer(cmdsizer); - cmdsizer->Fit(mwxPageCommand); - cmdsizer->SetSizeHints(mwxPageCommand); - - wxBoxSizer *helpsizer = new wxBoxSizer(wxVERTICAL); - - mwxPageHelp->SetAutoLayout(true); - mwxPageHelp->SetSizer(helpsizer); - helpsizer->Fit(mwxPageHelp); - helpsizer->SetSizeHints(mwxPageHelp); - - mwxHtmlWindow = new WxBrowser(mwxPageHelp, -//EED wxSize(1200,0)); - wxSize(200,0)); - - // mwxHtmlWindow->SetSize(wxSize(800,1000)); - helpsizer->Add (mwxHtmlWindow,1, wxGROW |wxLEFT | wxRIGHT | wxBOTTOM ); -// helpsizer->Add ( new wxButton(mwxPageHelp,-1,"perro"), 0, wxEXPAND ); - - //============== - // Command page - - mwxTextHistory = - new wxTextCtrl(mwxPageCommand, - ID_Text_History, - _T(""),wxDefaultPosition, - wxDefaultSize, //HistorySize, - wxTE_READONLY | - wxTE_MULTILINE ); - - wxFont* FixedFont = new wxFont(10, - wxFONTFAMILY_MODERN, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_NORMAL, - false); - - mwxTextHistoryAttr = new wxTextAttr; - mwxTextHistoryAttr->SetFont(*FixedFont); - /* - mwxTextCommand = - new wxTextCtrl(mwxPageCommand, - ID_Text_Command, - _T(""),wxDefaultPosition, - wxDefaultSize, - wxTE_PROCESS_ENTER - | wxTE_PROCESS_TAB - | wxWANTS_CHARS - //| wxTAB_TRAVERSAL - ); - mwxTextCommandAttr = new wxTextAttr; - mwxTextCommandAttr->SetFont(*FixedFont); - mwxTextCommand->SetDefaultStyle(*mwxTextCommandAttr); - */ - mwxTextCommand = - new wxComboBox(mwxPageCommand, - ID_Text_Command, - _T(""), - wxDefaultPosition, - wxDefaultSize, - 0, NULL, - wxTE_PROCESS_ENTER -// | wxTE_PROCESS_TAB -// | wxWANTS_CHARS -// //| wxTAB_TRAVERSAL - ); - - - mwxTextCommand->SetFocus(); - - wxPanel *btnsCtrlPanel = CreateBtnsCtrlPanel(mwxPageCommand); - - wxButton *btnGo = new wxButton( mwxPageCommand,-1,_T("Go") ); - Connect(btnGo->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxConsole::OnBtnGo ); - - wxFlexGridSizer *sizerCommand= new wxFlexGridSizer(2); - sizerCommand->AddGrowableCol(0); - sizerCommand->Add(mwxTextCommand,1,wxGROW); - sizerCommand->Add(btnGo); - - cmdsizer->Add ( mwxTextHistory, 1, wxALL | wxGROW, 10); -//EED cmdsizer->Add ( mwxTextCommand, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxGROW, 10 ); - cmdsizer->Add ( sizerCommand, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxGROW, 10 ); - cmdsizer->Add ( btnsCtrlPanel, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxGROW, 10 ); - - - // cmdsizer->AddGrowableCol(0); - // cmdsizer->AddGrowableRow(0); - // cmdsizer->AddGrowableRow(1); - // cmdsizer->SetFlexibleDirection(wxBOTH); - - //============================= - // Events connection - // COMMAND - // ENTER - Connect( mwxTextCommand->GetId(), - wxEVT_COMMAND_TEXT_ENTER, - (wxObjectEventFunction)& WxConsole::OnCommandEnter ); - /* - Connect( mwxTextCommand->GetId(), - wxEVT_CHAR, - //wxEVT_COMMAND_TEXT_UPDATED, - (wxObjectEventFunction)& WxConsole::OnCommandChar ); - */ - // MENU - // Connect ( - - // Redirection of std::cout to mwxTextHistory and printf - mRedirect_cout = - new WxStreamRedirector(std::cout,mwxTextHistory,*wxBLACK,true); - mRedirect_cerr = - new WxStreamRedirector(std::cerr,mwxTextHistory,*wxGREEN,true); - - // 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); - - 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; - } - //================================================================ - - - //================================================================ - void WxConsole::OnCommandEnter(wxCommandEvent& event) - { - wxString line(mwxTextCommand->GetValue()); - CommandString(line); - } - //================================================================ - - //================================================================ - void WxConsole::OnBtnGo(wxCommandEvent& event) - { - wxString line(mwxTextCommand->GetValue()); - CommandString(line); - } - //================================================================ - - //================================================================ - void WxConsole::CommandString(wxString line ) - { - //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()); -//EED mwxTextCommand->Clear(); - mwxTextCommand->SetValue(_T("")); - mwxTextCommand->Append(line); - -//EED mwxTextCommand->SetDefaultStyle(*mwxTextCommandAttr); - mwxTextHistoryAttr->SetTextColour(*wxBLACK); - mwxTextHistory->SetDefaultStyle(*mwxTextHistoryAttr); - - //printf("WxConsole::CommandString 03 \n"); - if ( mInterpreter->InterpretLine( wx2std(line) ) == - Interpreter::QUIT ) - { - Close(true); - } - - //printf("WxConsole::CommandString 06 \n"); - } - //================================================================ - - //================================================================ - /// Runs the interpretation of a file - void WxConsole::InterpretFile( const std::string& filename) - { - if ( mInterpreter->InterpretFile(filename) == - Interpreter::ERROR ) - { - Show(); - } - } - //================================================================ - - //================================================================ - void WxConsole::OnMenuQuit(wxCommandEvent& WXUNUSED(event)) - { - Close(true); - } - //================================================================ - - - //================================================================ - void WxConsole::OnMenuAbout(wxCommandEvent& WXUNUSED(event)) - { - 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)) - { -printf("EED WxConsole::OnMenuCreatePackage 01 \n"); - std::string command("toolsbbtk/appli/CreatePackage"); -printf("EED WxConsole::OnMenuCreatePackage 02 \n"); - - bbtkMessage("Debug",1,"Executing : '"<InterpretFile(command); -printf("EED WxConsole::OnMenuCreatePackage 05 \n"); - delete I; -printf("EED WxConsole::OnMenuCreatePackage 06 \n"); - } - //================================================================ - - - //================================================================ - void WxConsole::OnMenuCreateBlackBox(wxCommandEvent& WXUNUSED(event)) - { - std::string command("toolsbbtk/appli/CreateBlackBox"); - bbtkMessage("Debug",1,"Executing : '"<InterpretFile(command); - delete I; - } - //================================================================ - - //================================================================ - void WxConsole::OnMenuShowImageGraph(wxCommandEvent& WXUNUSED(event)) - { - 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_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 "<InterpretFile( filepath ); - - I->InterpretLine( "exec freeze"); - I->InterpretLine( "include *"); - I->InterpretLine( "index "+doc_path+"/bbdoc/index-alpha.html Initials"); - I->InterpretLine( "index "+doc_path+"/bbdoc/index-package.html Packages"); - I->InterpretLine( "index "+doc_path+"/bbdoc/index-category.html Categories"); - I->InterpretLine( "index "+doc_path+"/bbdoc/index-adaptors.html Adaptors"); - - delete I; - } - //================================================================ - - - - - //================================================================ - void WxConsole::OnCommandChar(wxCommandEvent& event) - { - std::cout << "c"; - /* - // Command completion - std::vector commands; - wxString sline( wx2std ( mwxTextCommand->GetValue() ) ); - int ind = sline.size(); - mInterpreter->FindCommandsWithPrefix( sline.c_str(),ind,commands); - if (commands.size()==1) - { - std::string com = *commands.begin(); - for (; indTextAppend( std2wx ( com[ind]) ); - } - mwxTextCommand->TextAppend(_T(" ")); - } - else if (commands.size()>1) - { - std::vector::iterator i; - write(1,"\n",1); - for (i=commands.begin();i!=commands.end();++i) - { - write(STDOUT_FILENO,(*i).c_str(),strlen((*i).c_str())); - PrintChar(' '); - } - write(STDOUT_FILENO,"\n> ",3); - //for (int j=0;jGoTo(page)) - { -//EED mwxNotebook->ChangeSelection(1); - mwxNotebook->SetSelection(1); - } - else - { - // std::cout << "ERROR html"<Add( btnInclude ); - btnsSizer->Add( btnReset ); - btnsSizer->Add( btnConfig ); - btnsSizer->Add( btnGraphS ); - btnsSizer->Add( btnGraphD ); - btnsSizer->Add( btnHelp ); - btnsCtrlPanel->SetSizer(btnsSizer); - - Connect(btnInclude->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxConsole::OnBtnInclude ); - Connect(btnReset->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxConsole::OnBtnReset ); - Connect(btnConfig->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxConsole::OnBtnConfig ); - Connect(btnGraphS->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxConsole::OnBtnGraphS ); - Connect(btnGraphD->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxConsole::OnBtnGraphD ); - Connect(btnHelp->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxConsole::OnBtnHelp ); - return btnsCtrlPanel; - } - //================================================================ - - - //================================================================ - 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 ); - } - - } - //================================================================ - - - //================================================================ - void WxConsole::OnBtnReset(wxCommandEvent& event) - { - CommandString(_T("reset")); - } - //================================================================ - - - //================================================================ - void WxConsole::OnBtnConfig(wxCommandEvent& event) - { - CommandString(_T("config")); - } - //================================================================ - - - - //================================================================ - void WxConsole::OnBtnGraphS(wxCommandEvent& event) - { - CommandString(_T("graph")); - } - //================================================================ - - //================================================================ - void WxConsole::OnBtnGraphD(wxCommandEvent& event) - { - CommandString(_T("graph . 1")); - } - //================================================================ - - //================================================================ - void WxConsole::OnBtnHelp(wxCommandEvent& event) - { - CommandString(_T("help")); - } - //================================================================ - - - //================================================================ - 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) - END_EVENT_TABLE() - //================================================================ - -} // namespace bbtk - - -#endif //_USE_WXWIDGETS_ diff --git a/kernel/src/bbtkWxEditor.cxx b/kernel/src/bbtkWxEditor.cxx index f178a89..a494269 100644 --- a/kernel/src/bbtkWxEditor.cxx +++ b/kernel/src/bbtkWxEditor.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkWxEditor.cxx,v $ Language: C++ - Date: $Date: 2008/03/19 14:58:13 $ - Version: $Revision: 1.5 $ + Date: $Date: 2008/03/20 09:51:29 $ + Version: $Revision: 1.6 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -50,6 +50,8 @@ // #include "icons/print.xpm" // #include "icons/help.xpm" + + namespace bbtk { @@ -487,30 +489,34 @@ namespace bbtk EVT_BUTTON(WxEditor::ID_ButtonQuit, WxEditor::OnButtonQuit) END_EVENT_TABLE() //================================================================ - - + + void WxEditorWindow::WxGUICommandEnter(const std::string& s) + { + std::cout << "Command received : '"<AddGrowableCol(0); + + mEditor = new WxEditor(this); sizer->Add(mEditor,1,wxGROW); + + WxGUICommand* com = new WxGUICommand(this,this); + sizer->Add(com); + SetSizer(sizer); + // Creates and sets the parent window of all bbtk windows - wxWindow* top = new wxPanel(this,-1);//,_T("top")); + wxWindow* top = new wxPanel(this,-1); top->Hide(); - //new wxFrame(this,-1,_T("bbtk"), - // wxDefaultPosition, - // wxSize(0,0), - // wxFRAME_TOOL_WINDOW) ;//wxMINIMIZE_BOX); Wx::SetTopWindow(top); - SetAutoLayout(true); Layout(); } diff --git a/kernel/src/bbtkWxEditor.h b/kernel/src/bbtkWxEditor.h index 4505af3..5ce7e1f 100644 --- a/kernel/src/bbtkWxEditor.h +++ b/kernel/src/bbtkWxEditor.h @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkWxEditor.h,v $ Language: C++ - Date: $Date: 2008/03/19 08:03:59 $ - Version: $Revision: 1.4 $ + Date: $Date: 2008/03/20 09:51:29 $ + Version: $Revision: 1.5 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -42,6 +42,8 @@ #include "bbtkInterpreter.h" #include +#include "bbtkWxGUICommand.h" + namespace bbtk { @@ -75,6 +77,7 @@ namespace bbtk void HighlightSyntax(); void UpdatePosition(); + private: Interpreter* mInterpreter; wxSplitterWindow* mwxSplit; @@ -82,7 +85,7 @@ namespace bbtk wxTextAttr* mwxInputTextAttr; WxTextCtrlGettingKeyEvents* mwxOutputText; wxTextAttr* mwxOutputTextAttr; - wxBitmapButton * mwxButtonNew; + wxButton * mwxButtonNew; wxButton * mwxButtonOpen; wxButton * mwxButtonSave; wxButton * mwxButtonRun; @@ -109,12 +112,15 @@ namespace bbtk /// Editor in a frame - class BBTK_EXPORT WxEditorWindow : public wxFrame + class BBTK_EXPORT WxEditorWindow : public wxFrame, public WxGUICommandUser { public: WxEditorWindow( wxWindow *parent, wxString title, wxSize size); ~WxEditorWindow(); void Open(const std::string& filename) { mEditor->Open(filename); } + void WxGUICommandEnter(const std::string& s); + + private : WxEditor* mEditor; diff --git a/kernel/src/bbtkWxGUICommand.cxx b/kernel/src/bbtkWxGUICommand.cxx new file mode 100644 index 0000000..929d07b --- /dev/null +++ b/kernel/src/bbtkWxGUICommand.cxx @@ -0,0 +1,187 @@ +/*========================================================================= + + Program: bbtk + Module: $RCSfile: bbtkWxGUICommand.cxx,v $ + Language: C++ + Date: $Date: 2008/03/20 09:51:29 $ + Version: $Revision: 1.1 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*//** + * \brief Short description in one line + * + * Long description which + * can span multiple lines + */ +/** + * \file + * \brief + */ +/** + * \class bbtk:: + * \brief + */ + + +#ifdef _USE_WXWIDGETS_ + +#include "bbtkWxGUICommand.h" +#include "bbtkMessageManager.h" +#include "bbtkConfigurationFile.h" + +namespace bbtk +{ + //================================================================ + BEGIN_EVENT_TABLE(WxGUICommand, wxPanel) + EVT_TEXT_ENTER(WxGUICommand::ID_Text_Command, WxGUICommand::OnCommandEnter) + EVT_BUTTON(WxGUICommand::ID_Btn_Go, WxGUICommand::OnBtnGo) + EVT_BUTTON(WxGUICommand::ID_Btn_Include, WxGUICommand::OnBtnInclude) + EVT_BUTTON(WxGUICommand::ID_Btn_Reset, WxGUICommand::OnBtnReset) + EVT_BUTTON(WxGUICommand::ID_Btn_Config, WxGUICommand::OnBtnConfig) + EVT_BUTTON(WxGUICommand::ID_Btn_GraphS, WxGUICommand::OnBtnGraphS) + EVT_BUTTON(WxGUICommand::ID_Btn_GraphD, WxGUICommand::OnBtnGraphD) + EVT_BUTTON(WxGUICommand::ID_Btn_Help, WxGUICommand::OnBtnHelp) + END_EVENT_TABLE() + //================================================================ + + + WxGUICommand::WxGUICommand(wxWindow *parent, WxGUICommandUser* user) + : wxPanel(parent,-1), + mUser(user) + { + wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); + + mwxTextCommand = + new wxComboBox(this, + ID_Text_Command, + _T(""), + wxDefaultPosition, + wxDefaultSize, + 0, NULL, + wxTE_PROCESS_ENTER + // | wxTE_PROCESS_TAB + // | wxWANTS_CHARS + // //| wxTAB_TRAVERSAL + ); + + wxButton *btnGo = new wxButton(this,ID_Btn_Go,_T("Go")); + + wxFlexGridSizer *sizerCommand= new wxFlexGridSizer(2); + sizerCommand->AddGrowableCol(0); + sizerCommand->Add(mwxTextCommand,1,wxGROW); + sizerCommand->Add(btnGo); + + sizer->Add(sizerCommand,0,wxLEFT | wxRIGHT | wxBOTTOM | wxGROW, 10 ); + + wxBoxSizer *btnsSizer = new wxBoxSizer(wxHORIZONTAL); + + wxButton *btnInclude = new wxButton(this,ID_Btn_Include,_T("include") ); + wxButton *btnReset = new wxButton(this,ID_Btn_Reset,_T("reset") ); + wxButton *btnConfig = new wxButton(this,ID_Btn_Config,_T("config") ); + wxButton *btnGraphS = new wxButton(this,ID_Btn_GraphS, + _T("graph (simple)") ); + wxButton *btnGraphD = new wxButton(this,ID_Btn_GraphD, + _T("graph (detailed)") ); + wxButton *btnHelp = new wxButton(this,ID_Btn_Help,_T("help") ); + + btnsSizer->Add( btnInclude ); + btnsSizer->Add( btnReset ); + btnsSizer->Add( btnConfig ); + btnsSizer->Add( btnGraphS ); + btnsSizer->Add( btnGraphD ); + btnsSizer->Add( btnHelp ); + + sizer->Add(btnsSizer,0,wxLEFT | wxRIGHT | wxBOTTOM | wxGROW, 10 ); + + SetSizer(sizer); + + SetAutoLayout(true); + Layout(); + } + + WxGUICommand::~WxGUICommand() + { + } + + void WxGUICommand::OnBtnGo(wxCommandEvent& event) + { + bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnGo"<GetValue())); + } + + void WxGUICommand::OnCommandEnter(wxCommandEvent& event) + { + bbtkDebugMessage("gui",2,"WxGUICommand::OnCommandEnter"<GetValue())); + } + + void WxGUICommand::SendCommand(const std::string& command) + { + if (command.length()==0) return; + + mwxTextCommand->SetValue(_T("")); + mwxTextCommand->Append(command); + if (mUser) mUser->WxGUICommandEnter(command); + } + + + void WxGUICommand::OnBtnInclude(wxCommandEvent& event) + { + bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnInclude"< +#include "bbtkWxGUIConsole.h" +#include "bbtkWxBlackBox.h" +#include "bbtkConfigurationFile.h" +#include "bbtkWxStreamRedirector.h" + + +#include "icons/cc_run.xpm" + +namespace bbtk +{ + + enum + { + ID_Menu_Quit = 1, + ID_Menu_About, + ID_Menu_EditConfig, + ID_Menu_CreatePackage, + ID_Menu_CreateBlackBox, + ID_Menu_ShowImageGraph, + ID_Menu_CreateIndex, + ID_Button_Run + }; + + + //================================================================ + WxGUIConsole::WxGUIConsole( 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->SetUser(this); + mInterpreter->SetCommandLine(true); + //============== + // Menu + wxInitAllImageHandlers(); + + wxMenu *menuFile = new wxMenu; + menuFile->Append( ID_Menu_Quit, _T("&Quit") ); + + wxMenu *menuAbout = new wxMenu; + menuAbout->Append( ID_Menu_About, _T("&About...") ); + + wxMenu *menuTools = new wxMenu; + 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; + menuBar->Append( menuFile, _T("&File") ); + menuBar->Append( menuTools, _T("&Tools") ); + menuBar->Append( menuAbout, _T("About") ); + + SetMenuBar( menuBar ); + + CreateStatusBar(); + SetStatusText( _T("Welcome to bbi !") ); + + //============== + // Notebook + + // wxFlexGridSizer *sizer = new wxFlexGridSizer(1); + +//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); + mwxPageHelp = new wxPanel(mwxNotebook,-1); + + + wxBoxSizer *cmdsizer = new wxBoxSizer(wxVERTICAL); + + mwxPageCommand->SetAutoLayout(true); + mwxPageCommand->SetSizer(cmdsizer); + cmdsizer->Fit(mwxPageCommand); + cmdsizer->SetSizeHints(mwxPageCommand); + + wxBoxSizer *helpsizer = new wxBoxSizer(wxVERTICAL); + + mwxPageHelp->SetAutoLayout(true); + mwxPageHelp->SetSizer(helpsizer); + helpsizer->Fit(mwxPageHelp); + helpsizer->SetSizeHints(mwxPageHelp); + + mWxGUIHtmlBrowser = new WxGUIHtmlBrowser(mwxPageHelp, + //EED wxSize(1200,0)); + wxSize(200,0)); + + // mWxGUIHtmlBrowser->SetSize(wxSize(800,1000)); + helpsizer->Add (mWxGUIHtmlBrowser,1, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM ); +// helpsizer->Add ( new wxButton(mwxPageHelp,-1,"perro"), 0, wxEXPAND ); + wxBitmap bmp_run(cc_run_xpm); + mwxButtonRun = new wxBitmapButton( mwxPageHelp,ID_Button_Run,bmp_run);//_T("Run") ); + helpsizer->Add( mwxButtonRun ); + + + //============== + // Command page + mWxGUIOutputMessages = new WxGUIOutputMessages(mwxPageCommand); + + mWxGUICommand = new WxGUICommand(mwxPageCommand,this); + + mWxGUICommand->SetFocus(); + + cmdsizer->Add (mWxGUIOutputMessages, 1, wxALL | wxGROW, 10); + cmdsizer->Add (mWxGUICommand, 1, wxALL | wxGROW, 10); + + + // Creates and sets the parent window of all bbtk windows + wxWindow* top = new wxPanel(this,-1);//,_T("top")); + top->Hide(); + Wx::SetTopWindow(top); + + + // Layout +//EED SetSizer(sizer); + + 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(); + } + //================================================================ + + //================================================================ + WxGUIConsole::~WxGUIConsole() + { + m_mgr.UnInit(); + } + //================================================================ + + + //================================================================ + void WxGUIConsole::WxGUICommandEnter(const std::string& command) + { + std::string s("> "); + s += command + "\n"; + mWxGUIOutputMessages->Print(s,wxRED); + + if ( mInterpreter->InterpretLine( command ) == + Interpreter::QUIT ) + { + Close(true); + } + } + //================================================================ + + //================================================================ + /// Runs the interpretation of a file + bool WxGUIConsole::InterpretFile( const std::string& filename) + { + if ( mInterpreter->InterpretFile(filename) == + Interpreter::ERROR ) + { + return false; + } + return true; + } + //================================================================ + + //================================================================ + void WxGUIConsole::OnButtonRun(wxCommandEvent& WXUNUSED(event)) + { + std::string filename = wx2std(mWxGUIHtmlBrowser->GetCurrentPage()); + 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]=='.')) + { + SetStatusText(_T("Executing ")+filename); + I->InterpretFile(filename); + } + else + { + SetStatusText(_T("The current page is not a bbs file : cannot execute it")); + } + + delete I; + } + //================================================================ + + //================================================================ + void WxGUIConsole::OnMenuQuit(wxCommandEvent& WXUNUSED(event)) + { + Close(true); + } + //================================================================ + + + //================================================================ + void WxGUIConsole::OnMenuAbout(wxCommandEvent& WXUNUSED(event)) + { + m_mgr.Update(); + Refresh(); + wxMessageBox(_T(" bbi\nThe Black Box Toolkit interpreter\n(c) CREATIS-LRMN 2008"), + _T("About ..."), wxOK | wxICON_INFORMATION, + this); + } + //================================================================ + + + //================================================================ + void WxGUIConsole::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 WxGUIConsole::OnMenuCreatePackage(wxCommandEvent& WXUNUSED(event)) + { +printf("EED WxGUIConsole::OnMenuCreatePackage 01 \n"); + std::string command("toolsbbtk/appli/CreatePackage"); +printf("EED WxGUIConsole::OnMenuCreatePackage 02 \n"); + + bbtkMessage("Debug",1,"Executing : '"<InterpretFile(command); +printf("EED WxGUIConsole::OnMenuCreatePackage 05 \n"); + delete I; +printf("EED WxGUIConsole::OnMenuCreatePackage 06 \n"); + } + //================================================================ + + + //================================================================ + void WxGUIConsole::OnMenuCreateBlackBox(wxCommandEvent& WXUNUSED(event)) + { + std::string command("toolsbbtk/appli/CreateBlackBox"); + bbtkMessage("Debug",1,"Executing : '"<InterpretFile(command); + delete I; + } + //================================================================ + + //================================================================ + void WxGUIConsole::OnMenuShowImageGraph(wxCommandEvent& WXUNUSED(event)) + { + 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_temp_dir+"/temp_dir/workspace_workspacePrototype.png"; + std::cout << "system: " << strcommand << std::endl; + system ( strcommand.c_str() ); + + } + //================================================================ + + + //================================================================ + void WxGUIConsole::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 "<InterpretFile( filepath ); + + I->InterpretLine( "exec freeze"); + I->InterpretLine( "include *"); + I->InterpretLine( "index "+doc_path+"/bbdoc/index-alpha.html Initials"); + I->InterpretLine( "index "+doc_path+"/bbdoc/index-package.html Packages"); + I->InterpretLine( "index "+doc_path+"/bbdoc/index-category.html Categories"); + I->InterpretLine( "index "+doc_path+"/bbdoc/index-adaptors.html Adaptors"); + + delete I; + } + //================================================================ + + + //================================================================ + void WxGUIConsole::InterpreterUserViewHtmlPage(const std::string& page) + { + std::string s(page); + // std::cout << "WxGUIConsole::ShowHtmlPage('"<GoTo(s)) + { +//EED mwxNotebook->ChangeSelection(1); + mwxNotebook->SetSelection(1); + } + else + { + // std::cout << "ERROR html"< #include "bbtkWx.h" @@ -43,22 +43,23 @@ #include "bbtkInterpreter.h" -#include "bbtkWxBrowser.h" + +#include "bbtkWxGUICommand.h" +#include "bbtkWxGUIOutputMessages.h" +#include "bbtkWxGUIHtmlBrowser.h" namespace bbtk { - class WxStreamRedirector; - /// A console in which user can enter commands - class BBTK_EXPORT WxConsole : public wxFrame + class BBTK_EXPORT WxGUIConsole : public wxFrame, + public InterpreterUser, + public WxGUICommandUser { public: - WxConsole( wxWindow *parent, wxString title, wxSize size); - ~WxConsole(); + WxGUIConsole( wxWindow *parent, wxString title, wxSize size); + ~WxGUIConsole(); - // static WxConsole* GetInstance() { return mInstance; } - /// Returns the Interpreter used /// ONLY ONE FOR THE MOMENT BUT IN THE FUTURE CAN BE DIFFERENT /// (DIFFERENT WORKSPACES) @@ -79,7 +80,8 @@ namespace bbtk { mInterpreter->SetDialogMode(t); } /// Runs the interpretation of a file - void InterpretFile( const std::string& filename); + /// Returns false on error + bool InterpretFile( const std::string& filename); void OnMenuQuit(wxCommandEvent& event); @@ -90,54 +92,34 @@ namespace bbtk void OnMenuShowImageGraph(wxCommandEvent& WXUNUSED(event)); void OnMenuCreateIndex(wxCommandEvent& WXUNUSED(event)); - void OnBtnGo(wxCommandEvent& event); - void OnCommandEnter(wxCommandEvent& event); - void OnCommandChar(wxCommandEvent& event); - - void OnBtnInclude(wxCommandEvent& event); - void OnBtnReset(wxCommandEvent& event); - void OnBtnConfig(wxCommandEvent& event); - void OnBtnGraphS(wxCommandEvent& event); - void OnBtnGraphD(wxCommandEvent& event); - void OnBtnHelp(wxCommandEvent& event); - - - void ShowHtmlPage(std::string&); + + void OnButtonRun(wxCommandEvent& WXUNUSED(event)); + + // Interpreter callbacks + bool InterpreterUserHasOwnHtmlPageViewer() { return true; } + void InterpreterUserViewHtmlPage(const std::string&); + + // WxGUICommand callbacks + void WxGUICommandEnter(const std::string&); private: - wxAuiManager m_mgr; + wxAuiManager m_mgr; Interpreter* mInterpreter; - wxTextCtrl* mwxTextHistory; -//EED wxTextCtrl* mwxTextCommand; - wxComboBox* mwxTextCommand; - wxTextAttr* mwxTextHistoryAttr; - wxTextAttr* mwxTextCommandAttr; + + //EED wxNotebook* mwxNotebook; - wxAuiNotebook* mwxNotebook; + wxAuiNotebook* mwxNotebook; wxPanel *mwxPageCommand, *mwxPageHelp; - WxStreamRedirector* mRedirect_cout; - WxStreamRedirector* mRedirect_cerr; - WxBrowser* mwxHtmlWindow; - // static WxConsole* mInstance; + + WxGUICommand* mWxGUICommand; + WxGUIOutputMessages* mWxGUIOutputMessages; + WxGUIHtmlBrowser* mWxGUIHtmlBrowser; - wxPanel* CreateBtnsCtrlPanel(wxWindow *parent); - void CommandString(wxString line ); + wxButton* mwxButtonRun; + public: - enum - { - ID_Menu_Quit = 1, - ID_Menu_About, - ID_Menu_EditConfig, - ID_Menu_CreatePackage, - ID_Menu_CreateBlackBox, - ID_Menu_ShowImageGraph, - ID_Menu_CreateIndex, - ID_Text_Command, - ID_Text_History, - - }; - + DECLARE_EVENT_TABLE() }; @@ -146,6 +128,6 @@ namespace bbtk } // namespace bbtk -#endif // __bbtkWxConsole_h__ +#endif // __bbtkWxGUIConsole_h__ #endif //_USE_WXWIDGETS_ diff --git a/kernel/src/bbtkWxBrowser.cxx b/kernel/src/bbtkWxGUIHtmlBrowser.cxx similarity index 71% rename from kernel/src/bbtkWxBrowser.cxx rename to kernel/src/bbtkWxGUIHtmlBrowser.cxx index 874f7f6..0461448 100644 --- a/kernel/src/bbtkWxBrowser.cxx +++ b/kernel/src/bbtkWxGUIHtmlBrowser.cxx @@ -1,9 +1,40 @@ +/*========================================================================= + + Program: bbtk + Module: $RCSfile: bbtkWxGUIHtmlBrowser.cxx,v $ + Language: C++ + Date: $Date: 2008/03/20 09:51:29 $ + Version: $Revision: 1.1 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*//** + * \brief Short description in one line + * + * Long description which + * can span multiple lines + */ +/** + * \file + * \brief + */ +/** + * \class bbtk:: + * \brief + */ + #ifdef _USE_WXWIDGETS_ -#include "bbtkWxBrowser.h" -#include "bbtkWxBlackBox.h" -#include "bbtkWxConsole.h" +#include "bbtkWxGUIHtmlBrowser.h" +//#include "bbtkWxBlackBox.h" +//#include "bbtkWxGUIConsole.h" #include "bbtkConfigurationFile.h" #include "bbtkUtilities.h" @@ -44,40 +75,40 @@ namespace bbtk //======================================================================== - BEGIN_EVENT_TABLE(WxBrowser, wxPanel) - EVT_BUTTON(bwd_id, WxBrowser::OnBackButton ) - EVT_BUTTON(fwd_id, WxBrowser::OnForwardButton ) - EVT_BUTTON(home_id, WxBrowser::OnHomeButton ) - EVT_BUTTON(reload_id, WxBrowser::OnReloadButton ) - EVT_BUTTON(include_id, WxBrowser::OnIncludeFileButton ) - EVT_TEXT_ENTER(url_id, WxBrowser::OnURLEnter ) - EVT_HTML_LINK_CLICKED(html_id, WxBrowser::OnLinkClicked) + BEGIN_EVENT_TABLE(WxGUIHtmlBrowser, wxPanel) + EVT_BUTTON(bwd_id, WxGUIHtmlBrowser::OnBackButton ) + EVT_BUTTON(fwd_id, WxGUIHtmlBrowser::OnForwardButton ) + EVT_BUTTON(home_id, WxGUIHtmlBrowser::OnHomeButton ) + EVT_BUTTON(reload_id, WxGUIHtmlBrowser::OnReloadButton ) + // EVT_BUTTON(include_id, WxGUIHtmlBrowser::OnIncludeFileButton ) + EVT_TEXT_ENTER(url_id, WxGUIHtmlBrowser::OnURLEnter ) + EVT_HTML_LINK_CLICKED(html_id, WxGUIHtmlBrowser::OnLinkClicked) END_EVENT_TABLE() //======================================================================== //======================================================================== - WxBrowser::WxBrowser ( wxWindow *parent, wxSize size ) + WxGUIHtmlBrowser::WxGUIHtmlBrowser ( wxWindow *parent, wxSize size ) : - wxPanel ( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL), - mWxConsole(0) + wxPanel ( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL) + // , mWxGUIConsole(0) { wxPanel* panel = this; - + wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); - + wxBoxSizer *bsizer = new wxBoxSizer(wxHORIZONTAL); - + mwxBackButton = new wxButton( panel, bwd_id,_T("<"),wxDefaultPosition, wxDefaultSize,wxBU_EXACTFIT); bsizer->Add ( mwxBackButton , 0, wxALIGN_CENTRE | wxLEFT | wxTOP | wxBOTTOM , 10 ); - + mwxForwardButton = new wxButton( panel, fwd_id,_T(">"),wxDefaultPosition, wxDefaultSize,wxBU_EXACTFIT); bsizer->Add ( mwxForwardButton , 0, wxALIGN_CENTRE | wxTOP | wxBOTTOM , 10); - + mwxHomeButton = new wxButton( panel, home_id,_T("Home"),wxDefaultPosition, wxDefaultSize,wxBU_EXACTFIT); bsizer->Add ( mwxHomeButton , 0, wxALIGN_CENTRE | wxLEFT | wxTOP | wxBOTTOM , 10 ); @@ -85,12 +116,14 @@ namespace bbtk mwxReloadButton = new wxButton( panel, reload_id,_T("Reload"),wxDefaultPosition, wxDefaultSize,wxBU_EXACTFIT); bsizer->Add ( mwxReloadButton , 0, wxALIGN_CENTRE | wxTOP | wxBOTTOM , 10 ); - + + /* mwxIncludeFileButton = new wxButton( panel, include_id, _T("RUN"),wxDefaultPosition, wxDefaultSize,wxBU_EXACTFIT); bsizer->Add ( mwxIncludeFileButton , 0, wxALIGN_CENTRE | wxLEFT | wxTOP | wxBOTTOM , 10 ); - + */ + mwxURL = new wxTextCtrl(panel,url_id,_T(""), wxDefaultPosition, wxDefaultSize, @@ -108,7 +141,7 @@ namespace bbtk wxDefaultPosition, size, wxHW_SCROLLBAR_AUTO, - "bbtk::WxBrowser"); + "bbtk::WxGUIHtmlBrowser"); */ mwxHtmlWindow->SetBorders(5); // mwxHtmlWindow->FitInside(); @@ -139,39 +172,12 @@ namespace bbtk // GoHome(); - /* - Connect( mwxBackButton->GetId(), - wxEVT_COMMAND_BUTTON_CLICKED , - (wxObjectEventFunction) - (void (wxPanel::*)(wxEvent&)) - &WxBrowser::OnBackButton ); - Connect( mwxForwardButton->GetId(), - wxEVT_COMMAND_BUTTON_CLICKED , - (wxObjectEventFunction) - (void (wxPanel::*)(wxEvent&)) - &WxBrowser::OnForwardButton ); - - std::cout << "e="<GetId(), - wxEVT_COMMAND_HTML_LINK_CLICKED , - wxHtmlLinkEventHandler( - //(wxObjectEventFunction) - // (void (wxPanel::*)(wxEvent&))& - WxBrowser::OnLinkClicked ) ); - Connect( mwxHtmlWindow->GetId(), - wxEVT_COMMAND_HTML_CELL_HOVER, - //(wxObjectEventFunction) - wxHtmlCellEventHandler( - // (void (wxPanel::*)(wxHtmlCellEvent&))& - WxBrowser::OnCell ) ); - */ - } + } //======================================================================== //======================================================================== - bool WxBrowser::GoTo(std::string& file) + bool WxGUIHtmlBrowser::GoTo(std::string& file) { // std::cout << "goto"<HistoryBack(); @@ -191,7 +197,7 @@ namespace bbtk //======================================================================== //======================================================================== - void WxBrowser::OnForwardButton(wxCommandEvent& ) + void WxGUIHtmlBrowser::OnForwardButton(wxCommandEvent& ) { // std::cout << "forward"<HistoryForward(); @@ -200,7 +206,7 @@ namespace bbtk //======================================================================== //======================================================================== - void WxBrowser::GoHome() + void WxGUIHtmlBrowser::GoHome() { std::string url = ConfigurationFile::GetInstance().Get_doc_path(); url += "/bbtkWebSite/menu.html"; @@ -224,26 +230,33 @@ namespace bbtk //======================================================================== //======================================================================== - void WxBrowser::OnHomeButton(wxCommandEvent& ) + void WxGUIHtmlBrowser::OnHomeButton(wxCommandEvent& ) { GoHome(); } //======================================================================== //======================================================================== - void WxBrowser::OnReloadButton(wxCommandEvent& e) + void WxGUIHtmlBrowser::OnReloadButton(wxCommandEvent& e) { OnURLEnter(e); } //======================================================================== + //======================================================================== + std::string WxGUIHtmlBrowser::GetCurrentPage() + { + return wx2std(mwxURL->GetValue()); + } + //======================================================================== + /* //======================================================================== - void WxBrowser::OnIncludeFileButton(wxCommandEvent& ) + void WxGUIHtmlBrowser::OnIncludeFileButton(wxCommandEvent& ) { std::string filename = wx2std(mwxURL->GetValue()); size_t s = filename.length(); - WxConsole* C = mWxConsole; //::GetInstance(); + WxGUIConsole* C = mWxGUIConsole; //::GetInstance(); // MessageManager::SetMessageLevel("All",9); Interpreter* I = new Interpreter; @@ -264,19 +277,13 @@ namespace bbtk } delete I; - /* - std::string bbdoc = ConfigurationFile::GetInstance().Get_url(); - bbdoc += "/bbdoc"; - std::string command("cd "); - command += bbdoc; - command += " & bbi -q -n make-index.bbs"; - system(command.c_str()); - */ - } + } //======================================================================== + */ + //======================================================================== - void WxBrowser::OnURLEnter( wxCommandEvent&) + void WxGUIHtmlBrowser::OnURLEnter( wxCommandEvent&) { mwxHtmlWindow->LoadPage(mwxURL->GetValue()); } @@ -284,7 +291,7 @@ namespace bbtk //======================================================================== - void WxBrowser::OnLinkClicked(wxHtmlLinkEvent& e) + void WxGUIHtmlBrowser::OnLinkClicked(wxHtmlLinkEvent& e) { mwxHtmlWindow->LoadPage( e.GetLinkInfo().GetHref() ); UpdateURL(); @@ -294,14 +301,14 @@ namespace bbtk /* - void WxBrowser::OnCell(wxHtmlCellEvent& ) + void WxGUIHtmlBrowser::OnCell(wxHtmlCellEvent& ) { std::cout << "OnCell"<GetOpenedPage(); @@ -315,7 +322,7 @@ namespace bbtk //======================================================================== //======================================================================== - void WxBrowser::SetSize( wxSize s) + void WxGUIHtmlBrowser::SetSize( wxSize s) { // wxPanel::SetSize(s); mwxHtmlWindow->SetSize(s); diff --git a/kernel/src/bbtkWxGUIHtmlBrowser.h b/kernel/src/bbtkWxGUIHtmlBrowser.h new file mode 100644 index 0000000..885dad0 --- /dev/null +++ b/kernel/src/bbtkWxGUIHtmlBrowser.h @@ -0,0 +1,123 @@ +/*========================================================================= + + Program: bbtk + Module: $RCSfile: bbtkWxGUIHtmlBrowser.h,v $ + Language: C++ + Date: $Date: 2008/03/20 09:51:29 $ + Version: $Revision: 1.1 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*//** + * \brief Short description in one line + * + * Long description which + * can span multiple lines + */ +/** + * \file + * \brief + */ +/** + * \class bbtk:: + * \brief + */ + +#ifdef _USE_WXWIDGETS_ + + +#ifndef __bbtkWxGUIHtmlBrowser_h_INCLUDED__ +#define __bbtkWxGUIHtmlBrowser_h_INCLUDED__ + +#include "bbtkWx.h" +#include + +namespace bbtk +{ + + class WxGUIHtmlBrowser; + + class WxHtmlWindow : public virtual wxHtmlWindow + { + public: + WxHtmlWindow( wxWindow *parent, int id, WxGUIHtmlBrowser* browser, wxSize size) + : wxHtmlWindow(parent, id, + wxDefaultPosition, + size, + wxHW_SCROLLBAR_AUTO, + _T("bbtk::WxGUIHtmlBrowser")), + mBrowser(browser) + { + + } + // wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,const wxString& url, wxString *redirect); +//EED virtual void OnLinkClicked(const wxHtmlLinkInfo& link); + + private: + WxGUIHtmlBrowser* mBrowser; + + + }; + + /* + /// Abstract class which defines the callbacks invoked by WxGUIHtmlBrowser + class WxGUIHtmlBrowserUser + { + public : + WxGUIHtmlBrowserUser() {} + ~WxGUIHtmlBrowserUser() {} + }; + */ + + + // class WxGUIConsole; + + + class WxGUIHtmlBrowser : public wxPanel + { + public: + WxGUIHtmlBrowser ( wxWindow *parent, wxSize size ); + // WxGUIHtmlBrowserUser* = 0 ); + + bool GoTo(std::string&); + void GoHome(); + + void OnBackButton(wxCommandEvent& ); + void OnForwardButton(wxCommandEvent& ); + void OnHomeButton(wxCommandEvent& ); + void OnReloadButton(wxCommandEvent& ); + // void OnRunButton(wxCommandEvent& ); + void OnLinkClicked(wxHtmlLinkEvent& ); + void OnURLEnter( wxCommandEvent&); + void UpdateURL(); + // void OnCell(wxHtmlCellEvent& ); + + void SetSize( wxSize ); + + std::string GetCurrentPage(); + + private: + WxHtmlWindow* mwxHtmlWindow; + wxTextCtrl* mwxURL; + wxButton* mwxBackButton; + wxButton* mwxForwardButton; + wxButton* mwxHomeButton; + wxButton* mwxReloadButton; + // wxButton* mwxRunButton; + + // WxGUIHtmlBrowserUser* mUser; + + // any class wishing to process wxWidgets events must use this macro + DECLARE_EVENT_TABLE() + }; + +} +#endif + +#endif diff --git a/kernel/src/bbtkWxGUIOutputMessages.cxx b/kernel/src/bbtkWxGUIOutputMessages.cxx new file mode 100644 index 0000000..bb1b422 --- /dev/null +++ b/kernel/src/bbtkWxGUIOutputMessages.cxx @@ -0,0 +1,104 @@ + /*========================================================================= + + Program: bbtk + Module: $RCSfile: bbtkWxGUIOutputMessages.cxx,v $ + Language: C++ + Date: $Date: 2008/03/20 09:51:29 $ + Version: $Revision: 1.1 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*//** + * \brief Short description in one line + * + * Long description which + * can span multiple lines + */ +/** + * \file + * \brief + */ +/** + * \class bbtk:: + * \brief + */ + + +#ifdef _USE_WXWIDGETS_ + +#include "bbtkWxGUIOutputMessages.h" +#include "bbtkMessageManager.h" +#include "bbtkConfigurationFile.h" +#include "bbtkWxStreamRedirector.h" + +namespace bbtk +{ + + + WxGUIOutputMessages::WxGUIOutputMessages(wxWindow *parent, WxGUIOutputMessagesUser* user) + : wxPanel(parent,-1), + mUser(user) + { + wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); + mwxOutputText = + new wxTextCtrl(this, + -1, //ID_OutputText, + _T(""),wxDefaultPosition, + wxDefaultSize, + wxTE_READONLY | + wxTE_MULTILINE ); + + wxFont* FixedFont = new wxFont(10, + wxFONTFAMILY_MODERN, + wxFONTSTYLE_NORMAL, + wxFONTWEIGHT_NORMAL, + false); + + mwxOutputTextAttr = new wxTextAttr; + mwxOutputTextAttr->SetFont(*FixedFont); + sizer->Add ( mwxOutputText, 1, wxALL | wxGROW, 10); + + // Redirection of std::cout to mwxTextHistory and printf + mRedirect_cout = + new WxStreamRedirector(std::cout,mwxOutputText,*wxBLACK,true); + mRedirect_cerr = + new WxStreamRedirector(std::cerr,mwxOutputText,*wxGREEN,true); + + SetSizer(sizer); + SetAutoLayout(true); + Layout(); + } + + WxGUIOutputMessages::~WxGUIOutputMessages() + { + delete mRedirect_cout; + delete mRedirect_cerr; + + } + + void WxGUIOutputMessages::Print(const std::string& message, + const wxColor* col) + { + if (col != 0) + { + mwxOutputTextAttr->SetTextColour(*col); + mwxOutputText->SetDefaultStyle(*mwxOutputTextAttr); + } + mwxOutputText->AppendText(std2wx(message)); + if (col != 0) + { + mwxOutputTextAttr->SetTextColour(*wxBLACK); + mwxOutputText->SetDefaultStyle(*mwxOutputTextAttr); + } + } + + +} + +#endif diff --git a/kernel/src/bbtkWxGUIOutputMessages.h b/kernel/src/bbtkWxGUIOutputMessages.h new file mode 100644 index 0000000..92d83db --- /dev/null +++ b/kernel/src/bbtkWxGUIOutputMessages.h @@ -0,0 +1,98 @@ +/*========================================================================= + + Program: bbtk + Module: $RCSfile: bbtkWxGUIOutputMessages.h,v $ + Language: C++ + Date: $Date: 2008/03/20 09:51:29 $ + Version: $Revision: 1.1 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*//** + * \brief Short description in one line + * + * Long description which + * can span multiple lines + */ +/** + * \file + * \brief + */ +/** + * \class bbtk:: + * \brief + */ + + +#ifdef _USE_WXWIDGETS_ + + +#ifndef __bbtkWxGUIOutputMessages_h__ +#define __bbtkWxGUIOutputMessages_h__ + +#include "bbtkWx.h" + + +namespace bbtk +{ + + /// Abstract class which defines the callbacks invoked by WxGUIOutputMessages + class BBTK_EXPORT WxGUIOutputMessagesUser + { + public: + WxGUIOutputMessagesUser() {} + ~WxGUIOutputMessagesUser() {} + /// Callback invoked when a command is entered in the WxGUIOutputMessages + virtual void WxGUIOutputMessagesEnter(const std::string& command) {} + }; + + + // Forward decl + class WxStreamRedirector; + + /// GUI Component which provides a command input zone + class BBTK_EXPORT WxGUIOutputMessages : public wxPanel + { + public: + WxGUIOutputMessages(wxWindow *parent, WxGUIOutputMessagesUser* user = 0); + ~WxGUIOutputMessages(); + + void Print(const std::string& message, const wxColor* col = 0); + + private : + WxGUIOutputMessagesUser* mUser; + wxTextCtrl* mwxOutputText; + wxTextAttr* mwxOutputTextAttr; + WxStreamRedirector* mRedirect_cout; + WxStreamRedirector* mRedirect_cerr; + /* + public: + enum + { + ID_Text_Command, + ID_Btn_Go, + ID_Btn_Include, + ID_Btn_Reset, + ID_Btn_Config, + ID_Btn_GraphS, + ID_Btn_GraphD, + ID_Btn_Help + }; + + DECLARE_EVENT_TABLE() + */ + }; + + +} // namespace bbtk + + +#endif // __bbtkWxGUIOutputMessages_h__ + +#endif //_USE_WXWIDGETS_ -- 2.45.1