1 #define __SP_ROOT_C__
3 /** \file
4 * SVG \<svg\> implementation.
5 */
6 /*
7 * Authors:
8 * Lauris Kaplinski <lauris@kaplinski.com>
9 *
10 * Copyright (C) 1999-2002 Lauris Kaplinski
11 * Copyright (C) 2000-2001 Ximian, Inc.
12 *
13 * Released under GNU GPL, read the file 'COPYING' for more information
14 */
16 #ifdef HAVE_CONFIG_H
17 # include "config.h"
18 #endif
20 #include <cstring>
21 #include <string>
23 #include "svg/svg.h"
24 #include "display/nr-arena-group.h"
25 #include "attributes.h"
26 #include "print.h"
27 #include "document.h"
28 #include "sp-defs.h"
29 #include "sp-root.h"
30 #include <libnr/nr-matrix-fns.h>
31 #include <libnr/nr-matrix-ops.h>
32 #include <libnr/nr-matrix-translate-ops.h>
33 #include <libnr/nr-scale-ops.h>
34 #include <libnr/nr-translate-scale-ops.h>
35 #include <xml/repr.h>
36 #include "svg/stringstream.h"
37 #include "inkscape-version.h"
39 class SPDesktop;
41 static void sp_root_class_init(SPRootClass *klass);
42 static void sp_root_init(SPRoot *root);
44 static void sp_root_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
45 static void sp_root_release(SPObject *object);
46 static void sp_root_set(SPObject *object, unsigned int key, gchar const *value);
47 static void sp_root_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref);
48 static void sp_root_remove_child(SPObject *object, Inkscape::XML::Node *child);
49 static void sp_root_update(SPObject *object, SPCtx *ctx, guint flags);
50 static void sp_root_modified(SPObject *object, guint flags);
51 static Inkscape::XML::Node *sp_root_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
53 static NRArenaItem *sp_root_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
54 static void sp_root_print(SPItem *item, SPPrintContext *ctx);
56 static SPGroupClass *parent_class;
58 /**
59 * Returns the type info of sp_root, including its class sizes and initialization routines.
60 */
61 GType
62 sp_root_get_type(void)
63 {
64 static GType type = 0;
65 if (!type) {
66 GTypeInfo info = {
67 sizeof(SPRootClass),
68 NULL, NULL,
69 (GClassInitFunc) sp_root_class_init,
70 NULL, NULL,
71 sizeof(SPRoot),
72 16,
73 (GInstanceInitFunc) sp_root_init,
74 NULL, /* value_table */
75 };
76 type = g_type_register_static(SP_TYPE_GROUP, "SPRoot", &info, (GTypeFlags)0);
77 }
78 return type;
79 }
81 /**
82 * Initializes an SPRootClass object by setting its class and parent class objects, and registering
83 * function pointers (i.e.\ gobject-style virtual functions) for various operations.
84 */
85 static void
86 sp_root_class_init(SPRootClass *klass)
87 {
88 GObjectClass *object_class;
89 SPObjectClass *sp_object_class;
90 SPItemClass *sp_item_class;
92 object_class = G_OBJECT_CLASS(klass);
93 sp_object_class = (SPObjectClass *) klass;
94 sp_item_class = (SPItemClass *) klass;
96 parent_class = (SPGroupClass *)g_type_class_ref(SP_TYPE_GROUP);
98 sp_object_class->build = sp_root_build;
99 sp_object_class->release = sp_root_release;
100 sp_object_class->set = sp_root_set;
101 sp_object_class->child_added = sp_root_child_added;
102 sp_object_class->remove_child = sp_root_remove_child;
103 sp_object_class->update = sp_root_update;
104 sp_object_class->modified = sp_root_modified;
105 sp_object_class->write = sp_root_write;
107 sp_item_class->show = sp_root_show;
108 sp_item_class->print = sp_root_print;
109 }
111 /**
112 * Initializes an SPRoot object by setting its default parameter values.
113 */
114 static void
115 sp_root_init(SPRoot *root)
116 {
117 static Inkscape::Version const zero_version(0, 0);
119 sp_version_from_string(SVG_VERSION, &root->original.svg);
120 root->version.svg = zero_version;
121 root->original.svg = zero_version;
122 root->version.inkscape = zero_version;
123 root->original.inkscape = zero_version;
125 root->x.unset();
126 root->y.unset();
127 root->width.unset(SVGLength::PERCENT, 1.0, 1.0);
128 root->height.unset(SVGLength::PERCENT, 1.0, 1.0);
130 /* root->viewbox.set_identity(); */
131 root->viewBox_set = FALSE;
133 root->c2p.setIdentity();
135 root->defs = NULL;
136 }
138 /**
139 * Fills in the data for an SPObject from its Inkscape::XML::Node object.
140 * It fills in data such as version, x, y, width, height, etc.
141 * It then calls the object's parent class object's build function.
142 */
143 static void
144 sp_root_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
145 {
146 SPGroup *group = (SPGroup *) object;
147 SPRoot *root = (SPRoot *) object;
149 if ( !object->repr->attribute("version") ) {
150 repr->setAttribute("version", SVG_VERSION);
151 }
153 sp_object_read_attr(object, "version");
154 sp_object_read_attr(object, "inkscape:version");
155 /* It is important to parse these here, so objects will have viewport build-time */
156 sp_object_read_attr(object, "x");
157 sp_object_read_attr(object, "y");
158 sp_object_read_attr(object, "width");
159 sp_object_read_attr(object, "height");
160 sp_object_read_attr(object, "viewBox");
161 sp_object_read_attr(object, "preserveAspectRatio");
162 sp_object_read_attr(object, "onload");
164 if (((SPObjectClass *) parent_class)->build)
165 (* ((SPObjectClass *) parent_class)->build) (object, document, repr);
167 /* Search for first <defs> node */
168 for (SPObject *o = sp_object_first_child(SP_OBJECT(group)) ; o != NULL; o = SP_OBJECT_NEXT(o) ) {
169 if (SP_IS_DEFS(o)) {
170 root->defs = SP_DEFS(o);
171 break;
172 }
173 }
175 // clear transform, if any was read in - SVG does not allow transform= on <svg>
176 SP_ITEM(object)->transform = Geom::identity();
177 }
179 /**
180 * This is a destructor routine for SPRoot objects. It de-references any \<def\> items and calls
181 * the parent class destructor.
182 */
183 static void
184 sp_root_release(SPObject *object)
185 {
186 SPRoot *root = (SPRoot *) object;
187 root->defs = NULL;
189 if (((SPObjectClass *) parent_class)->release)
190 ((SPObjectClass *) parent_class)->release(object);
191 }
193 /**
194 * Sets the attribute given by key for SPRoot objects to the value specified by value.
195 */
196 static void
197 sp_root_set(SPObject *object, unsigned int key, gchar const *value)
198 {
199 SPRoot *root = SP_ROOT(object);
201 switch (key) {
202 case SP_ATTR_VERSION:
203 if (!sp_version_from_string(value, &root->version.svg)) {
204 root->version.svg = root->original.svg;
205 }
206 break;
207 case SP_ATTR_INKSCAPE_VERSION:
208 if (!sp_version_from_string(value, &root->version.inkscape)) {
209 root->version.inkscape = root->original.inkscape;
210 }
211 break;
212 case SP_ATTR_X:
213 if (!root->x.readAbsolute(value)) {
214 /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */
215 root->x.unset();
216 }
217 /* fixme: I am almost sure these do not require viewport flag (Lauris) */
218 object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG);
219 break;
220 case SP_ATTR_Y:
221 if (!root->y.readAbsolute(value)) {
222 /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */
223 root->y.unset();
224 }
225 /* fixme: I am almost sure these do not require viewport flag (Lauris) */
226 object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG);
227 break;
228 case SP_ATTR_WIDTH:
229 if (!root->width.readAbsolute(value) || !(root->width.computed > 0.0)) {
230 /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */
231 root->width.unset(SVGLength::PERCENT, 1.0, 1.0);
232 }
233 object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG);
234 break;
235 case SP_ATTR_HEIGHT:
236 if (!root->height.readAbsolute(value) || !(root->height.computed > 0.0)) {
237 /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */
238 root->height.unset(SVGLength::PERCENT, 1.0, 1.0);
239 }
240 object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG);
241 break;
242 case SP_ATTR_VIEWBOX:
243 if (value) {
244 double x, y, width, height;
245 char *eptr;
246 /* fixme: We have to take original item affine into account */
247 /* fixme: Think (Lauris) */
248 eptr = (gchar *) value;
249 x = g_ascii_strtod(eptr, &eptr);
250 while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++;
251 y = g_ascii_strtod(eptr, &eptr);
252 while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++;
253 width = g_ascii_strtod(eptr, &eptr);
254 while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++;
255 height = g_ascii_strtod(eptr, &eptr);
256 while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++;
257 if ((width > 0) && (height > 0)) {
258 /* Set viewbox */
259 root->viewBox.x0 = x;
260 root->viewBox.y0 = y;
261 root->viewBox.x1 = x + width;
262 root->viewBox.y1 = y + height;
263 root->viewBox_set = TRUE;
264 } else {
265 root->viewBox_set = FALSE;
266 }
267 } else {
268 root->viewBox_set = FALSE;
269 }
270 object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG);
271 break;
272 case SP_ATTR_PRESERVEASPECTRATIO:
273 /* Do setup before, so we can use break to escape */
274 root->aspect_set = FALSE;
275 root->aspect_align = SP_ASPECT_XMID_YMID;
276 root->aspect_clip = SP_ASPECT_MEET;
277 object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG);
278 if (value) {
279 int len;
280 gchar c[256];
281 gchar const *p, *e;
282 unsigned int align, clip;
283 p = value;
284 while (*p && *p == 32) p += 1;
285 if (!*p) break;
286 e = p;
287 while (*e && *e != 32) e += 1;
288 len = e - p;
289 if (len > 8) break;
290 memcpy(c, value, len);
291 c[len] = 0;
292 /* Now the actual part */
293 if (!strcmp(c, "none")) {
294 align = SP_ASPECT_NONE;
295 } else if (!strcmp(c, "xMinYMin")) {
296 align = SP_ASPECT_XMIN_YMIN;
297 } else if (!strcmp(c, "xMidYMin")) {
298 align = SP_ASPECT_XMID_YMIN;
299 } else if (!strcmp(c, "xMaxYMin")) {
300 align = SP_ASPECT_XMAX_YMIN;
301 } else if (!strcmp(c, "xMinYMid")) {
302 align = SP_ASPECT_XMIN_YMID;
303 } else if (!strcmp(c, "xMidYMid")) {
304 align = SP_ASPECT_XMID_YMID;
305 } else if (!strcmp(c, "xMaxYMid")) {
306 align = SP_ASPECT_XMAX_YMID;
307 } else if (!strcmp(c, "xMinYMax")) {
308 align = SP_ASPECT_XMIN_YMAX;
309 } else if (!strcmp(c, "xMidYMax")) {
310 align = SP_ASPECT_XMID_YMAX;
311 } else if (!strcmp(c, "xMaxYMax")) {
312 align = SP_ASPECT_XMAX_YMAX;
313 } else {
314 break;
315 }
316 clip = SP_ASPECT_MEET;
317 while (*e && *e == 32) e += 1;
318 if (*e) {
319 if (!strcmp(e, "meet")) {
320 clip = SP_ASPECT_MEET;
321 } else if (!strcmp(e, "slice")) {
322 clip = SP_ASPECT_SLICE;
323 } else {
324 break;
325 }
326 }
327 root->aspect_set = TRUE;
328 root->aspect_align = align;
329 root->aspect_clip = clip;
330 }
331 break;
332 case SP_ATTR_ONLOAD:
333 root->onload = (char *) value;
334 break;
335 default:
336 /* Pass the set event to the parent */
337 if (((SPObjectClass *) parent_class)->set) {
338 ((SPObjectClass *) parent_class)->set(object, key, value);
339 }
340 break;
341 }
342 }
344 /**
345 * This routine is for adding a child SVG object to an SPRoot object.
346 * The SPRoot object is taken to be an SPGroup.
347 */
348 static void
349 sp_root_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
350 {
351 SPRoot *root = (SPRoot *) object;
352 SPGroup *group = (SPGroup *) object;
354 if (((SPObjectClass *) (parent_class))->child_added)
355 (* ((SPObjectClass *) (parent_class))->child_added)(object, child, ref);
357 SPObject *co = object->document->getObjectByRepr(child);
358 g_assert (co != NULL || !strcmp("comment", child->name())); // comment repr node has no object
360 if (co && SP_IS_DEFS(co)) {
361 SPObject *c;
362 /* We search for first <defs> node - it is not beautiful, but works */
363 for (c = sp_object_first_child(SP_OBJECT(group)) ; c != NULL; c = SP_OBJECT_NEXT(c) ) {
364 if (SP_IS_DEFS(c)) {
365 root->defs = SP_DEFS(c);
366 break;
367 }
368 }
369 }
370 }
372 /**
373 * Removes the given child from this SPRoot object.
374 */
375 static void sp_root_remove_child(SPObject *object, Inkscape::XML::Node *child)
376 {
377 SPRoot *root = (SPRoot *) object;
379 if ( root->defs && SP_OBJECT_REPR(root->defs) == child ) {
380 SPObject *iter;
381 /* We search for first remaining <defs> node - it is not beautiful, but works */
382 for ( iter = sp_object_first_child(object) ; iter ; iter = SP_OBJECT_NEXT(iter) ) {
383 if ( SP_IS_DEFS(iter) && (SPDefs *)iter != root->defs ) {
384 root->defs = (SPDefs *)iter;
385 break;
386 }
387 }
388 if (!iter) {
389 /* we should probably create a new <defs> here? */
390 root->defs = NULL;
391 }
392 }
394 if (((SPObjectClass *) (parent_class))->remove_child)
395 (* ((SPObjectClass *) (parent_class))->remove_child)(object, child);
396 }
398 /**
399 * This callback routine updates the SPRoot object when its attributes have been changed.
400 */
401 static void
402 sp_root_update(SPObject *object, SPCtx *ctx, guint flags)
403 {
404 SPItemView *v;
406 SPItem *item = SP_ITEM(object);
407 SPRoot *root = SP_ROOT(object);
408 SPItemCtx *ictx = (SPItemCtx *) ctx;
410 /* fixme: This will be invoked too often (Lauris) */
411 /* fixme: We should calculate only if parent viewport has changed (Lauris) */
412 /* If position is specified as percentage, calculate actual values */
413 if (root->x.unit == SVGLength::PERCENT) {
414 root->x.computed = root->x.value * (ictx->vp.x1 - ictx->vp.x0);
415 }
416 if (root->y.unit == SVGLength::PERCENT) {
417 root->y.computed = root->y.value * (ictx->vp.y1 - ictx->vp.y0);
418 }
419 if (root->width.unit == SVGLength::PERCENT) {
420 root->width.computed = root->width.value * (ictx->vp.x1 - ictx->vp.x0);
421 }
422 if (root->height.unit == SVGLength::PERCENT) {
423 root->height.computed = root->height.value * (ictx->vp.y1 - ictx->vp.y0);
424 }
426 /* Create copy of item context */
427 SPItemCtx rctx = *ictx;
429 /* Calculate child to parent transformation */
430 root->c2p.setIdentity();
432 if (object->parent) {
433 /*
434 * fixme: I am not sure whether setting x and y does or does not
435 * fixme: translate the content of inner SVG.
436 * fixme: Still applying translation and setting viewport to width and
437 * fixme: height seems natural, as this makes the inner svg element
438 * fixme: self-contained. The spec is vague here.
439 */
440 root->c2p = Geom::Matrix(Geom::Translate(root->x.computed,
441 root->y.computed));
442 }
444 if (root->viewBox_set) {
445 double x, y, width, height;
446 /* Determine actual viewbox in viewport coordinates */
447 if (root->aspect_align == SP_ASPECT_NONE) {
448 x = 0.0;
449 y = 0.0;
450 width = root->width.computed;
451 height = root->height.computed;
452 } else {
453 double scalex, scaley, scale;
454 /* Things are getting interesting */
455 scalex = root->width.computed / (root->viewBox.x1 - root->viewBox.x0);
456 scaley = root->height.computed / (root->viewBox.y1 - root->viewBox.y0);
457 scale = (root->aspect_clip == SP_ASPECT_MEET) ? MIN(scalex, scaley) : MAX(scalex, scaley);
458 width = (root->viewBox.x1 - root->viewBox.x0) * scale;
459 height = (root->viewBox.y1 - root->viewBox.y0) * scale;
460 /* Now place viewbox to requested position */
461 /* todo: Use an array lookup to find the 0.0/0.5/1.0 coefficients,
462 as is done for dialogs/align.cpp. */
463 switch (root->aspect_align) {
464 case SP_ASPECT_XMIN_YMIN:
465 x = 0.0;
466 y = 0.0;
467 break;
468 case SP_ASPECT_XMID_YMIN:
469 x = 0.5 * (root->width.computed - width);
470 y = 0.0;
471 break;
472 case SP_ASPECT_XMAX_YMIN:
473 x = 1.0 * (root->width.computed - width);
474 y = 0.0;
475 break;
476 case SP_ASPECT_XMIN_YMID:
477 x = 0.0;
478 y = 0.5 * (root->height.computed - height);
479 break;
480 case SP_ASPECT_XMID_YMID:
481 x = 0.5 * (root->width.computed - width);
482 y = 0.5 * (root->height.computed - height);
483 break;
484 case SP_ASPECT_XMAX_YMID:
485 x = 1.0 * (root->width.computed - width);
486 y = 0.5 * (root->height.computed - height);
487 break;
488 case SP_ASPECT_XMIN_YMAX:
489 x = 0.0;
490 y = 1.0 * (root->height.computed - height);
491 break;
492 case SP_ASPECT_XMID_YMAX:
493 x = 0.5 * (root->width.computed - width);
494 y = 1.0 * (root->height.computed - height);
495 break;
496 case SP_ASPECT_XMAX_YMAX:
497 x = 1.0 * (root->width.computed - width);
498 y = 1.0 * (root->height.computed - height);
499 break;
500 default:
501 x = 0.0;
502 y = 0.0;
503 break;
504 }
505 }
507 /* Compose additional transformation from scale and position */
508 Geom::Point const viewBox_min(root->viewBox.x0,
509 root->viewBox.y0);
510 Geom::Point const viewBox_max(root->viewBox.x1,
511 root->viewBox.y1);
512 Geom::Scale const viewBox_length( viewBox_max - viewBox_min );
513 Geom::Scale const new_length(width, height);
515 /* Append viewbox transformation */
516 /* TODO: The below looks suspicious to me (pjrm): I wonder whether the RHS
517 expression should have c2p at the beginning rather than at the end. Test it. */
518 root->c2p = Geom::Translate(-viewBox_min) * ( new_length * viewBox_length.inverse() ) * Geom::Translate(x, y) * root->c2p;
519 }
521 rctx.i2doc = root->c2p * rctx.i2doc;
523 /* Initialize child viewport */
524 if (root->viewBox_set) {
525 rctx.vp.x0 = root->viewBox.x0;
526 rctx.vp.y0 = root->viewBox.y0;
527 rctx.vp.x1 = root->viewBox.x1;
528 rctx.vp.y1 = root->viewBox.y1;
529 } else {
530 /* fixme: I wonder whether this logic is correct (Lauris) */
531 if (object->parent) {
532 rctx.vp.x0 = root->x.computed;
533 rctx.vp.y0 = root->y.computed;
534 } else {
535 rctx.vp.x0 = 0.0;
536 rctx.vp.y0 = 0.0;
537 }
538 rctx.vp.x1 = root->width.computed;
539 rctx.vp.y1 = root->height.computed;
540 }
542 rctx.i2vp = Geom::identity();
544 /* And invoke parent method */
545 if (((SPObjectClass *) (parent_class))->update)
546 ((SPObjectClass *) (parent_class))->update(object, (SPCtx *) &rctx, flags);
548 /* As last step set additional transform of arena group */
549 for (v = item->display; v != NULL; v = v->next) {
550 nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->arenaitem), root->c2p);
551 }
552 }
554 /**
555 * Calls the <tt>modified</tt> routine of the SPRoot object's parent class.
556 * Also, if the viewport has been modified, it sets the document size to the new
557 * height and width.
558 */
559 static void
560 sp_root_modified(SPObject *object, guint flags)
561 {
562 SPRoot *root = SP_ROOT(object);
564 if (((SPObjectClass *) (parent_class))->modified)
565 (* ((SPObjectClass *) (parent_class))->modified)(object, flags);
567 /* fixme: (Lauris) */
568 if (!object->parent && (flags & SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
569 sp_document_resized_signal_emit (SP_OBJECT_DOCUMENT(root), root->width.computed, root->height.computed);
570 }
571 }
573 /**
574 * Writes the object into the repr object, then calls the parent's write routine.
575 */
576 static Inkscape::XML::Node *
577 sp_root_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
578 {
579 SPRoot *root = SP_ROOT(object);
581 if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
582 repr = xml_doc->createElement("svg:svg");
583 }
585 if (flags & SP_OBJECT_WRITE_EXT) {
586 repr->setAttribute("inkscape:version", Inkscape::version_string);
587 }
589 if ( !repr->attribute("version") ) {
590 repr->setAttribute("version", sp_version_to_string(root->version.svg));
591 }
593 if (fabs(root->x.computed) > 1e-9)
594 sp_repr_set_svg_double(repr, "x", root->x.computed);
595 if (fabs(root->y.computed) > 1e-9)
596 sp_repr_set_svg_double(repr, "y", root->y.computed);
598 /* Unlike all other SPObject, here we want to preserve absolute units too (and only here,
599 * according to the recommendation in http://www.w3.org/TR/SVG11/coords.html#Units).
600 */
601 repr->setAttribute("width", sp_svg_length_write_with_units(root->width).c_str());
602 repr->setAttribute("height", sp_svg_length_write_with_units(root->height).c_str());
604 if (root->viewBox_set) {
605 Inkscape::SVGOStringStream os;
606 os << root->viewBox.x0 << " " << root->viewBox.y0 << " " << root->viewBox.x1 - root->viewBox.x0 << " " << root->viewBox.y1 - root->viewBox.y0;
607 repr->setAttribute("viewBox", os.str().c_str());
608 }
610 if (((SPObjectClass *) (parent_class))->write)
611 ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags);
613 return repr;
614 }
616 /**
617 * Displays the SPRoot item on the NRArena.
618 */
619 static NRArenaItem *
620 sp_root_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags)
621 {
622 SPRoot *root = SP_ROOT(item);
624 NRArenaItem *ai;
625 if (((SPItemClass *) (parent_class))->show) {
626 ai = ((SPItemClass *) (parent_class))->show(item, arena, key, flags);
627 if (ai) {
628 nr_arena_group_set_child_transform(NR_ARENA_GROUP(ai), root->c2p);
629 }
630 } else {
631 ai = NULL;
632 }
634 return ai;
635 }
637 /**
638 * Virtual print callback.
639 */
640 static void
641 sp_root_print(SPItem *item, SPPrintContext *ctx)
642 {
643 SPRoot *root = SP_ROOT(item);
645 sp_print_bind(ctx, root->c2p, 1.0);
647 if (((SPItemClass *) (parent_class))->print) {
648 ((SPItemClass *) (parent_class))->print(item, ctx);
649 }
651 sp_print_release(ctx);
652 }
655 /*
656 Local Variables:
657 mode:c++
658 c-file-style:"stroustrup"
659 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
660 indent-tabs-mode:nil
661 fill-column:99
662 End:
663 */
664 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :