[glabels] Added support for elliptical labels and markup



commit 8f71968174b552bd57d342f2deebf58ef8d2ca81
Author: Jim Evins <evins snaught com>
Date:   Wed Feb 3 22:24:36 2010 -0500

    Added support for elliptical labels and markup
    
    Added support for elliptical labels.
    Added support for elliptical markup lines.

 docs/libglabels/tmpl/template.sgml     |    6 +-
 docs/libglabels/tmpl/xml-template.sgml |    2 -
 libglabels/template.c                  |   79 +++++++++++++++++++
 libglabels/template.h                  |   63 +++++++++++++---
 libglabels/xml-template.c              |  129 ++++++++++++++++++++++++++++++++
 src/cairo-label-path.c                 |   49 ++++++++++++
 src/cairo-markup-path.c                |   69 +++++++++++++++++
 templates/glabels-2.3.dtd              |   24 ++++--
 8 files changed, 397 insertions(+), 24 deletions(-)
---
diff --git a/docs/libglabels/tmpl/template.sgml b/docs/libglabels/tmpl/template.sgml
index e7a5887..2b8ef73 100644
--- a/docs/libglabels/tmpl/template.sgml
+++ b/docs/libglabels/tmpl/template.sgml
@@ -26,15 +26,17 @@ of peel-off labels or cards.
 
 @brand: Brand name of label or card.  E.g. "Avery."
 @part: Part name or number of label or card.  E.g. "8160."
+ equiv_part: 
 @description: A description of the template.  E.g. "Mailing labels."
 @paper_id: A paper ID.  E.g. "A4" or "US-Letter."
 @page_width: Page width in points.  Used only if paper_id is "Other."
 @page_height: Page height in points.  Used only if paper_id is "Other."
