From: Eduardo Davila Date: Mon, 3 Mar 2008 10:48:47 +0000 (+0000) Subject: wxConsole new version X-Git-Tag: r0.6.1~154 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=212c9b04e56588b2e50c27f5d87258571463a819;p=bbtk.git wxConsole new version --- diff --git a/kernel/src/bbtkWxConsole.cxx b/kernel/src/bbtkWxConsole.cxx index b4b7e3a..78cc417 100644 --- a/kernel/src/bbtkWxConsole.cxx +++ b/kernel/src/bbtkWxConsole.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkWxConsole.cxx,v $ Language: C++ - Date: $Date: 2008/02/21 09:37:23 $ - Version: $Revision: 1.5 $ + Date: $Date: 2008/03/03 10:48:47 $ + 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 @@ -35,6 +35,7 @@ #include #include "bbtkWxConsole.h" #include "bbtkWxBlackBox.h" +#include "bbtkConfigurationFile.h" namespace bbtk { @@ -170,9 +171,16 @@ namespace bbtk wxMenu *menuAbout = new wxMenu; 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_ShowImageGraph, _T("&Show last image graph") ); + wxMenuBar *menuBar = new wxMenuBar; menuBar->Append( menuFile, _T("&File") ); + menuBar->Append( menuTools, _T("&Tools") ); menuBar->Append( menuAbout, _T("About") ); SetMenuBar( menuBar ); @@ -184,19 +192,27 @@ namespace bbtk // Notebook // wxFlexGridSizer *sizer = new wxFlexGridSizer(1); - wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL); - - - mwxNotebook = new wxNotebook(this, -1, - wxDefaultPosition, wxDefaultSize, 0); + +//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")); - + mwxPageHelp = new wxPanel(mwxNotebook,-1); mwxNotebook->AddPage( mwxPageHelp, _T("Help")); + - sizer->Add ( mwxNotebook, 1, wxEXPAND /*| wxALIGN_BOTTOM*/ ); +//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); @@ -239,6 +255,7 @@ namespace bbtk mwxTextHistoryAttr = new wxTextAttr; mwxTextHistoryAttr->SetFont(*FixedFont); + /* mwxTextCommand = new wxTextCtrl(mwxPageCommand, ID_Text_Command, @@ -247,22 +264,43 @@ namespace bbtk wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB | wxWANTS_CHARS - //| wxTAB_TRAVERSAL + //| wxTAB_TRAVERSAL ); - - mwxTextCommandAttr = new wxTextAttr; mwxTextCommandAttr->SetFont(*FixedFont); mwxTextCommand->SetDefaultStyle(*mwxTextCommandAttr); + */ + mwxTextCommand = + new wxComboBox(mwxPageCommand, + ID_Text_Command, + _T("") +// wxDefaultPosition, +// wxDefaultSize, +// 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); - - cmdsizer->Add ( mwxTextCommand, 0, wxLEFT | wxRIGHT | wxBOTTOM - | 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); @@ -295,7 +333,7 @@ namespace bbtk // Layout - SetSizer(sizer); +//EED SetSizer(sizer); SetAutoLayout(true); Layout(); @@ -315,21 +353,44 @@ namespace bbtk 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()); - mwxTextCommand->Clear(); - mwxTextCommand->SetDefaultStyle(*mwxTextCommandAttr); +//EED mwxTextCommand->Clear(); + mwxTextCommand->SetValue(_T("")); + mwxTextCommand->Append(line); + +//EED mwxTextCommand->SetDefaultStyle(*mwxTextCommandAttr); mwxTextHistoryAttr->SetTextColour(*wxBLACK); mwxTextHistory->SetDefaultStyle(*mwxTextHistoryAttr); +printf("WxConsole::CommandString 03 \n"); try { bool insideComment = false; +printf("WxConsole::CommandString 04 \n"); mInterpreter->InterpretLine( wx2std(line), insideComment ); +printf("WxConsole::CommandString 05 \n"); } catch (bbtk::QuitException) { @@ -348,6 +409,7 @@ namespace bbtk std::cout << "* UNDEFINED ERROR (not a bbtk nor a std exception)" << std::endl; } +printf("WxConsole::CommandString 06 \n"); } //================================================================ @@ -370,6 +432,45 @@ namespace bbtk } //================================================================ + + //================================================================ + void WxConsole::OnMenuCreatePackage(wxCommandEvent& WXUNUSED(event)) + { + + wxMessageBox(_T(" Creating Package"), + _T("Creating Package ..."), wxOK | wxICON_INFORMATION, + this); + } + //================================================================ + + + //================================================================ + void WxConsole::OnMenuCreateBlackBox(wxCommandEvent& WXUNUSED(event)) + { + + wxMessageBox(_T(" Creating blackbox"), + _T("Creating blackbox ..."), wxOK | wxICON_INFORMATION, + this); + } + //================================================================ + + //================================================================ + void WxConsole::OnMenuShowImageGraph(wxCommandEvent& WXUNUSED(event)) + { + std::string default_doc_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"; + system ( strcommand.c_str() ); + } + //================================================================ + + + //================================================================ void WxConsole::OnCommandChar(wxCommandEvent& event) { @@ -413,7 +514,8 @@ namespace bbtk // std::cout << "WxConsole::ShowHtmlPage('"<GoTo(page)) { - mwxNotebook->ChangeSelection(1); +//EED mwxNotebook->ChangeSelection(1); + mwxNotebook->SetSelection(1); } else { @@ -421,10 +523,110 @@ namespace bbtk } } + + + //================================================================ + 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") ); + + btnsSizer->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) + { +printf("WxConsole::OnBtnReset 01 \n"); + CommandString(_T("reset")); +printf("WxConsole::OnBtnReset 02 \n"); + } + //================================================================ + + + //================================================================ + 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_CreatePackage, WxConsole::OnMenuCreatePackage) + EVT_MENU(WxConsole::ID_Menu_CreateBlackBox, WxConsole::OnMenuCreateBlackBox) + EVT_MENU(WxConsole::ID_Menu_ShowImageGraph, WxConsole::OnMenuShowImageGraph) EVT_TEXT_ENTER(WxConsole::ID_Text_Command, WxConsole::OnCommandEnter) // EVT_CHAR(WxConsole::ID_Text_Command, WxConsole::OnCommandChar) END_EVENT_TABLE() diff --git a/kernel/src/bbtkWxConsole.h b/kernel/src/bbtkWxConsole.h index 261f434..41ca170 100644 --- a/kernel/src/bbtkWxConsole.h +++ b/kernel/src/bbtkWxConsole.h @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkWxConsole.h,v $ Language: C++ - Date: $Date: 2008/03/03 08:06:36 $ - Version: $Revision: 1.4 $ + Date: $Date: 2008/03/03 10:48:48 $ + 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 @@ -36,7 +36,7 @@ #ifndef __bbtkWxConsole_h__ #define __bbtkWxConsole_h__ - +#include #include "bbtkWx.h" #include #include @@ -76,31 +76,51 @@ namespace bbtk void OnMenuQuit(wxCommandEvent& event); void OnMenuAbout(wxCommandEvent& event); + void OnMenuCreatePackage(wxCommandEvent& WXUNUSED(event)); + void OnMenuCreateBlackBox(wxCommandEvent& WXUNUSED(event)); + void OnMenuShowImageGraph(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&); private: Interpreter* mInterpreter; wxTextCtrl* mwxTextHistory; - wxTextCtrl* mwxTextCommand; +//EED wxTextCtrl* mwxTextCommand; + wxComboBox* mwxTextCommand; wxTextAttr* mwxTextHistoryAttr; wxTextAttr* mwxTextCommandAttr; - wxNotebook* mwxNotebook; +//EED wxNotebook* mwxNotebook; + wxAuiNotebook* mwxNotebook; wxPanel *mwxPageCommand, *mwxPageHelp; WxTextCtrlStreamRedirector* mRedirect_cout; WxTextCtrlStreamRedirector* mRedirect_cerr; - WxBrowser* mwxHtmlWindow; - static WxConsole* mInstance; + + wxPanel* CreateBtnsCtrlPanel(wxWindow *parent); + void CommandString(wxString line ); + public: enum { ID_Menu_Quit = 1, ID_Menu_About, + ID_Menu_CreatePackage, + ID_Menu_CreateBlackBox, + ID_Menu_ShowImageGraph, ID_Text_Command, ID_Text_History,