File indexing completed on 2024-04-14 03:59:19
0001 /* 0002 KBlackBox - A simple game inspired by an emacs module 0003 0004 SPDX-FileCopyrightText: 1999-2000 Robert Cimrman <cimrman3@students.zcu.cz> 0005 SPDX-FileCopyrightText: 2007 Nicolas Roffet <nicolas-kde@roffet.com> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 0011 0012 #ifndef KBBGRAPHICSITEMBLACKBOX_H 0013 #define KBBGRAPHICSITEMBLACKBOX_H 0014 0015 0016 class QGraphicsLineItem; 0017 #include <QGraphicsRectItem> 0018 class QGraphicsScene; 0019 class QGraphicsView; 0020 #include <QList> 0021 #include <QPen> 0022 0023 0024 class KBBGraphicsItem; 0025 #include "kbbscalablegraphicwidget.h" 0026 #include <QObject> 0027 0028 0029 /** 0030 * @brief The black box in the scalable graphic widget 0031 */ 0032 class KBBGraphicsItemBlackBox : public QObject, public QGraphicsRectItem 0033 { 0034 Q_OBJECT 0035 public: 0036 /** 0037 * @brief Constructor 0038 */ 0039 KBBGraphicsItemBlackBox(QGraphicsView* parent, QGraphicsScene* scene, KBBThemeManager* themeManager, bool isPreview); 0040 0041 0042 /** 0043 * @brief Set the KBBScalableGraphicWidget 0044 */ 0045 void setKBBScalableGraphicWidget(KBBScalableGraphicWidget* w); 0046 0047 /** 0048 * @brief Define the (new) size of the black box 0049 * 0050 * Used to "recycle" the black box for a new game. 0051 */ 0052 void setSize(const int columns, const int rows); 0053 0054 0055 private: 0056 void mousePressEvent (QGraphicsSceneMouseEvent* event) override; 0057 void hoverMoveEvent (QGraphicsSceneHoverEvent* event) override; 0058 void hoverLeaveEvent (QGraphicsSceneHoverEvent* event) override; 0059 0060 KBBGraphicsItem* m_background; 0061 int m_columns; 0062 QList<QGraphicsLineItem*> m_lines; 0063 QPen m_penLines; 0064 int m_rows; 0065 QGraphicsScene* m_scene; 0066 KBBScalableGraphicWidget* m_widget; 0067 int m_zValueLines; 0068 public: 0069 Q_SIGNALS: 0070 void hoverMoved(int); 0071 }; 0072 0073 #endif // KBBGRAPHICSITEMBLACKBOX_H