]> git.sur5r.net Git - glabels/blob - glabels2/src/template.h
- View now tracks label resize events.
[glabels] / glabels2 / src / template.h
1 /*
2  *  (GLABELS) Label and Business Card Creation program for GNOME
3  *
4  *  template.h:  template module header file
5  *
6  *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21  */
22
23 #ifndef __TEMPLATE_H__
24 #define __TEMPLATE_H__
25
26 #include <libgnome/libgnome.h>
27
28 G_BEGIN_DECLS
29
30 /*
31  *   Template Label Structure
32  */
33 typedef enum {
34         GL_TEMPLATE_STYLE_RECT,
35         GL_TEMPLATE_STYLE_ROUND,
36         GL_TEMPLATE_STYLE_CD,
37 } glTemplateLabelStyle;
38
39 typedef struct {
40         glTemplateLabelStyle  style;
41         GList                *layouts;  /* List of glTemplateLayouts */
42         GList                *markups;  /* List of glTemplateMarkups */
43 } glTemplateLabelParent;
44
45 typedef struct {
46         glTemplateLabelParent parent;
47
48         gdouble               w, h, r;  /* Dimensions */
49 } glTemplateLabelRect;
50
51 typedef struct {
52         glTemplateLabelParent parent;
53
54         gdouble               r;        /* Dimensions */
55 } glTemplateLabelRound;
56
57 typedef struct {
58         glTemplateLabelParent parent;
59
60         gdouble               r1, r2, w, h; /* Dimensions, w&h are for business card CDs */
61 } glTemplateLabelCD;
62
63 typedef union {
64         glTemplateLabelStyle  style;
65         glTemplateLabelParent any;
66         glTemplateLabelRect   rect;
67         glTemplateLabelRound  round;
68         glTemplateLabelCD     cd;
69 } glTemplateLabel;
70
71
72 /*
73  *   Label Markup
74  */
75 typedef enum {
76         GL_TEMPLATE_MARKUP_MARGIN,
77         GL_TEMPLATE_MARKUP_LINE,
78 } glTemplateMarkupType;
79
80 typedef struct {
81         /* NOTE: These fields are common to all union members. */
82         glTemplateMarkupType   type;
83 } glTemplateMarkupParent;
84
85 typedef struct {
86         glTemplateMarkupParent parent;
87
88         gdouble                size;
89 } glTemplateMarkupMargin;
90
91 typedef struct {
92         glTemplateMarkupParent parent;
93
94         gdouble                x1, y1, x2, y2;
95 } glTemplateMarkupLine;
96
97 typedef union {
98         glTemplateMarkupType   type;
99         glTemplateMarkupParent any;
100         glTemplateMarkupMargin margin;
101         glTemplateMarkupLine   line;
102 } glTemplateMarkup;
103
104
105 /*
106  *   Label layout
107  */
108 typedef struct {
109         gint nx, ny;
110         gdouble x0, y0, dx, dy;
111 } glTemplateLayout;
112
113
114 /*
115  *   Template
116  */
117 typedef struct {
118         gchar               *name;
119         gchar               *description;
120         gchar               *page_size;
121         gdouble              page_width;
122         gdouble              page_height;
123
124         glTemplateLabel      label;
125
126         GList               *alias;
127 } glTemplate;
128
129
130 /*
131  *  Origin coordinates
132  */
133 typedef struct {
134         gdouble x, y;
135 } glTemplateOrigin;
136
137
138 void                 gl_template_init                (void);
139
140 GList               *gl_template_get_name_list       (const gchar       *page_size);
141 void                 gl_template_free_name_list      (GList            **names);
142
143 glTemplate          *gl_template_from_name           (const gchar       *name);
144
145 gchar               *gl_template_get_name_with_desc  (const glTemplate  *template);
146
147 glTemplate          *gl_template_dup                 (const glTemplate  *orig);
148 void                 gl_template_free                (glTemplate       **template);
149
150 gchar               *gl_template_get_label_size_desc (const glTemplate  *template);
151 void                 gl_template_get_label_size      (const glTemplate  *template,
152                                                       gdouble           *w,
153                                                       gdouble           *h);
154
155 gint                 gl_template_get_n_labels        (const glTemplate  *template);
156 glTemplateOrigin    *gl_template_get_origins         (const glTemplate  *template);
157 gchar               *gl_template_get_layout_desc     (const glTemplate  *template);
158
159 glTemplateLayout    *gl_template_layout_new          (gdouble            nx,
160                                                       gdouble            ny,
161                                                       gdouble            x0,
162                                                       gdouble            y0,
163                                                       gdouble            dx,
164                                                       gdouble            dy);
165
166 glTemplateMarkup    *gl_template_markup_margin_new   (gdouble            size);
167 glTemplateMarkup    *gl_template_markup_line_new     (gdouble            x1,
168                                                       gdouble            y1,
169                                                       gdouble            x2,
170                                                       gdouble            y2);
171
172
173 G_END_DECLS
174
175 #endif