1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
4 * (LIBGLABELS) Template library for GLABELS
6 * template.h: template module header file
8 * Copyright (C) 2001-2006 Jim Evins <evins@snaught.com>.
10 * This file is part of the LIBGLABELS library.
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with this library; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28 #ifndef __TEMPLATE_H__
29 #define __TEMPLATE_H__
31 #include <glib/gtypes.h>
32 #include <glib/glist.h>
36 typedef struct _lglTemplate lglTemplate;
38 typedef struct _lglTemplateAlias lglTemplateAlias;
40 typedef union _lglTemplateFrame lglTemplateFrame;
41 typedef struct _lglTemplateFrameAll lglTemplateFrameAll;
42 typedef struct _lglTemplateFrameRect lglTemplateFrameRect;
43 typedef struct _lglTemplateFrameRound lglTemplateFrameRound;
44 typedef struct _lglTemplateFrameCD lglTemplateFrameCD;
46 typedef struct _lglTemplateLayout lglTemplateLayout;
48 typedef union _lglTemplateMarkup lglTemplateMarkup;
49 typedef struct _lglTemplateMarkupMargin lglTemplateMarkupMargin;
50 typedef struct _lglTemplateMarkupLine lglTemplateMarkupLine;
51 typedef struct _lglTemplateMarkupCircle lglTemplateMarkupCircle;
52 typedef struct _lglTemplateMarkupRect lglTemplateMarkupRect;
54 typedef struct _lglTemplateOrigin lglTemplateOrigin;
57 * Top-level Template Structure
68 /* List of (lglTemplateAlias *) aliase structures. */
71 /* List of (gchar *) category ids. */
74 /* List of (lglTemplateFrame *) label frame structures.
75 * Currently glabels only supports a single label frame per
83 * Top-level Template Structure
85 struct _lglTemplateAlias {
93 * Possible Frame Shapes
96 LGL_TEMPLATE_FRAME_SHAPE_RECT,
97 LGL_TEMPLATE_FRAME_SHAPE_ROUND,
98 LGL_TEMPLATE_FRAME_SHAPE_CD,
99 } lglTemplateFrameShape;
105 struct _lglTemplateFrameAll {
107 /* Begin Common Fields */
108 lglTemplateFrameShape shape;
110 gchar *id; /* Id, currently always "0" */
111 GList *layouts; /* List of lglTemplateLayouts */
112 GList *markups; /* List of lglTemplateMarkups */
113 /* End Common Fields */
116 struct _lglTemplateFrameRect {
118 /* Begin Common Fields */
119 lglTemplateFrameShape shape; /* Always LGL_TEMPLATE_FRAME_SHAPE_RECT. */
121 gchar *id; /* Id, currently always "0" */
122 GList *layouts; /* List of lglTemplateLayouts */
123 GList *markups; /* List of lglTemplateMarkups */
124 /* End Common Fields */
126 gdouble w; /* Width */
127 gdouble h; /* Height */
128 gdouble r; /* Corner radius */
129 gdouble x_waste; /* Amount of horiz overprint allowed. */
130 gdouble y_waste; /* Amount of vert overprint allowed. */
133 struct _lglTemplateFrameRound {
135 /* Begin Common Fields */
136 lglTemplateFrameShape shape; /* Always LGL_TEMPLATE_FRAME_SHAPE_ROUND. */
138 gchar *id; /* Id, currently always "0" */
139 GList *layouts; /* List of lglTemplateLayouts */
140 GList *markups; /* List of lglTemplateMarkups */
141 /* End Common Fields */
143 gdouble r; /* Radius */
144 gdouble waste; /* Amount of overprint allowed. */
147 struct _lglTemplateFrameCD {
149 /* Begin Common Fields */
150 lglTemplateFrameShape shape; /* Always LGL_TEMPLATE_FRAME_SHAPE_CD. */
152 gchar *id; /* Id, currently always "0" */
153 GList *layouts; /* List of lglTemplateLayouts */
154 GList *markups; /* List of lglTemplateMarkups */
155 /* End Common Fields */
157 gdouble r1; /* Outer radius */
158 gdouble r2; /* Inner radius (hole) */
159 gdouble w; /* Clip width, business card CDs */
160 gdouble h; /* Clip height, business card CDs */
161 gdouble waste; /* Amount of overprint allowed. */
164 union _lglTemplateFrame{
166 lglTemplateFrameShape shape;
168 lglTemplateFrameAll all;
169 lglTemplateFrameRect rect;
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 } lglTemplateMarkupType;
204 * Label Markup Structure (Helpful lines drawn in glabels to help locate objects)
206 struct _lglTemplateMarkupMargin {
208 lglTemplateMarkupType type; /* Always LGL_TEMPLATE_MARKUP_MARGIN */
210 gdouble size; /* Margin size */
213 struct _lglTemplateMarkupLine {
215 lglTemplateMarkupType type; /* Always LGL_TEMPLATE_MARKUP_LINE */
217 gdouble x1, y1; /* 1st endpoint */
218 gdouble x2, y2; /* 2nd endpoint */
221 struct _lglTemplateMarkupCircle {
223 lglTemplateMarkupType type; /* Always LGL_TEMPLATE_MARKUP_CIRCLE */
225 gdouble x0, y0; /* Center of circle */
226 gdouble r; /* Radius of circle */
229 struct _lglTemplateMarkupRect {
231 lglTemplateMarkupType type; /* Always LGL_TEMPLATE_MARKUP_RECT */
233 gdouble x1, y1; /* Upper left corner */
234 gdouble w, h; /* Width and height. */
235 gdouble r; /* Radius of corners. */
238 union _lglTemplateMarkup {
240 lglTemplateMarkupType type;
242 lglTemplateMarkupMargin margin;
243 lglTemplateMarkupLine line;
244 lglTemplateMarkupCircle circle;
245 lglTemplateMarkupRect rect;
252 struct _lglTemplateOrigin {
254 gdouble x, y; /* Label origin relative to upper
255 * upper left hand corner of paper */
262 * Template query functions
264 gchar *lgl_template_get_name (const lglTemplate *template);
266 gboolean lgl_template_do_templates_match (const lglTemplate *template1,
267 const lglTemplate *template2);
269 gboolean lgl_template_does_brand_match (const lglTemplate *template,
272 gboolean lgl_template_does_page_size_match (const lglTemplate *template,
273 const gchar *paper_id);
275 gboolean lgl_template_does_category_match (const lglTemplate *template,
276 const gchar *category_id);
280 * Frame query functions
282 void lgl_template_frame_get_size (const lglTemplateFrame *frame,
286 gint lgl_template_frame_get_n_labels (const lglTemplateFrame *frame);
288 lglTemplateOrigin *lgl_template_frame_get_origins (const lglTemplateFrame *frame);
292 * Template Construction
294 lglTemplate *lgl_template_new (const gchar *brand,
296 const gchar *description,
297 const gchar *paper_id,
299 gdouble page_height);
301 void lgl_template_add_alias (lglTemplate *template,
302 lglTemplateAlias *alias);
304 void lgl_template_add_category (lglTemplate *template,
305 const gchar *category_id);
307 void lgl_template_add_frame (lglTemplate *template,
308 lglTemplateFrame *frame);
310 lglTemplateFrame *lgl_template_frame_rect_new (const gchar *id,
317 lglTemplateAlias *lgl_template_alias_new (const gchar *brand,
320 lglTemplateFrame *lgl_template_frame_round_new (const gchar *id,
324 lglTemplateFrame *lgl_template_frame_cd_new (const gchar *id,
331 void lgl_template_frame_add_layout (lglTemplateFrame *frame,
332 lglTemplateLayout *layout);
334 void lgl_template_frame_add_markup (lglTemplateFrame *frame,
335 lglTemplateMarkup *markup);
337 lglTemplateLayout *lgl_template_layout_new (gint nx,
344 lglTemplateMarkup *lgl_template_markup_margin_new (gdouble size);
346 lglTemplateMarkup *lgl_template_markup_line_new (gdouble x1,
351 lglTemplateMarkup *lgl_template_markup_circle_new (gdouble x0,
355 lglTemplateMarkup *lgl_template_markup_rect_new (gdouble x1,
361 lglTemplate *lgl_template_dup (const lglTemplate *orig_template);
363 void lgl_template_free (lglTemplate *template);
365 lglTemplateAlias *lgl_template_alias_dup (const lglTemplateAlias *orig_alias);
366 void lgl_template_alias_free (lglTemplateAlias *alias);
368 lglTemplateFrame *lgl_template_frame_dup (const lglTemplateFrame *orig_frame);
369 void lgl_template_frame_free (lglTemplateFrame *frame);
371 lglTemplateLayout *lgl_template_layout_dup (const lglTemplateLayout *orig_layout);
372 void lgl_template_layout_free (lglTemplateLayout *layout);
374 lglTemplateMarkup *lgl_template_markup_dup (const lglTemplateMarkup *orig_markup);
375 void lgl_template_markup_free (lglTemplateMarkup *markup);