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

ksquares

GameBoardScene Class Reference

#include <gameboardscene.h>

Inheritance diagram for GameBoardScene:

Inheritance graph
[legend]

List of all members.


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@milliams.com>

Definition at line 26 of file gameboardscene.h.


Public Slots

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

Signals

void lineDrawn (int)

Public Member Functions

 GameBoardScene (int newWidth, int newHeight, QObject *parent=0)
 ~GameBoardScene ()
const QSize minimumSizeHint () const

Protected Member Functions

QList< QGraphicsEllipseItem * > getTwoNearestPoints (const QPointF &pos) const
bool isLineAlready (const QList< QGraphicsEllipseItem * > &pointPair) const
void addLineToIndex (const QList< QGraphicsEllipseItem * > &pointPair)
int indexFromPointPair (const QList< QGraphicsEllipseItem * > &pointPair) const
QGraphicsLineItem * lineFromIndex (int index) const
void mouseReleaseEvent (QGraphicsSceneMouseEvent *mouseEvent)
void mouseMoveEvent (QGraphicsSceneMouseEvent *mouseEvent)

Protected Attributes

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

Constructor & Destructor Documentation

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

Create a new gameboard scene with the appropriate size.

Parameters:
newWidth the number of squares wide the board is
newHeight the number of squares tall the board is
parent passed to QGraphicsScene's constructor

Definition at line 19 of file gameboardscene.cpp.

GameBoardScene::~GameBoardScene (  ) 

Destructor.

Definition at line 74 of file gameboardscene.cpp.


Member Function Documentation

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 206 of file gameboardscene.cpp.

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

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

Parameters:
index the line-index of the line
colour the colour of the line

Definition at line 80 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:
index the square-index of the square
colour the colour fill of the square

Definition at line 91 of file gameboardscene.cpp.

void GameBoardScene::enableEvents (  )  [inline, slot]

disables mouse events

Definition at line 60 of file gameboardscene.h.

void GameBoardScene::disableEvents (  )  [inline, slot]

enables mouse events

Definition at line 62 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:
pos the point in question
Returns:
QList of (hopefully 2) QGraphicsEllipseItem*s

Definition at line 185 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:
pointPair QList of (hopefully 2) QGraphicsEllipseItem*s
Returns:
trur if there is a line there

Definition at line 167 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:
pointPair QList of (hopefully 2) QGraphicsEllipseItem*s

Definition at line 176 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:
pointPair QList of (hopefully 2) QGraphicsEllipseItem*s
Returns:
the line-index

Definition at line 98 of file gameboardscene.cpp.

QGraphicsLineItem * GameBoardScene::lineFromIndex ( int  index  )  const [protected]

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

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

Definition at line 138 of file gameboardscene.cpp.

void GameBoardScene::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  mouseEvent  )  [protected]

Reimplemented from QGraphicsScene.

Definition at line 217 of file gameboardscene.cpp.

void GameBoardScene::mouseMoveEvent ( QGraphicsSceneMouseEvent *  mouseEvent  )  [protected]

Reimplemented from QGraphicsScene.

Definition at line 238 of file gameboardscene.cpp.

void GameBoardScene::lineDrawn ( int   )  [signal]

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


Member Data Documentation

QGraphicsLineItem* GameBoardScene::indicatorLine [protected]

Moves to show where the next line will be drawn.

Definition at line 99 of file gameboardscene.h.

QList<bool> GameBoardScene::lineList [protected]

A local list of lines (non-canon).

Definition at line 102 of file gameboardscene.h.

int GameBoardScene::QGraphicsEllipseItemType [protected]

QGraphicsEllipseItem::type().

Definition at line 105 of file gameboardscene.h.

int GameBoardScene::width [protected]

Width of the board.

Definition at line 107 of file gameboardscene.h.

int GameBoardScene::height [protected]

Height of the board.

Definition at line 109 of file gameboardscene.h.

int GameBoardScene::spacing [protected]

Pixel spacing for standard zoom.

Definition at line 111 of file gameboardscene.h.

bool GameBoardScene::acceptEvents [protected]

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

Definition at line 113 of file gameboardscene.h.


The documentation for this class was generated from the following files:
  • gameboardscene.h
  • gameboardscene.cpp

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