summaryrefslogtreecommitdiffstats
path: root/src/display
diff options
context:
space:
mode:
authorsu_v <suv-sf@users.sourceforge.net>2012-10-29 10:01:26 +0000
committer~suv <suv-sf@users.sourceforge.net>2012-10-29 10:01:26 +0000
commit3630eed967e5b7020d1c1fc1b14fcf9819103d46 (patch)
tree2ff0fa96e32bb6aec2c208845c81cb9a19c780a9 /src/display
parentmerge from trunk (r11826) (diff)
parentFix for 165865 : Markers - fix Undo history (diff)
downloadinkscape-3630eed967e5b7020d1c1fc1b14fcf9819103d46.tar.gz
inkscape-3630eed967e5b7020d1c1fc1b14fcf9819103d46.zip
merge from trunk (r11850)
(bzr r11668.1.36)
Diffstat (limited to 'src/display')
-rw-r--r--src/display/canvas-axonomgrid.cpp116
-rw-r--r--src/display/canvas-axonomgrid.h15
-rw-r--r--src/display/canvas-grid.cpp7
-rw-r--r--src/display/canvas-text.cpp4
-rw-r--r--src/display/guideline.cpp8
-rw-r--r--src/display/nr-filter-composite.cpp9
-rw-r--r--src/display/nr-filter-image.cpp2
-rw-r--r--src/display/nr-filter-skeleton.cpp3
-rw-r--r--src/display/sodipodi-ctrl.cpp8
-rw-r--r--src/display/sodipodi-ctrlrect.cpp11
-rw-r--r--src/display/sp-canvas.cpp10
-rw-r--r--src/display/sp-ctrlpoint.cpp4
-rw-r--r--src/display/sp-ctrlquadr.cpp4
13 files changed, 106 insertions, 95 deletions
diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp
index d4e15f475..bfc6f27c4 100644
--- a/src/display/canvas-axonomgrid.cpp
+++ b/src/display/canvas-axonomgrid.cpp
@@ -2,7 +2,7 @@
* Authors:
* Johan Engelen <j.b.c.engelen@alumnus.utwente.nl>
*
- * Copyright (C) 2006-2011 Authors
+ * Copyright (C) 2006-2012 Authors
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -12,47 +12,37 @@
* smaller than 90 degrees (measured from horizontal, 0 degrees being a line extending
* to the right). The x-axis will always have an angle between 0 and 90 degrees.
*/
+
- /*
- * TODO:
- * THIS FILE AND THE HEADER FILE NEED CLEANING UP. PLEASE DO NOT HESISTATE TO DO SO.
- */
-
+#include <gtkmm/box.h>
+#include <gtkmm/label.h>
+#include <gtkmm/table.h>
#include <glibmm/i18n.h>
-#include "ui/widget/registered-widget.h"
#include "display/canvas-axonomgrid.h"
-#include "2geom/line.h"
+
+#include "ui/widget/registered-widget.h"
#include "desktop.h"
-#include "canvas-grid.h"
#include "desktop-handles.h"
#include "display/cairo-utils.h"
#include "display/canvas-grid.h"
#include "display/sp-canvas-util.h"
+#include "display/sp-canvas.h"
#include "document.h"
-#include "helper/units.h"
#include "inkscape.h"
#include "preferences.h"
#include "sp-namedview.h"
#include "sp-object.h"
#include "svg/svg-color.h"
+#include "2geom/line.h"
+#include "2geom/angle.h"
#include "util/mathfns.h"
-#include "xml/node-event-vector.h"
#include "round.h"
-#include "display/sp-canvas.h"
+#include "helper/units.h"
-#include <gtkmm/box.h>
-#include <gtkmm/label.h>
-#include <gtkmm/table.h>
enum Dim3 { X=0, Y, Z };
-#ifndef M_PI
-# define M_PI 3.14159265358979323846
-#endif
-
-static double deg_to_rad(double deg) { return deg*M_PI/180.0;}
-
/**
* This function calls Cairo to render a line on a particular canvas buffer.
* Coordinates are interpreted as SCREENcoordinates
@@ -138,9 +128,9 @@ CanvasAxonomGrid::CanvasAxonomGrid (SPNamedView * nv, Inkscape::XML::Node * in_r
angle_deg[Z] = prefs->getDouble("/options/grids/axonom/angle_z", 30.0);
angle_deg[Y] = 0;
- angle_rad[X] = deg_to_rad(angle_deg[X]);
+ angle_rad[X] = Geom::deg_to_rad(angle_deg[X]);
tan_angle[X] = tan(angle_rad[X]);
- angle_rad[Z] = deg_to_rad(angle_deg[Z]);
+ angle_rad[Z] = Geom::deg_to_rad(angle_deg[Z]);
tan_angle[Z] = tan(angle_rad[Z]);
snapper = new CanvasAxonomGridSnapper(this, &namedview->snap_manager, 0);
@@ -251,17 +241,17 @@ CanvasAxonomGrid::readRepr()
if ( (value = repr->attribute("gridanglex")) ) {
angle_deg[X] = g_ascii_strtod(value, NULL);
- if (angle_deg[X] < 1.0) angle_deg[X] = 1.0;
+ if (angle_deg[X] < 0.) angle_deg[X] = 0.;
if (angle_deg[X] > 89.0) angle_deg[X] = 89.0;
- angle_rad[X] = deg_to_rad(angle_deg[X]);
+ angle_rad[X] = Geom::deg_to_rad(angle_deg[X]);
tan_angle[X] = tan(angle_rad[X]);
}
if ( (value = repr->attribute("gridanglez")) ) {
angle_deg[Z] = g_ascii_strtod(value, NULL);
- if (angle_deg[Z] < 1.0) angle_deg[Z] = 1.0;
+ if (angle_deg[Z] < 0.) angle_deg[Z] = 0.;
if (angle_deg[Z] > 89.0) angle_deg[Z] = 89.0;
- angle_rad[Z] = deg_to_rad(angle_deg[Z]);
+ angle_rad[Z] = Geom::deg_to_rad(angle_deg[Z]);
tan_angle[Z] = tan(angle_rad[Z]);
}
@@ -477,8 +467,8 @@ CanvasAxonomGrid::Update (Geom::Affine const &affine, unsigned int /*flags*/)
spacing_ylines = sw[Geom::X] /(tan_angle[X] + tan_angle[Z]);
lyw = sw[Geom::Y];
- lxw_x = sw[Geom::X] / tan_angle[X];
- lxw_z = sw[Geom::X] / tan_angle[Z];
+ lxw_x = Geom::are_near(tan_angle[X],0.) ? Geom::infinity() : sw[Geom::X] / tan_angle[X];
+ lxw_z = Geom::are_near(tan_angle[Z],0.) ? Geom::infinity() : sw[Geom::X] / tan_angle[Z];
if (empspacing == 0) {
scaled = true;
@@ -526,8 +516,12 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf)
for (gdouble y = xstart_y_sc; y < buf->rect.bottom(); y += lyw, xlinenum++) {
gint const x0 = buf->rect.left();
gint const y0 = round(y);
- gint const x1 = x0 + round( (buf->rect.bottom() - y) / tan_angle[X] );
- gint const y1 = buf->rect.bottom();
+ gint x1 = x0 + round( (buf->rect.bottom() - y) / tan_angle[X] );
+ gint y1 = buf->rect.bottom();
+ if ( Geom::are_near(tan_angle[X],0.) ) {
+ x1 = buf->rect.right();
+ y1 = y0;
+ }
if (!scaled && (xlinenum % empspacing) != 0) {
sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
@@ -536,18 +530,21 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf)
}
}
// lines starting from top side
- gdouble const xstart_x_sc = buf->rect.left() + (lxw_x - (xstart_y_sc - buf->rect.top()) / tan_angle[X]) ;
- xlinenum = xlinestart-1;
- for (gdouble x = xstart_x_sc; x < buf->rect.right(); x += lxw_x, xlinenum--) {
- gint const y0 = buf->rect.top();
- gint const y1 = buf->rect.bottom();
- gint const x0 = round(x);
- gint const x1 = x0 + round( (y1 - y0) / tan_angle[X] );
-
- if (!scaled && (xlinenum % empspacing) != 0) {
- sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
- } else {
- sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, _empcolor);
+ if (!Geom::are_near(tan_angle[X],0.))
+ {
+ gdouble const xstart_x_sc = buf->rect.left() + (lxw_x - (xstart_y_sc - buf->rect.top()) / tan_angle[X]) ;
+ xlinenum = xlinestart-1;
+ for (gdouble x = xstart_x_sc; x < buf->rect.right(); x += lxw_x, xlinenum--) {
+ gint const y0 = buf->rect.top();
+ gint const y1 = buf->rect.bottom();
+ gint const x0 = round(x);
+ gint const x1 = x0 + round( (y1 - y0) / tan_angle[X] );
+
+ if (!scaled && (xlinenum % empspacing) != 0) {
+ sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
+ } else {
+ sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, _empcolor);
+ }
}
}
@@ -575,8 +572,12 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf)
for (gdouble y = zstart_y_sc; y < buf->rect.bottom(); y += lyw, zlinenum++, next_y = y) {
gint const x0 = buf->rect.left();
gint const y0 = round(y);
- gint const x1 = x0 + round( (y - buf->rect.top() ) / tan_angle[Z] );
- gint const y1 = buf->rect.top();
+ gint x1 = x0 + round( (y - buf->rect.top() ) / tan_angle[Z] );
+ gint y1 = buf->rect.top();
+ if ( Geom::are_near(tan_angle[Z],0.) ) {
+ x1 = buf->rect.right();
+ y1 = y0;
+ }
if (!scaled && (zlinenum % empspacing) != 0) {
sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
@@ -585,17 +586,20 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf)
}
}
// draw lines from bottom-up
- gdouble const zstart_x_sc = buf->rect.left() + (next_y - buf->rect.bottom()) / tan_angle[Z] ;
- for (gdouble x = zstart_x_sc; x < buf->rect.right(); x += lxw_z, zlinenum++) {
- gint const y0 = buf->rect.bottom();
- gint const y1 = buf->rect.top();
- gint const x0 = round(x);
- gint const x1 = x0 + round(buf->rect.height() / tan_angle[Z] );
-
- if (!scaled && (zlinenum % empspacing) != 0) {
- sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
- } else {
- sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, _empcolor);
+ if (!Geom::are_near(tan_angle[Z],0.))
+ {
+ gdouble const zstart_x_sc = buf->rect.left() + (next_y - buf->rect.bottom()) / tan_angle[Z] ;
+ for (gdouble x = zstart_x_sc; x < buf->rect.right(); x += lxw_z, zlinenum++) {
+ gint const y0 = buf->rect.bottom();
+ gint const y1 = buf->rect.top();
+ gint const x0 = round(x);
+ gint const x1 = x0 + round(buf->rect.height() / tan_angle[Z] );
+
+ if (!scaled && (zlinenum % empspacing) != 0) {
+ sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
+ } else {
+ sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, _empcolor);
+ }
}
}
diff --git a/src/display/canvas-axonomgrid.h b/src/display/canvas-axonomgrid.h
index 04919f947..0e24d3f56 100644
--- a/src/display/canvas-axonomgrid.h
+++ b/src/display/canvas-axonomgrid.h
@@ -2,9 +2,12 @@
#define CANVAS_AXONOMGRID_H
/*
- * Copyright (C) 2006-2007 Johan Engelen <johan@shouraizou.nl>
+ * Authors:
+ * Johan Engelen <j.b.c.engelen@alumnus.utwente.nl>
*
- */
+ * Copyright (C) 2006-2012 Authors
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
#include "line-snapper.h"
#include "canvas-grid.h"
@@ -15,7 +18,7 @@ struct SPNamedView;
namespace Inkscape {
namespace XML {
- class Node;
+ class Node;
};
class CanvasAxonomGrid : public CanvasGrid {
@@ -36,6 +39,9 @@ public:
bool scaled; /**< Whether the grid is in scaled mode */
+protected:
+ friend class CanvasAxonomGridSnapper;
+
Geom::Point ow; /**< Transformed origin by the affine for the zoom */
double lyw; /**< Transformed length y by the affine for the zoom */
double lxw_x;
@@ -44,7 +50,6 @@ public:
Geom::Point sw; /**< the scaling factors of the affine transform */
-protected:
virtual Gtk::Widget * newSpecificWidget();
private:
@@ -63,7 +68,7 @@ public:
bool ThisSnapperMightSnap() const;
Geom::Coord getSnapperTolerance() const; //returns the tolerance of the snapper in screen pixels (i.e. independent of zoom)
- bool getSnapperAlwaysSnap() const; //if true, then the snapper will always snap, regardless of its tolerance
+ bool getSnapperAlwaysSnap() const; //if true, then the snapper will always snap, regardless of its tolerance
private:
LineList _getSnapLines(Geom::Point const &p) const;
diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp
index 498958f08..cb33169cd 100644
--- a/src/display/canvas-grid.cpp
+++ b/src/display/canvas-grid.cpp
@@ -14,6 +14,9 @@
*/
#include <glibmm/i18n.h>
+#include <gtkmm/box.h>
+#include <gtkmm/label.h>
+#include <gtkmm/table.h>
#include "ui/widget/registered-widget.h"
#include "desktop.h"
@@ -37,10 +40,6 @@
#include "verbs.h"
#include "display/sp-canvas.h"
-#include <gtkmm/box.h>
-#include <gtkmm/label.h>
-#include <gtkmm/table.h>
-
using Inkscape::DocumentUndo;
namespace Inkscape {
diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp
index ddc946d5d..fe60d9c65 100644
--- a/src/display/canvas-text.cpp
+++ b/src/display/canvas-text.cpp
@@ -58,9 +58,9 @@ sp_canvastext_get_type (void)
static void sp_canvastext_class_init(SPCanvasTextClass *klass)
{
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass;
+ SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass);
- parent_class_ct = (SPCanvasItemClass*)g_type_class_peek_parent (klass);
+ parent_class_ct = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(klass));
item_class->destroy = sp_canvastext_destroy;
item_class->update = sp_canvastext_update;
diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp
index d3385978a..f71bc82ef 100644
--- a/src/display/guideline.cpp
+++ b/src/display/guideline.cpp
@@ -66,9 +66,9 @@ GType sp_guideline_get_type()
static void sp_guideline_class_init(SPGuideLineClass *c)
{
- parent_class = (SPCanvasItemClass*) g_type_class_peek_parent(c);
+ parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(c));
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) c;
+ SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(c);
item_class->destroy = sp_guideline_destroy;
item_class->update = sp_guideline_update;
item_class->render = sp_guideline_render;
@@ -191,8 +191,8 @@ static void sp_guideline_update(SPCanvasItem *item, Geom::Affine const &affine,
{
SPGuideLine *gl = SP_GUIDELINE(item);
- if (((SPCanvasItemClass *) parent_class)->update) {
- ((SPCanvasItemClass *) parent_class)->update(item, affine, flags);
+ if ((SP_CANVAS_ITEM_CLASS(parent_class))->update) {
+ (SP_CANVAS_ITEM_CLASS(parent_class))->update(item, affine, flags);
}
gl->affine = affine;
diff --git a/src/display/nr-filter-composite.cpp b/src/display/nr-filter-composite.cpp
index b25ecdf2c..040424cb3 100644
--- a/src/display/nr-filter-composite.cpp
+++ b/src/display/nr-filter-composite.cpp
@@ -48,10 +48,11 @@ struct ComposeArithmetic {
gint32 go = _k1*ga*gb + _k2*ga + _k3*gb + _k4;
gint32 bo = _k1*ba*bb + _k2*ba + _k3*bb + _k4;
- ao = (pxclamp(ao, 0, 255*255*255) + (255*255/2)) / (255*255);
- ro = (pxclamp(ro, 0, 255*255*255) + (255*255/2)) / (255*255);
- go = (pxclamp(go, 0, 255*255*255) + (255*255/2)) / (255*255);
- bo = (pxclamp(bo, 0, 255*255*255) + (255*255/2)) / (255*255);
+ ao = pxclamp(ao, 0, 255*255*255); // r, g and b are premultiplied, so should be clamped to the alpha channel
+ ro = (pxclamp(ro, 0, ao) + (255*255/2)) / (255*255);
+ go = (pxclamp(go, 0, ao) + (255*255/2)) / (255*255);
+ bo = (pxclamp(bo, 0, ao) + (255*255/2)) / (255*255);
+ ao = (ao + (255*255/2)) / (255*255);
ASSEMBLE_ARGB32(pxout, ao, ro, go, bo)
return pxout;
diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp
index e03a56964..bc18cbcc6 100644
--- a/src/display/nr-filter-image.cpp
+++ b/src/display/nr-filter-image.cpp
@@ -99,8 +99,10 @@ void FilterImage::render_cairo(FilterSlot &slot)
Geom::Rect area = *optarea;
Geom::Affine user2pb = slot.get_units().get_matrix_user2pb();
+ /* FIXME: These variables are currently unused. Why were they calculated?
double scaleX = feImageWidth / area.width();
double scaleY = feImageHeight / area.height();
+ */
Geom::Rect sa = slot.get_slot_area();
cairo_surface_t *out = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
diff --git a/src/display/nr-filter-skeleton.cpp b/src/display/nr-filter-skeleton.cpp
index 0c455a818..86ab8141e 100644
--- a/src/display/nr-filter-skeleton.cpp
+++ b/src/display/nr-filter-skeleton.cpp
@@ -42,7 +42,8 @@ FilterSkeleton::~FilterSkeleton()
void FilterSkeleton::render_cairo(FilterSlot &slot) {
cairo_surface_t *in = slot.getcairo(_input);
cairo_surface_t *out = ink_cairo_surface_create_identical(in);
- cairo_t *ct = cairo_create(out);
+
+// cairo_t *ct = cairo_create(out);
// cairo_set_source_surface(ct, in, offset[X], offset[Y]);
// cairo_paint(ct);
diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp
index e21bdff15..45dc38a37 100644
--- a/src/display/sodipodi-ctrl.cpp
+++ b/src/display/sodipodi-ctrl.cpp
@@ -63,10 +63,10 @@ sp_ctrl_get_type (void)
static void
sp_ctrl_class_init (SPCtrlClass *klass)
{
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass;
+ SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass);
GObjectClass *g_object_class = (GObjectClass *) klass;
- parent_class = (SPCanvasItemClass *)g_type_class_peek_parent (klass);
+ parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent (klass));
g_object_class->set_property = sp_ctrl_set_property;
g_object_class->get_property = sp_ctrl_get_property;
@@ -287,8 +287,8 @@ sp_ctrl_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int fla
ctrl = SP_CTRL (item);
- if (((SPCanvasItemClass *) parent_class)->update)
- (* ((SPCanvasItemClass *) parent_class)->update) (item, affine, flags);
+ if ((SP_CANVAS_ITEM_CLASS(parent_class))->update)
+ (* (SP_CANVAS_ITEM_CLASS(parent_class))->update) (item, affine, flags);
sp_canvas_item_reset_bounds (item);
diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp
index b0c997a92..c350e4614 100644
--- a/src/display/sodipodi-ctrlrect.cpp
+++ b/src/display/sodipodi-ctrlrect.cpp
@@ -61,9 +61,9 @@ GType sp_ctrlrect_get_type()
static void sp_ctrlrect_class_init(SPCtrlRectClass *c)
{
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) c;
+ SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(c);
- parent_class = (SPCanvasItemClass*) g_type_class_peek_parent(c);
+ parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(c));
item_class->destroy = sp_ctrlrect_destroy;
item_class->update = sp_ctrlrect_update;
@@ -119,8 +119,6 @@ void CtrlRect::render(SPCanvasBuf *buf)
using Geom::X;
using Geom::Y;
- static double const dashes[2] = {4.0, 4.0};
-
if (!_area) {
return;
}
@@ -129,6 +127,7 @@ void CtrlRect::render(SPCanvasBuf *buf)
area[X].max() + _shadow_size, area[Y].max() + _shadow_size);
if ( area_w_shadow.intersects(buf->rect) )
{
+ static double const dashes[2] = {4.0, 4.0};
cairo_save(buf->ct);
cairo_translate(buf->ct, -buf->rect.left(), -buf->rect.top());
cairo_set_line_width(buf->ct, 1);
@@ -161,8 +160,8 @@ void CtrlRect::update(Geom::Affine const &affine, unsigned int flags)
using Geom::X;
using Geom::Y;
- if (((SPCanvasItemClass *) parent_class)->update) {
- ((SPCanvasItemClass *) parent_class)->update(this, affine, flags);
+ if ((SP_CANVAS_ITEM_CLASS(parent_class))->update) {
+ (SP_CANVAS_ITEM_CLASS(parent_class))->update(this, affine, flags);
}
sp_canvas_item_reset_bounds(this);
diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp
index 6d4d01e33..536c54609 100644
--- a/src/display/sp-canvas.cpp
+++ b/src/display/sp-canvas.cpp
@@ -1081,7 +1081,7 @@ void SPCanvasGroup::update(SPCanvasItem *item, Geom::Affine const &affine, unsig
Geom::OptRect bounds;
for (GList *list = group->items; list; list = list->next) {
- SPCanvasItem *i = (SPCanvasItem *)list->data;
+ SPCanvasItem *i = SP_CANVAS_ITEM(list->data);
sp_canvas_item_invoke_update (i, affine, flags);
@@ -1118,7 +1118,7 @@ double SPCanvasGroup::point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **ac
double dist = 0.0;
for (GList *list = group->items; list; list = list->next) {
- SPCanvasItem *child = (SPCanvasItem *)list->data;
+ SPCanvasItem *child = SP_CANVAS_ITEM(list->data);
if ((child->x1 <= x2) && (child->y1 <= y2) && (child->x2 >= x1) && (child->y2 >= y1)) {
SPCanvasItem *point_item = NULL; // cater for incomplete item implementations
@@ -1152,7 +1152,7 @@ void SPCanvasGroup::render(SPCanvasItem *item, SPCanvasBuf *buf)
SPCanvasGroup const *group = SP_CANVAS_GROUP(item);
for (GList *list = group->items; list; list = list->next) {
- SPCanvasItem *child = (SPCanvasItem *)list->data;
+ SPCanvasItem *child = SP_CANVAS_ITEM(list->data);
if (child->visible) {
if ((child->x1 < buf->rect.right()) &&
(child->y1 < buf->rect.bottom()) &&
@@ -1171,7 +1171,7 @@ void SPCanvasGroup::viewboxChanged(SPCanvasItem *item, Geom::IntRect const &new_
SPCanvasGroup *group = SP_CANVAS_GROUP(item);
for (GList *list = group->items; list; list = list->next) {
- SPCanvasItem *child = (SPCanvasItem *)list->data;
+ SPCanvasItem *child = SP_CANVAS_ITEM(list->data);
if (child->visible) {
if (SP_CANVAS_ITEM_GET_CLASS(child)->viewbox_changed) {
SP_CANVAS_ITEM_GET_CLASS(child)->viewbox_changed(child, new_area);
@@ -1649,7 +1649,6 @@ int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event)
int SPCanvasImpl::pickCurrentItem(SPCanvas *canvas, GdkEvent *event)
{
int button_down = 0;
- double x, y;
if (!canvas->root) // canvas may have already be destroyed by closing desktop durring interrupted display!
return FALSE;
@@ -1709,6 +1708,7 @@ int SPCanvasImpl::pickCurrentItem(SPCanvas *canvas, GdkEvent *event)
// LeaveNotify means that there is no current item, so we don't look for one
if (canvas->pick_event.type != GDK_LEAVE_NOTIFY) {
// these fields don't have the same offsets in both types of events
+ double x, y;
if (canvas->pick_event.type == GDK_ENTER_NOTIFY) {
x = canvas->pick_event.crossing.x;
diff --git a/src/display/sp-ctrlpoint.cpp b/src/display/sp-ctrlpoint.cpp
index d07e9385b..026cc7589 100644
--- a/src/display/sp-ctrlpoint.cpp
+++ b/src/display/sp-ctrlpoint.cpp
@@ -52,9 +52,9 @@ sp_ctrlpoint_get_type (void)
static void sp_ctrlpoint_class_init(SPCtrlPointClass *klass)
{
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass;
+ SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass);
- parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass);
+ parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(klass));
item_class->destroy = sp_ctrlpoint_destroy;
item_class->update = sp_ctrlpoint_update;
diff --git a/src/display/sp-ctrlquadr.cpp b/src/display/sp-ctrlquadr.cpp
index ae15d620a..b6a0da109 100644
--- a/src/display/sp-ctrlquadr.cpp
+++ b/src/display/sp-ctrlquadr.cpp
@@ -61,9 +61,9 @@ sp_ctrlquadr_get_type (void)
static void
sp_ctrlquadr_class_init (SPCtrlQuadrClass *klass)
{
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass;
+ SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass);
- parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass);
+ parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(klass));
item_class->destroy = sp_ctrlquadr_destroy;
item_class->update = sp_ctrlquadr_update;