1998-12-31 05:54:41 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: bombs.h
|
|
|
|
// Purpose: Bombs game
|
|
|
|
// Author: P. Foggia 1996
|
2003-12-18 20:34:40 -05:00
|
|
|
// Modified by: Wlodzimierz Skiba (ABX) 2003
|
1998-12-31 05:54:41 -05:00
|
|
|
// Created: 1996
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// 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:
|
|
|
|
|
|
|
|
void OnNewEasyGame(wxCommandEvent& event);
|
|
|
|
void OnNewMediumGame(wxCommandEvent& event);
|
|
|
|
void OnNewHardGame(wxCommandEvent& event);
|
|
|
|
|
|
|
|
void OnExit(wxCommandEvent& event);
|
|
|
|
|
|
|
|
void OnAbout(wxCommandEvent& event);
|
|
|
|
|
|
|
|
BombsGame *m_game;
|
|
|
|
|
|
|
|
// 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
|
|
|
{
|
2003-12-18 20:34:40 -05:00
|
|
|
bombsID_NEWGAME = wxID_HIGHEST,
|
|
|
|
bombsID_EASY,
|
|
|
|
bombsID_MEDIUM,
|
|
|
|
bombsID_HARD
|
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;
|
|
|
|
|
|
|
|
~BombsCanvas();
|
|
|
|
|
|
|
|
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
|
|
|
|