BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

problem calling OnCellDraw method

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder
View previous topic :: View next topic  
Author Message
GLY7CH
Guest





PostPosted: Fri Aug 11, 2006 5:34 pm    Post subject: problem calling OnCellDraw method Reply with quote



Hi all.

Bit of a stupid problem i'm having here, i'm sure someone can point out
what to do in an instance, whereas i've been searching for a good hour
now.

Basically I am writing an Othello (the game) app in BCB 6, all the
backend data model stuff is in place and some of the GUI is done. I am
using a DrawGrid to represent the board, which needs each cell to be
filled either black or white depending on the state of each element of
an array of Piece objects (a piece inherits position(int x, int y) and
adds a char state). Inspecting and setting states of each element is of
course a piece of cake, but I need to represent this back to the GUI
DrawGrid. This method would be called at the start of a new game and on
every subsequent move to update the draw grid according to the new
state of the board array.

I have written the following method to determine which colour to use
and then fill the inspected cell with that colour:

void __fastcall TMain::grdBoardDrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, TGridDrawState State)
{
if(board->board[ACol][ARow].getState() == 'b')
{
grdBoard->Canvas->Brush->Color = clBlack;
grdBoard->Canvas->FloodFill(ACol, ARow, clBlack,
fsBorder);
}

else if (board->board[ARow][ACol].getState() == 'w')
{
grdBoard->Canvas->Brush->Color = clWhite;
grdBoard->Canvas->FloodFill(ACol, ARow, clWhite,
fsBorder);
}
}

Is this correct? Would this work??

When a new game is started the board is initialised with the centre 4
pieces set, the player's colour is set to 'b' for black, the scores on
the GUI are all updated and then the DrawGrid needs to be updated with
the correct cells shaded. Here's that method:

void __fastcall TMain::btnNewGameClick(TObject *Sender)
{
board->initBoard();
player->setColour('b');
updateAll();

for (int x = boardXMin; x <= boardXMax; x++)
{
for (int y = boardYMin; y <= boardYMax; y++)
{
//grdBoardDrawCell();
}
}

memInfo->Lines->Add("You have started a new game. Click on a
cell to select it, then click on Make Move");
}

The problem I have is I dont know what parameters to pass to the
grdBoardDrawCell method aside from the x and y of course. I assume for
the sender object that 'this' would suffice? As for the Rect and State
objects, I dont even know what they are so unsure what to pass.

If anyone can point out my errors here and show me how to fix them or
even tell me its all wrong and show me the right way to do what im
trying then all the better!

Kind Regards
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.