/*************************************************************************** * Copyright (C) 2005 by Tavarez Arnaud Bakoula * * tbakoula@yahoo.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "pionsrc.h" #include "utilities.h" #include "dragpion.h" #include /*! * \brief The constructor * * It constructs an instance of the PionSrc class * \param i the position of the source; it corresponds * with the color we want to provide * \param parent the parent widget * \param name the widget */ PionSrc::PionSrc( uint i, QWidget* parent, const char* name ) : QLabel( parent, name ) { moving = false; setPixmap( theIconLoader->loadIcon( colorToString( (Color)i ), KIcon::Toolbar, icon_res ) ); setFixedSize( pixmap()->size() ); } /*! * \brief The destructor */ PionSrc::~PionSrc() { // Nothing to do } /*! * \fn PionSrc::setColor( uint color ) * Sets the color of the piece represented by this object. */ void PionSrc::updateMe() { setPixmap( theIconLoader->loadIcon( colorToString( (Color)m_color ), KIcon::Toolbar, icon_res ) ); setFixedSize( pixmap()->size() ); } /*! * The mouse press event handler. */ void PionSrc::mousePressEvent( QMouseEvent* ) { moving = true; } /*! * The mouse release event handler. */ void PionSrc::mouseReleaseEvent( QMouseEvent* ) { moving = false; } /*! * The mousemoveevent handler permit to create * an instance of the class DragPion which will be * drag to a PionSrc object. */ void PionSrc::mouseMoveEvent( QMouseEvent* ) { if ( moving ) { DragPion* d = new DragPion( (uchar)m_color, this, "pion" ); d->setPixmap( *pixmap(), QPoint(12,12) ); d->dragMove(); moving = false; } }