]> git.sur5r.net Git - glabels/commitdiff
Added support for Markup-circle in templates.
authorJim Evins <evins@snaught.com>
Mon, 1 Sep 2003 03:59:54 +0000 (03:59 +0000)
committerJim Evins <evins@snaught.com>
Mon, 1 Sep 2003 03:59:54 +0000 (03:59 +0000)
git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@286 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/data/glabels-2.0.dtd
glabels2/src/template.c
glabels2/src/template.h
glabels2/src/view.c
glabels2/src/xml-template.c

index 5bd4efb4417e4dbd92c47e7475f9f7959f3f5a18..7132aedb08d8f1f975003468087241131602f755 100644 (file)
@@ -70,7 +70,7 @@
 <!-- Template Section                                                     -->
 <!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
 <!ENTITY % label_element  "Label-rectangle | Label-round | Label-cd">
-<!ENTITY % markup_element "Markup-margin | Markup-line">
+<!ENTITY % markup_element "Markup-margin | Markup-line | Markup-circle">
 
 <!ELEMENT Template ((%label_element;)+, Alias*)>
 <!ATTLIST Template
                  y2              %LENGTH_TYPE;           #REQUIRED
 >
 
+<!ELEMENT Markup-circle EMPTY>
+<!ATTLIST Markup-circle
+                 x0              %LENGTH_TYPE;           #REQUIRED
+                 y0              %LENGTH_TYPE;           #REQUIRED
+                 radius          %LENGTH_TYPE;           #REQUIRED
+>
+
 <!ELEMENT Layout EMPTY>
 <!ATTLIST Layout
                  nx              %UINT_TYPE;             #REQUIRED
index 22ef2af802144b0023f4cd6642554c0d82642852..d074306f2a3422af44e6643e2f448393e99815ca 100644 (file)
@@ -709,7 +709,7 @@ gl_template_markup_margin_new (gdouble size)
 }
 
 /*****************************************************************************/
