bombs.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: bombs.h
  3. // Purpose: Bombs game
  4. // Author: P. Foggia 1996
  5. // Modified by: Wlodzimierz Skiba (ABX) since 2003
  6. // Created: 1996
  7. // Copyright: (c) 1996 P. Foggia
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_DEMOS_BOMBS_BOMBS_H_
  11. #define _WX_DEMOS_BOMBS_BOMBS_H_
  12. #include "game.h"
  13. class BombsFrame;
  14. /*
  15. * Class representing the entire Application
  16. */
  17. class BombsApp: public wxApp
  18. {
  19. public:
  20. virtual bool OnInit();
  21. private :
  22. BombsFrame *m_frame;
  23. BombsGame m_game;
  24. };
  25. DECLARE_APP(BombsApp)
  26. class BombsCanvas;
  27. class BombsFrame : public wxFrame
  28. {
  29. public:
  30. BombsFrame(BombsGame *bombsGame);
  31. void NewGame(int level, bool query);
  32. private:
  33. void OnNewGame(wxCommandEvent& event);
  34. void OnEasyGame(wxCommandEvent& event);
  35. void OnMediumGame(wxCommandEvent& event);
  36. void OnHardGame(wxCommandEvent& event);
  37. void OnEasyCorner(wxCommandEvent& event);
  38. void OnExit(wxCommandEvent& event);
  39. void OnAbout(wxCommandEvent& event);
  40. BombsGame *m_game;
  41. bool m_easyCorner;
  42. int m_lastLevel;
  43. // Subwindows for reference within the program.
  44. BombsCanvas *m_canvas;
  45. DECLARE_EVENT_TABLE()
  46. };
  47. // App specific menu identifiers
  48. enum
  49. {
  50. bombsID_LEVEL = wxID_HIGHEST,
  51. bombsID_EASY,
  52. bombsID_MEDIUM,
  53. bombsID_HARD,
  54. bombsID_EASYCORNER
  55. };
  56. class BombsCanvas : public wxPanel
  57. {
  58. public:
  59. // Constructor and destructor
  60. BombsCanvas(wxFrame *parent, BombsGame *game);
  61. void UpdateGridSize();
  62. wxSize GetGridSizeInPixels() const;
  63. virtual ~BombsCanvas();
  64. private:
  65. void OnPaint(wxPaintEvent& event);
  66. void DrawField(wxDC *, int xc1, int yc1, int xc2, int yc2);
  67. void RefreshField(int xc1, int yc1, int xc2, int yc2);
  68. void Uncover(int x, int y);
  69. void OnMouseEvent(wxMouseEvent& event);
  70. void OnChar(wxKeyEvent& event);
  71. BombsGame *m_game;
  72. wxBitmap *m_bmp;
  73. // Cell size in pixels
  74. int m_cellWidth;
  75. int m_cellHeight;
  76. DECLARE_EVENT_TABLE()
  77. };
  78. /* The following sizes should probably be redefined */
  79. /* dimensions of a scroll unit, in pixels */
  80. #define X_UNIT 4
  81. #define Y_UNIT 4
  82. /* the dimensions of a cell, in scroll units are in
  83. * BombsCanvas::x_cell and y_cell
  84. */
  85. #ifdef __WXWINCE__
  86. #define BOMBS_FONT wxFont(12, wxSWISS, wxNORMAL, wxNORMAL)
  87. #else
  88. #define BOMBS_FONT wxFont(14, wxROMAN, wxNORMAL, wxNORMAL)
  89. #endif
  90. #endif // #ifndef _WX_DEMOS_BOMBS_BOMBS_H_