#ifndef DRAWER_H_ #define DRAWER_H_ #include #include #include "Vertex.h" class Window; class Drawer { private: GtkWidget *drawer; GtkWidget *drawingArea; GtkAdjustment *hAdjustment, *vAdjustment; int zoomExp; Window *window; float scale; float xTranslate, yTranslate; // prevent shallow copy Drawer(const Drawer &w); const Drawer& operator=(const Drawer &w); void updateViewport(); void updateScrolling(); void updateScrollbars(float x = 0.5f, float y = 0.5f); void updateHoveredPoint(float x, float y); gint getWidth() const { return drawingArea->allocation.width; } gint getHeight() const { return drawingArea->allocation.height; } static void realize(GtkWidget *widget, Drawer *drawer); static gboolean eventHandler(GtkWidget *widget, GdkEvent *event, Drawer *drawer); static void valueChanged(GtkAdjustment *adjustment, Drawer *drawer); public: Drawer(Window *window, GdkGLConfig *glconfig); virtual ~Drawer(); void zoom(int zoom, float x = 0.5f, float y = 0.5f); void imageToView(Vertex *v); void viewToImage(Vertex *v); float getImageWidth(); float getImageHeight(); float getXTranslate() { return xTranslate; } float getYTranslate() { return yTranslate; } float getScale() { return scale; } GtkWidget *getWidget() { return drawer; } void update() { gtk_widget_queue_draw(drawingArea); } }; #endif /*DRAWER_H_*/