Program: bbtk
Module: $RCSfile: bbtkException.h,v $
Language: C++
- Date: $Date: 2008/01/22 15:02:00 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/03/21 14:59:39 $
+ Version: $Revision: 1.2 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{
public:
Exception(const std::string& object,
- const std::string& file,
+ const std::string& source_file,
const std::string& message) throw()
: mObject(object),
- mFile(file),
+ mSourceFile(source_file),
mMessage(message)
{}
~Exception() throw() {}
int lev = bbtk::MessageManager::GetMessageLevel("Error");
if (lev > 0) {
std::cerr << "* OBJECT : " <<mObject<<std::endl;
- std::cerr << "* FILE : " <<mFile<<std::endl;
+ std::cerr << "* FILE : " <<mSourceFile<<std::endl;
}
}
const std::string& GetObject() const { return mObject; }
- const std::string& GetFile() const { return mFile; }
+ const std::string& GetSourceFile() const { return mSourceFile; }
const std::string& GetMessage() const { return mMessage; }
private:
std::string mObject;
- std::string mFile;
+ std::string mSourceFile;
std::string mMessage;
};
Program: bbtk
Module: $RCSfile: bbtkInterpreter.cxx,v $ $
Language: C++
- Date: $Date: 2008/03/21 11:44:37 $
- Version: $Revision: 1.51 $
+ Date: $Date: 2008/03/21 14:59:39 $
+ Version: $Revision: 1.52 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//=======================================================================
+ InterpreterError::InterpreterError( const std::string& message,
+ bool in_script_file,
+ const std::string& script_file,
+ int script_line
+ )
+ : Exception("Interpreter",0,message),
+ mInScriptFile(in_script_file),
+ mScriptFile(script_file),
+ mScriptLine(script_line)
+ {
+ }
+ InterpreterError::InterpreterError( const Exception& excep,
+ bool in_script_file,
+ const std::string& script_file,
+ int script_line
+ )
+ : Exception(excep),
+ mInScriptFile(in_script_file),
+ mScriptFile(script_file),
+ mScriptLine(script_line)
+ {
+ }
+ //=======================================================================
+ void Interpreter::CatchBbtkException( const bbtk::Exception& e )
+ {
+ if (mThrow)
+ {
+ bool in_script = false;
+ std::string file("");
+ int line = 0;
+ if (mFileName.size()) {
+ std::ifstream* fs = dynamic_cast<std::ifstream*>(mFile.back());
+ if (fs!=0) in_script = true;
+ file = mFileName.back();
+ line = mLine.back();
+ }
+ throw InterpreterError(e,in_script,file,line);
+ }
+ else
+ {
+ std::stringstream mess;
+ mess << "* ERROR : "<<e.GetMessage()<<std::endl;
+ if (mFileName.size()) {
+ mess << "* FILE : \""<<mFileName.back()<<"\""<<std::endl;
+ mess << "* LINE : "<<mLine.back()<<std::endl;
+ }
+ std::cerr << mess.str();
+ }
+ }
+ //=======================================================================
+
+ //=======================================================================
+ void Interpreter::CatchStdException( const std::exception& e )
+ {
+ if (mThrow)
+ {
+ bool in_script = false;
+ std::string file("");
+ int line = 0;
+ if (mFileName.size()) {
+ std::ifstream* fs = dynamic_cast<std::ifstream*>(mFile.back());
+ if (fs!=0) in_script = true;
+ file = mFileName.back();
+ line = mLine.back();
+ }
+ throw InterpreterError(e.what(),in_script,file,line);
+ }
+ else
+ {
+ std::stringstream mess;
+ mess << "* ERROR : "<<e.what()<<std::endl;
+ if (mFileName.size()) {
+ mess << "* FILE : \""<<mFileName.back()<<"\""<<std::endl;
+ mess << "* LINE : "<<mLine.back()<<std::endl;
+ }
+ std::cerr << mess.str();
+ }
+ }
+ //=======================================================================
+
+ //=======================================================================
+ void Interpreter::CatchUnknownException()
+ {
+ if (mThrow)
+ {
+ bool in_script = false;
+ std::string file("");
+ int line = 0;
+ if (mFileName.size()) {
+ std::ifstream* fs = dynamic_cast<std::ifstream*>(mFile.back());
+ if (fs!=0) in_script = true;
+ file = mFileName.back();
+ line = mLine.back();
+ }
+ throw InterpreterError("Unknown exception caught",
+ in_script,file,line);
+ }
+ else
+ {
+ std::stringstream mess;
+ mess << "* UNDEFINED ERROR (not a bbtk nor a std exception)"
+ << std::endl;
+ if (mFileName.size()) {
+ mess << "* FILE : \""<<mFileName.back()<<"\""<<std::endl;
+ mess << "* LINE : "<<mLine.back()<<std::endl;
+ }
+ std::cerr << mess.str();
+ }
+ }
+ //=======================================================================
+
+ //=======================================================================
+
+#define CATCH_MACRO \
+ catch (QuitException e) \
+ { \
+ status = Interpreter_QUIT; \
+ if (mThrow) throw QuitException(); \
+ } \
+ catch (bbtk::Exception e) \
+ { \
+ status = Interpreter_ERROR; \
+ CatchBbtkException(e); \
+ } \
+ catch (std::exception& e) \
+ { \
+ status = Interpreter_ERROR; \
+ CatchStdException(e); \
+ } \
+ catch (...) \
+ { \
+ status = Interpreter_ERROR; \
+ CatchUnknownException(); \
+ }
+ //=======================================================================
+
+
//=======================================================================
/**
*
ExitStatus status = Interpreter_OK;
-
try
{
SwitchToFile(filename);
CloseCurrentFile();
}
}
- catch (QuitException e)
- {
- status = Interpreter_QUIT;
- if (mThrow) throw QuitException();
- }
- catch (bbtk::Exception e)
- {
- std::stringstream mess;
- mess << "* ERROR : "<<e.GetMessage()<<std::endl;
- if (mFileName.size()) {
- mess << "* FILE : \""<<mFileName.back()<<"\""<<std::endl;
- mess << "* LINE : "<<mLine.back()<<std::endl;
- }
- status = Interpreter_ERROR;
- if (mThrow)
- throw bbtk::Exception("Interpreter","",mess.str());
- else
- std::cerr << mess.str();
-
- }
- catch (std::exception& e)
- {
- std::stringstream mess;
- mess << "* ERROR : "<<e.what()<<" (not in bbtk)"<<std::endl;
- if (mFileName.size()) {
- mess << "* FILE : \""<<mFileName.back()<<"\""<<std::endl;
- mess << "* LINE : "<<mLine.back()<<std::endl;
- }
- status = Interpreter_ERROR;
- if (mThrow)
- throw bbtk::Exception("Interpreter","",mess.str());
- else
- std::cerr << mess.str();
- }
- catch (...)
- {
- std::stringstream mess;
- mess << "* UNDEFINED ERROR (not a bbtk nor a std exception)"
- <<std::endl;
- if (mFileName.size()) {
- mess << "* FILE : \""<<mFileName.back()<<"\""<<std::endl;
- mess << "* LINE : "<<mLine.back()<<std::endl;
- }
- status = Interpreter_ERROR;
- if (mThrow)
- throw bbtk::Exception("Interpreter","",mess.str());
- else
- std::cerr << mess.str();
- }
+ CATCH_MACRO;
CloseAllFiles();
bbtkDebugMessage("Interpreter",9,"EO Interpreter::InterpretFile(\""<<filename<<"\")"<<std::endl);
CloseCurrentFile();
}
}
- catch (QuitException e)
- {
- status = Interpreter_QUIT;
- }
- catch (bbtk::Exception e)
- {
- std::cerr << "* ERROR : "<<e.GetMessage()<<std::endl;
- if (mFileName.size())
- {
- std::cerr << "* FILE : \""<<mFileName.back()<<"\""<<std::endl;
- std::cerr << "* LINE : "<<mLine.back()<<std::endl;
- }
- status = Interpreter_ERROR;
- }
- catch (std::exception& e)
- {
- std::cerr << "* ERROR : "<<e.what()<<" (not in bbtk)"<<std::endl;
- if (mFileName.size())
- {
- std::cerr << "* FILE : \""<<mFileName.back()<<"\""<<std::endl;
- std::cerr << "* LINE : "<<mLine.back()<<std::endl;
- }
- status = Interpreter_ERROR;
- }
- catch (...)
- {
- std::cerr
- << "* UNDEFINED ERROR (not a bbtk nor a std exception)"<<std::endl;
- if (mFileName.size())
- {
- std::cerr << "* FILE : \""<<mFileName.back()<<"\""<<std::endl;
- std::cerr << "* LINE : "<<mLine.back()<<std::endl;
- }
- status = Interpreter_ERROR;
- }
+ CATCH_MACRO;
CloseAllFiles();
bbtkDebugMessage("Interpreter",9,"EO Interpreter::InterpretBuffer()"<<std::endl);
bool insideComment = false;
InterpretLine(line, insideComment);
}
- catch (QuitException e)
+ CATCH_MACRO;
+ /*
+ catch (QuitException e)
{
status = Interpreter_QUIT;
}
<< "* UNDEFINED ERROR (not a bbtk nor a std exception)"<<std::endl;
status = Interpreter_ERROR;
}
-
+ */
bbtkDebugMessage("Interpreter",9,"EO Interpreter::InterpretLine()"
<<std::endl);
mFileName.push_back(fullPathScriptName);
mIncludeFileName.push_back(includeScriptName);
mLine.push_back(0);
+
return;
}
Program: bbtk
Module: $RCSfile: bbtkInterpreter.h,v $ $
Language: C++
- Date: $Date: 2008/03/21 11:44:37 $
- Version: $Revision: 1.19 $
+ Date: $Date: 2008/03/21 14:59:39 $
+ Version: $Revision: 1.20 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
};
+ ///
+ class BBTK_EXPORT InterpreterError : public Exception
+ {
+ public:
+ InterpreterError( const std::string& message,
+ bool in_script_file,
+ const std::string& script_file,
+ int script_line
+ );
+ InterpreterError( const Exception& excep,
+ bool in_script_file,
+ const std::string& script_file,
+ int script_line
+ );
+ ~InterpreterError() throw() {}
+
+ bool IsInScriptFile() const { return mInScriptFile; }
+ const std::string& GetScriptFile() const { return mScriptFile; }
+ int GetScriptLine() const { return mScriptLine; }
+ private:
+ bool mInScriptFile;
+ std::string mScriptFile;
+ int mScriptLine;
+ };
+
+
+ ///
class BBTK_EXPORT Interpreter
{
void LoadScript( std::string fullPathScriptName,
std::string includeScriptName);
+ ///
+ void CatchBbtkException( const bbtk::Exception& e );
+ void CatchStdException( const std::exception& e );
+ void CatchUnknownException();
+
private:
//==================================================================
Program: bbtk
Module: $RCSfile: bbtkWxGUIHtmlBrowser.cxx,v $
Language: C++
- Date: $Date: 2008/03/20 15:27:57 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/03/21 14:59:39 $
+ Version: $Revision: 1.3 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//========================================================================
- WxGUIHtmlBrowser::WxGUIHtmlBrowser ( wxWindow *parent, wxSize size )
+ WxGUIHtmlBrowser::WxGUIHtmlBrowser ( wxWindow *parent, wxSize size,
+ WxGUIHtmlBrowserUser* user)
:
- wxPanel ( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
- // , mWxGUIConsole(0)
+ wxPanel ( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
+ mUser(user)
{
wxPanel* panel = this;
//========================================================================
void WxGUIHtmlBrowser::OnLinkClicked(wxHtmlLinkEvent& e)
- {
- mwxHtmlWindow->LoadPage( e.GetLinkInfo().GetHref() );
+ {
+ std::cout << "BrOnLink"<<std::endl;
+
+ bool go = true;
+ if (mUser)
+ {
+ wxString file = wxPathOnly(mwxURL->GetValue());
+ file += std2wx(ConfigurationFile::GetInstance().Get_file_separator());
+ file += e.GetLinkInfo().GetHref();
+ go = mUser->WxGUIHtmlBrowserUserOnLinkClicked( wx2std( file ) );
+ }
+ if (go)
+ {
+ mwxHtmlWindow->LoadPage( e.GetLinkInfo().GetHref() );
UpdateURL();
- mwxHtmlWindow->LoadPage( mwxURL->GetValue() );
- }
+ }
+ // mwxHtmlWindow->LoadPage( mwxURL->GetValue() );
+ }
//========================================================================
Program: bbtk
Module: $RCSfile: bbtkWxGUIHtmlBrowser.h,v $
Language: C++
- Date: $Date: 2008/03/20 09:51:29 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/03/21 14:59:39 $
+ Version: $Revision: 1.2 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
};
- /*
+
/// Abstract class which defines the callbacks invoked by WxGUIHtmlBrowser
class WxGUIHtmlBrowserUser
{
public :
WxGUIHtmlBrowserUser() {}
~WxGUIHtmlBrowserUser() {}
+
+ virtual bool WxGUIHtmlBrowserUserOnLinkClicked(const std::string& target)
+ { return true; }
};
- */
+
// class WxGUIConsole;
class WxGUIHtmlBrowser : public wxPanel
{
public:
- WxGUIHtmlBrowser ( wxWindow *parent, wxSize size );
- // WxGUIHtmlBrowserUser* = 0 );
+ WxGUIHtmlBrowser ( wxWindow *parent, wxSize size,
+ WxGUIHtmlBrowserUser* = 0 );
bool GoTo(std::string&);
void GoHome();
wxButton* mwxReloadButton;
// wxButton* mwxRunButton;
- // WxGUIHtmlBrowserUser* mUser;
+ WxGUIHtmlBrowserUser* mUser;
// any class wishing to process wxWidgets events must use this macro
DECLARE_EVENT_TABLE()
Program: bbtk
Module: $RCSfile: bbtkWxGUIScriptingInterface.cxx,v $
Language: C++
- Date: $Date: 2008/03/21 11:46:41 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/03/21 14:59:39 $
+ Version: $Revision: 1.2 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
CreateStatusBar();
SetStatusText( _T("Welcome to bbi !") );
-
- /*
- m_mgr.AddPane(CreateSizeReportCtrl(), wxAuiPaneInfo().
- Name(wxT("test4")).Caption(wxT("Pane Caption")).
- Left());
- */
-
- //==============
- // 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);
-*/
- mWxGUITextEditor = new WxGUITextEditor(this);
+ //
+ mWxGUITextEditor = new WxGUITextEditor(this,this);
mWxGUITextEditor->SetFileNameFilter("*.bbs");
- mWxGUIHtmlBrowser = new WxGUIHtmlBrowser(this, //mwxPageHelp,
- //EED wxSize(1200,0));
- wxSize(200,0));
-
- // mWxGUIHtmlBrowser->SetSize(wxSize(800,1000));
- // helpsizer->Add (mWxGUIHtmlBrowser,1, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5 );
- // helpsizer->Add ( new wxButton(mwxPageHelp,-1,"perro"), 0, wxEXPAND );
-
- wxBitmap bmp_run(cc_run_xpm);
- mwxButtonRun = new wxBitmapButton( this, ID_Button_Run,bmp_run);//_T("Run") );
- // helpsizer->Add( mwxButtonRun, 0, wxALL, 5 );
+ mWxGUIHtmlBrowser = new WxGUIHtmlBrowser(this,wxSize(200,0),this);
+ /*
+ wxBitmap bmp_run(cc_run_xpm);
+ mwxButtonRun = new wxBitmapButton( this, ID_Button_Run,bmp_run);//_T("Run") );
+ */
- //==============
- // Command page
mWxGUIOutputMessages = new WxGUIOutputMessages(this);
mWxGUICommand = new WxGUICommand(this,this);
- // mWxGUICommand->SetFocus();
-
- // cmdsizer->Add (mWxGUIOutputMessages, 1, wxALL | wxGROW, 5);
- // cmdsizer->Add (mWxGUICommand, 0, wxALL | wxGROW, 5);
+ mWxGUICommand->SetFocus();
-
// 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(mWxGUITextEditor,
wxAuiPaneInfo().Name(wxT("editor_content"))
- .Top());
+ .Caption(wxT("Files"))
+ .MinimizeButton(true)
+ .MaximizeButton(true)
+ .Center()
+ );
+ m_mgr.AddPane(mWxGUIHtmlBrowser,
+ wxAuiPaneInfo().Name(wxT("browser_content"))
+ .Caption(wxT("Help"))
+ .MinimizeButton(true)
+ .MaximizeButton(true)
+ .Right()
+ );
m_mgr.AddPane(mWxGUIOutputMessages,
wxAuiPaneInfo().Name(wxT("messages_content"))
.Caption(wxT("Messages"))
- .Center());
- m_mgr.AddPane(mWxGUIHtmlBrowser,
- wxAuiPaneInfo().Name(wxT("browser_content"))
- .Right());
+ .MinimizeButton(true)
+ .MaximizeButton(true)
+ .Bottom()
+ );
m_mgr.AddPane(mWxGUICommand,
wxAuiPaneInfo().Name(wxT("command_content"))
- .Bottom());
- m_mgr.AddPane(mwxButtonRun,
- wxAuiPaneInfo().Name(wxT("button_run_content")));
+ .Caption(wxT("Command"))
+ .MinimizeButton(true)
+ .MaximizeButton(true)
+ .Bottom()
+ .Position(1)
+);
+ // m_mgr.AddPane(mwxButtonRun,
+ // wxAuiPaneInfo().Name(wxT("button_run_content")));
//.PaneBorder(false));
mWxGUIOutputMessages->Print(s,wxRED);
if ( mInterpreter->InterpretLine( command ) ==
- Interpreter::QUIT )
+ Interpreter::Interpreter_QUIT )
{
Close(true);
}
bool WxGUIScriptingInterface::InterpretFile( const std::string& filename)
{
if ( mInterpreter->InterpretFile(filename) ==
- Interpreter::ERROR )
+ Interpreter::Interpreter_ERROR )
{
return false;
}
//================================================================
//================================================================
- void WxGUIScriptingInterface::OnButtonRun(wxCommandEvent& WXUNUSED(event))
+ void WxGUIScriptingInterface::WxGUITextEditorRun()
{
- wxString per = m_mgr.SavePerspective();
- std::cout << per<< std::endl;
+ // wxString per = m_mgr.SavePerspective();
+ // std::cout << per<< std::endl;
+
+ // wxString temp = mWxGUIHtmlBrowser->GetCurrentPage();
+ std::stringstream* buf = new std::stringstream;
+ (*buf) << mWxGUITextEditor->GetCurrentPage()->GetText();
-// wxString temp = mWxGUIHtmlBrowser->GetCurrentPage();
- std::string filename = mWxGUIHtmlBrowser->GetCurrentPage();//wx2std(temp);
+ mInterpreter->SetThrow(true);
+ try
+ {
+ mInterpreter->InterpretBuffer(buf);
+ }
+ catch (InterpreterError e)
+ {
+ std::cerr << "* IERROR : "<<e.GetMessage()<<std::endl;
+ if (e.IsInScriptFile())
+ std::cerr << "* FILE : '"<<e.GetScriptFile()<<"'"<<std::endl;
+ std::cerr << "* LINE : "<<e.GetScriptLine()<<std::endl;
+ int lev = bbtk::MessageManager::GetMessageLevel("Error");
+ if (lev > 0) {
+ std::cerr << "* Exception thrown : "<<std::endl;
+ std::cerr << "* OBJECT : " <<e.GetObject()<<std::endl;
+ std::cerr << "* FILE : " <<e.GetSourceFile()<<std::endl;
+ }
+ }
+ /*
+ // wxString temp = mWxGUIHtmlBrowser->GetCurrentPage();
+ std::string filename = mWxGUITextEditor->GetCurrentPage();//wx2std(temp);
size_t s = filename.length();
Interpreter* I = new Interpreter;
}
delete I;
+ */
}
//================================================================
if (mWxGUIHtmlBrowser->GoTo(s))
{
//EED mwxNotebook->ChangeSelection(1);
- mwxNotebook->SetSelection(1);
+// mwxNotebook->SetSelection(1);
}
else
{
}
//================================================================
-
+ //================================================================
+ bool WxGUIScriptingInterface::WxGUIHtmlBrowserUserOnLinkClicked(const std::string& target)
+ {
+ std::cout << "OnLink"<<std::endl;
+ size_t s = target.length();
+ if ((s>3) && (target[s-1]=='s')
+ && (target[s-2]=='b')
+ && (target[s-3]=='b')
+ && (target[s-4]=='.'))
+ {
+ mWxGUITextEditor->Open(target);
+ return false;
+ }
+ return true;
+ }
+ //================================================================
+
//================================================================
BEGIN_EVENT_TABLE(WxGUIScriptingInterface, wxFrame)
EVT_MENU(ID_Menu_Quit, WxGUIScriptingInterface::OnMenuQuit)
EVT_MENU(ID_Menu_CreateBlackBox, WxGUIScriptingInterface::OnMenuCreateBlackBox)
EVT_MENU(ID_Menu_ShowImageGraph, WxGUIScriptingInterface::OnMenuShowImageGraph)
EVT_MENU(ID_Menu_CreateIndex, WxGUIScriptingInterface::OnMenuCreateIndex)
- EVT_BUTTON(ID_Button_Run, WxGUIScriptingInterface::OnButtonRun )
+ // EVT_BUTTON(ID_Button_Run, WxGUIScriptingInterface::OnButtonRun )
END_EVENT_TABLE()
//================================================================
Program: bbtk
Module: $RCSfile: bbtkWxGUIScriptingInterface.h,v $
Language: C++
- Date: $Date: 2008/03/21 11:46:41 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/03/21 14:59:39 $
+ Version: $Revision: 1.2 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
/// A scripting interface window
class BBTK_EXPORT WxGUIScriptingInterface : public wxFrame,
- public InterpreterUser,
- public WxGUICommandUser
+ public InterpreterUser,
+ public WxGUICommandUser,
+ public WxGUITextEditorUser,
+ public WxGUIHtmlBrowserUser
{
public:
WxGUIScriptingInterface( wxWindow *parent, wxString title, wxSize size);
void OnMenuCreateIndex(wxCommandEvent& WXUNUSED(event));
- void OnButtonRun(wxCommandEvent& WXUNUSED(event));
+ // void OnButtonRun(wxCommandEvent& WXUNUSED(event));
// Interpreter callbacks
bool InterpreterUserHasOwnHtmlPageViewer() { return true; }
// WxGUICommand callbacks
void WxGUICommandEnter(const std::string&);
+ // WxGUITextEditor callbacks
+ void WxGUITextEditorRun();
+
+ // WxGUIHtmlBrowser callbacks
+ bool WxGUIHtmlBrowserUserOnLinkClicked(const std::string& target);
private:
wxAuiManager m_mgr;
Interpreter* mInterpreter;
//EED wxNotebook* mwxNotebook;
- wxAuiNotebook* mwxNotebook;
- wxPanel *mwxPageCommand, *mwxPageHelp;
+// wxAuiNotebook* mwxNotebook;
+// wxPanel *mwxPageCommand, *mwxPageHelp;
WxGUICommand* mWxGUICommand;
WxGUIOutputMessages* mWxGUIOutputMessages;
WxGUIHtmlBrowser* mWxGUIHtmlBrowser;
WxGUITextEditor* mWxGUITextEditor;
- wxButton* mwxButtonRun;
+ // wxButton* mwxButtonRun;
public:
Program: bbtk
Module: $RCSfile: bbtkWxGUITextEditor.cxx,v $
Language: C++
- Date: $Date: 2008/03/21 11:46:41 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/03/21 14:59:39 $
+ Version: $Revision: 1.2 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//================================================================
- //================================================================
- class WxGUITextEditorPage : public wxPanel
- {
- public:
- WxGUITextEditorPage(wxWindow* parent, WxGUITextEditor* editor);
- ~WxGUITextEditorPage();
-
- void SetPageName(const std::string& name) { mName = name; }
- const std::string& GetPageName() const { return mName; }
-
- bool AskFilename() const { return mAskFilename; }
-
- WxTextCtrlGettingKeyEvents* GetTextCtrl() { return mwxInputText; }
-
- void Load(const std::string& filename);
- void Save(const std::string& filter);
-
- bool IsModified() { return mwxInputText->IsModified(); }
-
- private:
- WxGUITextEditor* mEditor;
- WxTextCtrlGettingKeyEvents* mwxInputText;
- wxTextAttr* mwxInputTextAttr;
- std::string mName;
- bool mAskFilename;
-
- /*
- enum
- {
- ID_InputText
- };
- */
- //DECLARE_EVENT_TABLE();
-
- } ;
- //================================================================
//================================================================
/* BEGIN_EVENT_TABLE(WxGUITextEditorPage, wxPanel)
}
//================================================================
+ bool WxGUITextEditorPage::IsModified()
+ { return mwxInputText->IsModified(); }
+
+ std::string WxGUITextEditorPage::GetText()
+ {
+ return wx2std(GetTextCtrl()->GetValue());
+ }
//================================================================
void WxGUITextEditorPage::Load(const std::string& filename)
//================================================================
//================================================================
- WxGUITextEditor::WxGUITextEditor( wxWindow *parent )
+ WxGUITextEditor::WxGUITextEditor( wxWindow *parent,
+ WxGUITextEditorUser* user )
: wxPanel(parent, -1),
+ mUser(user),
mFileNameFilter("*.*")
{
std::cout << "WxGUITextEditor::WxGUITextEditor"<<std::endl;
mwxButtonSave = new wxBitmapButton( btnsCtrlPanel,ID_ButtonSave,bmp_save);//_T("Save") );
btnsSizer->Add( mwxButtonSave );
- /*
wxBitmap bmp_run(cc_run_xpm);
mwxButtonRun = new wxBitmapButton( btnsCtrlPanel,ID_ButtonRun,bmp_run);//_T("Run") );
btnsSizer->Add( mwxButtonRun );
+ /*
wxBitmap bmp_quit(cc_exit_xpm);
mwxButtonQuit = new wxBitmapButton( btnsCtrlPanel,ID_ButtonQuit,bmp_quit);//_T("Quit") );
btnsSizer->Add( mwxButtonQuit );
if (AskSave()) GetParent()->Close();
}
//================================================================
-
+ */
//================================================================
void WxGUITextEditor::OnButtonRun(wxCommandEvent& event)
{
- Run();
+ if (mUser!=0) mUser->WxGUITextEditorRun();
FocusOnCurrentPage();
}
+
+ /*
void WxGUITextEditor::Run()
{
std::cout << "-------------- RUN ---------------"<<std::endl;
EVT_BUTTON(WxGUITextEditor::ID_ButtonNew, WxGUITextEditor::OnButtonNew)
EVT_BUTTON(WxGUITextEditor::ID_ButtonOpen, WxGUITextEditor::OnButtonOpen)
EVT_BUTTON(WxGUITextEditor::ID_ButtonSave, WxGUITextEditor::OnButtonSave)
- // EVT_BUTTON(WxGUITextEditor::ID_ButtonRun, WxGUITextEditor::OnButtonRun)
+ EVT_BUTTON(WxGUITextEditor::ID_ButtonRun, WxGUITextEditor::OnButtonRun)
// EVT_BUTTON(WxGUITextEditor::ID_ButtonQuit, WxGUITextEditor::OnButtonQuit)
EVT_AUINOTEBOOK_PAGE_CLOSE(wxID_ANY, WxGUITextEditor::OnPageClose)
END_EVENT_TABLE()
Program: bbtk
Module: $RCSfile: bbtkWxGUITextEditor.h,v $
Language: C++
- Date: $Date: 2008/03/21 11:46:41 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/03/21 14:59:39 $
+ Version: $Revision: 1.2 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{
class WxTextCtrlGettingKeyEvents;
- class WxGUITextEditorPage;
+ class WxGUITextEditor;
+
+
+ /// Abstract class which defines the callbacks invoked by WxGUITextEditor
+ class BBTK_EXPORT WxGUITextEditorUser
+ {
+ public:
+ WxGUITextEditorUser() {}
+ ~WxGUITextEditorUser() {}
+ /// Callback invoked when the 'run' button is pressed
+ virtual void WxGUITextEditorRun() {}
+ };
+
+ //================================================================
+ class WxGUITextEditorPage : public wxPanel
+ {
+ public:
+ WxGUITextEditorPage(wxWindow* parent, WxGUITextEditor* editor);
+ ~WxGUITextEditorPage();
+
+ void SetPageName(const std::string& name) { mName = name; }
+ const std::string& GetPageName() const { return mName; }
+
+ bool AskFilename() const { return mAskFilename; }
+
+ WxTextCtrlGettingKeyEvents* GetTextCtrl() { return mwxInputText; }
+
+ void Load(const std::string& filename);
+ void Save(const std::string& filter);
- /// A bbs editor panel
+ bool IsModified(); //{ return mwxInputText->IsModified(); }
+
+ std::string GetText();
+
+ private:
+ WxGUITextEditor* mEditor;
+ WxTextCtrlGettingKeyEvents* mwxInputText;
+ wxTextAttr* mwxInputTextAttr;
+ std::string mName;
+ bool mAskFilename;
+
+ /*
+ enum
+ {
+ ID_InputText
+ };
+ */
+ //DECLARE_EVENT_TABLE();
+
+ } ;
+ //================================================================
+
+
+
+ /// A text editor panel
class BBTK_EXPORT WxGUITextEditor : public wxPanel
{
public:
- WxGUITextEditor( wxWindow *parent );
+ WxGUITextEditor( wxWindow *parent, WxGUITextEditorUser* user = 0 );
~WxGUITextEditor();
void OnKeyDown(wxKeyEvent& event);
void OnButtonNew(wxCommandEvent& event);
void OnButtonOpen(wxCommandEvent& event);
void OnButtonSave(wxCommandEvent& event);
- // void OnButtonRun(wxCommandEvent& event);
+ void OnButtonRun(wxCommandEvent& event);
// void OnButtonQuit(wxCommandEvent& event);
void OnPageClose(wxAuiNotebookEvent& evt);
void Open();
void Open(const std::string& filename);
void Save();
- // void Run();
+ // void Run();
// void Quit();
void HighlightSyntax();
{ mFileNameFilter = filter; }
private:
+ WxGUITextEditorUser* mUser;
+
wxAuiManager m_mgr;
wxAuiNotebook* mwxNotebook;
wxButton * mwxButtonNew;
wxButton * mwxButtonOpen;
wxButton * mwxButtonSave;
- // wxButton * mwxButtonRun;
+ wxButton * mwxButtonRun;
// wxButton * mwxButtonQuit;
wxStaticText* mwxPosition;
{
ID_ButtonNew,
ID_ButtonOpen,
- ID_ButtonSave
- // ID_ButtonRun,
+ ID_ButtonSave,
+ ID_ButtonRun
// ID_ButtonQuit
};