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