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 _glTemplate glTemplate;
37 typedef struct _glTemplateLabelType glTemplateLabelType;
38 typedef struct _glTemplateLayout glTemplateLayout;
39 typedef struct _glTemplateMarkup glTemplateMarkup;
40 typedef struct _glTemplateOrigin glTemplateOrigin;
43 * Top-level Template Structure
53 /* List of (gchar *) category ids. */
56 /* List of (glTemplateLabelType *) label type structures.
57 * Currently glabels only supports a single label type per
61 /* List of (gchar *) aliases. */
68 * Possible Label Shapes
71 GL_TEMPLATE_SHAPE_RECT,
72 GL_TEMPLATE_SHAPE_ROUND,
74 } glTemplateLabelShape;
78 * Label Type Structure
80 struct _glTemplateLabelType{
82 gchar *id; /* Id, currently always "0" */
83 GList *layouts; /* List of glTemplateLayouts */
84 GList *markups; /* List of glTemplateMarkups */
86 glTemplateLabelShape shape;
91 gdouble w; /* Width */
92 gdouble h; /* Height */
93 gdouble r; /* Corner radius */
94 gdouble x_waste; /* Amount of horiz overprint allowed. */
95 gdouble y_waste; /* Amount of vert overprint allowed. */
99 gdouble r; /* Radius */
100 gdouble waste; /* Amount of overprint allowed. */
105 gdouble r1; /* Outer radius */
106 gdouble r2; /* Inner radius (hole) */
107 gdouble w; /* Clip width, business card CDs */
108 gdouble h; /* Clip height, business card CDs */
109 gdouble waste; /* Amount of overprint allowed. */
118 * Label Layout Structure
120 struct _glTemplateLayout {
122 gint nx; /* Number of labels across */
123 gint ny; /* Number of labels up and down */
125 gdouble x0; /* Left of grid from left edge of paper */
126 gdouble y0; /* Top of grid from top edge of paper */
128 gdouble dx; /* Horizontal pitch of grid */
129 gdouble dy; /* Vertical pitch of grid */
135 * Possible Markup Types
138 GL_TEMPLATE_MARKUP_MARGIN,
139 GL_TEMPLATE_MARKUP_LINE,
140 GL_TEMPLATE_MARKUP_CIRCLE,
141 } glTemplateMarkupType;
145 * Label Markup Structure (Helpful lines drawn in glabels to help locate objects)
147 struct _glTemplateMarkup {
149 glTemplateMarkupType type;
154 gdouble size; /* Margin size */
158 gdouble x1, y1; /* 1st endpoint */
159 gdouble x2, y2; /* 2nd endpoint */
163 gdouble x0, y0; /* Center of circle */
164 gdouble r; /* Radius of circle */
175 struct _glTemplateOrigin {
177 gdouble x, y; /* Label origin relative to upper
178 * upper left hand corner of paper */
185 * Module Initialization
187 void gl_template_init (void);
189 void gl_template_register (const glTemplate *template);
192 * Known templates query functions
194 GList *gl_template_get_name_list (const gchar *page_size,
195 const gchar *category);
197 void gl_template_free_name_list (GList *names);
199 glTemplate *gl_template_from_name (const gchar *name);
203 * Template query functions
205 gchar *gl_template_get_name_with_desc (const glTemplate *template);
207 const glTemplateLabelType *gl_template_get_first_label_type (const glTemplate *template);
209 gboolean gl_template_does_page_size_match (const glTemplate *template,
210 const gchar *page_size);
212 gboolean gl_template_does_category_match (const glTemplate *template,
213 const gchar *category);
217 * Label Type query functions
219 void gl_template_get_label_size (const glTemplateLabelType *label_type,
223 gint gl_template_get_n_labels (const glTemplateLabelType *label_type);
225 glTemplateOrigin *gl_template_get_origins (const glTemplateLabelType *label_type);
229 * Template Construction
231 glTemplate *gl_template_new (const gchar *name,
232 const gchar *description,
233 const gchar *page_size,
235 gdouble page_height);
237 void gl_template_add_category (glTemplate *template,
238 const gchar *category);
240 void gl_template_add_label_type (glTemplate *template,
241 glTemplateLabelType *label_type);
243 void gl_template_add_alias (glTemplate *template,
246 glTemplateLabelType *gl_template_rect_label_type_new (const gchar *id,
253 glTemplateLabelType *gl_template_round_label_type_new (const gchar *id,
257 glTemplateLabelType *gl_template_cd_label_type_new (const gchar *id,
264 void gl_template_add_layout (glTemplateLabelType *label_type,
265 glTemplateLayout *layout);
267 void gl_template_add_markup (glTemplateLabelType *label_type,
268 glTemplateMarkup *markup);
270 glTemplateLayout *gl_template_layout_new (gint nx,
277 glTemplateMarkup *gl_template_markup_margin_new (gdouble size);
279 glTemplateMarkup *gl_template_markup_line_new (gdouble x1,
284 glTemplateMarkup *gl_template_markup_circle_new (gdouble x0,
288 glTemplate *gl_template_dup (const glTemplate *orig);
290 void gl_template_free (glTemplate *template);
292 glTemplateLabelType *gl_template_label_type_dup (const glTemplateLabelType *orig_ltype);
293 void gl_template_label_type_free (glTemplateLabelType *ltype);
295 glTemplateLayout *gl_template_layout_dup (const glTemplateLayout *orig_layout);
296 void gl_template_layout_free (glTemplateLayout *layout);
298 glTemplateMarkup *gl_template_markup_dup (const glTemplateMarkup *orig_markup);
299 void gl_template_markup_free (glTemplateMarkup *markup);
303 * Debugging functions
305 void gl_template_print_known_templates (void);
306 void gl_template_print_aliases (const glTemplate *template);