]> git.sur5r.net Git - glabels/commitdiff
Added support for elliptical labels and markup
authorJim Evins <evins@snaught.com>
Thu, 4 Feb 2010 03:24:36 +0000 (22:24 -0500)
committerJim Evins <evins@snaught.com>
Thu, 4 Feb 2010 03:24:36 +0000 (22:24 -0500)
Added support for elliptical labels.
Added support for elliptical markup lines.

docs/libglabels/tmpl/template.sgml
docs/libglabels/tmpl/xml-template.sgml
libglabels/template.c
libglabels/template.h
libglabels/xml-template.c
src/cairo-label-path.c
src/cairo-markup-path.c
templates/glabels-2.3.dtd

index e7a58879a76688eaebdd97e5c8ca8e2d51346a43..2b8ef732a039b47997146fa8a1042bdaf5dd58dc 100644 (file)
@@ -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>
index 071a08ab18b40954ee27a23fc066d925752d245f..3954ff6e298db859cfed822bfb6ba8d71ee6765e 100644 (file)
@@ -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 ##### -->
index 34252031963f2b831cc36670ac77f8ba0f7debcc..9c1e71f2b0200ddba5fc230e44890e29ad07ed95 100644 (file)
@@ -409,6 +409,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").
@@ -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;
@@ -789,6 +828,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,
index 5793ea6ca7f7a9b34f24d41051ba7a89e9e4786e..6adfa83e2a3c47386bfd0db9794376a54e6a73a8 100644 (file)
@@ -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);
index c33cc58371c685eb9ff75915ba30b64ffd5f755e..a6f10a45a83af3514256a8961bb90103f4c9e9b3 100644 (file)
@@ -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.                                  */
 /*--------------------------------------------------------------------------*/
index 35964763448a2d5e8646bef30573d2bc249cb606..0c8de525fcddd523514edacc78971847ffb926db 100644 (file)
@@ -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;
@@ -152,6 +160,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                                                  */
 /*--------------------------------------------------------------------------*/
index 2785c01c4ff028dc6891dafec2a1ccc0048bfb69..78e8a6d04503bd634b33246263031e547cb01685 100644 (file)
@@ -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;
@@ -180,6 +194,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.                                              */
 /*---------------------------------------------------------------------------*/
@@ -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
index c788c33e68de5d1003482428007bb1e2ad4fe2dc..56cf2742b20fad6e5b45b8b707826e395dbbec20 100644 (file)
@@ -75,7 +75,7 @@
                                 CBR        |
                                 MSI        |
                                 PLS        |
-                               IEC16022)"
+                                IEC16022)"
                                -->
 
 <!-- Data encoding method -->
 <!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
 <!-- 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*)>
                  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
                  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
 
 <!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)>
                  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
 >