summaryrefslogtreecommitdiffstats
path: root/kblackbox/kbbgfx.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitc90c389a8a8d9d8661e9772ec4144c5cf2039f23 (patch)
tree6d8391395bce9eaea4ad78958617edb20c6a7573 /kblackbox/kbbgfx.h
downloadtdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.tar.gz
tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kblackbox/kbbgfx.h')
-rw-r--r--kblackbox/kbbgfx.h120
1 files changed, 120 insertions, 0 deletions
diff --git a/kblackbox/kbbgfx.h b/kblackbox/kbbgfx.h
new file mode 100644
index 00000000..ae4d207c
--- /dev/null
+++ b/kblackbox/kbbgfx.h
@@ -0,0 +1,120 @@
+//
+//
+// KBlackBox
+//
+// A simple game inspired by an emacs module
+//
+// File: kbbgfx.h
+//
+// The definition of the KBBGraphic widget
+//
+
+#ifndef KBBGFX_H
+#define KBBGFX_H
+
+#include <qwidget.h>
+#include <qpixmap.h>
+
+#include "util.h"
+
+/*
+ Default size of a cell
+*/
+
+#define CELLW 32
+#define CELLH 32
+
+/*
+ Graphical types of the boxes
+*/
+
+#define OUTERBBG 0
+#define INNERBBG 1
+#define LASERBBG 2
+#define FBALLBBG 3
+#define TBALLBBG 4
+#define WBALLBBG 5
+#define MARK1BBG 6
+#define LFIREBBG 7
+
+/*
+ These have the same pixmaps as some of those above...
+*/
+
+#define RLASERBBG 8
+#define HLASERBBG 9
+
+#define NROFTYPES 8
+
+/*
+ Negative numbers are deflected lasers...
+*/
+
+class KBBGraphic : public QWidget
+{
+ Q_OBJECT
+public:
+ KBBGraphic( QPixmap** p=0, QWidget* parent=0, const char* name=0 );
+ ~KBBGraphic();
+
+ friend class KBBGame;
+
+ void setSize( int w, int h );
+ RectOnArray *getGraphicBoard();
+ int numC();
+ int numR();
+ int width();
+ int height();
+ int wHint() const;
+ int hHint() const;
+ void setCellWidth( int w );
+ void setCellHeight( int h );
+ void setNumRows( int rows );
+ void setNumCols( int cols );
+
+public slots:
+ void setInputAccepted( bool b );
+ void updateElement( int col, int row );
+ void slotUp();
+ void slotDown();
+ void slotLeft();
+ void slotRight();
+ void slotInput();
+
+signals:
+ void sizeChanged();
+ void inputAt( int, int, int );
+ void endMouseClicked();
+
+protected:
+ virtual QSize sizeHint() const;
+ void paintEvent( QPaintEvent* );
+ void mousePressEvent( QMouseEvent* );
+ void mouseMoveEvent( QMouseEvent* );
+ void focusInEvent( QFocusEvent* );
+ void focusOutEvent( QFocusEvent* );
+ void resizeEvent( QResizeEvent* e );
+
+ void moveSelection(int drow, int dcol);
+
+private:
+ void paintCell( QPainter* p, int row, int col );
+ void paintCellDefault( QPainter*, int row, int col );
+ void paintCellPixmap( QPainter*, int row, int col );
+ void scalePixmaps( int w, int h );
+ RectOnArray *graphicBoard;
+ int curRow;
+ int curCol;
+ bool inputAccepted;
+ int minW;
+ int minH;
+ int cellW;
+ int cellH;
+ int numCols;
+ int numRows;
+ QPixmap **pix;
+ QPixmap **pixScaled;
+ QPixmap *drawBuffer;
+};
+
+#endif // KBBGFX_H