2007-10-04 23:38:05 +00:00
|
|
|
#ifndef DRAWER_H_
|
|
|
|
#define DRAWER_H_
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <gtk/gtkgl.h>
|
2007-10-18 23:38:05 +00:00
|
|
|
#include "Vertex.h"
|
2007-10-23 19:08:04 +00:00
|
|
|
#include "Renderer.h"
|
2007-10-04 23:38:05 +00:00
|
|
|
|
|
|
|
class Window;
|
|
|
|
|
|
|
|
|
|
|
|
class Drawer {
|
|
|
|
private:
|
|
|
|
GtkWidget *drawer;
|
|
|
|
GtkWidget *drawingArea;
|
|
|
|
GtkAdjustment *hAdjustment, *vAdjustment;
|
2008-01-17 21:13:00 +00:00
|
|
|
GtkWidget *hRuler, *vRuler;
|
2007-10-04 23:38:05 +00:00
|
|
|
int zoomExp;
|
|
|
|
|
|
|
|
Window *window;
|
|
|
|
|
2007-12-24 00:04:02 +00:00
|
|
|
Renderer renderer;
|
|
|
|
|
2007-10-18 23:38:05 +00:00
|
|
|
float scale;
|
2007-11-16 01:29:04 +00:00
|
|
|
float xCenter, yCenter;
|
2007-10-18 23:38:05 +00:00
|
|
|
|
2007-10-04 23:38:05 +00:00
|
|
|
// 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);
|
|
|
|
|
2007-10-23 19:08:04 +00:00
|
|
|
void render();
|
|
|
|
|
2007-10-04 23:38:05 +00:00
|
|
|
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);
|
|
|
|
|
2007-10-23 19:08:04 +00:00
|
|
|
void imageToView(Vertex *v) const;
|
|
|
|
void viewToImage(Vertex *v) const;
|
2007-10-18 23:38:05 +00:00
|
|
|
|
2007-10-23 19:08:04 +00:00
|
|
|
float getImageWidth() const;
|
|
|
|
float getImageHeight() const;
|
2007-10-18 23:38:05 +00:00
|
|
|
|
2007-11-16 01:29:04 +00:00
|
|
|
float getXCenter() const {
|
|
|
|
return xCenter;
|
2007-10-18 23:38:05 +00:00
|
|
|
}
|
|
|
|
|
2007-11-16 01:29:04 +00:00
|
|
|
float getYCenter() const {
|
|
|
|
return yCenter;
|
2007-10-18 23:38:05 +00:00
|
|
|
}
|
|
|
|
|
2007-10-23 19:08:04 +00:00
|
|
|
float getScale() const {
|
2007-10-18 23:38:05 +00:00
|
|
|
return scale;
|
|
|
|
}
|
|
|
|
|
2007-10-23 19:08:04 +00:00
|
|
|
GtkWidget *getWidget() const {
|
2007-10-04 23:38:05 +00:00
|
|
|
return drawer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void update() {
|
2007-11-16 17:49:00 +00:00
|
|
|
updateScrollbars();
|
2007-10-04 23:38:05 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /*DRAWER_H_*/
|