//==========================================================================
#include "bbtkInterpreter.h"
#include "bbtkWxBlackBox.h"
-#include "bbtkWxConsole.h"
+#include "bbtkWxGUIConsole.h"
#include <wx/cmdline.h>
#include <vector>
{ 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 }
};
bool graphical_dialog;
bool text_dialog;
bool no_command;
+ bool no_command_at_all;
std::map<std::string,std::string> param_map;
std::vector<std::string> input_file;
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
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);
if (text_dialog) I->SetDialogMode(bbtk::Executer::TextDialog);
std::vector<std::string>::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)
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();
}
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
#include "bbtkInterpreter.h"
#include "bbtkMessageManager.h"
#include "bbtkConfigurationFile.h"
-#include "bbtkWxConsole.h"
#include "bbtkUtilities.h"
#include <sys/stat.h>
#include <algorithm>
*/
Interpreter::Interpreter()
:
-#ifdef _USE_WXWIDGETS_
- mWxConsole(0),
-#endif
+ mUser(0),
mCommandLine(false)
{
bufferNb =0;
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("\""<<words[1].c_str()
- <<"\" is not a known command, package, black box type or black box name");
- }
- }
+ }
+ catch (bbtk::Exception g)
+ {
+ try
+ {
+ GetExecuter()->ShowRelations(words[1],"0","9999");
+ }
+ catch (bbtk::Exception h){
+ bbtkError("\""<<words[1].c_str()
+ <<"\" is not a known command, package, black box type or black box name");
+ }
+ }
}
}
}
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)
{
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);
+
}
//=======================================================================
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
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
{
#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
/// 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<std::istream*> mFile;
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
mMessageLevel[key] = 0;
mMessageHelp[key] = "Configuration related messages";
if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
- key = "Data";
+ key = "data";
mMessageLevel[key] = 0;
mMessageHelp[key] = "Data related messages";
if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
mMessageLevel[key] = 0;
mMessageHelp[key] = "Widgets related messages";
if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
- }
+ key = "gui";
+ mMessageLevel[key] = 0;
+ mMessageHelp[key] = "Graphical user interface related messages";
+ if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
+ }
+++ /dev/null
-#ifdef _USE_WXWIDGETS_
-
-
-#ifndef __bbtkWxBrowser_h_INCLUDED__
-#define __bbtkWxBrowser_h_INCLUDED__
-
-#include "bbtkWx.h"
-#include <wx/html/htmlwin.h>
-
-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
+++ /dev/null
-/*=========================================================================
-
- 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 <iostream>
-#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 : '"<<command<<"'"<<std::endl);
-printf("EED WxConsole::OnMenuCreatePackage 03 \n");
- Interpreter* I = new Interpreter;
-printf("EED WxConsole::OnMenuCreatePackage 04 \n");
- I->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 : '"<<command<<"'"<<std::endl);
- Interpreter* I = new Interpreter;
- I->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 "<<filepath<<std::endl;
-//EED I->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<std::string> 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 (; ind<com.size(); ++ind)
- {
- mwxTextCommand->TextAppend( std2wx ( com[ind]) );
- }
- mwxTextCommand->TextAppend(_T(" "));
- }
- else if (commands.size()>1)
- {
- std::vector<std::string>::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;j<ind;++j)
- //{
- write(STDOUT_FILENO,line,ind);
- // }
- }
- */
- }
- //================================================================
-
- void WxConsole::ShowHtmlPage(std::string& page)
- {
- // std::cout << "WxConsole::ShowHtmlPage('"<<page<<"')"<<std::endl;
- if (mwxHtmlWindow->GoTo(page))
- {
-//EED mwxNotebook->ChangeSelection(1);
- mwxNotebook->SetSelection(1);
- }
- else
- {
- // std::cout << "ERROR html"<<std::endl;
- }
- }
-
-
-
- //================================================================
- 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 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 );
- 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_
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
// #include "icons/print.xpm"
// #include "icons/help.xpm"
+
+
namespace bbtk
{
EVT_BUTTON(WxEditor::ID_ButtonQuit, WxEditor::OnButtonQuit)
END_EVENT_TABLE()
//================================================================
-
-
+
+ void WxEditorWindow::WxGUICommandEnter(const std::string& s)
+ {
+ std::cout << "Command received : '"<<s<<"'"<<std::endl;
+ }
+
//================================================================
WxEditorWindow::WxEditorWindow( wxWindow *parent, wxString title, wxSize size)
: wxFrame((wxFrame *)parent, -1, title, wxDefaultPosition, size)
{
- mEditor = new WxEditor(this);
-
- //wxFlexGridSizer *sizer= new wxFlexGridSizer(2);
+
+
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
- //sizer->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();
}
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
#include "bbtkInterpreter.h"
#include <wx/splitter.h>
+#include "bbtkWxGUICommand.h"
+
namespace bbtk
{
void HighlightSyntax();
void UpdatePosition();
+
private:
Interpreter* mInterpreter;
wxSplitterWindow* mwxSplit;
wxTextAttr* mwxInputTextAttr;
WxTextCtrlGettingKeyEvents* mwxOutputText;
wxTextAttr* mwxOutputTextAttr;
- wxBitmapButton * mwxButtonNew;
+ wxButton * mwxButtonNew;
wxButton * mwxButtonOpen;
wxButton * mwxButtonSave;
wxButton * mwxButtonRun;
/// 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;
--- /dev/null
+/*=========================================================================
+
+ 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"<<std::endl);
+ SendCommand(wx2std(mwxTextCommand->GetValue()));
+ }
+
+ void WxGUICommand::OnCommandEnter(wxCommandEvent& event)
+ {
+ bbtkDebugMessage("gui",2,"WxGUICommand::OnCommandEnter"<<std::endl);
+ SendCommand(wx2std(mwxTextCommand->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"<<std::endl);
+
+ 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("Include 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());
+ std::string command("include ");
+ command += wx2std(dialog.GetPath());
+ SendCommand(command);
+ }
+ }
+
+ void WxGUICommand::OnBtnReset(wxCommandEvent& event)
+ {
+ bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnReset"<<std::endl);
+ SendCommand("reset");
+ }
+
+ void WxGUICommand::OnBtnConfig(wxCommandEvent& event)
+ {
+ bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnConfig"<<std::endl);
+ SendCommand("config");
+ }
+
+ void WxGUICommand::OnBtnGraphS(wxCommandEvent& event)
+ {
+ bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnGraphS"<<std::endl);
+ SendCommand("graph");
+ }
+
+ void WxGUICommand::OnBtnGraphD(wxCommandEvent& event)
+ {
+ bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnGraphD"<<std::endl);
+ SendCommand("graph . 1");
+ }
+
+ void WxGUICommand::OnBtnHelp(wxCommandEvent& event)
+ {
+ bbtkDebugMessage("gui",2,"WxGUICommand::OnBtnHelp"<<std::endl);
+ SendCommand("help");
+ }
+
+} // namespace bbtk
+
+#endif // _USE_WXWIDGETS_
--- /dev/null
+/*=========================================================================
+
+ Program: bbtk
+ Module: $RCSfile: bbtkWxGUICommand.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 __bbtkWxGUICommand_h__
+#define __bbtkWxGUICommand_h__
+
+#include "bbtkWx.h"
+
+
+namespace bbtk
+{
+ /// Abstract class which defines the callbacks invoked by WxGUICommand
+ class BBTK_EXPORT WxGUICommandUser
+ {
+ public:
+ WxGUICommandUser() {}
+ ~WxGUICommandUser() {}
+ /// Callback invoked when a command is entered in the WxGUICommand
+ virtual void WxGUICommandEnter(const std::string& command) {}
+ };
+
+ /// GUI Component which provides a command input zone
+ class BBTK_EXPORT WxGUICommand : public wxPanel
+ {
+ public:
+ WxGUICommand(wxWindow *parent, WxGUICommandUser* user = 0);
+ ~WxGUICommand();
+
+ 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 SendCommand(const std::string& command);
+ private :
+ WxGUICommandUser* mUser;
+ wxComboBox* mwxTextCommand;
+ // wxTextAttr* mwxTextCommandAttr;
+
+ 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 // __bbtkWxGUICommand_h__
+
+#endif //_USE_WXWIDGETS_
--- /dev/null
+/*=========================================================================
+
+ Program: bbtk
+ Module: $RCSfile: bbtkWxGUIConsole.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 <iostream>
+#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 : '"<<command<<"'"<<std::endl);
+printf("EED WxGUIConsole::OnMenuCreatePackage 03 \n");
+ Interpreter* I = new Interpreter;
+printf("EED WxGUIConsole::OnMenuCreatePackage 04 \n");
+ I->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 : '"<<command<<"'"<<std::endl);
+ Interpreter* I = new Interpreter;
+ I->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 "<<filepath<<std::endl;
+//EED I->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('"<<page<<"')"<<std::endl;
+ if (mWxGUIHtmlBrowser->GoTo(s))
+ {
+//EED mwxNotebook->ChangeSelection(1);
+ mwxNotebook->SetSelection(1);
+ }
+ else
+ {
+ // std::cout << "ERROR html"<<std::endl;
+ }
+ }
+ //================================================================
+
+
+ //================================================================
+ BEGIN_EVENT_TABLE(WxGUIConsole, wxFrame)
+ EVT_MENU(ID_Menu_Quit, WxGUIConsole::OnMenuQuit)
+ EVT_MENU(ID_Menu_About, WxGUIConsole::OnMenuAbout)
+ EVT_MENU(ID_Menu_EditConfig, WxGUIConsole::OnMenuEditConfig)
+ EVT_MENU(ID_Menu_CreatePackage, WxGUIConsole::OnMenuCreatePackage)
+ EVT_MENU(ID_Menu_CreateBlackBox, WxGUIConsole::OnMenuCreateBlackBox)
+ EVT_MENU(ID_Menu_ShowImageGraph, WxGUIConsole::OnMenuShowImageGraph)
+ EVT_MENU(ID_Menu_CreateIndex, WxGUIConsole::OnMenuCreateIndex)
+ EVT_BUTTON(ID_Button_Run, WxGUIConsole::OnButtonRun )
+ END_EVENT_TABLE()
+ //================================================================
+
+} // namespace bbtk
+
+
+#endif //_USE_WXWIDGETS_
/*=========================================================================
Program: bbtk
- Module: $RCSfile: bbtkWxConsole.h,v $
+ Module: $RCSfile: bbtkWxGUIConsole.h,v $
Language: C++
- Date: $Date: 2008/03/19 14:58:13 $
- Version: $Revision: 1.10 $
+ 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
#ifdef _USE_WXWIDGETS_
-#ifndef __bbtkWxConsole_h__
-#define __bbtkWxConsole_h__
+#ifndef __bbtkWxGUIConsole_h__
+#define __bbtkWxGUIConsole_h__
#include <wx/aui/aui.h>
#include "bbtkWx.h"
#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)
{ 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);
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()
};
} // namespace bbtk
-#endif // __bbtkWxConsole_h__
+#endif // __bbtkWxGUIConsole_h__
#endif //_USE_WXWIDGETS_
+/*=========================================================================
+
+ 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"
//========================================================================
- 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 );
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,
wxDefaultPosition,
size,
wxHW_SCROLLBAR_AUTO,
- "bbtk::WxBrowser");
+ "bbtk::WxGUIHtmlBrowser");
*/
mwxHtmlWindow->SetBorders(5);
// mwxHtmlWindow->FitInside();
// 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="<<wxEVT_COMMAND_HTML_LINK_CLICKED<<std::endl;
-
- Connect( wxID_ANY, //mwxHtmlWindow->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"<<std::endl;
//========================================================================
//========================================================================
- void WxBrowser::OnBackButton(wxCommandEvent& )
+ void WxGUIHtmlBrowser::OnBackButton(wxCommandEvent& )
{
// std::cout << "back"<<std::endl;
mwxHtmlWindow->HistoryBack();
//========================================================================
//========================================================================
- void WxBrowser::OnForwardButton(wxCommandEvent& )
+ void WxGUIHtmlBrowser::OnForwardButton(wxCommandEvent& )
{
// std::cout << "forward"<<std::endl;
mwxHtmlWindow->HistoryForward();
//========================================================================
//========================================================================
- void WxBrowser::GoHome()
+ void WxGUIHtmlBrowser::GoHome()
{
std::string url = ConfigurationFile::GetInstance().Get_doc_path();
url += "/bbtkWebSite/menu.html";
//========================================================================
//========================================================================
- 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;
}
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());
}
//========================================================================
- void WxBrowser::OnLinkClicked(wxHtmlLinkEvent& e)
+ void WxGUIHtmlBrowser::OnLinkClicked(wxHtmlLinkEvent& e)
{
mwxHtmlWindow->LoadPage( e.GetLinkInfo().GetHref() );
UpdateURL();
/*
- void WxBrowser::OnCell(wxHtmlCellEvent& )
+ void WxGUIHtmlBrowser::OnCell(wxHtmlCellEvent& )
{
std::cout << "OnCell"<<std::endl;
}
*/
//========================================================================
- void WxBrowser::UpdateURL()
+ void WxGUIHtmlBrowser::UpdateURL()
{
wxString s = mwxHtmlWindow->GetOpenedPage();
//========================================================================
//========================================================================
- void WxBrowser::SetSize( wxSize s)
+ void WxGUIHtmlBrowser::SetSize( wxSize s)
{
// wxPanel::SetSize(s);
mwxHtmlWindow->SetSize(s);
--- /dev/null
+/*=========================================================================
+
+ 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 <wx/html/htmlwin.h>
+
+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
--- /dev/null
+ /*=========================================================================
+
+ 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
--- /dev/null
+/*=========================================================================
+
+ 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_