1998-12-31 05:54:41 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: bombs.h
|
|
|
|
// Purpose: Bombs game
|
|
|
|
// Author: P. Foggia 1996
|
2005-05-10 15:22:06 -04:00
|
|
|
// Modified by: Wlodzimierz Skiba (ABX) since 2003
|
1998-12-31 05:54:41 -05:00
|
|
|
// Created: 1996
|
|
|
|
// Copyright: (c) 1996 P. Foggia
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2003-12-18 20:34:40 -05:00
|
|
|
#ifndef _WX_DEMOS_BOMBS_BOMBS_H_
|
|
|
|
#define _WX_DEMOS_BOMBS_BOMBS_H_
|
1998-12-31 05:54:41 -05:00
|
|
|
|
|
|
|
#include "game.h"
|
|
|
|
|
2003-12-18 20:34:40 -05:00
|
|
|
class BombsFrame;
|
1998-12-31 05:54:41 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Class representing the entire Application
|
|
|
|
*/
|
2003-12-18 20:34:40 -05:00
|
|
|
class BombsApp: public wxApp
|
1998-12-31 05:54:41 -05:00
|
|
|
{
|
2003-12-18 20:34:40 -05:00
|
|
|
public:
|
|
|
|
virtual bool OnInit();
|
|
|
|
|
|
|
|
private :
|
|
|
|
BombsFrame *m_frame;
|
|
|
|
|
|
|
|
BombsGame m_game;
|
1998-12-31 05:54:41 -05:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2003-12-18 20:34:40 -05:00
|
|
|
DECLARE_APP(BombsApp)
|
1998-12-31 05:54:41 -05:00
|
|
|
|
2003-12-18 20:34:40 -05:00
|
|
|
class BombsCanvas;
|
1998-12-31 05:54:41 -05:00
|
|
|
|
2003-12-18 20:34:40 -05:00
|
|
|
class BombsFrame : public wxFrame
|
1998-12-31 05:54:41 -05:00
|
|
|
{
|
2003-12-18 20:34:40 -05:00
|
|
|
public:
|
|
|
|
|
|
|
|
BombsFrame(BombsGame *bombsGame);
|
|
|
|
|
2003-12-23 05:45:28 -05:00
|
|
|
void NewGame(int level, bool query);
|
2003-12-18 20:34:40 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2005-05-10 15:22:06 -04:00
|
|
|
void OnNewGame(wxCommandEvent& event);
|
|
|
|
void OnEasyGame(wxCommandEvent& event);
|
|
|
|
void OnMediumGame(wxCommandEvent& event);
|
|
|
|
void OnHardGame(wxCommandEvent& event);
|
2003-12-18 20:34:40 -05:00
|
|
|
|
2005-05-06 14:07:14 -04:00
|
|
|
void OnEasyCorner(wxCommandEvent& event);
|
|
|
|
|
2003-12-18 20:34:40 -05:00
|
|
|
void OnExit(wxCommandEvent& event);
|
|
|
|
|
|
|
|
void OnAbout(wxCommandEvent& event);
|
|
|
|
|
|
|
|
BombsGame *m_game;
|
2005-05-06 14:07:14 -04:00
|
|
|
bool m_easyCorner;
|
|
|
|
int m_lastLevel;
|
2003-12-18 20:34:40 -05:00
|
|
|
|
|
|
|
// Subwindows for reference within the program.
|
|
|
|
BombsCanvas *m_canvas;
|
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
1998-12-31 05:54:41 -05:00
|
|
|
};
|
|
|
|
|
2003-12-18 20:34:40 -05:00
|
|
|
// App specific menu identifiers
|
|
|
|
enum
|
1998-12-31 05:54:41 -05:00
|
|
|
{
|
2005-05-10 15:22:06 -04:00
|
|
|
bombsID_LEVEL = wxID_HIGHEST,
|
2003-12-18 20:34:40 -05:00
|
|
|
bombsID_EASY,
|
|
|
|
bombsID_MEDIUM,
|
2005-05-06 14:07:14 -04:00
|
|
|
bombsID_HARD,
|
|
|
|
bombsID_EASYCORNER
|
1998-12-31 05:54:41 -05:00
|
|
|
};
|
|
|
|
|
2003-12-18 20:34:40 -05:00
|
|
|
class BombsCanvas : public wxPanel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Constructor and destructor
|
|
|
|
|
|
|
|
BombsCanvas(wxFrame *parent, BombsGame *game);
|
|
|
|
|
|
|
|
void UpdateGridSize();
|
|
|
|
|
|
|
|
wxSize GetGridSizeInPixels() const;
|
|
|
|
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~BombsCanvas();
|
2003-12-18 20:34:40 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void OnPaint(wxPaintEvent& event);
|
|
|
|
void DrawField(wxDC *, int xc1, int yc1, int xc2, int yc2);
|
|
|
|
void RefreshField(int xc1, int yc1, int xc2, int yc2);
|
|
|
|
void Uncover(int x, int y);
|
|
|
|
void OnMouseEvent(wxMouseEvent& event);
|
|
|
|
void OnChar(wxKeyEvent& event);
|
|
|
|
|
|
|
|
BombsGame *m_game;
|
|
|
|
|
|
|
|
wxBitmap *m_bmp;
|
|
|
|
|
|
|
|
// Cell size in pixels
|
|
|
|
int m_cellWidth;
|
|
|
|
int m_cellHeight;
|
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
1998-12-31 05:54:41 -05:00
|
|
|
|
|
|
|
/* The following sizes should probably be redefined */
|
|
|
|
/* dimensions of a scroll unit, in pixels */
|
|
|
|
#define X_UNIT 4
|
|
|
|
#define Y_UNIT 4
|
|
|
|
|
|
|
|
/* the dimensions of a cell, in scroll units are in
|
2003-12-18 20:34:40 -05:00
|
|
|
* BombsCanvas::x_cell and y_cell
|
1998-12-31 05:54:41 -05:00
|
|
|
*/
|
|
|
|
|
2003-12-18 20:34:40 -05:00
|
|
|
#ifdef __WXWINCE__
|
|
|
|
#define BOMBS_FONT wxFont(12, wxSWISS, wxNORMAL, wxNORMAL)
|
|
|
|
#else
|
1998-12-31 05:54:41 -05:00
|
|
|
#define BOMBS_FONT wxFont(14, wxROMAN, wxNORMAL, wxNORMAL)
|
2003-12-18 20:34:40 -05:00
|
|
|
#endif
|
1998-12-31 05:54:41 -05:00
|
|
|
|
2003-12-18 20:34:40 -05:00
|
|
|
#endif // #ifndef _WX_DEMOS_BOMBS_BOMBS_H_
|
1998-12-31 05:54:41 -05:00
|
|
|
|