• Skip to content
  • Skip to link menu
KDE 4.2 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 class msg;
00017 
00027 class GameBoardScene : public QGraphicsScene
00028 {
00029     Q_OBJECT
00030     
00031     public:
00038         GameBoardScene(int newWidth, int newHeight, QObject *parent = 0);
00040         ~GameBoardScene();
00045         const QSize minimumSizeHint() const;
00046 
00047         void acknowledgeMove(int x1, int y1, int x2, int y2);
00048         
00049     public slots:
00055         void drawLine(int index, const QColor &colour);
00060         void highlightLine(int index);
00066         void drawSquare(int index, const QColor &colour);
00068         void enableEvents() {acceptEvents = true;}
00070         void disableEvents() {acceptEvents = false;}
00071         
00072     protected:
00078         QList<QGraphicsEllipseItem*> getTwoNearestPoints(const QPointF &pos) const;
00079         
00085         bool isLineAlready(const QList<QGraphicsEllipseItem*> &pointPair) const;
00090         void addLineToIndex(const QList<QGraphicsEllipseItem*> &pointPair);
00091         
00092         //conversion functions
00098         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
00104         QLineF lineFromIndex(int index) const;  //all external calls will need to be passed through this to convert to local coords
00105         
00107         QGraphicsLineItem* indicatorLine;
00108         
00110         QList<bool> lineList;   //Just kept in sync with the KSquaresGame one
00111         
00113         int QGraphicsEllipseItemType;
00115         int width;
00117         int height;
00119         int spacing;
00121         bool acceptEvents;
00122         
00123         //event handlers
00124         //void mousePressEvent (QGraphicsSceneMouseEvent* mouseEvent);
00125         void mouseReleaseEvent (QGraphicsSceneMouseEvent* mouseEvent);
00126         void mouseMoveEvent (QGraphicsSceneMouseEvent* mouseEvent);
00127         
00128     signals:
00130         void lineDrawn(int);
00132         void signalMoveRequest(int x1, int y1, int x2, int y2);
00133 };
00134 
00135 #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