2008-07-18 18:49:14 +04:00
/***************************************************************************
2008-09-17 22:38:53 +04:00
* Copyright ( C ) 2008 by BogDan Vatra *
* bogdan @ licentia . eu *
2023-06-12 03:25:55 +03:00
* Copyright ( C ) 2009 - 2023 by Robin Stuart < rstuart114 @ gmail . com > *
2008-07-18 18:49:14 +04:00
* *
2008-09-17 22:38:53 +04:00
* This program is free software : you can redistribute it and / or modify *
2008-07-18 18:49:14 +04:00
* it under the terms of the GNU General Public License as published by *
2008-09-17 22:38:53 +04:00
* the Free Software Foundation , either version 3 of the License , or *
2008-07-18 18:49:14 +04:00
* ( at your option ) any later version . *
* This program 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 General Public License for more details . *
* You should have received a copy of the GNU General Public License *
2008-09-17 22:38:53 +04:00
* along with this program . If not , see < http : //www.gnu.org/licenses/>. *
2008-07-18 18:49:14 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2021-06-24 20:31:08 +03:00
/* vim: set ts=4 sw=4 et : */
2008-07-18 18:49:14 +04:00
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 02:13:39 +03:00
//#include <QDebug>
2008-07-18 18:49:14 +04:00
# include "barcodeitem.h"
BarcodeItem : : BarcodeItem ( )
2021-06-24 20:31:08 +03:00
: QGraphicsItem ( )
2008-07-18 18:49:14 +04:00
{
2021-06-24 20:31:08 +03:00
w = 693 ;
h = 378 ; // Default widget size when created
2008-07-18 18:49:14 +04:00
}
BarcodeItem : : ~ BarcodeItem ( )
{
}
2016-12-15 02:33:17 +03:00
void BarcodeItem : : setSize ( int width , int height ) {
w = width ;
h = height ;
}
2023-06-12 03:25:55 +03:00
void BarcodeItem : : setColor ( const QColor & color ) {
m_color = color ;
}
2008-07-18 18:49:14 +04:00
QRectF BarcodeItem : : boundingRect ( ) const
{
2021-06-24 20:31:08 +03:00
return QRectF ( 0 , 0 , w , h ) ;
2008-07-18 18:49:14 +04:00
}
2021-06-24 20:31:08 +03:00
void BarcodeItem : : paint ( QPainter * painter , const QStyleOptionGraphicsItem * /*option*/ , QWidget * /*widget*/ )
2008-07-18 18:49:14 +04:00
{
2023-06-12 03:25:55 +03:00
QRectF painterRect = boundingRect ( ) ;
if ( m_color . isValid ( ) ) {
painter - > fillRect ( painterRect , m_color ) ;
}
bc . render ( * painter , painterRect ) ;
2008-07-18 18:49:14 +04:00
}