]>
git.saurik.com Git - wxWidgets.git/blob - demos/life/life.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: The game of life, created by J. H. Conway
4 // Author: Guillermo Rodriguez Garcia, <guille@iies.es>
8 // Copyright: (c) 2000, Guillermo Rodriguez Garcia
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "life.h"
19 // for compilers that support precompilation, includes "wx/wx.h"
20 #include "wx/wxprec.h"
26 // for all others, include the necessary headers
33 // --------------------------------------------------------------------------
35 // --------------------------------------------------------------------------
37 class LifeCanvas
: public wxScrolledWindow
41 LifeCanvas(wxWindow
* parent
, Life
* life
, bool interactive
= TRUE
);
46 void DrawEverything(bool force
= FALSE
);
47 void DrawCell(Cell c
);
48 void DrawCell(Cell c
, wxDC
&dc
);
49 inline int CellToCoord(int i
) const { return (i
* m_cellsize
); };
50 inline int CoordToCell(int x
) const { return ((x
>= 0)? (x
/ m_cellsize
) : -1); };
53 void OnPaint(wxPaintEvent
& event
);
54 void OnMouse(wxMouseEvent
& event
);
55 void OnSize(wxSizeEvent
& event
);
58 // any class wishing to process wxWindows events must use this macro
79 // --------------------------------------------------------------------------
81 // --------------------------------------------------------------------------
84 class LifeTimer
: public wxTimer
90 // --------------------------------------------------------------------------
92 // --------------------------------------------------------------------------
94 class LifeFrame
: public wxFrame
102 void UpdateInfoText();
105 void OnMenu(wxCommandEvent
& event
);
106 void OnNewGame(wxCommandEvent
& event
);
107 void OnSamples(wxCommandEvent
& event
);
111 void OnSlider(wxScrollEvent
& event
);
114 // any class wishing to process wxWindows events must use this macro
115 DECLARE_EVENT_TABLE()
119 LifeCanvas
*m_canvas
;
120 wxStaticText
*m_text
;
126 // --------------------------------------------------------------------------
128 // --------------------------------------------------------------------------
130 class LifeApp
: public wxApp
133 virtual bool OnInit();
136 #endif // _LIFE_APP_H_