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

kblackbox

  • sources
  • kde-4.14
  • kdegames
  • kblackbox
kbbscalablegraphicwidget.h
Go to the documentation of this file.
1 //
2 // KBlackBox
3 //
4 // A simple game inspired by an emacs module
5 //
6 /***************************************************************************
7  * Copyright (c) 1999-2000, Robert Cimrman *
8  * cimrman3@students.zcu.cz *
9  * *
10  * Copyright (c) 2007, Nicolas Roffet *
11  * nicolas-kde@roffet.com *
12  * *
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * *
19  * This program is distributed in the hope that it will be useful, *
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22  * GNU General Public License for more details. *
23  * *
24  * You should have received a copy of the GNU General Public License *
25  * along with this program; if not, write to the *
26  * Free Software Foundation, Inc., *
27  * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA *
28  ***************************************************************************/
29 
30 
31 
32 #ifndef KBBSCALABLEGRAPHICWIDGET_H
33 #define KBBSCALABLEGRAPHICWIDGET_H
34 
35 
36 class QAction;
37 class QGraphicsScene;
38 #include <QGraphicsView>
39 class QLCDNumber;
40 class QResizeEvent;
41 
42 
43 class KGamePopupItem;
44 class KPushButton;
45 
46 
47 class KBBBallsOnBoard;
48 class KBBGameDoc;
49 class KBBGraphicsItem;
50 class KBBGraphicsItemBallRepository;
51 class KBBGraphicsItemBlackBox;
52 class KBBGraphicsItemCursor;
53 class KBBGraphicsItemRay;
54 class KBBGraphicsItemSet;
55 class KBBThemeManager;
56 
57 
58 
62 class KBBScalableGraphicWidget : public QGraphicsView
63 {
64  Q_OBJECT
65 
66  public:
74  static int const BORDER_SIZE = 50;
75 
81  static int const RATIO = 25;
82 
89  enum itemType {
90  background=0,
91  informationBackground=1,
92  blackbox=2,
93  blackboxGrid=3,
94  tutorialMarker=4,
95  markerNothing=5,
96  solutionRay=6,
97  playerRay=7,
98  resultBackground=8,
99  resultBackgroundHighlight=9,
100  resultReflection=10,
101  resultHit=11,
102  resultText=12,
103  solutionBall=13,
104  playerBall=14,
105  unsureBall=15,
106  wrongPlayerBall=16,
107  rightPlayerBall=17,
108  interactionInfoDeflection=18,
109  interactionInfoHit=19,
110  interactionInfoNothing=20,
111  interactionInfoReflection=21,
112  interactionInfoReflectionSym=22,
113  laser0=23,
114  laser90=24,
115  laser180=25,
116  laser270=26,
117  cursor=27
118  };
119 
120 
124  explicit KBBScalableGraphicWidget(KBBGameDoc* gameDoc, KBBThemeManager* themeManager, QAction* done);
125  ~KBBScalableGraphicWidget();
126 
127 
128  void addBall(int boxPosition);
129  void addBall(int boxPosition, int outsidePosition);
130  void addBallUnsure(const int boxPosition);
131  void addMarkerNothing(const int boxPosition);
132  void drawRay(const int borderPosition);
133  void mouseBorderClick(const int borderPosition);
134  void mouseBoxClick(const Qt::MouseButton button, int boxPosition);
135  int moveBall(const int boxPositionFrom, const int boxPositionTo);
136  int moveMarkerNothing(const int boxPositionFrom, const int boxPositionTo);
137  void newGame(int columns, int rows, int ballNumber);
138 
145  void popupText(const QString& text, int time = 5000);
146 
147  int positionAfterMovingBall(const int boxPositionFrom, const int boxPositionTo) const;
148 
149  void setPause(bool state);
150  void removeAllBalls();
151  void removeBall(const int boxPosition);
152  void removeRay();
153  void resizeEvent(QResizeEvent*);
154  QGraphicsScene* scene();
155  void setScore(int score);
156 
163  void solve(const bool continueGame);
164 
165 
166  public slots:
167  void cursorAtNewPosition(int borderPosition);
168  void keyboardEnter();
169  void keyboardMoveDown();
170  void keyboardMoveLeft();
171  void keyboardMoveRight();
172  void keyboardMoveUp();
173  void keyboardSpace();
174 
175 
176  protected:
177  void drawBackground(QPainter* painter, const QRectF&);
178 
179 
180  private:
186  static int const MINIMUM_SIZE = 250;
187 
188  static int const OFFSET_DONE_BUTTON = 12;
189 
190  void fillBallsOutside();
191  void removeMarkerNothing(const int boxPosition);
192  void setBallUnsure(const int boxPosition, const bool unsure);
193  void setInputAccepted(bool inputAccepted);
194  void switchBall();
195  void switchMarker();
196  void updateDoneButton();
197  void useLaser(const int incomingPosition);
198 
199 
200  // Graphics items
201  KBBGraphicsItemBlackBox* m_blackbox;
202  KBBGraphicsItemSet* m_balls;
203  KBBGraphicsItemSet* m_ballsSolution;
204  KBBGraphicsItemSet* m_ballsUnsure;
205  KBBGraphicsItemCursor* m_cursor;
206  KBBGraphicsItemBallRepository* m_ballRepository;
207  KBBGraphicsItemSet* m_lasers;
208  KBBGraphicsItemSet* m_markersNothing;
209  KBBGraphicsItemSet* m_rayResults;
210  KBBGraphicsItemRay* m_playerRay;
211  KBBGraphicsItemRay* m_solutionRay;
212 
213 
220  QRectF m_rectBackground;
221 
222  // Various member variables
223  int m_ballNumber;
224  KBBBallsOnBoard* m_boardBalls;
225  KBBBallsOnBoard* m_boardBallsPlaced;
226  int m_columns;
227  QAction* m_doneAction;
228  KPushButton* m_doneButton;
229  KBBGameDoc* m_gameDoc;
230  KGamePopupItem* m_infoScore;
231  bool m_inputAccepted;
232  bool m_pause;
233  int m_rayNumber;
234 
235  int m_rows;
236  QGraphicsScene* m_scene; //TODO: Remove it because scene() already gives it back.
237  QLCDNumber* m_score;
238  KBBThemeManager* m_themeManager;
239 };
240 
241 #endif // KBBSCALABLEGRAPHICWIDGET_H
KBBScalableGraphicWidget::solutionBall
Definition: kbbscalablegraphicwidget.h:103
QResizeEvent
KBBScalableGraphicWidget::mouseBorderClick
void mouseBorderClick(const int borderPosition)
Definition: kbbscalablegraphicwidget.cpp:202
KBBScalableGraphicWidget::addMarkerNothing
void addMarkerNothing(const int boxPosition)
Definition: kbbscalablegraphicwidget.cpp:180
KBBScalableGraphicWidget::laser180
Definition: kbbscalablegraphicwidget.h:115
QGraphicsScene
KBBScalableGraphicWidget::drawBackground
void drawBackground(QPainter *painter, const QRectF &)
Definition: kbbscalablegraphicwidget.cpp:493
KBBScalableGraphicWidget::removeRay
void removeRay()
Definition: kbbscalablegraphicwidget.cpp:372
QWidget::cursor
QCursor cursor() const
KBBScalableGraphicWidget::moveBall
int moveBall(const int boxPositionFrom, const int boxPositionTo)
Definition: kbbscalablegraphicwidget.cpp:221
KBBGraphicsItem
Graphic item of the scalable graphic widget.
Definition: kbbgraphicsitem.h:44
KBBScalableGraphicWidget::keyboardMoveUp
void keyboardMoveUp()
Definition: kbbscalablegraphicwidget.cpp:470
KBBScalableGraphicWidget::scene
QGraphicsScene * scene()
Definition: kbbscalablegraphicwidget.cpp:379
KBBGraphicsItemSet
Set of graphic items with positions.
Definition: kbbgraphicsitemset.h:46
KBBScalableGraphicWidget::keyboardMoveDown
void keyboardMoveDown()
Definition: kbbscalablegraphicwidget.cpp:446
KBBScalableGraphicWidget::interactionInfoReflection
Definition: kbbscalablegraphicwidget.h:111
KBBScalableGraphicWidget
Scalable graphic central widget for KBlackBox.
Definition: kbbscalablegraphicwidget.h:62
KBBScalableGraphicWidget::resizeEvent
void resizeEvent(QResizeEvent *)
Definition: kbbscalablegraphicwidget.cpp:324
KBBScalableGraphicWidget::cursorAtNewPosition
void cursorAtNewPosition(int borderPosition)
Definition: kbbscalablegraphicwidget.cpp:417
KBBGraphicsItemBlackBox
The black box in the scalable graphic widget.
Definition: kbbgraphicsitemblackbox.h:52
KBBScalableGraphicWidget::addBallUnsure
void addBallUnsure(const int boxPosition)
Definition: kbbscalablegraphicwidget.cpp:173
KBBScalableGraphicWidget::markerNothing
Definition: kbbscalablegraphicwidget.h:95
KBBScalableGraphicWidget::setScore
void setScore(int score)
Definition: kbbscalablegraphicwidget.cpp:385
KBBScalableGraphicWidget::playerBall
Definition: kbbscalablegraphicwidget.h:104
KBBScalableGraphicWidget::resultBackground
Definition: kbbscalablegraphicwidget.h:98
KBBScalableGraphicWidget::moveMarkerNothing
int moveMarkerNothing(const int boxPositionFrom, const int boxPositionTo)
Definition: kbbscalablegraphicwidget.cpp:241
KBBGameDoc
Game document (Logical board)
Definition: kbbgamedoc.h:56
KBBScalableGraphicWidget::drawRay
void drawRay(const int borderPosition)
Definition: kbbscalablegraphicwidget.cpp:191
KBBScalableGraphicWidget::solutionRay
Definition: kbbscalablegraphicwidget.h:96
KBBScalableGraphicWidget::informationBackground
Definition: kbbscalablegraphicwidget.h:91
KBBGraphicsItemRay
Ray on the scalable graphic widget of KBlackBox.
Definition: kbbgraphicsitemray.h:52
KBBScalableGraphicWidget::interactionInfoHit
Definition: kbbscalablegraphicwidget.h:109
KBBScalableGraphicWidget::unsureBall
Definition: kbbscalablegraphicwidget.h:105
KBBScalableGraphicWidget::KBBScalableGraphicWidget
KBBScalableGraphicWidget(KBBGameDoc *gameDoc, KBBThemeManager *themeManager, QAction *done)
Constructor.
Definition: kbbscalablegraphicwidget.cpp:67
QPainter
KBBScalableGraphicWidget::tutorialMarker
Definition: kbbscalablegraphicwidget.h:94
KBBScalableGraphicWidget::rightPlayerBall
Definition: kbbscalablegraphicwidget.h:107
KBBScalableGraphicWidget::BORDER_SIZE
static int const BORDER_SIZE
Distance between the black box and the widget border.
Definition: kbbscalablegraphicwidget.h:74
KBBScalableGraphicWidget::keyboardMoveLeft
void keyboardMoveLeft()
Definition: kbbscalablegraphicwidget.cpp:454
KBBScalableGraphicWidget::playerRay
Definition: kbbscalablegraphicwidget.h:97
QString
KBBScalableGraphicWidget::setPause
void setPause(bool state)
Definition: kbbscalablegraphicwidget.cpp:312
KBBScalableGraphicWidget::popupText
void popupText(const QString &text, int time=5000)
Message to display.
Definition: kbbscalablegraphicwidget.cpp:292
KBBScalableGraphicWidget::positionAfterMovingBall
int positionAfterMovingBall(const int boxPositionFrom, const int boxPositionTo) const
Definition: kbbscalablegraphicwidget.cpp:303
KBBScalableGraphicWidget::blackbox
Definition: kbbscalablegraphicwidget.h:92
KBBScalableGraphicWidget::mouseBoxClick
void mouseBoxClick(const Qt::MouseButton button, int boxPosition)
Definition: kbbscalablegraphicwidget.cpp:210
KBBScalableGraphicWidget::resultText
Definition: kbbscalablegraphicwidget.h:102
KBBGraphicsItemCursor
"Cursor" on the scalable graphic widget
Definition: kbbgraphicsitemcursor.h:44
KBBScalableGraphicWidget::blackboxGrid
Definition: kbbscalablegraphicwidget.h:93
KBBScalableGraphicWidget::interactionInfoNothing
Definition: kbbscalablegraphicwidget.h:110
KBBScalableGraphicWidget::resultHit
Definition: kbbscalablegraphicwidget.h:101
KBBScalableGraphicWidget::laser90
Definition: kbbscalablegraphicwidget.h:114
KBBScalableGraphicWidget::interactionInfoDeflection
Definition: kbbscalablegraphicwidget.h:108
KBBScalableGraphicWidget::removeAllBalls
void removeAllBalls()
Definition: kbbscalablegraphicwidget.cpp:351
KBBScalableGraphicWidget::interactionInfoReflectionSym
Definition: kbbscalablegraphicwidget.h:112
KBBScalableGraphicWidget::keyboardEnter
void keyboardEnter()
Definition: kbbscalablegraphicwidget.cpp:434
QRectF
KBBScalableGraphicWidget::RATIO
static int const RATIO
Width and height of a single square on the black box.
Definition: kbbscalablegraphicwidget.h:81
QAction
KBBScalableGraphicWidget::keyboardSpace
void keyboardSpace()
Definition: kbbscalablegraphicwidget.cpp:478
KBBScalableGraphicWidget::~KBBScalableGraphicWidget
~KBBScalableGraphicWidget()
Definition: kbbscalablegraphicwidget.cpp:130
KBBScalableGraphicWidget::keyboardMoveRight
void keyboardMoveRight()
Definition: kbbscalablegraphicwidget.cpp:462
KBBScalableGraphicWidget::addBall
void addBall(int boxPosition)
Definition: kbbscalablegraphicwidget.cpp:150
QLCDNumber
KBBGraphicsItemBallRepository
The balls the player has to place.
Definition: kbbgraphicsitemballrepository.h:45
KBBThemeManager
Theme manager of the scalable graphic widget.
Definition: kbbthememanager.h:51
KBBScalableGraphicWidget::solve
void solve(const bool continueGame)
display the solution
Definition: kbbscalablegraphicwidget.cpp:391
KBBScalableGraphicWidget::laser270
Definition: kbbscalablegraphicwidget.h:116
KBBScalableGraphicWidget::newGame
void newGame(int columns, int rows, int ballNumber)
Definition: kbbscalablegraphicwidget.cpp:251
KBBScalableGraphicWidget::background
Definition: kbbscalablegraphicwidget.h:90
QGraphicsView
KBBScalableGraphicWidget::resultBackgroundHighlight
Definition: kbbscalablegraphicwidget.h:99
KBBScalableGraphicWidget::laser0
Definition: kbbscalablegraphicwidget.h:113
KBBScalableGraphicWidget::resultReflection
Definition: kbbscalablegraphicwidget.h:100
KBBScalableGraphicWidget::itemType
itemType
Every graphic items.
Definition: kbbscalablegraphicwidget.h:89
KBBScalableGraphicWidget::wrongPlayerBall
Definition: kbbscalablegraphicwidget.h:106
KBBBallsOnBoard
Set of balls (or various objects) with positions on the board.
Definition: kbbballsonboard.h:62
KBBScalableGraphicWidget::removeBall
void removeBall(const int boxPosition)
Definition: kbbscalablegraphicwidget.cpp:359
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kblackbox

Skip menu "kblackbox"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

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