glbarcode++
 
Loading...
Searching...
No Matches
Barcode.hpp
Go to the documentation of this file.
1// Barcode.hpp
2//
3// Copyright (C) 2013-2026 Jaye Evins <evins@snaught.com>
4//
5// This file is part of glbarcode++.
6//
7// glbarcode++ 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// glbarcode++ 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 glbarcode++. If not, see <http://www.gnu.org/licenses/>.
19//
20
21#ifndef glbarcode_Barcode_hpp
22#define glbarcode_Barcode_hpp
23
24
25#include <string>
26
27#include "Enums.hpp"
28#include "Renderer.hpp"
29
30
34extern "C" struct gbcBarcode {};
35
36
37namespace glbarcode
38{
39
51 class Barcode : public gbcBarcode
52 {
53
54 protected:
59
60
61 public:
65 virtual ~Barcode();
66
67 /*
68 * Non-copyable
69 */
70 Barcode( const Barcode & ) = delete;
71 void operator=( const Barcode & ) = delete;
72
82 Barcode& setShowText( bool value );
83
84
92 bool showText() const;
93
94
104 Barcode& setChecksum( bool value );
105
106
114 bool checksum() const;
115
116
126 virtual Barcode& build( const std::string& data,
127 double w = 0,
128 double h = 0 ) = 0;
129
130
136 void render( Renderer& renderer );
137
138
147 bool isEmpty() const;
148
149
158 bool isDataValid() const;
159
160
168 double width() const;
169
170
178 double height() const;
179
180
181 protected:
185 void clear();
186
187
200 void addLine( double x, double y, double w, double h );
201
202
215 void addBox( double x, double y, double w, double h );
216
217
231 void addText( double x, double y, double size, const std::string& text, HAlign halign = H_ALIGN_CENTER );
232
233
246 void addRing( double x, double y, double r, double w );
247
248
260 void addHexagon( double x, double y, double h );
261
262
272 void setIsEmpty( bool value );
273
274
284 void setIsDataValid( bool value );
285
286
296 void setWidth( double w );
297
298
308 void setHeight( double h );
309
310
311 private:
315 struct PrivateData;
316 PrivateData *d;
317
318 };
319
320}
321
322
323#endif // glbarcode_Barcode_hpp
Definition Barcode.hpp:52
bool isEmpty() const
bool checksum() const
void setHeight(double h)
bool isDataValid() const
Barcode(const Barcode &)=delete
void setIsDataValid(bool value)
void setIsEmpty(bool value)
void addHexagon(double x, double y, double h)
double width() const
void addBox(double x, double y, double w, double h)
void operator=(const Barcode &)=delete
void addLine(double x, double y, double w, double h)
virtual Barcode & build(const std::string &data, double w=0, double h=0)=0
bool showText() const
Barcode & setChecksum(bool value)
double height() const
void render(Renderer &renderer)
void addText(double x, double y, double size, const std::string &text, HAlign halign=H_ALIGN_CENTER)
void addRing(double x, double y, double r, double w)
void setWidth(double w)
Barcode & setShowText(bool value)
Definition Renderer.hpp:48
Definition Barcode.hpp:38
HAlign
Definition Enums.hpp:29
@ H_ALIGN_CENTER
Definition Enums.hpp:30
Definition Barcode.hpp:34