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

gowidget.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of 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 GOWIDGET_H
00022 #define GOWIDGET_H
00023 
00024 #include <qmainwindow.h>
00025 #include "amigo.h"
00026 
00027 
00028 class QToolBar;
00029 
00030 class GoMainWidget : public QMainWindow
00031 {
00032     Q_OBJECT
00033 public:
00034     static QString appName() { return QString::fromLatin1("go"); }
00035     GoMainWidget( QWidget *parent=0, const char* name=0, WFlags fl = 0);
00036 protected:
00037     void resizeEvent( QResizeEvent * );
00038 private:
00039     QToolBar *toolbar;
00040     
00041 };
00042 
00043 
00044 class QLabel;
00045 class GoWidget : public QWidget
00046 {
00047     Q_OBJECT
00048 public:
00049     GoWidget( QWidget *parent=0, const char* name=0);
00050     ~GoWidget();
00051 
00052     void doMove( int x, int y );
00053     void doComputerMove();
00054 
00055     void readConfig();
00056     void writeConfig();
00057 
00058 public slots:    
00059     void pass();
00060     void resign();
00061     void newGame();
00062     void setTwoplayer( bool );
00063     void setHandicap( int );
00064 signals:
00065     void showScore( const QString& );
00066     void showTurn( const QPixmap& );
00067     
00068 protected:
00069     void paintEvent( QPaintEvent * );
00070     void mousePressEvent( QMouseEvent * );
00071     void mouseMoveEvent( QMouseEvent * );
00072     void mouseReleaseEvent( QMouseEvent * );
00073     void resizeEvent( QResizeEvent * );
00074 private:
00075     void init();
00076     void removeStone(short x, short y);
00077     void placeStone (enum bVal c, short x, short y );
00078 
00079     void refresh( int x, int y );
00080     void showStone( int x, int y, enum bVal );
00081     void reportPrisoners(int,int);
00082     
00083     inline int x2board( int x ) { return (x-bx+d/2)/d; }
00084     inline int y2board( int y ) { return (y-by+d/2)/d; }
00085 
00086     void endGame();
00087 
00088     bool twoplayer;
00089     enum bVal currentPlayer;
00090     bool gameActive;
00091     int nPassed;
00092     signed char board[19][19];
00093 
00094     int d; //distance between lines
00095     int bx; //vertical baseline
00096     int by; //horizontal baseline
00097     
00098     int lastX,lastY;
00099     int newX,newY;
00100     
00101     static GoWidget *self;
00102 
00103     friend void removestone(short x, short y);
00104     friend void intrPrisonerReport( short, short );
00105     friend void placestone(enum bVal c, short x, short y );
00106 };
00107 
00108 
00109 
00110 
00111 
00112 #endif

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