X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e0a4029251c1d80d50f9cb0bd152d1fca7914bc4..6a54cc2a1156229f1db27ec816c9be84e8da2ee3:/demos/life/life.h diff --git a/demos/life/life.h b/demos/life/life.h index 4f87eee981..75cd4d23a1 100644 --- a/demos/life/life.h +++ b/demos/life/life.h @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // 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, // Modified by: // Created: Jan/2000 @@ -28,15 +28,18 @@ #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: @@ -91,19 +94,29 @@ private: 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 }; + // -------------------------------------------------------------------------- -// 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 wxWindows events must use this macro + DECLARE_EVENT_TABLE() + + // event handlers + void OnClose(wxCloseEvent& event); }; + // -------------------------------------------------------------------------- // LifeFrame // -------------------------------------------------------------------------- @@ -118,7 +131,6 @@ public: // member functions void UpdateInfoText(); void UpdateUI(); - void OnTimer(); private: // any class wishing to process wxWindows events must use this macro @@ -126,22 +138,31 @@ private: // 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 // --------------------------------------------------------------------------