From: <pha...@us...> - 2007-08-16 06:54:32
|
Revision: 51 http://chessdrills.svn.sourceforge.net/chessdrills/?rev=51&view=rev Author: phantomfive Date: 2007-08-15 23:54:31 -0700 (Wed, 15 Aug 2007) Log Message: ----------- Now has some sort of weird piece movement. Really need to make the backgrounds of the images transparent (not to mention draw them to look good) Modified Paths: -------------- gui/GuiControl.cpp gui/MainWindow.cpp Modified: gui/GuiControl.cpp =================================================================== --- gui/GuiControl.cpp 2007-08-10 06:24:04 UTC (rev 50) +++ gui/GuiControl.cpp 2007-08-16 06:54:31 UTC (rev 51) @@ -75,6 +75,14 @@ //--------------------------------------------------------------- // Methods called by the GUI //--------------------------------------------------------------- +void GuiControl::SquareWasSelected( int &row, int &col ){ + const ChessSquare *sqr = board.GetSquare((ChessColumn)col, (ChessRow)row); + const ChessPiece *piece = &(sqr->piece); + if( currentDrill != NULL ){ + currentDrill->SquareWasSelected( *sqr, *piece ); + } +} + const char **GuiControl::GetDrillList(){ return DrillName; } Modified: gui/MainWindow.cpp =================================================================== --- gui/MainWindow.cpp 2007-08-10 06:24:04 UTC (rev 50) +++ gui/MainWindow.cpp 2007-08-16 06:54:31 UTC (rev 51) @@ -19,8 +19,9 @@ BEGIN_EVENT_TABLE(MainWindow, wxFrame) EVT_PAINT(MainWindow::Redraw) -EVT_LEFT_DOWN(MainWindow::OnMouseClick) +EVT_LEFT_DOWN(MainWindow::OnMouseDown) EVT_LEFT_UP(MainWindow::OnMouseUp) +EVT_MOTION(MainWindow::OnMouseMove) EVT_MENU(ID_Quit, MainWindow::OnQuit) EVT_MENU(ID_SelectDrill1, MainWindow::OnSelectDrill) EVT_MENU(ID_SelectDrill2, MainWindow::OnSelectDrill) @@ -65,6 +66,7 @@ CreateStatusBar(); SetStatusText( "Here is our board!" ); boardIsFlipped = false; + dragging = false; //create the menu wxMenu *menuFile = new wxMenu; @@ -157,6 +159,11 @@ } } } + + //dragging stuff + if( dragging ){ + dc.DrawBitmap( blackQueen, mouseX-(SQUARE_HEIGHT/2), mouseY-(SQUARE_WIDTH/2), true ); + } } void MainWindow::OnQuit(wxCommandEvent& WXUNUSED(event)) @@ -176,25 +183,50 @@ //----------------------------------------------------------------------- // Mouse functions //----------------------------------------------------------------------- -void MainWindow::OnMouseClick( wxMouseEvent& event ){ + +void MainWindow::OnMouseDown( wxMouseEvent& event ){ + bool rv; int row, col; - bool rv; printf("Got a mouse down event!!\n"); printf("located at (%d,%d)\n",event.m_x, event.m_y); rv = GetSquareFromPoint(event.m_x,event.m_y,row,col); printf("square is (%d,%d) it is %s the board\n",col,row, (rv)?"on":"not on"); + dragging = true; + mouseX = event.m_x; + mouseY = event.m_y; + Refresh( false ); + Update(); } void MainWindow::OnMouseUp( wxMouseEvent& event ){ - int row, col; + /*int row, col; bool rv; - rv = GetSquareFromPoint(event.m_x, event.m_y, row, col ); + rv = GetSquareFromPoint(event.m_x, event.m_y, row, col ); if( rv ){ ctl.SquareWasSelected( row, col ); } + */ + bool rv; + int row, col; + printf("Got a mouse up event!!\n"); + printf("located at (%d,%d)\n",event.m_x, event.m_y); + rv = GetSquareFromPoint(event.m_x,event.m_y,row,col); + printf("square is (%d,%d) it is %s the board\n",col,row, + (rv)?"on":"not on"); + dragging = false; + Refresh( false ); + Update(); } +void MainWindow::OnMouseMove( wxMouseEvent& event ){ + if( !dragging ) return; + mouseX = event.m_x; + mouseY = event.m_y; + Refresh( false ); + Update(); +} + bool MainWindow::GetSquareFromPoint(int x, int y, int &row, int &col){ if(boardIsFlipped){ row = y/SQUARE_HEIGHT; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |