• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

ksquares

Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GameBoardScene Class Reference

#include <gameboardscene.h>

Inheritance diagram for GameBoardScene:
Inheritance graph
[legend]

Public Slots

void disableEvents ()
 
void drawLine (int index, const QColor &colour)
 
void drawSquare (int index, const QColor &colour)
 
void enableEvents ()
 
void highlightLine (int index)
 

Signals

void lineDrawn (int)
 

Public Member Functions

 GameBoardScene (int newWidth, int newHeight, QObject *parent=0)
 
 ~GameBoardScene ()
 
void acknowledgeMove (int x1, int y1, int x2, int y2)
 
const QSize minimumSizeHint () const
 
- Public Member Functions inherited from QGraphicsScene
 QGraphicsScene (QObject *parent)
 
 QGraphicsScene (const QRectF &sceneRect, QObject *parent)
 
 QGraphicsScene (qreal x, qreal y, qreal width, qreal height, QObject *parent)
 
virtual  ~QGraphicsScene ()
 
QGraphicsItem * activePanel () const
 
QGraphicsWidget * activeWindow () const
 
QGraphicsEllipseItem * addEllipse (const QRectF &rect, const QPen &pen, const QBrush &brush)
 
QGraphicsEllipseItem * addEllipse (qreal x, qreal y, qreal w, qreal h, const QPen &pen, const QBrush &brush)
 
void addItem (QGraphicsItem *item)
 
QGraphicsLineItem * addLine (const QLineF &line, const QPen &pen)
 
QGraphicsLineItem * addLine (qreal x1, qreal y1, qreal x2, qreal y2, const QPen &pen)
 
QGraphicsPathItem * addPath (const QPainterPath &path, const QPen &pen, const QBrush &brush)
 
QGraphicsPixmapItem * addPixmap (const QPixmap &pixmap)
 
QGraphicsPolygonItem * addPolygon (const QPolygonF &polygon, const QPen &pen, const QBrush &brush)
 
QGraphicsRectItem * addRect (const QRectF &rect, const QPen &pen, const QBrush &brush)
 
QGraphicsRectItem * addRect (qreal x, qreal y, qreal w, qreal h, const QPen &pen, const QBrush &brush)
 
QGraphicsSimpleTextItem * addSimpleText (const QString &text, const QFont &font)
 
QGraphicsTextItem * addText (const QString &text, const QFont &font)
 
QGraphicsProxyWidget * addWidget (QWidget *widget, QFlags< Qt::WindowType > wFlags)
 
void advance ()
 
QBrush backgroundBrush () const
 
int bspTreeDepth () const
 
void changed (const QList< QRectF > &region)
 
void clear ()
 
void clearFocus ()
 
void clearSelection ()
 
QList< QGraphicsItem * > collidingItems (const QGraphicsItem *item, Qt::ItemSelectionMode mode) const
 
QGraphicsItemGroup * createItemGroup (const QList< QGraphicsItem * > &items)
 
void destroyItemGroup (QGraphicsItemGroup *group)
 
QGraphicsItem * focusItem () const
 
QFont font () const
 
QBrush foregroundBrush () const
 
bool hasFocus () const
 
qreal height () const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const
 
void invalidate (qreal x, qreal y, qreal w, qreal h, QFlags< QGraphicsScene::SceneLayer > layers)
 
void invalidate (const QRectF &rect, QFlags< QGraphicsScene::SceneLayer > layers)
 
bool isActive () const
 
bool isSortCacheEnabled () const
 
QGraphicsItem * itemAt (qreal x, qreal y) const
 
QGraphicsItem * itemAt (qreal x, qreal y, const QTransform &deviceTransform) const
 
QGraphicsItem * itemAt (const QPointF &position) const
 
QGraphicsItem * itemAt (const QPointF &position, const QTransform &deviceTransform) const
 
ItemIndexMethod itemIndexMethod () const
 