- aliases: A list of alternate names for this template.  Often a single template can be used for
-multiple products.
+ product_url: 
 @category_ids: A list of category IDs that this template belongs to.
 @frames: A list of (#lglTemplateFrame *) structures.  GLabels currently only supports one frame
 per template -- future versions may support multiple frames per template.
+ aliases: A list of alternate names for this template.  Often a single template can be used for
+multiple products.
 
 <!-- ##### STRUCT lglTemplateAlias ##### -->
 <para>
diff --git a/docs/libglabels/tmpl/xml-template.sgml b/docs/libglabels/tmpl/xml-template.sgml
index 071a08a..3954ff6 100644
--- a/docs/libglabels/tmpl/xml-template.sgml
+++ b/docs/libglabels/tmpl/xml-template.sgml
@@ -25,7 +25,6 @@ template files and document files.
 </para>
 
 @utf8_filename: 
- Returns: 
 
 
 <!-- ##### FUNCTION lgl_xml_template_parse_templates_doc ##### -->
@@ -34,7 +33,6 @@ template files and document files.
 </para>
 
 @templates_doc: 
- Returns: 
 
 
 <!-- ##### FUNCTION lgl_xml_template_parse_template_node ##### -->
diff --git a/libglabels/template.c b/libglabels/template.c
index 3425203..9c1e71f 100644
--- a/libglabels/template.c
+++ b/libglabels/template.c
@@ -410,6 +410,41 @@ lgl_template_frame_rect_new  (const gchar         *id,
 
 
 /**
+ * lgl_template_frame_ellipse_new:
+ *   @id:      ID of frame.  (This should currently always be "0").
+ *   @w:       width of frame in points.
+ *   @h:       height of frame in points.
+ *   @r:       radius of rounded corners in points.  (Should be 0 for square corners.)
+ *   @x_waste: Amount of overprint to allow in the horizontal direction.
+ *   @y_waste: Amount of overprint to allow in the vertical direction.
+ *
+ * This function creates a new template frame for an elliptical label or card.
+ *
+ * Returns: Pointer to newly allocated #lglTemplateFrame structure.
+ *
+ */
+lglTemplateFrame *
+lgl_template_frame_ellipse_new  (const gchar         *id,
+                                 gdouble              w,
+                                 gdouble              h,
+                                 gdouble              waste)
+{
+	lglTemplateFrame *frame;
+
+	frame = g_new0 (lglTemplateFrame, 1);
+
+	frame->shape = LGL_TEMPLATE_FRAME_SHAPE_ELLIPSE;
+	frame->ellipse.id = g_strdup (id);
+
+	frame->ellipse.w = w;
+	frame->ellipse.h = h;
+	frame->ellipse.waste = waste;
+
+	return frame;
+}
+
+
+/**
  * lgl_template_frame_round_new:
  *   @id:      ID of frame.  (This should currently always be "0").
  *   @r:       radius of label in points.
@@ -499,6 +534,10 @@ lgl_template_frame_get_size (const lglTemplateFrame *frame,
 		*w = frame->rect.w;
 		*h = frame->rect.h;
 		break;
+	case LGL_TEMPLATE_FRAME_SHAPE_ELLIPSE:
+		*w = frame->ellipse.w;
+		*h = frame->ellipse.h;
+		break;
 	case LGL_TEMPLATE_FRAME_SHAPE_ROUND:
 		*w = 2.0 * frame->round.r;
 		*h = 2.0 * frame->round.r;
@@ -790,6 +829,38 @@ lgl_template_markup_rect_new (gdouble x1,
 
 
 /**
+ * lgl_template_markup_ellipse_new:
+ *   @x1: x coordinate of top-left corner of ellipse.
+ *   @y1: y coordinate of top-left corner of ellipse.
+ *   @w:  width of ellipse.
+ *   @h:  height of ellipse.
+ *
+ * This function creates a new ellipse markup structure.
+ *
+ * Returns: a newly allocated #lglTemplateMarkup structure.
+ *
+ */
+lglTemplateMarkup *
+lgl_template_markup_ellipse_new (gdouble x1,
+                                 gdouble y1,
+                                 gdouble w,
+                                 gdouble h)
+{
+	lglTemplateMarkup *markup;
+
+	markup = g_new0 (lglTemplateMarkup, 1);
+
+	markup->type        = LGL_TEMPLATE_MARKUP_ELLIPSE;
+	markup->ellipse.x1     = x1;
+	markup->ellipse.y1     = y1;
+	markup->ellipse.w      = w;
+	markup->ellipse.h      = h;
+
+	return markup;
+}
+
+
+/**
  * lgl_template_dup:
  *   @orig_template: Template to duplicate.
  *
@@ -981,6 +1052,14 @@ lgl_template_frame_dup (const lglTemplateFrame *orig_frame)
                                                      orig_frame->rect.y_waste);
 		break;
 
+	case LGL_TEMPLATE_FRAME_SHAPE_ELLIPSE:
+		frame =
+			lgl_template_frame_ellipse_new (orig_frame->all.id,
+                                                        orig_frame->ellipse.w,
+                                                        orig_frame->ellipse.h,
+                                                        orig_frame->ellipse.waste);
+		break;
+
 	case LGL_TEMPLATE_FRAME_SHAPE_ROUND:
 		frame =
 			lgl_template_frame_round_new (orig_frame->all.id,
diff --git a/libglabels/template.h b/libglabels/template.h
index 5793ea6..6adfa83 100644
--- a/libglabels/template.h
+++ b/libglabels/template.h
@@ -32,6 +32,7 @@ typedef struct _lglTemplateAlias           lglTemplateAlias;
 typedef union  _lglTemplateFrame           lglTemplateFrame;
 typedef struct _lglTemplateFrameAll        lglTemplateFrameAll;
 typedef struct _lglTemplateFrameRect       lglTemplateFrameRect;
+typedef struct _lglTemplateFrameEllipse    lglTemplateFrameEllipse;
 typedef struct _lglTemplateFrameRound      lglTemplateFrameRound;
 typedef struct _lglTemplateFrameCD         lglTemplateFrameCD;
 
@@ -42,6 +43,7 @@ typedef struct _lglTemplateMarkupMargin    lglTemplateMarkupMargin;
 typedef struct _lglTemplateMarkupLine      lglTemplateMarkupLine;
 typedef struct _lglTemplateMarkupCircle    lglTemplateMarkupCircle;
 typedef struct _lglTemplateMarkupRect      lglTemplateMarkupRect;
+typedef struct _lglTemplateMarkupEllipse   lglTemplateMarkupEllipse;
 
 typedef struct _lglTemplateOrigin          lglTemplateOrigin;
 
@@ -89,6 +91,7 @@ struct _lglTemplateAlias {
  */
 typedef enum {
 	LGL_TEMPLATE_FRAME_SHAPE_RECT,
+	LGL_TEMPLATE_FRAME_SHAPE_ELLIPSE,
 	LGL_TEMPLATE_FRAME_SHAPE_ROUND,
 	LGL_TEMPLATE_FRAME_SHAPE_CD,
 } lglTemplateFrameShape;
@@ -125,6 +128,21 @@ struct _lglTemplateFrameRect {
         gdouble               y_waste;  /* Amount of vert overprint allowed. */
 };
 
+struct _lglTemplateFrameEllipse {
+
+        /* Begin Common Fields */
+	lglTemplateFrameShape shape;    /* Always LGL_TEMPLATE_FRAME_SHAPE_ELLIPSE. */
+
+	gchar                *id;       /* Id, currently always "0" */
+	GList                *layouts;  /* List of lglTemplateLayouts */
+	GList                *markups;  /* List of lglTemplateMarkups */
+        /* End Common Fields */
+
+        gdouble               w;        /* Width */
+        gdouble               h;        /* Height */
+        gdouble               waste;    /* Amount of overprint allowed. */
+};
+
 struct _lglTemplateFrameRound {
 
         /* Begin Common Fields */
@@ -158,12 +176,13 @@ struct _lglTemplateFrameCD {
 
 union _lglTemplateFrame{
 
-	lglTemplateFrameShape shape;
+	lglTemplateFrameShape   shape;
 
-	lglTemplateFrameAll   all;
-	lglTemplateFrameRect  rect;
-	lglTemplateFrameRound round;
-	lglTemplateFrameCD    cd;
+	lglTemplateFrameAll     all;
+	lglTemplateFrameRect    rect;
+	lglTemplateFrameEllipse ellipse;
+	lglTemplateFrameRound   round;
+	lglTemplateFrameCD      cd;
 };
 
 
@@ -192,6 +211,7 @@ typedef enum {
 	LGL_TEMPLATE_MARKUP_LINE,
 	LGL_TEMPLATE_MARKUP_CIRCLE,
 	LGL_TEMPLATE_MARKUP_RECT,
+	LGL_TEMPLATE_MARKUP_ELLIPSE,
 } lglTemplateMarkupType;
 
 
@@ -230,14 +250,23 @@ struct _lglTemplateMarkupRect {
         gdouble                r;      /* Radius of corners. */
 };
 
+struct _lglTemplateMarkupEllipse {
+
+	lglTemplateMarkupType  type;   /* Always LGL_TEMPLATE_MARKUP_ELLIPSE */
+
+        gdouble                x1, y1; /* Upper left corner */
+        gdouble                w, h;   /* Width and height. */
+};
+
 union _lglTemplateMarkup {
 
-	lglTemplateMarkupType   type;
+	lglTemplateMarkupType    type;
 
-	lglTemplateMarkupMargin margin;
-	lglTemplateMarkupLine   line;
-	lglTemplateMarkupCircle circle;
-	lglTemplateMarkupRect   rect;
+	lglTemplateMarkupMargin  margin;
+	lglTemplateMarkupLine    line;
+	lglTemplateMarkupCircle  circle;
+	lglTemplateMarkupRect    rect;
+	lglTemplateMarkupEllipse ellipse;
 };
 
 
@@ -306,6 +335,9 @@ void                 lgl_template_add_category         (lglTemplate          *te
 void                 lgl_template_add_frame            (lglTemplate          *template,
                                                         lglTemplateFrame     *frame);
 
+lglTemplateAlias    *lgl_template_alias_new            (const gchar          *brand,
+                                                        const gchar          *part);
+
 lglTemplateFrame    *lgl_template_frame_rect_new       (const gchar          *id,
                                                         gdouble               w,
                                                         gdouble               h,
@@ -313,8 +345,10 @@ lglTemplateFrame    *lgl_template_frame_rect_new       (const gchar          *id
                                                         gdouble               x_waste,
                                                         gdouble               y_waste);
 
-lglTemplateAlias    *lgl_template_alias_new            (const gchar          *brand,
-                                                        const gchar          *part);
+lglTemplateFrame    *lgl_template_frame_ellipse_new    (const gchar          *id,
+                                                        gdouble               w,
+                                                        gdouble               h,
+                                                        gdouble               waste);
 
 lglTemplateFrame    *lgl_template_frame_round_new      (const gchar          *id,
                                                         gdouble               r,
@@ -357,6 +391,11 @@ lglTemplateMarkup   *lgl_template_markup_rect_new      (gdouble               x1
                                                         gdouble               h,
                                                         gdouble               r);
 
+lglTemplateMarkup   *lgl_template_markup_ellipse_new   (gdouble               x1,
+                                                        gdouble               y1,
+                                                        gdouble               w,
+                                                        gdouble               h);
+
 lglTemplate         *lgl_template_dup                  (const lglTemplate    *orig_template);
 
 void                 lgl_template_free                 (lglTemplate          *template);
diff --git a/libglabels/xml-template.c b/libglabels/xml-template.c
index c33cc58..a6f10a4 100644
--- a/libglabels/xml-template.c
+++ b/libglabels/xml-template.c
@@ -47,6 +47,8 @@ static void  xml_parse_meta_node            (xmlNodePtr              label_node,
 					     lglTemplate            *template);
 static void  xml_parse_label_rectangle_node (xmlNodePtr              label_node,
 					     lglTemplate            *template);
+static void  xml_parse_label_ellipse_node   (xmlNodePtr              label_node,
+					     lglTemplate            *template);
 static void  xml_parse_label_round_node     (xmlNodePtr              label_node,
 					     lglTemplate            *template);
 static void  xml_parse_label_cd_node        (xmlNodePtr              label_node,
@@ -61,6 +63,8 @@ static void  xml_parse_markup_circle_node   (xmlNodePtr              markup_node
 					     lglTemplateFrame       *frame);
 static void  xml_parse_markup_rect_node     (xmlNodePtr              markup_node,
 					     lglTemplateFrame       *frame);
+static void  xml_parse_markup_ellipse_node  (xmlNodePtr              markup_node,
+					     lglTemplateFrame       *frame);
 static void  xml_parse_alias_node           (xmlNodePtr              alias_node,
 					     lglTemplate            *template);
 
@@ -86,6 +90,9 @@ static void  xml_create_markup_circle_node  (const lglTemplateMarkup      *circl
 static void  xml_create_markup_rect_node    (const lglTemplateMarkup      *circle,
 					     xmlNodePtr                    root,
 					     const xmlNsPtr                ns);
+static void  xml_create_markup_ellipse_node (const lglTemplateMarkup      *circle,
+					     xmlNodePtr                    root,
+					     const xmlNsPtr                ns);
 static void  xml_create_alias_node          (const lglTemplateAlias       *alias,
 					     xmlNodePtr                    root,
 					     const xmlNsPtr                ns);
@@ -280,6 +287,8 @@ lgl_xml_template_parse_template_node (const xmlNodePtr template_node)
 			xml_parse_meta_node (node, template);
 		} else if (lgl_xml_is_node (node, "Label-rectangle")) {
 			xml_parse_label_rectangle_node (node, template);
+		} else if (lgl_xml_is_node (node, "Label-ellipse")) {
+			xml_parse_label_ellipse_node (node, template);
 		} else if (lgl_xml_is_node (node, "Label-round")) {
 			xml_parse_label_round_node (node, template);
 		} else if (lgl_xml_is_node (node, "Label-cd")) {
@@ -329,6 +338,7 @@ xml_parse_meta_node (xmlNodePtr   meta_node,
 	}
 }
 
+
 /*--------------------------------------------------------------------------*/
 /* PRIVATE.  Parse XML Template->Label-rectangle Node.                      */
 /*--------------------------------------------------------------------------*/
@@ -373,6 +383,56 @@ xml_parse_label_rectangle_node (xmlNodePtr   label_node,
 			xml_parse_markup_circle_node (node, frame);
 		} else if (lgl_xml_is_node (node, "Markup-rect")) {
 			xml_parse_markup_rect_node (node, frame);
+		} else if (lgl_xml_is_node (node, "Markup-ellipse")) {
+			xml_parse_markup_ellipse_node (node, frame);
+		} else if (!xmlNodeIsText (node)) {
+			if (!lgl_xml_is_node (node, "comment")) {
+				g_message ("bad node =  \"%s\"",node->name);
+			}
+		}
+	}
+
+	g_free (id);
+}
+
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  Parse XML Template->Label-ellipse Node.                        */
+/*--------------------------------------------------------------------------*/
+static void
+xml_parse_label_ellipse_node (xmlNodePtr   label_node,
+                              lglTemplate *template)
+{
+	gchar               *id;
+	gchar               *tmp;
+	gdouble              waste;
+	gdouble              w, h;
+	lglTemplateFrame    *frame;
+	xmlNodePtr           node;
+
+	id      = lgl_xml_get_prop_string (label_node, "id", NULL);
+
+	w       = lgl_xml_get_prop_length (label_node, "width", 0);
+	h       = lgl_xml_get_prop_length (label_node, "height", 0);
+        waste   = lgl_xml_get_prop_length (label_node, "waste", 0);
+
+	frame = lgl_template_frame_ellipse_new ((gchar *)id, w, h, waste);
+	lgl_template_add_frame (template, frame);
+
+	for (node = label_node->xmlChildrenNode; node != NULL;
+	     node = node->next) {
+		if (lgl_xml_is_node (node, "Layout")) {
+			xml_parse_layout_node (node, frame);
+		} else if (lgl_xml_is_node (node, "Markup-margin")) {
+			xml_parse_markup_margin_node (node, frame);
+		} else if (lgl_xml_is_node (node, "Markup-line")) {
+			xml_parse_markup_line_node (node, frame);
+		} else if (lgl_xml_is_node (node, "Markup-circle")) {
+			xml_parse_markup_circle_node (node, frame);
+		} else if (lgl_xml_is_node (node, "Markup-rect")) {
+			xml_parse_markup_rect_node (node, frame);
+		} else if (lgl_xml_is_node (node, "Markup-ellipse")) {
+			xml_parse_markup_ellipse_node (node, frame);
 		} else if (!xmlNodeIsText (node)) {
 			if (!lgl_xml_is_node (node, "comment")) {
 				g_message ("bad node =  \"%s\"",node->name);
@@ -383,6 +443,7 @@ xml_parse_label_rectangle_node (xmlNodePtr   label_node,
 	g_free (id);
 }
 
+
 /*--------------------------------------------------------------------------*/
 /* PRIVATE.  Parse XML Template->Label-round Node.                          */
 /*--------------------------------------------------------------------------*/
@@ -415,6 +476,8 @@ xml_parse_label_round_node (xmlNodePtr   label_node,
 			xml_parse_markup_circle_node (node, frame);
 		} else if (lgl_xml_is_node (node, "Markup-rect")) {
 			xml_parse_markup_rect_node (node, frame);
+		} else if (lgl_xml_is_node (node, "Markup-ellipse")) {
+			xml_parse_markup_ellipse_node (node, frame);
 		} else if (!xmlNodeIsText (node)) {
 			if (!lgl_xml_is_node (node, "comment")) {
 				g_message ("bad node =  \"%s\"",node->name);
@@ -460,6 +523,8 @@ xml_parse_label_cd_node (xmlNodePtr   label_node,
 			xml_parse_markup_circle_node (node, frame);
 		} else if (lgl_xml_is_node (node, "Markup-rect")) {
 			xml_parse_markup_rect_node (node, frame);
+		} else if (lgl_xml_is_node (node, "Markup-ellipse")) {
+			xml_parse_markup_ellipse_node (node, frame);
 		} else if (!xmlNodeIsText (node)) {
 			if (!lgl_xml_is_node (node, "comment")) {
 				g_message ("bad node =  \"%s\"",node->name);
@@ -583,6 +648,7 @@ xml_parse_markup_circle_node (xmlNodePtr          markup_node,
 
 }
 
+
 /*--------------------------------------------------------------------------*/
 /* PRIVATE.  Parse XML Template->Label->Markup-rect Node.                   */
 /*--------------------------------------------------------------------------*/
@@ -612,6 +678,36 @@ xml_parse_markup_rect_node (xmlNodePtr          markup_node,
 
 }
 
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  Parse XML Template->Label->Markup-ellipse Node.                */
+/*--------------------------------------------------------------------------*/
+static void
+xml_parse_markup_ellipse_node (xmlNodePtr          markup_node,
+                               lglTemplateFrame   *frame)
+{
+	gdouble     x1, y1, w, h, r;
+	xmlNodePtr  node;
+
+	x1 = lgl_xml_get_prop_length (markup_node, "x1", 0);
+	y1 = lgl_xml_get_prop_length (markup_node, "y1", 0);
+	w  = lgl_xml_get_prop_length (markup_node, "w", 0);
+	h  = lgl_xml_get_prop_length (markup_node, "h", 0);
+
+	lgl_template_frame_add_markup (frame, lgl_template_markup_ellipse_new (x1, y1, w, h));
+
+	for (node = markup_node->xmlChildrenNode; node != NULL;
+	     node = node->next) {
+		if (!xmlNodeIsText (node)) {
+			if (!lgl_xml_is_node (node, "comment")) {
+				g_message ("bad node =  \"%s\"",node->name);
+			}
+		}
+	}
+
+}
+
+
 /*--------------------------------------------------------------------------*/
 /* PRIVATE.  Parse XML Template->Alias Node.                                */
 /*--------------------------------------------------------------------------*/
@@ -828,6 +924,14 @@ xml_create_label_node (const lglTemplateFrame  *frame,
 		lgl_xml_set_prop_length (node, "y_waste", frame->rect.y_waste);
 		break;
 
+	case LGL_TEMPLATE_FRAME_SHAPE_ELLIPSE:
+		node = xmlNewChild(root, ns, (xmlChar *)"Label-ellipse", NULL);
+		lgl_xml_set_prop_string (node, "id",     frame->all.id);
+		lgl_xml_set_prop_length (node, "width",  frame->ellipse.w);
+		lgl_xml_set_prop_length (node, "height", frame->ellipse.h);
+		lgl_xml_set_prop_length (node, "waste",  frame->ellipse.waste);
+		break;
+
 	case LGL_TEMPLATE_FRAME_SHAPE_ROUND:
 		node = xmlNewChild(root, ns, (xmlChar *)"Label-round", NULL);
 		lgl_xml_set_prop_string (node, "id",      frame->all.id);
@@ -871,6 +975,9 @@ xml_create_label_node (const lglTemplateFrame  *frame,
 		case LGL_TEMPLATE_MARKUP_RECT:
 			xml_create_markup_rect_node (markup, node, ns);
 			break;
+		case LGL_TEMPLATE_MARKUP_ELLIPSE:
+			xml_create_markup_ellipse_node (markup, node, ns);
+			break;
 		default:
 			g_message ("Unknown markup type");
 			break;
@@ -957,6 +1064,7 @@ xml_create_markup_circle_node (const lglTemplateMarkup *markup,
 
 }
 
+
 /*--------------------------------------------------------------------------*/
 /* PRIVATE.  Add XML Template->Label->Markup-rect Node.                     */
 /*--------------------------------------------------------------------------*/
@@ -977,6 +1085,27 @@ xml_create_markup_rect_node (const lglTemplateMarkup *markup,
 
 }
 
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  Add XML Template->Label->Markup-ellipse Node.                  */
+/*--------------------------------------------------------------------------*/
+static void
+xml_create_markup_ellipse_node (const lglTemplateMarkup *markup,
+                                xmlNodePtr               root,
+                                const xmlNsPtr           ns)
+{
+	xmlNodePtr  node;
+
+	node = xmlNewChild(root, ns, (xmlChar *)"Markup-ellipse", NULL);
+
+	lgl_xml_set_prop_length (node, "x1", markup->ellipse.x1);
+	lgl_xml_set_prop_length (node, "y1", markup->ellipse.y1);
+	lgl_xml_set_prop_length (node, "w",  markup->ellipse.w);
+	lgl_xml_set_prop_length (node, "h",  markup->ellipse.h);
+
+}
+
+
 /*--------------------------------------------------------------------------*/
 /* PRIVATE.  Add XML Template->Alias Node.                                  */
 /*--------------------------------------------------------------------------*/
diff --git a/src/cairo-label-path.c b/src/cairo-label-path.c
index 3596476..0c8de52 100644
--- a/src/cairo-label-path.c
+++ b/src/cairo-label-path.c
@@ -45,6 +45,10 @@ static void gl_cairo_rect_label_path             (cairo_t                *cr,
                                                   const lglTemplate      *template,
                                                   gboolean                rotate_flag,
                                                   gboolean                waste_flag);
+static void gl_cairo_ellipse_label_path          (cairo_t                *cr,
+                                                  const lglTemplate      *template,
+                                                  gboolean                rotate_flag,
+                                                  gboolean                waste_flag);
 static void gl_cairo_round_label_path            (cairo_t                *cr,
                                                   const lglTemplate      *template,
                                                   gboolean                rotate_flag,
@@ -76,6 +80,10 @@ gl_cairo_label_path (cairo_t           *cr,
                 gl_cairo_rect_label_path (cr, template, rotate_flag, waste_flag);
                 break;
 
+        case LGL_TEMPLATE_FRAME_SHAPE_ELLIPSE:
+                gl_cairo_ellipse_label_path (cr, template, rotate_flag, waste_flag);
+                break;
+
         case LGL_TEMPLATE_FRAME_SHAPE_ROUND:
                 gl_cairo_round_label_path (cr, template, rotate_flag, waste_flag);
                 break;
@@ -153,6 +161,47 @@ gl_cairo_rect_label_path (cairo_t           *cr,
 
 
 /*--------------------------------------------------------------------------*/
+/* Create elliptical label path                                             */
+/*--------------------------------------------------------------------------*/
+static void
+gl_cairo_ellipse_label_path (cairo_t           *cr,
+                             const lglTemplate *template,
+                             gboolean           rotate_flag,
+                             gboolean           waste_flag)
+{
+        const lglTemplateFrame *frame;
+        gdouble                 w, h;
+        gdouble                 waste;
+
+        gl_debug (DEBUG_PATH, "START");
+
+        frame = (lglTemplateFrame *)template->frames->data;
+
+        if (rotate_flag)
+        {
+                lgl_template_frame_get_size (frame, &h, &w);
+        }
+        else
+        {
+                lgl_template_frame_get_size (frame, &w, &h);
+        }
+
+        waste = 0.0;
+        if (waste_flag)
+        {
+                waste = frame->ellipse.waste;
+        }
+
+        cairo_save (cr);
+        cairo_translate (cr, -waste, -waste);
+        gl_cairo_ellipse_path (cr, (w+waste)/2.0, (h+waste)/2.0);
+        cairo_restore (cr);
+
+        gl_debug (DEBUG_PATH, "END");
+}
+
+
+/*--------------------------------------------------------------------------*/
 /* Create round label path                                                  */
 /*--------------------------------------------------------------------------*/
 static void
diff --git a/src/cairo-markup-path.c b/src/cairo-markup-path.c
index 2785c01..78e8a6d 100644
--- a/src/cairo-markup-path.c
+++ b/src/cairo-markup-path.c
@@ -49,6 +49,10 @@ static void       gl_cairo_markup_margin_rect_path    (cairo_t                 *
                                                        const lglTemplateMarkup *markup,
                                                        glLabel                 *label);
 
+static void       gl_cairo_markup_margin_ellipse_path (cairo_t                 *cr,
+                                                       const lglTemplateMarkup *markup,
+                                                       glLabel                 *label);
+
 static void       gl_cairo_markup_margin_round_path   (cairo_t                 *cr,
                                                        const lglTemplateMarkup *markup,
                                                        glLabel                 *label);
@@ -66,6 +70,9 @@ static void       gl_cairo_markup_circle_path         (cairo_t                 *
 static void       gl_cairo_markup_rect_path           (cairo_t                 *cr,
                                                        const lglTemplateMarkup *markup);
 
+static void       gl_cairo_markup_ellipse_path        (cairo_t                 *cr,
+                                                       const lglTemplateMarkup *markup);
+
 
 /*--------------------------------------------------------------------------*/
 /* Create markup path                                                       */
@@ -90,6 +97,9 @@ gl_cairo_markup_path (cairo_t                 *cr,
         case LGL_TEMPLATE_MARKUP_RECT:
                 gl_cairo_markup_rect_path (cr, markup);
                 break;
+        case LGL_TEMPLATE_MARKUP_ELLIPSE:
+                gl_cairo_markup_ellipse_path (cr, markup);
+                break;
         default:
                 g_message ("Unknown template markup type");
                 break;
@@ -121,6 +131,10 @@ gl_cairo_markup_margin_path (cairo_t                *cr,
                 gl_cairo_markup_margin_rect_path (cr, markup, label);
                 break;
 
+        case LGL_TEMPLATE_FRAME_SHAPE_ELLIPSE:
+                gl_cairo_markup_margin_ellipse_path (cr, markup, label);
+                break;
+
         case LGL_TEMPLATE_FRAME_SHAPE_ROUND:
                 gl_cairo_markup_margin_round_path (cr, markup, label);
                 break;
@@ -181,6 +195,38 @@ gl_cairo_markup_margin_rect_path (cairo_t                 *cr,
 
 
 /*---------------------------------------------------------------------------*/
+/* PRIVATE.  Draw elliptical margin.                                         */
+/*---------------------------------------------------------------------------*/
+static void
+gl_cairo_markup_margin_ellipse_path (cairo_t                 *cr,
+                                     const lglTemplateMarkup *markup,
+                                     glLabel                 *label)
+{
+        const lglTemplate      *template;
+        const lglTemplateFrame *frame;
+        gdouble                 w, h, r, m;
+
+        gl_debug (DEBUG_PATH, "START");
+
+        template = gl_label_get_template (label);
+        frame = (lglTemplateFrame *)template->frames->data;
+
+        m = markup->margin.size;
+
+        lgl_template_frame_get_size (frame, &w, &h);
+	w = w - 2*m;
+	h = h - 2*m;
+
+        cairo_save (cr);
+        cairo_translate (cr, m, m);
+        gl_cairo_ellipse_path (cr, w/2.0, h/2.0);
+        cairo_restore (cr);
+
+        gl_debug (DEBUG_PATH, "END");
+}
+
+
+/*---------------------------------------------------------------------------*/
 /* PRIVATE.  Draw round margin.                                              */
 /*---------------------------------------------------------------------------*/
 static void
@@ -327,6 +373,29 @@ gl_cairo_markup_rect_path (cairo_t                 *cr,
 }
 
 
+/*---------------------------------------------------------------------------*/
+/* PRIVATE.  Draw ellipse markup.                                            */
+/*---------------------------------------------------------------------------*/
+static void
+gl_cairo_markup_ellipse_path (cairo_t                 *cr,
+                              const lglTemplateMarkup *markup)
+{
+        gdouble x1 = markup->ellipse.x1;
+        gdouble y1 = markup->ellipse.y1;
+        gdouble w  = markup->ellipse.w;
+        gdouble h  = markup->ellipse.h;
+
+	gl_debug (DEBUG_PATH, "START");
+
+        cairo_save (cr);
+        cairo_translate (cr, x1, y1);
+        gl_cairo_ellipse_path (cr, w/2.0, h/2.0);
+        cairo_restore (cr);
+
+	gl_debug (DEBUG_PATH, "END");
+}
+
+
 
 /*
  * Local Variables:       -- emacs
diff --git a/templates/glabels-2.3.dtd b/templates/glabels-2.3.dtd
index c788c33..56cf274 100644
--- a/templates/glabels-2.3.dtd
+++ b/templates/glabels-2.3.dtd
@@ -75,7 +75,7 @@
                                 CBR        |
                                 MSI        |
                                 PLS        |
-				IEC16022)"
+                                IEC16022)"
                                -->
 
 <!-- Data encoding method -->
@@ -166,7 +166,7 @@
 <!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
 <!-- Template Section                                                     -->
 <!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
-<!ENTITY % label_element  "Label-rectangle | Label-round | Label-cd">
+<!ENTITY % label_element  "Label-rectangle | Label-round | Label-ellipse | Label-cd">
 <!ENTITY % markup_element "Markup-margin | Markup-line | Markup-circle | Markup-rect">
 
 <!ELEMENT Template (Meta*, (%label_element;)*, Alias*)>
@@ -174,7 +174,7 @@
                  brand           %STRING_TYPE;           #REQUIRED
                  part            %STRING_TYPE;           #REQUIRED
                  name            %STRING_TYPE;           #IMPLIED
-	         equiv           %STRING_TYPE;           #IMPLIED
+                 equiv           %STRING_TYPE;           #IMPLIED
                  size            %STRING_TYPE;           #IMPLIED
                  width           %LENGTH_TYPE;           #IMPLIED
                  height          %LENGTH_TYPE;           #IMPLIED
@@ -206,6 +206,14 @@
                  waste           %LENGTH_TYPE;           #IMPLIED
 >
 
+<!ELEMENT Label-ellipse ((%markup_element;)*, Layout+)>
+<!ATTLIST Label-ellipse
+                 id              %STRING_TYPE;           #REQUIRED
+                 width           %LENGTH_TYPE;           #REQUIRED
+                 height          %LENGTH_TYPE;           #REQUIRED
+                 waste           %LENGTH_TYPE;           #IMPLIED
+>
+
 <!ELEMENT Label-cd ((%markup_element;)*, Layout+)>
 <!ATTLIST Label-cd
                  id              %STRING_TYPE;           #REQUIRED
@@ -311,10 +319,10 @@
 
 <!ENTITY % shadow_attrs
                  "shadow          %BOOLEAN_TYPE;         #IMPLIED
-		  shadow_x        %FLOAT_TYPE;           #IMPLIED
-		  shadow_y        %FLOAT_TYPE;           #IMPLIED
-		  shadow_color    %UINT_TYPE;            #IMPLIED
-		  shadow_opacity  %FLOAT_TYPE;           #IMPLIED"
+                  shadow_x        %FLOAT_TYPE;           #IMPLIED
+                  shadow_y        %FLOAT_TYPE;           #IMPLIED
+                  shadow_color    %UINT_TYPE;            #IMPLIED
+                  shadow_opacity  %FLOAT_TYPE;           #IMPLIED"
 >
 
 <!ELEMENT Object-text (Span)>
@@ -422,7 +430,7 @@
                  font_weight     %FONT_WEIGHT_TYPE;      #IMPLIED
                  font_italic     %BOOLEAN_TYPE;          #IMPLIED
                  color           %UINT_TYPE;             #IMPLIED
-				 color_field     %STRING_TYPE;           #IMPLIED
+                 color_field     %STRING_TYPE;           #IMPLIED
                  line_spacing    %LENGTH_TYPE;           #IMPLIED
 >
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]