/////////////////////////////////////////////////////////////////////////////
// Name: life.h
-// Purpose: The game of life, created by J. H. Conway
+// Purpose: The game of Life, created by J. H. Conway
// Author: Guillermo Rodriguez Garcia, <guille@iies.es>
// Modified by:
// Created: Jan/2000
#ifndef _LIFE_APP_H_
#define _LIFE_APP_H_
-#ifdef __GNUG__
- #pragma interface "life.h"
-#endif
-
// for compilers that support precompilation, includes "wx/wx.h"
#include "wx/wxprec.h"
#include "wx/wx.h"
#endif
+#include "wx/minifram.h"
+
#include "game.h"
+
// --------------------------------------------------------------------------
// LifeCanvas
// --------------------------------------------------------------------------
-/* Note that in LifeCanvas, all cell coordinates are
- * named i, j, while screen coordinates are named x, y.
- */
+// Note that in LifeCanvas, all cell coordinates are
+// named i, j, while screen coordinates are named x, y.
+
class LifeCanvas : public wxWindow
{
public:
// ctor and dtor
- LifeCanvas(wxWindow* parent, Life* life, bool interactive = TRUE);
- ~LifeCanvas();
+ LifeCanvas(wxWindow* parent, Life* life, bool interactive = true);
+ virtual ~LifeCanvas();
// view management
int GetCellSize() const { return m_cellsize; };
void DrawCell(wxInt32 i, wxInt32 j, bool alive);
private:
- // any class wishing to process wxWindows events must use this macro
+ // any class wishing to process wxWidgets events must use this macro
DECLARE_EVENT_TABLE()
// draw a cell (parametrized by DC)
wxInt32 m_viewportY; // first visible cell (y coord)
wxInt32 m_viewportW; // number of visible cells (w)
wxInt32 m_viewportH; // number of visible cells (h)
- int m_thumbX; // horiz. scrollbar thumb position
- int m_thumbY; // vert. scrollbar thumb position
- wxInt32 m_mi, m_mj; // last mouse position
+ int m_thumbX; // horiz. scrollbar thumb position
+ int m_thumbY; // vert. scrollbar thumb position
+ wxInt32 m_mi, m_mj; // last mouse position
};
+
// --------------------------------------------------------------------------
-// LifeTimer
+// LifeNavigator
// --------------------------------------------------------------------------
-// Life timer
-class LifeTimer : public wxTimer
+class LifeNavigator : public wxMiniFrame
{
public:
- void Notify();
+ // ctor
+ LifeNavigator(wxWindow *parent);
+
+private:
+ // any class wishing to process wxWidgets events must use this macro
+ DECLARE_EVENT_TABLE()
+
+ // event handlers
+ void OnClose(wxCloseEvent& event);
};
+
// --------------------------------------------------------------------------
// LifeFrame
// --------------------------------------------------------------------------
public:
// ctor and dtor
LifeFrame();
- ~LifeFrame();
+ virtual ~LifeFrame();
// member functions
void UpdateInfoText();
void UpdateUI();
- void OnTimer();
private:
- // any class wishing to process wxWindows events must use this macro
+ // any class wishing to process wxWidgets events must use this macro
DECLARE_EVENT_TABLE()
// event handlers
void OnMenu(wxCommandEvent& event);
+ void OnOpen(wxCommandEvent& event);
void OnSamples(wxCommandEvent& event);
+ void OnNavigate(wxCommandEvent& event);
+ void OnZoom(wxCommandEvent& event);
void OnSlider(wxScrollEvent& event);
+ void OnTimer(wxTimerEvent& event);
void OnClose(wxCloseEvent& event);
+
+ // event handler helpers
void OnStart();
void OnStop();
-
- Life *m_life;
- LifeTimer *m_timer;
- LifeCanvas *m_canvas;
- wxStaticText *m_text;
- bool m_running;
- bool m_topspeed;
- long m_interval;
- long m_tics;
+ void OnStep();
+
+ Life *m_life;
+ LifeCanvas *m_canvas;
+ LifeNavigator *m_navigator;
+ wxStaticText *m_text;
+ wxTimer *m_timer;
+ bool m_running;
+ bool m_topspeed;
+ long m_interval;
+ long m_tics;
};
+
// --------------------------------------------------------------------------
// LifeApp
// --------------------------------------------------------------------------