]> git.sur5r.net Git - glabels/blob - libglabels/template.h
Imported Upstream version 2.2.8
[glabels] / libglabels / template.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
2
3 /*
4  *  (LIBGLABELS) Template library for GLABELS
5  *
6  *  template.h:  template module header file
7  *
8  *  Copyright (C) 2001-2006  Jim Evins <evins@snaught.com>.
9  *
10  *  This file is part of the LIBGLABELS library.
11  *
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.
16  *
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.
21  *
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,
25  *  MA 02111-1307, USA
26  */
27
28 #ifndef __TEMPLATE_H__
29 #define __TEMPLATE_H__
30
31 #include <glib/gtypes.h>
32 #include <glib/glist.h>
33
34 G_BEGIN_DECLS
35
36 typedef struct _lglTemplate                lglTemplate;
37
38 typedef struct _lglTemplateAlias           lglTemplateAlias;
39
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;
45
46 typedef struct _lglTemplateLayout          lglTemplateLayout;
47
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;
53
54 typedef struct _lglTemplateOrigin          lglTemplateOrigin;
55
56 /*
57  *   Top-level Template Structure
58  */
59 struct _lglTemplate {
60
61         gchar               *brand;
62         gchar               *part;
63         gchar               *description;
64         gchar               *paper_id;
65         gdouble              page_width;
66         gdouble              page_height;
67
68         /* List of (lglTemplateAlias *) aliase structures. */
69         GList               *aliases;
70
71         /* List of (gchar *) category ids. */
72         GList               *category_ids;
73
74         /* List of (lglTemplateFrame *) label frame structures.
75          * Currently glabels only supports a single label frame per
76          * template. */
77         GList               *frames;
78
79 };
80
81
82 /*
83  *   Top-level Template Structure
84  */
85 struct _lglTemplateAlias {
86
87         gchar               *brand;
88         gchar               *part;
89
90 };
91
92 /*
93  *   Possible Frame Shapes
94  */
95 typedef enum {
96         LGL_TEMPLATE_FRAME_SHAPE_RECT,
97         LGL_TEMPLATE_FRAME_SHAPE_ROUND,
98         LGL_TEMPLATE_FRAME_SHAPE_CD,
99 } lglTemplateFrameShape;
100
101
102 /*
103  *   Frame Structure
104  */
105 struct _lglTemplateFrameAll {
106
107         /* Begin Common Fields */
108         lglTemplateFrameShape shape;
109
110         gchar                *id;       /* Id, currently always "0" */
111         GList                *layouts;  /* List of lglTemplateLayouts */
112         GList                *markups;  /* List of lglTemplateMarkups */
113         /* End Common Fields */
114 };
115
116 struct _lglTemplateFrameRect {
117
118         /* Begin Common Fields */
119         lglTemplateFrameShape shape;    /* Always LGL_TEMPLATE_FRAME_SHAPE_RECT. */
120
121         gchar                *id;       /* Id, currently always "0" */
122         GList                *layouts;  /* List of lglTemplateLayouts */
123         GList                *markups;  /* List of lglTemplateMarkups */
124         /* End Common Fields */
125
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. */
131 };
132
133 struct _lglTemplateFrameRound {
134
135         /* Begin Common Fields */
136         lglTemplateFrameShape shape;    /* Always LGL_TEMPLATE_FRAME_SHAPE_ROUND. */
137
138         gchar                *id;       /* Id, currently always "0" */
139         GList                *layouts;  /* List of lglTemplateLayouts */
140         GList                *markups;  /* List of lglTemplateMarkups */
141         /* End Common Fields */
142
143         gdouble               r;      /* Radius */
144         gdouble               waste;  /* Amount of overprint allowed. */
145 };
146
147 struct _lglTemplateFrameCD {
148
149         /* Begin Common Fields */
150         lglTemplateFrameShape shape;    /* Always LGL_TEMPLATE_FRAME_SHAPE_CD. */
151
152         gchar                *id;       /* Id, currently always "0" */
153         GList                *layouts;  /* List of lglTemplateLayouts */
154         GList                *markups;  /* List of lglTemplateMarkups */
155         /* End Common Fields */
156
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. */
162 };
163
164 union _lglTemplateFrame{
165
166         lglTemplateFrameShape shape;
167
168         lglTemplateFrameAll   all;
169         lglTemplateFrameRect  rect;
170         lglTemplateFrameRound round;
171         lglTemplateFrameCD    cd;
172 };
173
174
175 /*
176  *   Label Layout Structure
177  */
178 struct _lglTemplateLayout {
179
180         gint                  nx;  /* Number of labels across */
181         gint                  ny;  /* Number of labels up and down */
182
183         gdouble               x0;  /* Left of grid from left edge of paper */
184         gdouble               y0;  /* Top of grid from top edge of paper */
185
186         gdouble               dx;  /* Horizontal pitch of grid */
187         gdouble               dy;  /* Vertical pitch of grid */
188
189 };
190
191
192 /*
193  * Possible Markup Types
194  */
195 typedef enum {
196         LGL_TEMPLATE_MARKUP_MARGIN,
197         LGL_TEMPLATE_MARKUP_LINE,
198         LGL_TEMPLATE_MARKUP_CIRCLE,
199         LGL_TEMPLATE_MARKUP_RECT,
200 } lglTemplateMarkupType;
201
202
203 /*
204  *   Label Markup Structure (Helpful lines drawn in glabels to help locate objects)
205  */
206 struct _lglTemplateMarkupMargin {
207
208         lglTemplateMarkupType  type;  /* Always LGL_TEMPLATE_MARKUP_MARGIN */
209
210         gdouble                size;  /* Margin size */
211 };
212
213 struct _lglTemplateMarkupLine {
214
215         lglTemplateMarkupType  type;   /* Always LGL_TEMPLATE_MARKUP_LINE */
216
217         gdouble                x1, y1; /* 1st endpoint */
218         gdouble                x2, y2; /* 2nd endpoint */
219 };
220
221 struct _lglTemplateMarkupCircle {
222
223         lglTemplateMarkupType  type;   /* Always LGL_TEMPLATE_MARKUP_CIRCLE */
224
225         gdouble                x0, y0; /* Center of circle */
226         gdouble                r;      /* Radius of circle */
227 };
228
229 struct _lglTemplateMarkupRect {
230
231         lglTemplateMarkupType  type;   /* Always LGL_TEMPLATE_MARKUP_RECT */
232
233         gdouble                x1, y1; /* Upper left corner */
234         gdouble                w, h;   /* Width and height. */
235         gdouble                r;      /* Radius of corners. */
236 };
237
238 union _lglTemplateMarkup {
239
240         lglTemplateMarkupType   type;
241
242         lglTemplateMarkupMargin margin;
243         lglTemplateMarkupLine   line;
244         lglTemplateMarkupCircle circle;
245         lglTemplateMarkupRect   rect;
246 };
247
248
249 /*
250  *  Origin coordinates
251  */
252 struct _lglTemplateOrigin {
253
254         gdouble               x, y; /* Label origin relative to upper 
255                                      * upper left hand corner of paper */
256
257 };
258
259
260
261 /* 
262  * Template query functions
263  */
264 gchar                     *lgl_template_get_name             (const lglTemplate   *template);
265
266 gboolean                   lgl_template_do_templates_match   (const lglTemplate   *template1,
267                                                               const lglTemplate   *template2);
268
269 gboolean                   lgl_template_does_brand_match     (const lglTemplate   *template,
270                                                               const gchar         *brand);
271
272 gboolean                   lgl_template_does_page_size_match (const lglTemplate   *template,
273                                                               const gchar         *paper_id);
274
275 gboolean                   lgl_template_does_category_match  (const lglTemplate   *template,
276                                                               const gchar         *category_id);
277
278
279 /*
280  * Frame query functions
281  */
282 void                 lgl_template_frame_get_size       (const lglTemplateFrame    *frame,
283                                                         gdouble                   *w,
284                                                         gdouble                   *h);
285
286 gint                 lgl_template_frame_get_n_labels   (const lglTemplateFrame    *frame);
287
288 lglTemplateOrigin   *lgl_template_frame_get_origins    (const lglTemplateFrame    *frame);
289
290
291 /*
292  * Template Construction
293  */
294 lglTemplate         *lgl_template_new                  (const gchar          *brand,
295                                                         const gchar          *part,
296                                                         const gchar          *description,
297                                                         const gchar          *paper_id,
298                                                         gdouble               page_width,
299                                                         gdouble               page_height);
300
301 void                 lgl_template_add_alias            (lglTemplate          *template,
302                                                         lglTemplateAlias     *alias);
303
304 void                 lgl_template_add_category         (lglTemplate          *template,
305                                                         const gchar          *category_id);
306
307 void                 lgl_template_add_frame            (lglTemplate          *template,
308                                                         lglTemplateFrame     *frame);
309
310 lglTemplateFrame    *lgl_template_frame_rect_new       (const gchar          *id,
311                                                         gdouble               w,
312                                                         gdouble               h,
313                                                         gdouble               r,
314                                                         gdouble               x_waste,
315                                                         gdouble               y_waste);
316
317 lglTemplateAlias    *lgl_template_alias_new            (const gchar          *brand,
318                                                         const gchar          *part);
319
320 lglTemplateFrame    *lgl_template_frame_round_new      (const gchar          *id,
321                                                         gdouble               r,
322                                                         gdouble               waste);
323
324 lglTemplateFrame    *lgl_template_frame_cd_new         (const gchar          *id,
325                                                         gdouble               r1,
326                                                         gdouble               r2,
327                                                         gdouble               w,
328                                                         gdouble               h,
329                                                         gdouble               waste);
330
331 void                 lgl_template_frame_add_layout     (lglTemplateFrame     *frame,
332                                                         lglTemplateLayout    *layout);
333
334 void                 lgl_template_frame_add_markup     (lglTemplateFrame     *frame,
335                                                         lglTemplateMarkup    *markup);
336
337 lglTemplateLayout   *lgl_template_layout_new           (gint                  nx,
338                                                         gint                  ny,
339                                                         gdouble               x0,
340                                                         gdouble               y0,
341                                                         gdouble               dx,
342                                                         gdouble               dy);
343
344 lglTemplateMarkup   *lgl_template_markup_margin_new    (gdouble               size);
345
346 lglTemplateMarkup   *lgl_template_markup_line_new      (gdouble               x1,
347                                                         gdouble               y1,
348                                                         gdouble               x2,
349                                                         gdouble               y2);
350
351 lglTemplateMarkup   *lgl_template_markup_circle_new    (gdouble               x0,
352                                                         gdouble               y0,
353                                                         gdouble               r);
354
355 lglTemplateMarkup   *lgl_template_markup_rect_new      (gdouble               x1,
356                                                         gdouble               y1,
357                                                         gdouble               w,
358                                                         gdouble               h,
359                                                         gdouble               r);
360
361 lglTemplate         *lgl_template_dup                  (const lglTemplate    *orig_template);
362
363 void                 lgl_template_free                 (lglTemplate          *template);
364
365 lglTemplateAlias    *lgl_template_alias_dup            (const lglTemplateAlias     *orig_alias);
366 void                 lgl_template_alias_free           (lglTemplateAlias           *alias);
367
368 lglTemplateFrame    *lgl_template_frame_dup            (const lglTemplateFrame     *orig_frame);
369 void                 lgl_template_frame_free           (lglTemplateFrame           *frame);
370
371 lglTemplateLayout   *lgl_template_layout_dup           (const lglTemplateLayout    *orig_layout);
372 void                 lgl_template_layout_free          (lglTemplateLayout          *layout);
373
374 lglTemplateMarkup   *lgl_template_markup_dup           (const lglTemplateMarkup    *orig_markup);
375 void                 lgl_template_markup_free          (lglTemplateMarkup          *markup);
376
377
378 G_END_DECLS
379
380 #endif