| 1 | /****************************************************************************
|
|---|
| 2 | ** $Id: qtetrix.h 160 2006-12-11 20:15:57Z dmik $
|
|---|
| 3 | **
|
|---|
| 4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of an example program for Qt. This example
|
|---|
| 7 | ** program may be used, distributed and modified without limitation.
|
|---|
| 8 | **
|
|---|
| 9 | *****************************************************************************/
|
|---|
| 10 |
|
|---|
| 11 | #ifndef QTETRIX_H
|
|---|
| 12 | #define QTETRIX_H
|
|---|
| 13 |
|
|---|
| 14 | #include "qtetrixb.h"
|
|---|
| 15 | #include <qframe.h>
|
|---|
| 16 | #include <qlcdnumber.h>
|
|---|
| 17 | #include <qlabel.h>
|
|---|
| 18 | #include <qpushbutton.h>
|
|---|
| 19 | #include <qpainter.h>
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 | class ShowNextPiece : public QFrame
|
|---|
| 23 | {
|
|---|
| 24 | Q_OBJECT
|
|---|
| 25 | friend class QTetrix;
|
|---|
| 26 | public:
|
|---|
| 27 | ShowNextPiece( QWidget *parent=0, const char *name=0 );
|
|---|
| 28 | public slots:
|
|---|
| 29 | void drawNextSquare( int x, int y,QColor *color );
|
|---|
| 30 | signals:
|
|---|
| 31 | void update();
|
|---|
| 32 | private:
|
|---|
| 33 | void paintEvent( QPaintEvent * );
|
|---|
| 34 | void resizeEvent( QResizeEvent * );
|
|---|
| 35 |
|
|---|
| 36 | int blockWidth,blockHeight;
|
|---|
| 37 | int xOffset,yOffset;
|
|---|
| 38 | };
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 | class QTetrix : public QWidget
|
|---|
| 42 | {
|
|---|
| 43 | Q_OBJECT
|
|---|
| 44 | public:
|
|---|
| 45 | QTetrix( QWidget *parent=0, const char *name=0 );
|
|---|
| 46 | void startGame() { board->startGame(); }
|
|---|
| 47 |
|
|---|
| 48 | public slots:
|
|---|
| 49 | void gameOver();
|
|---|
| 50 | void quit();
|
|---|
| 51 | private:
|
|---|
| 52 | void keyPressEvent( QKeyEvent *e ) { board->keyPressEvent(e); }
|
|---|
| 53 |
|
|---|
| 54 | QTetrixBoard *board;
|
|---|
| 55 | ShowNextPiece *showNext;
|
|---|
| 56 | #ifndef QT_NO_LCDNUMBER
|
|---|
| 57 | QLCDNumber *showScore;
|
|---|
| 58 | QLCDNumber *showLevel;
|
|---|
| 59 | QLCDNumber *showLines;
|
|---|
| 60 | #else
|
|---|
| 61 | QLabel *showScore;
|
|---|
| 62 | QLabel *showLevel;
|
|---|
| 63 | QLabel *showLines;
|
|---|
| 64 | #endif
|
|---|
| 65 | QPushButton *quitButton;
|
|---|
| 66 | QPushButton *startButton;
|
|---|
| 67 | QPushButton *pauseButton;
|
|---|
| 68 | };
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 | void drawTetrixButton( QPainter *, int x, int y, int w, int h,
|
|---|
| 72 | const QColor *color, QWidget *widg);
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 | #endif
|
|---|