This repository has been archived on 2025-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
neofx-zoomedit/Drawer.h

84 lines
1.7 KiB
C
Raw Normal View History

#ifndef DRAWER_H_
#define DRAWER_H_
#include <gtk/gtk.h>
#include <gtk/gtkgl.h>
#include "Vertex.h"
#include "Renderer.h"
class Window;
class Drawer {
private:
GtkWidget *drawer;
GtkWidget *drawingArea;
GtkAdjustment *hAdjustment, *vAdjustment;
int zoomExp;
Window *window;
Renderer renderer;
float scale;
float xCenter, yCenter;
// 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);
void render();
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) const;
void viewToImage(Vertex *v) const;
float getImageWidth() const;
float getImageHeight() const;
float getXCenter() const {
return xCenter;
}
float getYCenter() const {
return yCenter;
}
float getScale() const {
return scale;
}
GtkWidget *getWidget() const {
return drawer;
}
void update() {
2007-11-16 17:49:00 +00:00
updateScrollbars();
}
};
#endif /*DRAWER_H_*/