Rev 2272 |
Rev 2309 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/***************************************************************************
scribusview.cpp - description
-------------------
begin : Fre Apr 6 21:47:55 CEST 2001
copyright : (C) 2001 by Franz Schmid
email : Franz.Schmid@altmuehlnet.de
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#include "scribusview.h"
#include "scribusview.moc"
#ifdef _MSC_VER
#if (_MSC_VER >= 1200)
#include "win-config.h"
#endif
#else
#include "config.h"
#endif
#include <qcolor.h>
#include <qfont.h>
#include <qfontmetrics.h>
#include <qpixmap.h>
#include <qpointarray.h>
#include <qstringlist.h>
#include <qdragobject.h>
#include <qimage.h>
#include <qcstring.h>
#include <qfileinfo.h>
#include <qfile.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <unistd.h>
#include <qcursor.h>
#include <qurl.h>
#include <qdir.h>
#include <qevent.h>
#if QT_VERSION > 0x030102
#define SPLITVC SplitHCursor
#define SPLITHC SplitVCursor
#else
#define SPLITVC SplitVCursor
#define SPLITHC SplitHCursor
#endif
#include "scribus.h"
#include "tree.h"
#include "mpalette.h"
#include "scribusXml.h"
#include "serializer.h"
#include "insertTable.h"
#include "hruler.h"
#include "vruler.h"
#include "filewatcher.h"
#include "undomanager.h"
#include "units.h"
#include "extimageprops.h"
#include "pageitemattributes.h"
#include "scpaths.h"
#include "actionmanager.h"
#ifdef HAVE_TIFF
#include <tiffio.h>
#endif
#ifdef HAVE_CMS
#include CMS_INC
#endif
using namespace std;
extern void Level2Layer(ScribusDoc *doc, struct Layer *ll, int Level);
extern double Cwidth(ScribusDoc *doc, Foi* name, QString ch, int Siz, QString ch2 = " ");
extern ScribusApp* ScApp;
extern QPointArray FlattenPath(FPointArray ina, QValueList<uint> &Segs);
extern QPixmap loadIcon(QString nam);
extern double xy2Deg(double x, double y);
extern void BezierPoints(QPointArray *ar, QPoint n1, QPoint n2, QPoint n3, QPoint n4);
extern FPointArray RegularPolygonF(double w, double h, uint c, bool star, double factor, double rota);
extern FPoint getMaxClipF(FPointArray* Clip);
extern FPoint getMinClipF(FPointArray* Clip);
extern void WordAndPara(PageItem *currItem, int *w, int *p, int *c, int *wN, int *pN, int *cN);
extern int callGS(const QStringList & args);
extern ProfilesL InputProfiles;
ScribusView::ScribusView(QWidget *parent, ScribusDoc *doc, ApplicationPrefs *prefs) : QScrollView(parent, "s", WRepaintNoErase | WNorthWestGravity)
{
Ready = false;
updateOn = true;
Doc = doc;
Doc->pageCount = 0;
Prefs = prefs;
setHScrollBarMode(QScrollView::AlwaysOn);
setVScrollBarMode(QScrollView::AlwaysOn);
setMargins(25, 25, 0, 0);
setResizePolicy(Manual);
viewport()->setBackgroundMode(PaletteBackground);
QFont fo = QFont(font());
fo.setPointSize(10);
LE = new MSpinBox( 10, 3200, this, 2 );
LE->setFont(fo);
LE->setValue( 100 );
LE->setFocusPolicy(QWidget::ClickFocus);
zoomOutToolbarButton = new QPushButton(this);
zoomOutToolbarButton->setPixmap(loadIcon("Klein.xpm"));
zoomOutToolbarButton->setFocusPolicy(QWidget::NoFocus);
zoomInToolbarButton = new QPushButton(this);
zoomInToolbarButton->setFocusPolicy(QWidget::NoFocus);
zoomInToolbarButton->setPixmap(loadIcon("Gross.xpm"));
PGS = new PageSelector(this, 1);
PGS->setFont(fo);
PGS->setFocusPolicy(QWidget::ClickFocus);
LY = new QPushButton(this);
LY->setFont(fo);
Laymen = new QPopupMenu(this);
Laymen->setFont(fo);
LY->setPopup(Laymen);
LY->setFocusPolicy(QWidget::NoFocus);
horizRuler = new Hruler(this, Doc);
vertRuler = new Vruler(this, Doc);
UN = new QToolButton(this);
Unitmen = new QPopupMenu(this);
UN->setPopup(Unitmen);
UN->setFocusPolicy(QWidget::NoFocus);
UN->setPopupDelay(10);
Ready = true;
viewport()->setMouseTracking(true);
setAcceptDrops(true);
viewport()->setAcceptDrops(true);
setDragAutoScroll(false);
SelItem.clear();
Doc->DragP = false;
Doc->leaveDrag = false;
Imoved = false;
Mpressed = false;
MidButt = false;
HaveSelRect = false;
Magnify = false;
FirstPoly = true;
EdPoints = true;
GroupSel = false;
DraggedGroup = false;
MoveGY = false;
MoveGX = false;
EditContour = false;
CursVis = false;
mCG = false;
MidButt = false;
previewMode = false;
Doc->SubMode = -1;
GroupX = 0;
GroupY = 0;
GroupW = 0;
GroupH = 0;
DrHY = -1;
DrVX = -1;
GyM = 0;
GxM = 0;
ClRe = -1;
ClRe2 = -1;
_groupTransactionStarted = false;
_itemCreationTransactionStarted = false;
_isGlobalMode = true;
undoManager = UndoManager::instance();
languageChange();
connect(zoomOutToolbarButton, SIGNAL(clicked()), this, SLOT(slotZoomOut()));
connect(zoomInToolbarButton, SIGNAL(clicked()), this, SLOT(slotZoomIn()));
connect(LE, SIGNAL(valueChanged(int)), this, SLOT(Zval()));
connect(PGS, SIGNAL(GotoPage(int)), this, SLOT(GotoPa(int)));
connect(Laymen, SIGNAL(activated(int)), this, SLOT(GotoLa(int)));
connect(Unitmen, SIGNAL(activated(int)), this, SLOT(ChgUnit(int)));
connect(this, SIGNAL(contentsMoving(int, int)), this, SLOT(setRulerPos(int, int)));
connect(this, SIGNAL(HaveSel(int)), this, SLOT(selectionChanged()));
evSpon = false;
}
void ScribusView::languageChange()
{
LE->setSuffix( tr( " %" ) );
LY->setText( tr("Layer")+" 0");
//CB TODO Convert to actions later
UN->setText(unitGetStrFromIndex(Doc->docUnitIndex));
Unitmen->clear();
for (int i=0;i<=unitGetMaxIndex();++i)
Unitmen->insertItem(unitGetStrFromIndex(i));
}
void ScribusView::viewportPaintEvent ( QPaintEvent * p )
{
if (p->spontaneous())
evSpon = true;
QScrollView::viewportPaintEvent(p);
}
void ScribusView::drawContents(QPainter *, int clipx, int clipy, int clipw, int cliph)
{
QPoint vr;
if (Doc->loading)
return;
if (!updateOn)
return;
// QTime tim;
// tim.start();
if ((clipw > 0) && (cliph > 0))
{
vr = contentsToViewport(QPoint(clipx, clipy));
ScPainter *painter = new ScPainter(viewport(), clipw, cliph, vr.x(), vr.y());
painter->clear(paletteBackgroundColor());
painter->translate(-clipx, -clipy);
painter->setLineWidth(1);
painter->setFillMode(ScPainter::Solid);
painter->translate(0.5, 0.5);
painter->setZoomFactor(1.0);
/* Draw Page Outlines */
if (!Doc->MasterP)
{
for (uint a = 0; a < Doc->Pages.count(); ++a)
{
int x = static_cast<int>(Doc->Pages.at(a)->Xoffset * Scale);
int y = static_cast<int>(Doc->Pages.at(a)->Yoffset * Scale);
int w = static_cast<int>(Doc->Pages.at(a)->Width * Scale);
int h = static_cast<int>(Doc->Pages.at(a)->Height * Scale);
if (QRect(x, y, w+5, h+5).intersects(QRect(clipx, clipy, clipw, cliph)))
{
painter->setFillMode(ScPainter::Solid);
painter->setPen(black, 1, SolidLine, FlatCap, MiterJoin);
painter->setBrush(QColor(128,128,128));
painter->drawRect(x+5, y+5, w, h);
if (a == Doc->currentPage->PageNr)
painter->setPen(red, 2, SolidLine, FlatCap, MiterJoin);
else
painter->setPen(black, 1, SolidLine, FlatCap, MiterJoin);
painter->setBrush(Doc->papColor);
painter->drawRect(x, y, w, h);
if (Doc->guidesSettings.before)
DrawPageMarks(painter, Doc->Pages.at(a), QRect(clipx, clipy, clipw, cliph));
}
DrawMasterItems(painter, Doc->Pages.at(a), QRect(clipx, clipy, clipw, cliph));
}
DrawPageItems(painter, QRect(clipx, clipy, clipw, cliph));
if (!Doc->guidesSettings.before)
{
for (uint a = 0; a < Doc->Pages.count(); ++a)
{
int x = static_cast<int>(Doc->Pages.at(a)->Xoffset * Scale);
int y = static_cast<int>(Doc->Pages.at(a)->Yoffset * Scale);
int w = static_cast<int>(Doc->Pages.at(a)->Width * Scale);
int h = static_cast<int>(Doc->Pages.at(a)->Height * Scale);
if (QRect(x, y, w+5, h+5).intersects(QRect(clipx, clipy, clipw, cliph)))
DrawPageMarks(painter, Doc->Pages.at(a), QRect(clipx, clipy, clipw, cliph));
}
}
}
else
{
int x = static_cast<int>(Doc->ScratchLeft * Scale);
int y = static_cast<int>(Doc->ScratchTop * Scale);
int w = static_cast<int>(Doc->currentPage->Width * Scale);
int h = static_cast<int>(Doc->currentPage->Height * Scale);
if (QRect(x, y, w+5, h+5).intersects(QRect(clipx, clipy, clipw, cliph)))
{
painter->setFillMode(ScPainter::Solid);
painter->setPen(black, 1, SolidLine, FlatCap, MiterJoin);
painter->setBrush(QColor(128,128,128));
painter->drawRect(x+5, y+5, w, h);
painter->setBrush(Doc->papColor);
painter->drawRect(x, y, w, h);
if (Doc->guidesSettings.before)
DrawPageMarks(painter, Doc->currentPage, QRect(clipx, clipy, clipw, cliph));
}
DrawPageItems(painter, QRect(clipx, clipy, clipw, cliph));
if ((!Doc->guidesSettings.before) && (QRect(x, y, w+5, h+5).intersects(QRect(clipx, clipy, clipw, cliph))))
DrawPageMarks(painter, Doc->currentPage, QRect(clipx, clipy, clipw, cliph));
}
if ((SelItem.count() != 0) || (linkedFramesToShow.count() != 0))
{
double z = painter->zoomFactor();
painter->setZoomFactor(Scale);
painter->save();
PageItem *currItem;
if ((Doc->guidesSettings.linkShown) && (linkedFramesToShow.count() != 0))
currItem = linkedFramesToShow.at(0);
else
{
if (linkedFramesToShow.count() != 0)
currItem = linkedFramesToShow.at(0);
else
currItem = SelItem.at(0);
}
if ((((Doc->appMode == LinkFrames) || (Doc->appMode == UnlinkFrames))
&& (currItem->itemType() == PageItem::TextFrame)) || (Doc->guidesSettings.linkShown))
{
PageItem *nextItem = currItem;
if (Doc->guidesSettings.linkShown)
{
for (uint lks = 0; lks < linkedFramesToShow.count(); ++lks)
{
nextItem = linkedFramesToShow.at(lks);
while (nextItem != 0)
{
double x11, y11, x12, y12, x1mid, y1mid;
double x21, y21, x22, y22, x2mid, y2mid;
x11 = nextItem->Xpos;
y11 = nextItem->Ypos;
x12 = nextItem->Xpos+nextItem->Width;
y12 = nextItem->Ypos+nextItem->Height;
x1mid = x11+(x12-x11)/2;
y1mid = y11+(y12-y11)/2;
if (nextItem->Rot!=0.000)
{
FPoint tempPoint = transformPoint(FPoint(0,0), x11, y11, nextItem->Rot, 1, 1);
x11=tempPoint.x();
y11=tempPoint.y();
tempPoint = transformPoint(FPoint(0,0), x12, y12, nextItem->Rot, 1, 1);
x12=tempPoint.x();
y12=tempPoint.y();
tempPoint = transformPoint(FPoint(0,0), x1mid, y1mid, nextItem->Rot, 1, 1);
x1mid=tempPoint.x();
y1mid=tempPoint.y();
}
double a1, b1, a2, b2;
a1 = a2 = b1 = b2 = 0;
if (nextItem->NextBox!=NULL)
{
x21 = nextItem->NextBox->Xpos;
y21 = nextItem->NextBox->Ypos;
x22 = nextItem->NextBox->Xpos+nextItem->NextBox->Width;
y22 = nextItem->NextBox->Ypos+nextItem->NextBox->Height;
x2mid = nextItem->NextBox->Xpos + nextItem->NextBox->Width/2;
y2mid = nextItem->NextBox->Ypos + nextItem->NextBox->Height/2;
x2mid = x21+(x22-x21)/2;
y2mid = y21+(y22-y21)/2;
if (nextItem->NextBox->Rot!=0.000)
{
FPoint tempPoint = transformPoint(FPoint(0,0), x21, y21, nextItem->NextBox->Rot, 1, 1);
x21=tempPoint.x();
y21=tempPoint.y();
tempPoint = transformPoint(FPoint(0,0), x22, y22, nextItem->NextBox->Rot, 1, 1);
x22=tempPoint.x();
y22=tempPoint.y();
tempPoint = transformPoint(FPoint(0,0), x2mid, y2mid, nextItem->NextBox->Rot, 1, 1);
x2mid=tempPoint.x();
y2mid=tempPoint.y();
}
if (x22<x11) { a1 = x11; a2 = x22; }
if (x21>x12) { a1 = x12; a2 = x21; }
if (y22<y11) { b1 = y11; b2 = y22; }
if (y21>y12) { b1 = y12; b2 = y21; }
if (x21<x12 && x21>x11) { a1 = x1mid; a2 = x2mid; }
if (x21<x11 && x22>x11) { a1 = x1mid; a2 = x2mid; }
if (y21<y12 && y21>y11) { b1 = y1mid; b2 = y2mid; }
if (y21<y11 && y22>y11) { b1 = y1mid; b2 = y2mid; }
}
FPoint Start = transformPoint(FPoint(a1-nextItem->Xpos, b1-nextItem->Ypos), nextItem->Xpos, nextItem->Ypos, nextItem->Rot, 1, 1);
//FPoint Start = transformPoint(FPoint(nextItem->Width/2, nextItem->Height), nextItem->Xpos, nextItem->Ypos, nextItem->Rot, 1, 1);
nextItem = nextItem->NextBox;
if (nextItem != NULL)
{
FPoint End = transformPoint(FPoint(a2-nextItem->Xpos, b2-nextItem->Ypos), nextItem->Xpos, nextItem->Ypos, nextItem->Rot, 1, 1);
//FPoint End = transformPoint(FPoint(nextItem->Width/2, 0), nextItem->Xpos, nextItem->Ypos, nextItem->Rot, 1, 1);
painter->setPen(black, 5.0 / Scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
painter->setPenOpacity(0.3);
painter->drawLine(Start, End);
double r = atan2(End.y()-Start.y(),End.x()-Start.x())*(180.0/M_PI);
QWMatrix arrowTrans;
FPointArray arrow;
arrow.addQuadPoint(-12, 0, -12, 0, -12, 0, -12, 0);
arrow.addQuadPoint(-15, -5, -15, -5, -15, -5, -15, -5);
arrow.addQuadPoint(0, 0, 0, 0, 0, 0, 0, 0);
arrow.addQuadPoint(-15, 5, -15, 5, -15, 5, -15, 5);
arrow.addQuadPoint(-12, 0, -12, 0, -12, 0, -12, 0);
arrowTrans.translate(End.x(), End.y());
arrowTrans.rotate(r);
arrowTrans.scale(2.5 / Scale, 2.5 / Scale);
arrow.map(arrowTrans);
painter->setBrush(painter->pen());
painter->setBrushOpacity(0.3);
painter->setLineWidth(0);
painter->setFillMode(ScPainter::Solid);
painter->setupPolygon(&arrow);
painter->fillPath();
}
}
}
}
else
{
while (nextItem != 0)
{
if (nextItem->BackBox != 0)
nextItem = nextItem->BackBox;
else
break;
}
while (nextItem != 0)
{
FPoint Start = transformPoint(FPoint(nextItem->Width/2, nextItem->Height), nextItem->Xpos, nextItem->Ypos, nextItem->Rot, 1, 1);
nextItem = nextItem->NextBox;
if (nextItem != 0)
{
FPoint End = transformPoint(FPoint(nextItem->Width/2, 0), nextItem->Xpos, nextItem->Ypos, nextItem->Rot, 1, 1);
painter->setPen(black, 5.0 / Scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
painter->setPenOpacity(0.3);
painter->drawLine(Start, End);
}
}
}
}
painter->setLineWidth(1);
painter->setPenOpacity(1.0);
painter->restore();
painter->setZoomFactor(z);
}
painter->end();
delete painter;
}
if (SelItem.count() != 0)
{
PageItem *currItem = SelItem.at(0);
currItem->paintObj();
if ((Doc->EditClip) && (currItem->Select))
MarkClip(currItem);
if (GroupSel)
{
setGroupRect();
paintGroupRect();
}
}
if (Doc->appMode == EditMode)
slotDoCurs(true);
if (Doc->appMode == EditGradientVectors)
{
PageItem *currItem = SelItem.at(0);
QPainter p;
p.begin(viewport());
ToView(&p);
Transform(currItem, &p);
p.setPen(QPen(blue, 1, SolidLine, FlatCap, MiterJoin));
p.setBrush(NoBrush);
p.drawLine(QPoint(qRound(currItem->GrStartX), qRound(currItem->GrStartY)), QPoint(qRound(currItem->GrEndX), qRound(currItem->GrEndY)));
p.setPen(QPen(magenta, 8, SolidLine, RoundCap, MiterJoin));
p.drawLine(QPoint(qRound(currItem->GrStartX), qRound(currItem->GrStartY)), QPoint(qRound(currItem->GrStartX), qRound(currItem->GrStartY)));
p.drawLine(QPoint(qRound(currItem->GrEndX), qRound(currItem->GrEndY)), QPoint(qRound(currItem->GrEndX), qRound(currItem->GrEndY)));
p.end();
}
evSpon = false;
// qDebug( "Time elapsed: %d ms", tim.elapsed() );
}
void ScribusView::DrawMasterItems(ScPainter *painter, Page *page, QRect clip)
{
QPainter p;
int Lnr;
struct Layer ll;
PageItem *currItem;
ll.isViewable = false;
ll.LNr = 0;
double z = painter->zoomFactor();
if (page->MPageNam != "")
{
Page* Mp = Doc->MasterPages.at(Doc->MasterNames[page->MPageNam]);
if (page->FromMaster.count() != 0)
{
Lnr = 0;
for (uint la = 0; la < Doc->Layers.count(); ++la)
{
Level2Layer(Doc, &ll, Lnr);
bool pr = true;
if ((previewMode) && (!ll.isPrintable))
pr = false;
if ((ll.isViewable) && (pr))
{
for (uint a = 0; a < page->FromMaster.count(); ++a)
{
currItem = page->FromMaster.at(a);
if (currItem->LayerNr != ll.LNr)
continue;
if ((currItem->OwnPage != -1) && (currItem->OwnPage != static_cast<int>(Mp->PageNr)))
continue;
if ((previewMode) && (!currItem->isPrintable))
continue;
currItem->savedOwnPage = currItem->OwnPage;
double OldX = currItem->Xpos;
double OldY = currItem->Ypos;
double OldBX = currItem->BoundingX;
double OldBY = currItem->BoundingY;
currItem->OwnPage = page->PageNr;
if (!currItem->ChangedMasterItem)
{
currItem->Xpos = OldX - Mp->Xoffset + page->Xoffset;
currItem->Ypos = OldY - Mp->Yoffset + page->Yoffset;
currItem->BoundingX = OldBX - Mp->Xoffset + page->Xoffset;
currItem->BoundingY = OldBY - Mp->Yoffset + page->Yoffset;
}
if (evSpon)
currItem->Dirty = true;
QRect oldR = getRedrawBounding(currItem);
if (clip.intersects(oldR))
currItem->DrawObj(painter, clip);
currItem->OwnPage = currItem->savedOwnPage;
if (!currItem->ChangedMasterItem)
{
currItem->Xpos = OldX;
currItem->Ypos = OldY;
currItem->BoundingX = OldBX;
currItem->BoundingY = OldBY;
}
}
for (uint a = 0; a < page->FromMaster.count(); ++a)
{
currItem = page->FromMaster.at(a);
if (currItem->LayerNr != ll.LNr)
continue;
if (!currItem->isTableItem)
continue;
if ((currItem->OwnPage != -1) && (currItem->OwnPage != static_cast<int>(Mp->PageNr)))
continue;
double OldX = currItem->Xpos;
double OldY = currItem->Ypos;
double OldBX = currItem->BoundingX;
double OldBY = currItem->BoundingY;
if (!currItem->ChangedMasterItem)
{
currItem->Xpos = OldX - Mp->Xoffset + page->Xoffset;
currItem->Ypos = OldY - Mp->Yoffset + page->Yoffset;
currItem->BoundingX = OldBX - Mp->Xoffset + page->Xoffset;
currItem->BoundingY = OldBY - Mp->Yoffset + page->Yoffset;
}
QRect oldR = getRedrawBounding(currItem);
if (clip.intersects(oldR))
{
painter->setZoomFactor(Scale);
painter->save();
painter->translate(currItem->Xpos*Scale, currItem->Ypos*Scale);
painter->rotate(currItem->Rot);
if (currItem->lineColor() != "None")
{
QColor tmp;
currItem->SetFarbe(&tmp, currItem->lineColor(), currItem->lineShade());
if ((currItem->TopLine) || (currItem->RightLine) || (currItem->BottomLine) || (currItem->LeftLine))
{
painter->setPen(tmp, currItem->Pwidth, currItem->PLineArt, Qt::SquareCap, currItem->PLineJoin);
if (currItem->TopLine)
painter->drawLine(FPoint(0.0, 0.0), FPoint(currItem->Width, 0.0));
if (currItem->RightLine)
painter->drawLine(FPoint(currItem->Width, 0.0), FPoint(currItem->Width, currItem->Height));
if (currItem->BottomLine)
painter->drawLine(FPoint(currItem->Width, currItem->Height), FPoint(0.0, currItem->Height));
if (currItem->LeftLine)
painter->drawLine(FPoint(0.0, currItem->Height), FPoint(0.0, 0.0));
}
}
painter->restore();
}
if (!currItem->ChangedMasterItem)
{
currItem->Xpos = OldX;
currItem->Ypos = OldY;
currItem->BoundingX = OldBX;
currItem->BoundingY = OldBY;
}
}
}
Lnr++;
}
}
}
painter->setZoomFactor(z);
}
void ScribusView::DrawPageItems(ScPainter *painter, QRect clip)
{
QPainter p;
int Lnr;
struct Layer ll;
PageItem *currItem;
ll.isViewable = false;
ll.LNr = 0;
linkedFramesToShow.clear();
double z = painter->zoomFactor();
if (Doc->Items.count() != 0)
{
Lnr = 0;
for (uint la2 = 0; la2 < Doc->Layers.count(); ++la2)
{
Level2Layer(Doc, &ll, Lnr);
bool pr = true;
if ((previewMode) && (!ll.isPrintable))
pr = false;
if ((ll.isViewable) && (pr))
{
QPtrListIterator<PageItem> docItem(Doc->Items);
while ( (currItem = docItem.current()) != 0 )
{
++docItem;
if (currItem->LayerNr != ll.LNr)
continue;
if ((previewMode) && (!currItem->isPrintable))
continue;
if ((Doc->MasterP) && ((currItem->OwnPage != -1) && (currItem->OwnPage != static_cast<int>(Doc->currentPage->PageNr))))
continue;
if ((!Doc->MasterP) && (currItem->OnMasterPage != ""))
{
if (currItem->OnMasterPage != Doc->currentPage->PageNam)
continue;
}
QRect oldR = getRedrawBounding(currItem);
if (clip.intersects(oldR))
{
if (evSpon)
currItem->Dirty = true;
if (!((Doc->EditClip) && (Mpressed)))
currItem->DrawObj(painter, clip);
currItem->Redrawn = true;
if ((currItem->itemType() == PageItem::TextFrame) && ((currItem->NextBox != 0) || (currItem->BackBox != 0)))
{
PageItem *nextItem = currItem;
while (nextItem != 0)
{
if (nextItem->BackBox != 0)
nextItem = nextItem->BackBox;
else
break;
}
if (linkedFramesToShow.find(nextItem) == -1)
linkedFramesToShow.append(nextItem);
}
if ((Doc->appMode == EditMode) && (currItem->Select) && (currItem->itemType() == PageItem::TextFrame))
{
//CB 230305 Stop redrawing the horizontal ruler if it hasnt changed when typing text!!!
if ((qRound(horizRuler->ItemPos*10000) != qRound((currItem->Xpos - Doc->ScratchLeft)*10000)) || (qRound(horizRuler->ItemEndPos*10000) != qRound(((currItem->Xpos+currItem->Width) - Doc->ScratchLeft)*10000)))
{
horizRuler->ItemPos = currItem->Xpos - Doc->ScratchLeft;
horizRuler->ItemEndPos = (currItem->Xpos+currItem->Width) - Doc->ScratchLeft;
if (currItem->lineColor() != "None")
horizRuler->lineCorr = currItem->Pwidth / 2.0;
else
horizRuler->lineCorr = 0;
horizRuler->ColGap = currItem->ColGap;
horizRuler->Cols = currItem->Cols;
horizRuler->Extra = currItem->Extra;
horizRuler->RExtra = currItem->RExtra;
horizRuler->First = Doc->docParagraphStyles[Doc->currentParaStyle].First;
horizRuler->Indent = Doc->docParagraphStyles[Doc->currentParaStyle].Indent;
if (currItem->imageFlippedH() || (currItem->Reverse))
horizRuler->Revers = true;
else
horizRuler->Revers = false;
horizRuler->ItemPosValid = true;
horizRuler->repX = false;
if (Doc->currentParaStyle < 5)
horizRuler->TabValues = currItem->TabValues;
else
horizRuler->TabValues = Doc->docParagraphStyles[Doc->currentParaStyle].TabValues;
horizRuler->repaint();
}
}
}
}
QPtrListIterator<PageItem> docItem2(Doc->Items);
while ( (currItem = docItem2.current()) != 0 )
{
++docItem2;
if (currItem->LayerNr != ll.LNr)
continue;
if (!currItem->isTableItem)
continue;
QRect oldR = getRedrawBounding(currItem);
if (clip.intersects(oldR))
{
painter->setZoomFactor(Scale);
painter->save();
painter->translate(currItem->Xpos*Scale, currItem->Ypos*Scale);
painter->rotate(currItem->Rot);
if (currItem->lineColor() != "None")
{
QColor tmp;
currItem->SetFarbe(&tmp, currItem->lineColor(), currItem->lineShade());
if ((currItem->TopLine) || (currItem->RightLine) || (currItem->BottomLine) || (currItem->LeftLine))
{
painter->setPen(tmp, currItem->Pwidth, currItem->PLineArt, Qt::SquareCap, currItem->PLineJoin);
if (currItem->TopLine)
painter->drawLine(FPoint(0.0, 0.0), FPoint(currItem->Width, 0.0));
if (currItem->RightLine)
painter->drawLine(FPoint(currItem->Width, 0.0), FPoint(currItem->Width, currItem->Height));
if (currItem->BottomLine)
painter->drawLine(FPoint(currItem->Width, currItem->Height), FPoint(0.0, currItem->Height));
if (currItem->LeftLine)
painter->drawLine(FPoint(0.0, currItem->Height), FPoint(0.0, 0.0));
}
}
painter->restore();
}
}
}
Lnr++;
}
}
painter->setZoomFactor(z);
}
void ScribusView::DrawPageMarks(ScPainter *p, Page *page, QRect)
{
double lw = 1.0 / Scale;
double z = p->zoomFactor();
p->save();
p->setZoomFactor(Scale);
p->translate(page->Xoffset * Scale, page->Yoffset * Scale);
p->setLineWidth(lw);
if (Doc->guidesSettings.marginsShown)
{
p->setPen(Doc->guidesSettings.margColor);
if (Doc->marginColored)
{
p->setBrush(Doc->guidesSettings.margColor);
p->drawRect(0, 0, page->Width, page->Margins.Top);
p->drawRect(0, page->Margins.Top, page->Margins.Left, page->Height - page->Margins.Top);
p->drawRect(page->Margins.Left, page->Height - page->Margins.Bottom, page->Width - page->Margins.Right - page->Margins.Left, page->Margins.Bottom);
p->drawRect(page->Width - page->Margins.Right, page->Margins.Top, page->Margins.Right, page->Height-page->Margins.Top);
}
p->setPen(Doc->guidesSettings.margColor);
p->drawLine(FPoint(0, page->Margins.Top), FPoint(page->Width, page->Margins.Top));
p->drawLine(FPoint(0, page->Height - page->Margins.Bottom), FPoint(page->Width, page->Height - page->Margins.Bottom));
p->drawLine(FPoint(page->Margins.Left, 0), FPoint(page->Margins.Left, page->Height));
p->drawLine(FPoint(page->Width - page->Margins.Right, 0), FPoint(page->Width - page->Margins.Right, page->Height));
}
if (Doc->guidesSettings.baseShown)
{
p->setPen(Doc->guidesSettings.baseColor, lw, SolidLine, FlatCap, MiterJoin);
for (double yg = Doc->typographicSetttings.offsetBaseGrid; yg < page->Height; yg += Doc->typographicSetttings.valueBaseGrid)
p->drawLine(FPoint(0, yg), FPoint(page->Width, yg));
}
if (Doc->guidesSettings.gridShown)
{
double stx = 0;
double endx = page->Width;
double sty = 0;
double endy = page->Height;
/* double stx = QMAX((clip.x() - page->Xoffset) / Scale, 0);
double endx = QMIN(stx + clip.width() / Scale, page->Width);
double sty = QMAX((clip.y() - page->Yoffset) / Scale, 0);
double endy = QMIN(sty + clip.height() / Scale, page->Height); */
if (Scale > 0.49)
{
double i,start;
i = Doc->guidesSettings.majorGrid;
p->setPen(Doc->guidesSettings.majorColor, lw, SolidLine, FlatCap, MiterJoin);
start=floor(sty/i);
start*=i;
for (double b = start; b < endy; b+=i)
{
p->drawLine(FPoint(0, b), FPoint(page->Width, b));
}
start=floor(stx/i);
start*=i;
for (double b = start; b <= endx; b+=i)
{
p->drawLine(FPoint(b, 0), FPoint(b, page->Height));
}
i = Doc->guidesSettings.minorGrid;
p->setPen(Doc->guidesSettings.minorColor, lw, DotLine, FlatCap, MiterJoin);
start=floor(sty/i);
start*=i;
for (double b = start; b < endy; b+=i)
{
p->drawLine(FPoint(0, b), FPoint(page->Width, b));
}
start=floor(stx/i);
start*=i;
for (double b = start; b <= endx; b+=i)
{
p->drawLine(FPoint(b, 0), FPoint(b, page->Height));
}
}
}
if (Doc->guidesSettings.guidesShown)
{
p->setPen(Doc->guidesSettings.guideColor, lw, DotLine, FlatCap, MiterJoin);
if (page->XGuides.count() != 0)
{
for (uint xg = 0; xg < page->XGuides.count(); ++xg)
p->drawLine(FPoint(page->XGuides[xg], 0), FPoint(page->XGuides[xg], page->Height));
}
if (page->YGuides.count() != 0)
{
for (uint yg = 0; yg < page->YGuides.count(); ++yg)
p->drawLine(FPoint(0, page->YGuides[yg]), FPoint(page->Width, page->YGuides[yg]));
}
}
p->restore();
p->setZoomFactor(z);
}
void ScribusView::leaveEvent(QEvent *)
{
/* if (BlockLeave)
return; */
if (!Mpressed)
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
/* else
{
if ((SelItem.count() != 0) && (Mpressed) && (!doku->DragP) && (doku->appMode == 1))
{
PageItem *currItem = SelItem.at(0);
if ((b->Locked) || (b->Sizing))
return;
doku->DragP = true;
doku->leaveDrag = true;
doku->DraggedElem = b;
doku->DragElements.clear();
for (uint dre=0; dre<SelItem.count(); ++dre)
doku->DragElements.append(SelItem.at(dre)->ItemNr);
ScriXmlDoc *ss = new ScriXmlDoc();
QDragObject *dr = new QTextDrag(ss->WriteElem(&SelItem, doku), this);
dr->setPixmap(loadIcon("DragPix.xpm"));
dr->drag();
delete ss;
doku->DragP = false;
doku->leaveDrag = false;
Mpressed = false;
doku->DraggedElem = 0;
doku->DragElements.clear();
}
} */
}
void ScribusView::contentsDragEnterEvent(QDragEnterEvent *e)
{
QString text;
e->accept(QTextDrag::canDecode(e));
if (QTextDrag::decode(e, text))
{
double gx, gy, gw, gh;
setActiveWindow();
raise();
ScApp->newActWin(Doc->WinHan);
updateContents();
// SeleItemPos(e->pos());
QUrl ur(text);
QFileInfo fi = QFileInfo(ur.path());
ScriXmlDoc *ss = new ScriXmlDoc();
if (fi.exists())
text = ur.path();
if(ss->ReadElemHeader(text,fi.exists(), &gx, &gy, &gw, &gh))
{
GroupX = e->pos().x() / Scale;
GroupY = e->pos().y() / Scale;
GroupW = gw;
GroupH = gh;
DraggedGroup = true;
DraggedGroupFirst = true;
GroupSel = false;
QPainter p;
p.begin(viewport());
PaintSizeRect(&p, QRect());
// QPoint pv = QPoint(qRound(gx), qRound(gy));
// PaintSizeRect(&p, QRect(pv, QPoint(pv.x()+qRound(gw), pv.y()+qRound(gh))));
p.end();
}
delete ss;
}
}
void ScribusView::contentsDragMoveEvent(QDragMoveEvent *e)
{
QString text;
// PageItem *currItem;
// bool img;
e->accept(QTextDrag::canDecode(e));
if (QTextDrag::decode(e, text))
{
if (DraggedGroup)
{
double gx, gy, gw, gh;
GroupX = e->pos().x() / Scale;
GroupY = e->pos().y() / Scale;
getGroupRectScreen(&gx, &gy, &gw, &gh);
QPainter p;
p.begin(viewport());
QPoint pv = QPoint(qRound(gx), qRound(gy));
if (!DraggedGroupFirst)
PaintSizeRect(&p, QRect(pv, QPoint(pv.x()+qRound(gw), pv.y()+qRound(gh))));
DraggedGroupFirst = false;
p.end();
emit MousePos(GroupX-Doc->currentPage->Xoffset, GroupY-Doc->currentPage->Yoffset);
horizRuler->Draw(e->pos().x());
vertRuler->Draw(e->pos().y());
return;
}
/* QUrl ur(text);
QFileInfo fi = QFileInfo(ur.path());
QString ext = fi.extension(false).upper();
QStrList imfo = QImageIO::inputFormats();
if (ext == "JPG")
ext = "JPEG";
img = ((imfo.contains(ext))||(ext=="PS")||(ext=="EPS")||(ext=="TIF"));
if (!SeleItemPos(e->pos()))
{
if (SelItem.count() != 0)
Deselect(true);
}
else
{
b = SelItem.at(0);
if (img)
{
if (b->PType != 2)
Deselect(true);
}
else
{
if (b->PType != 4)
Deselect(true);
}
} */
}
}
void ScribusView::contentsDragLeaveEvent(QDragLeaveEvent *)
{
if (DraggedGroup)
{
updateContents();
DraggedGroup = false;
DraggedGroupFirst = false;
}
}
void ScribusView::contentsDropEvent(QDropEvent *e)
{
QString text;
PageItem *currItem;
bool img = false;
// struct ScText *hg;
// uint a;
int re = 0;
e->accept(QTextDrag::canDecode(e));
DraggedGroupFirst = false;
if (QTextDrag::decode(e, text))
{
QUrl ur(text);
QFileInfo fi = QFileInfo(ur.path());
QString ext = fi.extension(false).upper();
QStrList imfo = QImageIO::inputFormats();
if (ext == "JPG")
ext = "JPEG";
img = ((imfo.contains(ext))||(ext=="PS")||(ext=="EPS")||(ext=="PDF")||(ext=="TIF"));
/* if ((fi.exists()) && (img) && (!SeleItemPos(e->pos())))
{
int z = PaintPict(qRound(e->pos().x()/doku->Scale), qRound(e->pos().y()/doku->Scale), 1, 1);
b = Items.at(z);
LoadPict(ur.path(), b->ItemNr);
b->Width = static_cast<double>(b->pixm.width());
b->Height = static_cast<double>(b->pixm.height());
b->OldB2 = b->Width;
b->OldH2 = b->Height;
UpdateClip(b);
emit DocChanged();
update();
return;
} */
/* if ((SeleItemPos(e->pos())) && (!text.startsWith("<SCRIBUSELEM")))
{
b = SelItem.at(0);
if (b->itemType() == PageItem::ImageFrame)
{
if ((fi.exists()) && (img))
{
LoadPict(ur.path(), b->ItemNr);
update();
}
}
if (b->PType == 4)
{
if ((b->BackBox != 0) && (b->itemText.count() == 0))
return;
if ((fi.exists()) && (!img) && (fi.size() < 500000))
{
Serializer *ss = new Serializer(ur.path());
if (ss->Read())
{
int st = doku->currentParaStyle;
ss->GetText(b, st, doku->docParagraphStyles[st].Font, doku->docParagraphStyles[st].FontSize, true);
emit DocChanged();
}
delete ss;
update();
}
else
{
slotDoCurs(false);
slotSetCurs(e->pos().x(), e->pos().y());
if (text.startsWith("<SCRIBUSELEM"))
return;
for (a=0; a<text.length(); ++a)
{
hg = new ScText;
hg->ch = text.at(a);
if (hg->ch == QChar(10))
hg->ch = QChar(13);
if (hg->ch == QChar(4))
hg->ch = QChar(9);
if (hg->ch == QChar(5))
hg->ch = QChar(13);
hg->cfont = b->IFont;
hg->csize = b->ISize;
hg->ccolor = b->TxtFill;
hg->cshade = b->ShTxtFill;
hg->cstroke = b->TxtStroke;
hg->cshade2 = b->ShTxtStroke;
hg->cselect = false;
hg->cscale = b->TxtScale;
hg->cextra = 0;
hg->cstyle = 0;
hg->cab = 0;
hg->xp = 0;
hg->yp = 0;
hg->PRot = 0;
hg->PtransX = 0;
hg->PtransY = 0;
b->itemText.insert(b->CPos, hg);
b->CPos += 1;
}
emit DocChanged();
update();
}
}
}
else
{ */
for (uint as = 0; as < Doc->Items.count(); ++as)
{
Doc->Items.at(as)->Select = false;
}
uint ac = Doc->Items.count();
if ((!img) && (Doc->DraggedElem == 0))
{
if ((fi.exists()) && (!img))
emit LoadElem(ur.path(), qRound(e->pos().x()/Scale), qRound(e->pos().y()/Scale), true, false, Doc, this);
else
emit LoadElem(QString(text), qRound(e->pos().x()/Scale), qRound(e->pos().y()/Scale), false, false, Doc, this);
SelItem.clear();
for (uint as = ac; as < Doc->Items.count(); ++as)
{
currItem = Doc->Items.at(as);
if (currItem->isBookmark)
emit AddBM(currItem);
SelectItemNr(as);
}
}
else
{
if (Doc->DraggedElem != 0)
{
if (!Doc->leaveDrag)
{
QPopupMenu *pmen = new QPopupMenu();
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
pmen->insertItem( tr("Copy Here"));
pmen->insertItem( tr("Move Here"));
pmen->insertItem( tr("Cancel"));
re = pmen->indexOf(pmen->exec(QCursor::pos()));
delete pmen;
}
else
re = 1;
if ((re == 2) || (re == -1))
{
updateContents();
return;
}
if ((re == 1) || (Doc->leaveDrag))
{
QPtrList<PageItem> pasted;
emit LoadElem(QString(text), qRound(e->pos().x()/Scale), qRound(e->pos().y()/Scale), false, false, Doc, this);
for (uint as = ac; as < Doc->Items.count(); ++as)
{
pasted.append(Doc->Items.at(as));
}
SelItem.clear();
for (uint dre=0; dre<Doc->DragElements.count(); ++dre)
{
SelItem.append(Doc->Items.at(Doc->DragElements[dre]));
}
PageItem* bb;
int fin;
for (uint dre=0; dre<Doc->DragElements.count(); ++dre)
{
bb = pasted.at(dre);
currItem = SelItem.at(dre);
if ((currItem->itemType() == PageItem::TextFrame) && ((currItem->NextBox != 0) || (currItem->BackBox != 0)))
{
if (currItem->BackBox != 0)
{
bb->BackBox = currItem->BackBox;
fin = SelItem.find(currItem->BackBox);
if (fin != -1)
bb->BackBox = pasted.at(fin);
bb->BackBox->NextBox = bb;
}
if (currItem->NextBox != 0)
{
bb->NextBox = currItem->NextBox;
fin = SelItem.find(currItem->NextBox);
if (fin != -1)
bb->NextBox = pasted.at(fin);
bb->NextBox->BackBox = bb;
}
}
}
for (uint dre=0; dre<Doc->DragElements.count(); ++dre)
{
currItem = SelItem.at(dre);
currItem->NextBox = 0;
currItem->BackBox = 0;
}
pasted.clear();
DeleteItem();
}
}
if ((!img) && ((re == 0)))
emit LoadElem(QString(text), qRound(e->pos().x()/Scale), qRound(e->pos().y()/Scale), false, false, Doc, this);
Doc->DraggedElem = 0;
Doc->DragElements.clear();
SelItem.clear();
for (uint as = ac; as < Doc->Items.count(); ++as)
{
currItem = Doc->Items.at(as);
if (currItem->isBookmark)
emit AddBM(currItem);
SelectItemNr(as);
}
updateContents();
}
// }
}
}
void ScribusView::contentsMouseDoubleClickEvent(QMouseEvent *m)
{
m->accept();
Mpressed = false;
PageItem *currItem = 0;
if (Doc->EditClip)
{
emit EndNodeEdit();
return;
}
if ((GroupSel) || (Doc->appMode != NormalMode))
{
if ((GroupSel) && (Doc->appMode == NormalMode))
{
if (GetItem(&currItem))
{
if (currItem->isTableItem)
{
Deselect(false);
SelItem.append(currItem);
currItem->isSingleSel = true;
currItem->Select = true;
emit HaveSel(currItem->itemType());
EmitValues(currItem);
currItem->paintObj();
}
}
}
else
contentsMousePressEvent(m);
return;
}
if (GetItem(&currItem))
{
if ((currItem->itemType() == PageItem::Polygon) || (currItem->itemType() == PageItem::PolyLine) || (currItem->itemType() == PageItem::ImageFrame) || (currItem->itemType() == PageItem::PathText))
{
if ((currItem->locked()) || (!currItem->ScaleType))
{
contentsMousePressEvent(m);
return;
}
emit Amode(EditMode);
}
else
if (currItem->itemType() == PageItem::TextFrame)
{
emit currItem->isAnnotation ? AnnotProps() : Amode(EditMode);
contentsMousePressEvent(m);
}
}
}
void ScribusView::contentsMouseReleaseEvent(QMouseEvent *m)
{
PageItem *currItem;
Mpressed = false;
if (Doc->guidesSettings.guidesShown)
{
bool fg = false;
double nx = m->x()/Scale;
double ny = m->y()/Scale;
if (Doc->currentPage->YGuides.count() != 0)
{
for (uint yg = 0; yg < Doc->currentPage->YGuides.count(); ++yg)
{
if ((Doc->currentPage->YGuides[yg]+Doc->currentPage->Yoffset < (ny+Doc->guidesSettings.grabRad)) &&
(Doc->currentPage->YGuides[yg]+Doc->currentPage->Yoffset > (ny-Doc->guidesSettings.grabRad)))
{
fg = true;
break;
}
}
}
if (Doc->currentPage->XGuides.count() != 0)
{
for (uint xg = 0; xg < Doc->currentPage->XGuides.count(); ++xg)
{
if ((Doc->currentPage->XGuides[xg]+Doc->currentPage->Xoffset < (nx+Doc->guidesSettings.grabRad)) &&
(Doc->currentPage->XGuides[xg]+Doc->currentPage->Xoffset > (nx-Doc->guidesSettings.grabRad)))
{
fg = true;
break;
}
}
}
if ((fg) && (m->button() == RightButton) && (!GetItem(&currItem)))
{
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
MoveGY = false;
MoveGX = false;
emit EditGuides();
return;
}
if (MoveGY)
{
SetYGuide(m, GyM);
MoveGY = false;
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
updateContents();
return;
}
if (MoveGX)
{
SetXGuide(m, GxM);
MoveGX = false;
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
updateContents();
return;
}
}
if (Doc->appMode == EditGradientVectors)
return;
if (Doc->appMode == CopyProperties)
return;
if (Doc->appMode == MeasurementTool)
{
QPainter p;
p.begin(viewport());
ToView(&p);
p.setRasterOp(XorROP);
p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin));
p.drawLine(Dxp, Dyp, Mxp, Myp);
p.end();
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
//emit PaintingDone();
return;
}
if (Doc->appMode == PanningMode)
return;
if (Doc->appMode == DrawTable)
{
if ((SelItem.count() == 0) && (HaveSelRect) && (!MidButt))
{
QRect AreaR = QRect(static_cast<int>(Mxp), static_cast<int>(Myp), static_cast<int>(SeRx-Mxp), static_cast<int>(SeRy-Myp));
QPainter p;
p.begin(viewport());
ToView(&p);
p.scale(Scale, Scale);
p.setRasterOp(XorROP);
p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin));
if(Mxp > SeRx)
{
double tmp=SeRx;
SeRx=static_cast<int>(Mxp);
Mxp=static_cast<int>(tmp);
}
if(Myp > SeRy)
{
double tmp=SeRy;
SeRy=static_cast<int>(Myp);
Myp=static_cast<int>(tmp);
}
HaveSelRect = false;
double Tx, Ty, Tw, Th;
Tx = Mxp;
Ty = Myp;
Tw = SeRx-Mxp;
Th = SeRy-Myp;
int z;
int Cols, Rows;
double deltaX, deltaY, offX, offY;
if ((Th < 6) || (Tw < 6))
{
p.drawRect(AreaR);
p.end();
Doc->appMode = NormalMode;
emit PaintingDone();
return;
}
InsertTable *dia = new InsertTable(this, static_cast<int>(Th / 6), static_cast<int>(Tw / 6));
if (!dia->exec())
{
p.drawRect(AreaR);
p.end();
Doc->appMode = NormalMode;
emit PaintingDone();
delete dia;
return;
}
p.end();
Cols = dia->Cols->value();
Rows = dia->Rows->value();
delete dia;
deltaX = Tw / Cols;
deltaY = Th / Rows;
offX = 0.0;
offY = 0.0;
SelItem.clear();
if (UndoManager::undoEnabled())
undoManager->beginTransaction(Doc->currentPage->getUName(), Um::ITable, Um::CreateTable,
QString(Um::RowsCols).arg(Rows).arg(Cols), Um::ICreate);
for (int rc = 0; rc < Rows; ++rc)
{
for (int cc = 0; cc < Cols; ++cc)
{
z = PaintText(Tx + offX, Ty + offY, deltaX, deltaY, Doc->toolSettings.dWidth, Doc->toolSettings.dPenText);
currItem = Doc->Items.at(z);
currItem->isTableItem = true;
SelItem.append(currItem);
offX += deltaX;
}
offY += deltaY;
offX = 0.0;
}
for (int rc = 0; rc < Rows; ++rc)
{
for (int cc = 0; cc < Cols; ++cc)
{
currItem = SelItem.at((rc * Cols) + cc);
if (rc == 0)
currItem->TopLink = 0;
else
currItem->TopLink = SelItem.at(((rc-1)*Cols)+cc);
if (rc == Rows-1)
currItem->BottomLink = 0;
else
currItem->BottomLink = SelItem.at(((rc+1)*Cols)+cc);
if (cc == 0)
currItem->LeftLink = 0;
else
currItem->LeftLink = SelItem.at((rc*Cols)+cc-1);
if (cc == Cols-1)
currItem->RightLink = 0;
else
currItem->RightLink = SelItem.at((rc*Cols)+cc+1);
}
}
emit DoGroup();
if (UndoManager::undoEnabled())
undoManager->commit();
}
Doc->appMode = NormalMode;
emit PaintingDone();
emit DocChanged();
updateContents();
return;
}
if (Doc->appMode == DrawFreehandLine)
{
Doc->appMode = NormalMode;
if (RecordP.size() > 1)
{
uint z = PaintPolyLine(0, 0, 1, 1, Doc->toolSettings.dWidth, "None", Doc->toolSettings.dPenLine);
currItem = Doc->Items.at(z);
currItem->PoLine.resize(0);
currItem->PoLine.addPoint(RecordP.point(0));
currItem->PoLine.addPoint(RecordP.point(0));
for (uint px = 1; px < RecordP.size()-1; ++px)
{
currItem->PoLine.addPoint(RecordP.point(px));
currItem->PoLine.addPoint(RecordP.point(px));
currItem->PoLine.addPoint(RecordP.point(px));
currItem->PoLine.addPoint(RecordP.point(px));
}
currItem->PoLine.addPoint(RecordP.point(RecordP.size()-1));
currItem->PoLine.addPoint(RecordP.point(RecordP.size()-1));
AdjustItemSize(currItem);
SelItem.clear();
SelItem.append(currItem);
currItem->ClipEdited = true;
currItem->Select = true;
currItem->FrameType = 3;
currItem->OwnPage = OnPage(currItem);
emit ItemPos(currItem->Xpos, currItem->Ypos);
emit SetSizeValue(currItem->Pwidth);
emit SetLineArt(currItem->PLineArt, currItem->PLineEnd, currItem->PLineJoin);
emit ItemFarben(currItem->lineColor(), currItem->fillColor(), currItem->lineShade(), currItem->fillShade());
emit ItemGradient(currItem->GrType);
emit ItemTrans(currItem->fillTransparency(), currItem->lineTransparency());
emit HaveSel(PageItem::PolyLine);
}
updateContents();
emit PaintingDone();
emit DocChanged();
return;
}
if ((Doc->EditClip) && (ClRe == -1) && (HaveSelRect))
{
double sc = Scale;
QPainter p;
p.begin(viewport());
ToView(&p);
p.scale(Scale, Scale);
p.setRasterOp(XorROP);
p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin));
p.drawRect(Mxp, Myp, SeRx-Mxp, SeRy-Myp);
p.end();
if(Mxp > SeRx)
{
double tmp=SeRx;
SeRx=static_cast<int>(Mxp);
Mxp=static_cast<int>(tmp);
}
if(Myp > SeRy)
{
double tmp=SeRy;
SeRy=static_cast<int>(Myp);
Myp=static_cast<int>(tmp);
}
currItem = SelItem.at(0);
SelNode.clear();
QRect Sele = QRect(static_cast<int>(Mxp*sc), static_cast<int>(Myp*sc), static_cast<int>((SeRx-Mxp)*sc), static_cast<int>((SeRy-Myp)*sc));
FPointArray Clip;
if (EditContour)
Clip = currItem->ContourLine;
else
Clip = currItem->PoLine;
for (uint a = 0; a < Clip.size(); ++a)
{
if (Clip.point(a).x() > 900000)
continue;
p.begin(viewport());
Transform(currItem, &p);
QPoint npf = p.xForm(Clip.pointQ(a));
p.end();
if ((Sele.contains(npf)) && ((a == 0) || (((a-2) % 4) == 0)))
{
ClRe = a;
SelNode.append(a);
emit ClipPo(Clip.point(a).x(), Clip.point(a).y());
}
}
HaveSelRect = false;
MarkClip(currItem);
return;
}
if ((Doc->EditClip) && (SegP1 == -1) && (SegP2 == -1))
{
if (Imoved)
{
currItem = SelItem.at(0);
currItem->OldB2 = currItem->Width;
currItem->OldH2 = currItem->Height;
double nx = m->x()/Scale;
double ny = m->y()/Scale;
if (!ApplyGuides(&nx, &ny))
{
FPoint npg = ApplyGridF(FPoint(nx, ny));
nx = npg.x();
ny = npg.y();
}
FPoint np = transformPointI(FPoint(nx, ny), currItem->Xpos, currItem->Ypos, currItem->Rot, 1, 1);
MoveClipPoint(currItem, np);
}
updateContents();
Imoved = false;
return;
}
if ((Doc->EditClip) && (SegP1 != -1) && (SegP2 != -1))
{
SegP1 = -1;
SegP2 = -1;
currItem = SelItem.at(0);
Imoved = false;
updateContents();
return;
}
if ((!GetItem(&currItem)) && (m->button() == RightButton) && (!Doc->DragP) && (Doc->appMode == NormalMode))
{
QPopupMenu *pmen = new QPopupMenu();
if (ScApp->Buffer2.startsWith("<SCRIBUSELEM"))
{
Mxp = m->x();
Myp = m->y();
pmen->insertItem( tr("&Paste") , this, SLOT(PasteToPage()));
pmen->insertSeparator();
}
setObjectUndoMode();
ScApp->scrActions["editUndoAction"]->addTo(pmen);
ScApp->scrActions["editRedoAction"]->addTo(pmen);
pmen->insertSeparator();
ScApp->scrActions["viewShowMargins"]->addTo(pmen);
ScApp->scrActions["viewShowFrames"]->addTo(pmen);
ScApp->scrActions["viewShowImages"]->addTo(pmen);
ScApp->scrActions["viewShowGrid"]->addTo(pmen);
ScApp->scrActions["viewShowGuides"]->addTo(pmen);
ScApp->scrActions["viewShowBaseline"]->addTo(pmen);
ScApp->scrActions["viewShowTextChain"]->addTo(pmen);
pmen->insertSeparator();
ScApp->scrActions["viewSnapToGrid"]->addTo(pmen);
ScApp->scrActions["viewSnapToGuides"]->addTo(pmen);
pmen->exec(QCursor::pos());
setGlobalUndoMode();
delete pmen;
return;
}
if ((Doc->appMode != Magnifier) && (!Doc->EditClip) && (Doc->appMode != DrawBezierLine))
{
if ((GetItem(&currItem)) && (m->button() == RightButton) && (!Doc->DragP))
{
QPopupMenu *pmen = new QPopupMenu();
QPopupMenu *pmen2 = new QPopupMenu();
pmen3 = new QPopupMenu();
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
QPopupMenu *pmen4 = new QPopupMenu();
QPopupMenu *pmenLevel = new QPopupMenu();
QPopupMenu *pmenPDF = new QPopupMenu();
pmenResolution = new QPopupMenu();
setObjectUndoMode();
if ((currItem->itemType() == PageItem::TextFrame) || (currItem->itemType() == PageItem::ImageFrame) || (currItem->itemType() == PageItem::PathText))
{
QButtonGroup *InfoGroup = new QButtonGroup( this, "InfoGroup" );
InfoGroup->setFrameShape( QButtonGroup::NoFrame );
InfoGroup->setFrameShadow( QButtonGroup::Plain );
InfoGroup->setTitle("");
InfoGroup->setExclusive( true );
InfoGroup->setColumnLayout(0, Qt::Vertical );
InfoGroup->layout()->setSpacing( 0 );
InfoGroup->layout()->setMargin( 0 );
QGridLayout *InfoGroupLayout = new QGridLayout( InfoGroup->layout() );
InfoGroupLayout->setAlignment( Qt::AlignTop );
InfoGroupLayout->setSpacing( 2 );
InfoGroupLayout->setMargin( 0 );
QString txtC, txtC2;
QLabel *InfoT = new QLabel(InfoGroup, "ct");
QLabel *ParCT = new QLabel(InfoGroup, "pt");
QLabel *ParC = new QLabel(InfoGroup, "pc");
QLabel *WordCT = new QLabel(InfoGroup, "wt");
QLabel *WordC = new QLabel(InfoGroup, "wc");
QLabel *CharCT = new QLabel(InfoGroup, "ct");
QLabel *CharC = new QLabel(InfoGroup, "cc");
QLabel *PrintCT = new QLabel(InfoGroup, "nt"); // <a.l.e>
QLabel *PrintC = new QLabel(InfoGroup, "nc"); // </a.l.e>
if (currItem->itemType() == PageItem::ImageFrame)
{
QFileInfo fi = QFileInfo(currItem->Pfile);
InfoT->setText( tr("Picture"));
InfoGroupLayout->addMultiCellWidget( InfoT, 0, 0, 0, 1, Qt::AlignCenter );
ParCT->setText( tr("File: "));
InfoGroupLayout->addWidget( ParCT, 1, 0, Qt::AlignRight );
ParC->setText(fi.fileName());
InfoGroupLayout->addWidget( ParC, 1, 1 );
WordCT->setText( tr("Original PPI: "));
InfoGroupLayout->addWidget( WordCT, 2, 0, Qt::AlignRight );
WordC->setText(txtC.setNum(qRound(currItem->pixm.imgInfo.xres))+" x "+txtC2.setNum(qRound(currItem->pixm.imgInfo.yres)));
InfoGroupLayout->addWidget( WordC, 2, 1 );
CharCT->setText( tr("Actual PPI: "));
InfoGroupLayout->addWidget( CharCT, 3, 0, Qt::AlignRight );
CharC->setText(txtC.setNum(qRound(72.0 / currItem->LocalScX))+" x "+
txtC2.setNum(qRound(72.0 / currItem->LocalScY)));
InfoGroupLayout->addWidget( CharC, 3, 1 );
}
if ((currItem->itemType() == PageItem::TextFrame) || (currItem->itemType() == PageItem::PathText))
{
int Parag = 0;
int Words = 0;
int Chara = 0;
int ParagN = 0;
int WordsN = 0;
int CharaN = 0;
if (currItem->itemType() == PageItem::TextFrame)
{
if ((currItem->NextBox != 0) || (currItem->BackBox != 0))
InfoT->setText( tr("Linked Text"));
else
InfoT->setText( tr("Text Frame"));
}
else
InfoT->setText( tr("Text on a Path"));
InfoGroupLayout->addMultiCellWidget( InfoT, 0, 0, 0, 1, Qt::AlignCenter );
WordAndPara(currItem, &Words, &Parag, &Chara, &WordsN, &ParagN, &CharaN);
ParCT->setText( tr("Paragraphs: "));
InfoGroupLayout->addWidget( ParCT, 1, 0, Qt::AlignRight );
if (ParagN != 0)
ParC->setText(txtC.setNum(Parag+ParagN)+" ("+txtC2.setNum(ParagN)+")");
else
ParC->setText(txtC.setNum(Parag));
InfoGroupLayout->addWidget( ParC, 1, 1 );
WordCT->setText( tr("Words: "));
InfoGroupLayout->addWidget( WordCT, 2, 0, Qt::AlignRight );
if (WordsN != 0)
WordC->setText(txtC.setNum(Words+WordsN)+" ("+txtC2.setNum(WordsN)+")");
else
WordC->setText(txtC.setNum(Words));
InfoGroupLayout->addWidget( WordC, 2, 1 );
CharCT->setText( tr("Chars: "));
InfoGroupLayout->addWidget( CharCT, 3, 0, Qt::AlignRight );
if (CharaN != 0)
CharC->setText(txtC.setNum(Chara+CharaN)+" ("+txtC2.setNum(CharaN)+")");
else
CharC->setText(txtC.setNum(Chara));
InfoGroupLayout->addWidget( CharC, 3, 1 );
}
int row = InfoGroupLayout->numRows(); // <a.l.e>
PrintCT->setText( tr("Print: "));
InfoGroupLayout->addWidget( PrintCT, row, 0, Qt::AlignRight );
if (currItem->isPrintable == true)
PrintC->setText( tr("Enabled"));
else
PrintC->setText( tr("Disabled"));
InfoGroupLayout->addWidget( PrintC, row, 1 ); // </a.l.e>
pmen4->insertItem(InfoGroup);
pmen->insertItem( tr("In&fo"), pmen4);
}
pmen->insertSeparator();
ScApp->scrActions["editUndoAction"]->addTo(pmen);
ScApp->scrActions["editRedoAction"]->addTo(pmen);
pmen->insertSeparator();
ScApp->scrActions["itemAttributes"]->addTo(pmen);
if (currItem->itemType() == PageItem::ImageFrame)
{
ScApp->scrActions["fileImportImage"]->addTo(pmen);
ScApp->scrActions["itemImageIsVisible"]->addTo(pmen);
pmen->insertItem( tr("Preview Settings"), pmenResolution);
ScApp->scrActions["itemPreviewLow"]->addTo(pmenResolution);
ScApp->scrActions["itemPreviewNormal"]->addTo(pmenResolution);
ScApp->scrActions["itemPreviewFull"]->addTo(pmenResolution);
if ((currItem->PicAvail) && (currItem->pixm.imgInfo.valid))
ScApp->scrActions["itemExtendedImageProperties"]->addTo(pmen);
if (currItem->PicAvail)
ScApp->scrActions["itemUpdateImage"]->addTo(pmen);
if (currItem->PicAvail && currItem->isRaster)
ScApp->scrActions["editEditWithImageEditor"]->addTo(pmen);
if ((currItem->PicAvail) && (!currItem->isTableItem))
ScApp->scrActions["itemAdjustFrameToImage"]->addTo(pmen);
}
if (currItem->itemType() == PageItem::TextFrame)
{
ScApp->scrActions["fileImportText"]->addTo(pmen);
ScApp->scrActions["fileImportAppendText"]->addTo(pmen);
ScApp->scrActions["toolsEditWithStoryEditor"]->addTo(pmen);
if (Doc->currentPage->PageNam == "")
{
ScApp->scrActions["itemPDFIsAnnotation"]->addTo(pmenPDF);
ScApp->scrActions["itemPDFIsBookmark"]->addTo(pmenPDF);
if (currItem->isAnnotation)
{
if ((currItem->AnType == 0) || (currItem->AnType == 1) || (currItem->AnType > 9))
ScApp->scrActions["itemPDFAnnotationProps"]->addTo(pmenPDF);
else
ScApp->scrActions["itemPDFFieldProps"]->addTo(pmenPDF);
}
}
pmen->insertItem( tr("&PDF Options"), pmenPDF);
}
if (currItem->itemType() == PageItem::PathText)
ScApp->scrActions["toolsEditWithStoryEditor"]->addTo(pmen);
ScApp->scrActions["itemLock"]->addTo(pmen);
ScApp->scrActions["itemLockSize"]->addTo(pmen);
if (!currItem->isSingleSel)
{
ScApp->scrActions["itemSendToScrapbook"]->addTo(pmen);
if (Doc->Layers.count() > 1)
{
for (uint lam=0; lam < Doc->Layers.count(); ++lam)
{
int lai = pmen3->insertItem(Doc->Layers[lam].Name);
if (Doc->Layers[lam].LNr == Doc->ActiveLayer)
pmen3->setItemEnabled(lai, 0);
}
pmen->insertItem( tr("Send to La&yer"), pmen3);
}
connect(pmen3, SIGNAL(activated(int)), this, SLOT(sentToLayer(int)));
}
if (!currItem->locked())
{
if (SelItem.count() > 1)
{
bool isGroup = true;
int firstElem = -1;
if (currItem->Groups.count() != 0)
firstElem = currItem->Groups.top();
for (uint bx = 0; bx < SelItem.count(); ++bx)
{
if (SelItem.at(bx)->Groups.count() != 0)
{
if (SelItem.at(bx)->Groups.top() != firstElem)
isGroup = false;
}
else
isGroup = false;
}
if (!isGroup)
ScApp->scrActions["itemGroup"]->addTo(pmen);
}
if (currItem->Groups.count() != 0)
ScApp->scrActions["itemUngroup"]->addTo(pmen);
if ((!currItem->isTableItem) && (!currItem->isSingleSel))
{
pmen->insertItem( tr("Le&vel"), pmenLevel);
ScApp->scrActions["itemRaise"]->addTo(pmenLevel);
ScApp->scrActions["itemLower"]->addTo(pmenLevel);
ScApp->scrActions["itemRaiseToTop"]->addTo(pmenLevel);
ScApp->scrActions["itemLowerToBottom"]->addTo(pmenLevel);
}
}
if (Doc->appMode != EditMode) //Create convertTo Menu
{
bool insertConvertToMenu=false;
if (currItem->itemType() == PageItem::TextFrame)
{
insertConvertToMenu=true;
ScApp->scrActions["itemConvertToImageFrame"]->addTo(pmen2);
if (!currItem->isTableItem)
{
ScApp->scrActions["itemConvertToOutlines"]->addTo(pmen2);
ScApp->scrActions["itemConvertToPolygon"]->addTo(pmen2);
}
}
if (currItem->itemType() == PageItem::ImageFrame)
{
insertConvertToMenu=true;
ScApp->scrActions["itemConvertToTextFrame"]->addTo(pmen2);
if (!currItem->isTableItem)
ScApp->scrActions["itemConvertToPolygon"]->addTo(pmen2);
}
if (currItem->itemType() == PageItem::Polygon)
{
insertConvertToMenu=true;
ScApp->scrActions["itemConvertToBezierCurve"]->addTo(pmen2);
ScApp->scrActions["itemConvertToImageFrame"]->addTo(pmen2);
ScApp->scrActions["itemConvertToTextFrame"]->addTo(pmen2);
}
if (insertConvertToMenu)
pmen->insertItem( tr("Conve&rt to"), pmen2);
}
pmen->insertSeparator();
if (!currItem->locked() && !(currItem->isTableItem && currItem->isSingleSel))
ScApp->scrActions["editCut"]->addTo(pmen);
if (!(currItem->isTableItem && currItem->isSingleSel))
ScApp->scrActions["editCopy"]->addTo(pmen);
if ((Doc->appMode == EditMode) && (ScApp->Buffer2.startsWith("<SCRIBUSTEXT")) && (currItem->itemType() == PageItem::TextFrame))
ScApp->scrActions["editPaste"]->addTo(pmen);
if (!currItem->locked() && (Doc->appMode != 7) && (!(currItem->isTableItem && currItem->isSingleSel)))
pmen->insertItem( tr("&Delete"), this, SLOT(DeleteItem()));
if ((currItem->itemType() == PageItem::ImageFrame) || (currItem->itemType() == PageItem::TextFrame))
ScApp->scrActions["editClearContents"]->addTo(pmen);
pmen->insertSeparator();
ScApp->scrActions["toolsProperties"]->addTo(pmen);
pmen->exec(QCursor::pos());
setGlobalUndoMode();
delete pmen;
delete pmen2;
disconnect(pmen3, SIGNAL(activated(int)), this, SLOT(sentToLayer(int)));
delete pmen3;
delete pmen4;
delete pmenLevel;
delete pmenPDF;
delete pmenResolution;
}
if (Doc->appMode == LinkFrames)
{
updateContents();
if (Doc->ElemToLink != 0)
return;
else
{
Doc->appMode = NormalMode;
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
emit PaintingDone();
return;
}
}
if (Doc->appMode == DrawRegularPolygon)
{
currItem = SelItem.at(0);
FPoint np1 = FPoint(m->x() / Scale, m->y() / Scale);
np1 = ApplyGridF(np1);
currItem->Width = np1.x() - currItem->Xpos;
currItem->Height = np1.y()- currItem->Ypos;
FPointArray cli = RegularPolygonF(currItem->Width, currItem->Height, Doc->toolSettings.polyC, Doc->toolSettings.polyS, Doc->toolSettings.polyF, Doc->toolSettings.polyR);
FPoint np = FPoint(cli.point(0));
currItem->PoLine.resize(2);
currItem->PoLine.setPoint(0, np);
currItem->PoLine.setPoint(1, np);
for (uint ax = 1; ax < cli.size(); ++ax)
{
np = FPoint(cli.point(ax));
currItem->PoLine.putPoints(currItem->PoLine.size(), 4, np.x(), np.y(), np.x(), np.y(), np.x(), np.y(), np.x(), np.y());
}
np = FPoint(cli.point(0));
currItem->PoLine.putPoints(currItem->PoLine.size(), 2, np.x(), np.y(), np.x(), np.y());
FPoint tp2 = getMinClipF(&currItem->PoLine);
if ((tp2.x() > -1) || (tp2.y() > -1))
{
SizeItem(currItem->Width - tp2.x(), currItem->Height - tp2.y(), currItem->ItemNr, false, false, false);
}
FPoint tp = getMaxClipF(&currItem->PoLine);
SizeItem(tp.x(), tp.y(), currItem->ItemNr, false, false, false);
currItem->Clip = FlattenPath(currItem->PoLine, currItem->Segments);
AdjustItemSize(currItem);
currItem->ContourLine = currItem->PoLine.copy();
setRedrawBounding(currItem);
currItem->OwnPage = OnPage(currItem);
updateContents();
}
if (Doc->appMode == DrawLine)
{
currItem = SelItem.at(0);
QPainter p;
p.begin(viewport());
Transform(currItem, &p);
QPoint np = p.xFormDev(m->pos());
p.end();
np = ApplyGrid(np);
currItem->Rot = xy2Deg(np.x(), np.y());
currItem->Width = sqrt(pow(np.x(),2.0)+pow(np.y(),2.0));
currItem->Height = 1;
currItem->Sizing = false;
UpdateClip(currItem);
setRedrawBounding(currItem);
currItem->OwnPage = OnPage(currItem);
updateContents();
}
if (GetItem(&currItem))
{
if (GroupSel)
{
if (mCG)
{
double gx, gy, gh, gw, nx, ny, scx, scy;
getGroupRect(&gx, &gy, &gw, &gh);
double sc = Scale;
scx = sc;
scy = sc;
QPoint np2;
if (m->state() & ControlButton)
np2 = QPoint(qRound(m->x()/sc), qRound(((gy+(gh * ((m->x()/sc-gx) / gw)))*sc)/sc));
else
np2 = QPoint(qRound(m->x()/sc), qRound(m->y()/sc));
nx = np2.x();
ny = np2.y();
if (!ApplyGuides(&nx, &ny))
{
np2 = ApplyGrid(np2);
nx = np2.x();
ny = np2.y();
}
switch (HowTo)
{
case 1:
scx = fabs(nx-gx) / gw;
scy = fabs(ny-gy) / gh;
break;
case 2:
scx = fabs(nx-(gx+gw)) / gw;
scy = fabs(ny-(gy+gh)) / gh;
break;
case 3:
scx = fabs(nx-gx) / gw;
scy = fabs(ny-(gy+gh)) / gh;
break;
case 4:
scx = fabs(nx-(gx+gw)) / gw;
scy = fabs(ny-gy) / gh;
break;
case 5:
scx = 1.0;
scy = fabs(ny-gy) / gh;
break;
case 6:
scx = fabs(nx-gx) / gw;
scy = 1.0;
break;
case 7:
scx = fabs(nx-(gx+gw)) / gw;
scy = 1.0;
break;
case 8:
scx = 1.0;
scy = fabs(ny-(gy+gh)) / gh;
break;
}
RotMode = Doc->RotMode;
Doc->RotMode = 0;
scaleGroup(scx, scy);
if ((HowTo == 3) || (HowTo == 8))
moveGroup(0, ny-gy);
if (HowTo == 2)
moveGroup(nx-gx, ny-gy);
if ((HowTo == 7) || (HowTo == 4))
moveGroup(nx-gx, 0);
Doc->RotMode = RotMode;
updateContents();
emit DocChanged();
}
}
else
{
if (currItem->Sizing)
{
FPoint npx;
double nx = m->pos().x()/Scale;
double ny = m->pos().y()/Scale;
if (Doc->SnapGuides)
{
ApplyGuides(&nx, &ny);
npx = transformPointI(FPoint(nx, ny), currItem->Xpos, currItem->Ypos, currItem->Rot, 1, 1);
}
else
npx = ApplyGridF(transformPointI(FPoint(nx, ny), currItem->Xpos, currItem->Ypos, currItem->Rot, 1, 1));
if ((HowTo == 1) && (currItem->itemType() != PageItem::Line) && (Doc->SnapGuides))
SizeItem(npx.x(), npx.y(), currItem->ItemNr);
bool sav = Doc->SnapGuides;
Doc->SnapGuides = false;
switch (HowTo)
{
case 1:
if (currItem->itemType() != PageItem::Line)
{
if (currItem->isTableItem)
{
double dist;
if (currItem->LeftLink != 0)
dist = npx.y() - currItem->LeftLink->Height;
else if (currItem->RightLink != 0)
dist = npx.y() - currItem->RightLink->Height;
else
dist = npx.y() - currItem->Height;
PageItem* bb2;
PageItem* bb = currItem;
while (bb->LeftLink != 0)
{
bb = bb->LeftLink;
}
while (bb->RightLink != 0)
{
bb2 = bb;
while (bb2->BottomLink != 0)
{
MoveRotated(bb2->BottomLink, FPoint(0, dist));
bb2 = bb2->BottomLink;
}
if (bb != currItem)
MoveSizeItem(FPoint(0, 0), FPoint(0, -dist), bb->ItemNr);
bb = bb->RightLink;
}
bb2 = bb;
while (bb2->BottomLink != 0)
{
MoveRotated(bb2->BottomLink, FPoint(0, dist));
bb2 = bb2->BottomLink;
}
if (bb != currItem)
MoveSizeItem(FPoint(0, 0), FPoint(0, -dist), bb->ItemNr);
bb = currItem;
if (currItem->TopLink != 0)
dist = npx.x() - currItem->TopLink->Width;
else if (currItem->BottomLink != 0)
dist = npx.x() - currItem->BottomLink->Width;
else
dist = npx.x() - currItem->Width;
while (bb->TopLink != 0)
{
bb = bb->TopLink;
}
while (bb->BottomLink != 0)
{
bb2 = bb;
while (bb2->RightLink != 0)
{
MoveRotated(bb2->RightLink, FPoint(dist, 0));
bb2 = bb2->RightLink;
}
if (bb != currItem)
MoveSizeItem(FPoint(0, 0), FPoint(-dist, 0), bb->ItemNr);
bb = bb->BottomLink;
}
bb2 = bb;
while (bb2->RightLink != 0)
{
MoveRotated(bb2->RightLink, FPoint(dist, 0));
bb2 = bb2->RightLink;
}
if (bb != currItem)
MoveSizeItem(FPoint(0, 0), FPoint(-dist, 0), bb->ItemNr);
}
if (currItem->imageFlippedH())
MoveItemI(-(currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, currItem->ItemNr, false);
if (currItem->imageFlippedV())
MoveItemI(0, -(currItem->Height - currItem->OldH2)/currItem->LocalScY, currItem->ItemNr, false);
}
else
{
if (sav)
{
double nx = m->pos().x()/Scale;
double ny = m->pos().y()/Scale;
if (Doc->useRaster)
{
FPoint ra = ApplyGridF(FPoint(nx, ny));
nx = ra.x();
ny = ra.y();
}
Doc->SnapGuides = sav;
ApplyGuides(&nx, &ny);
Doc->SnapGuides = false;
double r = atan2(ny - currItem->Ypos, nx - currItem->Xpos)*(180.0/M_PI);
RotateItem(r, currItem->ItemNr);
double w = sqrt(pow(nx - currItem->Xpos, 2) + pow(ny - currItem->Ypos,2));
SizeItem(w, currItem->Height, currItem->ItemNr, true);
}
}
currItem->Sizing = false;
break;
case 2:
if (currItem->itemType() != PageItem::Line)
{
if (currItem->isTableItem)
{
PageItem* bb2;
PageItem* bb = currItem;
while (bb->TopLink != 0)
{
bb = bb->TopLink;
}
while (bb->BottomLink != 0)
{
bb2 = bb;
while (bb2->LeftLink != 0)
{
MoveRotated(bb2->LeftLink, FPoint(npx.x(), 0));
bb2 = bb2->LeftLink;
}
MoveSizeItem(FPoint(npx.x(), 0), FPoint(npx.x(), 0), bb->ItemNr);
bb = bb->BottomLink;
}
bb2 = bb;
while (bb2->LeftLink != 0)
{
MoveRotated(bb2->LeftLink, FPoint(npx.x(), 0));
bb2 = bb2->LeftLink;
}
MoveSizeItem(FPoint(npx.x(), 0), FPoint(npx.x(), 0), bb->ItemNr);
bb = currItem;
while (bb->LeftLink != 0)
{
bb = bb->LeftLink;
}
while (bb->RightLink != 0)
{
bb2 = bb;
while (bb2->TopLink != 0)
{
MoveRotated(bb2->TopLink, FPoint(0, npx.y()));
bb2 = bb2->TopLink;
}
MoveSizeItem(FPoint(0, npx.y()), FPoint(0, npx.y()), bb->ItemNr);
bb = bb->RightLink;
}
bb2 = bb;
while (bb2->TopLink != 0)
{
MoveRotated(bb2->TopLink, FPoint(0, npx.y()));
bb2 = bb2->TopLink;
}
MoveSizeItem(FPoint(0, npx.y()), FPoint(0, npx.y()), bb->ItemNr);
}
else
MoveSizeItem(npx, npx, currItem->ItemNr);
currItem->Sizing = false;
if (!currItem->imageFlippedH())
MoveItemI((currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, currItem->ItemNr);
if (!currItem->imageFlippedV())
MoveItemI(0, (currItem->Height - currItem->OldH2)/currItem->LocalScY, currItem->ItemNr);
}
else
{
if (sav)
{
double nx = m->pos().x()/Scale;
double ny = m->pos().y()/Scale;
if (Doc->useRaster)
{
FPoint ra = ApplyGridF(FPoint(nx, ny));
nx = ra.x();
ny = ra.y();
}
Doc->SnapGuides = sav;
ApplyGuides(&nx, &ny);
Doc->SnapGuides = false;
QWMatrix ma;
ma.translate(currItem->Xpos, currItem->Ypos);
ma.rotate(currItem->Rot);
double mx = ma.m11() * currItem->Width + ma.m21() * currItem->Height + ma.dx();
double my = ma.m22() * currItem->Height + ma.m12() * currItem->Width + ma.dy();
double r = atan2(my-ny,mx-nx)*(180.0/M_PI);
double w = sqrt(pow(mx-nx,2)+pow(my-ny,2));
MoveItem(nx - currItem->Xpos, ny - currItem->Ypos, currItem, true);
SizeItem(w, currItem->Height, currItem->ItemNr, true);
RotateItem(r, currItem->ItemNr);
currItem->Sizing = false;
}
}
break;
case 3:
if (currItem->isTableItem)
{
double dist = npx.x() - currItem->Width;
PageItem* bb2;
PageItem* bb = currItem;
while (bb->TopLink != 0)
{
bb = bb->TopLink;
}
while (bb->BottomLink != 0)
{
bb2 = bb;
while (bb2->RightLink != 0)
{
MoveRotated(bb2->RightLink, FPoint(dist, 0));
bb2 = bb2->RightLink;
}
MoveSizeItem(FPoint(0, 0), FPoint(-dist, 0), bb->ItemNr);
bb = bb->BottomLink;
}
bb2 = bb;
while (bb2->RightLink != 0)
{
MoveRotated(bb2->RightLink, FPoint(dist, 0));
bb2 = bb2->RightLink;
}
MoveSizeItem(FPoint(0, 0), FPoint(-dist, 0), bb->ItemNr);
bb = currItem;
while (bb->LeftLink != 0)
{
bb = bb->LeftLink;
}
while (bb->RightLink != 0)
{
bb2 = bb;
while (bb2->TopLink != 0)
{
MoveRotated(bb2->TopLink, FPoint(0, npx.y()));
bb2 = bb2->TopLink;
}
MoveSizeItem(FPoint(0, npx.y()), FPoint(0, npx.y()), bb->ItemNr);
bb = bb->RightLink;
}
bb2 = bb;
while (bb2->TopLink != 0)
{
MoveRotated(bb2->TopLink, FPoint(0, npx.y()));
bb2 = bb2->TopLink;
}
MoveSizeItem(FPoint(0, npx.y()), FPoint(0, npx.y()), bb->ItemNr);
}
else
MoveSizeItem(FPoint(0, npx.y()), FPoint(currItem->Width - npx.x(), npx.y()), currItem->ItemNr);
currItem->Sizing = false;
if (currItem->imageFlippedH())
MoveItemI(-(currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, currItem->ItemNr, false);
if (!currItem->imageFlippedV())
MoveItemI(0, (currItem->Height - currItem->OldH2)/currItem->LocalScY, currItem->ItemNr, false);
break;
case 4:
if (currItem->isTableItem)
{
double dist = npx.y() - currItem->Height;
PageItem* bb2;
PageItem* bb = currItem;
while (bb->LeftLink != 0)
{
bb = bb->LeftLink;
}
while (bb->RightLink != 0)
{
bb2 = bb;
while (bb2->BottomLink != 0)
{
MoveRotated(bb2->BottomLink, FPoint(0, dist));
bb2 = bb2->BottomLink;
}
MoveSizeItem(FPoint(0, 0), FPoint(0, -dist), bb->ItemNr);
bb = bb->RightLink;
}
bb2 = bb;
while (bb2->BottomLink != 0)
{
MoveRotated(bb2->BottomLink, FPoint(0, dist));
bb2 = bb2->BottomLink;
}
MoveSizeItem(FPoint(0, 0), FPoint(0, -dist), bb->ItemNr);
bb = currItem;
while (bb->TopLink != 0)
{
bb = bb->TopLink;
}
while (bb->BottomLink != 0)
{
bb2 = bb;
while (bb2->LeftLink != 0)
{
MoveRotated(bb2->LeftLink, FPoint(npx.x(), 0));
bb2 = bb2->LeftLink;
}
MoveSizeItem(FPoint(npx.x(), 0), FPoint(npx.x(), 0), bb->ItemNr);
bb = bb->BottomLink;
}
bb2 = bb;
while (bb2->LeftLink != 0)
{
MoveRotated(bb2->LeftLink, FPoint(npx.x(), 0));
bb2 = bb2->LeftLink;
}
MoveSizeItem(FPoint(npx.x(), 0), FPoint(npx.x(), 0), bb->ItemNr);
}
else
MoveSizeItem(FPoint(npx.x(), 0), FPoint(npx.x(), currItem->Height - npx.y()), currItem->ItemNr);
currItem->Sizing = false;
if (!currItem->imageFlippedH())
MoveItemI((currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, currItem->ItemNr, false);
if (currItem->imageFlippedV())
MoveItemI(0, -(currItem->Height - currItem->OldH2)/currItem->LocalScY, currItem->ItemNr, false);
break;
case 5:
if (currItem->isTableItem)
{
double dist = npx.y() - currItem->Height;
PageItem* bb2;
PageItem* bb = currItem;
while (bb->LeftLink != 0)
{
bb = bb->LeftLink;
}
while (bb->RightLink != 0)
{
bb2 = bb;
while (bb2->BottomLink != 0)
{
MoveRotated(bb2->BottomLink, FPoint(0, dist));
bb2 = bb2->BottomLink;
}
MoveSizeItem(FPoint(0, 0), FPoint(0, -dist), bb->ItemNr);
bb = bb->RightLink;
}
bb2 = bb;
while (bb2->BottomLink != 0)
{
MoveRotated(bb2->BottomLink, FPoint(0, dist));
bb2 = bb2->BottomLink;
}
MoveSizeItem(FPoint(0, 0), FPoint(0, -dist), bb->ItemNr);
}
else
MoveSizeItem(FPoint(0, 0), FPoint(0, currItem->Height - npx.y()), currItem->ItemNr);
if (currItem->imageFlippedV())
MoveItemI(0, -(currItem->Height - currItem->OldH2)/currItem->LocalScY, currItem->ItemNr, false);
currItem->Sizing = false;
break;
case 6:
if (currItem->isTableItem)
{
double dist = npx.x() - currItem->Width;
PageItem* bb2;
PageItem* bb = currItem;
while (bb->TopLink != 0)
{
bb = bb->TopLink;
}
while (bb->BottomLink != 0)
{
bb2 = bb;
while (bb2->RightLink != 0)
{
MoveRotated(bb2->RightLink, FPoint(dist, 0));
bb2 = bb2->RightLink;
}
MoveSizeItem(FPoint(0, 0), FPoint(-dist, 0), bb->ItemNr);
bb = bb->BottomLink;
}
bb2 = bb;
while (bb2->RightLink != 0)
{
MoveRotated(bb2->RightLink, FPoint(dist, 0));
bb2 = bb2->RightLink;
}
MoveSizeItem(FPoint(0, 0), FPoint(-dist, 0), bb->ItemNr);
}
else
MoveSizeItem(FPoint(0, 0), FPoint(currItem->Width - npx.x(), 0), currItem->ItemNr);
if (currItem->imageFlippedH())
MoveItemI(-(currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, currItem->ItemNr, false);
currItem->Sizing = false;
break;
case 7:
if (currItem->isTableItem)
{
PageItem* bb2;
PageItem* bb = currItem;
while (bb->TopLink != 0)
{
bb = bb->TopLink;
}
while (bb->BottomLink != 0)
{
bb2 = bb;
while (bb2->LeftLink != 0)
{
MoveRotated(bb2->LeftLink, FPoint(npx.x(), 0));
bb2 = bb2->LeftLink;
}
MoveSizeItem(FPoint(npx.x(), 0), FPoint(npx.x(), 0), bb->ItemNr);
bb = bb->BottomLink;
}
bb2 = bb;
while (bb2->LeftLink != 0)
{
MoveRotated(bb2->LeftLink, FPoint(npx.x(), 0));
bb2 = bb2->LeftLink;
}
MoveSizeItem(FPoint(npx.x(), 0), FPoint(npx.x(), 0), bb->ItemNr);
}
else
MoveSizeItem(FPoint(npx.x(), 0), FPoint(npx.x(), 0), currItem->ItemNr);
currItem->Sizing = false;
if (!currItem->imageFlippedH())
MoveItemI((currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, currItem->ItemNr, false);
if (currItem->imageFlippedV())
MoveItemI(0, -(currItem->Height - currItem->OldH2)/currItem->LocalScY, currItem->ItemNr, false);
break;
case 8:
if (currItem->isTableItem)
{
PageItem* bb2;
PageItem* bb = currItem;
while (bb->LeftLink != 0)
{
bb = bb->LeftLink;
}
while (bb->RightLink != 0)
{
bb2 = bb;
while (bb2->TopLink != 0)
{
MoveRotated(bb2->TopLink, FPoint(0, npx.y()));
bb2 = bb2->TopLink;
}
MoveSizeItem(FPoint(0, npx.y()), FPoint(0, npx.y()), bb->ItemNr);
bb = bb->RightLink;
}
bb2 = bb;
while (bb2->TopLink != 0)
{
MoveRotated(bb2->TopLink, FPoint(0, npx.y()));
bb2 = bb2->TopLink;
}
MoveSizeItem(FPoint(0, npx.y()), FPoint(0, npx.y()), bb->ItemNr);
}
else
MoveSizeItem(FPoint(0, npx.y()), FPoint(0, npx.y()), currItem->ItemNr);
currItem->Sizing = false;
if (currItem->imageFlippedH())
MoveItemI(-(currItem->Width - currItem->OldB2)/currItem->LocalScX, 0, currItem->ItemNr, false);
if (!currItem->imageFlippedV())
MoveItemI(0, (currItem->Height - currItem->OldH2)/currItem->LocalScY, currItem->ItemNr, false);
break;
}
if ((currItem->itemType() == PageItem::TextFrame) && (m->state() & ShiftButton) && (m->state() & ControlButton))
{
double scx = currItem->Width / currItem->OldB2;
double scy = currItem->Height / currItem->OldH2;
scx = scx != scy ? scx / scy : 1.0;
if (currItem->itemText.count() != 0)
{
currItem->ISize = QMAX(qRound(currItem->ISize * scy), 1);
currItem->LineSp = ((currItem->ISize / 10.0)* static_cast<double>(Doc->typographicSetttings.autoLineSpacing) / 100) + (currItem->ISize / 10.0);
currItem->TxtScale = QMIN(QMAX(qRound(currItem->TxtScale * scx), 25), 400);
Doc->CurrTextScale = currItem->TxtScale;
Doc->CurrFontSize = currItem->ISize;
Doc->CurrTextBase = currItem->TxtBase;
Doc->CurrTextShadowX = currItem->TxtShadowX;
Doc->CurrTextShadowY = currItem->TxtShadowY;
Doc->CurrTextOutline = currItem->TxtOutline;
Doc->CurrTextUnderPos = currItem->TxtUnderPos;
Doc->CurrTextUnderWidth = currItem->TxtUnderWidth;
Doc->CurrTextStrikePos = currItem->TxtStrikePos;
Doc->CurrTextStrikeWidth = currItem->TxtStrikeWidth;
emit ItemTextStrike(currItem->TxtStrikePos, currItem->TxtStrikeWidth);
emit ItemTextUnderline(currItem->TxtUnderPos, currItem->TxtUnderWidth);
emit ItemTextOutline(currItem->TxtOutline);
emit ItemTextShadow(currItem->TxtShadowX, currItem->TxtShadowY);
emit ItemTextAttr(currItem->LineSp);
emit ItemTextCols(currItem->Cols, currItem->ColGap);
emit ItemTextSize(currItem->ISize);
emit ItemTextSca(currItem->TxtScale);
emit ItemTextScaV(currItem->TxtScaleV);
emit ItemTextBase(currItem->TxtBase);
for (uint aa = 0; aa < currItem->itemText.count(); ++aa)
{
currItem->itemText.at(aa)->csize = QMAX(qRound(currItem->itemText.at(aa)->csize*scy), 1);
currItem->itemText.at(aa)->cscale = QMAX(QMIN(qRound(currItem->itemText.at(aa)->cscale*scx), 4000), 100);
}
}
}
if (currItem->itemType() == PageItem::ImageFrame)
AdjustPictScale(currItem);
UpdateClip(currItem);
emit ItemTextCols(currItem->Cols, currItem->ColGap);
Doc->SnapGuides = sav;
updateContents();
emit DocChanged();
}
setRedrawBounding(currItem);
currItem->OwnPage = OnPage(currItem);
}
if (Imoved)
{
if (GroupSel)
{
setGroupRect();
double gx, gy, gh, gw;
getGroupRect(&gx, &gy, &gw, &gh);
double nx = gx;
double ny = gy;
if (!ApplyGuides(&nx, &ny))
{
FPoint npx;
npx = ApplyGridF(FPoint(nx, ny));
nx = npx.x();
ny = npx.y();
}
moveGroup(nx-gx, ny-gy, false);
setGroupRect();
getGroupRect(&gx, &gy, &gw, &gh);
nx = gx+gw;
ny = gy+gh;
ApplyGuides(&nx, &ny);
moveGroup(nx-(gx+gw), ny-(gy+gh), false);
setGroupRect();
}
else
{
currItem = SelItem.at(0);
if (currItem->itemType() != PageItem::Line)
{
if (fabs(currItem->Width) < 5)
currItem->Width = 5;
if (fabs(currItem->Height) < 5)
currItem->Height = 5;
}
if (Doc->useRaster)
{
double nx = currItem->Xpos;
double ny = currItem->Ypos;
if (!ApplyGuides(&nx, &ny))
{
FPoint npx;
npx = ApplyGridF(FPoint(nx, ny));
nx = npx.x();
ny = npx.y();
}
MoveItem(nx-currItem->Xpos, ny-currItem->Ypos, currItem);
}
else
MoveItem(0, 0, currItem, false);
}
Imoved = false;
setRedrawBounding(currItem);
currItem->OwnPage = OnPage(currItem);
if (currItem->OwnPage != -1)
{
Doc->currentPage = Doc->Pages.at(currItem->OwnPage);
setMenTxt(currItem->OwnPage);
}
emit HaveSel(currItem->itemType());
EmitValues(currItem);
updateContents();
emit DocChanged();
}
}
if ((SelItem.count() == 0) && (HaveSelRect) && (!MidButt))
{
double sc = Scale;
QPainter p;
p.begin(viewport());
ToView(&p);
p.scale(Scale, Scale);
p.setRasterOp(XorROP);
p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin));
p.drawRect(Mxp, Myp, SeRx-Mxp, SeRy-Myp);
p.end();
if(Mxp > SeRx)
{
double tmp=SeRx;
SeRx=static_cast<int>(Mxp);
Mxp=static_cast<int>(tmp);
}
if(Myp > SeRy)
{
double tmp=SeRy;
SeRy=static_cast<int>(Myp);
Myp=static_cast<int>(tmp);
}
QRect Sele = QRect(static_cast<int>(Mxp*sc), static_cast<int>(Myp*sc), static_cast<int>((SeRx-Mxp)*sc), static_cast<int>((SeRy-Myp)*sc));
if (Doc->Items.count() != 0)
{
for (uint a = 0; a < Doc->Items.count(); ++a)
{
PageItem* docItem = Doc->Items.at(a);
p.begin(viewport());
Transform(docItem, &p);
QRegion apr = QRegion(p.xForm(docItem->Clip));
QRect apr2 = getRedrawBounding(docItem);
p.end();
if ((Doc->MasterP) && (docItem->OnMasterPage != Doc->currentPage->PageNam))
continue;
if (((Sele.contains(apr.boundingRect())) || (Sele.contains(apr2))) && (docItem->LayerNr == Doc->ActiveLayer))
SelectItemNr(a, false);
}
}
HaveSelRect = false;
}
if (Doc->appMode != EditMode)
{
if (Doc->appMode == Rotation)
Doc->RotMode = RotMode;
Doc->appMode = NormalMode;
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
emit PaintingDone();
}
if (GetItem(&currItem))
{
if (SelItem.count() > 1)
{
setGroupRect();
paintGroupRect();
emit HaveSel(currItem->itemType());
double x, y, w, h;
getGroupRect(&x, &y, &w, &h);
emit ItemPos(x, y);
emit ItemGeom(w, h);
}
else
{
emit HaveSel(currItem->itemType());
EmitValues(currItem);
}
}
}
if ((Doc->appMode == EditMode) && !HanMove)
{
currItem = SelItem.at(0);
uint a;
if (currItem->itemType() == PageItem::TextFrame)
{
if (oldCp == currItem->CPos)
{
for (a = 0; a < currItem->itemText.count(); ++a)
currItem->itemText.at(a)->cselect = false;
currItem->HasSel = false;
emit HasNoTextSel();
RefreshItem(currItem);
}
}
else
emit DocChanged();
}
if (Doc->appMode == Magnifier)
{
double sc = Scale;
if (HaveSelRect)
{
if((Mxp*sc) > SeRx)
{
double tmp=SeRx;
SeRx=static_cast<int>(Mxp*sc);
Mxp=static_cast<int>(tmp/sc);
}
if((Myp*sc) > SeRy)
{
double tmp=SeRy;
SeRy=static_cast<int>(Myp*sc);
Myp=static_cast<int>(tmp/sc);
}
double yf = height() / (SeRy/sc-Myp);
double xf = width() / (SeRx/sc-Mxp);
Scale = QMIN(yf, xf);
slotDoZoom();
if (sc == Scale)
{
SetCPo(Mxp, Myp);
HaveSelRect = false;
Doc->appMode = NormalMode;
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
emit PaintingDone();
}
}
else
{
int mx = qRound(m->x() / Scale);
int my = qRound(m->y() / Scale);
Magnify ? slotZoomIn2(mx,my) : slotZoomOut2(mx,my);
if (sc == Scale)
{
HaveSelRect = false;
Doc->appMode = NormalMode;
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
emit PaintingDone();
}
else
qApp->setOverrideCursor(QCursor(loadIcon("LupeZ.xpm")), true);
}
}
if ((Doc->appMode == DrawBezierLine) && (m->button() == LeftButton))
{
currItem = SelItem.at(0);
currItem->ClipEdited = true;
currItem->FrameType = 3;
QPainter p;
QPointArray Bez(4);
p.begin(viewport());
Transform(currItem, &p);
FPoint npf = FPoint(p.xFormDev(m->pos()));
npf = ApplyGridF(npf);
currItem->PoLine.addPoint(npf);
bool ssiz = currItem->Sizing;
currItem->Sizing = true;
if ((currItem->PoLine.size() % 4 == 0) && (currItem->PoLine.size() > 3))
{
FPoint lxy = currItem->PoLine.point(currItem->PoLine.size()-2);
FPoint lk = currItem->PoLine.point(currItem->PoLine.size()-1);
double dx = lxy.x() - lk.x();
double dy = lxy.y() - lk.y();
lk.setX(lk.x() + dx*2);
lk.setY(lk.y() + dy*2);
currItem->PoLine.addPoint(lxy);
currItem->PoLine.addPoint(lk);
}
FPoint np2 = getMinClipF(&currItem->PoLine);
if (np2.x() < 0)
{
currItem->PoLine.translate(-np2.x(), 0);
MoveItem(np2.x(), 0, currItem);
}
if (np2.y() < 0)
{
currItem->PoLine.translate(0, -np2.y());
MoveItem(0, np2.y(), currItem);
}
if (FirstPoly)
{
FirstPoly = false;
currItem->Sizing = ssiz;
}
else
{
SizeItem(currItem->PoLine.WidthHeight().x(), currItem->PoLine.WidthHeight().y(), currItem->ItemNr, false, false, false);
SetPolyClip(currItem, qRound(QMAX(currItem->Pwidth / 2, 1)));
AdjustItemSize(currItem);
currItem->Sizing = ssiz;
currItem->ContourLine = currItem->PoLine.copy();
RefreshItem(currItem);
}
p.end();
}
if ((Doc->appMode == DrawBezierLine) && (m->button() == RightButton))
{
currItem = SelItem.at(0);
currItem->PoLine.resize(currItem->PoLine.size()-2);
if (currItem->PoLine.size() < 4)
{
// emit DelObj(Doc->currentPage->PageNr, currItem->ItemNr);
Doc->Items.remove(currItem->ItemNr);
SelItem.removeFirst();
emit HaveSel(-1);
}
else
{
SizeItem(currItem->PoLine.WidthHeight().x(), currItem->PoLine.WidthHeight().y(), currItem->ItemNr, false, false);
SetPolyClip(currItem, qRound(QMAX(currItem->Pwidth / 2, 1)));
AdjustItemSize(currItem);
currItem->ContourLine = currItem->PoLine.copy();
}
Doc->appMode = NormalMode;
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
emit PaintingDone();
emit DocChanged();
FirstPoly = true;
updateContents();
}
Doc->DragP = false;
Doc->leaveDrag = false;
Imoved = false;
mCG = false;
MidButt = false;
Doc->SubMode = -1;
if (_groupTransactionStarted)
{
for (uint i = 0; i < SelItem.count(); ++i)
SelItem.at(i)->checkChanges(true);
undoManager->commit();
_groupTransactionStarted = false;
}
for (uint i = 0; i < SelItem.count(); ++i)
SelItem.at(i)->checkChanges();
if (_itemCreationTransactionStarted && Doc->appMode != DrawBezierLine)
{
PageItem *ite = SelItem.at(0);
if (ite!=NULL)
{
ite->checkChanges(true);
QString targetName = Um::ScratchSpace;
if (ite->OwnPage > -1)
targetName = Doc->Pages.at(ite->OwnPage)->getUName();
undoManager->commit(targetName, ite->getUPixmap(),
Um::Create + " " + ite->getUName(), "", Um::ICreate);
_itemCreationTransactionStarted = false;
if (!Doc->loading)
emit AddObj(ite);
}
}
}
void ScribusView::contentsMouseMoveEvent(QMouseEvent *m)
{
int newX, newY, c;
double nx, ny, dx, dy;
uint a;
PageItem *currItem;
QPoint np, np2, mop;
FPoint npf, npf2;
QPainter p;
QRect tx;
QPointArray Bez(4);
bool erf = false;
double sc = Scale;
horizRuler->Draw(m->x());
vertRuler->Draw(m->y());
emit MousePos(m->x()/Scale-Doc->currentPage->Xoffset, m->y()/Scale-Doc->currentPage->Yoffset);
if (Doc->guidesSettings.guidesShown)
{
if (MoveGY)
{
FromHRuler(m);
if (((m->y()/sc) < Doc->currentPage->Yoffset) || ((m->y()/sc) > Doc->currentPage->Height+Doc->currentPage->Yoffset))
qApp->setOverrideCursor(QCursor(loadIcon("DelPoint.png")), true);
else
qApp->setOverrideCursor(QCursor(SPLITHC), true);
return;
}
if (MoveGX)
{
FromVRuler(m);
if (((m->x()/sc) < Doc->currentPage->Xoffset) || ((m->x()/sc) > Doc->currentPage->Width+Doc->currentPage->Xoffset))
qApp->setOverrideCursor(QCursor(loadIcon("DelPoint.png")), true);
else
qApp->setOverrideCursor(QCursor(SPLITVC), true);
return;
}
}
/* if ((!Doc->DragP) && (Mpressed) && (SelItem.count() != 0))
{
int cx = Anz->contentsX() - Anz->childX(doku->currentPage->parentWidget());
int cy = Anz->contentsY() - Anz->childY(doku->currentPage->parentWidget());
int cw = Anz->visibleWidth();
int ch = Anz->visibleHeight();
if ((m->y() < cy+10) || ((ch - (m->y() - cy)) - 10 < 0) || (m->x() < cx + 10) || ((cw - (m->x() - cx)) - 10 < 0))
{
if (m->y() < cy+10)
Anz->scrollBy(0, m->y() - cy - 10);
else if ((ch - (m->y() - cy)) - 10 < 0)
Anz->scrollBy(0, m->y() - cy - ch +10);
else if (m->x() < cx + 10)
Anz->scrollBy(m->x() - cx - 10, 0);
else if ((cw - (m->x() - cx)) - 10 < 0)
Anz->scrollBy(m->x() - cx - cw + 10, 0);
BlockLeave = true;
update();
}
else
BlockLeave = false;
} */
if (Mpressed && (Doc->appMode == EditGradientVectors))
{
PageItem *currItem = SelItem.at(0);
newX = m->x();
newY = m->y();
if (m->state() == LeftButton)
{
currItem->GrStartX -= (Mxp - newX) / Scale;
currItem->GrStartX = QMIN(QMAX(0.0, currItem->GrStartX), currItem->Width);
currItem->GrStartY -= (Myp - newY) / Scale;
currItem->GrStartY = QMIN(QMAX(0.0, currItem->GrStartY), currItem->Height);
}
if (m->state() == RightButton)
{
currItem->GrEndX -= (Mxp - newX) / Scale;
currItem->GrEndX = QMIN(QMAX(0.0, currItem->GrEndX), currItem->Width);
currItem->GrEndY -= (Myp - newY) / Scale;
currItem->GrEndY = QMIN(QMAX(0.0, currItem->GrEndY), currItem->Height);
}
Mxp = newX;
Myp = newY;
RefreshItem(currItem);
ScApp->propertiesPalette->Cpal->setSpecialGradient(currItem->GrStartX * Doc->unitRatio, currItem->GrStartY * Doc->unitRatio,
currItem->GrEndX * Doc->unitRatio, currItem->GrEndY * Doc->unitRatio,
currItem->Width * Doc->unitRatio, currItem->Height * Doc->unitRatio);
return;
}
if (Mpressed && (Doc->appMode == MeasurementTool))
{
newX = m->x();
newY = m->y();
p.begin(viewport());
ToView(&p);
p.setRasterOp(XorROP);
p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin));
p.drawLine(Dxp, Dyp, Mxp, Myp);
p.drawLine(Dxp, Dyp, newX, newY);
p.end();
Mxp = newX;
Myp = newY;
double dxp = Dxp / sc - Doc->currentPage->Xoffset;
double dyp = Dyp / sc - Doc->currentPage->Yoffset;
double nxp = newX / sc - Doc->currentPage->Xoffset;
double nyp = newY / sc - Doc->currentPage->Yoffset;
emit MVals(dxp, dyp, nxp, nyp, -xy2Deg(newX/sc - Dxp*sc, newY/sc - Dyp/sc), sqrt(pow(newX/sc - Dxp/sc,2)+pow(newY/sc - Dyp/sc,2)), Doc->docUnitIndex);
return;
}
if (Mpressed && (Doc->appMode == PanningMode))
{
int scroX = m->x() - qRound((Mxp * sc));
int scroY = m->y() - qRound((Myp * sc));
scrollBy(-scroX, -scroY);
Mxp = static_cast<int>((m->x()-scroX)/sc);
Myp = static_cast<int>((m->y()-scroY)/sc);
return;
}
if (Mpressed && (Doc->appMode == DrawFreehandLine))
{
newX = m->x();
newY = m->y();
double newXF = m->x()/sc;
double newYF = m->y()/sc;
if (RecordP.size() > 0)
{
if (FPoint(newXF, newYF) != RecordP.point(RecordP.size()-1))
RecordP.addPoint(FPoint(newXF, newYF));
}
else
RecordP.addPoint(FPoint(newXF, newYF));
p.begin(viewport());
ToView(&p);
if (RecordP.size() > 1)
{
FPoint xp = RecordP.point(RecordP.size()-2);
p.drawLine(qRound(xp.x()*sc), qRound(xp.y()*sc), newX, newY);
}
else
p.drawPoint(m->x(), m->y());
p.end();
return;
}
if (GetItem(&currItem))
{
newX = static_cast<int>(m->x