static void xml_add_markup_margin (glTemplateMarkupMargin *margin,
xmlNodePtr root,
xmlNsPtr ns);
+static void xml_add_markup_line (glTemplateMarkupLine *line,
+ xmlNodePtr root,
+ xmlNsPtr ns);
static void xml_add_alias (gchar *name,
xmlNodePtr root,
xmlNsPtr ns);
static void layout_free (glTemplateLayout **layout);
static glTemplateMarkup *markup_margin_new (gdouble size);
+static glTemplateMarkup *markup_line_new (gdouble x1,
+ gdouble y1,
+ gdouble x2,
+ gdouble y2);
static glTemplateMarkup *markup_dup (glTemplateMarkup *orig_markup);
static void markup_free (glTemplateMarkup **markup);
{
gchar *type;
gdouble size;
+ gdouble x1, y1, x2, y2;
xmlNodePtr node;
gl_debug (DEBUG_TEMPLATE, "START");
template->label.any.markups =
g_list_append (template->label.any.markups,
markup_margin_new (size));
+ } else if (g_strcasecmp (type, "line") == 0) {
+ x1 = g_strtod (xmlGetProp (markup_node, "x1"), NULL);
+ y1 = g_strtod (xmlGetProp (markup_node, "y1"), NULL);
+ x2 = g_strtod (xmlGetProp (markup_node, "x2"), NULL);
+ y2 = g_strtod (xmlGetProp (markup_node, "y2"), NULL);
+ template->label.any.markups =
+ g_list_append (template->label.any.markups,
+ markup_line_new (x1, y1, x2, y2));
}
for (node = markup_node->xmlChildrenNode; node != NULL;
xml_add_markup_margin ((glTemplateMarkupMargin *)markup,
node, ns);
break;
+ case GL_TEMPLATE_MARKUP_LINE:
+ xml_add_markup_line ((glTemplateMarkupLine *)markup,
+ node, ns);
+ break;
default:
g_warning ("Unknown markup type");
break;
}
/*--------------------------------------------------------------------------*/
-/* PRIVATE. Add XML Sheet->Label->Markup Node. */
+/* PRIVATE. Add XML Sheet->Label->Markup (margin) Node. */
/*--------------------------------------------------------------------------*/
static void
xml_add_markup_margin (glTemplateMarkupMargin *margin,
gl_debug (DEBUG_TEMPLATE, "END");
}
+/*--------------------------------------------------------------------------*/
+/* PRIVATE. Add XML Sheet->Label->Markup (line) Node. */
+/*--------------------------------------------------------------------------*/
+static void
+xml_add_markup_line (glTemplateMarkupLine *line,
+ xmlNodePtr root,
+ xmlNsPtr ns)
+{
+ xmlNodePtr node;
+ gchar *string;
+
+ gl_debug (DEBUG_TEMPLATE, "START");
+
+ node = xmlNewChild(root, ns, "Markup", NULL);
+ xmlSetProp (node, "type", "line");
+
+ string = g_strdup_printf ("%g", line->x1);
+ xmlSetProp (node, "x1", string);
+ g_free (string);
+ string = g_strdup_printf ("%g", line->y1);
+ xmlSetProp (node, "y1", string);
+ g_free (string);
+ string = g_strdup_printf ("%g", line->x2);
+ xmlSetProp (node, "x2", string);
+ g_free (string);
+ string = g_strdup_printf ("%g", line->y2);
+ xmlSetProp (node, "y2", string);
+ g_free (string);
+
+ gl_debug (DEBUG_TEMPLATE, "END");
+}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Add XML Sheet->Alias Node. */
/*--------------------------------------------------------------------------*/
return markup;
}
+/*--------------------------------------------------------------------------*/
+/* PRIVATE. Create new margin line structure. */
+/*--------------------------------------------------------------------------*/
+static glTemplateMarkup *
+markup_line_new (gdouble x1,
+ gdouble y1,
+ gdouble x2,
+ gdouble y2)
+{
+ glTemplateMarkup *markup;
+
+ markup = g_new0 (glTemplateMarkup, 1);
+
+ markup->type = GL_TEMPLATE_MARKUP_LINE;
+ markup->line.x1 = x1;
+ markup->line.y1 = y1;
+ markup->line.x2 = x2;
+ markup->line.y2 = y2;
+
+ return markup;
+}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Duplicate markup structure. */
/*--------------------------------------------------------------------------*/
static void draw_markup_margin_cd (glView *view,
glTemplateMarkupMargin *margin);
+static void draw_markup_line (glView *view,
+ glTemplateMarkupLine *line);
+
static void select_object_real (glView *view,
glViewObject *view_object);
draw_markup_margin (view,
(glTemplateMarkupMargin *)markup);
break;
+ case GL_TEMPLATE_MARKUP_LINE:
+ draw_markup_line (view,
+ (glTemplateMarkupLine *)markup);
+ break;
default:
g_warning ("Unknown template markup type");
break;
gl_debug (DEBUG_VIEW, "END");
}
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Draw line markup. */
+/*---------------------------------------------------------------------------*/
+static void
+draw_markup_line (glView *view,
+ glTemplateMarkupLine *line)
+{
+ GnomeCanvasPoints *points;
+
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (GL_IS_VIEW (view));
+
+ points = gnome_canvas_points_new (2);
+ points->coords[0] = line->x1;
+ points->coords[1] = line->y1;
+ points->coords[2] = line->x2;
+ points->coords[3] = line->y2;
+
+ /* Bounding box @ margin */
+ gnome_canvas_item_new (view->markup_group,
+ gnome_canvas_line_get_type (),
+ "points", points,
+ "width_pixels", 1,
+ "fill_color_rgba", MARKUP_COLOR,
+ NULL);
+
+ gnome_canvas_points_free (points);
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
/*****************************************************************************/
/* Raise foreground items to top. */
/*****************************************************************************/