1 /*********************************************************************** 2 * 3 * Copyright (C) 2009 Graeme Gott <graeme@gottcode.org> 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 ***********************************************************************/ 19 20 #ifndef LETTER_H 21 #define LETTER_H 22 23 #include <QGraphicsPathItem> 24 class QGraphicsSimpleTextItem; 25 class Board; 26 class Cell; 27 28 class Letter : public QGraphicsPathItem { 29 public: 30 Letter(const QChar& character, Board* board); 31 character()32 QChar character() const { 33 return m_character; 34 } 35 isMovable()36 bool isMovable() const { 37 return m_movable; 38 } 39 40 void setCell(Cell* cell); 41 void setCorrect(); 42 void setHighlight(bool highlight = true); 43 void setJoin(); 44 void setPaused(bool paused); 45 46 protected: 47 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event); 48 virtual void mousePressEvent(QGraphicsSceneMouseEvent* event); 49 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event); 50 51 private: 52 void setText(const QChar& character); 53 54 private: 55 Board* m_board; 56 QChar m_character; 57 Cell* m_cell; 58 bool m_correct; 59 bool m_movable; 60 bool m_dragged; 61 QGraphicsSimpleTextItem* m_text; 62 QGraphicsPathItem* m_shadow; 63 }; 64 65 #endif 66