00001 #ifndef CANVAS_H
00002 #define CANVAS_H
00003
00004 #include <QWidget>
00005 #include <QPaintEvent>
00006 #include <QResizeEvent>
00007 #include <QPainterPath>
00008 #include <QPainter>
00009 #include <QString>
00010 #include <QVector>
00011 #include <QTextOption>
00012 #include <QRect>
00013 #include <QTimer>
00014 #include <cmath>
00015 #include "tournament.h"
00016
00017
00023 class Canvas : public QWidget
00024 {
00025 Q_OBJECT
00026
00027 public:
00031 Canvas(QWidget *parent);
00032 ~Canvas();
00033
00035 static int STEP_UP;
00036 static int STEP_DOWN;
00037
00041 Tournament *tournament;
00045 int round;
00047 bool picks;
00048
00052 int x0, y0, dx, dy;
00053
00057 QTimer* timer;
00058 Game* animatedGame;
00059 int step;
00060 bool animated;
00061 void setAnimationEndPoint(int end, int offset, int color);
00062
00068 void init(void);
00069
00070 protected:
00071 void mousePressEvent(QMouseEvent* mevent);
00072
00073 private:
00075 static const int LEFT = 1;
00077 static const int RIGHT = -1;
00079 static const int VMARGIN = 50;
00081 static const int brcktHmargin = 10;
00082 static const int pickHeight = 12;
00083 static const int normalLen = 20;
00084
00086 int HMARGIN;
00088 int brcktVmargin;
00089
00090
00092 int animEnd;
00093 int dashOffset;
00095 int colorStep;
00096
00097 QPainter *painter;
00098 QPen pen;
00100 QPen undecided;
00102 QPen decided;
00103 int fontheight;
00104
00109 void paintEvent(QPaintEvent* pevent);
00110 void resizeEvent(QResizeEvent* revent);
00119 void initBracketPositions(int id, int num, int y0, int dy, int level);
00120 QPainterPath drawBracket(int x0, int y0, int ylink, int dx, int dy, int dashOffset);
00121 void drawBrackets(void);
00123 void drawTeamInfo (void);
00125 void drawPicks(int round);
00130 void updateParentBracket(int ID);
00134 bool isDrawn(Game* game);
00135 QPen getPenForTeam(Team* team);
00136 Team* findTeamFromCoordinates(int x, int y);
00137
00138
00139 private slots:
00140 void animate();
00141 };
00142
00143 #endif // CANVAS_H