File indexing completed on 2024-05-19 07:52:02
0001 /* 0002 This file is part of the game 'KJumpingCube' 0003 0004 SPDX-FileCopyrightText: 1998-2000 Matthias Kiefer <matthias.kiefer@gmx.de> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #ifndef KCUBEWIDGET_H 0010 #define KCUBEWIDGET_H 0011 0012 #include <QFrame> 0013 #include "ai_globals.h" 0014 0015 enum SVGElement {Neutral, Player1, Player2, Pip, BlinkLight, BlinkDark, 0016 FirstElement = Neutral, LastElement = BlinkDark}; 0017 0018 class QMouseEvent; 0019 class QPaintEvent; 0020 0021 /** 0022 * 0023 */ 0024 class KCubeWidget : public QFrame 0025 { 0026 Q_OBJECT 0027 0028 public: 0029 /** constructs a new KCubeWidget*/ 0030 explicit KCubeWidget (QWidget * parent = nullptr); 0031 ~KCubeWidget() override; 0032 0033 Player owner() const { return m_owner; } 0034 int value() const { return m_value; } 0035 0036 void setOwner (Player newOwner); 0037 void setValue (int newValue); 0038 void setPixmaps (QList<QPixmap> * ptr); 0039 0040 /** 0041 * sets the coordinates of the Cube in a Cubebox; 0042 * needed for identification when clicked. 0043 */ 0044 void setCoordinates (int row, int col, int limit); 0045 0046 /** enables or disables possibility to click a cube*/ 0047 static void enableClicks(bool flag); 0048 0049 void setLight() { blinking = Light; update(); } 0050 void setDark() { blinking = Dark; update(); } 0051 void setNeutral() { blinking = None; update(); } 0052 bool isNeutral() { return (blinking == None); } 0053 0054 void shrink (qreal scale); 0055 void expand (qreal scale); 0056 void migrateDot (int rowDiff, int colDiff, int step, Player player); 0057 0058 public Q_SLOTS: 0059 /** resets the Cube to default values */ 0060 virtual void reset(); 0061 /** shows changed colors*/ 0062 virtual void updateColors(); 0063 0064 Q_SIGNALS: 0065 void clicked (int row, int column); 0066 0067 protected: 0068 /** checks, if mouseclick was inside this cube*/ 0069 void mouseReleaseEvent(QMouseEvent*) override; 0070 0071 /** refreshes the contents of the Cube */ 0072 void paintEvent(QPaintEvent*) override; 0073 0074 private: 0075 int m_row; 0076 int m_col; 0077 int m_limit; 0078 Player m_owner; 0079 int m_value; 0080 0081 QList<QPixmap> * pixmaps; 0082 enum Blink {None, Light, Dark}; 0083 Blink blinking; 0084 0085 static bool _clicksAllowed; 0086 int migrating; 0087 qreal m_rowDiff; 0088 qreal m_colDiff; 0089 Player m_player; 0090 qreal m_scale; 0091 qreal m_opacity; 0092 }; 0093 0094 #endif // KCUBEWIDGET_H