X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/graphlib.git/blobdiff_plain/f41c1c8ff250f095b47fb6d5f7e578279b0c2844..e76ea9e634775180ffbb3fd9c6479a31aeaa43fd:/DrawingWindow.h diff --git a/DrawingWindow.h b/DrawingWindow.h index 7dd9bb7..66fc445 100644 --- a/DrawingWindow.h +++ b/DrawingWindow.h @@ -1,29 +1,59 @@ #ifndef DRAWING_WINDOW_H #define DRAWING_WINDOW_H -#include "DrawingArea.h" -#include -#include #include +#include -class DrawingWindow: public QWidget { -/* Q_OBJECT */ +class DrawingWindowPrivate; +class DrawingWindow: public QWidget { public: - DrawingWindow(DrawingArea &a); - DrawingWindow(QWidget *parent, DrawingArea &a); - DrawingWindow(QWidget *parent, Qt::WindowFlags flags, DrawingArea &a); + typedef void (*ThreadFunction)(DrawingWindow &); + + static const int DEFAULT_WIDTH = 640; + static const int DEFAULT_HEIGHT = 480; + + DrawingWindow(ThreadFunction fun, + int width = DEFAULT_WIDTH, int height = DEFAULT_HEIGHT); + DrawingWindow(QWidget *parent, + ThreadFunction fun, + int width = DEFAULT_WIDTH, int height = DEFAULT_HEIGHT); + DrawingWindow(QWidget *parent, Qt::WindowFlags flags, + ThreadFunction fun, + int width = DEFAULT_WIDTH, int height = DEFAULT_HEIGHT); + + ~DrawingWindow(); + + const int width; + const int height; + + void setColor(float red, float green, float blue); + void setBgColor(float red, float green, float blue); + + void clearGraph(); + + void drawPoint(int x, int y); + void drawLine(int x1, int y1, int x2, int y2); + void drawRect(int x1, int y1, int x2, int y2); + + bool sync(unsigned long time = ULONG_MAX); + + void sleep(unsigned long secs); + void msleep(unsigned long msecs); + void usleep(unsigned long usecs); protected: + void closeEvent(QCloseEvent *ev); + void customEvent(QEvent *ev); + void keyPressEvent(QKeyEvent *ev); void paintEvent(QPaintEvent *ev); + void showEvent(QShowEvent *ev); void timerEvent(QTimerEvent *ev); private: - DrawingArea &drawingArea; - QPixmap pixmap; - QBasicTimer timer; + DrawingWindowPrivate * const d; - void initialize(); + friend class DrawingWindowPrivate; }; #endif // !DRAWING_WINDOW_H