mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-01-18 10:26:15 +01:00
- new gfxboard class drawing with tiles
This commit is contained in:
parent
094a920a4a
commit
1b4cdf5acf
5 changed files with 504 additions and 293 deletions
|
@ -122,9 +122,9 @@ void
|
||||||
BoardFrame::Refresh(refresh_t force)
|
BoardFrame::Refresh(refresh_t force)
|
||||||
{
|
{
|
||||||
if (force == REFRESH)
|
if (force == REFRESH)
|
||||||
board->Refresh(BOARD_REFRESH);
|
board->Refresh(GfxBoard::BOARD_REFRESH);
|
||||||
else
|
else
|
||||||
board->Refresh(BOARD_FORCE_REFRESH);
|
board->Refresh(GfxBoard::BOARD_FORCE_REFRESH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************/
|
/****************************************************************/
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
/* Eliot */
|
/* Eliot */
|
||||||
/* Copyright (C) 1999 Antoine Fraboulet */
|
/* Copyright (C) 1999 Antoine Fraboulet */
|
||||||
/* Antoine.Fraboulet@free.fr */
|
|
||||||
/* */
|
/* */
|
||||||
/* This program is free software; you can redistribute it and/or modify */
|
/* This file is part of Eliot. */
|
||||||
|
/* */
|
||||||
|
/* Eliot is free software; you can redistribute it and/or modify */
|
||||||
/* 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 */
|
||||||
/* the Free Software Foundation; either version 2 of the License, or */
|
/* the Free Software Foundation; either version 2 of the License, or */
|
||||||
/* (at your option) any later version. */
|
/* (at your option) any later version. */
|
||||||
/* */
|
/* */
|
||||||
/* This program is distributed in the hope that it will be useful, */
|
/* Eliot is distributed in the hope that it will be useful, */
|
||||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
/* GNU General Public License for more details. */
|
/* GNU General Public License for more details. */
|
||||||
|
@ -16,6 +17,13 @@
|
||||||
/* along with this program; if not, write to the Free Software */
|
/* along with this program; if not, write to the Free Software */
|
||||||
/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file configdb.cc
|
||||||
|
* \brief Access to Eliot persistant configuration data
|
||||||
|
* \author Antoine Fraboulet
|
||||||
|
* \date 2002
|
||||||
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "ewx.h"
|
#include "ewx.h"
|
||||||
#include "configdb.h"
|
#include "configdb.h"
|
||||||
|
@ -456,7 +464,12 @@ wxFont ConfigDB::ChooseFont(wxFrame* frame,wxFont initfont)
|
||||||
void ConfigDB::setFontDefault()
|
void ConfigDB::setFontDefault()
|
||||||
{
|
{
|
||||||
wxFont fsys;
|
wxFont fsys;
|
||||||
|
|
||||||
|
#ifdef WXWIN24
|
||||||
fsys = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
|
fsys = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
|
||||||
|
#else
|
||||||
|
fsys = wxSystemSettingsNative::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||||
|
#endif
|
||||||
|
|
||||||
setFont(BOARDFONT ,fsys);
|
setFont(BOARDFONT ,fsys);
|
||||||
setFont(LISTFONT ,fsys);
|
setFont(LISTFONT ,fsys);
|
||||||
|
@ -502,6 +515,10 @@ wxColour ConfigDB::ChooseColour(wxFrame* frame,wxColour initcolour)
|
||||||
#define BACKDEF wxColour(255,255,255)
|
#define BACKDEF wxColour(255,255,255)
|
||||||
#define LETTDEF wxColour( 0, 0, 0)
|
#define LETTDEF wxColour( 0, 0, 0)
|
||||||
#define TSTLETTDEF wxColour( 0, 0, 0)
|
#define TSTLETTDEF wxColour( 0, 0, 0)
|
||||||
|
#define TILEDEF wxColour(0xff,0xeb,0xcd)
|
||||||
|
//#define TSTTILEDEF wxColour(0xff,0xe4,0xb5)
|
||||||
|
//#define TSTTILEDEF wxColour(0x46,0x82,0xb4)
|
||||||
|
#define TSTTILEDEF wxColour(0xbd,0xb7,0x7b)
|
||||||
|
|
||||||
void ConfigDB::setColourDefault()
|
void ConfigDB::setColourDefault()
|
||||||
{
|
{
|
||||||
|
@ -512,6 +529,8 @@ void ConfigDB::setColourDefault()
|
||||||
setColour(wxString(BCOLOURLX3),LX3DEF);
|
setColour(wxString(BCOLOURLX3),LX3DEF);
|
||||||
setColour(wxString(BCOLOURBACKGROUND),BACKDEF);
|
setColour(wxString(BCOLOURBACKGROUND),BACKDEF);
|
||||||
setColour(wxString(BCOLOURLETTERS),LETTDEF);
|
setColour(wxString(BCOLOURLETTERS),LETTDEF);
|
||||||
|
setColour(wxString(BTILEBACKGROUND),TILEDEF);
|
||||||
|
setColour(wxString(BTSTTILEBACKGROUND),TSTTILEDEF);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -767,6 +786,20 @@ bool ConfigDB::getRackChecking()
|
||||||
return Read(key,(bool)FALSE);
|
return Read(key,(bool)FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConfigDB::setDrawTile(bool val)
|
||||||
|
{
|
||||||
|
wxString key;
|
||||||
|
key = wxString(BDRAWBACKGROUND);
|
||||||
|
Write(key,val);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ConfigDB::getDrawTile()
|
||||||
|
{
|
||||||
|
wxString key;
|
||||||
|
key = wxString(BDRAWBACKGROUND);
|
||||||
|
return Read(key,(bool)TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -787,4 +820,3 @@ ConfigDB::setFirstDefault()
|
||||||
|
|
||||||
Write(wxString(INIT),1L);
|
Write(wxString(INIT),1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
/* Eliot */
|
/* Eliot */
|
||||||
/* Copyright (C) 1999 Antoine Fraboulet */
|
/* Copyright (C) 1999 Antoine Fraboulet */
|
||||||
/* Antoine.Fraboulet@free.fr */
|
|
||||||
/* */
|
/* */
|
||||||
/* This program is free software; you can redistribute it and/or modify */
|
/* This file is part of Eliot. */
|
||||||
|
/* */
|
||||||
|
/* Eliot is free software; you can redistribute it and/or modify */
|
||||||
/* 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 */
|
||||||
/* the Free Software Foundation; either version 2 of the License, or */
|
/* the Free Software Foundation; either version 2 of the License, or */
|
||||||
/* (at your option) any later version. */
|
/* (at your option) any later version. */
|
||||||
/* */
|
/* */
|
||||||
/* This program is distributed in the hope that it will be useful, */
|
/* Eliot is distributed in the hope that it will be useful, */
|
||||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
/* GNU General Public License for more details. */
|
/* GNU General Public License for more details. */
|
||||||
|
@ -16,7 +17,12 @@
|
||||||
/* along with this program; if not, write to the Free Software */
|
/* along with this program; if not, write to the Free Software */
|
||||||
/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||||
|
|
||||||
// -*-C++-*-
|
/**
|
||||||
|
* \file configdb.h
|
||||||
|
* \brief Access to Eliot persistant configuration data
|
||||||
|
* \author Antoine Fraboulet
|
||||||
|
* \date 2002
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _CONFIGDB_H
|
#ifndef _CONFIGDB_H
|
||||||
#define _CONFIGDB_H
|
#define _CONFIGDB_H
|
||||||
|
@ -30,19 +36,23 @@
|
||||||
|
|
||||||
#define BUTTON_FONT wxFont(8,wxDEFAULT,wxNORMAL,wxNORMAL)
|
#define BUTTON_FONT wxFont(8,wxDEFAULT,wxNORMAL,wxNORMAL)
|
||||||
|
|
||||||
#define BOARD "Board"
|
#define BOARD "Board"
|
||||||
#define BCOLOURLINES wxT(BOARD"/Lines")
|
#define BCOLOURLINES wxT(BOARD"/Lines")
|
||||||
#define BCOLOURWX2 wxT(BOARD"/Wx2")
|
#define BCOLOURWX2 wxT(BOARD"/Wx2")
|
||||||
#define BCOLOURWX3 wxT(BOARD"/Wx3")
|
#define BCOLOURWX3 wxT(BOARD"/Wx3")
|
||||||
#define BCOLOURLX2 wxT(BOARD"/Lx2")
|
#define BCOLOURLX2 wxT(BOARD"/Lx2")
|
||||||
#define BCOLOURLX3 wxT(BOARD"/Lx3")
|
#define BCOLOURLX3 wxT(BOARD"/Lx3")
|
||||||
#define BCOLOURBACKGROUND wxT(BOARD"/Background")
|
#define BCOLOURBACKGROUND wxT(BOARD"/Background")
|
||||||
#define BCOLOURLETTERS wxT(BOARD"/Letters")
|
#define BCOLOURLETTERS wxT(BOARD"/Letters")
|
||||||
#define BCOLOURTSTLETTERS wxT(BOARD"/TstLetters")
|
#define BCOLOURTSTLETTERS wxT(BOARD"/TstLetters")
|
||||||
#define BOARDFONT wxT(BOARD"/Font")
|
#define BOARDFONT wxT(BOARD"/Font")
|
||||||
|
|
||||||
#define LIST "List"
|
#define BDRAWBACKGROUND wxT(BOARD"/DrawTile")
|
||||||
#define LISTFONT wxT(LIST"/Font")
|
#define BTILEBACKGROUND wxT(BOARD"/TileBG")
|
||||||
|
#define BTSTTILEBACKGROUND wxT(BOARD"/TstTileBG")
|
||||||
|
|
||||||
|
#define LIST "List"
|
||||||
|
#define LISTFONT wxT(LIST"/Font")
|
||||||
|
|
||||||
#define PRINT "Print"
|
#define PRINT "Print"
|
||||||
#define PHEADER PRINT"/Header"
|
#define PHEADER PRINT"/Header"
|
||||||
|
@ -58,6 +68,8 @@
|
||||||
#define FRAMERACC wxT(FRAME"Racc")
|
#define FRAMERACC wxT(FRAME"Racc")
|
||||||
#define FRAMEBENJ wxT(FRAME"Benj")
|
#define FRAMEBENJ wxT(FRAME"Benj")
|
||||||
#define FRAMEBAG wxT(FRAME"Bag")
|
#define FRAMEBAG wxT(FRAME"Bag")
|
||||||
|
#define FRAMEGAME wxT(FRAME"Game")
|
||||||
|
#define FRAMERESULT wxT(FRAME"Result")
|
||||||
|
|
||||||
enum Justif { LEFT, CENTER, RIGHT };
|
enum Justif { LEFT, CENTER, RIGHT };
|
||||||
|
|
||||||
|
@ -160,11 +172,15 @@ public:
|
||||||
void setFrameShow(wxString,int);
|
void setFrameShow(wxString,int);
|
||||||
void setFrameDefault();
|
void setFrameDefault();
|
||||||
|
|
||||||
void setJokerPlus1(bool);
|
|
||||||
void setRackChecking(bool);
|
void setRackChecking(bool);
|
||||||
bool getJokerPlus1();
|
|
||||||
bool getRackChecking();
|
bool getRackChecking();
|
||||||
|
|
||||||
|
void setJokerPlus1(bool);
|
||||||
|
bool getJokerPlus1();
|
||||||
|
|
||||||
|
void setDrawTile(bool);
|
||||||
|
bool getDrawTile();
|
||||||
|
|
||||||
float getPrintLineScale();
|
float getPrintLineScale();
|
||||||
void setPrintLineScale(float);
|
void setPrintLineScale(float);
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
/* Eliot */
|
/* Eliot */
|
||||||
/* Copyright (C) 1999 Antoine Fraboulet */
|
/* Copyright (C) 1999 Antoine Fraboulet */
|
||||||
/* Antoine.Fraboulet@free.fr */
|
|
||||||
/* */
|
/* */
|
||||||
/* This program is free software; you can redistribute it and/or modify */
|
/* This file is part of Eliot. */
|
||||||
|
/* */
|
||||||
|
/* Eliot is free software; you can redistribute it and/or modify */
|
||||||
/* 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 */
|
||||||
/* the Free Software Foundation; either version 2 of the License, or */
|
/* the Free Software Foundation; either version 2 of the License, or */
|
||||||
/* (at your option) any later version. */
|
/* (at your option) any later version. */
|
||||||
/* */
|
/* */
|
||||||
/* This program is distributed in the hope that it will be useful, */
|
/* Eliot is distributed in the hope that it will be useful, */
|
||||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
/* GNU General Public License for more details. */
|
/* GNU General Public License for more details. */
|
||||||
|
@ -16,6 +17,13 @@
|
||||||
/* along with this program; if not, write to the Free Software */
|
/* along with this program; if not, write to the Free Software */
|
||||||
/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file gfxboard.cc
|
||||||
|
* \brief Game board graphical view
|
||||||
|
* \author Antoine Fraboulet
|
||||||
|
* \date 2002
|
||||||
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -28,313 +36,423 @@
|
||||||
#include "configdb.h"
|
#include "configdb.h"
|
||||||
#include "gfxboard.h"
|
#include "gfxboard.h"
|
||||||
|
|
||||||
|
#ifdef DEBUG_
|
||||||
|
# define GFXDEBUG(x) x
|
||||||
|
#else
|
||||||
|
# define GFXDEBUG(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(GfxBoard, wxWindow)
|
BEGIN_EVENT_TABLE(GfxBoard, wxWindow)
|
||||||
EVT_PAINT(GfxBoard::OnPaint)
|
EVT_PAINT(GfxBoard::OnPaint)
|
||||||
EVT_SIZE(GfxBoard::OnSize)
|
EVT_SIZE(GfxBoard::OnSize)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
#define LINE_WIDTH 1
|
||||||
|
#define BOARD_SIZE (BOARD_DIM + 2)
|
||||||
|
|
||||||
#define LINE_WIDTH 2
|
/* ************************************************** */
|
||||||
#define BOARD_SIZE 17
|
/* ************************************************** */
|
||||||
|
|
||||||
|
|
||||||
GfxBoard::GfxBoard(wxFrame *parent, Game &iGame) :
|
GfxBoard::GfxBoard(wxFrame *parent, Game &iGame) :
|
||||||
wxWindow(parent, -1), m_game(iGame)
|
wxWindow(parent, wxWindowID(-1), wxDefaultPosition, wxDefaultSize,
|
||||||
|
wxNO_BORDER | wxFULL_REPAINT_ON_RESIZE, wxT("gfxboard")),
|
||||||
|
m_game(iGame)
|
||||||
{
|
{
|
||||||
bmp = NULL;
|
bmp = NULL;
|
||||||
board_size = 0;
|
board_size = 0;
|
||||||
tile_size = 0;
|
tile_size = 0;
|
||||||
memset(paintedboard_char,0,sizeof(paintedboard_char));
|
#if defined(MSW_RESIZE_BUG)
|
||||||
memset(paintedboard_attr,0,sizeof(paintedboard_attr));
|
just_resized = false;
|
||||||
|
#endif
|
||||||
|
for(int i=0; i<BOARD_DIM; i++)
|
||||||
|
{
|
||||||
|
for(int j=0; j < BOARD_DIM; j++)
|
||||||
|
{
|
||||||
|
paintedboard_char[i][j] = wxT(' ');
|
||||||
|
paintedboard_attr[i][j] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ************************************************** */
|
||||||
|
/* ************************************************** */
|
||||||
|
|
||||||
GfxBoard::~GfxBoard(void)
|
GfxBoard::~GfxBoard(void)
|
||||||
{
|
{
|
||||||
if (bmp)
|
if (bmp)
|
||||||
{
|
{
|
||||||
delete bmp;
|
delete bmp;
|
||||||
}
|
bmp = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make new dimensions available for the next OnPaint
|
||||||
|
* event. The BMP is deleted if it exists.
|
||||||
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
GfxBoard::OnSize(wxSizeEvent& e)
|
GfxBoard::OnSize(wxSizeEvent& e)
|
||||||
{
|
{
|
||||||
size = GetClientSize();
|
GFXDEBUG(std::cerr << "On size : ");
|
||||||
|
|
||||||
board_size = size.GetWidth() < size.GetHeight() ?
|
wxSize cs = GetClientSize();
|
||||||
size.GetWidth() : size.GetHeight();
|
board_size = cs.GetWidth() < cs.GetHeight() ? cs.GetWidth() : cs.GetHeight();
|
||||||
|
tile_size = (int)((float)board_size / (float)(BOARD_SIZE)) - LINE_WIDTH;
|
||||||
|
|
||||||
tile_size = (int)((float)board_size / (float)(BOARD_SIZE)) - LINE_WIDTH;
|
GFXDEBUG(std::cerr << "(" << cs.GetWidth() << "," << cs.GetHeight() << ")");
|
||||||
|
GFXDEBUG(std::cerr << " tile size " << tile_size << endl);
|
||||||
|
|
||||||
TopLeft = wxPoint((size.GetWidth() - (board_size - tile_size/2)) / 2,
|
TopLeft = wxPoint((cs.GetWidth() - (board_size - tile_size/2)) / 2,
|
||||||
(size.GetHeight() - (board_size - tile_size/2)) / 2);
|
(cs.GetHeight() - (board_size - tile_size/2)) / 2);
|
||||||
|
|
||||||
if (bmp)
|
#if defined(MSW_RESIZE_BUG)
|
||||||
{
|
just_resized = true;
|
||||||
delete bmp;
|
#endif
|
||||||
bmp = NULL;
|
|
||||||
}
|
if (bmp)
|
||||||
|
{
|
||||||
|
delete bmp;
|
||||||
|
bmp = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a BMP in memory and draws the board inside
|
||||||
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
GfxBoard::CreateBMP()
|
GfxBoard::CreateBMP()
|
||||||
{
|
{
|
||||||
|
GFXDEBUG(std::cerr << "Create BMP ");
|
||||||
if (!bmp)
|
if (!bmp)
|
||||||
{
|
{
|
||||||
wxSize bs = GetClientSize();
|
wxSize bs = GetClientSize();
|
||||||
bmp=new wxBitmap(bs.x,bs.y);
|
bmp=new wxBitmap(bs.x,bs.y);
|
||||||
if (bmp)
|
GFXDEBUG(std::cerr << " new bmp (" << bs.x << "," << bs.y << ")");
|
||||||
{
|
if (bmp)
|
||||||
wxMemoryDC memDC;
|
{
|
||||||
memDC.SelectObject(* bmp);
|
wxMemoryDC memDC;
|
||||||
DrawBoard(&memDC);
|
memDC.SelectObject(* bmp);
|
||||||
memDC.SelectObject(wxNullBitmap);
|
DrawBoard(&memDC);
|
||||||
}
|
memDC.SelectObject(wxNullBitmap);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
GFXDEBUG(std::cerr << endl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the full BMP and copy only the requested area
|
||||||
|
* to the ClientDC
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
GfxBoard::RefreshSquare(wxRect &r)
|
||||||
|
{
|
||||||
|
wxClientDC dc(this);
|
||||||
|
|
||||||
|
if (bmp)
|
||||||
|
{
|
||||||
|
int vX,vY,vW,vH;
|
||||||
|
wxMemoryDC memDC;
|
||||||
|
memDC.SelectObject(* bmp);
|
||||||
|
DrawBoard(&memDC);
|
||||||
|
vX = r.x;
|
||||||
|
vY = r.y;
|
||||||
|
vW = r.width;
|
||||||
|
vH = r.height;
|
||||||
|
GFXDEBUG(std::cerr << " refresh (" << vX << "," << vY << "," << vW << "," << vH << ") ");
|
||||||
|
dc.Blit(vX,vY,vW,vH,&memDC,vX,vY,wxCOPY);
|
||||||
|
memDC.SelectObject(wxNullBitmap);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DrawBoard(&dc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force a full refresh of the board
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
GfxBoard::Refresh(board_refresh_t WXUNUSED(force))
|
||||||
|
{
|
||||||
|
wxSize cs = GetClientSize();
|
||||||
|
board_size = cs.GetWidth() < cs.GetHeight() ? cs.GetWidth() : cs.GetHeight();
|
||||||
|
tile_size = (int)((float)board_size / (float)(BOARD_SIZE)) - LINE_WIDTH;
|
||||||
|
wxRect r (0,0,cs.GetWidth(),cs.GetHeight());
|
||||||
|
RefreshSquare(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Window manager OnPaint event handler.
|
||||||
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
GfxBoard::OnPaint(wxPaintEvent&)
|
GfxBoard::OnPaint(wxPaintEvent&)
|
||||||
{
|
{
|
||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
|
|
||||||
CreateBMP();
|
CreateBMP();
|
||||||
|
|
||||||
if (bmp)
|
GFXDEBUG(std::cerr << "OnPaint : ");
|
||||||
{
|
|
||||||
int vX,vY,vW,vH;
|
|
||||||
wxMemoryDC memDC;
|
|
||||||
memDC.SelectObject(* bmp);
|
|
||||||
wxRegionIterator upd(GetUpdateRegion());
|
|
||||||
|
|
||||||
while (upd)
|
if (bmp)
|
||||||
{
|
{
|
||||||
vX = upd.GetX();
|
#if defined(MSW_RESIZE_BUG)
|
||||||
vY = upd.GetY();
|
Refresh(BOARD_FORCE_REFRESH);
|
||||||
vW = upd.GetW();
|
if (just_resized == true)
|
||||||
vH = upd.GetH();
|
{
|
||||||
dc.Blit(vX,vY,vW,vH,&memDC,vX,vY,wxCOPY);
|
just_resized = false;
|
||||||
upd ++ ;
|
}
|
||||||
|
#else
|
||||||
|
// we keep that code for wxgtk
|
||||||
|
// it does not work under wxmsw, don't know why
|
||||||
|
// all the onsize/repaint should be checked ... later
|
||||||
|
int vX,vY,vW,vH;
|
||||||
|
wxMemoryDC memDC;
|
||||||
|
memDC.SelectObject(* bmp);
|
||||||
|
wxRegionIterator upd(GetUpdateRegion());
|
||||||
|
while (upd)
|
||||||
|
{
|
||||||
|
vX = upd.GetX();
|
||||||
|
vY = upd.GetY();
|
||||||
|
vW = upd.GetW();
|
||||||
|
vH = upd.GetH();
|
||||||
|
GFXDEBUG(std::cerr << "+(" << vX << "," << vY << "," << vW << "," << vH << ")");
|
||||||
|
dc.Blit(vX,vY,vW,vH,&memDC,vX,vY,wxCOPY);
|
||||||
|
upd ++ ;
|
||||||
|
}
|
||||||
|
memDC.SelectObject(wxNullBitmap);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GFXDEBUG(std::cerr << " call to DrawBoard ");
|
||||||
|
DrawBoard(&dc);
|
||||||
}
|
}
|
||||||
|
|
||||||
memDC.SelectObject(wxNullBitmap);
|
GFXDEBUG(std::cerr << "End of OnPaint" << endl);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DrawBoard(&dc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GfxBoard::Refresh(board_refresh_t force)
|
GfxBoard::DrawTileBack(wxDC* dc, int top, int left, int size, bool testtile)
|
||||||
{
|
{
|
||||||
wxClientDC dc(this);
|
// void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20)
|
||||||
|
wxBrush oldbrush = dc->GetBrush();
|
||||||
|
wxColour colBackground;
|
||||||
|
|
||||||
CreateBMP();
|
if (testtile)
|
||||||
|
|
||||||
if (force == BOARD_FORCE_REFRESH)
|
|
||||||
{
|
|
||||||
if (bmp)
|
|
||||||
{
|
{
|
||||||
wxMemoryDC memDC;
|
colBackground = config.getColour(wxString(BTSTTILEBACKGROUND));
|
||||||
memDC.SelectObject(* bmp);
|
|
||||||
DrawBoard(&memDC);
|
|
||||||
dc.Blit(0,0,board_size,board_size,&memDC,0,0,wxCOPY);
|
|
||||||
memDC.SelectObject(wxNullBitmap);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DrawBoard(&dc);
|
colBackground = config.getColour(wxString(BTILEBACKGROUND));
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bmp)
|
wxBrush *BackgroundBrush = wxTheBrushList->FindOrCreateBrush(colBackground, wxSOLID);
|
||||||
{
|
dc->SetBrush(* BackgroundBrush);
|
||||||
int vX,vY,vW,vH;
|
dc->DrawRoundedRectangle(left,top,size,size,std::max(2,size/6));
|
||||||
wxMemoryDC memDC;
|
dc->SetBrush(oldbrush);
|
||||||
memDC.SelectObject(* bmp);
|
|
||||||
|
|
||||||
DrawBoard(&memDC);
|
|
||||||
vX = (tile_size + LINE_WIDTH) * left;
|
|
||||||
vY = (tile_size + LINE_WIDTH) * top;
|
|
||||||
vW = (tile_size + 2*LINE_WIDTH) * (right - left + LINE_WIDTH);
|
|
||||||
vH = (tile_size + 2*LINE_WIDTH) * (bottom - top + LINE_WIDTH);
|
|
||||||
|
|
||||||
dc.Blit(vX,vY,vW,vH,&memDC,vX,vY,wxCOPY);
|
|
||||||
|
|
||||||
memDC.SelectObject(wxNullBitmap);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DrawBoard(&dc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw a tile to the wxDC object.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define TILE_LEFT(col) (col*(tile_size+LINE_WIDTH) + TopLeft.x)
|
||||||
|
#define TILE_TOP(row) (row*(tile_size+LINE_WIDTH) + TopLeft.y)
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO
|
||||||
|
- ajuster avec une LINE_SIZE differente
|
||||||
|
- calculer la taille de la police
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* TILE_LEFT
|
||||||
|
|
|
||||||
|
| TILE_LEFT + LINE_WIDTH
|
||||||
|
| |
|
||||||
|
+++++++++-- TILE_TOP
|
||||||
|
+++++++++
|
||||||
|
+++++++++
|
||||||
|
+++ +++-------------- TILE_TOP + LINE_WIDTH
|
||||||
|
+++ +++ | = tile_size
|
||||||
|
+++ +++--
|
||||||
|
+++++++++--
|
||||||
|
+++++++++ | = LINE_WIDTH
|
||||||
|
+++++++++--
|
||||||
|
| |
|
||||||
|
|_|
|
||||||
|
|
|
||||||
|
LINE_WIDTH
|
||||||
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
GfxBoard::DrawTile(wxDC *dc, wxString& wxs, int row, int column)
|
GfxBoard::DrawTile(wxDC *dc, wxString& wxs, int row, int column, bool testtile, bool drawtileback)
|
||||||
{
|
{
|
||||||
int l;
|
wxColour colour;
|
||||||
char c = 0;
|
wxCoord width, height;
|
||||||
wxCoord width, height;
|
wxCoord posx, posy;
|
||||||
wxCoord posx, posy;
|
wxCoord left,top;
|
||||||
|
// redraw borders
|
||||||
|
left = TILE_LEFT(column);
|
||||||
|
top = TILE_TOP(row);
|
||||||
|
|
||||||
// redraw borders
|
if (wxs.length() > 0 && *wxs.GetData())
|
||||||
if (row && column)
|
{
|
||||||
dc->DrawRectangle(column*(tile_size+LINE_WIDTH) + TopLeft.x,
|
// we got a letter (or 2 chars for coordinates > 9)
|
||||||
row*(tile_size+LINE_WIDTH) + TopLeft.y,
|
// draw plastic tile
|
||||||
tile_size + 2*LINE_WIDTH,
|
if (drawtileback)
|
||||||
tile_size + 2*LINE_WIDTH);
|
{
|
||||||
|
DrawTileBack(dc,
|
||||||
|
top + LINE_WIDTH,
|
||||||
|
left + LINE_WIDTH,
|
||||||
|
tile_size, testtile);
|
||||||
|
}
|
||||||
|
// draw letter
|
||||||
|
if (testtile)
|
||||||
|
{
|
||||||
|
colour = config.getColour(wxString(BCOLOURTSTLETTERS));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
colour = config.getColour(wxString(BCOLOURLETTERS));
|
||||||
|
}
|
||||||
|
|
||||||
// const char* ptr = wxs.mb_str();
|
dc->SetTextForeground(colour);
|
||||||
// if (wxs.Len() && isalnum(*ptr))
|
dc->GetTextExtent(wxs,&width,&height);
|
||||||
// {
|
posx = left + LINE_WIDTH + (tile_size - width) / 2;
|
||||||
|
posy = top + LINE_WIDTH + (tile_size - height) / 2;
|
||||||
const char* ptr = (const char*)wxs.c_str();
|
dc->DrawText(wxs,posx,posy);
|
||||||
l = strlen(ptr);
|
}
|
||||||
if (ptr)
|
|
||||||
c = *ptr;
|
|
||||||
|
|
||||||
if (l > 0 && isalnum(c))
|
|
||||||
{
|
|
||||||
// we got a letter (or 2 chars for coordinates > 9)
|
|
||||||
dc->GetTextExtent(wxs,&width,&height);
|
|
||||||
posx = TopLeft.x + column*(tile_size+LINE_WIDTH) + LINE_WIDTH +
|
|
||||||
(tile_size - width) / 2;
|
|
||||||
posy = TopLeft.y + row*(tile_size+LINE_WIDTH) + LINE_WIDTH +
|
|
||||||
(tile_size - height) / 2;
|
|
||||||
dc->DrawText(wxs,posx,posy);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw the complete board in the wxDC.
|
||||||
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
GfxBoard::DrawBoard(wxDC *dc)
|
GfxBoard::DrawBoard(wxDC *dc)
|
||||||
{
|
{
|
||||||
wxString wxs;
|
Board board;
|
||||||
int attr;
|
|
||||||
int row,column;
|
|
||||||
|
|
||||||
left = BOARD_MAX;
|
wxString wxs;
|
||||||
right = BOARD_MIN;
|
int row,column;
|
||||||
top = BOARD_MAX;
|
|
||||||
bottom = BOARD_MIN;
|
|
||||||
|
|
||||||
wxFont font = config.getFont(BOARDFONT);
|
wxFont font = config.getFont(BOARDFONT);
|
||||||
|
wxColour colForeground = config.getColour(wxString(BCOLOURLINES));
|
||||||
|
wxColour colBackground = config.getColour(wxString(BCOLOURBACKGROUND));
|
||||||
|
|
||||||
wxColour colLines = config.getColour(wxString(BCOLOURLINES));
|
wxBrush *BackgroundBrush = wxTheBrushList->FindOrCreateBrush(colBackground, wxSOLID);
|
||||||
wxColour colLetters = config.getColour(wxString(BCOLOURLETTERS));
|
wxPen *LinesPen = wxThePenList->FindOrCreatePen(colForeground, LINE_WIDTH, wxSOLID);
|
||||||
wxColour colTestLetters = config.getColour(wxString(BCOLOURTSTLETTERS));
|
|
||||||
wxColour colBackground = config.getColour(wxString(BCOLOURBACKGROUND));
|
|
||||||
wxColour colWx3 = config.getColour(wxString(BCOLOURWX3));
|
|
||||||
wxColour colWx2 = config.getColour(wxString(BCOLOURWX2));
|
|
||||||
wxColour colLx3 = config.getColour(wxString(BCOLOURLX3));
|
|
||||||
wxColour colLx2 = config.getColour(wxString(BCOLOURLX2));
|
|
||||||
|
|
||||||
wxPen *LinesPen = wxThePenList->FindOrCreatePen(colLines, 1, wxSOLID);
|
dc->SetFont (font);
|
||||||
wxBrush *BackgroundBrush = wxTheBrushList->FindOrCreateBrush(colBackground,
|
dc->SetPen (* LinesPen);
|
||||||
wxSOLID);
|
dc->SetBrush(* BackgroundBrush);
|
||||||
|
|
||||||
wxBrush *Wx3Brush = wxTheBrushList->FindOrCreateBrush(colWx3, wxSOLID);
|
// background rectangle (entire frame)
|
||||||
wxBrush *Wx2Brush = wxTheBrushList->FindOrCreateBrush(colWx2, wxSOLID);
|
wxSize bs = GetClientSize();
|
||||||
wxBrush *Lx3Brush = wxTheBrushList->FindOrCreateBrush(colLx3, wxSOLID);
|
dc->DrawRectangle(0,0,bs.x,bs.y);
|
||||||
wxBrush *Lx2Brush = wxTheBrushList->FindOrCreateBrush(colLx2, wxSOLID);
|
|
||||||
|
|
||||||
dc->SetFont(font);
|
// lines
|
||||||
LinesPen->SetWidth(LINE_WIDTH);
|
for(row=BOARD_MIN; row < BOARD_MAX; row++)
|
||||||
dc->SetPen(* LinesPen);
|
{
|
||||||
dc->SetBrush(* BackgroundBrush);
|
// vertical
|
||||||
|
dc->DrawLine(TILE_LEFT(row+1),
|
||||||
|
TILE_TOP(1),
|
||||||
|
TILE_LEFT(row+1),
|
||||||
|
TILE_TOP(BOARD_MAX));
|
||||||
|
// horizontal row <-> line
|
||||||
|
dc->DrawLine(TILE_LEFT(1),
|
||||||
|
TILE_TOP(row+1),
|
||||||
|
TILE_LEFT(BOARD_MAX),
|
||||||
|
TILE_TOP(row+1));
|
||||||
|
}
|
||||||
|
|
||||||
// background rectangle (entire frame)
|
// 1 2 3 4 5 ...
|
||||||
wxSize bs = GetClientSize();
|
// A B C D ...
|
||||||
dc->DrawRectangle(0,0,bs.x,bs.y);
|
|
||||||
|
|
||||||
// lines
|
|
||||||
// dc->DrawRectangle(TopLeft.x,TopLeft.y,board_size - tile_size/2, board_size - tile_size/2);
|
|
||||||
for(row=BOARD_MIN; row < BOARD_MAX; row++)
|
|
||||||
{
|
|
||||||
// vertical
|
|
||||||
dc->DrawLine(TopLeft.x + (row+1)*(tile_size+LINE_WIDTH),
|
|
||||||
TopLeft.y + tile_size + LINE_WIDTH,
|
|
||||||
TopLeft.x + (row+1)*(tile_size+LINE_WIDTH),
|
|
||||||
TopLeft.y + BOARD_MAX * (tile_size+LINE_WIDTH));
|
|
||||||
// horizontal row <-> line
|
|
||||||
dc->DrawLine(TopLeft.x + tile_size+LINE_WIDTH,
|
|
||||||
TopLeft.y + (row+1)*(tile_size+LINE_WIDTH),
|
|
||||||
TopLeft.x + BOARD_MAX * (tile_size+LINE_WIDTH),
|
|
||||||
TopLeft.y + (row+1)*(tile_size+LINE_WIDTH));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1 2 3 4 5 ...
|
|
||||||
// A B C D
|
|
||||||
for(row=BOARD_MIN; row <= BOARD_MAX; row++)
|
|
||||||
{
|
|
||||||
wxs.Printf(wxT("%d"), row);
|
|
||||||
DrawTile(dc, wxs, 0, row);
|
|
||||||
wxs.Printf(wxT("%c"), row + 'A' - 1);
|
|
||||||
DrawTile(dc, wxs, row, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
dc->SetTextForeground(colLetters);
|
|
||||||
for(row=BOARD_MIN; row <= BOARD_MAX; row++)
|
for(row=BOARD_MIN; row <= BOARD_MAX; row++)
|
||||||
{
|
{
|
||||||
for (column = BOARD_MIN; column <= BOARD_MAX; column++)
|
wxs.Printf(wxT("%d"), row);
|
||||||
{
|
DrawTile(dc, wxs, 0, row);
|
||||||
if (m_game.getBoard().getLetterMultiplier(row, column) == 2)
|
wxs.Printf(wxT("%c"), row + 'A' - 1);
|
||||||
{
|
DrawTile(dc, wxs, row, 0);
|
||||||
dc->SetBrush(*Lx2Brush);
|
}
|
||||||
dc->SetTextBackground(colLx2);
|
|
||||||
}
|
|
||||||
else if (m_game.getBoard().getLetterMultiplier(row, column) == 3)
|
|
||||||
{
|
|
||||||
dc->SetBrush(*Lx3Brush);
|
|
||||||
dc->SetTextBackground(colLx3);
|
|
||||||
}
|
|
||||||
else if (m_game.getBoard().getWordMultiplier(row, column) == 2)
|
|
||||||
{
|
|
||||||
dc->SetBrush(*Wx2Brush);
|
|
||||||
dc->SetTextBackground(colWx2);
|
|
||||||
}
|
|
||||||
else if (m_game.getBoard().getWordMultiplier(row, column) == 3)
|
|
||||||
{
|
|
||||||
dc->SetBrush(*Wx3Brush);
|
|
||||||
dc->SetTextBackground(colWx3);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxs = wxString((wxChar)m_game.getBoard().getChar(row, column));
|
// Board Background
|
||||||
attr = m_game.getBoard().getCharAttr(row, column);
|
wxColour colWx3 = config.getColour(wxString(BCOLOURWX3));
|
||||||
if ((paintedboard_char[row - BOARD_MIN][column - BOARD_MIN] != wxs.GetChar(0)) ||
|
wxColour colWx2 = config.getColour(wxString(BCOLOURWX2));
|
||||||
(paintedboard_attr[row - BOARD_MIN][column - BOARD_MIN] != attr))
|
wxColour colLx3 = config.getColour(wxString(BCOLOURLX3));
|
||||||
{
|
wxColour colLx2 = config.getColour(wxString(BCOLOURLX2));
|
||||||
top = top < row ? top : row;
|
|
||||||
bottom = bottom > row ? bottom : row;
|
|
||||||
left = left < column ? left : column;
|
|
||||||
right = right > column ? right : column;
|
|
||||||
paintedboard_char[row - BOARD_MIN][column - BOARD_MIN] = wxs.GetChar(0);
|
|
||||||
paintedboard_attr[row - BOARD_MIN][column - BOARD_MIN] = attr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attr & ATTR_TEST)
|
wxBrush *Wx3Brush = wxTheBrushList->FindOrCreateBrush(colWx3, wxSOLID);
|
||||||
{
|
wxBrush *Wx2Brush = wxTheBrushList->FindOrCreateBrush(colWx2, wxSOLID);
|
||||||
dc->SetTextForeground(colTestLetters);
|
wxBrush *Lx3Brush = wxTheBrushList->FindOrCreateBrush(colLx3, wxSOLID);
|
||||||
DrawTile(dc,wxs,row,column);
|
wxBrush *Lx2Brush = wxTheBrushList->FindOrCreateBrush(colLx2, wxSOLID);
|
||||||
dc->SetTextForeground(colLetters);
|
|
||||||
}
|
board = m_game.getBoard();
|
||||||
else
|
for(row=BOARD_MIN; row <= BOARD_MAX; row++)
|
||||||
{
|
{
|
||||||
DrawTile(dc,wxs,row,column);
|
for (column = BOARD_MIN; column <= BOARD_MAX; column++)
|
||||||
}
|
{
|
||||||
dc->SetBrush(* BackgroundBrush);
|
if (board.getLetterMultiplier(row, column) == 2)
|
||||||
dc->SetTextBackground(colBackground);
|
{
|
||||||
}
|
dc->SetBrush(*Lx2Brush);
|
||||||
}
|
}
|
||||||
|
else if (board.getLetterMultiplier(row, column) == 3)
|
||||||
|
{
|
||||||
|
dc->SetBrush(*Lx3Brush);
|
||||||
|
}
|
||||||
|
else if (board.getWordMultiplier(row, column) == 2)
|
||||||
|
{
|
||||||
|
dc->SetBrush(*Wx2Brush);
|
||||||
|
}
|
||||||
|
else if (board.getWordMultiplier(row, column) == 3)
|
||||||
|
{
|
||||||
|
dc->SetBrush(*Wx3Brush);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dc->SetBrush(*BackgroundBrush);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (row && column)
|
||||||
|
{
|
||||||
|
dc->DrawRectangle(TILE_LEFT(column), TILE_TOP(row),
|
||||||
|
tile_size + 2*LINE_WIDTH,
|
||||||
|
tile_size + 2*LINE_WIDTH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tiles
|
||||||
|
LinesPen->SetWidth(1);
|
||||||
|
dc->SetPen (* LinesPen);
|
||||||
|
bool drawtiles = config.getDrawTile();
|
||||||
|
for(row=BOARD_MIN; row <= BOARD_MAX; row++)
|
||||||
|
{
|
||||||
|
for (column = BOARD_MIN; column <= BOARD_MAX; column++)
|
||||||
|
{
|
||||||
|
int attr = board.getCharAttr(row, column);
|
||||||
|
wxs = wxString((wxChar)board.getChar(row, column));
|
||||||
|
|
||||||
|
paintedboard_char[row - BOARD_MIN][column - BOARD_MIN] = *wxs.GetData();
|
||||||
|
paintedboard_attr[row - BOARD_MIN][column - BOARD_MIN] = attr;
|
||||||
|
|
||||||
|
DrawTile(dc,wxs,row,column,attr & ATTR_TEST,drawtiles);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dc->SetFont(wxNullFont);
|
dc->SetFont(wxNullFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Local Variables:
|
||||||
|
/// mode: hs-minor
|
||||||
|
/// c-basic-offset: 4
|
||||||
|
/// End:
|
||||||
|
|
117
wxwin/gfxboard.h
117
wxwin/gfxboard.h
|
@ -1,13 +1,14 @@
|
||||||
/* Eliot */
|
/* Eliot */
|
||||||
/* Copyright (C) 1999 Antoine Fraboulet */
|
/* Copyright (C) 1999 Antoine Fraboulet */
|
||||||
/* Antoine.Fraboulet@free.fr */
|
|
||||||
/* */
|
/* */
|
||||||
/* This program is free software; you can redistribute it and/or modify */
|
/* This file is part of Eliot. */
|
||||||
|
/* */
|
||||||
|
/* Eliot is free software; you can redistribute it and/or modify */
|
||||||
/* 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 */
|
||||||
/* the Free Software Foundation; either version 2 of the License, or */
|
/* the Free Software Foundation; either version 2 of the License, or */
|
||||||
/* (at your option) any later version. */
|
/* (at your option) any later version. */
|
||||||
/* */
|
/* */
|
||||||
/* This program is distributed in the hope that it will be useful, */
|
/* Eliot is distributed in the hope that it will be useful, */
|
||||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
/* GNU General Public License for more details. */
|
/* GNU General Public License for more details. */
|
||||||
|
@ -17,7 +18,7 @@
|
||||||
/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file gfxboard.h
|
* \file gfxboard.h
|
||||||
* \brief Game board graphical view
|
* \brief Game board graphical view
|
||||||
* \author Antoine Fraboulet
|
* \author Antoine Fraboulet
|
||||||
* \date 2002
|
* \date 2002
|
||||||
|
@ -26,45 +27,89 @@
|
||||||
#ifndef _GFXBOARD_H
|
#ifndef _GFXBOARD_H
|
||||||
#define _GFXBOARD_H
|
#define _GFXBOARD_H
|
||||||
|
|
||||||
/*
|
/**
|
||||||
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).
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
BOARD_REFRESH,
|
|
||||||
BOARD_FORCE_REFRESH
|
|
||||||
} board_refresh_t;
|
|
||||||
|
|
||||||
|
|
||||||
class GfxBoard : public wxWindow
|
class GfxBoard : public wxWindow
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Game &m_game;
|
/**
|
||||||
int top,bottom,left,right;
|
* reference on the played game
|
||||||
char paintedboard_char[BOARD_DIM][BOARD_DIM];
|
*/
|
||||||
char paintedboard_attr[BOARD_DIM][BOARD_DIM];
|
Game &m_game;
|
||||||
int board_size;
|
|
||||||
int tile_size;
|
|
||||||
wxPoint TopLeft;
|
|
||||||
wxSize size;
|
|
||||||
wxBitmap *bmp;
|
|
||||||
void CreateBMP();
|
|
||||||
void DrawTile(wxDC*,wxString&,int,int);
|
|
||||||
void DrawBoard(wxDC*);
|
|
||||||
|
|
||||||
ConfigDB config;
|
/**
|
||||||
public:
|
* paintedboard_char is the matrix of played tiles
|
||||||
GfxBoard(wxFrame*, Game&);
|
*/
|
||||||
~GfxBoard(void);
|
wxChar paintedboard_char[BOARD_DIM][BOARD_DIM];
|
||||||
|
|
||||||
void Refresh(board_refresh_t force = BOARD_REFRESH);
|
/**
|
||||||
void OnPaint(wxPaintEvent& event);
|
* paintedboard_attr is the matrix of special attributes for tiles, for
|
||||||
void OnSize(wxSizeEvent& event);
|
* instance it can store if a tile is a test tile (placed but not played).
|
||||||
DECLARE_EVENT_TABLE()
|
*/
|
||||||
|
char paintedboard_attr[BOARD_DIM][BOARD_DIM];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* size in pixels for the board.
|
||||||
|
* board_size = min(width,height)
|
||||||
|
*/
|
||||||
|
int board_size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tile_size = size in pixels of a tile
|
||||||
|
*/
|
||||||
|
int tile_size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* there is a bug when doing an OnSize under windows : the window
|
||||||
|
* has to be fully refreshed (UpdateRegion does not seem to work).
|
||||||
|
*/
|
||||||
|
#if defined(MSW_RESIZE_BUG)
|
||||||
|
bool just_resized;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* top left point used to draw the lines, used to keep the board
|
||||||
|
* centered horizontally and vertically
|
||||||
|
*/
|
||||||
|
wxPoint TopLeft;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Board bitmap, created by CreateBMP
|
||||||
|
*/
|
||||||
|
wxBitmap *bmp;
|
||||||
|
|
||||||
|
void CreateBMP();
|
||||||
|
void DrawTileBack(wxDC*,int,int,int, bool testtile);
|
||||||
|
void DrawTile(wxDC*,wxString&,int,int,bool testtile = false, bool drawtileback = false);
|
||||||
|
void DrawBoard(wxDC*);
|
||||||
|
void RefreshSquare(wxRect&);
|
||||||
|
|
||||||
|
ConfigDB config;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
GfxBoard(wxFrame* parent, Game& game);
|
||||||
|
~GfxBoard(void);
|
||||||
|
|
||||||
|
void OnPaint (wxPaintEvent& event);
|
||||||
|
void OnSize (wxSizeEvent& event);
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
BOARD_REFRESH,
|
||||||
|
BOARD_FORCE_REFRESH
|
||||||
|
} board_refresh_t;
|
||||||
|
|
||||||
|
void Refresh (board_refresh_t force = BOARD_REFRESH);
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/// Local Variables:
|
||||||
|
/// mode: hs-minor
|
||||||
|
/// c-basic-offset: 4
|
||||||
|
/// End:
|
||||||
|
|
Loading…
Reference in a new issue