]> git.sur5r.net Git - glabels/blob - src/bc.h
909f74f24da9941c20a946a6cf055845f4fcdd0d
[glabels] / src / bc.h
1 /*
2  *  bc.h
3  *  Copyright (C) 2001-2009  Jim Evins <evins@snaught.com>.
4  *
5  *  This file is part of gLabels.
6  *
7  *  gLabels is free software: you can redistribute it and/or modify
8  *  it under the terms of the GNU 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  *  gLabels 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 General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with gLabels.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #ifndef __BC_H__
22 #define __BC_H__
23
24 #include <glib.h>
25 #include <pango/pango.h>
26
27 G_BEGIN_DECLS
28
29 typedef enum {
30         GL_BARCODE_SHAPE_LINE,
31         GL_BARCODE_SHAPE_ALPHA,
32 } glBarcodeShapeType;
33
34 typedef struct {
35
36         /* Begin Common Fields */
37         glBarcodeShapeType  type;
38         gdouble             x;
39         gdouble             y;
40         /* End Common Fields */
41
42 } glBarcodeShapeAny;
43
44 /*
45  * glBarcodeShapeLine:
46  *
47  * @ =  origin (x,y) from top left corner of barcode
48  *
49  *              +--@--+
50  *              |     |
51  *              |     |
52  *              |     |
53  *              |     | length
54  *              |     |
55  *              |     |
56  *              |     |
57  *              +-----+
58  *               width
59  */
60 typedef struct {
61
62         /* Begin Common Fields */
63         glBarcodeShapeType  type; /* Always GL_BARCODE_SHAPE_LINE. */
64         gdouble             x;
65         gdouble             y;
66         /* End Common Fields */
67
68         gdouble             length;
69         gdouble             width;
70
71 } glBarcodeShapeLine;
72
73 /*
74  * glBarcodeShapeAlpha:
75  *
76  * @ =  origin (x,y) from top left corner of barcode
77  *
78  *              ____ ------------
79  *             /    \           ^
80  *            /  /\  \          |
81  *           /  /__\  \         |
82  *          /  ______  \        | ~fsize
83  *         /  /      \  \       |
84  *        /__/        \__\      |
85  *                              v
86  *       @ ----------------------
87  */
88 typedef struct {
89
90         /* Begin Common Fields */
91         glBarcodeShapeType  type; /* Always GL_BARCODE_SHAPE_ALPHA. */
92         gdouble             x;
93         gdouble             y;
94         /* End Common Fields */
95
96         gdouble             fsize;
97         gchar               c;
98
99 } glBarcodeShapeAlpha;
100
101 typedef union {
102
103         glBarcodeShapeType    type;
104         glBarcodeShapeAny     any;
105
106         glBarcodeShapeLine    line;
107         glBarcodeShapeAlpha   alpha;
108
109 } glBarcodeShape;
110
111 typedef struct {
112         gdouble width, height;
113         GList *shapes;          /* List of glBarcodeShape */
114 } glBarcode;
115
116 typedef glBarcode *(*glBarcodeNewFunc) (const gchar    *id,
117                                         gboolean        text_flag,
118                                         gboolean        checksum_flag,
119                                         gdouble         w,
120                                         gdouble         h,
121                                         const gchar    *digits);
122
123
124 #define GL_BARCODE_FONT_FAMILY      "Sans"
125 #define GL_BARCODE_FONT_WEIGHT      PANGO_WEIGHT_NORMAL
126
127
128 glBarcodeShapeLine  *gl_barcode_shape_line_new  (void);
129 glBarcodeShapeAlpha *gl_barcode_shape_alpha_new (void);
130
131 glBarcode       *gl_barcode_new              (const gchar    *id,
132                                               gboolean        text_flag,
133                                               gboolean        checksum_flag,
134                                               gdouble         w,
135                                               gdouble         h,
136                                               const gchar    *digits);
137
138 void             gl_barcode_free             (glBarcode     **bc);
139
140 void             gl_barcode_add_shape        (glBarcode      *bc,
141                                               glBarcodeShape *shape);
142
143 GList           *gl_barcode_get_styles_list  (void);
144 void             gl_barcode_free_styles_list (GList          *styles_list);
145
146 gchar           *gl_barcode_default_digits   (const gchar    *id,
147                                               guint            n);
148
149 gboolean         gl_barcode_can_text         (const gchar    *id);
150 gboolean         gl_barcode_text_optional    (const gchar    *id);
151
152 gboolean         gl_barcode_can_csum         (const gchar    *id);
153 gboolean         gl_barcode_csum_optional    (const gchar    *id);
154
155 gboolean         gl_barcode_can_freeform     (const gchar    *id);
156 guint            gl_barcode_get_prefered_n   (const gchar    *id);
157
158 const gchar     *gl_barcode_id_to_name       (const gchar    *id);
159 const gchar     *gl_barcode_name_to_id       (const gchar    *name);
160
161 G_END_DECLS
162
163 #endif /* __BC_H__ */
164
165
166
167 /*
168  * Local Variables:       -- emacs
169  * mode: C                -- emacs
170  * c-basic-offset: 8      -- emacs
171  * tab-width: 8           -- emacs
172  * indent-tabs-mode: nil  -- emacs
173  * End:                   -- emacs
174  */