1 #ifndef BYOGAMEBASE_H 2 #define BYOGAMEBASE_H 3 4 #include <wx/window.h> 5 #include <wx/string.h> 6 7 class wxDC; 8 class wxColour; 9 class wxFocusEvent; 10 class wxSizeEvent; 11 12 class byoGameBase: public wxWindow 13 { 14 public: 15 16 /** \brief Ctor */ 17 byoGameBase(wxWindow* parent,const wxString& GameName); 18 19 /** \brief Dctor */ 20 virtual ~byoGameBase(); 21 22 /** \brief Getting name of the game */ GetGameName()23 inline const wxString& GetGameName() const { return m_GameName; } 24 25 /** \brief Causing this class to reload all configuration stuff */ 26 static void ReloadFromConfig(); 27 28 /** \brief Time tick - this is used in Back-To-Work mode */ 29 static void BackToWorkTimer(); 30 31 protected: 32 33 /** \brief Function recalculating size hints used inside bricks drawing 34 * 35 * Settings provided here will be used whenever content of window is resized 36 * to recalculate valid values 37 */ 38 void RecalculateSizeHints(int minStepsHoriz,int minStepsVert); 39 40 /** \brief Getting abrolute position of given cell */ 41 void GetCellAbsolutePos(int cellX,int cellY,int& posX,int& posY) const; 42 43 /** \brief Function drawing brick in given absolute position */ 44 void DrawBrickAbsolute(wxDC* DC,int posX,int posY,int width,int height,const wxColour& base); 45 46 /** \brief Function drawing brick using grid ans size */ 47 void DrawBrick(wxDC* DC,int cellX,int cellY,const wxColour& base); 48 49 /** \brief Function drawing the columns guidelines */ 50 void DrawGuidelines(wxDC* DC, int offset, int columns, int rows, const wxColour& base); 51 52 /** \brief Getting one of standard colours used in game */ 53 const wxColour& GetColour(int index) const; 54 55 /** \brief Function changing paused state 56 * \return state really set 57 * \note when in "work-forcing-mode", pause state can not be set to false 58 */ 59 bool SetPause(bool pause=true); 60 61 /** \brief Getting paused state */ IsPaused()62 inline bool IsPaused() const { return m_Paused; } 63 64 /** \brief Getting string informing about Back-To-Work mode */ 65 wxString GetBackToWorkString() const; 66 67 private: 68 69 WX_DEFINE_ARRAY(byoGameBase*,GamesListT); 70 71 /** \brief Resize event, used to recalculate size hints */ 72 void OnSize(wxSizeEvent& event); 73 74 /** \brief Focus killing event, does automatically pause the game */ 75 void OnKillFocus(wxFocusEvent& event); 76 77 int m_CellSize; 78 int m_FirstCellXPos; 79 int m_FirstCellYPos; 80 int m_MinCellsHoriz; 81 int m_MinCellsVert; 82 bool m_Paused; 83 wxString m_GameName; 84 85 static GamesListT AllGames; 86 87 DECLARE_EVENT_TABLE() 88 }; 89 90 #endif 91