Last change
on this file since 10 was 2, checked in by dmik, 20 years ago |
Imported xplatform parts of the official release 3.3.1 from Trolltech
|
-
Property svn:keywords
set to
Id
|
File size:
1.3 KB
|
Line | |
---|
1 | /****************************************************************************
|
---|
2 | ** $Id: life.h 2 2005-11-16 15:49:26Z 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 LIFE_H
|
---|
12 | #define LIFE_H
|
---|
13 |
|
---|
14 | #include <qframe.h>
|
---|
15 |
|
---|
16 |
|
---|
17 | class LifeWidget : public QFrame
|
---|
18 | {
|
---|
19 | Q_OBJECT
|
---|
20 | public:
|
---|
21 | LifeWidget( int s = 10, QWidget *parent = 0, const char *name = 0 );
|
---|
22 |
|
---|
23 | void setPoint( int i, int j );
|
---|
24 |
|
---|
25 | int maxCol() { return maxi; }
|
---|
26 | int maxRow() { return maxj; }
|
---|
27 |
|
---|
28 | public slots:
|
---|
29 | void nextGeneration();
|
---|
30 | void clear();
|
---|
31 |
|
---|
32 | protected:
|
---|
33 | virtual void paintEvent( QPaintEvent * );
|
---|
34 | virtual void mouseMoveEvent( QMouseEvent * );
|
---|
35 | virtual void mousePressEvent( QMouseEvent * );
|
---|
36 | virtual void resizeEvent( QResizeEvent * );
|
---|
37 | void mouseHandle( const QPoint &pos );
|
---|
38 |
|
---|
39 | private:
|
---|
40 | enum { MAXSIZE = 50, MINSIZE = 10, BORDER = 5 };
|
---|
41 |
|
---|
42 | bool cells[2][MAXSIZE + 2][MAXSIZE + 2];
|
---|
43 | int current;
|
---|
44 | int maxi, maxj;
|
---|
45 |
|
---|
46 | int pos2index( int x )
|
---|
47 | {
|
---|
48 | return ( x - BORDER ) / SCALE + 1;
|
---|
49 | }
|
---|
50 | int index2pos( int i )
|
---|
51 | {
|
---|
52 | return ( i - 1 ) * SCALE + BORDER;
|
---|
53 | }
|
---|
54 |
|
---|
55 | int SCALE;
|
---|
56 | };
|
---|
57 |
|
---|
58 |
|
---|
59 | #endif // LIFE_H
|
---|
Note:
See
TracBrowser
for help on using the repository browser.