3 * Copyright (C) 2001-2010 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 __LGL_TEMPLATE_H__
22 #define __LGL_TEMPLATE_H__
25 #include "lgl-units.h"
29 typedef struct _lglTemplate lglTemplate;
31 typedef union _lglTemplateFrame lglTemplateFrame;
32 typedef struct _lglTemplateFrameAll lglTemplateFrameAll;
33 typedef struct _lglTemplateFrameRect lglTemplateFrameRect;
34 typedef struct _lglTemplateFrameEllipse lglTemplateFrameEllipse;
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;
45 typedef struct _lglTemplateMarkupEllipse lglTemplateMarkupEllipse;
47 typedef struct _lglTemplateOrigin lglTemplateOrigin;
50 * Top-level Template Structure
63 /* Meta information. */
64 gchar *product_url; /* URL to manufacturer's product website. */
65 GList *category_ids; /* List of (gchar *) category ids. */
67 /* List of (lglTemplateFrame *) label frame structures.
68 * Currently glabels only supports a single label frame per
76 * Possible Frame Shapes
79 LGL_TEMPLATE_FRAME_SHAPE_RECT,
80 LGL_TEMPLATE_FRAME_SHAPE_ELLIPSE,
81 LGL_TEMPLATE_FRAME_SHAPE_ROUND,
82 LGL_TEMPLATE_FRAME_SHAPE_CD
83 } lglTemplateFrameShape;
89 struct _lglTemplateFrameAll {
91 /* Begin Common Fields */
92 lglTemplateFrameShape shape;
94 gchar *id; /* Id, currently always "0" */
95 GList *layouts; /* List of lglTemplateLayouts */
96 GList *markups; /* List of lglTemplateMarkups */
97 /* End Common Fields */
100 struct _lglTemplateFrameRect {
102 /* Begin Common Fields */
103 lglTemplateFrameShape shape; /* Always LGL_TEMPLATE_FRAME_SHAPE_RECT. */
105 gchar *id; /* Id, currently always "0" */
106 GList *layouts; /* List of lglTemplateLayouts */
107 GList *markups; /* List of lglTemplateMarkups */
108 /* End Common Fields */
110 gdouble w; /* Width */
111 gdouble h; /* Height */
112 gdouble r; /* Corner radius */
113 gdouble x_waste; /* Amount of horiz overprint allowed. */
114 gdouble y_waste; /* Amount of vert overprint allowed. */
117 struct _lglTemplateFrameEllipse {
119 /* Begin Common Fields */
120 lglTemplateFrameShape shape; /* Always LGL_TEMPLATE_FRAME_SHAPE_ELLIPSE. */
122 gchar *id; /* Id, currently always "0" */
123 GList *layouts; /* List of lglTemplateLayouts */
124 GList *markups; /* List of lglTemplateMarkups */
125 /* End Common Fields */
127 gdouble w; /* Width */
128 gdouble h; /* Height */
129 gdouble waste; /* Amount of overprint allowed. */
132 struct _lglTemplateFrameRound {
134 /* Begin Common Fields */
135 lglTemplateFrameShape shape; /* Always LGL_TEMPLATE_FRAME_SHAPE_ROUND. */
137 gchar *id; /* Id, currently always "0" */
138 GList *layouts; /* List of lglTemplateLayouts */
139 GList *markups; /* List of lglTemplateMarkups */
140 /* End Common Fields */
142 gdouble r; /* Radius */
143 gdouble waste; /* Amount of overprint allowed. */
146 struct _lglTemplateFrameCD {
148 /* Begin Common Fields */
149 lglTemplateFrameShape shape; /* Always LGL_TEMPLATE_FRAME_SHAPE_CD. */
151 gchar *id; /* Id, currently always "0" */
152 GList *layouts; /* List of lglTemplateLayouts */
153 GList *markups; /* List of lglTemplateMarkups */
154 /* End Common Fields */
156 gdouble r1; /* Outer radius */
157 gdouble r2; /* Inner radius (hole) */
158 gdouble w; /* Clip width, business card CDs */
159 gdouble h; /* Clip height, business card CDs */
160 gdouble waste; /* Amount of overprint allowed. */
163 union _lglTemplateFrame{
165 lglTemplateFrameShape shape;
167 lglTemplateFrameAll all;
168 lglTemplateFrameRect rect;
169 lglTemplateFrameEllipse ellipse;
170 lglTemplateFrameRound round;
171 lglTemplateFrameCD cd;
176 * Label Layout Structure
178 struct _lglTemplateLayout {
180 gint nx; /* Number of labels across */
181 gint ny; /* Number of labels up and down */
183 gdouble x0; /* Left of grid from left edge of paper */
184 gdouble y0; /* Top of grid from top edge of paper */
186 gdouble dx; /* Horizontal pitch of grid */
187 gdouble dy; /* Vertical pitch of grid */
193 * Possible Markup Types
196 LGL_TEMPLATE_MARKUP_MARGIN,
197 LGL_TEMPLATE_MARKUP_LINE,
198 LGL_TEMPLATE_MARKUP_CIRCLE,
199 LGL_TEMPLATE_MARKUP_RECT,
200 LGL_TEMPLATE_MARKUP_ELLIPSE
201 } lglTemplateMarkupType;
205 * Label Markup Structure (Helpful lines drawn in glabels to help locate objects)
207 struct _lglTemplateMarkupMargin {
209 lglTemplateMarkupType type; /* Always LGL_TEMPLATE_MARKUP_MARGIN */
211 gdouble size; /* Margin size */
214 struct _lglTemplateMarkupLine {
216 lglTemplateMarkupType type; /* Always LGL_TEMPLATE_MARKUP_LINE */
218 gdouble x1, y1; /* 1st endpoint */
219 gdouble x2, y2; /* 2nd endpoint */
222 struct _lglTemplateMarkupCircle {
224 lglTemplateMarkupType type; /* Always LGL_TEMPLATE_MARKUP_CIRCLE */
226 gdouble x0, y0; /* Center of circle */
227 gdouble r; /* Radius of circle */
230 struct _lglTemplateMarkupRect {
232 lglTemplateMarkupType type; /* Always LGL_TEMPLATE_MARKUP_RECT */
234 gdouble x1, y1; /* Upper left corner */
235 gdouble w, h; /* Width and height. */
236 gdouble r; /* Radius of corners. */
239 struct _lglTemplateMarkupEllipse {
241 lglTemplateMarkupType type; /* Always LGL_TEMPLATE_MARKUP_ELLIPSE */
243 gdouble x1, y1; /* Upper left corner */
244 gdouble w, h; /* Width and height. */
247 union _lglTemplateMarkup {
249 lglTemplateMarkupType type;
251 lglTemplateMarkupMargin margin;
252 lglTemplateMarkupLine line;
253 lglTemplateMarkupCircle circle;
254 lglTemplateMarkupRect rect;
255 lglTemplateMarkupEllipse ellipse;
262 struct _lglTemplateOrigin {
264 gdouble x, y; /* Label origin relative to upper
265 * upper left hand corner of paper */
272 * Template query functions
274 gchar *lgl_template_get_name (const lglTemplate *template);
276 gboolean lgl_template_do_templates_match (const lglTemplate *template1,
277 const lglTemplate *template2);
279 gboolean lgl_template_does_brand_match (const lglTemplate *template,
282 gboolean lgl_template_does_page_size_match (const lglTemplate *template,
283 const gchar *paper_id);
285 gboolean lgl_template_does_category_match (const lglTemplate *template,
286 const gchar *category_id);
288 gboolean lgl_template_are_templates_identical (const lglTemplate *template1,
289 const lglTemplate *template2);
295 * Frame query functions
297 void lgl_template_frame_get_size (const lglTemplateFrame *frame,
301 gint lgl_template_frame_get_n_labels (const lglTemplateFrame *frame);
303 lglTemplateOrigin *lgl_template_frame_get_origins (const lglTemplateFrame *frame);
305 gchar *lgl_template_frame_get_layout_description (const lglTemplateFrame *frame);
307 gchar *lgl_template_frame_get_size_description (const lglTemplateFrame *frame,
314 * Template Construction
316 lglTemplate *lgl_template_new (const gchar *brand,
318 const gchar *description,
319 const gchar *paper_id,
321 gdouble page_height);
323 lglTemplate *lgl_template_new_from_equiv (const gchar *brand,
325 const gchar *equiv_part);
327 void lgl_template_add_category (lglTemplate *template,
328 const gchar *category_id);
330 void lgl_template_add_frame (lglTemplate *template,
331 lglTemplateFrame *frame);
333 lglTemplateFrame *lgl_template_frame_rect_new (const gchar *id,
340 lglTemplateFrame *lgl_template_frame_ellipse_new (const gchar *id,
345 lglTemplateFrame *lgl_template_frame_round_new (const gchar *id,
349 lglTemplateFrame *lgl_template_frame_cd_new (const gchar *id,
356 void lgl_template_frame_add_layout (lglTemplateFrame *frame,
357 lglTemplateLayout *layout);
359 void lgl_template_frame_add_markup (lglTemplateFrame *frame,
360 lglTemplateMarkup *markup);
362 lglTemplateLayout *lgl_template_layout_new (gint nx,
369 lglTemplateMarkup *lgl_template_markup_margin_new (gdouble size);
371 lglTemplateMarkup *lgl_template_markup_line_new (gdouble x1,
376 lglTemplateMarkup *lgl_template_markup_circle_new (gdouble x0,
380 lglTemplateMarkup *lgl_template_markup_rect_new (gdouble x1,
386 lglTemplateMarkup *lgl_template_markup_ellipse_new (gdouble x1,
391 lglTemplate *lgl_template_dup (const lglTemplate *orig_template);
393 void lgl_template_free (lglTemplate *template);
395 lglTemplateFrame *lgl_template_frame_dup (const lglTemplateFrame *orig_frame);
396 void lgl_template_frame_free (lglTemplateFrame *frame);
398 lglTemplateLayout *lgl_template_layout_dup (const lglTemplateLayout *orig_layout);
399 void lgl_template_layout_free (lglTemplateLayout *layout);
401 lglTemplateMarkup *lgl_template_markup_dup (const lglTemplateMarkup *orig_markup);
402 void lgl_template_markup_free (lglTemplateMarkup *markup);
406 * Debugging functions.
408 void lgl_template_print (const lglTemplate *template);
413 #endif /* __LGL_TEMPLATE_H__ */
418 * Local Variables: -- emacs
420 * c-basic-offset: 8 -- emacs
421 * tab-width: 8 -- emacs
422 * indent-tabs-mode: nil -- emacs