1 #ifndef DRAWING_WINDOW_H
2 #define DRAWING_WINDOW_H
11 #include <QWaitCondition>
17 class DrawingWindow: public QWidget {
19 typedef void (*ThreadFunction)(DrawingWindow &);
21 static const int DEFAULT_WIDTH = 640;
22 static const int DEFAULT_HEIGHT = 480;
24 DrawingWindow(ThreadFunction fun,
25 int width_ = DEFAULT_WIDTH, int height_ = DEFAULT_HEIGHT);
26 DrawingWindow(QWidget *parent,
28 int width_ = DEFAULT_WIDTH, int height_ = DEFAULT_HEIGHT);
29 DrawingWindow(QWidget *parent, Qt::WindowFlags flags,
31 int width_ = DEFAULT_WIDTH, int height_ = DEFAULT_HEIGHT);
38 void setColor(unsigned int color);
39 void setColor(const char *name);
40 void setColor(float red, float green, float blue);
42 void setBgColor(unsigned int color);
43 void setBgColor(const char *name);
44 void setBgColor(float red, float green, float blue);
48 void drawPoint(int x, int y);
49 void drawLine(int x1, int y1, int x2, int y2);
50 void drawRect(int x1, int y1, int x2, int y2);
51 void fillRect(int x1, int y1, int x2, int y2);
52 void drawCircle(int x, int y, int r);
53 void fillCircle(int x, int y, int r);
55 void drawText(int x, int y, const char *text, int flags = 0);
56 void drawTextBg(int x, int y, const char *text, int flags = 0);
58 unsigned int getPointColor(int x, int y);
60 bool sync(unsigned long time = ULONG_MAX);
64 void sleep(unsigned long secs);
65 void msleep(unsigned long msecs);
66 void usleep(unsigned long usecs);
69 void closeEvent(QCloseEvent *ev);
70 void customEvent(QEvent *ev);
71 void keyPressEvent(QKeyEvent *ev);
72 void paintEvent(QPaintEvent *ev);
73 void showEvent(QShowEvent *ev);
74 void timerEvent(QTimerEvent *ev);
77 //! Intervalle de temps entre deux rendus (ms)
78 static const int paintInterval = 33;
83 QWaitCondition syncCondition;
93 DrawingThread *thread;
95 void initialize(ThreadFunction fun);
97 void setColor(const QColor& color);
98 void setBgColor(const QColor& color);
102 void safeLock(QMutex &mutex);
103 void safeUnlock(QMutex &mutex);
106 void dirty(int x, int y);
107 void dirty(int x1, int y1, int x2, int y2);
108 void dirty(const QRect &rect);
112 void realDrawText(int x, int y, const char *text, int flags);
115 #endif // !DRAWING_WINDOW_H