#ifndef VISITOOL_HPP #define VISITOOL_HPP /* "Species" - a CoreWars evolver. Copyright (C) 2003 'Varfar' * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 1, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "species.hpp" class SpeciesFrame; // forward class SimulationThread: public wxThread { public: SimulationThread(SpeciesFrame *owner); virtual ~SimulationThread(); void Stop() { _stopping = true; /* kingdom.stop(); */ } bool is_stopping() const { return _stopping; } bool is_running() const { return !_stopped; } virtual ExitCode Entry(); CKingdom *kingdom() const { return _kingdom; } private: SpeciesFrame *_owner; bool _stopping, _stopped; CKingdom *_kingdom; }; class SpeciesFrame: public wxFrame { public: SpeciesFrame(const wxString &title,const wxPoint &pos,const wxSize &size); // event handlers enum { ID_Quit = 1, ID_About, ID_Run_Simulation, ID_Stop_Simulation }; void OnMnuFileQuit(wxCommandEvent &event); void OnMnuFileAbout(wxCommandEvent &event); void OnPaint(wxPaintEvent &event); void OnSize(wxSizeEvent &event); void OnRunSimulation(); void OnStopSimulation(); void OnSimulationStopped(); DECLARE_EVENT_TABLE() // accessors CKingdom *kingdom() const { return _simthread->kingdom(); } private: class CircleTag: public CHook { public: CircleTag(const wxString &label,const int nitems,const int index,const wxRect &bounds); virtual ~CircleTag() {} void draw(wxDC &dc); const wxRect &bounds() const { return _bounds; } private: typedef double Precision; int _x, _y; wxCoord _radius; wxRect _bounds; wxString _label; }; wxStaticText *_kingdom_label; wxButton *_run_simulation, *_stop_simulation; wxPanel *_run_stop_panel; SimulationThread *_simthread; // main diagram draw function void draw(wxDC &dc); void calcLayout(); }; class VisiToolApp: public wxApp { public: virtual bool OnInit(); }; #endif // ifndef VISITOOL_HPP