>
<!ENTITY % object_commons_attrs
- "name CDATA #REQUIRED
- x CDATA #REQUIRED
- y CDATA #REQUIRED"
+ "name CDATA #REQUIRED
+ x CDATA #REQUIRED
+ y CDATA #REQUIRED
+ visible (y | n) #IMPLIED"
>
<!ENTITY % object_size_attrs
<!ENTITY % object_position_attrs
"x CDATA #REQUIRED
- y CDATA #REQUIRED"
+ y CDATA #REQUIRED
+ visible (y | n) #IMPLIED"
>
<!ENTITY % object_size_attrs
/*
- * Copyright (C) 2007 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2007-2011 Andrea Zagli <azagli@libero.it>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
{
PROP_0,
PROP_NAME,
- PROP_POSITION
+ PROP_POSITION,
+ PROP_VISIBLE
};
static void rpt_object_class_init (RptObjectClass *klass);
{
gchar *name;
RptPoint *position;
+ gboolean visibile;
};
-GType
-rpt_object_get_type (void)
-{
- static GType rpt_object_type = 0;
-
- if (!rpt_object_type)
- {
- static const GTypeInfo rpt_object_info =
- {
- sizeof (RptObjectClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) rpt_object_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (RptObject),
- 0, /* n_preallocs */
- (GInstanceInitFunc) rpt_object_init,
- NULL
- };
-
- rpt_object_type = g_type_register_static (G_TYPE_OBJECT, "RptObject",
- &rpt_object_info, 0);
- }
-
- return rpt_object_type;
-}
+G_DEFINE_TYPE (RptObject, rpt_object, G_TYPE_OBJECT)
static void
rpt_object_class_init (RptObjectClass *klass)
"Position",
"The object's position.",
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_VISIBLE,
+ g_param_spec_boolean ("visible",
+ "Visibility",
+ "The object's visibility.",
+ TRUE,
+ G_PARAM_READWRITE));
}
static void
{
RptObjectPrivate *priv = RPT_OBJECT_GET_PRIVATE (rpt_object);
+ priv->name = NULL;
priv->position = NULL;
+ priv->visibile = TRUE;
}
/**
RptObjectPrivate *priv = RPT_OBJECT_GET_PRIVATE (rpt_object);
xmlSetProp (xnode, "name", priv->name);
+
if (priv->position != NULL)
{
rpt_common_set_position (xnode, priv->position);
}
+ xmlSetProp (xnode, "visible", priv->visibile ? "y" : "n");
+
RPT_OBJECT_GET_CLASS (rpt_object)->get_xml (rpt_object, xnode);
}
}
+/**
+ * rpt_object_set_from_xml:
+ * @rpt_object:
+ * @xnode:
+ *
+ */
+void
+rpt_object_set_from_xml (RptObject *rpt_object, xmlNode *xnode)
+{
+ gchar *prop;
+
+ g_return_if_fail (IS_RPT_OBJECT (rpt_object));
+
+ prop = (gchar *)xmlGetProp (xnode, "visible");
+ g_object_set (rpt_object, "visible", g_strcmp0 (prop, "y") == 0, NULL);
+ if (prop != NULL) xmlFree (prop);
+}
+
static void
rpt_object_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
RptObject *rpt_object = RPT_OBJECT (object);
-
RptObjectPrivate *priv = RPT_OBJECT_GET_PRIVATE (rpt_object);
switch (property_id)
priv->position = g_memdup (g_value_get_pointer (value), sizeof (RptPoint));
break;
+ case PROP_VISIBLE:
+ priv->visibile = g_value_get_boolean (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
rpt_object_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
{
RptObject *rpt_object = RPT_OBJECT (object);
-
RptObjectPrivate *priv = RPT_OBJECT_GET_PRIVATE (rpt_object);
switch (property_id)
g_value_set_pointer (value, g_memdup (priv->position, sizeof (RptPoint)));
break;
+ case PROP_VISIBLE:
+ g_value_set_boolean (value, priv->visibile);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
/*
- * Copyright (C) 2007 Andrea Zagli <azagli@inwind.it>
+ * Copyright (C) 2007-2011 Andrea Zagli <azagli@inwind.it>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
RptObject *rpt_object_new (const gchar *name, RptPoint position);
void rpt_object_get_xml (RptObject *rpt_object, xmlNode *xnode);
+void rpt_object_set_from_xml (RptObject *rpt_object, xmlNode *xnode);
G_END_DECLS
/*
- * Copyright (C) 2007-2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2007-2011 Andrea Zagli <azagli@libero.it>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
RptSize *size;
RptStroke *stroke;
+ rpt_object_set_from_xml (RPT_OBJECT (rpt_obj_ellipse), xnode);
+
priv = RPT_OBJ_ELLIPSE_GET_PRIVATE (rpt_obj_ellipse);
size = rpt_common_get_size (xnode);
/*
- * Copyright (C) 2007 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2007-2011 Andrea Zagli <azagli@libero.it>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
{
priv = RPT_OBJ_IMAGE_GET_PRIVATE (rpt_obj_image);
+ rpt_object_set_from_xml (RPT_OBJECT (rpt_obj_image), xnode);
+
priv->size = rpt_common_get_size (xnode);
priv->rotation = rpt_common_get_rotation (xnode);
priv->border = rpt_common_get_border (xnode);
/*
- * Copyright (C) 2007 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2007-2011 Andrea Zagli <azagli@libero.it>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
if (rpt_obj_line != NULL)
{
+ rpt_object_set_from_xml (RPT_OBJECT (rpt_obj_line), xnode);
+
priv = RPT_OBJ_LINE_GET_PRIVATE (rpt_obj_line);
priv->size = rpt_common_get_size (xnode);
/*
- * Copyright (C) 2007 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2007-2011 Andrea Zagli <azagli@libero.it>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
RptRotation *rotation;
RptStroke *stroke;
+ rpt_object_set_from_xml (RPT_OBJECT (rpt_obj_rect), xnode);
+
priv = RPT_OBJ_RECT_GET_PRIVATE (rpt_obj_rect);
size = rpt_common_get_size (xnode);
{
gchar *prop;
+ rpt_object_set_from_xml (RPT_OBJECT (rpt_obj_text), xnode);
+
priv = RPT_OBJ_TEXT_GET_PRIVATE (rpt_obj_text);
priv->size = rpt_common_get_size (xnode);
static void
rpt_print_page (RptPrint *rpt_print, xmlNode *xnode)
{
+ gchar *prop;
+
RptPrintPrivate *priv = RPT_PRINT_GET_PRIVATE (rpt_print);
xmlNode *cur = xnode->children;
{
if (!xmlNodeIsText (cur))
{
- cairo_save (priv->cr);
- if (g_strcmp0 (cur->name, "text") == 0)
- {
- rpt_print_text_xml (rpt_print, cur);
- }
- else if (g_strcmp0 (cur->name, "line") == 0)
- {
- rpt_print_line_xml (rpt_print, cur);
- }
- else if (g_strcmp0 (cur->name, "rect") == 0)
- {
- rpt_print_rect_xml (rpt_print, cur);
- }
- else if (g_strcmp0 (cur->name, "ellipse") == 0)
+ prop = (gchar *)xmlGetProp (cur, "visible");
+ if (prop != NULL
+ && strcmp (g_strstrip (prop), "y") == 0)
{
- rpt_print_ellipse_xml (rpt_print, cur);
+ cairo_save (priv->cr);
+ if (g_strcmp0 (cur->name, "text") == 0)
+ {
+ rpt_print_text_xml (rpt_print, cur);
+ }
+ else if (g_strcmp0 (cur->name, "line") == 0)
+ {
+ rpt_print_line_xml (rpt_print, cur);
+ }
+ else if (g_strcmp0 (cur->name, "rect") == 0)
+ {
+ rpt_print_rect_xml (rpt_print, cur);
+ }
+ else if (g_strcmp0 (cur->name, "ellipse") == 0)
+ {
+ rpt_print_ellipse_xml (rpt_print, cur);
+ }
+ else if (g_strcmp0 (cur->name, "image") == 0)
+ {
+ rpt_print_image_xml (rpt_print, cur);
+ }
+ cairo_restore (priv->cr);
}
- else if (g_strcmp0 (cur->name, "image") == 0)
+
+ if (prop != NULL)
{
- rpt_print_image_xml (rpt_print, cur);
+ xmlFree (prop);
}
- cairo_restore (priv->cr);
}
cur = cur->next;
rpt_print_set_output_filename (rptp, "test.pdf");
rpt_print_print (rptp, NULL);
}
+ else
+ {
+ g_warning ("Error on creating RptPrint.");
+ }
}
return 0;