-/* Create new margin line structure.                                         */
+/* Create new markup line structure.                                         */
 /*****************************************************************************/
 glTemplateMarkup *
 gl_template_markup_line_new (gdouble x1,
@@ -730,6 +730,26 @@ gl_template_markup_line_new (gdouble x1,
        return markup;
 }
 
+/*****************************************************************************/
+/* Create new markup circle structure.                                       */
+/*****************************************************************************/
+glTemplateMarkup *
+gl_template_markup_circle_new (gdouble x0,
+                              gdouble y0,
+                              gdouble r)
+{
+       glTemplateMarkup *markup;
+
+       markup = g_new0 (glTemplateMarkup, 1);
+
+       markup->type        = GL_TEMPLATE_MARKUP_CIRCLE;
+       markup->circle.x0     = x0;
+       markup->circle.y0     = y0;
+       markup->circle.r      = r;
+
+       return markup;
+}
+
 /*--------------------------------------------------------------------------*/
 /* PRIVATE.  Duplicate markup structure.                                    */
 /*--------------------------------------------------------------------------*/
index cb419d87bfac19734d66b88948109ee46860cf05..7d8da895ef8f66b41299fc391971b08c89c9eb45 100644 (file)
@@ -78,6 +78,7 @@ typedef union {
 typedef enum {
        GL_TEMPLATE_MARKUP_MARGIN,
        GL_TEMPLATE_MARKUP_LINE,
+       GL_TEMPLATE_MARKUP_CIRCLE,
 } glTemplateMarkupType;
 
 typedef struct {
@@ -97,11 +98,18 @@ typedef struct {
        gdouble                x1, y1, x2, y2;
 } glTemplateMarkupLine;
 
+typedef struct {
+       glTemplateMarkupParent parent;
+
+       gdouble                x0, y0, r;
+} glTemplateMarkupCircle;
+
 typedef union {
        glTemplateMarkupType   type;
        glTemplateMarkupParent any;
        glTemplateMarkupMargin margin;
        glTemplateMarkupLine   line;
+       glTemplateMarkupCircle circle;
 } glTemplateMarkup;
 
 
@@ -171,6 +179,9 @@ glTemplateMarkup    *gl_template_markup_line_new     (gdouble            x1,
                                                      gdouble            y1,
                                                      gdouble            x2,
                                                      gdouble            y2);
+glTemplateMarkup    *gl_template_markup_circle_new   (gdouble            x0,
+                                                     gdouble            y0,
+                                                     gdouble            r);
 
 
 G_END_DECLS
index 44e49ca16ef0e83ee0d99a8767dd41577f321fb0..32fe99cae244e8a8dff5601ee928df6878950f2d 100644 (file)
@@ -144,6 +144,9 @@ static void       draw_markup_margin_cd_bc        (glView *view,
 static void       draw_markup_line                (glView *view,
                                                   glTemplateMarkupLine   *line);
 
+static void       draw_markup_circle              (glView *view,
+                                                  glTemplateMarkupCircle *circle);
+
 
 static void       select_object_real              (glView *view,
                                                   glViewObject *view_object);
@@ -1137,6 +1140,9 @@ draw_markup_layer (glView *view)
                case GL_TEMPLATE_MARKUP_LINE:
                        draw_markup_line (view,
                                          (glTemplateMarkupLine *)markup);
+               case GL_TEMPLATE_MARKUP_CIRCLE:
+                       draw_markup_line (view,
+                                         (glTemplateMarkupCircle *)markup);
                        break;
                default:
                        g_warning ("Unknown template markup type");
@@ -1535,6 +1541,31 @@ draw_markup_line (glView               *view,
        gl_debug (DEBUG_VIEW, "END");
 }
 
+/*---------------------------------------------------------------------------*/
+/* PRIVATE.  Draw circle markup.                                             */
+/*---------------------------------------------------------------------------*/
+static void
+draw_markup_circle (glView                 *view,
+                   glTemplateMarkupCircle *circle)
+{
+       gl_debug (DEBUG_VIEW, "START");
+
+       g_return_if_fail (view && GL_IS_VIEW (view));
+
+       /* Circle outline */
+       gnome_canvas_item_new (view->markup_group,
+                              gnome_canvas_ellipse_get_type (),
+                              "x1", circle->x0 - circle->r,
+                              "y1", circle->y0 - circle->r,
+                              "x2", circle->x0 + circle->r,
+                              "y2", circle->y0 + circle->r,
+                              "width_pixels", 1,
+                              "outline_color_rgba", MARKUP_COLOR,
+                              NULL);
+
+       gl_debug (DEBUG_VIEW, "END");
+}
+
 /*****************************************************************************/
 /* Show grid.                                                                */
 /*****************************************************************************/
index 98e30bc5e5edc1513c704f2da1d4df96d30d64bd..1233da2042bee558b3de553d580df71eddb77c6b 100644 (file)
@@ -55,6 +55,8 @@ static void        xml_parse_markup_margin      (xmlNodePtr              markup_
                                                 glTemplate             *template);
 static void        xml_parse_markup_line        (xmlNodePtr              markup_node,
                                                 glTemplate             *template);
+static void        xml_parse_markup_circle      (xmlNodePtr              markup_node,
+                                                glTemplate             *template);
 static void        xml_parse_alias              (xmlNodePtr              alias_node,
                                                 glTemplate             *template);
 
@@ -70,6 +72,9 @@ static void        xml_add_markup_margin        (glTemplateMarkupMargin *margin,
 static void        xml_add_markup_line          (glTemplateMarkupLine   *line,
                                                 xmlNodePtr              root,
                                                 xmlNsPtr                ns);
+static void        xml_add_markup_circle        (glTemplateMarkupCircle *circle,
+                                                xmlNodePtr              root,
+                                                xmlNsPtr                ns);
 static void        xml_add_alias                (gchar                  *name,
                                                 xmlNodePtr              root,
                                                 xmlNsPtr                ns);
@@ -233,6 +238,8 @@ xml_parse_label_rectangle (xmlNodePtr  label_node,
                        xml_parse_markup_margin (node, template);
                } else if (xmlStrEqual (node->name, "Markup-line")) {
                        xml_parse_markup_line (node, template);
+               } else if (xmlStrEqual (node->name, "Markup-circle")) {
+                       xml_parse_markup_circle (node, template);
                } else if (!xmlNodeIsText (node)) {
                        g_warning ("bad node =  \"%s\"", node->name);
                }
@@ -405,6 +412,36 @@ xml_parse_markup_line (xmlNodePtr  markup_node,
        gl_debug (DEBUG_TEMPLATE, "END");
 }
 
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  Parse XML Template->Label->Markup-circle Node.                 */
+/*--------------------------------------------------------------------------*/
+static void
+xml_parse_markup_circle (xmlNodePtr  markup_node,
+                      glTemplate *template)
+{
+       gdouble     x0, y0, r;
+       xmlNodePtr  node;
+
+       gl_debug (DEBUG_TEMPLATE, "START");
+
+       x0 = gl_xml_get_prop_length (markup_node, "x0", 0);
+       y0 = gl_xml_get_prop_length (markup_node, "y0", 0);
+       r  = gl_xml_get_prop_length (markup_node, "radius", 0);
+
+       template->label.any.markups =
+               g_list_append (template->label.any.markups,
+                              gl_template_markup_circle_new (x0, y0, r));
+
+       for (node = markup_node->xmlChildrenNode; node != NULL;
+            node = node->next) {
+               if (!xmlNodeIsText (node)) {
+                       g_warning ("bad node =  \"%s\"", node->name);
+               }
+       }
+
+       gl_debug (DEBUG_TEMPLATE, "END");
+}
+
 /*--------------------------------------------------------------------------*/
 /* PRIVATE.  Parse XML Template->Alias Node.                                */
 /*--------------------------------------------------------------------------*/
@@ -523,6 +560,10 @@ xml_add_label (const glTemplate *template,
                        xml_add_markup_line ((glTemplateMarkupLine *)markup,
                                             node, ns);
                        break;
+               case GL_TEMPLATE_MARKUP_CIRCLE:
+                       xml_add_markup_circle ((glTemplateMarkupCircle *)markup,
+                                              node, ns);
+                       break;
                default:
                        g_warning ("Unknown markup type");
                        break;
@@ -561,7 +602,7 @@ xml_add_layout (glTemplateLayout *layout,
 }
 
 /*--------------------------------------------------------------------------*/
-/* PRIVATE.  Add XML Template->Label->Markup (margin) Node.                    */
+/* PRIVATE.  Add XML Template->Label->Markup-margin Node.                   */
 /*--------------------------------------------------------------------------*/
 static void
 xml_add_markup_margin (glTemplateMarkupMargin *margin,
@@ -580,7 +621,7 @@ xml_add_markup_margin (glTemplateMarkupMargin *margin,
 }
 
 /*--------------------------------------------------------------------------*/
-/* PRIVATE.  Add XML Template->Label->Markup (line) Node.                      */
+/* PRIVATE.  Add XML Template->Label->Markup-line Node.                     */
 /*--------------------------------------------------------------------------*/
 static void
 xml_add_markup_line (glTemplateMarkupLine *line,
@@ -601,6 +642,27 @@ xml_add_markup_line (glTemplateMarkupLine *line,
        gl_debug (DEBUG_TEMPLATE, "END");
 }
 
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  Add XML Template->Label->Markup-circle Node.                   */
+/*--------------------------------------------------------------------------*/
+static void
+xml_add_markup_circle (glTemplateMarkupCircle *circle,
+                      xmlNodePtr            root,
+                      xmlNsPtr              ns)
+{
+       xmlNodePtr  node;
+
+       gl_debug (DEBUG_TEMPLATE, "START");
+
+       node = xmlNewChild(root, ns, "Markup-circle", NULL);
+
+       gl_xml_set_prop_length (node, "x0", circle->x0);
+       gl_xml_set_prop_length (node, "y0", circle->y0);
+       gl_xml_set_prop_length (node, "radius", circle->r);
+
+       gl_debug (DEBUG_TEMPLATE, "END");
+}
+
 /*--------------------------------------------------------------------------*/
 /* PRIVATE.  Add XML Template->Alias Node.                                     */
 /*--------------------------------------------------------------------------*/