Skip to content

Commit

Permalink
Moved more common stuff in TobyFrame.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Feb 19, 2007
1 parent e12630c commit 39fd239
Showing 1 changed file with 36 additions and 30 deletions.
66 changes: 36 additions & 30 deletions src/toby_wxwidgets.cpp
Expand Up @@ -139,8 +139,8 @@ class TobyFrame : public wxFrame
static const wxPoint getPreviousPos();
static const wxSize getPreviousSize();
void openFile(const wxString &path);
void startRun() { this->startRunImpl(); this->turtleSpace->startRun(); }
void stopRun() { this->stopRunImpl(); this->turtleSpace->stopRun(); }
void startRun();
void stopRun();
virtual void openFileImpl(const wxString &fname, char *buf) = 0;
virtual void startRunImpl() = 0;
virtual void stopRunImpl() = 0;
Expand Down Expand Up @@ -201,8 +201,8 @@ class TobyStandaloneFrame : public TobyFrame
TobyStandaloneFrame();
void onMenuQuit(wxCommandEvent &evt);
virtual void openFileImpl(const wxString &fname, char *prog);
virtual void startRunImpl();
virtual void stopRunImpl();
virtual void startRunImpl() { /* no-op in this implementation. */ }
virtual void stopRunImpl() { /* no-op in this implementation. */ }

private:
DECLARE_EVENT_TABLE()
Expand Down Expand Up @@ -843,6 +843,38 @@ const wxSize TobyFrame::getPreviousSize()
} // TobyFrame::getPreviousSize


void TobyFrame::startRun()
{
wxMenuBar *mb = this->menuBar;
mb->FindItem(MENUCMD_RunOrStop)->SetText(wxT("&Stop Program\tF5"));
mb->FindItem(MENUCMD_RunOrStop)->Enable(true);
mb->FindItem(MENUCMD_RunForPrinting)->Enable(false);
mb->FindItem(MENUCMD_SaveAsImage)->Enable(false);
mb->FindItem(MENUCMD_Print)->Enable(false);
mb->FindItem(MENUCMD_PrintPreview)->Enable(false);
mb->FindItem(MENUCMD_Cleanup)->Enable(false);

this->startRunImpl();
this->turtleSpace->startRun();
} // TobyFrame::startRun


void TobyFrame::stopRun()
{
wxMenuBar *mb = this->menuBar;
mb->FindItem(MENUCMD_RunOrStop)->SetText(wxT("&Run Program\tF5"));
mb->FindItem(MENUCMD_RunOrStop)->Enable(true);
mb->FindItem(MENUCMD_RunForPrinting)->Enable(true);
mb->FindItem(MENUCMD_SaveAsImage)->Enable(true);
mb->FindItem(MENUCMD_Print)->Enable(true);
mb->FindItem(MENUCMD_PrintPreview)->Enable(true);
mb->FindItem(MENUCMD_Cleanup)->Enable(true);

this->stopRunImpl();
this->turtleSpace->stopRun();
} // TobyFrame::stopRun


void TobyFrame::openFile(const wxString &path)
{
wxFileInputStream strm(path);
Expand Down Expand Up @@ -1137,32 +1169,6 @@ void TobyStandaloneFrame::openFileImpl(const wxString &fname, char *prog)
this->turtleSpace->runProgram(this->program, false);
} // TobyStandaloneFrame::openFileImpl


void TobyStandaloneFrame::startRunImpl()
{
wxMenuBar *mb = this->GetMenuBar();
mb->FindItem(MENUCMD_RunOrStop)->SetText(wxT("&Stop Program\tF5"));
mb->FindItem(MENUCMD_RunOrStop)->Enable(true);
mb->FindItem(MENUCMD_RunForPrinting)->Enable(false);
mb->FindItem(MENUCMD_SaveAsImage)->Enable(false);
mb->FindItem(MENUCMD_Print)->Enable(false);
mb->FindItem(MENUCMD_PrintPreview)->Enable(false);
mb->FindItem(MENUCMD_Cleanup)->Enable(false);
} // TobyStandaloneFrame::startRunImpl


void TobyStandaloneFrame::stopRunImpl()
{
wxMenuBar *mb = this->GetMenuBar();
mb->FindItem(MENUCMD_RunOrStop)->SetText(wxT("&Run Program\tF5"));
mb->FindItem(MENUCMD_RunOrStop)->Enable(true);
mb->FindItem(MENUCMD_RunForPrinting)->Enable(true);
mb->FindItem(MENUCMD_SaveAsImage)->Enable(true);
mb->FindItem(MENUCMD_Print)->Enable(true);
mb->FindItem(MENUCMD_PrintPreview)->Enable(true);
mb->FindItem(MENUCMD_Cleanup)->Enable(true);
} // TobyStandaloneFrame::stopRunImpl

#endif // TOBY_WX_BUILD_STANDALONE


Expand Down

0 comments on commit 39fd239

Please sign in to comment.