/*************************************************************************** * Copyright (C) 2004 by Johan Maes - ON4QZ * * on4qz@telenet.be * * http://users.telenet.be/on4qz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (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 * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "canvasitems.h" #include "effects.h" #include #include #include #include "configdialog.h" canvasItemBase::canvasItemBase(QCanvas *cnv):QCanvasRectangle(cnv),itemRect(0,0,1,1) { final=FALSE; locked=FALSE; gradient=0; angle=0;shear=0.; font.setFamily("Helvetica"); } void canvasItemBase::setParam(scanvasItemParam ¶m,int depth) { setGeometry(param.rect.topLeft(),param.rect.bottomRight()); text=param.text; fullImage=param.img; //debug("setting full image"); setShear(param.shear); setRotate(param.angle); locked=param.locked; foreground=(param.foreground); background=(param.background); lineWidth=(param.lineWidth); font=param.font; gradient=param.gradient; setZ(depth); } void canvasItemBase::getParam(scanvasItemParam ¶m) { param.rect=itemRect; param.text=text; param.img=fullImage; param.shear=shear; param.angle=angle; param.locked=locked; param.type=rtti(); param.foreground=foreground; param.background=background; param.lineWidth=lineWidth; param.font=font; param.gradient=gradient; } void canvasItemBase::setGeometry(QPoint start,QPoint end) { negSlope=TRUE; if((( start.x()<=end.x())&&(start.y()<=end.y())) || (( start.x()>=end.x())&&(start.y()>=end.y()))) { negSlope=FALSE; } itemRect.setTopLeft(start); itemRect.setBottomRight(end); if(itemRect.width()==0) itemRect.setWidth(1); if(itemRect.height()==0) itemRect.setHeight(1); // notNormalizedItemRect=itemRect; itemRect=itemRect.normalize(); setX(itemRect.x()); setY(itemRect.y()); setSize(itemRect.width(),itemRect.height()); updateActiveImage(); // changed=TRUE; } void canvasItemBase::moveBy(int x,int y) { itemRect.moveBy(x,y); QCanvasRectangle::moveBy(x,y); } void canvasItemBase::applyColors(QColor fg,QColor bg,int lW) { foreground=fg; background=bg; lineWidth=lW; updateActiveImage(); } void canvasItemBase::changeFont(QFont newFont) { font=newFont; updateActiveImage(); } void canvasItemBase::load(QDataStream &str) { //debug("load"); QColor fg; QColor bg; Q_UINT32 lw; QSize sz; Q_UINT32 z,bl; QPoint startP,endP; str >> foreground; str >> background; str >> lw; lineWidth=lw; str >>startP; //startPoint str >>endP; // endPoint str >> z; // depth str >> bl; // locked locked=bl; str >> gradient; str >> shear; str >> angle; setShear(shear); setRotate(angle); str >> text; str>>font; setZ(z); create(startP,endP); setVisible(TRUE); if(rtti()==imageRTTI) { str >> fullImage; setFinal(TRUE); } } void canvasItemBase::save(QDataStream &str) { // save type str << (Q_INT16) rtti (); str << foreground; str << background; str << (Q_UINT32) lineWidth; str << startPoint() << endPoint(); str << (Q_UINT32) z(); str << (Q_UINT32)locked; str << (Q_UINT32) gradient; str << shear; str << angle; str << text; str <