gfxboard.h

Go to the documentation of this file.
00001 /* Eliot                                                                     */
00002 /* Copyright (C) 1999  Antoine Fraboulet                                     */
00003 /*                                                                           */
00004 /* This file is part of Eliot.                                               */
00005 /*                                                                           */
00006 /* Eliot is free software; you can redistribute it and/or modify             */
00007 /* it under the terms of the GNU General Public License as published by      */
00008 /* the Free Software Foundation; either version 2 of the License, or         */
00009 /* (at your option) any later version.                                       */
00010 /*                                                                           */
00011 /* Eliot is distributed in the hope that it will be useful,                  */
00012 /* but WITHOUT ANY WARRANTY; without even the implied warranty of            */
00013 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             */
00014 /* GNU General Public License for more details.                              */
00015 /*                                                                           */
00016 /* You should have received a copy of the GNU General Public License         */
00017 /* along with this program; if not, write to the Free Software               */
00018 /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00019 
00020 /**
00021  *  \file   gfxboard.h
00022  *  \brief  Game board graphical view
00023  *  \author Antoine Fraboulet
00024  *  \date   2002
00025  */
00026 
00027 #ifndef _GFXBOARD_H
00028 #define _GFXBOARD_H
00029 
00030 /**
00031  * gfxboard is a wxWindow widget that draws a Scrabble board
00032  */
00033 
00034 class GfxBoard : public wxWindow
00035 {
00036  private:
00037     /**
00038      * reference on the played game
00039      */
00040     Game &m_game;
00041 
00042     /**
00043      *  paintedboard_char is the matrix of played tiles
00044      */
00045     wxChar paintedboard_char[BOARD_DIM][BOARD_DIM];
00046 
00047     /**
00048      * paintedboard_attr is the matrix of special attributes for tiles, for
00049      * instance it can store if a tile is a test tile (placed but not played).
00050      */
00051     char   paintedboard_attr[BOARD_DIM][BOARD_DIM];
00052 
00053     /**
00054      * size in pixels for the board.
00055      * board_size = min(width,height)
00056      */
00057     int board_size;
00058 
00059     /**
00060      * tile_size = size in pixels of a tile
00061      */
00062     int tile_size;
00063 
00064     /**
00065      * there is a bug when doing an OnSize under windows : the window
00066      * has to be fully refreshed (UpdateRegion does not seem to work).
00067      */
00068 #if defined(MSW_RESIZE_BUG)
00069     bool just_resized;
00070 #endif
00071 
00072     /**
00073      * top left point used to draw the lines, used to keep the board
00074      * centered horizontally and vertically
00075      */
00076     wxPoint  TopLeft;
00077 
00078     /**
00079      * Board bitmap, created by CreateBMP
00080      */
00081     wxBitmap *bmp;
00082 
00083     void CreateBMP();
00084     void DrawTileBack(wxDC*,int,int,int, bool testtile);
00085     void DrawTile(wxDC*,wxString&,int,int,bool testtile = false, bool drawtileback = false);
00086     void DrawBoard(wxDC*);
00087     void RefreshSquare(wxRect&);
00088 
00089     ConfigDB config;
00090 
00091  public:
00092 
00093     GfxBoard(wxFrame* parent, Game& game);
00094     ~GfxBoard(void);
00095 
00096     void OnPaint (wxPaintEvent& event);
00097     void OnSize  (wxSizeEvent&  event);
00098 
00099     typedef enum {
00100         BOARD_REFRESH,
00101         BOARD_FORCE_REFRESH
00102     } board_refresh_t;
00103 
00104     void Refresh (board_refresh_t force = BOARD_REFRESH);
00105 
00106     DECLARE_EVENT_TABLE()
00107 };
00108 
00109 #endif
00110 
00111 
00112 /// Local Variables:
00113 /// mode: hs-minor
00114 /// c-basic-offset: 4
00115 /// End:

Generated on Thu Dec 29 02:01:15 2005 for Eliot by  doxygen 1.4.5