QList< QGraphicsItem * > items (qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const
 
QList< QGraphicsItem * > items () const
 
QList< QGraphicsItem * > items (Qt::SortOrder order) const
 
QList< QGraphicsItem * > items (const QPointF &pos, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const
 
QList< QGraphicsItem * > items (const QPolygonF &polygon, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const
 
QList< QGraphicsItem * > items (const QRectF &rect, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const
 
QList< QGraphicsItem * > items (const QPainterPath &path, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const
 
QList< QGraphicsItem * > items (const QPointF &pos) const
 
QList< QGraphicsItem * > items (const QRectF &rectangle, Qt::ItemSelectionMode mode) const
 
QList< QGraphicsItem * > items (const QPolygonF &polygon, Qt::ItemSelectionMode mode) const
 
QList< QGraphicsItem * > items (const QPainterPath &path, Qt::ItemSelectionMode mode) const
 
QList< QGraphicsItem * > items (qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode) const
 
QRectF itemsBoundingRect () const
 
QGraphicsItem * mouseGrabberItem () const
 
QPalette palette () const
 
void removeItem (QGraphicsItem *item)
 
void render (QPainter *painter, const QRectF &target, const QRectF &source, Qt::AspectRatioMode aspectRatioMode)
 
QRectF sceneRect () const
 
void sceneRectChanged (const QRectF &rect)
 
QList< QGraphicsItem * > selectedItems () const
 
QPainterPath selectionArea () const
 
void selectionChanged ()
 
bool sendEvent (QGraphicsItem *item, QEvent *event)
 
void setActivePanel (QGraphicsItem *item)
 
void setActiveWindow (QGraphicsWidget *widget)
 
void setBackgroundBrush (const QBrush &brush)
 
void setBspTreeDepth (int depth)
 
void setFocus (Qt::FocusReason focusReason)
 
void setFocusItem (QGraphicsItem *item, Qt::FocusReason focusReason)
 
void setFont (const QFont &font)
 
void setForegroundBrush (const QBrush &brush)
 
void setItemIndexMethod (ItemIndexMethod method)
 
void setPalette (const QPalette &palette)
 
void setSceneRect (qreal x, qreal y, qreal w, qreal h)
 
void setSceneRect (const QRectF &rect)
 
void setSelectionArea (const QPainterPath &path, const QTransform &deviceTransform)
 
void setSelectionArea (const QPainterPath &path)
 
void setSelectionArea (const QPainterPath &path, Qt::ItemSelectionMode mode, const QTransform &deviceTransform)
 
void setSelectionArea (const QPainterPath &path, Qt::ItemSelectionMode mode)
 
void setSortCacheEnabled (bool enabled)
 
void setStickyFocus (bool enabled)
 
void setStyle (QStyle *style)
 
bool stickyFocus () const
 
QStyle * style () const
 
void update (const QRectF &rect)
 
void update (qreal x, qreal y, qreal w, qreal h)
 
QList< QGraphicsView * > views () const
 
qreal width () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
virtual  ~QObject ()
 
bool blockSignals (bool block)
 
QObject * child (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const QObject *receiver, const char *method)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArray > dynamicPropertyNames () const
 
T findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObject * metaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObject * parent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThread * thread () const
 

Protected Member Functions

void addLineToIndex (const QList< QGraphicsEllipseItem * > &pointPair)
 
QList< QGraphicsEllipseItem * > getTwoNearestPoints (const QPointF &pos) const
 
int indexFromPointPair (const QList< QGraphicsEllipseItem * > &pointPair) const
 
bool isLineAlready (const QList< QGraphicsEllipseItem * > &pointPair) const
 
QLineF lineFromIndex (int index) const
 
void mouseMoveEvent (QGraphicsSceneMouseEvent *mouseEvent)
 
void mouseReleaseEvent (QGraphicsSceneMouseEvent *mouseEvent)
 
- Protected Member Functions inherited from QGraphicsScene
virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *contextMenuEvent)
 
virtual void dragEnterEvent (QGraphicsSceneDragDropEvent *event)
 
virtual void dragLeaveEvent (QGraphicsSceneDragDropEvent *event)
 
virtual void dragMoveEvent (QGraphicsSceneDragDropEvent *event)
 
virtual void drawBackground (QPainter *painter, const QRectF &rect)
 
virtual void drawForeground (QPainter *painter, const QRectF &rect)
 
virtual void drawItems (QPainter *painter, int numItems, QGraphicsItem *[] items, const QStyleOptionGraphicsItem[] options, QWidget *widget)
 
virtual void dropEvent (QGraphicsSceneDragDropEvent *event)
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
virtual void focusInEvent (QFocusEvent *focusEvent)
 
bool focusNextPrevChild (bool next)
 
virtual void focusOutEvent (QFocusEvent *focusEvent)
 
virtual void helpEvent (QGraphicsSceneHelpEvent *helpEvent)
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 
virtual void keyPressEvent (QKeyEvent *keyEvent)
 
virtual void keyReleaseEvent (QKeyEvent *keyEvent)
 
virtual void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *mouseEvent)
 
virtual void mousePressEvent (QGraphicsSceneMouseEvent *mouseEvent)
 
virtual void wheelEvent (QGraphicsSceneWheelEvent *wheelEvent)
 
- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Protected Attributes

bool acceptEvents
 
int height
 
QGraphicsLineItem * indicatorLine
 
QList< bool > lineList
 
int QGraphicsEllipseItemType
 
int spacing
 
int width
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QGraphicsScene
typedef SceneLayers
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 
- Properties inherited from QGraphicsScene
 backgroundBrush
 
 bspTreeDepth
 
 font
 
 foregroundBrush
 
 itemIndexMethod
 
 palette
 
 sceneRect
 
 sortCacheEnabled
 
 stickyFocus
 
- Properties inherited from QObject
 objectName
 

Detailed Description

Scene for displaying the game board.

Created anew at the beginning of each game. Contains the visual representation of the board. Is used to interperet mouse clicks from the user (if the view is unlocked) Contains QGraphicsLineItems for lines, QGraphicsEllipseItems for the dots and QGraphicsRectItem for when a square is complete.

Author
Matt Williams matt@.nosp@m.mill.nosp@m.iams..nosp@m.com

Definition at line 27 of file gameboardscene.h.

Constructor & Destructor Documentation

GameBoardScene::GameBoardScene ( int  newWidth,
int  newHeight,
QObject *  parent = 0 
)

Create a new gameboard scene with the appropriate size.

Parameters
newWidththe number of squares wide the board is
newHeightthe number of squares tall the board is
parentpassed to QGraphicsScene's constructor

Definition at line 21 of file gameboardscene.cpp.

GameBoardScene::~GameBoardScene ( )

Destructor.

Definition at line 76 of file gameboardscene.cpp.

Member Function Documentation

void GameBoardScene::acknowledgeMove ( int  x1,
int  y1,
int  x2,
int  y2 
)

Definition at line 247 of file gameboardscene.cpp.

void GameBoardScene::addLineToIndex ( const QList< QGraphicsEllipseItem * > &  pointPair)
protected

Adds the line to the index for a specified pair of points.

Parameters
pointPairQList of (hopefully 2) QGraphicsEllipseItem*s

Definition at line 185 of file gameboardscene.cpp.

void GameBoardScene::disableEvents ( )
inlineslot

enables mouse events

Definition at line 70 of file gameboardscene.h.

void GameBoardScene::drawLine ( int  index,
const QColor &  colour 
)
slot

Add the line to the scene so it shows up in the view.

Parameters
indexthe line-index of the line
colourthe colour of the line

Definition at line 82 of file gameboardscene.cpp.

void GameBoardScene::drawSquare ( int  index,
const QColor &  colour 
)
slot

Fill a box to show it is owned be a particular player.

Parameters
indexthe square-index of the square
colourthe colour fill of the square

Definition at line 100 of file gameboardscene.cpp.

void GameBoardScene::enableEvents ( )
inlineslot

disables mouse events

Definition at line 68 of file gameboardscene.h.

QList< QGraphicsEllipseItem * > GameBoardScene::getTwoNearestPoints ( const QPointF &  pos) const
protected

Given a single location in the scene, gives the two nearest QGraphicsEllipseItem.

Parameters
posthe point in question
Returns
QList of (hopefully 2) QGraphicsEllipseItem*s

Definition at line 194 of file gameboardscene.cpp.

void GameBoardScene::highlightLine ( int  index)
slot

Draw a temporary halo behind a line.

Parameters
indexthe line-index of the line

Definition at line 93 of file gameboardscene.cpp.

int GameBoardScene::indexFromPointPair ( const QList< QGraphicsEllipseItem * > &  pointPair) const
protected

Takes a pair of QGraphicsEllipseItems and finds the index that relates to the line that's between them.

Parameters
pointPairQList of (hopefully 2) QGraphicsEllipseItem*s
Returns
the line-index

Definition at line 107 of file gameboardscene.cpp.

bool GameBoardScene::isLineAlready ( const QList< QGraphicsEllipseItem * > &  pointPair) const
protected

Given a pair of points, returns whether there is already a line there.

Parameters
pointPairQList of (hopefully 2) QGraphicsEllipseItem*s
Returns
trur if there is a line there

Definition at line 176 of file gameboardscene.cpp.

void GameBoardScene::lineDrawn ( int  )
signal

Emits the index of the closet (undrawn) line when a click is detected.

QLineF GameBoardScene::lineFromIndex ( int  index) const
protected

Takes a line-index and returns a QLineF located at that position.

Parameters
indexthe line-index
Returns
line located at the correct position

Definition at line 147 of file gameboardscene.cpp.

const QSize GameBoardScene::minimumSizeHint ( ) const

The smallest the view can be when 'auto-zoom' is off.

Returns
the minimum size the view should be

Definition at line 215 of file gameboardscene.cpp.

void GameBoardScene::mouseMoveEvent ( QGraphicsSceneMouseEvent *  mouseEvent)
protectedvirtual

Reimplemented from QGraphicsScene.

Definition at line 254 of file gameboardscene.cpp.

void GameBoardScene::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  mouseEvent)
protectedvirtual

Reimplemented from QGraphicsScene.

Definition at line 226 of file gameboardscene.cpp.

Member Data Documentation

bool GameBoardScene::acceptEvents
protected

This property holds whether mouse events are enabled for this widget.

Definition at line 121 of file gameboardscene.h.

int GameBoardScene::height
protected

Height of the board.

Definition at line 117 of file gameboardscene.h.

QGraphicsLineItem* GameBoardScene::indicatorLine
protected

Moves to show where the next line will be drawn.

Definition at line 107 of file gameboardscene.h.

QList<bool> GameBoardScene::lineList
protected

A local list of lines (non-canon)

Definition at line 110 of file gameboardscene.h.

int GameBoardScene::QGraphicsEllipseItemType
protected

QGraphicsEllipseItem::type()

Definition at line 113 of file gameboardscene.h.

int GameBoardScene::spacing
protected

Pixel spacing for standard zoom.

Definition at line 119 of file gameboardscene.h.

int GameBoardScene::width
protected

Width of the board.

Definition at line 115 of file gameboardscene.h.


The documentation for this class was generated from the following files:
  • gameboardscene.h
  • gameboardscene.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

ksquares

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

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal