• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

ksquares

gameboardscene.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Matthew Williams    <matt@milliams.com>         *
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU General Public License as published by  *
00006  *   the Free Software Foundation; either version 2 of the License, or     *
00007  *   (at your option) any later version.                                   *
00008  ***************************************************************************/
00009 
00010 #ifndef GAMEBOARDSCENE_H
00011 #define GAMEBOARDSCENE_H
00012 
00013 #include <QGraphicsScene>
00014 
00015 class QGraphicsEllipseItem;
00016 
00026 class GameBoardScene : public QGraphicsScene
00027 {
00028     Q_OBJECT
00029     
00030     public:
00037         GameBoardScene(int newWidth, int newHeight, QObject *parent = 0);
00039         ~GameBoardScene();
00044         const QSize minimumSizeHint() const;
00045         
00046     public slots:
00052         void drawLine(int index, const QColor &colour);
00058         void drawSquare(int index, const QColor &colour);
00060         void enableEvents() {acceptEvents = true;}
00062         void disableEvents() {acceptEvents = false;}
00063         
00064     protected:
00070         QList<QGraphicsEllipseItem*> getTwoNearestPoints(const QPointF &pos) const;
00071         
00077         bool isLineAlready(const QList<QGraphicsEllipseItem*> &pointPair) const;
00082         void addLineToIndex(const QList<QGraphicsEllipseItem*> &pointPair);
00083         
00084         //conversion functions
00090         int indexFromPointPair(const QList<QGraphicsEllipseItem*> &pointPair) const;    //given a pointPair, returns the index of the line between them. If not a valid line, returns -1
00096         QGraphicsLineItem* lineFromIndex(int index) const;  //all external calls will need to be passed through this to convert to local coords
00097         
00099         QGraphicsLineItem* indicatorLine;
00100         
00102         QList<bool> lineList;   //Just kept in sync with the KSquaresGame one
00103         
00105         int QGraphicsEllipseItemType;
00107         int width;
00109         int height;
00111         int spacing;
00113         bool acceptEvents;
00114         
00115         //event handlers
00116         //void mousePressEvent (QGraphicsSceneMouseEvent* mouseEvent);
00117         void mouseReleaseEvent (QGraphicsSceneMouseEvent* mouseEvent);
00118         void mouseMoveEvent (QGraphicsSceneMouseEvent* mouseEvent);
00119         
00120     signals:
00122         void lineDrawn(int);
00123 };
00124 
00125 #endif // GAMEBOARDSCENE_H

ksquares

Skip menu "ksquares"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • kblackbox
  • kgoldrunner
  • kmahjongg
  • ksquares
  • libkdegames
  •   highscore
  •   kgame
  •   kggzgames
  •   kggzmod
  •   kggznet
  • libkmahjongg
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal