1 
2 #ifndef VISITOOL_HPP
3 #define VISITOOL_HPP
4 
5 /* "Species" - a CoreWars evolver.  Copyright (C) 2003 'Varfar'
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the Free
9  * Software Foundation; either version 1, or (at your option) any later
10  * version.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15  * more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21 
22  #include <wx/wx.h>
23 
24 #include "species.hpp"
25 
26 class SpeciesFrame; // forward
27 
28 class SimulationThread: public wxThread {
29 	public:
30 		SimulationThread(SpeciesFrame *owner);
31 		virtual ~SimulationThread();
Stop()32 		void Stop() { _stopping = true; /* kingdom.stop(); */ }
is_stopping() const33 		bool is_stopping() const { return _stopping; }
is_running() const34 		bool is_running() const { return !_stopped; }
35 		virtual ExitCode Entry();
kingdom() const36 		CKingdom *kingdom() const { return _kingdom; }
37 	private:
38 		SpeciesFrame *_owner;
39 		bool _stopping, _stopped;
40 		CKingdom *_kingdom;
41 };
42 
43 class SpeciesFrame: public wxFrame {
44 	public:
45 		SpeciesFrame(const wxString &title,const wxPoint &pos,const wxSize &size);
46 		// event handlers
47 		enum {
48 			ID_Quit = 1,
49 			ID_About,
50 			ID_Run_Simulation,
51 			ID_Stop_Simulation
52 		};
53 		void OnMnuFileQuit(wxCommandEvent &event);
54 		void OnMnuFileAbout(wxCommandEvent &event);
55 		void OnPaint(wxPaintEvent &event);
56 		void OnSize(wxSizeEvent &event);
57 		void OnRunSimulation();
58 		void OnStopSimulation();
59 		void OnSimulationStopped();
DECLARE_EVENT_TABLE()60 		DECLARE_EVENT_TABLE()
61 		// accessors
62 		CKingdom *kingdom() const { return _simthread->kingdom(); }
63 	private:
64 		class CircleTag: public CHook {
65 			public:
66 				CircleTag(const wxString &label,const int nitems,const int index,const wxRect &bounds);
~CircleTag()67 				virtual ~CircleTag() {}
68 				void draw(wxDC &dc);
bounds() const69 				const wxRect &bounds() const { return _bounds; }
70 			private:
71 				typedef double Precision;
72 				int _x, _y;
73 				wxCoord _radius;
74 				wxRect _bounds;
75 				wxString _label;
76 		};
77 		wxStaticText *_kingdom_label;
78 		wxButton *_run_simulation,
79 			*_stop_simulation;
80 		wxPanel *_run_stop_panel;
81 		SimulationThread *_simthread;
82 		// main diagram draw function
83 		void draw(wxDC &dc);
84 		void calcLayout();
85 };
86 
87 class VisiToolApp: public wxApp {
88 	public:
89 		virtual bool OnInit();
90 };
91 
92 #endif // ifndef VISITOOL_HPP
93 
94 
95