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#ifndef KBBGRAPHICSITEMRAYRESULT_H
31#define KBBGRAPHICSITEMRAYRESULT_H
32
33
34
35class QGraphicsScene;
36class QGraphicsSvgItem;
37
38
39#include "kbbgraphicsitem.h"
40#include "kbbgraphicsitemborder.h"
41#include "kbbitemwithposition.h"
42class KBBScalableGraphicWidget;
43class KBBThemeManager;
44
45
46
47/**
48 * @brief Result of a laser ray shoot in the black box
49 *
50 * There 3 kinds of ray results:
51 * - HIT: if the laser ray hits a ball in the black box by entering at the considered position.
52 * - REFLECTION: if the laser ray exits the black box at the entrance point.
53 * - A number to display both positions where the laser ray entered and exited the black box. Both positions are opposite positions of each other and belong together.
54 */
55class KBBGraphicsItemRayResult : public KBBGraphicsItemBorder, public KBBGraphicsItem, public KBBItemWithPosition
56{
57 public:
58 KBBGraphicsItemRayResult(KBBScalableGraphicWidget* parent, KBBThemeManager* themeManager, QGraphicsScene* scene, const int borderPosition, const int columns, const int rows, const int rayNumber);
59
60
61 /**
62 * @brief Destructor of the class and dependent object
63 * Call this methode to destroy simultaneously this QGraphicsItem and all other dependent QGraphicsItems: The number or the sign.
64 */
65 void cleanDelete();
66
67 /**
68 * @brief Highlight the item
69 *
70 * Usually used when the mouse goes over the item or over the opposite item.
71 */
72 void highlight(bool state);
73
74 /**
75 * @brief Highlight the item and the opposite one
76 */
77 void highlightBoth(bool state);
78
79 /**
80 * @brief Get the border position
81 */
82 int position();
83
84 /**
85 * @brief Define the opposite "ray result" item
86 *
87 * Used if the result is not a HIT and not a REFLECTION. In the other case, the opoosite is the item itself and this method doesn't need to be called.
88 * @param opposite Correspondent item with the same "number".
89 */
90 void setOpposite(KBBGraphicsItemRayResult* opposite);
91
92 /**
93 * @brief Set the pause state
94 */
95 void setPause(bool state);
96
97
98 private:
99 void hoverEnterEvent (QGraphicsSceneHoverEvent*);
100 void hoverLeaveEvent (QGraphicsSceneHoverEvent*);
101
102 QString m_elementIdResultBackground;
103 QString m_elementIdResultBackgroundHighlight;
104 QGraphicsSvgItem* m_notNumber;
105 QGraphicsSimpleTextItem* m_number;
106 KBBGraphicsItemRayResult* m_opposite;
107 bool m_pause;
108 QGraphicsScene* m_scene;
109 KBBScalableGraphicWidget* m_widget;
110};
111
112#endif // KBBGRAPHICSITEMRAYRESULT_H
113