summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2012-01-12 01:59:22 +0000
committerJon A. Cruz <jon@joncruz.org>2012-01-12 01:59:22 +0000
commit10f55ededa291836ef120c831eac52d698440fbb (patch)
treef377c504dd3515c4983c255782c508494207ad9d /src
parentA few GSEAL issues (diff)
downloadinkscape-10f55ededa291836ef120c831eac52d698440fbb.tar.gz
inkscape-10f55ededa291836ef120c831eac52d698440fbb.zip
Initial C++ification of SPCanvas.
(bzr r10873)
Diffstat (limited to 'src')
-rw-r--r--src/arc-context.cpp7
-rw-r--r--src/box3d-context.cpp4
-rw-r--r--src/desktop.cpp13
-rw-r--r--src/display/canvas-arena.cpp8
-rw-r--r--src/display/canvas-bpath.cpp15
-rw-r--r--src/display/canvas-grid.cpp8
-rw-r--r--src/display/canvas-text.cpp7
-rw-r--r--src/display/gnome-canvas-acetate.cpp5
-rw-r--r--src/display/sodipodi-ctrl.cpp4
-rw-r--r--src/display/sodipodi-ctrlrect.cpp93
-rw-r--r--src/display/sp-canvas-item.h8
-rw-r--r--src/display/sp-canvas-util.cpp10
-rw-r--r--src/display/sp-canvas.cpp1371
-rw-r--r--src/display/sp-canvas.h93
-rw-r--r--src/display/sp-ctrlline.cpp10
-rw-r--r--src/display/sp-ctrlpoint.cpp20
-rw-r--r--src/display/sp-ctrlquadr.cpp17
-rw-r--r--src/dyna-draw-context.cpp5
-rw-r--r--src/eraser-context.cpp4
-rw-r--r--src/flood-context.cpp2
-rw-r--r--src/gradient-drag.cpp4
-rw-r--r--src/pen-context.cpp7
-rw-r--r--src/pencil-context.cpp3
-rw-r--r--src/rect-context.cpp6
-rw-r--r--src/rubberband.cpp8
-rw-r--r--src/select-context.cpp12
-rw-r--r--src/spiral-context.cpp6
-rw-r--r--src/spray-context.cpp6
-rw-r--r--src/star-context.cpp6
-rw-r--r--src/svg-view-widget.cpp4
-rw-r--r--src/tweak-context.cpp4
-rw-r--r--src/ui/tool/control-point.cpp9
-rw-r--r--src/ui/widget/selected-style.cpp5
-rw-r--r--src/ui/widget/svg-canvas.cpp3
-rw-r--r--src/widgets/desktop-widget.cpp6
-rw-r--r--src/widgets/fill-style.cpp4
-rw-r--r--src/widgets/select-toolbar.cpp4
37 files changed, 910 insertions, 891 deletions
diff --git a/src/arc-context.cpp b/src/arc-context.cpp
index 1f3e118fe..b2a7fe7a3 100644
--- a/src/arc-context.cpp
+++ b/src/arc-context.cpp
@@ -8,6 +8,7 @@
* bulia byak <buliabyak@users.sf.net>
* Johan Engelen <johan@shouraizou.nl>
* Abhishek Sharma
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2000-2006 Authors
* Copyright (C) 2000-2001 Ximian, Inc.
@@ -425,7 +426,7 @@ static void sp_arc_drag(SPArcContext *ac, Geom::Point pt, guint state)
ac->item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
ac->item->updateRepr();
- sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
+ desktop->canvas->forceFullRedrawAfterInterruptions(5);
}
bool ctrl_save = false;
@@ -502,7 +503,7 @@ static void sp_arc_finish(SPArcContext *ac)
SP_OBJECT(ac->item)->updateRepr();
- sp_canvas_end_forced_full_redraws(desktop->canvas);
+ desktop->canvas->endForcedFullRedraws();
sp_desktop_selection(desktop)->set(ac->item);
DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ARC,
@@ -529,7 +530,7 @@ static void sp_arc_cancel(SPArcContext *ac)
ac->yp = 0;
ac->item_to_select = NULL;
- sp_canvas_end_forced_full_redraws(desktop->canvas);
+ desktop->canvas->endForcedFullRedraws();
DocumentUndo::cancel(sp_desktop_document(desktop));
}
diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp
index 9c144e927..528b9b67b 100644
--- a/src/box3d-context.cpp
+++ b/src/box3d-context.cpp
@@ -634,7 +634,7 @@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
// at this point (only after finishing the box), we must do this "manually"
/* bc._vpdrag->updateDraggers(); */
- sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
+ desktop->canvas->forceFullRedrawAfterInterruptions(5);
}
g_assert(bc.item);
@@ -677,7 +677,7 @@ static void sp_box3d_finish(Box3DContext *bc)
box3d_relabel_corners(box);
- sp_canvas_end_forced_full_redraws(desktop->canvas);
+ desktop->canvas->endForcedFullRedraws();
sp_desktop_selection(desktop)->set(bc->item);
DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
diff --git a/src/desktop.cpp b/src/desktop.cpp
index c6cdb64a2..e03347e48 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -176,7 +176,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid
/* Setup Canvas */
g_object_set_data (G_OBJECT (canvas), "SPDesktop", this);
- SPCanvasGroup *root = sp_canvas_root (canvas);
+ SPCanvasGroup *root = canvas->getRoot();
/* Setup adminstrative layers */
acetate = sp_canvas_item_new (root, GNOME_TYPE_CANVAS_ACETATE, NULL);
@@ -793,8 +793,8 @@ SPDesktop::set_display_area (double x0, double y0, double x1, double y1, double
x0 = cx - 0.5 * viewbox.dimensions()[Geom::X] / newscale;
y1 = cy + 0.5 * viewbox.dimensions()[Geom::Y] / newscale;
- /* Scroll */
- sp_canvas_scroll_to (canvas, x0 * newscale - border, y1 * -newscale - border, clear);
+ // Scroll
+ canvas->scrollTo(x0 * newscale - border, y1 * -newscale - border, clear);
/* update perspective lines if we are in the 3D box tool (so that infinite ones are shown correctly) */
sp_box3d_context_update_lines(event_context);
@@ -1115,7 +1115,7 @@ SPDesktop::scroll_world (double dx, double dy, bool is_scrolling)
Geom::Rect const viewbox = canvas->getViewbox();
- sp_canvas_scroll_to(canvas, viewbox.min()[Geom::X] - dx, viewbox.min()[Geom::Y] - dy, FALSE, is_scrolling);
+ canvas->scrollTo(viewbox.min()[Geom::X] - dx, viewbox.min()[Geom::Y] - dy, FALSE, is_scrolling);
/* update perspective lines if we are in the 3D box tool (so that infinite ones are shown correctly) */
sp_box3d_context_update_lines(event_context);
@@ -1377,10 +1377,9 @@ SPDesktop::emitToolSubselectionChanged(gpointer data)
inkscape_subselection_changed (this);
}
-void
-SPDesktop::updateNow()
+void SPDesktop::updateNow()
{
- sp_canvas_update_now(canvas);
+ canvas->updateNow();
}
void
diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp
index 57c930fff..6d62c5962 100644
--- a/src/display/canvas-arena.cpp
+++ b/src/display/canvas-arena.cpp
@@ -3,6 +3,7 @@
*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2001-2002 Lauris Kaplinski
* Copyright (C) 2001 Ximian, Inc.
@@ -347,11 +348,10 @@ sp_canvas_arena_request_update (SPCanvasArena *ca, DrawingItem */*item*/)
sp_canvas_item_request_update (SP_CANVAS_ITEM (ca));
}
-static void
-sp_canvas_arena_request_render (SPCanvasArena *ca, Geom::IntRect const &area)
+static void sp_canvas_arena_request_render(SPCanvasArena *ca, Geom::IntRect const &area)
{
- SPCanvas *canvas = SP_CANVAS_ITEM (ca)->canvas;
- sp_canvas_request_redraw (canvas, area.left(), area.top(), area.right(), area.bottom());
+ SPCanvas *canvas = SP_CANVAS_ITEM(ca)->canvas;
+ canvas->requestRedraw(area.left(), area.top(), area.right(), area.bottom());
}
void
diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp
index 14f120600..a28624fe9 100644
--- a/src/display/canvas-bpath.cpp
+++ b/src/display/canvas-bpath.cpp
@@ -3,6 +3,7 @@
*
* Authors:
* Lauris Kaplinski <lauris@ximian.com>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2001 Lauris Kaplinski and Ximian, Inc.
*
@@ -99,15 +100,15 @@ sp_canvas_bpath_destroy (GtkObject *object)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
-static void
-sp_canvas_bpath_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags)
+static void sp_canvas_bpath_update(SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags)
{
- SPCanvasBPath *cbp = SP_CANVAS_BPATH (item);
+ SPCanvasBPath *cbp = SP_CANVAS_BPATH(item);
- sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
- if (((SPCanvasItemClass *) parent_class)->update)
- ((SPCanvasItemClass *) parent_class)->update (item, affine, flags);
+ if (reinterpret_cast<SPCanvasItemClass *>(parent_class)->update) {
+ reinterpret_cast<SPCanvasItemClass *>(parent_class)->update(item, affine, flags);
+ }
sp_canvas_item_reset_bounds (item);
@@ -128,7 +129,7 @@ sp_canvas_bpath_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned
item->x2 = 0;
item->y2 = 0;
}
- sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
}
static void
diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp
index 734ce2043..bc3b01692 100644
--- a/src/display/canvas-grid.cpp
+++ b/src/display/canvas-grid.cpp
@@ -4,6 +4,7 @@
/* Copyright (C) Johan Engelen 2006-2007 <johan@shouraizou.nl>
* Copyright (C) Lauris Kaplinski 2000
* Abhishek Sharma
+ * Jon A. Cruz <jon@joncruz.org>
*/
/* As a general comment, I am not exactly proud of how things are done.
@@ -74,7 +75,7 @@ grid_canvasitem_get_type (void)
NULL
};
- grid_canvasitem_type = g_type_register_static (sp_canvas_item_get_type (), "GridCanvasItem", &grid_canvasitem_info, (GTypeFlags)0);
+ grid_canvasitem_type = g_type_register_static(SPCanvasItem::getType(), "GridCanvasItem", &grid_canvasitem_info, GTypeFlags(0));
}
return grid_canvasitem_type;
}
@@ -136,9 +137,8 @@ grid_canvasitem_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned
if (gridcanvasitem->grid) {
gridcanvasitem->grid->Update(affine, flags);
- sp_canvas_request_redraw (item->canvas,
- -1000000, -1000000,
- 1000000, 1000000);
+ item->canvas->requestRedraw(-1000000, -1000000,
+ 1000000, 1000000);
item->x1 = item->y1 = -1000000;
item->x2 = item->y2 = 1000000;
diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp
index 3a51fc570..7d765d970 100644
--- a/src/display/canvas-text.cpp
+++ b/src/display/canvas-text.cpp
@@ -1,11 +1,10 @@
-#define __SP_CANVASTEXT_C__
-
/*
* Canvas text
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Maximilian Albert <maximilian.albert@gmail.com>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2000-2002 Lauris Kaplinski
* Copyright (C) 2008 Maximilian Albert
@@ -153,7 +152,7 @@ sp_canvastext_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned i
{
SPCanvasText *cl = SP_CANVASTEXT (item);
- sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
if (parent_class_ct->update)
(* parent_class_ct->update) (item, affine, flags);
@@ -252,7 +251,7 @@ sp_canvastext_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned i
item->y1 -= cl->anchor_offset_y;
item->y2 -= cl->anchor_offset_y;
- sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
}
SPCanvasItem *
diff --git a/src/display/gnome-canvas-acetate.cpp b/src/display/gnome-canvas-acetate.cpp
index d6ebfa175..0891836b5 100644
--- a/src/display/gnome-canvas-acetate.cpp
+++ b/src/display/gnome-canvas-acetate.cpp
@@ -1,5 +1,3 @@
-#define __SP_CANVAS_ACETATE_C__
-
/*
* Infinite invisible canvas item
*
@@ -7,6 +5,7 @@
* Federico Mena <federico@nuclecu.unam.mx>
* Raph Levien <raph@acm.org>
* Lauris Kaplinski <lauris@kaplinski.com>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 1998-1999 The Free Software Foundation
* Copyright (C) 2002 Lauris Kaplinski
@@ -39,7 +38,7 @@ GType sp_canvas_acetate_get_type (void)
(GInstanceInitFunc) sp_canvas_acetate_init,
NULL
};
- acetate_type = g_type_register_static (sp_canvas_item_get_type (), "SPCanvasAcetate", &acetate_info, (GTypeFlags)0);
+ acetate_type = g_type_register_static(SPCanvasItem::getType(), "SPCanvasAcetate", &acetate_info, GTypeFlags(0));
}
return acetate_type;
}
diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp
index a23cbd745..b4fbaefc6 100644
--- a/src/display/sodipodi-ctrl.cpp
+++ b/src/display/sodipodi-ctrl.cpp
@@ -1,5 +1,3 @@
-#define INKSCAPE_CTRL_C
-
/*
* SPCtrl
*
@@ -232,7 +230,7 @@ sp_ctrl_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int fla
if (!ctrl->_moved) return;
if (ctrl->shown) {
- sp_canvas_request_redraw (item->canvas, ctrl->box.left(), ctrl->box.top(), ctrl->box.right() + 1, ctrl->box.bottom() + 1);
+ item->canvas->requestRedraw(ctrl->box.left(), ctrl->box.top(), ctrl->box.right() + 1, ctrl->box.bottom() + 1);
}
if (!ctrl->defined) return;
diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp
index c0e08c00a..7942514a7 100644
--- a/src/display/sodipodi-ctrlrect.cpp
+++ b/src/display/sodipodi-ctrlrect.cpp
@@ -1,5 +1,3 @@
-#define __INKSCAPE_CTRLRECT_C__
-
/*
* Simple non-transformed rectangle, usable for rubberband
*
@@ -7,6 +5,7 @@
* Lauris Kaplinski <lauris@ximian.com>
* bulia byak <buliabyak@users.sf.net>
* Carl Hetherington <inkscape@carlh.net>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 1999-2001 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
@@ -188,110 +187,92 @@ void CtrlRect::update(Geom::Affine const &affine, unsigned int flags)
// FIXME: we don't process a possible change in _has_fill
if (_has_fill) {
if (_area_old) {
- sp_canvas_request_redraw(canvas,
- area_old[X].min() - 1, area_old[Y].min() - 1,
- area_old[X].max() + _shadow_size + 1, area_old[Y].max() + _shadow_size + 1);
+ canvas->requestRedraw(area_old[X].min() - 1, area_old[Y].min() - 1,
+ area_old[X].max() + _shadow_size + 1, area_old[Y].max() + _shadow_size + 1);
}
if (_area) {
- sp_canvas_request_redraw(canvas,
- area[X].min() - 1, area[Y].min() - 1,
- area[X].max() + _shadow_size + 1, area[Y].max() + _shadow_size + 1);
+ canvas->requestRedraw(area[X].min() - 1, area[Y].min() - 1,
+ area[X].max() + _shadow_size + 1, area[Y].max() + _shadow_size + 1);
}
} else { // clear box, be smart about what part of the frame to redraw
/* Top */
if (area[Y].min() != area_old[Y].min()) { // different level, redraw fully old and new
if (area_old[X].min() != area_old[X].max())
- sp_canvas_request_redraw(canvas,
- area_old[X].min() - 1, area_old[Y].min() - 1,
- area_old[X].max() + 1, area_old[Y].min() + 1);
+ canvas->requestRedraw(area_old[X].min() - 1, area_old[Y].min() - 1,
+ area_old[X].max() + 1, area_old[Y].min() + 1);
if (area[X].min() != area[X].max())
- sp_canvas_request_redraw(canvas,
- area[X].min() - 1, area[Y].min() - 1,
- area[X].max() + 1, area[Y].min() + 1);
+ canvas->requestRedraw(area[X].min() - 1, area[Y].min() - 1,
+ area[X].max() + 1, area[Y].min() + 1);
} else { // same level, redraw only the ends
if (area[X].min() != area_old[X].min()) {
- sp_canvas_request_redraw(canvas,
- MIN(area_old[X].min(),area[X].min()) - 1, area[Y].min() - 1,
- MAX(area_old[X].min(),area[X].min()) + 1, area[Y].min() + 1);
+ canvas->requestRedraw(MIN(area_old[X].min(),area[X].min()) - 1, area[Y].min() - 1,
+ MAX(area_old[X].min(),area[X].min()) + 1, area[Y].min() + 1);
}
if (area[X].max() != area_old[X].max()) {
- sp_canvas_request_redraw(canvas,
- MIN(area_old[X].max(),area[X].max()) - 1, area[Y].min() - 1,
- MAX(area_old[X].max(),area[X].max()) + 1, area[Y].min() + 1);
+ canvas->requestRedraw(MIN(area_old[X].max(),area[X].max()) - 1, area[Y].min() - 1,
+ MAX(area_old[X].max(),area[X].max()) + 1, area[Y].min() + 1);
}
}
/* Left */
if (area[X].min() != area_old[X].min()) { // different level, redraw fully old and new
if (area_old[Y].min() != area_old[Y].max())
- sp_canvas_request_redraw(canvas,
- area_old[X].min() - 1, area_old[Y].min() - 1,
- area_old[X].min() + 1, area_old[Y].max() + 1);
+ canvas->requestRedraw(area_old[X].min() - 1, area_old[Y].min() - 1,
+ area_old[X].min() + 1, area_old[Y].max() + 1);
if (area[Y].min() != area[Y].max())
- sp_canvas_request_redraw(canvas,
- area[X].min() - 1, area[Y].min() - 1,
- area[X].min() + 1, area[Y].max() + 1);
+ canvas->requestRedraw(area[X].min() - 1, area[Y].min() - 1,
+ area[X].min() + 1, area[Y].max() + 1);
} else { // same level, redraw only the ends
if (area[Y].min() != area_old[Y].min()) {
- sp_canvas_request_redraw(canvas,
- area[X].min() - 1, MIN(area_old[Y].min(),area[Y].min()) - 1,
- area[X].min() + 1, MAX(area_old[Y].min(),area[Y].min()) + 1);
+ canvas->requestRedraw(area[X].min() - 1, MIN(area_old[Y].min(),area[Y].min()) - 1,
+ area[X].min() + 1, MAX(area_old[Y].min(),area[Y].min()) + 1);
}
if (area[Y].max() != area_old[Y].max()) {
- sp_canvas_request_redraw(canvas,
- area[X].min() - 1, MIN(area_old[Y].max(),area[Y].max()) - 1,
- area[X].min() + 1, MAX(area_old[Y].max(),area[Y].max()) + 1);
+ canvas->requestRedraw(area[X].min() - 1, MIN(area_old[Y].max(),area[Y].max()) - 1,
+ area[X].min() + 1, MAX(area_old[Y].max(),area[Y].max()) + 1);
}
}
/* Right */
if (area[X].max() != area_old[X].max() || _shadow_size_old != _shadow_size) {
if (area_old[Y].min() != area_old[Y].max())
- sp_canvas_request_redraw(canvas,
- area_old[X].max() - 1, area_old[Y].min() - 1,
- area_old[X].max() + _shadow_size + 1, area_old[Y].max() + _shadow_size + 1);
+ canvas->requestRedraw(area_old[X].max() - 1, area_old[Y].min() - 1,
+ area_old[X].max() + _shadow_size + 1, area_old[Y].max() + _shadow_size + 1);
if (area[Y].min() != area[Y].max())
- sp_canvas_request_redraw(canvas,
- area[X].max() - 1, area[Y].min() - 1,
- area[X].max() + _shadow_size + 1, area[Y].max() + _shadow_size + 1);
+ canvas->requestRedraw(area[X].max() - 1, area[Y].min() - 1,
+ area[X].max() + _shadow_size + 1, area[Y].max() + _shadow_size + 1);
} else { // same level, redraw only the ends
if (area[Y].min() != area_old[Y].min()) {
- sp_canvas_request_redraw(canvas,
- area[X].max() - 1, MIN(area_old[Y].min(),area[Y].min()) - 1,
- area[X].max() + _shadow_size + 1, MAX(area_old[Y].min(),area[Y].min()) + _shadow_size + 1);
+ canvas->requestRedraw(area[X].max() - 1, MIN(area_old[Y].min(),area[Y].min()) - 1,
+ area[X].max() + _shadow_size + 1, MAX(area_old[Y].min(),area[Y].min()) + _shadow_size + 1);
}
if (area[Y].max() != area_old[Y].max()) {
- sp_canvas_request_redraw(canvas,
- area[X].max() - 1, MIN(area_old[Y].max(),area[Y].max()) - 1,
- area[X].max() + _shadow_size + 1, MAX(area_old[Y].max(),area[Y].max()) + _shadow_size + 1);
+ canvas->requestRedraw(area[X].max() - 1, MIN(area_old[Y].max(),area[Y].max()) - 1,
+ area[X].max() + _shadow_size + 1, MAX(area_old[Y].max(),area[Y].max()) + _shadow_size + 1);
}
}
/* Bottom */
if (area[Y].max() != area_old[Y].max() || _shadow_size_old != _shadow_size) {
if (area_old[X].min() != area_old[X].max())
- sp_canvas_request_redraw(canvas,
- area_old[X].min() - 1, area_old[Y].max() - 1,
- area_old[X].max() + _shadow_size + 1, area_old[Y].max() + _shadow_size + 1);
+ canvas->requestRedraw(area_old[X].min() - 1, area_old[Y].max() - 1,
+ area_old[X].max() + _shadow_size + 1, area_old[Y].max() + _shadow_size + 1);
if (area[X].min() != area[X].max())
- sp_canvas_request_redraw(canvas,
- area[X].min() - 1, area[Y].max() - 1,
- area[X].max() + _shadow_size + 1, area[Y].max() + _shadow_size + 1);
+ canvas->requestRedraw(area[X].min() - 1, area[Y].max() - 1,
+ area[X].max() + _shadow_size + 1, area[Y].max() + _shadow_size + 1);
} else { // same level, redraw only the ends
if (area[X].min() != area_old[X].min()) {
- sp_canvas_request_redraw(canvas,
- MIN(area_old[X].min(),area[X].min()) - 1, area[Y].max() - 1,
- MAX(area_old[X].min(),area[X].min()) + _shadow_size + 1, area[Y].max() + _shadow_size + 1);
+ canvas->requestRedraw(MIN(area_old[X].min(),area[X].min()) - 1, area[Y].max() - 1,
+ MAX(area_old[X].min(),area[X].min()) + _shadow_size + 1, area[Y].max() + _shadow_size + 1);
}
if (area[X].max() != area_old[X].max()) {
- sp_canvas_request_redraw(canvas,
- MIN(area_old[X].max(),area[X].max()) - 1, area[Y].max() - 1,
- MAX(area_old[X].max(),area[X].max()) + _shadow_size + 1, area[Y].max() + _shadow_size + 1);
+ canvas->requestRedraw(MIN(area_old[X].max(),area[X].max()) - 1, area[Y].max() - 1,
+ MAX(area_old[X].max(),area[X].max()) + _shadow_size + 1, area[Y].max() + _shadow_size + 1);
}
}
}
diff --git a/src/display/sp-canvas-item.h b/src/display/sp-canvas-item.h
index 2c1dbdcf0..c70a4e241 100644
--- a/src/display/sp-canvas-item.h
+++ b/src/display/sp-canvas-item.h
@@ -36,18 +36,18 @@ struct SPCanvasGroup;
typedef struct _SPCanvasItemClass SPCanvasItemClass;
-#define SP_TYPE_CANVAS_ITEM (sp_canvas_item_get_type())
+#define SP_TYPE_CANVAS_ITEM (SPCanvasItem::getType())
#define SP_CANVAS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_CANVAS_ITEM, SPCanvasItem))
#define SP_IS_CANVAS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_CANVAS_ITEM))
#define SP_CANVAS_ITEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), SP_TYPE_CANVAS_ITEM, SPCanvasItemClass))
-GType sp_canvas_item_get_type();
-
/**
* An SPCanvasItem refers to a SPCanvas and to its parent item; it has
* four coordinates, a bounding rectangle, and a transformation matrix.
*/
struct SPCanvasItem : public GtkObject {
+ static GType getType();
+
SPCanvas *canvas;
SPCanvasItem *parent;
@@ -88,8 +88,6 @@ void sp_canvas_item_ungrab(SPCanvasItem *item, guint32 etime);
Geom::Affine sp_canvas_item_i2w_affine(SPCanvasItem const *item);
-void sp_canvas_item_grab_focus(SPCanvasItem *item);
-
void sp_canvas_item_request_update(SPCanvasItem *item);
/* get item z-order in parent group */
diff --git a/src/display/sp-canvas-util.cpp b/src/display/sp-canvas-util.cpp
index 78936009b..79c8c614e 100644
--- a/src/display/sp-canvas-util.cpp
+++ b/src/display/sp-canvas-util.cpp
@@ -1,10 +1,9 @@
-#define __SP_CANVAS_UTILS_C__
-
/*
* Helper stuff for SPCanvas
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 1999-2002 authors
* Copyright (C) 2001-2002 Ximian, Inc.
@@ -18,15 +17,14 @@
#include "sp-canvas-item.h"
#include "sp-canvas.h"
-void
-sp_canvas_update_bbox (SPCanvasItem *item, int x1, int y1, int x2, int y2)
+void sp_canvas_update_bbox(SPCanvasItem *item, int x1, int y1, int x2, int y2)
{
- sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
item->x1 = x1;
item->y1 = y1;
item->x2 = x2;
item->y2 = y2;
- sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
}
void
diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp
index 71700d6a5..cddef2fda 100644
--- a/src/display/sp-canvas.cpp
+++ b/src/display/sp-canvas.cpp
@@ -7,6 +7,7 @@
* Lauris Kaplinski <lauris@kaplinski.com>
* fred
* bbyak
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 1998 The Free Software Foundation
* Copyright (C) 2002-2006 authors
@@ -50,32 +51,80 @@ static bool const HAS_BROKEN_MOTION_HINTS =
// If any part of it is dirtied, the entire tile is dirtied (its int is nonzero) and repainted.
#define TILE_SIZE 16
-static gint const sp_canvas_update_priority = G_PRIORITY_HIGH_IDLE;
-
-#define SP_CANVAS_WINDOW(c) (gtk_widget_get_window ((GtkWidget *) (c)))
-
-enum {
- SP_CANVAS_ITEM_VISIBLE = 1 << 7,
- SP_CANVAS_ITEM_NEED_UPDATE = 1 << 8,
- SP_CANVAS_ITEM_NEED_AFFINE = 1 << 9
+/**
+ * The SPCanvasGroup vtable.
+ */
+struct SPCanvasGroupClass {
+ SPCanvasItemClass parent_class;
};
/**
* A group of Items.
*/
struct SPCanvasGroup {
+ static GType getType();
+
+ /**
+ * Adds an item to a canvas group.
+ */
+ void add(SPCanvasItem *item);
+
+ /**
+ * Removes an item from a canvas group.
+ */
+ void remove(SPCanvasItem *item);
+
+ /**
+ * Class initialization function for SPCanvasGroupClass.
+ */
+ static void classInit(SPCanvasGroupClass *klass);
+
+ /**
+ * Callback. Empty.
+ */
+ static void init(SPCanvasGroup *group);
+
+ /**
+ * Callback that destroys all items in group and calls group's virtual
+ * destroy() function.
+ */
+ static void destroy(GtkObject *object);
+
+ /**
+ * Update handler for canvas groups.
+ */
+ static void update(SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags);
+
+ /**
+ * Point handler for canvas groups.
+ */
+ static double point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item);
+
+ /**
+ * Renders all visible canvas group items in buf rectangle.
+ */
+ static void render(SPCanvasItem *item, SPCanvasBuf *buf);
+
+ static void viewboxChanged(SPCanvasItem *item, Geom::IntRect const &new_area);
+
+
+ // Data members: ----------------------------------------------------------
+
SPCanvasItem item;
- GList *items, *last;
-};
+ GList *items;
+ GList *last;
-/**
- * The SPCanvasGroup vtable.
- */
-struct SPCanvasGroupClass {
- SPCanvasItemClass parent_class;
+ static SPCanvasItemClass *parentClass;
};
+SPCanvasItemClass *SPCanvasGroup::parentClass;
+
+GType sp_canvas_group_get_type()
+{
+ return SPCanvasGroup::getType();
+}
+
/**
* The SPCanvas vtable.
*/
@@ -83,57 +132,266 @@ struct SPCanvasClass {
GtkWidgetClass parent_class;
};
-static void group_add (SPCanvasGroup *group, SPCanvasItem *item);
-static void group_remove (SPCanvasGroup *group, SPCanvasItem *item);
+namespace {
+
+gint const UPDATE_PRIORITY = G_PRIORITY_HIGH_IDLE;
+
+GdkWindow *getWindow(SPCanvas *canvas)
+{
+ return gtk_widget_get_window(reinterpret_cast<GtkWidget *>(canvas));
+}
+
+enum {
+ SP_CANVAS_ITEM_VISIBLE = 1 << 7,
+ SP_CANVAS_ITEM_NEED_UPDATE = 1 << 8,
+ SP_CANVAS_ITEM_NEED_AFFINE = 1 << 9
+};
+
+// SPCanvasItem
-/* SPCanvasItem */
+enum {
+ ITEM_EVENT,
+ ITEM_LAST_SIGNAL
+};
-enum {ITEM_EVENT, ITEM_LAST_SIGNAL};
-enum {PROP_0, PROP_VISIBLE};
+enum {
+ PROP_0,
+ PROP_VISIBLE
+};
-static void sp_canvas_request_update (SPCanvas *canvas);
+void trackLatency(GdkEvent const *event);
-static void track_latency(GdkEvent const *event);
-static void sp_canvas_item_class_init (SPCanvasItemClass *klass);
-static void sp_canvas_item_init (SPCanvasItem *item);
-static void sp_canvas_item_dispose (GObject *object);
-static void sp_canvas_item_construct (SPCanvasItem *item, SPCanvasGroup *parent, gchar const *first_arg_name, va_list args);
+/**
+ * Initializes the SPCanvasItem vtable and the "event" signal.
+ */
+void sp_canvas_item_class_init(SPCanvasItemClass *klass);
-static int emit_event (SPCanvas *canvas, GdkEvent *event);
-static int pick_current_item (SPCanvas *canvas, GdkEvent *event);
+/**
+ * Callback for initialization of SPCanvasItem.
+ */
+void sp_canvas_item_init(SPCanvasItem *item);
-static guint item_signals[ITEM_LAST_SIGNAL] = { 0 };
+/**
+ * Callback that removes item from all referers and destroys it.
+ */
+void sp_canvas_item_dispose(GObject *object);
+
+/**
+ * Sets up the newly created SPCanvasItem.
+ *
+ * We make it static for encapsulation reasons since it was nowhere used.
+ */
+void sp_canvas_item_construct(SPCanvasItem *item, SPCanvasGroup *parent, gchar const *first_arg_name, va_list args);
/**
- * Registers the SPCanvasItem class with Glib and returns its type number.
+ * Convenience function to reorder items in a group's child list.
+ *
+ * This puts the specified link after the "before" link.
*/
-GType
-sp_canvas_item_get_type (void)
+void put_item_after(GList *link, GList *before);
+
+/**
+ * Helper that returns true iff item is descendant of parent.
+ */
+bool is_descendant(SPCanvasItem const *item, SPCanvasItem const *parent);
+
+guint item_signals[ITEM_LAST_SIGNAL] = { 0 };
+
+struct PaintRectSetup;
+
+} // namespace
+
+class SPCanvasImpl
+{
+public:
+
+ /**
+ * Helper that emits an event for an item in the canvas, be it the current
+ * item, grabbed item, or focused item, as appropriate.
+ */
+ static int emitEvent(SPCanvas *canvas, GdkEvent *event);
+
+ /**
+ * Helper that re-picks the current item in the canvas, based on the event's
+ * coordinates and emits enter/leave events for items as appropriate.
+ */
+ static int pickCurrentItem(SPCanvas *canvas, GdkEvent *event);
+
+ /**
+ * Class initialization function for SPCanvasClass.
+ */
+ static void classInit(SPCanvasClass *klass);
+
+ /**
+ * Callback: object initialization for SPCanvas.
+ */
+ static void init(SPCanvas *canvas);
+
+ /**
+ * Destroy handler for SPCanvas.
+ */
+ static void destroy(GtkObject *object);
+
+ /**
+ * The canvas widget's realize callback.
+ */
+ static void realize(GtkWidget *widget);
+
+ /**
+ * The canvas widget's unrealize callback.
+ */
+ static void unrealize(GtkWidget *widget);
+
+ /**
+ * The canvas widget's size request callback.
+ */
+ static void sizeRequest(GtkWidget *widget, GtkRequisition *req);
+
+ /**
+ * The canvas widget's size allocate callback.
+ */
+ static void sizeAllocate(GtkWidget *widget, GtkAllocation *allocation);
+
+ /**
+ * Button event handler for the canvas.
+ */
+ static gint button(GtkWidget *widget, GdkEventButton *event);
+
+ /**
+ * Scroll event handler for the canvas.
+ *
+ * @todo FIXME: generate motion events to re-select items.
+ */
+ static gint handleScroll(GtkWidget *widget, GdkEventScroll *event);
+
+ /**
+ * Motion event handler for the canvas.
+ */
+ static gint handleMotion(GtkWidget *widget, GdkEventMotion *event);
+
+ /**
+ * The canvas widget's expose callback.
+ */
+ static gint handleExpose(GtkWidget *widget, GdkEventExpose *event);
+
+ /**
+ * The canvas widget's keypress callback.
+ */
+ static gint handleKeyEvent(GtkWidget *widget, GdkEventKey *event);
+
+ /**
+ * Crossing event handler for the canvas.
+ */
+ static gint handleCrossing(GtkWidget *widget, GdkEventCrossing *event);
+
+ /**
+ * Focus in handler for the canvas.
+ */
+ static gint handleFocusIn(GtkWidget *widget, GdkEventFocus *event);
+
+ /**
+ * Focus out handler for the canvas.
+ */
+ static gint handleFocusOut(GtkWidget *widget, GdkEventFocus *event);
+
+ /**
+ * Helper that allocates a new tile array for the canvas, copying overlapping tiles from the old array
+ */
+ static void sp_canvas_resize_tiles(SPCanvas* canvas, int nl, int nt, int nr, int nb);
+
+ /**
+ * Helper that queues a canvas rectangle for redraw
+ */
+ static void sp_canvas_dirty_rect(SPCanvas* canvas, Geom::IntRect const &area);
+
+ /**
+ * Helper that marks specific canvas rectangle as clean (val == 0) or dirty (otherwise)
+ */
+ static void sp_canvas_mark_rect(SPCanvas* canvas, Geom::IntRect const &area, uint8_t val);
+
+ /**
+ * Helper that invokes update, paint, and repick on canvas.
+ */
+ static int do_update(SPCanvas *canvas);
+
+ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect const &paint_rect, Geom::IntRect const &canvas_rect, int sw);
+
+ /**
+ * Paint the given rect, recursively subdividing the region until it is the size of a single
+ * buffer.
+ *
+ * @return true if the drawing completes
+ */
+ static int sp_canvas_paint_rect_internal(PaintRectSetup const *setup, Geom::IntRect const &this_rect);
+
+ /**
+ * Helper that draws a specific rectangular part of the canvas.
+ *
+ * @return true if the rectangle painting succeeds.
+ */
+ static bool sp_canvas_paint_rect(SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1);
+
+ /**
+ * Helper that repaints the areas in the canvas that need it.
+ *
+ * @return true if all the dirty parts have been redrawn
+ */
+ static int paint(SPCanvas *canvas);
+
+ /**
+ * Idle handler for the canvas that deals with pending updates and redraws.
+ */
+ static gint idle_handler(gpointer data);
+
+ /**
+ * Convenience function to add an idle handler to a canvas.
+ */
+ static void add_idle(SPCanvas *canvas);
+
+ /**
+ * Convenience function to remove the idle handler of a canvas.
+ */
+ static void remove_idle(SPCanvas *canvas);
+
+ /**
+ * Removes the transient state of the canvas (idle handler, grabs).
+ */
+ static void shutdown_transients(SPCanvas *canvas);
+
+ /**
+ * Update callback for canvas widget.
+ */
+ static void requestCanvasUpdate(SPCanvas *canvas);
+
+ static GtkWidgetClass *parentClass;
+};
+
+GtkWidgetClass *SPCanvasImpl::parentClass = 0;
+
+GType SPCanvasItem::getType()
{
static GType type = 0;
if (!type) {
static GTypeInfo const info = {
- sizeof (SPCanvasItemClass),
+ sizeof(SPCanvasItemClass),
NULL, NULL,
- (GClassInitFunc) sp_canvas_item_class_init,
+ reinterpret_cast<GClassInitFunc>(sp_canvas_item_class_init),
NULL, NULL,
- sizeof (SPCanvasItem),
+ sizeof(SPCanvasItem),
0,
- (GInstanceInitFunc) sp_canvas_item_init,
+ reinterpret_cast<GInstanceInitFunc>(sp_canvas_item_init),
NULL
};
- type = g_type_register_static (GTK_TYPE_OBJECT, "SPCanvasItem", &info, (GTypeFlags)0);
+ type = g_type_register_static(GTK_TYPE_OBJECT, "SPCanvasItem", &info, GTypeFlags(0));
}
return type;
}
-/**
- * Initializes the SPCanvasItem vtable and the "event" signal.
- */
-static void
-sp_canvas_item_class_init (SPCanvasItemClass *klass)
+namespace {
+
+void sp_canvas_item_class_init(SPCanvasItemClass *klass)
{
GObjectClass *object_class = (GObjectClass *) klass;
@@ -149,11 +407,7 @@ sp_canvas_item_class_init (SPCanvasItemClass *klass)
object_class->dispose = sp_canvas_item_dispose;
}
-/**
- * Callback for initialization of SPCanvasItem.
- */
-static void
-sp_canvas_item_init (SPCanvasItem *item)
+void sp_canvas_item_init(SPCanvasItem *item)
{
// TODO items should not be visible on creation - this causes kludges with items
// that should be initially invisible; examples of such items: node handles, the CtrlRect
@@ -162,17 +416,18 @@ sp_canvas_item_init (SPCanvasItem *item)
item->xform = Geom::Affine(Geom::identity());
}
+} // namespace
+
/**
* Constructs new SPCanvasItem on SPCanvasGroup.
*/
-SPCanvasItem *
-sp_canvas_item_new (SPCanvasGroup *parent, GType type, gchar const *first_arg_name, ...)
+SPCanvasItem *sp_canvas_item_new(SPCanvasGroup *parent, GType type, gchar const *first_arg_name, ...)
{
va_list args;
- g_return_val_if_fail (parent != NULL, NULL);
- g_return_val_if_fail (SP_IS_CANVAS_GROUP (parent), NULL);
- g_return_val_if_fail (g_type_is_a (type, sp_canvas_item_get_type ()), NULL);
+ g_return_val_if_fail(parent != NULL, NULL);
+ g_return_val_if_fail(SP_IS_CANVAS_GROUP (parent), NULL);
+ g_return_val_if_fail(g_type_is_a(type, SPCanvasItem::getType()), NULL);
SPCanvasItem *item = SP_CANVAS_ITEM (g_object_new (type, NULL));
@@ -183,13 +438,9 @@ sp_canvas_item_new (SPCanvasGroup *parent, GType type, gchar const *first_arg_na
return item;
}
-/**
- * Sets up the newly created SPCanvasItem.
- *
- * We make it static for encapsulation reasons since it was nowhere used.
- */
-static void
-sp_canvas_item_construct (SPCanvasItem *item, SPCanvasGroup *parent, gchar const *first_arg_name, va_list args)
+namespace {
+
+void sp_canvas_item_construct(SPCanvasItem *item, SPCanvasGroup *parent, gchar const *first_arg_name, va_list args)
{
g_return_if_fail (SP_IS_CANVAS_GROUP (parent));
g_return_if_fail (SP_IS_CANVAS_ITEM (item));
@@ -199,16 +450,17 @@ sp_canvas_item_construct (SPCanvasItem *item, SPCanvasGroup *parent, gchar const
g_object_set_valist (G_OBJECT (item), first_arg_name, args);
- group_add (SP_CANVAS_GROUP (item->parent), item);
+ SP_CANVAS_GROUP(item->parent)->add(item);
sp_canvas_item_request_update (item);
}
+} // namespace
+
/**
* Helper function that requests redraw only if item's visible flag is set.
*/
-static void
-redraw_if_visible (SPCanvasItem *item)
+static void redraw_if_visible(SPCanvasItem *item)
{
if (item->flags & SP_CANVAS_ITEM_VISIBLE) {
int x0 = (int)(item->x1);
@@ -217,16 +469,14 @@ redraw_if_visible (SPCanvasItem *item)
int y1 = (int)(item->y2);
if (x0 !=0 || x1 !=0 || y0 !=0 || y1 !=0) {
- sp_canvas_request_redraw (item->canvas, (int)(item->x1), (int)(item->y1), (int)(item->x2 + 1), (int)(item->y2 + 1));
+ item->canvas->requestRedraw((int)(item->x1), (int)(item->y1), (int)(item->x2 + 1), (int)(item->y2 + 1));
}
}
}
-/**
- * Callback that removes item from all referers and destroys it.
- */
-static void
-sp_canvas_item_dispose (GObject *object)
+namespace {
+
+void sp_canvas_item_dispose(GObject *object)
{
SPCanvasItem *item = SP_CANVAS_ITEM (object);
@@ -256,39 +506,44 @@ sp_canvas_item_dispose (GObject *object)
gdk_pointer_ungrab (GDK_CURRENT_TIME);
}
- if (item == item->canvas->focused_item)
+ if (item == item->canvas->focused_item) {
item->canvas->focused_item = NULL;
+ }
if (item->parent) {
- group_remove (SP_CANVAS_GROUP (item->parent), item);
+ SP_CANVAS_GROUP(item->parent)->remove(item);
}
- G_OBJECT_CLASS (g_type_class_peek(g_type_parent(sp_canvas_item_get_type())))->dispose (object);
+ G_OBJECT_CLASS(g_type_class_peek(g_type_parent(SPCanvasItem::getType())))->dispose(object);
}
+} // namespace
+
/**
* Helper function to update item and its children.
*
* NB! affine is parent2canvas.
*/
-static void
-sp_canvas_item_invoke_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags)
+static void sp_canvas_item_invoke_update(SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags)
{
- /* Apply the child item's transform */
+ // Apply the child item's transform
Geom::Affine child_affine = item->xform * affine;
- /* apply object flags to child flags */
+ // apply object flags to child flags
int child_flags = flags & ~SP_CANVAS_UPDATE_REQUESTED;
- if (item->flags & SP_CANVAS_ITEM_NEED_UPDATE)
+ if (item->flags & SP_CANVAS_ITEM_NEED_UPDATE) {
child_flags |= SP_CANVAS_UPDATE_REQUESTED;
+ }
- if (item->flags & SP_CANVAS_ITEM_NEED_AFFINE)
+ if (item->flags & SP_CANVAS_ITEM_NEED_AFFINE) {
child_flags |= SP_CANVAS_UPDATE_AFFINE;
+ }
if (child_flags & (SP_CANVAS_UPDATE_REQUESTED | SP_CANVAS_UPDATE_AFFINE)) {
- if (SP_CANVAS_ITEM_GET_CLASS (item)->update)
- SP_CANVAS_ITEM_GET_CLASS (item)->update (item, child_affine, child_flags);
+ if (SP_CANVAS_ITEM_GET_CLASS (item)->update) {
+ SP_CANVAS_ITEM_GET_CLASS (item)->update(item, child_affine, child_flags);
+ }
}
GTK_OBJECT_UNSET_FLAGS (item, SP_CANVAS_ITEM_NEED_UPDATE);
@@ -302,11 +557,11 @@ sp_canvas_item_invoke_update (SPCanvasItem *item, Geom::Affine const &affine, un
* system. This routine applies the inverse of the item's transform,
* maintaining the affine invariant.
*/
-static double
-sp_canvas_item_invoke_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item)
+static double sp_canvas_item_invoke_point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item)
{
- if (SP_CANVAS_ITEM_GET_CLASS (item)->point)
+ if (SP_CANVAS_ITEM_GET_CLASS(item)->point) {
return SP_CANVAS_ITEM_GET_CLASS (item)->point (item, p, actual_item);
+ }
return Geom::infinity();
}
@@ -318,8 +573,7 @@ sp_canvas_item_invoke_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **a
* @item: A canvas item.
* @affine: An affine transformation matrix.
*/
-void
-sp_canvas_item_affine_absolute (SPCanvasItem *item, Geom::Affine const &affine)
+void sp_canvas_item_affine_absolute(SPCanvasItem *item, Geom::Affine const &affine)
{
item->xform = affine;
@@ -328,28 +582,27 @@ sp_canvas_item_affine_absolute (SPCanvasItem *item, Geom::Affine const &affine)
if (item->parent != NULL) {
sp_canvas_item_request_update (item->parent);
} else {
- sp_canvas_request_update (item->canvas);
+ SPCanvasImpl::requestCanvasUpdate(item->canvas);
}
}
item->canvas->need_repick = TRUE;
}
-/**
- * Convenience function to reorder items in a group's child list.
- *
- * This puts the specified link after the "before" link.
- */
-static void
-put_item_after (GList *link, GList *before)
+namespace {
+
+void put_item_after(GList *link, GList *before)
{
- if (link == before)
+ if (link == before) {
return;
+ }
SPCanvasGroup *parent = SP_CANVAS_GROUP (SP_CANVAS_ITEM (link->data)->parent);
if (before == NULL) {
- if (link == parent->items) return;
+ if (link == parent->items) {
+ return;
+ }
link->prev->next = link->next;
@@ -364,15 +617,17 @@ put_item_after (GList *link, GList *before)
link->next->prev = link;
parent->items = link;
} else {
- if ((link == parent->last) && (before == parent->last->prev))
+ if ((link == parent->last) && (before == parent->last->prev)) {
return;
+ }
- if (link->next)
+ if (link->next) {
link->next->prev = link->prev;
+ }
- if (link->prev)
+ if (link->prev) {
link->prev->next = link->next;
- else {
+ } else {
parent->items = link->next;
parent->items->prev = NULL;
}
@@ -382,32 +637,34 @@ put_item_after (GList *link, GList *before)
link->prev->next = link;
- if (link->next)
+ if (link->next) {
link->next->prev = link;
- else
+ } else {
parent->last = link;
+ }
}
}
+} // namespace
/**
* Raises the item in its parent's stack by the specified number of positions.
*
- * \param item A canvas item.
- * \param positions Number of steps to raise the item.
+ * @param item A canvas item.
+ * @param positions Number of steps to raise the item.
*
* If the number of positions is greater than the distance to the top of the
* stack, then the item is put at the top.
*/
-void
-sp_canvas_item_raise (SPCanvasItem *item, int positions)
+void sp_canvas_item_raise(SPCanvasItem *item, int positions)
{
g_return_if_fail (item != NULL);
g_return_if_fail (SP_IS_CANVAS_ITEM (item));
g_return_if_fail (positions >= 0);
- if (!item->parent || positions == 0)
+ if (!item->parent || positions == 0) {
return;
+ }
SPCanvasGroup *parent = SP_CANVAS_GROUP (item->parent);
GList *link = g_list_find (parent->items, item);
@@ -417,8 +674,9 @@ sp_canvas_item_raise (SPCanvasItem *item, int positions)
for (before = link; positions && before; positions--)
before = before->next;
- if (!before)
+ if (!before) {
before = parent->last;
+ }
put_item_after (link, before);
@@ -430,32 +688,34 @@ sp_canvas_item_raise (SPCanvasItem *item, int positions)
/**
* Lowers the item in its parent's stack by the specified number of positions.
*
- * \param item A canvas item.
- * \param positions Number of steps to lower the item.
+ * @param item A canvas item.
+ * @param positions Number of steps to lower the item.
*
* If the number of positions is greater than the distance to the bottom of the
* stack, then the item is put at the bottom.
- **/
-void
-sp_canvas_item_lower (SPCanvasItem *item, int positions)
+ */
+void sp_canvas_item_lower(SPCanvasItem *item, int positions)
{
g_return_if_fail (item != NULL);
g_return_if_fail (SP_IS_CANVAS_ITEM (item));
g_return_if_fail (positions >= 1);
- if (!item->parent || positions == 0)
+ if (!item->parent || positions == 0) {
return;
+ }
SPCanvasGroup *parent = SP_CANVAS_GROUP (item->parent);
GList *link = g_list_find (parent->items, item);
g_assert (link != NULL);
GList *before;
- if (link->prev)
- for (before = link->prev; positions && before; positions--)
+ if (link->prev) {
+ for (before = link->prev; positions && before; positions--) {
before = before->prev;
- else
+ }
+ } else {
before = NULL;
+ }
put_item_after (link, before);
@@ -463,8 +723,7 @@ sp_canvas_item_lower (SPCanvasItem *item, int positions)
item->canvas->need_repick = TRUE;
}
-bool
-sp_canvas_item_is_visible (SPCanvasItem *item)
+bool sp_canvas_item_is_visible(SPCanvasItem *item)
{
return item->flags & SP_CANVAS_ITEM_VISIBLE;
}
@@ -473,14 +732,14 @@ sp_canvas_item_is_visible (SPCanvasItem *item)
/**
* Sets visible flag on item and requests a redraw.
*/
-void
-sp_canvas_item_show (SPCanvasItem *item)
+void sp_canvas_item_show(SPCanvasItem *item)
{
g_return_if_fail (item != NULL);
g_return_if_fail (SP_IS_CANVAS_ITEM (item));
- if (item->flags & SP_CANVAS_ITEM_VISIBLE)
+ if (item->flags & SP_CANVAS_ITEM_VISIBLE) {
return;
+ }
item->flags |= SP_CANVAS_ITEM_VISIBLE;
@@ -490,7 +749,7 @@ sp_canvas_item_show (SPCanvasItem *item)
int y1 = (int)(item->y2);
if (x0 !=0 || x1 !=0 || y0 !=0 || y1 !=0) {
- sp_canvas_request_redraw (item->canvas, (int)(item->x1), (int)(item->y1), (int)(item->x2 + 1), (int)(item->y2 + 1));
+ item->canvas->requestRedraw((int)(item->x1), (int)(item->y1), (int)(item->x2 + 1), (int)(item->y2 + 1));
item->canvas->need_repick = TRUE;
}
}
@@ -498,14 +757,14 @@ sp_canvas_item_show (SPCanvasItem *item)
/**
* Clears visible flag on item and requests a redraw.
*/
-void
-sp_canvas_item_hide (SPCanvasItem *item)
+void sp_canvas_item_hide(SPCanvasItem *item)
{
g_return_if_fail (item != NULL);
g_return_if_fail (SP_IS_CANVAS_ITEM (item));
- if (!(item->flags & SP_CANVAS_ITEM_VISIBLE))
+ if (!(item->flags & SP_CANVAS_ITEM_VISIBLE)) {
return;
+ }
item->flags &= ~SP_CANVAS_ITEM_VISIBLE;
@@ -515,7 +774,7 @@ sp_canvas_item_hide (SPCanvasItem *item)
int y1 = (int)(item->y2);
if (x0 !=0 || x1 !=0 || y0 !=0 || y1 !=0) {
- sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)(item->x2 + 1), (int)(item->y2 + 1));
+ item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)(item->x2 + 1), (int)(item->y2 + 1));
item->canvas->need_repick = TRUE;
}
}
@@ -525,15 +784,15 @@ sp_canvas_item_hide (SPCanvasItem *item)
*
* \pre !canvas->grabbed_item && item->flags & SP_CANVAS_ITEM_VISIBLE
*/
-int
-sp_canvas_item_grab (SPCanvasItem *item, guint event_mask, GdkCursor *cursor, guint32 etime)
+int sp_canvas_item_grab(SPCanvasItem *item, guint event_mask, GdkCursor *cursor, guint32 etime)
{
g_return_val_if_fail (item != NULL, -1);
g_return_val_if_fail (SP_IS_CANVAS_ITEM (item), -1);
g_return_val_if_fail (gtk_widget_get_mapped (GTK_WIDGET (item->canvas)), -1);
- if (item->canvas->grabbed_item)
+ if (item->canvas->grabbed_item) {
return -1;
+ }
// This test disallows grabbing events by an invisible item, which may be useful
// sometimes. An example is the hidden control point used for the selector component,
@@ -547,16 +806,16 @@ sp_canvas_item_grab (SPCanvasItem *item, guint event_mask, GdkCursor *cursor, gu
event_mask &= ~GDK_POINTER_MOTION_HINT_MASK;
}
- /* fixme: Top hack (Lauris) */
- /* fixme: If we add key masks to event mask, Gdk will abort (Lauris) */
- /* fixme: But Canvas actualle does get key events, so all we need is routing these here */
- gdk_pointer_grab (SP_CANVAS_WINDOW (item->canvas), FALSE,
+ // fixme: Top hack (Lauris)
+ // fixme: If we add key masks to event mask, Gdk will abort (Lauris)
+ // fixme: But Canvas actualle does get key events, so all we need is routing these here
+ gdk_pointer_grab( getWindow(item->canvas), FALSE,
(GdkEventMask)(event_mask & (~(GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK))),
NULL, cursor, etime);
item->canvas->grabbed_item = item;
item->canvas->grabbed_event_mask = event_mask;
- item->canvas->current_item = item; /* So that events go to the grabbed item */
+ item->canvas->current_item = item; // So that events go to the grabbed item
return 0;
}
@@ -565,17 +824,17 @@ sp_canvas_item_grab (SPCanvasItem *item, guint event_mask, GdkCursor *cursor, gu
* Ungrabs the item, which must have been grabbed in the canvas, and ungrabs the
* mouse.
*
- * \param item A canvas item that holds a grab.
- * \param etime The timestamp for ungrabbing the mouse.
+ * @param item A canvas item that holds a grab.
+ * @param etime The timestamp for ungrabbing the mouse.
*/
-void
-sp_canvas_item_ungrab (SPCanvasItem *item, guint32 etime)
+void sp_canvas_item_ungrab(SPCanvasItem *item, guint32 etime)
{
g_return_if_fail (item != NULL);
g_return_if_fail (SP_IS_CANVAS_ITEM (item));
- if (item->canvas->grabbed_item != item)
+ if (item->canvas->grabbed_item != item) {
return;
+ }
item->canvas->grabbed_item = NULL;
@@ -599,75 +858,41 @@ Geom::Affine sp_canvas_item_i2w_affine(SPCanvasItem const *item)
return affine;
}
-/**
- * Helper that returns true iff item is descendant of parent.
- */
-static bool is_descendant(SPCanvasItem const *item, SPCanvasItem const *parent)
+namespace {
+
+bool is_descendant(SPCanvasItem const *item, SPCanvasItem const *parent)
{
while (item) {
- if (item == parent)
+ if (item == parent) {
return true;
+ }
item = item->parent;
}
return false;
}
-/**
- * Focus canvas, and item under cursor if it is not already focussed.
- */
-void
-sp_canvas_item_grab_focus (SPCanvasItem *item)
-{
- g_return_if_fail (item != NULL);
- g_return_if_fail (SP_IS_CANVAS_ITEM (item));
- g_return_if_fail (gtk_widget_get_can_focus (GTK_WIDGET (item->canvas)));
-
- SPCanvasItem *focused_item = item->canvas->focused_item;
-
- if (focused_item) {
- GdkEvent ev;
- ev.focus_change.type = GDK_FOCUS_CHANGE;
- ev.focus_change.window = SP_CANVAS_WINDOW (item->canvas);
- ev.focus_change.send_event = FALSE;
- ev.focus_change.in = FALSE;
-
- emit_event (item->canvas, &ev);
- }
-
- item->canvas->focused_item = item;
- gtk_widget_grab_focus (GTK_WIDGET (item->canvas));
-
- if (focused_item) {
- GdkEvent ev;
- ev.focus_change.type = GDK_FOCUS_CHANGE;
- ev.focus_change.window = SP_CANVAS_WINDOW (item->canvas);
- ev.focus_change.send_event = FALSE;
- ev.focus_change.in = TRUE;
-
- emit_event (item->canvas, &ev);
- }
-}
+} // namespace
/**
* Requests that the canvas queue an update for the specified item.
*
* To be used only by item implementations.
*/
-void
-sp_canvas_item_request_update (SPCanvasItem *item)
+void sp_canvas_item_request_update(SPCanvasItem *item)
{
- if (item->flags & SP_CANVAS_ITEM_NEED_UPDATE)
+ if (item->flags & SP_CANVAS_ITEM_NEED_UPDATE) {
return;
+ }
item->flags |= SP_CANVAS_ITEM_NEED_UPDATE;
if (item->parent != NULL) {
- /* Recurse up the tree */
+ // Recurse up the tree
sp_canvas_item_request_update (item->parent);
} else {
- /* Have reached the top of the tree, make sure the update call gets scheduled. */
- sp_canvas_request_update (item->canvas);
+ // Have reached the top of the tree, make sure the update call gets scheduled.
+ SPCanvasImpl::requestCanvasUpdate(item->canvas);
}
}
@@ -679,23 +904,12 @@ gint sp_canvas_item_order (SPCanvasItem * item)
return g_list_index (SP_CANVAS_GROUP (item->parent)->items, item);
}
-/* SPCanvasGroup */
-
-static void sp_canvas_group_class_init (SPCanvasGroupClass *klass);
-static void sp_canvas_group_init (SPCanvasGroup *group);
-static void sp_canvas_group_destroy (GtkObject *object);
-
-static void sp_canvas_group_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags);
-static double sp_canvas_group_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item);
-static void sp_canvas_group_render (SPCanvasItem *item, SPCanvasBuf *buf);
-static void sp_canvas_group_viewbox_changed (SPCanvasItem *item, Geom::IntRect const &new_area);
-
-static SPCanvasItemClass *group_parent_class;
+// SPCanvasGroup
/**
* Registers SPCanvasGroup class with Gtk and returns its type number.
*/
-GType sp_canvas_group_get_type(void)
+GType SPCanvasGroup::getType(void)
{
static GType type = 0;
if (!type) {
@@ -703,78 +917,62 @@ GType sp_canvas_group_get_type(void)
sizeof(SPCanvasGroupClass),
0, // base_init
0, // base_finalize
- (GClassInitFunc)sp_canvas_group_class_init,
+ reinterpret_cast<GClassInitFunc>(SPCanvasGroup::classInit),
0, // class_finalize
0, // class_data
sizeof(SPCanvasGroup),
0, // n_preallocs
- (GInstanceInitFunc)sp_canvas_group_init,
+ reinterpret_cast<GInstanceInitFunc>(SPCanvasGroup::init),
0 // value_table
};
- type = g_type_register_static(sp_canvas_item_get_type(), "SPCanvasGroup", &info, static_cast<GTypeFlags>(0));
+ type = g_type_register_static(SPCanvasItem::getType(), "SPCanvasGroup", &info, static_cast<GTypeFlags>(0));
}
return type;
}
-/**
- * Class initialization function for SPCanvasGroupClass
- */
-static void
-sp_canvas_group_class_init (SPCanvasGroupClass *klass)
+void SPCanvasGroup::classInit(SPCanvasGroupClass *klass)
{
- GtkObjectClass *object_class = (GtkObjectClass *) klass;
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass;
+ GtkObjectClass *object_class = reinterpret_cast<GtkObjectClass *>(klass);
+ SPCanvasItemClass *item_class = reinterpret_cast<SPCanvasItemClass *>(klass);
- group_parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass);
+ parentClass = reinterpret_cast<SPCanvasItemClass*>(g_type_class_peek_parent(klass));
- object_class->destroy = sp_canvas_group_destroy;
+ object_class->destroy = SPCanvasGroup::destroy;
- item_class->update = sp_canvas_group_update;
- item_class->render = sp_canvas_group_render;
- item_class->point = sp_canvas_group_point;
- item_class->viewbox_changed = sp_canvas_group_viewbox_changed;
+ item_class->update = SPCanvasGroup::update;
+ item_class->render = SPCanvasGroup::render;
+ item_class->point = SPCanvasGroup::point;
+ item_class->viewbox_changed = SPCanvasGroup::viewboxChanged;
}
-/**
- * Callback. Empty.
- */
-static void
-sp_canvas_group_init (SPCanvasGroup */*group*/)
+void SPCanvasGroup::init(SPCanvasGroup * /*group*/)
{
- /* Nothing here */
+ // Nothing here
}
-/**
- * Callback that destroys all items in group and calls group's virtual
- * destroy() function.
- */
-static void
-sp_canvas_group_destroy (GtkObject *object)
+void SPCanvasGroup::destroy(GtkObject *object)
{
- g_return_if_fail (object != NULL);
- g_return_if_fail (SP_IS_CANVAS_GROUP (object));
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(SP_IS_CANVAS_GROUP(object));
- SPCanvasGroup const *group = SP_CANVAS_GROUP (object);
+ SPCanvasGroup const *group = SP_CANVAS_GROUP(object);
GList *list = group->items;
while (list) {
- SPCanvasItem *child = (SPCanvasItem *)list->data;
+ SPCanvasItem *child = reinterpret_cast<SPCanvasItem *>(list->data);
list = list->next;
- gtk_object_destroy (GTK_OBJECT (child));
+ gtk_object_destroy(GTK_OBJECT(child));
}
- if (GTK_OBJECT_CLASS (group_parent_class)->destroy)
- (* GTK_OBJECT_CLASS (group_parent_class)->destroy) (object);
+ if (GTK_OBJECT_CLASS(parentClass)->destroy) {
+ (* GTK_OBJECT_CLASS(parentClass)->destroy)(object);
+ }
}
-/**
- * Update handler for canvas groups
- */
-static void
-sp_canvas_group_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags)
+void SPCanvasGroup::update(SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags)
{
- SPCanvasGroup const *group = SP_CANVAS_GROUP (item);
+ SPCanvasGroup const *group = SP_CANVAS_GROUP(item);
Geom::RectHull corners(Geom::Point(0, 0));
bool empty=true;
@@ -806,13 +1004,9 @@ sp_canvas_group_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned
}
}
-/**
- * Point handler for canvas groups.
- */
-static double
-sp_canvas_group_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item)
+double SPCanvasGroup::point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item)
{
- SPCanvasGroup const *group = SP_CANVAS_GROUP (item);
+ SPCanvasGroup const *group = SP_CANVAS_GROUP(item);
double const x = p[Geom::X];
double const y = p[Geom::Y];
int x1 = (int)(x - item->canvas->close_enough);
@@ -829,14 +1023,15 @@ sp_canvas_group_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_
SPCanvasItem *child = (SPCanvasItem *)list->data;
if ((child->x1 <= x2) && (child->y1 <= y2) && (child->x2 >= x1) && (child->y2 >= y1)) {
- SPCanvasItem *point_item = NULL; /* cater for incomplete item implementations */
+ SPCanvasItem *point_item = NULL; // cater for incomplete item implementations
int has_point;
if ((child->flags & SP_CANVAS_ITEM_VISIBLE) && SP_CANVAS_ITEM_GET_CLASS (child)->point) {
dist = sp_canvas_item_invoke_point (child, p, &point_item);
has_point = TRUE;
- } else
+ } else {
has_point = FALSE;
+ }
// This metric should be improved, because in case of (partly) overlapping items we will now
// always select the last one that has been added to the group. We could instead select the one
@@ -854,13 +1049,9 @@ sp_canvas_group_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_
return best;
}
-/**
- * Renders all visible canvas group items in buf rectangle.
- */
-static void
-sp_canvas_group_render (SPCanvasItem *item, SPCanvasBuf *buf)
+void SPCanvasGroup::render(SPCanvasItem *item, SPCanvasBuf *buf)
{
- SPCanvasGroup const *group = SP_CANVAS_GROUP (item);
+ SPCanvasGroup const *group = SP_CANVAS_GROUP(item);
for (GList *list = group->items; list; list = list->next) {
SPCanvasItem *child = (SPCanvasItem *)list->data;
@@ -869,110 +1060,73 @@ sp_canvas_group_render (SPCanvasItem *item, SPCanvasBuf *buf)
(child->y1 < buf->rect.bottom()) &&
(child->x2 > buf->rect.left()) &&
(child->y2 > buf->rect.top())) {
- if (SP_CANVAS_ITEM_GET_CLASS (child)->render)
- SP_CANVAS_ITEM_GET_CLASS (child)->render (child, buf);
+ if (SP_CANVAS_ITEM_GET_CLASS(child)->render) {
+ SP_CANVAS_ITEM_GET_CLASS(child)->render(child, buf);
+ }
}
}
}
}
-static void
-sp_canvas_group_viewbox_changed (SPCanvasItem *item, Geom::IntRect const &new_area)
+void SPCanvasGroup::viewboxChanged(SPCanvasItem *item, Geom::IntRect const &new_area)
{
- SPCanvasGroup *group = SP_CANVAS_GROUP (item);
+ SPCanvasGroup *group = SP_CANVAS_GROUP(item);
for (GList *list = group->items; list; list = list->next) {
SPCanvasItem *child = (SPCanvasItem *)list->data;
if (child->flags & SP_CANVAS_ITEM_VISIBLE) {
- if (SP_CANVAS_ITEM_GET_CLASS (child)->viewbox_changed)
- SP_CANVAS_ITEM_GET_CLASS (child)->viewbox_changed (child, new_area);
+ if (SP_CANVAS_ITEM_GET_CLASS(child)->viewbox_changed) {
+ SP_CANVAS_ITEM_GET_CLASS(child)->viewbox_changed(child, new_area);
+ }
}
}
}
-/**
- * Adds an item to a canvas group.
- */
-static void
-group_add (SPCanvasGroup *group, SPCanvasItem *item)
+void SPCanvasGroup::add(SPCanvasItem *item)
{
- gtk_object_ref (GTK_OBJECT (item));
- g_object_ref_sink (item);
+ gtk_object_ref( GTK_OBJECT(item) );
+ g_object_ref_sink(item);
- if (!group->items) {
- group->items = g_list_append (group->items, item);
- group->last = group->items;
+ if (!items) {
+ items = g_list_append(items, item);
+ last = items;
} else {
- group->last = g_list_append (group->last, item)->next;
+ last = g_list_append(last, item)->next;
}
- sp_canvas_item_request_update (item);
+ sp_canvas_item_request_update(item);
}
-/**
- * Removes an item from a canvas group
- */
-static void
-group_remove (SPCanvasGroup *group, SPCanvasItem *item)
+void SPCanvasGroup::remove(SPCanvasItem *item)
{
- g_return_if_fail (group != NULL);
- g_return_if_fail (SP_IS_CANVAS_GROUP (group));
- g_return_if_fail (item != NULL);
+ g_return_if_fail(item != NULL);
- for (GList *children = group->items; children; children = children->next) {
+ for (GList *children = items; children; children = children->next) {
if (children->data == item) {
- /* Unparent the child */
-
+ // Unparent the child
item->parent = NULL;
- gtk_object_unref (GTK_OBJECT (item));
+ gtk_object_unref(GTK_OBJECT(item));
- /* Remove it from the list */
-
- if (children == group->last) group->last = children->prev;
+ // Remove it from the list
+ if (children == last) {
+ last = children->prev;
+ }
- group->items = g_list_remove_link (group->items, children);
- g_list_free (children);
+ items = g_list_remove_link(items, children);
+ g_list_free(children);
break;
}
}
}
-/* SPCanvas */
-
-static void sp_canvas_class_init (SPCanvasClass *klass);
-static void sp_canvas_init (SPCanvas *canvas);
-static void sp_canvas_destroy (GtkObject *object);
-
-static void sp_canvas_realize (GtkWidget *widget);
-static void sp_canvas_unrealize (GtkWidget *widget);
-
-static void sp_canvas_size_request (GtkWidget *widget, GtkRequisition *req);
-static void sp_canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
-
-static gint sp_canvas_button (GtkWidget *widget, GdkEventButton *event);
-static gint sp_canvas_scroll (GtkWidget *widget, GdkEventScroll *event);
-static gint sp_canvas_motion (GtkWidget *widget, GdkEventMotion *event);
-static gint sp_canvas_expose (GtkWidget *widget, GdkEventExpose *event);
-static gint sp_canvas_key (GtkWidget *widget, GdkEventKey *event);
-static gint sp_canvas_crossing (GtkWidget *widget, GdkEventCrossing *event);
-static gint sp_canvas_focus_in (GtkWidget *widget, GdkEventFocus *event);
-static gint sp_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event);
-
-static GtkWidgetClass *canvas_parent_class;
-
-static void sp_canvas_resize_tiles(SPCanvas* canvas, int nl, int nt, int nr, int nb);
-static void sp_canvas_dirty_rect(SPCanvas* canvas, Geom::IntRect const &area);
-static void sp_canvas_mark_rect(SPCanvas* canvas, Geom::IntRect const &area, uint8_t val);
-static int do_update (SPCanvas *canvas);
-
/**
* Registers the SPCanvas class if necessary, and returns the type ID
* associated to it.
*
- * \return The type ID of the SPCanvas class.
- **/
-GType sp_canvas_get_type(void)
+ * @return The type ID of the SPCanvas class.
+ */
+GType SPCanvas::getType(void)
{
static GType type = 0;
if (!type) {
@@ -980,12 +1134,12 @@ GType sp_canvas_get_type(void)
sizeof(SPCanvasClass),
0, // base_init
0, // base_finalize
- (GClassInitFunc)sp_canvas_class_init,
+ (GClassInitFunc)SPCanvasImpl::classInit,
0, // class_finalize
0, // class_data
sizeof(SPCanvas),
0, // n_preallocs
- (GInstanceInitFunc)sp_canvas_init,
+ (GInstanceInitFunc)SPCanvasImpl::init,
0 // value_table
};
type = g_type_register_static(GTK_TYPE_WIDGET, "SPCanvas", &info, static_cast<GTypeFlags>(0));
@@ -993,41 +1147,33 @@ GType sp_canvas_get_type(void)
return type;
}
-/**
- * Class initialization function for SPCanvasClass.
- */
-static void
-sp_canvas_class_init (SPCanvasClass *klass)
+void SPCanvasImpl::classInit(SPCanvasClass *klass)
{
GtkObjectClass *object_class = (GtkObjectClass *) klass;
GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
- canvas_parent_class = (GtkWidgetClass *)g_type_class_peek_parent (klass);
+ parentClass = reinterpret_cast<GtkWidgetClass *>(g_type_class_peek_parent(klass));
- object_class->destroy = sp_canvas_destroy;
+ object_class->destroy = SPCanvasImpl::destroy;
- widget_class->realize = sp_canvas_realize;
- widget_class->unrealize = sp_canvas_unrealize;
- widget_class->size_request = sp_canvas_size_request;
- widget_class->size_allocate = sp_canvas_size_allocate;
- widget_class->button_press_event = sp_canvas_button;
- widget_class->button_release_event = sp_canvas_button;
- widget_class->motion_notify_event = sp_canvas_motion;
- widget_class->scroll_event = sp_canvas_scroll;
- widget_class->expose_event = sp_canvas_expose;
- widget_class->key_press_event = sp_canvas_key;
- widget_class->key_release_event = sp_canvas_key;
- widget_class->enter_notify_event = sp_canvas_crossing;
- widget_class->leave_notify_event = sp_canvas_crossing;
- widget_class->focus_in_event = sp_canvas_focus_in;
- widget_class->focus_out_event = sp_canvas_focus_out;
+ widget_class->realize = SPCanvasImpl::realize;
+ widget_class->unrealize = SPCanvasImpl::unrealize;
+ widget_class->size_request = SPCanvasImpl::sizeRequest;
+ widget_class->size_allocate = SPCanvasImpl::sizeAllocate;
+ widget_class->button_press_event = SPCanvasImpl::button;
+ widget_class->button_release_event = SPCanvasImpl::button;
+ widget_class->motion_notify_event = SPCanvasImpl::handleMotion;
+ widget_class->scroll_event = SPCanvasImpl::handleScroll;
+ widget_class->expose_event = SPCanvasImpl::handleExpose;
+ widget_class->key_press_event = SPCanvasImpl::handleKeyEvent;
+ widget_class->key_release_event = SPCanvasImpl::handleKeyEvent;
+ widget_class->enter_notify_event = SPCanvasImpl::handleCrossing;
+ widget_class->leave_notify_event = SPCanvasImpl::handleCrossing;
+ widget_class->focus_in_event = SPCanvasImpl::handleFocusIn;
+ widget_class->focus_out_event = SPCanvasImpl::handleFocusOut;
}
-/**
- * Callback: object initialization for SPCanvas.
- */
-static void
-sp_canvas_init (SPCanvas *canvas)
+void SPCanvasImpl::init(SPCanvas *canvas)
{
gtk_widget_set_has_window (GTK_WIDGET (canvas), TRUE);
gtk_widget_set_double_buffered (GTK_WIDGET (canvas), FALSE);
@@ -1037,8 +1183,8 @@ sp_canvas_init (SPCanvas *canvas)
canvas->pick_event.crossing.x = 0;
canvas->pick_event.crossing.y = 0;
- /* Create the root item as a special case */
- canvas->root = SP_CANVAS_ITEM (g_object_new (sp_canvas_group_get_type (), NULL));
+ // Create the root item as a special case
+ canvas->root = SP_CANVAS_ITEM(g_object_new(SPCanvasGroup::getType(), NULL));
canvas->root->canvas = canvas;
gtk_object_ref (GTK_OBJECT (canvas->root));
@@ -1066,11 +1212,7 @@ sp_canvas_init (SPCanvas *canvas)
canvas->is_scrolling = false;
}
-/**
- * Convenience function to remove the idle handler of a canvas.
- */
-static void
-remove_idle (SPCanvas *canvas)
+void SPCanvasImpl::remove_idle(SPCanvas *canvas)
{
if (canvas->idle_id) {
g_source_remove (canvas->idle_id);
@@ -1078,17 +1220,13 @@ remove_idle (SPCanvas *canvas)
}
}
-/*
- * Removes the transient state of the canvas (idle handler, grabs).
- */
-static void
-shutdown_transients (SPCanvas *canvas)
+void SPCanvasImpl::shutdown_transients(SPCanvas *canvas)
{
- /* We turn off the need_redraw flag, since if the canvas is mapped again
- * it will request a redraw anyways. We do not turn off the need_update
- * flag, though, because updates are not queued when the canvas remaps
- * itself.
- */
+ // We turn off the need_redraw flag, since if the canvas is mapped again
+ // it will request a redraw anyways. We do not turn off the need_update
+ // flag, though, because updates are not queued when the canvas remaps
+ // itself.
+ //
if (canvas->need_redraw) {
canvas->need_redraw = FALSE;
}
@@ -1102,31 +1240,31 @@ shutdown_transients (SPCanvas *canvas)
gdk_pointer_ungrab (GDK_CURRENT_TIME);
}
- remove_idle (canvas);
+ remove_idle(canvas);
}
-/**
- * Destroy handler for SPCanvas.
- */
-static void
-sp_canvas_destroy (GtkObject *object)
+void SPCanvasImpl::destroy(GtkObject *object)
{
- SPCanvas *canvas = SP_CANVAS (object);
+ SPCanvas *canvas = SP_CANVAS(object);
if (canvas->root) {
gtk_object_unref (GTK_OBJECT (canvas->root));
canvas->root = NULL;
}
- shutdown_transients (canvas);
+ shutdown_transients(canvas);
#if ENABLE_LCMS
canvas->cms_key.~ustring();
#endif
- if (GTK_OBJECT_CLASS (canvas_parent_class)->destroy)
- (* GTK_OBJECT_CLASS (canvas_parent_class)->destroy) (object);
+ if (GTK_OBJECT_CLASS(parentClass)->destroy) {
+ (* GTK_OBJECT_CLASS(parentClass)->destroy)(object);
+ }
}
-static void track_latency(GdkEvent const *event) {
+namespace {
+
+void trackLatency(GdkEvent const *event)
+{
GdkEventLatencyTracker &tracker = GdkEventLatencyTracker::default_tracker();
boost::optional<double> latency = tracker.process(event);
if (latency && *latency > 2.0) {
@@ -1134,22 +1272,15 @@ static void track_latency(GdkEvent const *event) {
}
}
-/**
- * Returns new canvas as widget.
- */
-GtkWidget *
-sp_canvas_new_aa (void)
-{
- SPCanvas *canvas = (SPCanvas *)g_object_new (sp_canvas_get_type (), NULL);
+} // namespace
- return (GtkWidget *) canvas;
+GtkWidget *SPCanvas::createAA()
+{
+ SPCanvas *canvas = reinterpret_cast<SPCanvas *>(g_object_new(SPCanvas::getType(), NULL));
+ return GTK_WIDGET(canvas);
}
-/**
- * The canvas widget's realize callback.
- */
-static void
-sp_canvas_realize (GtkWidget *widget)
+void SPCanvasImpl::realize(GtkWidget *widget)
{
GdkWindowAttr attributes;
GtkAllocation allocation;
@@ -1193,11 +1324,7 @@ sp_canvas_realize (GtkWidget *widget)
gtk_widget_set_realized (widget, TRUE);
}
-/**
- * The canvas widget's unrealize callback.
- */
-static void
-sp_canvas_unrealize (GtkWidget *widget)
+void SPCanvasImpl::unrealize(GtkWidget *widget)
{
SPCanvas *canvas = SP_CANVAS (widget);
@@ -1205,17 +1332,13 @@ sp_canvas_unrealize (GtkWidget *widget)
canvas->grabbed_item = NULL;
canvas->focused_item = NULL;
- shutdown_transients (canvas);
+ shutdown_transients(canvas);
- if (GTK_WIDGET_CLASS (canvas_parent_class)->unrealize)
- (* GTK_WIDGET_CLASS (canvas_parent_class)->unrealize) (widget);
+ if (GTK_WIDGET_CLASS(parentClass)->unrealize)
+ (* GTK_WIDGET_CLASS(parentClass)->unrealize)(widget);
}
-/**
- * The canvas widget's size_request callback.
- */
-static void
-sp_canvas_size_request (GtkWidget *widget, GtkRequisition *req)
+void SPCanvasImpl::sizeRequest(GtkWidget *widget, GtkRequisition *req)
{
static_cast<void>(SP_CANVAS (widget));
@@ -1223,11 +1346,7 @@ sp_canvas_size_request (GtkWidget *widget, GtkRequisition *req)
req->height = 256;
}
-/**
- * The canvas widget's size_allocate callback.
- */
-static void
-sp_canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
+void SPCanvasImpl::sizeAllocate(GtkWidget *widget, GtkAllocation *allocation)
{
SPCanvas *canvas = SP_CANVAS (widget);
GtkAllocation widg_allocation;
@@ -1239,24 +1358,22 @@ sp_canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
Geom::IntRect new_area = Geom::IntRect::from_xywh(canvas->x0, canvas->y0,
allocation->width, allocation->height);
- /* Schedule redraw of new region */
+ // Schedule redraw of new region
sp_canvas_resize_tiles(canvas,canvas->x0,canvas->y0,canvas->x0+allocation->width,canvas->y0+allocation->height);
if (SP_CANVAS_ITEM_GET_CLASS (canvas->root)->viewbox_changed)
SP_CANVAS_ITEM_GET_CLASS (canvas->root)->viewbox_changed (canvas->root, new_area);
if (allocation->width > widg_allocation.width) {
- sp_canvas_request_redraw (canvas,
- canvas->x0 + widg_allocation.width,
- 0,
- canvas->x0 + allocation->width,
- canvas->y0 + allocation->height);
+ canvas->requestRedraw(canvas->x0 + widg_allocation.width,
+ 0,
+ canvas->x0 + allocation->width,
+ canvas->y0 + allocation->height);
}
if (allocation->height > widg_allocation.height) {
- sp_canvas_request_redraw (canvas,
- 0,
- canvas->y0 + widg_allocation.height,
- canvas->x0 + allocation->width,
- canvas->y0 + allocation->height);
+ canvas->requestRedraw(0,
+ canvas->y0 + widg_allocation.height,
+ canvas->x0 + allocation->width,
+ canvas->y0 + allocation->height);
}
gtk_widget_set_allocation (widget, allocation);
@@ -1268,12 +1385,7 @@ sp_canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
}
}
-/**
- * Helper that emits an event for an item in the canvas, be it the current
- * item, grabbed item, or focused item, as appropriate.
- */
-static int
-emit_event (SPCanvas *canvas, GdkEvent *event)
+int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event)
{
guint mask;
@@ -1313,9 +1425,9 @@ emit_event (SPCanvas *canvas, GdkEvent *event)
if (!(mask & canvas->grabbed_event_mask)) return FALSE;
}
- /* Convert to world coordinates -- we have two cases because of different
- * offsets of the fields in the event structures.
- */
+ // Convert to world coordinates -- we have two cases because of different
+ // offsets of the fields in the event structures.
+ //
GdkEvent ev = *event;
@@ -1337,12 +1449,12 @@ emit_event (SPCanvas *canvas, GdkEvent *event)
break;
}
- /* Choose where we send the event */
+ // Choose where we send the event
- /* canvas->current_item becomes NULL in some cases under Win32
- ** (e.g. if the pointer leaves the window). So this is a hack that
- ** Lauris applied to SP to get around the problem.
- */
+ // canvas->current_item becomes NULL in some cases under Win32
+ // (e.g. if the pointer leaves the window). So this is a hack that
+ // Lauris applied to SP to get around the problem.
+ //
SPCanvasItem* item = NULL;
if (canvas->grabbed_item && !is_descendant (canvas->current_item, canvas->grabbed_item)) {
item = canvas->grabbed_item;
@@ -1359,7 +1471,7 @@ emit_event (SPCanvas *canvas, GdkEvent *event)
// otherwise selection of nodes in the node editor by dragging a rectangle using a
// tablet will break
canvas->need_repick = FALSE;
- pick_current_item (canvas, (GdkEvent *) event);
+ pickCurrentItem(canvas, reinterpret_cast<GdkEvent *>(event));
}
item = canvas->current_item;
}
@@ -1371,10 +1483,9 @@ emit_event (SPCanvas *canvas, GdkEvent *event)
item = canvas->focused_item;
}
- /* The event is propagated up the hierarchy (for if someone connected to
- * a group instead of a leaf event), and emission is stopped if a
- * handler returns TRUE, just like for GtkWidget events.
- */
+ // The event is propagated up the hierarchy (for if someone connected to
+ // a group instead of a leaf event), and emission is stopped if a
+ // handler returns TRUE, just like for GtkWidget events.
gint finished = FALSE;
@@ -1389,12 +1500,7 @@ emit_event (SPCanvas *canvas, GdkEvent *event)
return finished;
}
-/**
- * Helper that re-picks the current item in the canvas, based on the event's
- * coordinates and emits enter/leave events for items as appropriate.
- */
-static int
-pick_current_item (SPCanvas *canvas, GdkEvent *event)
+int SPCanvasImpl::pickCurrentItem(SPCanvas *canvas, GdkEvent *event)
{
int button_down = 0;
double x, y;
@@ -1415,14 +1521,14 @@ pick_current_item (SPCanvas *canvas, GdkEvent *event)
if (!button_down) canvas->left_grabbed_item = FALSE;
}
- /* Save the event in the canvas. This is used to synthesize enter and
- * leave events in case the current item changes. It is also used to
- * re-pick the current item if the current one gets deleted. Also,
- * synthesize an enter event.
- */
+ // Save the event in the canvas. This is used to synthesize enter and
+ // leave events in case the current item changes. It is also used to
+ // re-pick the current item if the current one gets deleted. Also,
+ // synthesize an enter event.
+
if (event != &canvas->pick_event) {
if ((event->type == GDK_MOTION_NOTIFY) || (event->type == GDK_BUTTON_RELEASE)) {
- /* these fields have the same offsets in both types of events */
+ // these fields have the same offsets in both types of events
canvas->pick_event.crossing.type = GDK_ENTER_NOTIFY;
canvas->pick_event.crossing.window = event->motion.window;
@@ -1435,7 +1541,7 @@ pick_current_item (SPCanvas *canvas, GdkEvent *event)
canvas->pick_event.crossing.focus = FALSE;
canvas->pick_event.crossing.state = event->motion.state;
- /* these fields don't have the same offsets in both types of events */
+ // these fields don't have the same offsets in both types of events
if (event->type == GDK_MOTION_NOTIFY) {
canvas->pick_event.crossing.x_root = event->motion.x_root;
@@ -1449,12 +1555,14 @@ pick_current_item (SPCanvas *canvas, GdkEvent *event)
}
}
- /* Don't do anything else if this is a recursive call */
- if (canvas->in_repick) return retval;
+ // Don't do anything else if this is a recursive call
+ if (canvas->in_repick) {
+ return retval;
+ }
- /* LeaveNotify means that there is no current item, so we don't look for one */
+ // 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 */
+ // these fields don't have the same offsets in both types of events
if (canvas->pick_event.type == GDK_ENTER_NOTIFY) {
x = canvas->pick_event.crossing.x;
@@ -1464,11 +1572,11 @@ pick_current_item (SPCanvas *canvas, GdkEvent *event)
y = canvas->pick_event.motion.y;
}
- /* world coords */
+ // world coords
x += canvas->x0;
y += canvas->y0;
- /* find the closest item */
+ // find the closest item
if (canvas->root->flags & SP_CANVAS_ITEM_VISIBLE) {
sp_canvas_item_invoke_point (canvas->root, Geom::Point(x, y), &canvas->new_current_item);
} else {
@@ -1479,10 +1587,10 @@ pick_current_item (SPCanvas *canvas, GdkEvent *event)
}
if ((canvas->new_current_item == canvas->current_item) && !canvas->left_grabbed_item) {
- return retval; /* current item did not change */
+ return retval; // current item did not change
}
- /* Synthesize events for old and new current items */
+ // Synthesize events for old and new current items
if ((canvas->new_current_item != canvas->current_item)
&& (canvas->current_item != NULL)
@@ -1495,20 +1603,20 @@ pick_current_item (SPCanvas *canvas, GdkEvent *event)
new_event.crossing.detail = GDK_NOTIFY_ANCESTOR;
new_event.crossing.subwindow = NULL;
canvas->in_repick = TRUE;
- retval = emit_event (canvas, &new_event);
+ retval = emitEvent(canvas, &new_event);
canvas->in_repick = FALSE;
}
if (canvas->gen_all_enter_events == false) {
// new_current_item may have been set to NULL during the call to
- // emit_event() above
+ // emitEvent() above
if ((canvas->new_current_item != canvas->current_item) && button_down) {
canvas->left_grabbed_item = TRUE;
return retval;
}
}
- /* Handle the rest of cases */
+ // Handle the rest of cases
canvas->left_grabbed_item = FALSE;
canvas->current_item = canvas->new_current_item;
@@ -1520,28 +1628,22 @@ pick_current_item (SPCanvas *canvas, GdkEvent *event)
new_event.type = GDK_ENTER_NOTIFY;
new_event.crossing.detail = GDK_NOTIFY_ANCESTOR;
new_event.crossing.subwindow = NULL;
- retval = emit_event (canvas, &new_event);
+ retval = emitEvent(canvas, &new_event);
}
-
-
return retval;
}
-/**
- * Button event handler for the canvas.
- */
-static gint
-sp_canvas_button (GtkWidget *widget, GdkEventButton *event)
+gint SPCanvasImpl::button(GtkWidget *widget, GdkEventButton *event)
{
SPCanvas *canvas = SP_CANVAS (widget);
int retval = FALSE;
- /* dispatch normally regardless of the event's window if an item
- has a pointer grab in effect */
+ // dispatch normally regardless of the event's window if an item
+ // has a pointer grab in effect
if (!canvas->grabbed_item &&
- event->window != SP_CANVAS_WINDOW (canvas))
+ event->window != getWindow(canvas))
return retval;
int mask;
@@ -1569,24 +1671,24 @@ sp_canvas_button (GtkWidget *widget, GdkEventButton *event)
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
- /* Pick the current item as if the button were not pressed, and
- * then process the event.
- */
+ // Pick the current item as if the button were not pressed, and
+ // then process the event.
+ //
canvas->state = event->state;
- pick_current_item (canvas, (GdkEvent *) event);
+ pickCurrentItem(canvas, reinterpret_cast<GdkEvent *>(event));
canvas->state ^= mask;
- retval = emit_event (canvas, (GdkEvent *) event);
+ retval = emitEvent(canvas, (GdkEvent *) event);
break;
case GDK_BUTTON_RELEASE:
- /* Process the event as if the button were pressed, then repick
- * after the button has been released
- */
+ // Process the event as if the button were pressed, then repick
+ // after the button has been released
+ //
canvas->state = event->state;
- retval = emit_event (canvas, (GdkEvent *) event);
+ retval = emitEvent(canvas, (GdkEvent *) event);
event->state ^= mask;
canvas->state = event->state;
- pick_current_item (canvas, (GdkEvent *) event);
+ pickCurrentItem(canvas, reinterpret_cast<GdkEvent *>(event));
event->state ^= mask;
break;
@@ -1598,15 +1700,9 @@ sp_canvas_button (GtkWidget *widget, GdkEventButton *event)
return retval;
}
-/**
- * Scroll event handler for the canvas.
- *
- * \todo FIXME: generate motion events to re-select items.
- */
-static gint
-sp_canvas_scroll (GtkWidget *widget, GdkEventScroll *event)
+gint SPCanvasImpl::handleScroll(GtkWidget *widget, GdkEventScroll *event)
{
- return emit_event (SP_CANVAS (widget), (GdkEvent *) event);
+ return emitEvent(SP_CANVAS(widget), reinterpret_cast<GdkEvent *>(event));
}
static inline void request_motions(GdkWindow *w, GdkEventMotion *event) {
@@ -1614,26 +1710,23 @@ static inline void request_motions(GdkWindow *w, GdkEventMotion *event) {
gdk_event_request_motions(event);
}
-/**
- * Motion event handler for the canvas.
- */
-static int
-sp_canvas_motion (GtkWidget *widget, GdkEventMotion *event)
+int SPCanvasImpl::handleMotion(GtkWidget *widget, GdkEventMotion *event)
{
int status;
SPCanvas *canvas = SP_CANVAS (widget);
- track_latency((GdkEvent *)event);
+ trackLatency((GdkEvent *)event);
- if (event->window != SP_CANVAS_WINDOW (canvas))
+ if (event->window != getWindow(canvas)) {
return FALSE;
+ }
if (canvas->root == NULL) // canvas being deleted
return FALSE;
canvas->state = event->state;
- pick_current_item (canvas, (GdkEvent *) event);
- status = emit_event (canvas, (GdkEvent *) event);
+ pickCurrentItem(canvas, reinterpret_cast<GdkEvent *>(event));
+ status = emitEvent(canvas, reinterpret_cast<GdkEvent *>(event));
if (event->is_hint) {
request_motions(gtk_widget_get_window (widget), event);
}
@@ -1641,7 +1734,7 @@ sp_canvas_motion (GtkWidget *widget, GdkEventMotion *event)
return status;
}
-static void sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect const &paint_rect, Geom::IntRect const &canvas_rect, int /*sw*/)
+void SPCanvasImpl::sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect const &paint_rect, Geom::IntRect const &canvas_rect, int /*sw*/)
{
GtkWidget *widget = GTK_WIDGET (canvas);
GtkStyle *style;
@@ -1664,7 +1757,8 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect const
cairo_rectangle(xctt, 0, 0, paint_rect.width(), paint_rect.height());
cairo_fill(xctt);
cairo_destroy(xctt);
- //*/
+ //
+ */
// create temporary surface
cairo_surface_t *imgs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, paint_rect.width(), paint_rect.height());
@@ -1733,6 +1827,8 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect const
//cairo_surface_destroy (cst);
}
+namespace {
+
struct PaintRectSetup {
SPCanvas* canvas;
Geom::IntRect big_rect;
@@ -1741,14 +1837,9 @@ struct PaintRectSetup {
Geom::Point mouse_loc;
};
-/**
- * Paint the given rect, recursively subdividing the region until it is the size of a single
- * buffer.
- *
- * @return true if the drawing completes
- */
-static int
-sp_canvas_paint_rect_internal (PaintRectSetup const *setup, Geom::IntRect const &this_rect)
+}// namespace
+
+int SPCanvasImpl::sp_canvas_paint_rect_internal(PaintRectSetup const *setup, Geom::IntRect const &this_rect)
{
GTimeVal now;
g_get_current_time (&now);
@@ -1790,14 +1881,16 @@ sp_canvas_paint_rect_internal (PaintRectSetup const *setup, Geom::IntRect const
if (bw * bh < setup->max_pixels) {
// We are small enough
- /*GdkRectangle r;
+ /*
+ GdkRectangle r;
r.x = this_rect.x0 - setup->canvas->x0;
r.y = this_rect.y0 - setup->canvas->y0;
r.width = this_rect.x1 - this_rect.x0;
r.height = this_rect.y1 - this_rect.y0;
GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(setup->canvas));
- gdk_window_begin_paint_rect(window, &r);*/
+ gdk_window_begin_paint_rect(window, &r);
+ */
sp_canvas_paint_single_buffer (setup->canvas,
this_rect, setup->big_rect, bw);
@@ -1858,13 +1951,7 @@ The default for now is the strips mode.
}
-/**
- * Helper that draws a specific rectangular part of the canvas.
- *
- * @return true if the rectangle painting succeeds.
- */
-static bool
-sp_canvas_paint_rect (SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1)
+bool SPCanvasImpl::sp_canvas_paint_rect(SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1)
{
GtkAllocation allocation;
g_return_val_if_fail (!canvas->need_update, false);
@@ -1907,119 +1994,87 @@ sp_canvas_paint_rect (SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1)
return sp_canvas_paint_rect_internal(&setup, paint_rect);
}
-/**
- * Force a full redraw after a specified number of interrupted redraws
- */
-void
-sp_canvas_force_full_redraw_after_interruptions(SPCanvas *canvas, unsigned int count) {
- g_return_if_fail(canvas != NULL);
-
- canvas->forced_redraw_limit = count;
- canvas->forced_redraw_count = 0;
+void SPCanvas::forceFullRedrawAfterInterruptions(unsigned int count)
+{
+ forced_redraw_limit = count;
+ forced_redraw_count = 0;
}
-/**
- * End forced full redraw requests
- */
-void
-sp_canvas_end_forced_full_redraws(SPCanvas *canvas) {
- g_return_if_fail(canvas != NULL);
-
- canvas->forced_redraw_limit = -1;
+void SPCanvas::endForcedFullRedraws()
+{
+ forced_redraw_limit = -1;
}
-/**
- * The canvas widget's expose callback.
- */
-static gint
-sp_canvas_expose (GtkWidget *widget, GdkEventExpose *event)
+gint SPCanvasImpl::handleExpose(GtkWidget *widget, GdkEventExpose *event)
{
- SPCanvas *canvas = SP_CANVAS (widget);
+ SPCanvas *canvas = SP_CANVAS(widget);
if (!gtk_widget_is_drawable (widget) ||
- (event->window != SP_CANVAS_WINDOW (canvas)))
+ (event->window != getWindow(canvas))) {
return FALSE;
+ }
- int n_rects;
- GdkRectangle *rects;
- gdk_region_get_rectangles (event->region, &rects, &n_rects);
+ int n_rects = 0;
+ GdkRectangle *rects = 0;
+ gdk_region_get_rectangles(event->region, &rects, &n_rects);
for (int i = 0; i < n_rects; i++) {
Geom::IntRect r = Geom::IntRect::from_xywh(
rects[i].x + canvas->x0, rects[i].y + canvas->y0,
rects[i].width, rects[i].height);
- sp_canvas_request_redraw (canvas, r.left(), r.top(), r.right(), r.bottom());
+ canvas->requestRedraw(r.left(), r.top(), r.right(), r.bottom());
}
- if (n_rects > 0)
+ if (n_rects > 0) {
g_free (rects);
+ }
return FALSE;
}
-/**
- * The canvas widget's keypress callback.
- */
-static gint
-sp_canvas_key (GtkWidget *widget, GdkEventKey *event)
+gint SPCanvasImpl::handleKeyEvent(GtkWidget *widget, GdkEventKey *event)
{
- return emit_event (SP_CANVAS (widget), (GdkEvent *) event);
+ return emitEvent(SP_CANVAS(widget), reinterpret_cast<GdkEvent *>(event));
}
-/**
- * Crossing event handler for the canvas.
- */
-static gint
-sp_canvas_crossing (GtkWidget *widget, GdkEventCrossing *event)
+gint SPCanvasImpl::handleCrossing(GtkWidget *widget, GdkEventCrossing *event)
{
SPCanvas *canvas = SP_CANVAS (widget);
- if (event->window != SP_CANVAS_WINDOW (canvas))
+ if (event->window != getWindow(canvas)) {
return FALSE;
+ }
canvas->state = event->state;
- return pick_current_item (canvas, (GdkEvent *) event);
+ return pickCurrentItem(canvas, reinterpret_cast<GdkEvent *>(event));
}
-/**
- * Focus in handler for the canvas.
- */
-static gint
-sp_canvas_focus_in (GtkWidget *widget, GdkEventFocus *event)
+gint SPCanvasImpl::handleFocusIn(GtkWidget *widget, GdkEventFocus *event)
{
gtk_widget_grab_focus (widget);
SPCanvas *canvas = SP_CANVAS (widget);
if (canvas->focused_item) {
- return emit_event (canvas, (GdkEvent *) event);
+ return emitEvent(canvas, reinterpret_cast<GdkEvent *>(event));
} else {
return FALSE;
}
}
-/**
- * Focus out handler for the canvas.
- */
-static gint
-sp_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event)
+gint SPCanvasImpl::handleFocusOut(GtkWidget *widget, GdkEventFocus *event)
{
- SPCanvas *canvas = SP_CANVAS (widget);
+ SPCanvas *canvas = SP_CANVAS(widget);
- if (canvas->focused_item)
- return emit_event (canvas, (GdkEvent *) event);
- else
+ if (canvas->focused_item) {
+ return emitEvent(canvas, reinterpret_cast<GdkEvent *>(event));
+ } else {
return FALSE;
+ }
}
-/**
- * Helper that repaints the areas in the canvas that need it.
- *
- * @return true if all the dirty parts have been redrawn
- */
-static int
-paint (SPCanvas *canvas)
+int SPCanvasImpl::paint(SPCanvas *canvas)
{
if (canvas->need_update) {
sp_canvas_item_invoke_update (canvas->root, Geom::identity(), 0);
@@ -2068,11 +2123,7 @@ paint (SPCanvas *canvas)
return TRUE;
}
-/**
- * Helper that invokes update, paint, and repick on canvas.
- */
-static int
-do_update (SPCanvas *canvas)
+int SPCanvasImpl::do_update(SPCanvas *canvas)
{
if (!canvas->root) // canvas may have already be destroyed by closing desktop during interrupted display!
return TRUE;
@@ -2080,31 +2131,27 @@ do_update (SPCanvas *canvas)
if (canvas->drawing_disabled)
return TRUE;
- /* Cause the update if necessary */
+ // Cause the update if necessary
if (canvas->need_update) {
sp_canvas_item_invoke_update (canvas->root, Geom::identity(), 0);
canvas->need_update = FALSE;
}
- /* Paint if able to */
+ // Paint if able to
if (gtk_widget_is_drawable ( GTK_WIDGET (canvas))) {
return paint (canvas);
}
- /* Pick new current item */
+ // Pick new current item
while (canvas->need_repick) {
canvas->need_repick = FALSE;
- pick_current_item (canvas, &canvas->pick_event);
+ pickCurrentItem(canvas, &canvas->pick_event);
}
return TRUE;
}
-/**
- * Idle handler for the canvas that deals with pending updates and redraws.
- */
-static gint
-idle_handler (gpointer data)
+gint SPCanvasImpl::idle_handler(gpointer data)
{
GDK_THREADS_ENTER ();
@@ -2113,7 +2160,7 @@ idle_handler (gpointer data)
int const ret = do_update (canvas);
if (ret) {
- /* Reset idle id */
+ // Reset idle id
canvas->idle_id = 0;
}
@@ -2122,67 +2169,48 @@ idle_handler (gpointer data)
return !ret;
}
-/**
- * Convenience function to add an idle handler to a canvas.
- */
-static void
-add_idle (SPCanvas *canvas)
+void SPCanvasImpl::add_idle(SPCanvas *canvas)
{
- if (canvas->idle_id != 0)
- return;
-
- canvas->idle_id = g_idle_add_full (sp_canvas_update_priority, idle_handler,
- canvas, NULL);
+ if (canvas->idle_id == 0) {
+ canvas->idle_id = g_idle_add_full(UPDATE_PRIORITY, idle_handler, canvas, NULL);
+ }
}
-/**
- * Returns the root group of the specified canvas.
- */
-SPCanvasGroup *
-sp_canvas_root (SPCanvas *canvas)
+SPCanvasGroup *SPCanvas::getRoot()
{
- g_return_val_if_fail (canvas != NULL, NULL);
- g_return_val_if_fail (SP_IS_CANVAS (canvas), NULL);
-
- return SP_CANVAS_GROUP (canvas->root);
+ return SP_CANVAS_GROUP(root);
}
-/**
- * Scrolls canvas to specific position (cx and cy are measured in screen pixels)
- */
-void
-sp_canvas_scroll_to (SPCanvas *canvas, double cx, double cy, unsigned int clear, bool is_scrolling)
+void SPCanvas::scrollTo(double cx, double cy, unsigned int clear, bool is_scrolling)
{
GtkAllocation allocation;
- g_return_if_fail (canvas != NULL);
- g_return_if_fail (SP_IS_CANVAS (canvas));
-
int ix = (int) round(cx); // ix and iy are the new canvas coordinates (integer screen pixels)
int iy = (int) round(cy); // cx might be negative, so (int)(cx + 0.5) will not do!
- int dx = ix - canvas->x0; // dx and dy specify the displacement (scroll) of the
- int dy = iy - canvas->y0; // canvas w.r.t its previous position
+ int dx = ix - x0; // dx and dy specify the displacement (scroll) of the
+ int dy = iy - y0; // canvas w.r.t its previous position
- Geom::IntRect old_area = canvas->getViewboxIntegers();
+ Geom::IntRect old_area = getViewboxIntegers();
Geom::IntRect new_area = old_area + Geom::IntPoint(dx, dy);
- canvas->dx0 = cx; // here the 'd' stands for double, not delta!
- canvas->dy0 = cy;
- canvas->x0 = ix;
- canvas->y0 = iy;
+ dx0 = cx; // here the 'd' stands for double, not delta!
+ dy0 = cy;
+ x0 = ix;
+ y0 = iy;
- gtk_widget_get_allocation (&canvas->widget, &allocation);
+ gtk_widget_get_allocation(&widget, &allocation);
- sp_canvas_resize_tiles (canvas, canvas->x0, canvas->y0, canvas->x0+allocation.width, canvas->y0+allocation.height);
- if (SP_CANVAS_ITEM_GET_CLASS (canvas->root)->viewbox_changed)
- SP_CANVAS_ITEM_GET_CLASS (canvas->root)->viewbox_changed (canvas->root, new_area);
+ SPCanvasImpl::sp_canvas_resize_tiles(this, x0, y0, x0 + allocation.width, y0 + allocation.height);
+ if (SP_CANVAS_ITEM_GET_CLASS(root)->viewbox_changed) {
+ SP_CANVAS_ITEM_GET_CLASS(root)->viewbox_changed(root, new_area);
+ }
if (!clear) {
// scrolling without zoom; redraw only the newly exposed areas
if ((dx != 0) || (dy != 0)) {
- canvas->is_scrolling = is_scrolling;
- if (gtk_widget_get_realized (GTK_WIDGET (canvas))) {
- gdk_window_scroll (SP_CANVAS_WINDOW (canvas), -dx, -dy);
+ this->is_scrolling = is_scrolling;
+ if (gtk_widget_get_realized(GTK_WIDGET(this))) {
+ gdk_window_scroll(getWindow(this), -dx, -dy);
}
}
} else {
@@ -2190,56 +2218,40 @@ sp_canvas_scroll_to (SPCanvas *canvas, double cx, double cy, unsigned int clear,
}
}
-/**
- * Updates canvas if necessary.
- */
-void
-sp_canvas_update_now (SPCanvas *canvas)
+void SPCanvas::updateNow()
{
- g_return_if_fail (canvas != NULL);
- g_return_if_fail (SP_IS_CANVAS (canvas));
-
- if (!(canvas->need_update ||
- canvas->need_redraw))
- return;
-
- do_update (canvas);
+ if (need_update || need_redraw) {
+ SPCanvasImpl::do_update(this);
+ }
}
-/**
- * Update callback for canvas widget.
- */
-static void
-sp_canvas_request_update (SPCanvas *canvas)
+void SPCanvasImpl::requestCanvasUpdate(SPCanvas *canvas)
{
canvas->need_update = TRUE;
- add_idle (canvas);
+ add_idle(canvas);
}
-/**
- * Forces redraw of rectangular canvas area.
- */
-void
-sp_canvas_request_redraw (SPCanvas *canvas, int x0, int y0, int x1, int y1)
+void SPCanvas::requestRedraw(int x0, int y0, int x1, int y1)
{
GtkAllocation allocation;
- g_return_if_fail (canvas != NULL);
- g_return_if_fail (SP_IS_CANVAS (canvas));
-
- if (!gtk_widget_is_drawable ( GTK_WIDGET (canvas))) return;
- if ((x0 >= x1) || (y0 >= y1)) return;
+ if (!gtk_widget_is_drawable ( GTK_WIDGET(this) )) {
+ return;
+ }
+ if ((x0 >= x1) || (y0 >= y1)) {
+ return;
+ }
Geom::IntRect bbox(x0, y0, x1, y1);
- gtk_widget_get_allocation (GTK_WIDGET (canvas), &allocation);
+ gtk_widget_get_allocation(GTK_WIDGET(this), &allocation);
- Geom::IntRect canvas_rect = Geom::IntRect::from_xywh(canvas->x0, canvas->y0,
- allocation.width, allocation.height);
+ Geom::IntRect canvas_rect = Geom::IntRect::from_xywh(x0, y0,
+ allocation.width, allocation.height);
Geom::OptIntRect clip = bbox & canvas_rect;
if (clip) {
- sp_canvas_dirty_rect(canvas, *clip);
- add_idle (canvas);
+ SPCanvasImpl::sp_canvas_dirty_rect(this, *clip);
+ SPCanvasImpl::add_idle(this);
}
}
@@ -2344,10 +2356,7 @@ inline int sp_canvas_tile_ceil(int x)
return ((x + (TILE_SIZE - 1)) & (~(TILE_SIZE - 1))) / TILE_SIZE;
}
-/**
- * Helper that allocates a new tile array for the canvas, copying overlapping tiles from the old array
- */
-static void sp_canvas_resize_tiles(SPCanvas* canvas, int nl, int nt, int nr, int nb)
+void SPCanvasImpl::sp_canvas_resize_tiles(SPCanvas* canvas, int nl, int nt, int nr, int nb)
{
if ( nl >= nr || nt >= nb ) {
if ( canvas->tiles ) g_free(canvas->tiles);
@@ -2383,19 +2392,13 @@ static void sp_canvas_resize_tiles(SPCanvas* canvas, int nl, int nt, int nr, int
canvas->tileV=nv;
}
-/*
- * Helper that queues a canvas rectangle for redraw
- */
-static void sp_canvas_dirty_rect(SPCanvas* canvas, Geom::IntRect const &area) {
+void SPCanvasImpl::sp_canvas_dirty_rect(SPCanvas* canvas, Geom::IntRect const &area) {
canvas->need_redraw = TRUE;
sp_canvas_mark_rect(canvas, area, 1);
}
-/**
- * Helper that marks specific canvas rectangle as clean (val == 0) or dirty (otherwise)
- */
-void sp_canvas_mark_rect(SPCanvas* canvas, Geom::IntRect const &area, uint8_t val)
+void SPCanvasImpl::sp_canvas_mark_rect(SPCanvas* canvas, Geom::IntRect const &area, uint8_t val)
{
int tl=sp_canvas_tile_floor(area.left());
int tt=sp_canvas_tile_floor(area.top());
diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h
index 14cbab6c3..3bdd5c061 100644
--- a/src/display/sp-canvas.h
+++ b/src/display/sp-canvas.h
@@ -10,6 +10,7 @@
* Federico Mena <federico@nuclecu.unam.mx>
* Raph Levien <raph@gimp.org>
* Lauris Kaplinski <lauris@kaplinski.com>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 1998 The Free Software Foundation
* Copyright (C) 2002 Lauris Kaplinski
@@ -38,12 +39,10 @@
G_BEGIN_DECLS
-#define SP_TYPE_CANVAS sp_canvas_get_type()
+#define SP_TYPE_CANVAS (SPCanvas::getType())
#define SP_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_CANVAS, SPCanvas))
#define SP_IS_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_CANVAS))
-GType sp_canvas_get_type();
-
struct SPCanvas;
struct SPCanvasItem;
struct SPCanvasGroup;
@@ -69,43 +68,91 @@ struct SPCanvasBuf {
G_END_DECLS
// SPCanvas -------------------------------------------------
+
+class SPCanvasImpl;
+
/**
* Port of GnomeCanvas for inkscape needs.
*/
struct SPCanvas {
+ friend class SPCanvasImpl;
+
+ static GType getType();
+
+ /**
+ * Returns new canvas as widget.
+ */
+ static GtkWidget *createAA();
+
+ /**
+ * Returns the root group of the specified canvas.
+ */
+ SPCanvasGroup *getRoot();
+
+ /**
+ * Scrolls canvas to specific position (cx and cy are measured in screen pixels).
+ */
+ void scrollTo(double cx, double cy, unsigned int clear, bool is_scrolling = false);
+
+
+ /**
+ * Updates canvas if necessary.
+ */
+ void updateNow();
+
+ /**
+ * Forces redraw of rectangular canvas area.
+ */
+ void requestRedraw(int x1, int y1, int x2, int y2);
+
+ /**
+ * Force a full redraw after a specified number of interrupted redraws.
+ */
+ void forceFullRedrawAfterInterruptions(unsigned int count);
+
+ /**
+ * End forced full redraw requests.
+ */
+ void endForcedFullRedraws();
+
+
+ // Data members: ----------------------------------------------------------
+
GtkWidget widget;
guint idle_id;
SPCanvasItem *root;
- double dx0, dy0;
- int x0, y0;
+ double dx0;
+ double dy0;
+ int x0;
+ int y0;
/* Area that needs redrawing, stored as a microtile array */
- int tLeft,tTop,tRight,tBottom;
- int tileH,tileV;
+ int tLeft, tTop, tRight, tBottom;
+ int tileH, tileV;
uint8_t *tiles;
- /* Last known modifier state, for deferred repick when a button is down */
+ /** Last known modifier state, for deferred repick when a button is down. */
int state;
- /* The item containing the mouse pointer, or NULL if none */
+ /** The item containing the mouse pointer, or NULL if none. */
SPCanvasItem *current_item;
- /* Item that is about to become current (used to track deletions and such) */
+ /** Item that is about to become current (used to track deletions and such). */
SPCanvasItem *new_current_item;
- /* Item that holds a pointer grab, or NULL if none */
+ /** Item that holds a pointer grab, or NULL if none. */
SPCanvasItem *grabbed_item;
- /* Event mask specified when grabbing an item */
+ /** Event mask specified when grabbing an item. */
guint grabbed_event_mask;
- /* If non-NULL, the currently focused item */
+ /** If non-NULL, the currently focused item. */
SPCanvasItem *focused_item;
- /* Event on which selection of current item is based */
+ /** Event on which selection of current item is based. */
GdkEvent pick_event;
int close_enough;
@@ -117,9 +164,10 @@ struct SPCanvas {
int forced_redraw_count;
int forced_redraw_limit;
- /* For use by internal pick_current_item() function */
+ /** For use by internal pick_current_item() function. */
unsigned int left_grabbed_item : 1;
- /* For use by internal pick_current_item() function */
+
+ /** For use by internal pick_current_item() function. */
unsigned int in_repick : 1;
// In most tools Inkscape only generates enter and leave events
@@ -130,7 +178,7 @@ struct SPCanvas {
// 'true'.
bool gen_all_enter_events;
- /* For scripting, sometimes we want to delay drawing. */
+ /** For scripting, sometimes we want to delay drawing. */
bool drawing_disabled;
int rendermode;
@@ -147,17 +195,6 @@ struct SPCanvas {
Geom::IntRect getViewboxIntegers() const;
};
-GtkWidget *sp_canvas_new_aa();
-
-SPCanvasGroup *sp_canvas_root(SPCanvas *canvas);
-
-void sp_canvas_scroll_to(SPCanvas *canvas, double cx, double cy, unsigned int clear, bool is_scrolling = false);
-void sp_canvas_update_now(SPCanvas *canvas);
-
-void sp_canvas_request_redraw(SPCanvas *canvas, int x1, int y1, int x2, int y2);
-void sp_canvas_force_full_redraw_after_interruptions(SPCanvas *canvas, unsigned int count);
-void sp_canvas_end_forced_full_redraws(SPCanvas *canvas);
-
bool sp_canvas_world_pt_inside_window(SPCanvas const *canvas, Geom::Point const &world);
void sp_canvas_window_to_world(SPCanvas const *canvas, double winx, double winy, double *worldx, double *worldy);
diff --git a/src/display/sp-ctrlline.cpp b/src/display/sp-ctrlline.cpp
index 77f5c1d15..646dcd89e 100644
--- a/src/display/sp-ctrlline.cpp
+++ b/src/display/sp-ctrlline.cpp
@@ -1,11 +1,10 @@
-#define __INKSCAPE_CTRLLINE_C__
-
/*
* Simple straight line
*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2007 Johan Engelen
* Copyright (C) 1999-2002 Lauris Kaplinski
@@ -123,7 +122,7 @@ sp_ctrlline_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int
{
SPCtrlLine *cl = SP_CTRLLINE (item);
- sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
if (parent_class->update)
(* parent_class->update) (item, affine, flags);
@@ -144,8 +143,7 @@ sp_ctrlline_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int
item->x2 = round(MAX(s[Geom::X], e[Geom::X]) + 1);
item->y2 = round(MAX(s[Geom::Y], e[Geom::Y]) + 1);
- sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
-
+ item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
}
}
@@ -159,7 +157,7 @@ sp_ctrlline_set_rgba32 (SPCtrlLine *cl, guint32 rgba)
SPCanvasItem *item;
cl->rgba = rgba;
item = SP_CANVAS_ITEM (cl);
- sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
}
}
diff --git a/src/display/sp-ctrlpoint.cpp b/src/display/sp-ctrlpoint.cpp
index 3a29b9b7c..3d82f8b05 100644
--- a/src/display/sp-ctrlpoint.cpp
+++ b/src/display/sp-ctrlpoint.cpp
@@ -1,10 +1,9 @@
-#define __INKSCAPE_CTRLPOINT_C__
-
/*
* Simple point
*
* Author:
* Maximilian Albert <maximilian.albert@gmail.com>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2008 Maximilian Albert
*
@@ -109,15 +108,15 @@ sp_ctrlpoint_render (SPCanvasItem *item, SPCanvasBuf *buf)
cairo_stroke(buf->ct);
}
-static void
-sp_ctrlpoint_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags)
+static void sp_ctrlpoint_update(SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags)
{
- SPCtrlPoint *cp = SP_CTRLPOINT (item);
+ SPCtrlPoint *cp = SP_CTRLPOINT(item);
- sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
- if (parent_class->update)
+ if (parent_class->update) {
(* parent_class->update) (item, affine, flags);
+ }
sp_canvas_item_reset_bounds (item);
@@ -130,9 +129,8 @@ sp_ctrlpoint_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned in
item->x2 = pt[Geom::X] + cp->radius;
item->y2 = pt[Geom::Y] + cp->radius;
- sp_canvas_request_redraw (item->canvas,
- (int)item->x1 - 15, (int)item->y1 - 15,
- (int)item->x1 + 15, (int)item->y1 + 15);
+ item->canvas->requestRedraw((int)item->x1 - 15, (int)item->y1 - 15,
+ (int)item->x1 + 15, (int)item->y1 + 15);
}
void
@@ -145,7 +143,7 @@ sp_ctrlpoint_set_color (SPCtrlPoint *cp, guint32 rgba)
SPCanvasItem *item;
cp->rgba = rgba;
item = SP_CANVAS_ITEM (cp);
- sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
}
}
diff --git a/src/display/sp-ctrlquadr.cpp b/src/display/sp-ctrlquadr.cpp
index af761864c..723075f74 100644
--- a/src/display/sp-ctrlquadr.cpp
+++ b/src/display/sp-ctrlquadr.cpp
@@ -3,6 +3,7 @@
*
* Authors:
* bulia byak
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2005 authors
*
@@ -135,15 +136,15 @@ sp_ctrlquadr_render (SPCanvasItem *item, SPCanvasBuf *buf)
d )
-static void
-sp_ctrlquadr_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags)
+static void sp_ctrlquadr_update(SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags)
{
- SPCtrlQuadr *cq = SP_CTRLQUADR (item);
+ SPCtrlQuadr *cq = SP_CTRLQUADR(item);
- sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
- if (parent_class->update)
- (* parent_class->update) (item, affine, flags);
+ if (parent_class->update) {
+ (* parent_class->update)(item, affine, flags);
+ }
sp_canvas_item_reset_bounds (item);
@@ -159,7 +160,7 @@ sp_ctrlquadr_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned in
item->x2 = (int)(MAX4(p1[Geom::X], p2[Geom::X], p3[Geom::X], p4[Geom::X]));
item->y2 = (int)(MAX4(p1[Geom::Y], p2[Geom::Y], p3[Geom::Y], p4[Geom::Y]));
- sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
}
void
@@ -172,7 +173,7 @@ sp_ctrlquadr_set_rgba32 (SPCtrlQuadr *cl, guint32 rgba)
SPCanvasItem *item;
cl->rgba = rgba;
item = SP_CANVAS_ITEM (cl);
- sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
}
}
diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp
index 32da6de4e..5c70426d5 100644
--- a/src/dyna-draw-context.cpp
+++ b/src/dyna-draw-context.cpp
@@ -7,6 +7,7 @@
* bulia byak <buliabyak@users.sf.net>
* MenTaLguY <mental@rydia.net>
* Abhishek Sharma
+ * Jon A. Cruz <jon@joncruz.org>
*
* The original dynadraw code:
* Paul Haeberli <paul@sgi.com>
@@ -561,7 +562,7 @@ sp_dyna_draw_context_root_handler(SPEventContext *event_context,
ret = TRUE;
- sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 3);
+ desktop->canvas->forceFullRedrawAfterInterruptions(3);
dc->is_drawing = true;
dc->just_started_drawing = true;
}
@@ -819,7 +820,7 @@ sp_dyna_draw_context_root_handler(SPEventContext *event_context,
Geom::Point const motion_dt(desktop->w2d(motion_w));
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time);
- sp_canvas_end_forced_full_redraws(desktop->canvas);
+ desktop->canvas->endForcedFullRedraws();
dc->is_drawing = false;
if (dc->dragging && event->button.button == 1 && !event_context->space_panning) {
diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp
index 2352d909f..257a6c5ec 100644
--- a/src/eraser-context.cpp
+++ b/src/eraser-context.cpp
@@ -512,7 +512,7 @@ sp_eraser_context_root_handler(SPEventContext *event_context,
ret = TRUE;
- sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 3);
+ desktop->canvas->forceFullRedrawAfterInterruptions(3);
dc->is_drawing = true;
}
break;
@@ -553,7 +553,7 @@ sp_eraser_context_root_handler(SPEventContext *event_context,
Geom::Point const motion_dt(desktop->w2d(motion_w));
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time);
- sp_canvas_end_forced_full_redraws(desktop->canvas);
+ desktop->canvas->endForcedFullRedraws();
dc->is_drawing = false;
if (dc->dragging && event->button.button == 1 && !event_context->space_panning) {
diff --git a/src/flood-context.cpp b/src/flood-context.cpp
index 6d291a482..9c527613e 100644
--- a/src/flood-context.cpp
+++ b/src/flood-context.cpp
@@ -1259,7 +1259,7 @@ static void sp_flood_finish(SPFloodContext *rc)
SP_OBJECT(rc->item)->updateRepr();
- sp_canvas_end_forced_full_redraws(desktop->canvas);
+ desktop->canvas->endForcedFullRedraws();
sp_desktop_selection(desktop)->set(rc->item);
DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET,
diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp
index ad39382e5..d5f922ce5 100644
--- a/src/gradient-drag.cpp
+++ b/src/gradient-drag.cpp
@@ -891,7 +891,7 @@ static void gr_knot_grabbed_handler(SPKnot */*knot*/, unsigned int /*state*/, gp
{
GrDragger *dragger = (GrDragger *) data;
- sp_canvas_force_full_redraw_after_interruptions(dragger->parent->desktop->canvas, 5);
+ dragger->parent->desktop->canvas->forceFullRedrawAfterInterruptions(5);
}
/**
@@ -901,7 +901,7 @@ static void gr_knot_ungrabbed_handler(SPKnot *knot, unsigned int state, gpointer
{
GrDragger *dragger = (GrDragger *) data;
- sp_canvas_end_forced_full_redraws(dragger->parent->desktop->canvas);
+ dragger->parent->desktop->canvas->endForcedFullRedraws();
dragger->point_original = dragger->point = knot->pos;
diff --git a/src/pen-context.cpp b/src/pen-context.cpp
index 2be2fd87b..5e9f27fb9 100644
--- a/src/pen-context.cpp
+++ b/src/pen-context.cpp
@@ -6,6 +6,7 @@
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2000 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
@@ -252,7 +253,7 @@ pen_cancel (SPPenContext *const pc)
pc->_message_context->clear();
pc->_message_context->flash(Inkscape::NORMAL_MESSAGE, _("Drawing cancelled"));
- sp_canvas_end_forced_full_redraws(pc->desktop->canvas);
+ pc->desktop->canvas->endForcedFullRedraws();
}
/**
@@ -1221,7 +1222,7 @@ spdc_pen_set_initial_point(SPPenContext *const pc, Geom::Point const p)
pc->npoints = 2;
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), NULL);
- sp_canvas_force_full_redraw_after_interruptions(pc->desktop->canvas, 5);
+ pc->desktop->canvas->forceFullRedrawAfterInterruptions(5);
}
/**
@@ -1398,7 +1399,7 @@ spdc_pen_finish(SPPenContext *const pc, gboolean const closed)
}
- sp_canvas_end_forced_full_redraws(pc->desktop->canvas);
+ pc->desktop->canvas->endForcedFullRedraws();
pen_enable_events(pc);
}
diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp
index d67833a91..bdaae5d01 100644
--- a/src/pencil-context.cpp
+++ b/src/pencil-context.cpp
@@ -6,6 +6,7 @@
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2000 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
@@ -558,7 +559,7 @@ pencil_cancel (SPPencilContext *const pc)
pc->_message_context->clear();
pc->_message_context->flash(Inkscape::NORMAL_MESSAGE, _("Drawing cancelled"));
- sp_canvas_end_forced_full_redraws(pc->desktop->canvas);
+ pc->desktop->canvas->endForcedFullRedraws();
}
static gint
diff --git a/src/rect-context.cpp b/src/rect-context.cpp
index 8f0ec8763..e24e4fc20 100644
--- a/src/rect-context.cpp
+++ b/src/rect-context.cpp
@@ -480,7 +480,7 @@ static void sp_rect_drag(SPRectContext &rc, Geom::Point const pt, guint state)
rc.item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
rc.item->updateRepr();
- sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
+ desktop->canvas->forceFullRedrawAfterInterruptions(5);
}
Geom::Rect const r = Inkscape::snap_rectangular_box(desktop, rc.item, pt, rc.center, state);
@@ -548,7 +548,7 @@ static void sp_rect_finish(SPRectContext *rc)
SP_OBJECT(rc->item)->updateRepr();
- sp_canvas_end_forced_full_redraws(desktop->canvas);
+ desktop->canvas->endForcedFullRedraws();
sp_desktop_selection(desktop)->set(rc->item);
DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_RECT,
@@ -575,7 +575,7 @@ static void sp_rect_cancel(SPRectContext *rc)
rc->yp = 0;
rc->item_to_select = NULL;
- sp_canvas_end_forced_full_redraws(desktop->canvas);
+ desktop->canvas->endForcedFullRedraws();
DocumentUndo::cancel(sp_desktop_document(desktop));
}
diff --git a/src/rubberband.cpp b/src/rubberband.cpp
index cdf41d400..89ac04ee6 100644
--- a/src/rubberband.cpp
+++ b/src/rubberband.cpp
@@ -3,6 +3,7 @@
*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 1999-2002 Lauris Kaplinski
*
@@ -54,7 +55,7 @@ void Inkscape::Rubberband::start(SPDesktop *d, Geom::Point const &p)
_points.push_back(_desktop->d2w(p));
_touchpath_curve->moveto(p);
- sp_canvas_force_full_redraw_after_interruptions(_desktop->canvas, 5);
+ _desktop->canvas->forceFullRedrawAfterInterruptions(5);
}
void Inkscape::Rubberband::stop()
@@ -67,8 +68,9 @@ void Inkscape::Rubberband::stop()
delete_canvas_items();
- if (_desktop)
- sp_canvas_end_forced_full_redraws(_desktop->canvas);
+ if (_desktop) {
+ _desktop->canvas->endForcedFullRedraws();
+ }
}
void Inkscape::Rubberband::move(Geom::Point const &p)
diff --git a/src/select-context.cpp b/src/select-context.cpp
index 9ef3c7a6e..2dec3269b 100644
--- a/src/select-context.cpp
+++ b/src/select-context.cpp
@@ -346,7 +346,7 @@ sp_select_context_item_handler(SPEventContext *event_context, SPItem *item, GdkE
sc->moved = FALSE;
gdk_window_set_cursor(window, CursorSelectDragging);
- sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
+ desktop->canvas->forceFullRedrawAfterInterruptions(5);
// remember the clicked item in sc->item:
if (sc->item) {
@@ -369,7 +369,7 @@ sp_select_context_item_handler(SPEventContext *event_context, SPItem *item, GdkE
NULL, event->button.time);
sc->grabbed = SP_CANVAS_ITEM(desktop->drawing);
- sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
+ desktop->canvas->forceFullRedrawAfterInterruptions(5);
ret = TRUE;
}
@@ -495,7 +495,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
sc->dragging = false;
sp_event_context_discard_delayed_snap_event(event_context);
- sp_canvas_end_forced_full_redraws(desktop->canvas);
+ desktop->canvas->endForcedFullRedraws();
} else { // switch tool
Geom::Point const button_pt(event->button.x, event->button.y);
Geom::Point const p(desktop->w2d(button_pt));
@@ -569,7 +569,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (sp_desktop_canvas(desktop)));
gdk_window_set_cursor(window, CursorSelectDragging);
- sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
+ desktop->canvas->forceFullRedrawAfterInterruptions(5);
}
if (sc->dragging) {
@@ -619,7 +619,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
} else {
sc->dragging = FALSE;
sp_event_context_discard_delayed_snap_event(event_context);
- sp_canvas_end_forced_full_redraws(desktop->canvas);
+ desktop->canvas->endForcedFullRedraws();
}
} else {
if (Inkscape::Rubberband::get(desktop)->is_started()) {
@@ -675,7 +675,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
window = gtk_widget_get_window (GTK_WIDGET (sp_desktop_canvas(desktop)));
gdk_window_set_cursor(window, CursorSelectMouseover);
sp_event_context_discard_delayed_snap_event(event_context);
- sp_canvas_end_forced_full_redraws(desktop->canvas);
+ desktop->canvas->endForcedFullRedraws();
if (sc->item) {
sp_object_unref( sc->item, NULL);
diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp
index 64eedf3f9..b6d846f77 100644
--- a/src/spiral-context.cpp
+++ b/src/spiral-context.cpp
@@ -424,7 +424,7 @@ static void sp_spiral_drag(SPSpiralContext *sc, Geom::Point const &p, guint stat
sc->item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
sc->item->updateRepr();
- sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
+ desktop->canvas->forceFullRedrawAfterInterruptions(5);
}
SnapManager &m = desktop->namedview->snap_manager;
@@ -478,7 +478,7 @@ sp_spiral_finish(SPSpiralContext *sc)
SP_SHAPE(spiral)->setShape();
SP_OBJECT(spiral)->updateRepr(SP_OBJECT_WRITE_EXT);
- sp_canvas_end_forced_full_redraws(desktop->canvas);
+ desktop->canvas->endForcedFullRedraws();
sp_desktop_selection(desktop)->set(sc->item);
DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SPIRAL,
@@ -505,7 +505,7 @@ static void sp_spiral_cancel(SPSpiralContext *sc)
sc->yp = 0;
sc->item_to_select = NULL;
- sp_canvas_end_forced_full_redraws(desktop->canvas);
+ desktop->canvas->endForcedFullRedraws();
DocumentUndo::cancel(sp_desktop_document(desktop));
}
diff --git a/src/spray-context.cpp b/src/spray-context.cpp
index 87247f2a6..e865e4621 100644
--- a/src/spray-context.cpp
+++ b/src/spray-context.cpp
@@ -670,7 +670,7 @@ gint sp_spray_context_root_handler(SPEventContext *event_context, GdkEvent *even
sp_spray_extinput(tc, event);
- sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 3);
+ desktop->canvas->forceFullRedrawAfterInterruptions(3);
tc->is_drawing = true;
tc->is_dilating = true;
tc->has_dilated = false;
@@ -734,7 +734,7 @@ gint sp_spray_context_root_handler(SPEventContext *event_context, GdkEvent *even
}
tc->last_push = desktop->dt2doc(scroll_dt);
sp_spray_extinput(tc, event);
- sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 3);
+ desktop->canvas->forceFullRedrawAfterInterruptions(3);
tc->is_drawing = true;
tc->is_dilating = true;
tc->has_dilated = false;
@@ -762,7 +762,7 @@ gint sp_spray_context_root_handler(SPEventContext *event_context, GdkEvent *even
Geom::Point const motion_w(event->button.x, event->button.y);
Geom::Point const motion_dt(desktop->w2d(motion_w));
- sp_canvas_end_forced_full_redraws(desktop->canvas);
+ desktop->canvas->endForcedFullRedraws();
tc->is_drawing = false;
if (tc->is_dilating && event->button.button == 1 && !event_context->space_panning) {
diff --git a/src/star-context.cpp b/src/star-context.cpp
index 352bdfece..f1080afcb 100644
--- a/src/star-context.cpp
+++ b/src/star-context.cpp
@@ -439,7 +439,7 @@ static void sp_star_drag(SPStarContext *sc, Geom::Point p, guint state)
sc->item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
sc->item->updateRepr();
- sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
+ desktop->canvas->forceFullRedrawAfterInterruptions(5);
}
/* Snap corner point with no constraints */
@@ -500,7 +500,7 @@ sp_star_finish (SPStarContext * sc)
object->updateRepr(SP_OBJECT_WRITE_EXT);
- sp_canvas_end_forced_full_redraws(desktop->canvas);
+ desktop->canvas->endForcedFullRedraws();
sp_desktop_selection(desktop)->set(sc->item);
DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
@@ -527,7 +527,7 @@ static void sp_star_cancel(SPStarContext *sc)
sc->yp = 0;
sc->item_to_select = NULL;
- sp_canvas_end_forced_full_redraws(desktop->canvas);
+ desktop->canvas->endForcedFullRedraws();
DocumentUndo::cancel(sp_desktop_document(desktop));
}
diff --git a/src/svg-view-widget.cpp b/src/svg-view-widget.cpp
index 1cfb078d3..227778723 100644
--- a/src/svg-view-widget.cpp
+++ b/src/svg-view-widget.cpp
@@ -95,7 +95,7 @@ static void sp_svg_view_widget_init(SPSVGSPViewWidget *vw)
/* Canvas */
gtk_widget_push_colormap (gdk_rgb_get_cmap ());
- vw->canvas = sp_canvas_new_aa ();
+ vw->canvas = SPCanvas::createAA();
gtk_widget_pop_colormap ();
style = gtk_style_copy (gtk_widget_get_style (vw->canvas));
style->bg[GTK_STATE_NORMAL] = style->white;
@@ -104,7 +104,7 @@ static void sp_svg_view_widget_init(SPSVGSPViewWidget *vw)
gtk_widget_show (vw->canvas);
/* View */
- parent = sp_canvas_item_new (sp_canvas_root (SP_CANVAS (vw->canvas)), SP_TYPE_CANVAS_GROUP, NULL);
+ parent = sp_canvas_item_new(SP_CANVAS(vw->canvas)->getRoot(), SP_TYPE_CANVAS_GROUP, NULL);
Inkscape::UI::View::View *view = Inkscape::GC::release(new SPSVGView (SP_CANVAS_GROUP (parent)));
sp_view_widget_set_view (SP_VIEW_WIDGET (vw), view);
}
diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp
index bd106a1bf..c95657fcb 100644
--- a/src/tweak-context.cpp
+++ b/src/tweak-context.cpp
@@ -1202,7 +1202,7 @@ sp_tweak_context_root_handler(SPEventContext *event_context,
sp_tweak_extinput(tc, event);
- sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 3);
+ desktop->canvas->forceFullRedrawAfterInterruptions(3);
tc->is_drawing = true;
tc->is_dilating = true;
tc->has_dilated = false;
@@ -1249,7 +1249,7 @@ sp_tweak_context_root_handler(SPEventContext *event_context,
Geom::Point const motion_w(event->button.x, event->button.y);
Geom::Point const motion_dt(desktop->w2d(motion_w));
- sp_canvas_end_forced_full_redraws(desktop->canvas);
+ desktop->canvas->endForcedFullRedraws();
tc->is_drawing = false;
if (tc->is_dilating && event->button.button == 1 && !event_context->space_panning) {
diff --git a/src/ui/tool/control-point.cpp b/src/ui/tool/control-point.cpp
index 79d70d453..3c4ce25fe 100644
--- a/src/ui/tool/control-point.cpp
+++ b/src/ui/tool/control-point.cpp
@@ -4,6 +4,7 @@
*/
/* Authors:
* Krzysztof KosiƄski <tweenk.pl@gmail.com>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2009 Authors
* Released under GNU GPL, read the file 'COPYING' for more information
@@ -355,7 +356,7 @@ bool ControlPoint::_eventHandler(GdkEvent *event)
// _drag_initiated might change during the above virtual call
if (!_drag_initiated) {
// this guarantees smooth redraws while dragging
- sp_canvas_force_full_redraw_after_interruptions(_desktop->canvas, 5);
+ _desktop->canvas->forceFullRedrawAfterInterruptions(5);
_drag_initiated = true;
}
}
@@ -395,7 +396,7 @@ bool ControlPoint::_eventHandler(GdkEvent *event)
_event_grab = false;
if (_drag_initiated) {
- sp_canvas_end_forced_full_redraws(_desktop->canvas);
+ _desktop->canvas->endForcedFullRedraws();
}
if (_drag_initiated) {
@@ -426,7 +427,7 @@ bool ControlPoint::_eventHandler(GdkEvent *event)
{
ungrabbed(NULL);
if (_drag_initiated)
- sp_canvas_end_forced_full_redraws(_desktop->canvas);
+ _desktop->canvas->endForcedFullRedraws();
}
_setState(STATE_NORMAL);
_event_grab = false;
@@ -556,7 +557,7 @@ void ControlPoint::transferGrab(ControlPoint *prev_point, GdkEventMotion *event)
sp_canvas_item_grab(_canvas_item, _grab_event_mask, NULL, event->time);
if (!_drag_initiated) {
- sp_canvas_force_full_redraw_after_interruptions(_desktop->canvas, 5);
+ _desktop->canvas->forceFullRedrawAfterInterruptions(5);
_drag_initiated = true;
}
diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp
index afbb52e05..40dbbc962 100644
--- a/src/ui/widget/selected-style.cpp
+++ b/src/ui/widget/selected-style.cpp
@@ -2,6 +2,7 @@
* Author:
* buliabyak@gmail.com
* Abhishek Sharma
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2005 author
*
@@ -1150,13 +1151,13 @@ void SelectedStyle::on_opacity_changed () {
// me. As a result, scrolling the spinbutton once results in runaway change until it hits 1.0
// or 0.0. (And no, this is not a race with ::update, I checked that.)
// Sigh. So we disable interruptibility while we're setting the new value.
- sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(_desktop), 0);
+ sp_desktop_canvas(_desktop)->forceFullRedrawAfterInterruptions(0);
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
DocumentUndo::maybeDone(sp_desktop_document(_desktop), "fillstroke:opacity", SP_VERB_DIALOG_FILL_STROKE,
_("Change opacity"));
// resume interruptibility
- sp_canvas_end_forced_full_redraws(sp_desktop_canvas(_desktop));
+ sp_desktop_canvas(_desktop)->endForcedFullRedraws();
spinbutton_defocus(GTK_OBJECT(_opacity_sb.gobj()));
_opacity_blocked = false;
}
diff --git a/src/ui/widget/svg-canvas.cpp b/src/ui/widget/svg-canvas.cpp
index d3d9f70f2..a0d5e1215 100644
--- a/src/ui/widget/svg-canvas.cpp
+++ b/src/ui/widget/svg-canvas.cpp
@@ -1,6 +1,7 @@
/*
* Authors:
* Ralf Stephan <ralf@ark.in-berlin.de>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2005 The Authors
*
@@ -20,7 +21,7 @@ namespace Widget {
SVGCanvas::SVGCanvas()
{
- void *canvas = g_object_new (sp_canvas_get_type (), NULL);
+ void *canvas = g_object_new(SPCanvas::getType(), NULL);
_spcanvas = static_cast<SPCanvas*>(canvas);
_widget = Glib::wrap (static_cast<GtkWidget*> (canvas));
_dt = 0;
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index 4d76fbe1a..5b07cddf5 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -444,7 +444,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
}
/* Canvas */
- dtw->canvas = SP_CANVAS (sp_canvas_new_aa ());
+ dtw->canvas = SP_CANVAS(SPCanvas::createAA());
#if ENABLE_LCMS
dtw->canvas->enable_cms_display_adj = prefs->getBool("/options/displayprofile/enable");
#endif // ENABLE_LCMS
@@ -1617,8 +1617,8 @@ sp_desktop_widget_adjustment_value_changed (GtkAdjustment */*adj*/, SPDesktopWid
dtw->update = 1;
- sp_canvas_scroll_to (dtw->canvas, gtk_adjustment_get_value(dtw->hadj),
- gtk_adjustment_get_value(dtw->vadj), FALSE);
+ dtw->canvas->scrollTo(gtk_adjustment_get_value(dtw->hadj),
+ gtk_adjustment_get_value(dtw->vadj), FALSE);
sp_desktop_widget_update_rulers (dtw);
/* update perspective lines if we are in the 3D box tool (so that infinite ones are shown correctly) */
diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp
index 6f076b4c4..425ee1f5e 100644
--- a/src/widgets/fill-style.cpp
+++ b/src/widgets/fill-style.cpp
@@ -492,7 +492,7 @@ void FillNStroke::updateFromPaint()
{
if (kind == FILL) {
// FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed; here it results in losing release events
- sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
+ sp_desktop_canvas(desktop)->forceFullRedrawAfterInterruptions(0);
}
psel->setFlatColor( desktop,
@@ -503,7 +503,7 @@ void FillNStroke::updateFromPaint()
if (kind == FILL) {
// resume interruptibility
- sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
+ sp_desktop_canvas(desktop)->endForcedFullRedraws();
}
// on release, toggle undo_label so that the next drag will not be lumped with this one
diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp
index 83cbe98ff..7659b1688 100644
--- a/src/widgets/select-toolbar.cpp
+++ b/src/widgets/select-toolbar.cpp
@@ -241,7 +241,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
if (actionkey != NULL) {
// FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed
- sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
+ sp_desktop_canvas(desktop)->forceFullRedrawAfterInterruptions(0);
gdouble strokewidth = stroke_average_width (selection->itemList());
int transform_stroke = prefs->getBool("/options/transform/stroke", true) ? 1 : 0;
@@ -262,7 +262,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
_("Transform by toolbar"));
// resume interruptibility
- sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
+ sp_desktop_canvas(desktop)->endForcedFullRedraws();
}
g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));