3 * Copyright (C) 2001-2009 Jim Evins <evins@snaught.com>.
5 * This file is part of libglabels.
7 * libglabels is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * libglabels is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with libglabels. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef __TEMPLATE_H__
22 #define __TEMPLATE_H__
28 typedef struct _lglTemplate lglTemplate;
30 typedef struct _lglTemplateAlias lglTemplateAlias;
32 typedef union _lglTemplateFrame lglTemplateFrame;
33 typedef struct _lglTemplateFrameAll lglTemplateFrameAll;
34 typedef struct _lglTemplateFrameRect lglTemplateFrameRect;
35 typedef struct _lglTemplateFrameRound lglTemplateFrameRound;
36 typedef struct _lglTemplateFrameCD lglTemplateFrameCD;
38 typedef struct _lglTemplateLayout lglTemplateLayout;
40 typedef union _lglTemplateMarkup lglTemplateMarkup;
41 typedef struct _lglTemplateMarkupMargin lglTemplateMarkupMargin;
42 typedef struct _lglTemplateMarkupLine lglTemplateMarkupLine;
43 typedef struct _lglTemplateMarkupCircle lglTemplateMarkupCircle;
44 typedef struct _lglTemplateMarkupRect lglTemplateMarkupRect;
46 typedef struct _lglTemplateOrigin lglTemplateOrigin;
49 * Top-level Template Structure
60 /* List of (lglTemplateAlias *) aliase structures. */
63 /* List of (gchar *) category ids. */
66 /* List of (lglTemplateFrame *) label frame structures.
67 * Currently glabels only supports a single label frame per
75 * Top-level Template Structure
77 struct _lglTemplateAlias {
85 * Possible Frame Shapes
88 LGL_TEMPLATE_FRAME_SHAPE_RECT,
89 LGL_TEMPLATE_FRAME_SHAPE_ROUND,
90 LGL_TEMPLATE_FRAME_SHAPE_CD,
91 } lglTemplateFrameShape;
97 struct _lglTemplateFrameAll {
99 /* Begin Common Fields */
100 lglTemplateFrameShape shape;
102 gchar *id; /* Id, currently always "0" */
103 GList *layouts; /* List of lglTemplateLayouts */
104 GList *markups; /* List of lglTemplateMarkups */
105 /* End Common Fields */
108 struct _lglTemplateFrameRect {
110 /* Begin Common Fields */
111 lglTemplateFrameShape shape; /* Always LGL_TEMPLATE_FRAME_SHAPE_RECT. */
113 gchar *id; /* Id, currently always "0" */
114 GList *layouts; /* List of lglTemplateLayouts */
115 GList *markups; /* List of lglTemplateMarkups */
116 /* End Common Fields */
118 gdouble w; /* Width */
119 gdouble h; /* Height */
120 gdouble r; /* Corner radius */
121 gdouble x_waste; /* Amount of horiz overprint allowed. */
122 gdouble y_waste; /* Amount of vert overprint allowed. */
125 struct _lglTemplateFrameRound {
127 /* Begin Common Fields */
128 lglTemplateFrameShape shape; /* Always LGL_TEMPLATE_FRAME_SHAPE_ROUND. */
130 gchar *id; /* Id, currently always "0" */
131 GList *layouts; /* List of lglTemplateLayouts */
132 GList *markups; /* List of lglTemplateMarkups */
133 /* End Common Fields */
135 gdouble r; /* Radius */
136 gdouble waste; /* Amount of overprint allowed. */
139 struct _lglTemplateFrameCD {
141 /* Begin Common Fields */
142 lglTemplateFrameShape shape; /* Always LGL_TEMPLATE_FRAME_SHAPE_CD. */
144 gchar *id; /* Id, currently always "0" */
145 GList *layouts; /* List of lglTemplateLayouts */
146 GList *markups; /* List of lglTemplateMarkups */
147 /* End Common Fields */
149 gdouble r1; /* Outer radius */
150 gdouble r2; /* Inner radius (hole) */
151 gdouble w; /* Clip width, business card CDs */
152 gdouble h; /* Clip height, business card CDs */
153 gdouble waste; /* Amount of overprint allowed. */
156 union _lglTemplateFrame{
158 lglTemplateFrameShape shape;
160 lglTemplateFrameAll all;
161 lglTemplateFrameRect rect;
162 lglTemplateFrameRound round;
163 lglTemplateFrameCD cd;
168 * Label Layout Structure
170 struct _lglTemplateLayout {
172 gint nx; /* Number of labels across */
173 gint ny; /* Number of labels up and down */
175 gdouble x0; /* Left of grid from left edge of paper */
176 gdouble y0; /* Top of grid from top edge of paper */
178 gdouble dx; /* Horizontal pitch of grid */
179 gdouble dy; /* Vertical pitch of grid */
185 * Possible Markup Types
188 LGL_TEMPLATE_MARKUP_MARGIN,
189 LGL_TEMPLATE_MARKUP_LINE,
190 LGL_TEMPLATE_MARKUP_CIRCLE,
191 LGL_TEMPLATE_MARKUP_RECT,
192 } lglTemplateMarkupType;
196 * Label Markup Structure (Helpful lines drawn in glabels to help locate objects)
198 struct _lglTemplateMarkupMargin {
200 lglTemplateMarkupType type; /* Always LGL_TEMPLATE_MARKUP_MARGIN */
202 gdouble size; /* Margin size */
205 struct _lglTemplateMarkupLine {
207 lglTemplateMarkupType type; /* Always LGL_TEMPLATE_MARKUP_LINE */
209 gdouble x1, y1; /* 1st endpoint */
210 gdouble x2, y2; /* 2nd endpoint */
213 struct _lglTemplateMarkupCircle {
215 lglTemplateMarkupType type; /* Always LGL_TEMPLATE_MARKUP_CIRCLE */
217 gdouble x0, y0; /* Center of circle */
218 gdouble r; /* Radius of circle */
221 struct _lglTemplateMarkupRect {
223 lglTemplateMarkupType type; /* Always LGL_TEMPLATE_MARKUP_RECT */
225 gdouble x1, y1; /* Upper left corner */
226 gdouble w, h; /* Width and height. */
227 gdouble r; /* Radius of corners. */
230 union _lglTemplateMarkup {
232 lglTemplateMarkupType type;
234 lglTemplateMarkupMargin margin;
235 lglTemplateMarkupLine line;
236 lglTemplateMarkupCircle circle;
237 lglTemplateMarkupRect rect;
244 struct _lglTemplateOrigin {
246 gdouble x, y; /* Label origin relative to upper
247 * upper left hand corner of paper */
254 * Template query functions
256 gchar *lgl_template_get_name (const lglTemplate *template);
258 gboolean lgl_template_do_templates_match (const lglTemplate *template1,
259 const lglTemplate *template2);
261 gboolean lgl_template_does_brand_match (const lglTemplate *template,
264 gboolean lgl_template_does_page_size_match (const lglTemplate *template,
265 const gchar *paper_id);
267 gboolean lgl_template_does_category_match (const lglTemplate *template,
268 const gchar *category_id);
272 * Frame query functions
274 void lgl_template_frame_get_size (const lglTemplateFrame *frame,
278 gint lgl_template_frame_get_n_labels (const lglTemplateFrame *frame);
280 lglTemplateOrigin *lgl_template_frame_get_origins (const lglTemplateFrame *frame);
284 * Template Construction
286 lglTemplate *lgl_template_new (const gchar *brand,
288 const gchar *description,
289 const gchar *paper_id,
291 gdouble page_height);
293 void lgl_template_add_alias (lglTemplate *template,
294 lglTemplateAlias *alias);
296 void lgl_template_add_category (lglTemplate *template,
297 const gchar *category_id);
299 void lgl_template_add_frame (lglTemplate *template,
300 lglTemplateFrame *frame);
302 lglTemplateFrame *lgl_template_frame_rect_new (const gchar *id,
309 lglTemplateAlias *lgl_template_alias_new (const gchar *brand,
312 lglTemplateFrame *lgl_template_frame_round_new (const gchar *id,
316 lglTemplateFrame *lgl_template_frame_cd_new (const gchar *id,
323 void lgl_template_frame_add_layout (lglTemplateFrame *frame,
324 lglTemplateLayout *layout);
326 void lgl_template_frame_add_markup (lglTemplateFrame *frame,
327 lglTemplateMarkup *markup);
329 lglTemplateLayout *lgl_template_layout_new (gint nx,
336 lglTemplateMarkup *lgl_template_markup_margin_new (gdouble size);
338 lglTemplateMarkup *lgl_template_markup_line_new (gdouble x1,
343 lglTemplateMarkup *lgl_template_markup_circle_new (gdouble x0,
347 lglTemplateMarkup *lgl_template_markup_rect_new (gdouble x1,
353 lglTemplate *lgl_template_dup (const lglTemplate *orig_template);
355 void lgl_template_free (lglTemplate *template);
357 lglTemplateAlias *lgl_template_alias_dup (const lglTemplateAlias *orig_alias);
358 void lgl_template_alias_free (lglTemplateAlias *alias);
360 lglTemplateFrame *lgl_template_frame_dup (const lglTemplateFrame *orig_frame);
361 void lgl_template_frame_free (lglTemplateFrame *frame);
363 lglTemplateLayout *lgl_template_layout_dup (const lglTemplateLayout *orig_layout);
364 void lgl_template_layout_free (lglTemplateLayout *layout);
366 lglTemplateMarkup *lgl_template_markup_dup (const lglTemplateMarkup *orig_markup);
367 void lgl_template_markup_free (lglTemplateMarkup *markup);
377 * Local Variables: -- emacs
379 * c-basic-offset: 8 -- emacs
380 * tab-width: 8 -- emacs
381 * indent-tabs-mode: nil -- emacs