summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2012-05-04 09:35:59 +0000
committerJon A. Cruz <jon@joncruz.org>2012-05-04 09:35:59 +0000
commit3b72e337ab1a812319a9557adcd8fc40c2f36bb7 (patch)
treea64394c27307b434b03a1d09701df516b7150e97 /src
parentSyntax of null pointer dereference checking (diff)
downloadinkscape-3b72e337ab1a812319a9557adcd8fc40c2f36bb7.tar.gz
inkscape-3b72e337ab1a812319a9557adcd8fc40c2f36bb7.zip
C++ification of SPCtrlLine in preparation of visibility improvements.
(bzr r11321)
Diffstat (limited to 'src')
-rw-r--r--src/display/sp-ctrlline.cpp125
-rw-r--r--src/display/sp-ctrlline.h25
-rw-r--r--src/gradient-drag.cpp26
-rw-r--r--src/line-geometry.cpp9
-rw-r--r--src/measure-context.cpp17
-rw-r--r--src/pen-context.cpp34
-rw-r--r--src/pen-context.h7
-rw-r--r--src/seltrans.cpp6
-rw-r--r--src/seltrans.h3
-rw-r--r--src/text-context.cpp16
-rw-r--r--src/text-context.h3
-rw-r--r--src/ui/tool/node.cpp14
-rw-r--r--src/ui/tool/node.h3
-rw-r--r--src/vanishing-point.cpp18
14 files changed, 156 insertions, 150 deletions
diff --git a/src/display/sp-ctrlline.cpp b/src/display/sp-ctrlline.cpp
index 3175baf96..11d0b34f8 100644
--- a/src/display/sp-ctrlline.cpp
+++ b/src/display/sp-ctrlline.cpp
@@ -28,82 +28,82 @@
#include "color.h"
#include "display/sp-canvas.h"
+namespace {
-static void sp_ctrlline_class_init (SPCtrlLineClass *klass);
-static void sp_ctrlline_init (SPCtrlLine *ctrlline);
-static void sp_ctrlline_destroy (GtkObject *object);
+void sp_ctrlline_class_init(SPCtrlLineClass *klass, gpointer data);
+void sp_ctrlline_init(SPCtrlLine *ctrlline, gpointer g_class);
+void sp_ctrlline_destroy(GtkObject *object);
-static void sp_ctrlline_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags);
-static void sp_ctrlline_render (SPCanvasItem *item, SPCanvasBuf *buf);
+void sp_ctrlline_update(SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags);
+void sp_ctrlline_render(SPCanvasItem *item, SPCanvasBuf *buf);
-static SPCanvasItemClass *parent_class;
+SPCanvasItemClass *parent_class = 0;
-GType
-sp_ctrlline_get_type (void)
+} // namespace
+
+GType SPCtrlLine::getType()
{
static GType type = 0;
if (!type) {
GTypeInfo info = {
sizeof(SPCtrlLineClass),
NULL, NULL,
- (GClassInitFunc) sp_ctrlline_class_init,
+ reinterpret_cast<GClassInitFunc>(sp_ctrlline_class_init),
NULL, NULL,
sizeof(SPCtrlLine),
0,
- (GInstanceInitFunc) sp_ctrlline_init,
+ reinterpret_cast<GInstanceInitFunc>(sp_ctrlline_init),
NULL
};
- type = g_type_register_static(SP_TYPE_CANVAS_ITEM, "SPCtrlLine", &info, (GTypeFlags)0);
+ type = g_type_register_static(SP_TYPE_CANVAS_ITEM, "SPCtrlLine", &info, static_cast<GTypeFlags>(0));
}
return type;
}
-static void
-sp_ctrlline_class_init (SPCtrlLineClass *klass)
-{
- GtkObjectClass *object_class = (GtkObjectClass *) klass;
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass;
+namespace {
- parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass);
+void sp_ctrlline_class_init(SPCtrlLineClass *klass, gpointer /*data*/)
+{
+ parent_class = reinterpret_cast<SPCanvasItemClass*>(g_type_class_peek_parent(klass));
- object_class->destroy = sp_ctrlline_destroy;
+ klass->destroy = sp_ctrlline_destroy;
- item_class->update = sp_ctrlline_update;
- item_class->render = sp_ctrlline_render;
+ klass->update = sp_ctrlline_update;
+ klass->render = sp_ctrlline_render;
}
-static void
-sp_ctrlline_init (SPCtrlLine *ctrlline)
+void sp_ctrlline_init(SPCtrlLine *ctrlline, gpointer /*g_class*/)
{
ctrlline->rgba = 0x0000ff7f;
ctrlline->s[Geom::X] = ctrlline->s[Geom::Y] = ctrlline->e[Geom::X] = ctrlline->e[Geom::Y] = 0.0;
ctrlline->item=NULL;
}
-static void
-sp_ctrlline_destroy (GtkObject *object)
+void sp_ctrlline_destroy(GtkObject *object)
{
- g_return_if_fail (object != NULL);
- g_return_if_fail (SP_IS_CTRLLINE (object));
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(SP_IS_CTRLLINE(object));
- SPCtrlLine *ctrlline = SP_CTRLLINE (object);
+ SPCtrlLine *ctrlline = SP_CTRLLINE(object);
- ctrlline->item=NULL;
+ ctrlline->item = NULL;
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+ if (GTK_OBJECT_CLASS (parent_class)->destroy) {
+ (* GTK_OBJECT_CLASS (parent_class)->destroy)(object);
+ }
}
-static void
-sp_ctrlline_render (SPCanvasItem *item, SPCanvasBuf *buf)
+void sp_ctrlline_render(SPCanvasItem *item, SPCanvasBuf *buf)
{
- SPCtrlLine *cl = SP_CTRLLINE (item);
+ SPCtrlLine *cl = SP_CTRLLINE(item);
- if (!buf->ct)
+ if (!buf->ct) {
return;
+ }
- if (cl->s == cl->e)
+ if (cl->s == cl->e) {
return;
+ }
ink_cairo_set_source_rgba32(buf->ct, cl->rgba);
cairo_set_line_width(buf->ct, 1);
@@ -118,17 +118,17 @@ sp_ctrlline_render (SPCanvasItem *item, SPCanvasBuf *buf)
cairo_stroke(buf->ct);
}
-static void
-sp_ctrlline_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags)
+void sp_ctrlline_update(SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags)
{
- SPCtrlLine *cl = SP_CTRLLINE (item);
+ SPCtrlLine *cl = SP_CTRLLINE(item);
- item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ item->canvas->requestRedraw(item->x1, item->y1, item->x2, 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);
+ sp_canvas_item_reset_bounds(item);
cl->affine = affine;
@@ -144,46 +144,37 @@ 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);
- item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ item->canvas->requestRedraw(item->x1, item->y1, item->x2, item->y2);
}
}
-void
-sp_ctrlline_set_rgba32 (SPCtrlLine *cl, guint32 rgba)
+} // namespace
+
+void SPCtrlLine::setRgba32(guint32 rgba)
{
- g_return_if_fail (cl != NULL);
- g_return_if_fail (SP_IS_CTRLLINE (cl));
-
- if (rgba != cl->rgba) {
- SPCanvasItem *item;
- cl->rgba = rgba;
- item = SP_CANVAS_ITEM (cl);
- item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
+ if (rgba != this->rgba) {
+ this->rgba = rgba;
+ canvas->requestRedraw(x1, y1, x2, y2);
}
}
#define EPSILON 1e-6
#define DIFFER(a,b) (fabs ((a) - (b)) > EPSILON)
-void
-sp_ctrlline_set_coords (SPCtrlLine *cl, gdouble x0, gdouble y0, gdouble x1, gdouble y1)
+void SPCtrlLine::setCoords(gdouble x0, gdouble y0, gdouble x1, gdouble y1)
{
- g_return_if_fail (cl != NULL);
- g_return_if_fail (SP_IS_CTRLLINE (cl));
-
- if (DIFFER (x0, cl->s[Geom::X]) || DIFFER (y0, cl->s[Geom::Y]) || DIFFER (x1, cl->e[Geom::X]) || DIFFER (y1, cl->e[Geom::Y])) {
- cl->s[Geom::X] = x0;
- cl->s[Geom::Y] = y0;
- cl->e[Geom::X] = x1;
- cl->e[Geom::Y] = y1;
- sp_canvas_item_request_update (SP_CANVAS_ITEM (cl));
+ if (DIFFER(x0, s[Geom::X]) || DIFFER(y0, s[Geom::Y]) || DIFFER(x1, e[Geom::X]) || DIFFER(y1, e[Geom::Y])) {
+ s[Geom::X] = x0;
+ s[Geom::Y] = y0;
+ e[Geom::X] = x1;
+ e[Geom::Y] = y1;
+ sp_canvas_item_request_update(this);
}
}
-void
-sp_ctrlline_set_coords (SPCtrlLine *cl, const Geom::Point start, const Geom::Point end)
+void SPCtrlLine::setCoords(Geom::Point const &start, Geom::Point const &end)
{
- sp_ctrlline_set_coords(cl, start[0], start[1], end[0], end[1]);
+ setCoords(start[0], start[1], end[0], end[1]);
}
/*
diff --git a/src/display/sp-ctrlline.h b/src/display/sp-ctrlline.h
index 4bfe50a77..12be03ca5 100644
--- a/src/display/sp-ctrlline.h
+++ b/src/display/sp-ctrlline.h
@@ -7,7 +7,9 @@
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
+ * Jon A. Cruz <jon@joncruz.org>
*
+ * Copyright (C) 2012 Authors
* Copyright (C) 2007 Johan Engelen
* Copyright (C) 1999-2002 Lauris Kaplinski
*
@@ -18,23 +20,28 @@
class SPItem;
-#define SP_TYPE_CTRLLINE (sp_ctrlline_get_type ())
+#define SP_TYPE_CTRLLINE (SPCtrlLine::getType())
#define SP_CTRLLINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CTRLLINE, SPCtrlLine))
#define SP_IS_CTRLLINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_CTRLLINE))
-struct SPCtrlLine : public SPCanvasItem{
+struct SPCtrlLine : public SPCanvasItem {
+ static GType getType();
+
+ void setRgba32(guint32 rgba);
+
+ void setCoords(gdouble x0, gdouble y0, gdouble x1, gdouble y1);
+
+ void setCoords(Geom::Point const &start, Geom::Point const &end);
+
+
SPItem *item; // the item to which this line belongs in some sense; may be NULL for some users
guint32 rgba;
- Geom::Point s, e;
+ Geom::Point s;
+ Geom::Point e;
Geom::Affine affine;
};
-struct SPCtrlLineClass : public SPCanvasItemClass{};
-GType sp_ctrlline_get_type (void);
-
-void sp_ctrlline_set_rgba32 (SPCtrlLine *cl, guint32 rgba);
-void sp_ctrlline_set_coords (SPCtrlLine *cl, gdouble x0, gdouble y0, gdouble x1, gdouble y1);
-void sp_ctrlline_set_coords (SPCtrlLine *cl, const Geom::Point start, const Geom::Point end);
+struct SPCtrlLineClass : public SPCanvasItemClass{};
diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp
index c1f9251df..629659208 100644
--- a/src/gradient-drag.cpp
+++ b/src/gradient-drag.cpp
@@ -453,17 +453,16 @@ bool GrDrag::dropColor(SPItem */*item*/, gchar const *c, Geom::Point p)
// now see if we're over line and create a new stop
bool over_line = false;
- SPCtrlLine *line = NULL;
if (lines) {
for (GSList *l = lines; (l != NULL) && (!over_line); l = l->next) {
- line = (SPCtrlLine*) l->data;
+ SPCtrlLine *line = (SPCtrlLine*) l->data;
Geom::LineSegment ls(line->s, line->e);
Geom::Point nearest = ls.pointAt(ls.nearestPoint(p));
- double dist_screen = Geom::L2 (p - nearest) * desktop->current_zoom();
+ double dist_screen = Geom::L2(p - nearest) * desktop->current_zoom();
if (line->item && dist_screen < 5) {
- SPStop *stop = addStopNearPoint (line->item, p, 5/desktop->current_zoom());
+ SPStop *stop = addStopNearPoint(line->item, p, 5/desktop->current_zoom());
if (stop) {
- SPCSSAttr *css = sp_repr_css_attr_new ();
+ SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_set_property( css, "stop-color", stopIsNull ? 0 : toUse.c_str() );
sp_repr_css_set_property( css, "stop-opacity", "1" );
sp_repr_css_change(stop->getRepr(), css, "style");
@@ -1576,15 +1575,16 @@ void GrDrag::setDeselected(GrDragger *dragger)
*/
void GrDrag::addLine(SPItem *item, Geom::Point p1, Geom::Point p2, guint32 rgba)
{
- SPCanvasItem *line = sp_canvas_item_new(sp_desktop_controls(this->desktop),
- SP_TYPE_CTRLLINE, NULL);
+ SPCtrlLine *line = SP_CTRLLINE(sp_canvas_item_new(sp_desktop_controls(this->desktop), SP_TYPE_CTRLLINE, NULL));
+
sp_canvas_item_move_to_z(line, 0);
- SP_CTRLLINE(line)->item = item;
- sp_ctrlline_set_coords(SP_CTRLLINE(line), p1, p2);
- if (rgba != GR_LINE_COLOR_FILL) // fill is the default, so don't set color for it to speed up redraw
- sp_ctrlline_set_rgba32 (SP_CTRLLINE(line), rgba);
- sp_canvas_item_show (line);
- this->lines = g_slist_append (this->lines, line);
+ line->item = item;
+ line->setCoords(p1, p2);
+ if (rgba != GR_LINE_COLOR_FILL) { // fill is the default, so don't set color for it to speed up redraw
+ line->setRgba32(rgba);
+ }
+ sp_canvas_item_show(line);
+ this->lines = g_slist_append(this->lines, line);
}
/**
diff --git a/src/line-geometry.cpp b/src/line-geometry.cpp
index 2e528f3af..39f18dca4 100644
--- a/src/line-geometry.cpp
+++ b/src/line-geometry.cpp
@@ -211,11 +211,10 @@ void create_canvas_point(Geom::Point const &pos, double size, guint32 rgba)
void create_canvas_line(Geom::Point const &p1, Geom::Point const &p2, guint32 rgba)
{
SPDesktop *desktop = inkscape_active_desktop();
- SPCanvasItem *line = sp_canvas_item_new(sp_desktop_controls(desktop),
- SP_TYPE_CTRLLINE, NULL);
- sp_ctrlline_set_coords(SP_CTRLLINE(line), p1, p2);
- sp_ctrlline_set_rgba32 (SP_CTRLLINE(line), rgba);
- sp_canvas_item_show (line);
+ SPCtrlLine *line = SP_CTRLLINE(sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRLLINE, NULL));
+ line->setCoords(p1, p2);
+ line->setRgba32(rgba);
+ sp_canvas_item_show(line);
}
} // namespace Box3D
diff --git a/src/measure-context.cpp b/src/measure-context.cpp
index 3237bb3fb..e522c44a5 100644
--- a/src/measure-context.cpp
+++ b/src/measure-context.cpp
@@ -260,9 +260,8 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv
//draw control line
- SPCanvasItem * control_line = NULL;
- control_line = sp_canvas_item_new(sp_desktop_tempgroup(desktop), SP_TYPE_CTRLLINE, NULL);
- sp_ctrlline_set_coords(SP_CTRLLINE(control_line), start_point, end_point);
+ SPCtrlLine *control_line = SP_CTRLLINE(sp_canvas_item_new(sp_desktop_tempgroup(desktop), SP_TYPE_CTRLLINE, NULL));
+ control_line->setCoords(start_point, end_point);
measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0));
Geom::PathVector lineseg;
@@ -433,16 +432,16 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv
Geom::Point normal = desktop->w2d(Geom::unit_vector(Geom::rot90(desktop->d2w(end_point - start_point))));
if (intersections.size() > 2) {
- control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL);
- sp_ctrlline_set_coords(SP_CTRLLINE(control_line), desktop->doc2dt(intersections[0]) + normal*60, desktop->doc2dt(intersections[intersections.size()-1]) + normal*60);
+ control_line = SP_CTRLLINE(sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL));
+ control_line->setCoords(desktop->doc2dt(intersections[0]) + normal*60, desktop->doc2dt(intersections[intersections.size()-1]) + normal*60);
measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0));
- control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL);
- sp_ctrlline_set_coords(SP_CTRLLINE(control_line), desktop->doc2dt(intersections[0]), desktop->doc2dt(intersections[0]) + normal*65);
+ control_line = SP_CTRLLINE(sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL));
+ control_line->setCoords(desktop->doc2dt(intersections[0]), desktop->doc2dt(intersections[0]) + normal*65);
measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0));
- control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL);
- sp_ctrlline_set_coords(SP_CTRLLINE(control_line), desktop->doc2dt(intersections[intersections.size()-1]), desktop->doc2dt(intersections[intersections.size()-1]) + normal*65);
+ control_line = SP_CTRLLINE(sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL));
+ control_line->setCoords(desktop->doc2dt(intersections[intersections.size()-1]), desktop->doc2dt(intersections[intersections.size()-1]) + normal*65);
measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0));
double totallengthval = (intersections[intersections.size()-1] - intersections[0]).length();
diff --git a/src/pen-context.cpp b/src/pen-context.cpp
index 731f31e42..2fe510416 100644
--- a/src/pen-context.cpp
+++ b/src/pen-context.cpp
@@ -218,10 +218,10 @@ static void sp_pen_context_setup(SPEventContext *ec)
pc->c1 = ControlManager::getManager().createControl(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(ec)), Inkscape::CTRL_TYPE_ADJ_HANDLE);
ControlManager::getManager().track(pc->c1);
- pc->cl0 = sp_canvas_item_new(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRLLINE, NULL);
- sp_ctrlline_set_rgba32(SP_CTRLLINE(pc->cl0), 0x0000007f);
- pc->cl1 = sp_canvas_item_new(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRLLINE, NULL);
- sp_ctrlline_set_rgba32(SP_CTRLLINE(pc->cl1), 0x0000007f);
+ pc->cl0 = SP_CTRLLINE(sp_canvas_item_new(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRLLINE, NULL));
+ pc->cl0->setRgba32(0x0000007f);
+ pc->cl1 = SP_CTRLLINE(sp_canvas_item_new(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRLLINE, NULL));
+ pc->cl1->setRgba32(0x0000007f);
sp_canvas_item_hide(pc->c0);
sp_canvas_item_hide(pc->c1);
@@ -892,12 +892,12 @@ void pen_redraw_all (SPPenContext *const pc)
// handles
if (pc->p[0] != pc->p[1]) {
SP_CTRL(pc->c1)->moveto(pc->p[1]);
- sp_ctrlline_set_coords(SP_CTRLLINE(pc->cl1), pc->p[0], pc->p[1]);
- sp_canvas_item_show (pc->c1);
- sp_canvas_item_show (pc->cl1);
+ pc->cl1->setCoords(pc->p[0], pc->p[1]);
+ sp_canvas_item_show(pc->c1);
+ sp_canvas_item_show(pc->cl1);
} else {
- sp_canvas_item_hide (pc->c1);
- sp_canvas_item_hide (pc->cl1);
+ sp_canvas_item_hide(pc->c1);
+ sp_canvas_item_hide(pc->cl1);
}
Geom::Curve const * last_seg = pc->green_curve->last_segment();
@@ -908,12 +908,12 @@ void pen_redraw_all (SPPenContext *const pc)
{
Geom::Point p2 = (*cubic)[2];
SP_CTRL(pc->c0)->moveto(p2);
- sp_ctrlline_set_coords(SP_CTRLLINE(pc->cl0), p2, pc->p[0]);
- sp_canvas_item_show (pc->c0);
- sp_canvas_item_show (pc->cl0);
+ pc->cl0->setCoords(p2, pc->p[0]);
+ sp_canvas_item_show(pc->c0);
+ sp_canvas_item_show(pc->cl0);
} else {
- sp_canvas_item_hide (pc->c0);
- sp_canvas_item_hide (pc->cl0);
+ sp_canvas_item_hide(pc->c0);
+ sp_canvas_item_hide(pc->cl0);
}
}
}
@@ -1285,7 +1285,7 @@ static void spdc_pen_set_ctrl(SPPenContext *const pc, Geom::Point const p, guint
sp_canvas_item_hide(pc->c0);
sp_canvas_item_hide(pc->cl0);
SP_CTRL(pc->c1)->moveto(pc->p[1]);
- sp_ctrlline_set_coords(SP_CTRLLINE(pc->cl1), pc->p[0], pc->p[1]);
+ pc->cl1->setCoords(pc->p[0], pc->p[1]);
spdc_pen_set_angle_distance_status_message(pc, p, 0, _("<b>Curve handle</b>: angle %3.2f&#176;, length %s; with <b>Ctrl</b> to snap angle"));
} else if ( pc->npoints == 5 ) {
@@ -1304,9 +1304,9 @@ static void spdc_pen_set_ctrl(SPPenContext *const pc, Geom::Point const p, guint
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve);
}
SP_CTRL(pc->c0)->moveto(pc->p[2]);
- sp_ctrlline_set_coords(SP_CTRLLINE(pc->cl0), pc->p[3], pc->p[2]);
+ pc->cl0 ->setCoords(pc->p[3], pc->p[2]);
SP_CTRL(pc->c1)->moveto(pc->p[4]);
- sp_ctrlline_set_coords(SP_CTRLLINE(pc->cl1), pc->p[3], pc->p[4]);
+ pc->cl1->setCoords(pc->p[3], pc->p[4]);
gchar *message = is_symm ?
_("<b>Curve handle, symmetric</b>: angle %3.2f&#176;, length %s; with <b>Ctrl</b> to snap angle, with <b>Shift</b> to move this handle only") :
diff --git a/src/pen-context.h b/src/pen-context.h
index 1dfd6e184..a68b76ff5 100644
--- a/src/pen-context.h
+++ b/src/pen-context.h
@@ -26,6 +26,8 @@ enum {
SP_PEN_CONTEXT_MODE_DRAG
};
+struct SPCtrlLine;
+
/**
* SPPenContext: a context for pen tool events.
*/
@@ -49,8 +51,9 @@ struct SPPenContext : public SPDrawContext {
SPCanvasItem *c0;
SPCanvasItem *c1;
- SPCanvasItem *cl0;
- SPCanvasItem *cl1;
+
+ SPCtrlLine *cl0;
+ SPCtrlLine *cl1;
unsigned int events_disabled : 1;
};
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index 494c12916..ca190e5ad 100644
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
@@ -157,7 +157,7 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) :
sp_canvas_item_hide(_norm);
for (int i = 0; i < 4; i++) {
- _l[i] = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRLLINE, NULL);
+ _l[i] = SP_CTRLLINE(sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRLLINE, NULL));
sp_canvas_item_hide(_l[i]);
}
@@ -202,7 +202,7 @@ Inkscape::SelTrans::~SelTrans()
}
for (int i = 0; i < 4; i++) {
if (_l[i]) {
- gtk_object_destroy(GTK_OBJECT(_l[i]));
+ gtk_object_destroy(_l[i]);
_l[i] = NULL;
}
}
@@ -404,7 +404,7 @@ void Inkscape::SelTrans::transform(Geom::Affine const &rel_affine, Geom::Point c
p[i] = _bbox->corner(i) * affine;
}
for (unsigned i = 0 ; i < 4 ; i++) {
- sp_ctrlline_set_coords(SP_CTRLLINE(_l[i]), p[i], p[(i+1)%4]);
+ _l[i]->setCoords(p[i], p[(i+1)%4]);
}
}
}
diff --git a/src/seltrans.h b/src/seltrans.h
index 122e7a522..55c109ed7 100644
--- a/src/seltrans.h
+++ b/src/seltrans.h
@@ -29,6 +29,7 @@
struct SPKnot;
class SPDesktop;
struct SPCanvasItem;
+struct SPCtrlLine;
class SPSelTransHandle;
namespace Inkscape
@@ -167,7 +168,7 @@ private:
SPKnot *_chandle;
SPCanvasItem *_norm;
SPCanvasItem *_grip;
- SPCanvasItem *_l[4];
+ SPCtrlLine *_l[4];
guint _sel_changed_id;
guint _sel_modified_id;
GSList *_stamp_cache;
diff --git a/src/text-context.cpp b/src/text-context.cpp
index 94e25069b..2bf172f43 100644
--- a/src/text-context.cpp
+++ b/src/text-context.cpp
@@ -200,9 +200,9 @@ static void sp_text_context_setup(SPEventContext *ec)
timeout /= 2;
}
- tc->cursor = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRLLINE, NULL);
- sp_ctrlline_set_coords(SP_CTRLLINE(tc->cursor), 100, 0, 100, 100);
- sp_ctrlline_set_rgba32(SP_CTRLLINE(tc->cursor), 0x000000ff);
+ tc->cursor = SP_CTRLLINE(sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRLLINE, NULL));
+ tc->cursor->setCoords(100, 0, 100, 100);
+ tc->cursor->setRgba32(0x000000ff);
sp_canvas_item_hide(tc->cursor);
tc->indicator = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRLRECT, NULL);
@@ -302,7 +302,7 @@ static void sp_text_context_finish(SPEventContext *ec)
}
if (tc->cursor) {
- gtk_object_destroy(GTK_OBJECT(tc->cursor));
+ gtk_object_destroy(tc->cursor);
tc->cursor = NULL;
}
@@ -708,7 +708,7 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd
// Cursor height is defined by the new text object's font size; it needs to be set
// artificially here, for the text object does not exist yet:
double cursor_height = sp_desktop_get_font_size_tool(desktop);
- sp_ctrlline_set_coords(SP_CTRLLINE(tc->cursor), p1, p1 + Geom::Point(0, cursor_height));
+ tc->cursor->setCoords(p1, p1 + Geom::Point(0, cursor_height));
if (tc->imc) {
GdkRectangle im_cursor;
Geom::Point const top_left = SP_EVENT_CONTEXT(tc)->desktop->get_display_area().corner(3);
@@ -1608,7 +1608,7 @@ static void sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see
}
sp_canvas_item_show(tc->cursor);
- sp_ctrlline_set_coords(SP_CTRLLINE(tc->cursor), d0, d1);
+ tc->cursor->setCoords(d0, d1);
/* fixme: ... need another transformation to get canvas widget coordinate space? */
if (tc->imc) {
@@ -1699,10 +1699,10 @@ static gint sp_text_context_timeout(SPTextContext *tc)
sp_canvas_item_show(tc->cursor);
if (tc->phase) {
tc->phase = 0;
- sp_ctrlline_set_rgba32(SP_CTRLLINE(tc->cursor), 0x000000ff);
+ tc->cursor->setRgba32(0x000000ff);
} else {
tc->phase = 1;
- sp_ctrlline_set_rgba32(SP_CTRLLINE(tc->cursor), 0xffffffff);
+ tc->cursor->setRgba32(0xffffffff);
}
}
diff --git a/src/text-context.h b/src/text-context.h
index 50a738ca0..9915583eb 100644
--- a/src/text-context.h
+++ b/src/text-context.h
@@ -29,6 +29,7 @@
#define SP_IS_TEXT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_TEXT_CONTEXT))
#define SP_IS_TEXT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_TEXT_CONTEXT))
+struct SPCtrlLine;
class SPTextContext;
class SPTextContextClass;
@@ -53,7 +54,7 @@ struct SPTextContext : public SPEventContext {
bool unimode;
guint unipos;
- SPCanvasItem *cursor;
+ SPCtrlLine *cursor;
SPCanvasItem *indicator;
SPCanvasItem *frame; // hiliting the first frame of flowtext; FIXME: make this a list to accommodate arbitrarily many chained shapes
std::vector<SPCanvasItem*> text_selection_quads;
diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp
index 61f306a66..ad48b523b 100644
--- a/src/ui/tool/node.cpp
+++ b/src/ui/tool/node.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
@@ -91,20 +92,23 @@ Handle::Handle(NodeSharedData const &data, Geom::Point const &initial_pos, Node
, _degenerate(true)
{
_cset = &handle_colors;
- _handle_line = sp_canvas_item_new(data.handle_line_group, SP_TYPE_CTRLLINE, NULL);
+ _handle_line = SP_CTRLLINE(sp_canvas_item_new(data.handle_line_group, SP_TYPE_CTRLLINE, NULL));
setVisible(false);
}
Handle::~Handle()
{
//sp_canvas_item_hide(_handle_line);
- gtk_object_destroy(GTK_OBJECT(_handle_line));
+ gtk_object_destroy(_handle_line);
}
void Handle::setVisible(bool v)
{
ControlPoint::setVisible(v);
- if (v) sp_canvas_item_show(_handle_line);
- else sp_canvas_item_hide(_handle_line);
+ if (v) {
+ sp_canvas_item_show(_handle_line);
+ } else {
+ sp_canvas_item_hide(_handle_line);
+ }
}
void Handle::move(Geom::Point const &new_pos)
@@ -181,7 +185,7 @@ void Handle::move(Geom::Point const &new_pos)
void Handle::setPosition(Geom::Point const &p)
{
ControlPoint::setPosition(p);
- sp_ctrlline_set_coords(SP_CTRLLINE(_handle_line), _parent->position(), position());
+ _handle_line->setCoords(_parent->position(), position());
// update degeneration info and visibility
if (Geom::are_near(position(), _parent->position()))
diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h
index 94b67da59..f2e31e018 100644
--- a/src/ui/tool/node.h
+++ b/src/ui/tool/node.h
@@ -22,6 +22,7 @@
#include "snapped-point.h"
#include "ui/tool/node-types.h"
+struct SPCtrlLine;
namespace Inkscape {
namespace UI {
@@ -113,7 +114,7 @@ private:
inline PathManipulator &_pm();
Node *_parent; // the handle's lifetime does not extend beyond that of the parent node,
// so a naked pointer is OK and allows setting it during Node's construction
- SPCanvasItem *_handle_line;
+ SPCtrlLine *_handle_line;
bool _degenerate; // True if the handle is retracted, i.e. has zero length. This is used often internally so it makes sense to cache this
static Geom::Point _saved_other_pos;
diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp
index fb48fb2d9..f90966578 100644
--- a/src/vanishing-point.cpp
+++ b/src/vanishing-point.cpp
@@ -766,17 +766,17 @@ VPDrag::swap_perspectives_of_VPs(Persp3D *persp2, Persp3D *persp1)
}
/**
-Create a line from p1 to p2 and add it to the lines list
+ * Create a line from p1 to p2 and add it to the lines list.
*/
-void
-VPDrag::addLine (Geom::Point p1, Geom::Point p2, guint32 rgba)
+void VPDrag::addLine(Geom::Point p1, Geom::Point p2, guint32 rgba)
{
- SPCanvasItem *line = sp_canvas_item_new(sp_desktop_controls(inkscape_active_desktop()), SP_TYPE_CTRLLINE, NULL);
- sp_ctrlline_set_coords(SP_CTRLLINE(line), p1, p2);
- if (rgba != VP_LINE_COLOR_FILL) // fill is the default, so don't set color for it to speed up redraw
- sp_ctrlline_set_rgba32 (SP_CTRLLINE(line), rgba);
- sp_canvas_item_show (line);
- this->lines = g_slist_append (this->lines, line);
+ SPCtrlLine *line = SP_CTRLLINE(sp_canvas_item_new(sp_desktop_controls(inkscape_active_desktop()), SP_TYPE_CTRLLINE, NULL));
+ line->setCoords(p1, p2);
+ if (rgba != VP_LINE_COLOR_FILL) { // fill is the default, so don't set color for it to speed up redraw
+ line->setRgba32(rgba);
+ }
+ sp_canvas_item_show(line);
+ this->lines = g_slist_append(this->lines, line);
}
} // namespace Box3D