File indexing completed on 2024-11-10 03:44:30

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 #ifndef KBBGRAPHICSITEMONBOX_H
0011 #define KBBGRAPHICSITEMONBOX_H
0012 
0013 
0014 
0015 class QGraphicsScene;
0016 
0017 
0018 #include "kbbgraphicsitem.h"
0019 #include "kbbitemwithposition.h"
0020 class KBBScalableGraphicWidget;
0021 class KBBThemeManager;
0022 
0023 
0024 
0025 /**
0026  * @brief Item on the box on the scalable graphic widget
0027  *
0028  * The item is general and can be a ball or other markers.
0029  */
0030 class KBBGraphicsItemOnBox : public KBBGraphicsItem, public KBBItemWithPosition
0031 {
0032     public:
0033         /**
0034          * @brief Invalid box position
0035          */
0036         static const int NO_POSITION = -1;
0037 
0038 
0039         KBBGraphicsItemOnBox(KBBScalableGraphicWidget::itemType itemType, KBBScalableGraphicWidget* parent, KBBThemeManager* themeManager, const int boxPosition, const int columns, const int rows);
0040         
0041         int position() override;
0042 
0043 
0044     protected:
0045         virtual void removeInteractionInfos();
0046 
0047         KBBScalableGraphicWidget* m_widget;
0048         int m_columns;
0049         int m_rows;
0050 
0051 
0052     private:
0053         int boxPosition(qreal x, qreal y);
0054         bool isMovable();
0055         void mousePressEvent (QGraphicsSceneMouseEvent* event) override;
0056         void mouseReleaseEvent (QGraphicsSceneMouseEvent* event) override;
0057         void setBoxPosition(int boxPosition);
0058         
0059         int m_boxPosition;
0060         qreal m_dragXPos;
0061         qreal m_dragYPos;
0062         qreal m_dragX;
0063         qreal m_dragY;
0064         KBBScalableGraphicWidget::itemType m_itemType;
0065 };
0066 
0067 #endif // KBBGRAPHICSITEMONBOX_H