1 |
/* Eliot */ |
/* Eliot */ |
2 |
/* Copyright (C) 1999 Antoine Fraboulet */ |
/* Copyright (C) 1999 Antoine Fraboulet */ |
|
/* Antoine.Fraboulet@free.fr */ |
|
3 |
/* */ |
/* */ |
4 |
/* This program is free software; you can redistribute it and/or modify */ |
/* This file is part of Eliot. */ |
5 |
|
/* */ |
6 |
|
/* Eliot is free software; you can redistribute it and/or modify */ |
7 |
/* it under the terms of the GNU General Public License as published by */ |
/* it under the terms of the GNU General Public License as published by */ |
8 |
/* the Free Software Foundation; either version 2 of the License, or */ |
/* the Free Software Foundation; either version 2 of the License, or */ |
9 |
/* (at your option) any later version. */ |
/* (at your option) any later version. */ |
10 |
/* */ |
/* */ |
11 |
/* This program is distributed in the hope that it will be useful, */ |
/* Eliot is distributed in the hope that it will be useful, */ |
12 |
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
13 |
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ |
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ |
14 |
/* GNU General Public License for more details. */ |
/* GNU General Public License for more details. */ |
20 |
/* $Id$ */ |
/* $Id$ */ |
21 |
|
|
22 |
/** |
/** |
23 |
* \file gfxboard.h |
* \file gfxboard.h |
24 |
* \brief Game board graphical view |
* \brief Game board graphical view |
25 |
* \author Antoine Fraboulet |
* \author Antoine Fraboulet |
26 |
* \date 2002 |
* \date 2002 |
29 |
#ifndef _GFXBOARD_H |
#ifndef _GFXBOARD_H |
30 |
#define _GFXBOARD_H |
#define _GFXBOARD_H |
31 |
|
|
32 |
/* |
/** |
33 |
paintedboard_char is the matrix of played tiles |
* gfxboard is a wxWindow widget that draws a Scrabble board |
|
paintedboard_attr is the matrix of special attributes for tiles, for |
|
|
instance it can store if a tile is a test tile (placed but not played). |
|
34 |
*/ |
*/ |
35 |
|
|
|
typedef enum { |
|
|
BOARD_REFRESH, |
|
|
BOARD_FORCE_REFRESH |
|
|
} board_refresh_t; |
|
|
|
|
|
|
|
36 |
class GfxBoard : public wxWindow |
class GfxBoard : public wxWindow |
37 |
{ |
{ |
38 |
private: |
private: |
39 |
Game &m_game; |
/** |
40 |
int top,bottom,left,right; |
* reference on the played game |
41 |
char paintedboard_char[BOARD_DIM][BOARD_DIM]; |
*/ |
42 |
char paintedboard_attr[BOARD_DIM][BOARD_DIM]; |
Game &m_game; |
43 |
int board_size; |
|
44 |
int tile_size; |
/** |
45 |
wxPoint TopLeft; |
* paintedboard_char is the matrix of played tiles |
46 |
wxSize size; |
*/ |
47 |
wxBitmap *bmp; |
wxChar paintedboard_char[BOARD_DIM][BOARD_DIM]; |
48 |
void CreateBMP(); |
|
49 |
void DrawTile(wxDC*,wxString&,int,int); |
/** |
50 |
void DrawBoard(wxDC*); |
* paintedboard_attr is the matrix of special attributes for tiles, for |
51 |
|
* instance it can store if a tile is a test tile (placed but not played). |
52 |
ConfigDB config; |
*/ |
53 |
public: |
char paintedboard_attr[BOARD_DIM][BOARD_DIM]; |
54 |
GfxBoard(wxFrame*, Game&); |
|
55 |
~GfxBoard(void); |
/** |
56 |
|
* size in pixels for the board. |
57 |
void Refresh(board_refresh_t force = BOARD_REFRESH); |
* board_size = min(width,height) |
58 |
void OnPaint(wxPaintEvent& event); |
*/ |
59 |
void OnSize(wxSizeEvent& event); |
int board_size; |
60 |
DECLARE_EVENT_TABLE() |
|
61 |
|
/** |
62 |
|
* tile_size = size in pixels of a tile |
63 |
|
*/ |
64 |
|
int tile_size; |
65 |
|
|
66 |
|
/** |
67 |
|
* there is a bug when doing an OnSize under windows : the window |
68 |
|
* has to be fully refreshed (UpdateRegion does not seem to work). |
69 |
|
*/ |
70 |
|
#if defined(MSW_RESIZE_BUG) |
71 |
|
bool just_resized; |
72 |
|
#endif |
73 |
|
|
74 |
|
/** |
75 |
|
* top left point used to draw the lines, used to keep the board |
76 |
|
* centered horizontally and vertically |
77 |
|
*/ |
78 |
|
wxPoint TopLeft; |
79 |
|
|
80 |
|
/** |
81 |
|
* Board bitmap, created by CreateBMP |
82 |
|
*/ |
83 |
|
wxBitmap *bmp; |
84 |
|
|
85 |
|
void CreateBMP(); |
86 |
|
void DrawTileBack(wxDC*,int,int,int, bool testtile); |
87 |
|
void DrawTile(wxDC*,wxString&,int,int,bool testtile = false, bool drawtileback = false); |
88 |
|
void DrawBoard(wxDC*); |
89 |
|
void RefreshSquare(wxRect&); |
90 |
|
|
91 |
|
ConfigDB config; |
92 |
|
|
93 |
|
public: |
94 |
|
|
95 |
|
GfxBoard(wxFrame* parent, Game& game); |
96 |
|
~GfxBoard(void); |
97 |
|
|
98 |
|
void OnPaint (wxPaintEvent& event); |
99 |
|
void OnSize (wxSizeEvent& event); |
100 |
|
|
101 |
|
typedef enum { |
102 |
|
BOARD_REFRESH, |
103 |
|
BOARD_FORCE_REFRESH |
104 |
|
} board_refresh_t; |
105 |
|
|
106 |
|
void Refresh (board_refresh_t force = BOARD_REFRESH); |
107 |
|
|
108 |
|
DECLARE_EVENT_TABLE() |
109 |
}; |
}; |
110 |
|
|
111 |
#endif |
#endif |
112 |
|
|
113 |
|
|
114 |
|
/// Local Variables: |
115 |
|
/// mode: hs-minor |
116 |
|
/// c-basic-offset: 4 |
117 |
|
/// End: |