Incorporated glbarcode library into source tree.

This commit is contained in:
Jim Evins
2017-04-09 19:14:13 -04:00
parent 76bd5a0c6b
commit b17cea7ace
47 changed files with 6290 additions and 0 deletions
+195
View File
@@ -0,0 +1,195 @@
/* Barcode.cpp
*
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
*
* This file is part of glbarcode++.
*
* glbarcode++ is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* glbarcode++ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with glbarcode++. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Barcode.h"
#include <list>
#include "DrawingPrimitives.h"
namespace glbarcode
{
/*
* Barcode private data
*/
struct Barcode::PrivateData {
bool mShowTextFlag; /**< Display text flag */
bool mChecksumFlag; /**< Add checksum flag */
double mW; /**< Width of barcode (points) */
double mH; /**< Height of barcode (points) */
bool mIsEmpty; /**< Empty data flag */
bool mIsDataValid; /**< Valid data flag */
std::list<DrawingPrimitive *> mPrimitives; /**< List of drawing primitives */
};
Barcode::Barcode()
{
d = new Barcode::PrivateData;
d->mShowTextFlag = false;
d->mChecksumFlag = false;
d->mW = 0;
d->mH = 0;
d->mIsEmpty = true;
d->mIsDataValid = false;
}
Barcode::~Barcode()
{
clear(); /* Clear drawing primitives. */
delete d;
}
Barcode& Barcode::setShowText( bool value )
{
d->mShowTextFlag = value;
return *this;
}
bool Barcode::showText( void ) const
{
return d->mShowTextFlag;
}
Barcode& Barcode::setChecksum( bool value )
{
d->mChecksumFlag = value;
return *this;
}
bool Barcode::checksum( void ) const
{
return d->mChecksumFlag;
}
void Barcode::render( Renderer& renderer )
{
renderer.render( d->mW, d->mH, d->mPrimitives );
}
bool Barcode::isEmpty( void ) const
{
return d->mIsEmpty;
}
void Barcode::setIsEmpty( bool value )
{
d->mIsEmpty = value;
}
bool Barcode::isDataValid( void ) const
{
return d->mIsDataValid;
}
void Barcode::setIsDataValid( bool value )
{
d->mIsDataValid = value;
}
double Barcode::width( void ) const
{
return d->mW;
}
double Barcode::height( void ) const
{
return d->mH;
}
void Barcode::setWidth( double w )
{
d->mW = w;
}
void Barcode::setHeight( double h )
{
d->mH = h;
}
void Barcode::clear( void )
{
std::list<DrawingPrimitive*>::iterator primitive;
for ( primitive = d->mPrimitives.begin(); primitive != d->mPrimitives.end(); primitive++ )
{
delete *primitive;
}
d->mPrimitives.clear();
}
void Barcode::addLine( double x, double y, double w, double h )
{
d->mPrimitives.push_back( new DrawingPrimitiveLine( x, y, w, h ) );
}
void Barcode::addBox( double x, double y, double w, double h )
{
d->mPrimitives.push_back( new DrawingPrimitiveBox( x, y, w, h ) );
}
void Barcode::addText( double x, double y, double size, const std::string& text )
{
d->mPrimitives.push_back( new DrawingPrimitiveText( x, y, size, text ) );
}
void Barcode::addRing( double x, double y, double r, double w )
{
d->mPrimitives.push_back( new DrawingPrimitiveRing( x, y, r, w ) );
}
void Barcode::addHexagon( double x, double y, double h )
{
d->mPrimitives.push_back( new DrawingPrimitiveHexagon( x, y, h ) );
}
}