canvas-grid.cpp revision 060a6ac2802d7b67f9e58c20cbdedc2326738e3b
#define INKSCAPE_CANVAS_GRID_C
/*
*
* Copyright (C) Johan Engelen 2006-2007 <johan@shouraizou.nl>
* Copyright (C) Lauris Kaplinski 2000
*
*/
#include "sp-canvas-util.h"
#include "display-forward.h"
#include <libnr/nr-pixops.h>
#include "desktop-handles.h"
#include "svg/svg-color.h"
#include "xml/node-event-vector.h"
#include "sp-object.h"
#include "sp-namedview.h"
#include "inkscape.h"
#include "desktop.h"
#include "../document.h"
#include "canvas-grid.h"
#include "canvas-axonomgrid.h"
namespace Inkscape {
#define DEFAULTGRIDCOLOR 0x0000FF20
#define DEFAULTGRIDEMPCOLOR 0x0000FF40
static void grid_canvasitem_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
static SPCanvasItemClass * parent_class;
grid_canvasitem_get_type (void)
{
static GtkType grid_canvasitem_type = 0;
if (!grid_canvasitem_type) {
"GridCanvasItem",
sizeof (GridCanvasItem),
sizeof (GridCanvasItemClass),
};
}
return grid_canvasitem_type;
}
static void
{
}
static void
{
}
static void
{
}
/**
*/
static void
{
}
static void
{
if (parent_class->update)
if (gridcanvasitem->grid) {
-1000000, -1000000,
1000000, 1000000);
}
}
// ##########################################################
// CanvasGrid
NULL, /* child_added */
NULL, /* child_removed */
NULL, /* content_changed */
NULL /* order_changed */
};
{
if (repr) {
}
canvasitems = NULL;
}
CanvasGrid::~CanvasGrid()
{
if (repr) {
repr->removeListenerByData (this);
}
while (canvasitems) {
}
}
/*
* writes an <inkscape:grid> child to repr.
*/
void
{
if (!repr) return;
if (!gridtype) return;
// first create the child xml node, then hook it to repr. This order is important, to not set off listeners to repr before the new node is complete.
// FIXME: add this to history?
// sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR,
// _("Create new element node"));
}
/*
* Creates a new CanvasGrid object of type gridtype
*/
{
}
return NULL;
}
/**
* creates a new grid canvasitem for the SPDesktop given as parameter. Keeps a link to this canvasitem in the canvasitems list.
*/
{
//Johan: I think for multiple desktops it is best if each has their own canvasitem, but share the same CanvasGrid object; that is what this function is for.
// check if there is already a canvasitem on this desktop linking to this grid
return NULL;
}
}
GridCanvasItem * item = INKSCAPE_GRID_CANVASITEM( sp_canvas_item_new(sp_desktop_gridgroup(desktop), INKSCAPE_TYPE_GRID_CANVASITEM, NULL) );
gtk_object_ref(GTK_OBJECT(item)); // since we're keeping a link to this item, we need to bump up the ref count
return item;
}
void
CanvasGrid::on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive, void * data)
{
if (!data)
return;
}
// ##########################################################
// CanvasXYGrid
static void
{
guint r, g, b, a;
guchar *p;
r = NR_RGBA32_R (rgba);
g = NR_RGBA32_G (rgba);
b = NR_RGBA32_B (rgba);
a = NR_RGBA32_A (rgba);
p[0] = NR_COMPOSEN11_1111 (r, a, p[0]);
p += 3;
}
}
}
static void
{
guint r, g, b, a;
guchar *p;
r = NR_RGBA32_R(rgba);
g = NR_RGBA32_G (rgba);
b = NR_RGBA32_B (rgba);
a = NR_RGBA32_A (rgba);
p[0] = NR_COMPOSEN11_1111 (r, a, p[0]);
p += buf->buf_rowstride;
}
}
}
/**
* A DIRECT COPY-PASTE FROM DOCUMENT-PROPERTIES.CPP TO QUICKLY GET RESULTS
*
* Helper function that attachs widgets in a 3xn table. The widgets come in an
* array that has two entries per table row. The two entries code for four
* possible cases: (0,0) means insert space in first column; (0, non-0) means
* widget in columns 2-3; (non-0, 0) means label in columns 1-3; and
* (non-0, non-0) means two widgets in columns 2 and 3.
**/
#define SPACE_SIZE_X 15
#define SPACE_SIZE_Y 10
static inline void
{
{
{
}
else
{
if (arr[i+1])
else if (arr[i])
{
}
else
{
}
}
++r;
}
}
{
empspacing = 5;
// initialize widgets:
_("Color of the major (highlighted) grid lines"),
{
0, 0,
};
}
CanvasXYGrid::~CanvasXYGrid ()
{
}
/* fixme: Collect all these length parsing methods and think common sane API */
{
if (!str) {
return FALSE;
}
gchar *u;
if (!u) {
return FALSE;
}
while (isspace(*u)) {
u += 1;
}
if (!*u) {
/* No unit specified - keep default */
*val = v;
return TRUE;
}
if (base & SP_UNIT_DEVICE) {
*val = v;
return TRUE;
}
}
if (base & SP_UNIT_ABSOLUTE) {
} else {
return FALSE;
}
*val = v;
return TRUE;
}
return FALSE;
}
{
if (!str) {
return FALSE;
}
gchar *u;
if (!u) {
return FALSE;
}
return TRUE;
}
void
{
}
}
}
}
}
}
}
}
}
}
return;
}
/**
* Called when XML node attribute changed; updates dialog widgets if change was not done by widgets themselves.
*/
void
CanvasXYGrid::onReprAttrChanged (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive)
{
readRepr();
if ( ! (_wr.isUpdating()) )
}
{
return vbox;
}
/**
* Update dialog widgets from object's values.
*/
void
{
if (_wr.isUpdating()) return;
_wr.setUpdating (true);
_wr.setUpdating (false);
return;
}
void
{
if (scaling_factor <= 1)
scaling_factor = 5;
/* First pass, go up to the major line spacing, then
keep increasing by two. */
scaling_factor = 2;
}
}
}
void
{
gdouble y;
} else {
}
}
gdouble x;
} else {
}
}
}
/**
* \return x rounded to the nearest multiple of c1 plus c0.
*
* \note
* If c1==0 (and c0 is finite), then returns +/-inf. This makes grid spacing of zero
* mean "ignore the grid in this dimention". We're currently discussing "good" semantics
*/
/* FIXME: move this somewhere else, perhaps */
{
}
CanvasXYGridSnapper::CanvasXYGridSnapper(CanvasXYGrid *grid, SPNamedView const *nv, NR::Coord const d) : LineSnapper(nv, d)
{
}
{
LineList s;
return s;
}
for (unsigned int i = 0; i < 2; ++i) {
/* This is to make sure we snap to only visible grid lines */
// convert screen pixels to px
// FIXME: after we switch to snapping dist in screen pixels, this will be unnecessary
if (SP_ACTIVE_DESKTOP) {
}
}
return s;
}
}; /* namespace Inkscape */
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :