From: Markus R. <rol...@us...> - 2007-02-16 17:07:04
|
Update of /cvsroot/simspark/simspark/contrib/rsgedit In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv30646 Modified Files: Tag: WIN32 constants.h mainframe.cpp mainframe.h Log Message: - move GUI ID_ constansts to constants.h - add automatic reload button Index: constants.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/Attic/constants.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** constants.h 15 Feb 2007 21:08:00 -0000 1.1.2.1 --- constants.h 16 Feb 2007 17:06:00 -0000 1.1.2.2 *************** *** 27,29 **** --- 27,39 ---- }; + #define ID_SIM_START (wxID_HIGHEST+10) + #define ID_SIM_PAUSE (wxID_HIGHEST+11) + + #define ID_VIEW_LOG (wxID_HIGHEST+20) + #define ID_VIEW_TREE (wxID_HIGHEST+21) + #define ID_VIEW_TOOLBAR (wxID_HIGHEST+22) + + #define ID_FILE_OPEN (wxID_HIGHEST+23) + #define ID_FILE_RELOAD (wxID_HIGHEST+24) + #endif // RSGEDIT_CONSTANTS_H Index: mainframe.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.h,v retrieving revision 1.7.2.3 retrieving revision 1.7.2.4 diff -C2 -d -r1.7.2.3 -r1.7.2.4 *** mainframe.h 15 Feb 2007 21:07:59 -0000 1.7.2.3 --- mainframe.h 16 Feb 2007 17:06:41 -0000 1.7.2.4 *************** *** 45,57 **** // end wxGlade - #define ID_SIM_START (wxID_HIGHEST+10) - #define ID_SIM_PAUSE (wxID_HIGHEST+11) - - #define ID_VIEW_LOG (wxID_HIGHEST+20) - #define ID_VIEW_TREE (wxID_HIGHEST+21) - #define ID_VIEW_TOOLBAR (wxID_HIGHEST+22) - - #define ID_FILE_OPEN (wxID_HIGHEST+23) - class mainframe: public wxFrame { public: --- 45,48 ---- *************** *** 102,105 **** --- 93,99 ---- void OnUpdateFileOpen(wxUpdateUIEvent& event); + void OnFileReload(wxCommandEvent& event); + void OnUpdateFileReload(wxUpdateUIEvent& event); + void OnExit(wxCommandEvent& event); void OnClose( wxCloseEvent& event ); *************** *** 109,113 **** /** appends the accumulated log buffer to the log window pane */ void UpdateLogWindow(); ! /** returns true iff its safe to close this frame now */ bool CanClose(); --- 103,107 ---- /** appends the accumulated log buffer to the log window pane */ void UpdateLogWindow(); ! /** returns true iff its safe to close this frame now */ bool CanClose(); *************** *** 116,119 **** --- 110,121 ---- ESimState GetSimState() const; + /** update the title of the window */ + void mainframe::UpdateTitle(); + + /** resets the current simulation and starts a new one from the + given script file + */ + bool OpenSimulation(const wxString& fname); + void InitTreeNodeProperties(); *************** *** 156,159 **** --- 158,166 ---- int mLastVertSashPosition; + /** the filename of the current simulation (i.e. the corresponding + startup .rb script) + */ + wxString mSimFName; + DECLARE_EVENT_TABLE() }; // wxGlade: end class Index: mainframe.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.cpp,v retrieving revision 1.8.2.3 retrieving revision 1.8.2.4 diff -C2 -d -r1.8.2.3 -r1.8.2.4 *** mainframe.cpp 15 Feb 2007 21:07:59 -0000 1.8.2.3 --- mainframe.cpp 16 Feb 2007 17:06:40 -0000 1.8.2.4 *************** *** 29,32 **** --- 29,33 ---- #include <rsgedit/res/xpm_pause.xpm> #include <rsgedit/res/xpm_open.xpm> + #include <rsgedit/res/xpm_reload.xpm> //! wxWidgets and zeitgeist both use a 'DECLARE_CLASS' macro *************** *** 59,62 **** --- 60,66 ---- EVT_UPDATE_UI(ID_FILE_OPEN, mainframe::OnUpdateFileOpen) + EVT_MENU(ID_FILE_RELOAD, mainframe::OnFileReload) + EVT_UPDATE_UI(ID_FILE_RELOAD, mainframe::OnUpdateFileReload) + EVT_TIMER(1, mainframe::OnLogTimer) *************** *** 73,77 **** // the default height of the log window pane [pixel] ! static const int LOGWND_DEFAULT_HEIGHT = 80; // the update interval of the log window [milliseconds} --- 77,81 ---- // the default height of the log window pane [pixel] ! static const int LOGWND_DEFAULT_HEIGHT = 150; // the update interval of the log window [milliseconds} *************** *** 101,104 **** --- 105,109 ---- wxMenu* wxglade_tmp_menu_1 = new wxMenu(); wxglade_tmp_menu_1->Append(ID_FILE_OPEN, wxT("&Open"), wxT(""), wxITEM_NORMAL); + wxglade_tmp_menu_1->Append(ID_FILE_RELOAD, wxT("&Reload"), wxT(""), wxITEM_NORMAL); wxglade_tmp_menu_1->Append(wxID_EXIT, wxT("&Exit"), wxT(""), wxITEM_NORMAL); MainFrame_menubar->Append(wxglade_tmp_menu_1, wxT("&File")); *************** *** 125,128 **** --- 130,134 ---- mToolBar->AddTool(ID_FILE_OPEN, wxT("Open"), wxBitmap(xpm_open)); + mToolBar->AddTool(ID_FILE_RELOAD, wxT("Reload"), wxBitmap(xpm_reload)); mToolBar->AddSeparator(); mToolBar->AddTool(ID_SIM_START, wxT("Start"), wxBitmap(xpm_play)); *************** *** 149,152 **** --- 155,160 ---- // init log wnd timer mTimer.Start(LOGWND_UPDATE_INTERVAL); + + UpdateTitle(); } *************** *** 155,158 **** --- 163,177 ---- } + void mainframe::UpdateTitle() + { + wxString title = "SimSpark"; + if (! mSimFName.empty()) + { + title += " <" + mSimFName + ">"; + } + + SetTitle(title); + } + void mainframe::SplitHor() { *************** *** 545,562 **** } ! void mainframe::OnFileOpen(wxCommandEvent& event) { - wxString message = "Choose a ruby script to run"; - wxString default_path = "./rsg"; - wxString default_filename = ""; - wxString default_extension = ""; - wxString wildcard = "ruby scripts (*.rb)|*.rb"; - - wxString filename = wxFileSelector(message, default_path, default_filename, default_extension, wildcard); - if (filename.empty() ) - { - return; - } - ResetSimulation(); mSparkTree.Init(mCtrTree); --- 564,569 ---- } ! bool mainframe::OpenSimulation(const wxString& fname) { ResetSimulation(); mSparkTree.Init(mCtrTree); *************** *** 567,575 **** { assert(false); ! return; } ! spark->GetScriptServer()->Run(filename.c_str()); ! spark->GetLog()->Normal() << "(RsgEdit) reading " << filename << "\n"; shared_ptr<SimulationServer> sim = spark->GetSimulationServer(); --- 574,585 ---- { assert(false); ! return false; } ! spark->GetLog()->Normal() << "(RsgEdit) reading " << fname << "\n"; ! if (! spark->GetScriptServer()->Run(fname.c_str())) ! { ! return false; ! } shared_ptr<SimulationServer> sim = spark->GetSimulationServer(); *************** *** 577,581 **** { assert(false); ! return; } --- 587,591 ---- { assert(false); ! return false; } *************** *** 583,585 **** --- 593,629 ---- AdvanceSimulation(sim, 0.01f); DoneSimulation(sim); + + mSimFName = fname; + UpdateTitle(); + return true; + } + + void mainframe::OnFileOpen(wxCommandEvent& event) + { + wxString message = "Choose a ruby script to run"; + wxString default_path = "./rsg"; + wxString default_filename = ""; + wxString default_extension = ""; + wxString wildcard = "ruby scripts (*.rb)|*.rb"; + + wxString filename = wxFileSelector(message, default_path, default_filename, default_extension, wildcard); + if (filename.empty() ) + { + return; + } + + OpenSimulation(filename); + } + + void mainframe::OnUpdateFileReload(wxUpdateUIEvent& event) + { + event.Enable( + (GetSimState() == S_PAUSED) && + (! mSimFName.empty()) + ); + } + + void mainframe::OnFileReload(wxCommandEvent& event) + { + OpenSimulation(mSimFName); } |