]> git.sur5r.net Git - glabels/blob - glabels2/src/template.h
Restructured template module to ultimately support multiple layouts and markups.
[glabels] / glabels2 / src / template.h
1 /*
2  *  (GLABELS) Label and Business Card Creation program for GNOME
3  *
4  *  template.h:  template module header file
5  *
6  *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21  */
22
23 #ifndef __TEMPLATE_H__
24 #define __TEMPLATE_H__
25
26 #include <libgnome/libgnome.h>
27 #include <libxml/tree.h>
28 #include <libxml/parser.h>
29
30
31 /*
32  *   Template Label Structure
33  */
34 typedef enum {
35         GL_TEMPLATE_STYLE_RECT,
36         GL_TEMPLATE_STYLE_ROUND,
37         GL_TEMPLATE_STYLE_CD,
38 } glTemplateLabelStyle;
39
40 typedef struct {
41         glTemplateLabelStyle  style;
42         GList                *layouts;  /* List of glTemplateLayouts */
43         GList                *markups;  /* List of glTemplateMarkups */
44 } glTemplateLabelParent;
45
46 typedef struct {
47         glTemplateLabelParent parent;
48
49         gdouble               w, h, r;  /* Dimensions */
50 } glTemplateLabelRect;
51
52 typedef struct {
53         glTemplateLabelParent parent;
54
55         gdouble               r;        /* Dimensions */
56 } glTemplateLabelRound;
57
58 typedef struct {
59         glTemplateLabelParent parent;
60
61         gdouble               r1, r2;   /* Dimensions */
62 } glTemplateLabelCD;
63
64 typedef union {
65         glTemplateLabelStyle  style;
66         glTemplateLabelParent any;
67         glTemplateLabelRect   rect;
68         glTemplateLabelRound  round;
69         glTemplateLabelCD     cd;
70 } glTemplateLabel;
71
72
73 /*
74  *   Label Markup
75  */
76 typedef enum {
77         GL_TEMPLATE_MARKUP_MARGIN,
78 } glTemplateMarkupType;
79
80 typedef struct {
81         /* NOTE: These fields are common to all union members. */
82         glTemplateMarkupType   type;
83 } glTemplateMarkupParent;
84
85 typedef struct {
86         glTemplateMarkupParent parent;
87
88         gdouble                size;
89 } glTemplateMarkupMargin;
90
91 typedef union {
92         glTemplateMarkupType   type;
93         glTemplateMarkupParent any;
94         glTemplateMarkupMargin margin;
95 } glTemplateMarkup;
96
97
98 /*
99  *   Label layout
100  */
101 typedef struct {
102         gint nx, ny;
103         gdouble x0, y0, dx, dy;
104 } glTemplateLayout;
105
106
107 /*
108  *   Template
109  */
110 typedef struct {
111         GList               *name;
112         gchar               *description;
113         gchar               *page_size;
114
115         glTemplateLabel      label;
116
117 } glTemplate;
118
119
120 /*
121  *  Origin coordinates
122  */
123 typedef struct {
124         gdouble x, y;
125 } glTemplateOrigin;
126
127
128 extern void                 gl_template_init                (void);
129
130 extern GList               *gl_template_get_page_size_list  (void);
131 extern void                 gl_template_free_page_size_list (GList **sizes);
132
133 extern GList               *gl_template_get_name_list       (const gchar *page_size);
134 extern void                 gl_template_free_name_list      (GList **names);
135
136 extern glTemplate          *gl_template_from_name           (const gchar *name);
137
138 extern glTemplate          *gl_template_dup                 (const glTemplate *orig);
139 extern void                 gl_template_free                (glTemplate **template);
140
141 extern glTemplate          *gl_template_xml_parse_sheet     (xmlNodePtr sheet_node);
142
143 extern void                 gl_template_xml_add_sheet       (const glTemplate *template,
144                                                              xmlNodePtr root,
145                                                              xmlNsPtr ns);
146
147 extern gchar               *gl_template_get_label_size_desc (const glTemplate *template);
148 extern void                 gl_template_get_label_size      (const glTemplate *template,
149                                                              gdouble *w,
150                                                              gdouble *h);
151
152 extern gint                 gl_template_get_n_labels        (const glTemplate *template);
153 extern glTemplateOrigin    *gl_template_get_origins         (const glTemplate *template);
154 extern gchar               *gl_template_get_layout_desc     (const glTemplate *template);
155
156 #endif