canvas-grid.h revision 59a0ba05e8bea8ef8d8c905eb0232c5980ac9afa
5aefb6555731130ca4fd295960123d71f2d21fe8rie#ifndef INKSCAPE_CANVAS_GRID_H
5aefb6555731130ca4fd295960123d71f2d21fe8rie#define INKSCAPE_CANVAS_GRID_H
5aefb6555731130ca4fd295960123d71f2d21fe8rie
5aefb6555731130ca4fd295960123d71f2d21fe8rie/*
5aefb6555731130ca4fd295960123d71f2d21fe8rie * Inkscape::CXYGrid
5aefb6555731130ca4fd295960123d71f2d21fe8rie *
5aefb6555731130ca4fd295960123d71f2d21fe8rie * Generic (and quite unintelligent) grid item for gnome canvas
5aefb6555731130ca4fd295960123d71f2d21fe8rie *
5aefb6555731130ca4fd295960123d71f2d21fe8rie * Copyright (C) Johan Engelen 2006 <johan@shouraizou.nl>
5aefb6555731130ca4fd295960123d71f2d21fe8rie * Copyright (C) Lauris Kaplinski 2000
5aefb6555731130ca4fd295960123d71f2d21fe8rie *
5aefb6555731130ca4fd295960123d71f2d21fe8rie */
5aefb6555731130ca4fd295960123d71f2d21fe8rie
5aefb6555731130ca4fd295960123d71f2d21fe8rie#include <display/sp-canvas.h>
5aefb6555731130ca4fd295960123d71f2d21fe8rie#include "xml/repr.h"
5aefb6555731130ca4fd295960123d71f2d21fe8rie#include <gtkmm/box.h>
5aefb6555731130ca4fd295960123d71f2d21fe8rie
5aefb6555731130ca4fd295960123d71f2d21fe8rie
5aefb6555731130ca4fd295960123d71f2d21fe8rie#include <gtkmm.h>
5aefb6555731130ca4fd295960123d71f2d21fe8rie#include "ui/widget/color-picker.h"
5aefb6555731130ca4fd295960123d71f2d21fe8rie#include "ui/widget/scalar-unit.h"
5aefb6555731130ca4fd295960123d71f2d21fe8rie
ba2be53024c0b999e74ba9adcd7d80fec5df8c57ab#include "ui/widget/registered-widget.h"
5aefb6555731130ca4fd295960123d71f2d21fe8rie#include "ui/widget/registry.h"
5aefb6555731130ca4fd295960123d71f2d21fe8rie#include "ui/widget/tolerance-slider.h"
5aefb6555731130ca4fd295960123d71f2d21fe8rie
5aefb6555731130ca4fd295960123d71f2d21fe8rie#include "xml/node-event-vector.h"
5aefb6555731130ca4fd295960123d71f2d21fe8rie
5aefb6555731130ca4fd295960123d71f2d21fe8rie#include "snapper.h"
5aefb6555731130ca4fd295960123d71f2d21fe8rie#include "line-snapper.h"
5aefb6555731130ca4fd295960123d71f2d21fe8rie
ba2be53024c0b999e74ba9adcd7d80fec5df8c57abstruct SPDesktop;
5aefb6555731130ca4fd295960123d71f2d21fe8riestruct SPNamedView;
5aefb6555731130ca4fd295960123d71f2d21fe8rie
5aefb6555731130ca4fd295960123d71f2d21fe8rienamespace Inkscape {
5aefb6555731130ca4fd295960123d71f2d21fe8rie
5aefb6555731130ca4fd295960123d71f2d21fe8rie#define INKSCAPE_TYPE_GRID_CANVASITEM (Inkscape::grid_canvasitem_get_type ())
5aefb6555731130ca4fd295960123d71f2d21fe8rie#define INKSCAPE_GRID_CANVASITEM(obj) (GTK_CHECK_CAST ((obj), INKSCAPE_TYPE_GRID_CANVASITEM, GridCanvasItem))
5aefb6555731130ca4fd295960123d71f2d21fe8rie#define INKSCAPE_GRID_CANVASITEM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), INKSCAPE_TYPE_GRID_CANVASITEM, GridCanvasItem))
5aefb6555731130ca4fd295960123d71f2d21fe8rie#define INKSCAPE_IS_GRID_CANVASITEM(obj) (GTK_CHECK_TYPE ((obj), INKSCAPE_TYPE_GRID_CANVASITEM))
5aefb6555731130ca4fd295960123d71f2d21fe8rie#define INKSCAPE_IS_GRID_CANVASITEM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), INKSCAPE_TYPE_GRID_CANVASITEM))
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18abclass CanvasGrid;
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab/** \brief All the variables that are tracked for a grid specific
981a172d53aeb81520fcfecf6ab2615277c7bd18ab canvas item. */
981a172d53aeb81520fcfecf6ab2615277c7bd18abstruct GridCanvasItem : public SPCanvasItem{
981a172d53aeb81520fcfecf6ab2615277c7bd18ab CanvasGrid *grid; // the owning grid object
981a172d53aeb81520fcfecf6ab2615277c7bd18ab};
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18abstruct GridCanvasItemClass {
981a172d53aeb81520fcfecf6ab2615277c7bd18ab SPCanvasItemClass parent_class;
981a172d53aeb81520fcfecf6ab2615277c7bd18ab};
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab/* Standard Gtk function */
981a172d53aeb81520fcfecf6ab2615277c7bd18abGtkType grid_canvasitem_get_type (void);
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18abclass CanvasGrid {
981a172d53aeb81520fcfecf6ab2615277c7bd18abpublic:
981a172d53aeb81520fcfecf6ab2615277c7bd18ab CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr);
981a172d53aeb81520fcfecf6ab2615277c7bd18ab virtual ~CanvasGrid();
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab static CanvasGrid* NewGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, const char * gridtype);
981a172d53aeb81520fcfecf6ab2615277c7bd18ab static void writeNewGridToRepr(Inkscape::XML::Node * repr, const char * gridtype);
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab GridCanvasItem * createCanvasItem(SPDesktop * desktop);
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab virtual void Update (NR::Matrix const &affine, unsigned int flags) = 0;
981a172d53aeb81520fcfecf6ab2615277c7bd18ab virtual void Render (SPCanvasBuf *buf) = 0;
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab virtual void readRepr() {};
981a172d53aeb81520fcfecf6ab2615277c7bd18ab virtual void onReprAttrChanged (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive) {};
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab virtual Gtk::Widget & getWidget() = 0;
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab Inkscape::XML::Node * repr;
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab Inkscape::Snapper* snapper;
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab static void on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive, void * data);
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18abprotected:
981a172d53aeb81520fcfecf6ab2615277c7bd18ab GSList * canvasitems; // list of created canvasitems
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab SPNamedView * namedview;
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab Gtk::VBox vbox;
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18abprivate:
981a172d53aeb81520fcfecf6ab2615277c7bd18ab CanvasGrid(const CanvasGrid&);
981a172d53aeb81520fcfecf6ab2615277c7bd18ab CanvasGrid& operator=(const CanvasGrid&);
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab};
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18abclass CanvasXYGrid : public CanvasGrid {
981a172d53aeb81520fcfecf6ab2615277c7bd18abpublic:
981a172d53aeb81520fcfecf6ab2615277c7bd18ab CanvasXYGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr);
5aefb6555731130ca4fd295960123d71f2d21fe8rie ~CanvasXYGrid();
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
5aefb6555731130ca4fd295960123d71f2d21fe8rie void Update (NR::Matrix const &affine, unsigned int flags);
5aefb6555731130ca4fd295960123d71f2d21fe8rie void Render (SPCanvasBuf *buf);
5aefb6555731130ca4fd295960123d71f2d21fe8rie
f5a18a30a06b60eec275589214da939abbaa99d9rie void readRepr();
5aefb6555731130ca4fd295960123d71f2d21fe8rie void onReprAttrChanged (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive);
5aefb6555731130ca4fd295960123d71f2d21fe8rie
5aefb6555731130ca4fd295960123d71f2d21fe8rie Gtk::Widget & getWidget();
31fdd7ca2d295948f9f1bcc2a1178c66467bca63ab
5aefb6555731130ca4fd295960123d71f2d21fe8rie NR::Point origin;
5aefb6555731130ca4fd295960123d71f2d21fe8rie guint32 color;
5aefb6555731130ca4fd295960123d71f2d21fe8rie guint32 empcolor;
5aefb6555731130ca4fd295960123d71f2d21fe8rie gint empspacing;
5aefb6555731130ca4fd295960123d71f2d21fe8rie SPUnit const* gridunit;
5aefb6555731130ca4fd295960123d71f2d21fe8rie
5aefb6555731130ca4fd295960123d71f2d21fe8rie NR::Point spacing; /**< Spacing between elements of the grid */
5aefb6555731130ca4fd295960123d71f2d21fe8rie bool scaled[2]; /**< Whether the grid is in scaled mode, which can
5aefb6555731130ca4fd295960123d71f2d21fe8rie be different in the X or Y direction, hense two
5aefb6555731130ca4fd295960123d71f2d21fe8rie variables */
5aefb6555731130ca4fd295960123d71f2d21fe8rie NR::Point ow; /**< Transformed origin by the affine for the zoom */
5aefb6555731130ca4fd295960123d71f2d21fe8rie NR::Point sw; /**< Transformed spacing by the affine for the zoom */
5aefb6555731130ca4fd295960123d71f2d21fe8rieprivate:
981a172d53aeb81520fcfecf6ab2615277c7bd18ab CanvasXYGrid(const CanvasXYGrid&);
981a172d53aeb81520fcfecf6ab2615277c7bd18ab CanvasXYGrid& operator=(const CanvasXYGrid&);
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab void updateWidgets();
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab Gtk::Table table;
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab Inkscape::UI::Widget::RegisteredCheckButton _rcbgrid, _rcbsnbb, _rcbsnnod;
981a172d53aeb81520fcfecf6ab2615277c7bd18ab Inkscape::UI::Widget::RegisteredUnitMenu _rumg, _rums;
981a172d53aeb81520fcfecf6ab2615277c7bd18ab Inkscape::UI::Widget::RegisteredScalarUnit _rsu_ox, _rsu_oy, _rsu_sx, _rsu_sy;
981a172d53aeb81520fcfecf6ab2615277c7bd18ab Inkscape::UI::Widget::RegisteredColorPicker _rcp_gcol, _rcp_gmcol;
981a172d53aeb81520fcfecf6ab2615277c7bd18ab Inkscape::UI::Widget::RegisteredSuffixedInteger _rsi;
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab Inkscape::UI::Widget::Registry _wr;
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab};
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18abclass CanvasXYGridSnapper : public LineSnapper
981a172d53aeb81520fcfecf6ab2615277c7bd18ab{
981a172d53aeb81520fcfecf6ab2615277c7bd18abpublic:
981a172d53aeb81520fcfecf6ab2615277c7bd18ab CanvasXYGridSnapper(CanvasXYGrid *grid, SPNamedView const *nv, NR::Coord const d);
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18abprivate:
981a172d53aeb81520fcfecf6ab2615277c7bd18ab LineList _getSnapLines(NR::Point const &p) const;
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab CanvasXYGrid *grid;
981a172d53aeb81520fcfecf6ab2615277c7bd18ab};
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab}; /* namespace Inkscape */
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab
981a172d53aeb81520fcfecf6ab2615277c7bd18ab#endif
5aefb6555731130ca4fd295960123d71f2d21fe8rie