1 #ifndef DRAWING_WINDOW_H
2 #define DRAWING_WINDOW_H
13 class DrawingWindow: public QWidget {
17 typedef int (*ThreadFunction)(DrawingWindow &);
19 static const int DEFAULT_WIDTH = 640;
20 static const int DEFAULT_HEIGHT = 480;
22 DrawingWindow(ThreadFunction fun,
23 int width = DEFAULT_WIDTH, int height = DEFAULT_HEIGHT);
24 DrawingWindow(QWidget *parent,
26 int width = DEFAULT_WIDTH, int height = DEFAULT_HEIGHT);
27 DrawingWindow(QWidget *parent, Qt::WindowFlags flags,
29 int width = DEFAULT_WIDTH, int height = DEFAULT_HEIGHT);
36 void setColor(float red, float green, float blue);
37 void setColor(const QColor &color);
39 void drawPoint(int x, int y);
40 void drawLine(int x1, int y1, int x2, int y2);
43 void paintEvent(QPaintEvent *ev);
44 void showEvent(QShowEvent *ev);
45 void timerEvent(QTimerEvent *ev);
50 static const int paintInterval = 33;
57 DrawingThread *thread;
65 void initialize(ThreadFunction fun, int width, int height);
71 void setDirtyRect(int x, int y);
72 void setDirtyRect(int x1, int y1, int x2, int y2);
73 void setDirtyRect(const QRect &rect);
77 int DrawingWindow::width() const
79 return image->width();
83 int DrawingWindow::height() const
85 return image->height();
89 void DrawingWindow::lock()
95 void DrawingWindow::unlock()
101 void DrawingWindow::setDirtyRect()
104 dirtyRect.setRect(0, 0, width(), height());
108 void DrawingWindow::setDirtyRect(int x, int y)
110 setDirtyRect(QRect(x, y, 1, 1));
114 void DrawingWindow::setDirtyRect(int x1, int y1, int x2, int y2)
117 r.setCoords(x1, y1, x2, y2);
118 setDirtyRect(r.normalized());
121 #endif // !DRAWING_WINDOW_H