Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

mindbreaker.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of the Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 
00021 #ifndef MINDBREAKER_H
00022 #define MINDBREAKER_H
00023 
00024 #include <qwidget.h>
00025 #include <qmainwindow.h>
00026 #include <qimage.h>
00027 #include <qvector.h>
00028 #include <qcanvas.h>
00029 #include <qlabel.h>
00030 
00031 static const int panel_height = 26;
00032 static const int panel_width = 180;
00033 
00034 static const int title_height = 25;
00035 static const int title_width = 180;
00036 
00037 static const int bin_margin = 10;
00038 static const int peg_size = 20;
00039 static const int answerpeg_size = 13;
00040 
00041 static const int first_peg_x_diff = 21;
00042 static const int first_peg_y_diff = ((panel_height - peg_size) >> 1);
00043 static const int peg_spacing = 30;
00044 
00045 static const int answerpegx = 152;
00046 static const int answerpegy = 2;
00047 static const int answerpeg_diff = 9;
00048 
00049 static const int board_height = (title_height + (panel_height * 9));
00050 static const int board_width = (panel_width + (bin_margin * 2) + peg_size);
00051 
00052 class Peg;
00053 class QToolButton;
00054 class QTimer;
00055 
00056 class MindBreakerBoard : public QCanvasView // QWidget
00057 {
00058     Q_OBJECT
00059 public:
00060     MindBreakerBoard(QWidget *parent=0, const char *name=0, int wFlags=0 );
00061     ~MindBreakerBoard();
00062 
00063     void getScore(int *, int *);
00064 
00065     void resizeEvent(QResizeEvent*);
00066     void fixSize();
00067 
00068 signals:
00069     void scoreChanged(int, int);
00070 
00071 public slots:
00072     void clear();
00073     void resetScore();
00074 
00075 private slots:
00076     void doFixSize();
00077 
00078 protected:
00079     void contentsMousePressEvent(QMouseEvent *);
00080     void contentsMouseMoveEvent(QMouseEvent *);
00081     void contentsMouseReleaseEvent(QMouseEvent *);
00082 
00083 private:
00084     QCanvas cnv;
00085 
00086     void readConfig();
00087     void writeConfig();
00088 
00089     void drawBackground();
00090     void checkGuess();
00091     void checkScores();
00092     void placeGuessPeg(int pos, int pegId);
00093 
00094     QImage panelImage;
00095     QImage titleImage;
00096 
00097     Peg *moving;
00098     Peg *current_highlight;
00099     QPoint moving_pos;
00100 
00101     // the game stuff 
00102     int answer[4];
00103     int current_guess[4];
00104     int past_guesses[4*9];
00105     int current_go;
00106 
00107     int null_press;
00108     QPoint null_point;
00109     bool copy_press;
00110     Peg *copy_peg;
00111     bool game_over;
00112 
00113     int total_turns;
00114     int total_games;
00115 
00116     QTimer *widthTimer;
00117 };
00118 
00119 class MindBreaker : public QMainWindow // QWidget
00120 {
00121     Q_OBJECT
00122 public:
00123     MindBreaker(QWidget *parent=0, const char *name=0, int wFlags=0 );
00124     static QString appName() { return QString::fromLatin1("mindbreaker"); }
00125 public slots:
00126     void setScore(int, int);
00127 
00128 protected:
00129     void resizeEvent( QResizeEvent * );
00130 
00131 private:
00132     QCanvas canvas;
00133     MindBreakerBoard *board;
00134     QToolButton *score;
00135 
00136 };
00137 
00138 
00139 #endif 

Generated on Sat Nov 5 16:17:22 2005 for OPIE by  doxygen 1.4.2