Rev 617 |
Rev 633 |
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 <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>
#include <qeventloop.h>
#include <qprocess.h>
#if QT_VERSION > 0x030102
#define SPLITVC SplitHCursor
#define SPLITHC SplitVCursor
#else
#define SPLITVC SplitVCursor
#define SPLITHC SplitHCursor
#endif
#include "scribus.h"
#include "mpalette.h"
#include "scribusXml.h"
#include "serializer.h"
#include "insertTable.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, QString 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 void WordAndPara(PageItem* b, int *w, int *p, int *c, int *wN, int *pN, int *cN);
#ifdef HAVE_CMS
QImage ProofPict(QImage *Im, QString Prof, int Rend, cmsHPROFILE emPr=0);
#else
QImage ProofPict(QImage *Im, QString Prof, int Rend);
#endif
extern int callGS(const QStringList & args);
extern double UmReFaktor;
extern int PolyC;
extern int PolyFd;
extern double PolyF;
extern bool PolyS;
extern double PolyR;
extern ProfilesL InputProfiles;
ScribusView::ScribusView(QWidget *parent, ScribusDoc *doc, preV *prefs) : QScrollView(parent, "s", WRepaintNoErase | WNorthWestGravity)
{
Ready = false;
updateOn = true;
Doc = doc;
Doc->PageC = 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->setSuffix( tr( " %" ) );
LE->setValue( 100 );
LE->setFocusPolicy(QWidget::ClickFocus);
SB1 = new QPushButton(this);
SB1->setPixmap(loadIcon("Klein.xpm"));
SB1->setFocusPolicy(QWidget::NoFocus);
SB2 = new QPushButton(this);
SB2->setFocusPolicy(QWidget::NoFocus);
SB2->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->setText( tr("Layer")+" 0");
LY->setPopup(Laymen);
LY->setFocusPolicy(QWidget::NoFocus);
HR = new Hruler(this, Doc);
VR = new Vruler(this, Doc);
UN = new QToolButton(this);
Unitmen = new QPopupMenu(this);
Unitmen->insertItem(tr("pt"));
Unitmen->insertItem(tr("mm"));
Unitmen->insertItem(tr("in"));
Unitmen->insertItem(tr("p"));
UN->setPopup(Unitmen);
UN->setFocusPolicy(QWidget::NoFocus);
UN->setPopupDelay(10);
switch (doc->Einheit)
{
case 0:
UN->setText( tr("pt"));
break;
case 1:
UN->setText( tr("mm"));
break;
case 2:
UN->setText( tr("in"));
break;
case 3:
UN->setText( tr("p"));
break;
}
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;
GroupX = 0;
GroupY = 0;
GroupW = 0;
GroupH = 0;
DrHY = -1;
DrVX = -1;
GyM = 0;
GxM = 0;
ClRe = -1;
ClRe2 = -1;
connect(SB1, SIGNAL(clicked()), this, SLOT(slotZoomOut()));
connect(SB2, 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)));
}
void ScribusView::drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph)
{
if (Doc->loading)
return;
if (!updateOn)
return;
// QTime tim;
// tim.start();
if ((clipw > 0) && (cliph > 0))
{
QPixmap pm = QPixmap(clipw, cliph);
ScPainter *painter = new ScPainter(&pm, clipw, cliph);
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);
painter->setBrush(Doc->papColor);
painter->drawRect(x, y, w, h);
if (Doc->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->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->ActPage->Width * Scale);
int h = static_cast<int>(Doc->ActPage->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->Before)
DrawPageMarks(painter, Doc->ActPage, QRect(clipx, clipy, clipw, cliph));
}
DrawPageItems(painter, QRect(clipx, clipy, clipw, cliph));
if ((!Doc->Before) && (QRect(x, y, w+5, h+5).intersects(QRect(clipx, clipy, clipw, cliph))))
DrawPageMarks(painter, Doc->ActPage, QRect(clipx, clipy, clipw, cliph));
}
if (SelItem.count() != 0)
{
double z = painter->zoomFactor();
painter->setZoomFactor(Scale);
painter->save();
PageItem *b = SelItem.at(0);
if (((Doc->AppMode == 10) || (Doc->AppMode == 11)) && (b->PType == 4))
{
PageItem *nb = b;
while (nb != 0)
{
if (nb->BackBox != 0)
nb = nb->BackBox;
else
break;
}
while (nb != 0)
{
FPoint Start = transformPoint(FPoint(nb->Width/2, nb->Height), nb->Xpos, nb->Ypos, nb->Rot, 1, 1);
nb = nb->NextBox;
if (nb != 0)
{
FPoint End = transformPoint(FPoint(nb->Width/2, 0), nb->Xpos, nb->Ypos, nb->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();
QPoint vr = contentsToViewport(QPoint(clipx, clipy));
bitBlt( viewport(), vr.x(), vr.y(), &pm, 0, 0, clipw, cliph );
delete painter;
}
if (SelItem.count() != 0)
{
PageItem *b = SelItem.at(0);
b->paintObj();
if ((Doc->EditClip) && (b->Select))
MarkClip(b);
if (GroupSel)
{
setGroupRect();
paintGroupRect();
}
}
if (Doc->AppMode == 7)
slotDoCurs(true);
// qDebug( "Time elapsed: %d ms", tim.elapsed() );
}
void ScribusView::DrawMasterItems(ScPainter *painter, Page *page, QRect clip)
{
QPainter p;
int Lnr;
struct Layer ll;
PageItem* b;
ll.Sichtbar = 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);
if (ll.Sichtbar)
{
for (uint a = 0; a < page->FromMaster.count(); ++a)
{
b = page->FromMaster.at(a);
if (b->LayerNr != ll.LNr)
continue;
if ((b->OwnPage != -1) && (b->OwnPage != static_cast<int>(Mp->PageNr)))
continue;
uint OldOwn = b->OwnPage;
double OldX = b->Xpos;
double OldY = b->Ypos;
double OldBX = b->BoundingX;
double OldBY = b->BoundingY;
b->OwnPage = page->PageNr;
if (!b->ChangedMasterItem)
{
b->Xpos = OldX - Mp->Xoffset + page->Xoffset;
b->Ypos = OldY - Mp->Yoffset + page->Yoffset;
b->BoundingX = OldBX - Mp->Xoffset + page->Xoffset;
b->BoundingY = OldBY - Mp->Yoffset + page->Yoffset;
}
QRect oldR = getRedrawBounding(b);
if (clip.intersects(oldR))
b->DrawObj(painter, clip);
b->OwnPage = OldOwn;
if (!b->ChangedMasterItem)
{
b->Xpos = OldX;
b->Ypos = OldY;
b->BoundingX = OldBX;
b->BoundingY = OldBY;
}
}
for (uint a = 0; a < page->FromMaster.count(); ++a)
{
b = page->FromMaster.at(a);
if (b->LayerNr != ll.LNr)
continue;
if (!b->isTableItem)
continue;
if ((b->OwnPage != -1) && (b->OwnPage != static_cast<int>(Mp->PageNr)))
continue;
double OldX = b->Xpos;
double OldY = b->Ypos;
double OldBX = b->BoundingX;
double OldBY = b->BoundingY;
if (!b->ChangedMasterItem)
{
b->Xpos = OldX - Mp->Xoffset + page->Xoffset;
b->Ypos = OldY - Mp->Yoffset + page->Yoffset;
b->BoundingX = OldBX - Mp->Xoffset + page->Xoffset;
b->BoundingY = OldBY - Mp->Yoffset + page->Yoffset;
}
QRect oldR = getRedrawBounding(b);
if (clip.intersects(oldR))
{
painter->setZoomFactor(Scale);
painter->save();
painter->translate(b->Xpos*Scale, b->Ypos*Scale);
painter->rotate(b->Rot);
if (b->Pcolor2 != "None")
{
QColor tmp;
b->SetFarbe(&tmp, b->Pcolor2, b->Shade2);
if ((b->TopLine) || (b->RightLine) || (b->BottomLine) || (b->LeftLine))
{
painter->setPen(tmp, b->Pwidth, b->PLineArt, Qt::SquareCap, b->PLineJoin);
if (b->TopLine)
painter->drawLine(FPoint(0.0, 0.0), FPoint(b->Width, 0.0));
if (b->RightLine)
painter->drawLine(FPoint(b->Width, 0.0), FPoint(b->Width, b->Height));
if (b->BottomLine)
painter->drawLine(FPoint(b->Width, b->Height), FPoint(0.0, b->Height));
if (b->LeftLine)
painter->drawLine(FPoint(0.0, b->Height), FPoint(0.0, 0.0));
}
}
painter->restore();
}
if (!b->ChangedMasterItem)
{
b->Xpos = OldX;
b->Ypos = OldY;
b->BoundingX = OldBX;
b->BoundingY = OldBY;
}
}
}
Lnr++;
}
}
}
painter->setZoomFactor(z);
}
void ScribusView::DrawPageItems(ScPainter *painter, QRect clip)
{
QPainter p;
int Lnr;
struct Layer ll;
PageItem* b;
ll.Sichtbar = false;
ll.LNr = 0;
double z = painter->zoomFactor();
if (Doc->Items.count() != 0)
{
Lnr = 0;
for (uint la2 = 0; la2 < Doc->Layers.count(); ++la2)
{
Level2Layer(Doc, &ll, Lnr);
if (ll.Sichtbar)
{
QPtrListIterator<PageItem> docItem(Doc->Items);
while ( (b = docItem.current()) != 0 )
{
++docItem;
if (b->LayerNr != ll.LNr)
continue;
if ((Doc->MasterP) && ((b->OwnPage != -1) && (b->OwnPage != static_cast<int>(Doc->ActPage->PageNr))))
continue;
QRect oldR = getRedrawBounding(b);
if (clip.intersects(oldR))
{
if (!((Doc->EditClip) && (Mpressed)))
b->DrawObj(painter, clip);
b->Redrawn = true;
if ((Doc->AppMode == 7) && (b->Select) && (b->PType == 4))
{
HR->ItemPos = b->Xpos - Doc->ScratchLeft;
HR->ItemEndPos = (b->Xpos+b->Width) - Doc->ScratchLeft;
if (b->Pcolor2 != "None")
HR->lineCorr = b->Pwidth / 2.0;
else
HR->lineCorr = 0;
HR->ColGap = b->ColGap;
HR->Cols = b->Cols;
HR->Extra = b->Extra;
HR->RExtra = b->RExtra;
HR->First = Doc->Vorlagen[Doc->CurrentABStil].First;
HR->Indent = Doc->Vorlagen[Doc->CurrentABStil].Indent;
if ((b->flippedH % 2 != 0) || (b->Reverse))
HR->Revers = true;
else
HR->Revers = false;
HR->ItemPosValid = true;
HR->repX = false;
if (Doc->CurrentABStil < 5)
HR->TabValues = b->TabValues;
else
HR->TabValues = Doc->Vorlagen[Doc->CurrentABStil].TabValues;
HR->repaint();
}
}
}
QPtrListIterator<PageItem> docItem2(Doc->Items);
while ( (b = docItem2.current()) != 0 )
{
++docItem2;
if (b->LayerNr != ll.LNr)
continue;
if (!b->isTableItem)
continue;
QRect oldR = getRedrawBounding(b);
if (clip.intersects(oldR))
{
painter->setZoomFactor(Scale);
painter->save();
painter->translate(b->Xpos*Scale, b->Ypos*Scale);
painter->rotate(b->Rot);
if (b->Pcolor2 != "None")
{
QColor tmp;
b->SetFarbe(&tmp, b->Pcolor2, b->Shade2);
if ((b->TopLine) || (b->RightLine) || (b->BottomLine) || (b->LeftLine))
{
painter->setPen(tmp, b->Pwidth, b->PLineArt, Qt::SquareCap, b->PLineJoin);
if (b->TopLine)
painter->drawLine(FPoint(0.0, 0.0), FPoint(b->Width, 0.0));
if (b->RightLine)
painter->drawLine(FPoint(b->Width, 0.0), FPoint(b->Width, b->Height));
if (b->BottomLine)
painter->drawLine(FPoint(b->Width, b->Height), FPoint(0.0, b->Height));
if (b->LeftLine)
painter->drawLine(FPoint(0.0, b->Height), FPoint(0.0, 0.0));
}
}
painter->restore();
}
}
}
Lnr++;
}
}
painter->setZoomFactor(z);
}
void ScribusView::DrawPageMarks(ScPainter *p, Page *page, QRect clip)
{
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 (Prefs->MarginsShown)
{
p->setPen(Doc->margColor);
if (Doc->RandFarbig)
{
p->setBrush(Doc->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);
}
p->setPen(Doc->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 (Prefs->BaseShown)
{
p->setPen(Doc->baseColor, lw, SolidLine, FlatCap, MiterJoin);
for (double yg = Doc->BaseOffs; yg < page->Height; yg += Doc->BaseGrid)
p->drawLine(FPoint(0, yg), FPoint(page->Width, yg));
}
if (Prefs->GridShown)
{
double stx = 0;
double endx = page->Width;
double sty = 0;
double endy = page->Height;
/* double stx = clip.x() / Scale;
double endx = QMIN(stx + clip.width() / Scale, page->Width);
double sty = clip.y() / Scale;
double endy = QMIN(sty + clip.height() / Scale, page->Height); */
if (Scale > 0.49)
{
double i,start;
i = Doc->majorGrid;
p->setPen(Doc->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->minorGrid;
p->setPen(Doc->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 (Prefs->GuidesShown)
{
p->setPen(Doc->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 *b = 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 *b;
// 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->ActPage->Xoffset, GroupY-Doc->ActPage->Yoffset);
HR->Draw(e->pos().x());
VR->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 *b;
bool img = false;
// struct Pti *hg;
// uint a;
int re;
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->PType == 2)
{
if ((fi.exists()) && (img))
{
LoadPict(ur.path(), b->ItemNr);
update();
}
}
if (b->PType == 4)
{
if ((b->BackBox != 0) && (b->Ptext.count() == 0))
return;
if ((fi.exists()) && (!img) && (fi.size() < 500000))
{
Serializer *ss = new Serializer(ur.path());
if (ss->Read())
{
int st = doku->CurrentABStil;
ss->GetText(b, st, doku->Vorlagen[st].Font, doku->Vorlagen[st].FontSize);
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 Pti;
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->Ptext.insert(b->CPos, hg);
b->CPos += 1;
}
emit DocChanged();
update();
}
}
}
else
{ */
uint ac = Doc->Items.count();
if ((!img) && (Doc->DraggedElem == 0))
emit LoadElem(QString(text), qRound(e->pos().x()/Scale), qRound(e->pos().y()/Scale), false, false, Doc, this);
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);
b = SelItem.at(dre);
if ((b->PType == 4) && ((b->NextBox != 0) || (b->BackBox != 0)))
{
if (b->BackBox != 0)
{
bb->BackBox = b->BackBox;
fin = SelItem.find(b->BackBox);
if (fin != -1)
bb->BackBox = pasted.at(fin);
bb->BackBox->NextBox = bb;
}
if (b->NextBox != 0)
{
bb->NextBox = b->NextBox;
fin = SelItem.find(b->NextBox);
if (fin != -1)
bb->NextBox = pasted.at(fin);
bb->NextBox->BackBox = bb;
}
}
}
for (uint dre=0; dre<Doc->DragElements.count(); ++dre)
{
b = SelItem.at(dre);
b->NextBox = 0;
b->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)
{
SelectItemNr(as);
}
updateContents();
}
// }
}
}
void ScribusView::contentsMouseDoubleClickEvent(QMouseEvent *m)
{
m->accept();
Mpressed = false;
PageItem *b = 0;
if (Doc->EditClip)
{
emit EndNodeEdit();
return;
}
if ((GroupSel) || (Doc->AppMode != 1))
{
if ((GroupSel) && (Doc->AppMode == 1))
{
if (GetItem(&b))
{
if (b->isTableItem)
{
Deselect(false);
SelItem.append(b);
b->isSingleSel = true;
b->Select = true;
emit HaveSel(b->PType);
EmitValues(b);
b->paintObj();
}
}
}
else
contentsMousePressEvent(m);
return;
}
if (GetItem(&b))
{
if ((b->PType == 6) || (b->PType == 7) || (b->PType == 2) || (b->PType == 8))
{
if ((b->Locked) || (!b->ScaleType))
{
contentsMousePressEvent(m);
return;
}
emit Amode(7);
}
else
if (b->PType == 4)
emit b->isAnnotation ? AnnotProps() : Amode(7);
}
}
void ScribusView::contentsMouseReleaseEvent(QMouseEvent *m)
{
PageItem *b;
Mpressed = false;
if (Prefs->GuidesShown)
{
bool fg = false;
double nx = m->x()/Scale;
double ny = m->y()/Scale;
if (Doc->ActPage->YGuides.count() != 0)
{
for (uint yg = 0; yg < Doc->ActPage->YGuides.count(); ++yg)
{
if ((Doc->ActPage->YGuides[yg]+Doc->ActPage->Yoffset < (ny+Doc->GrabRad)) &&
(Doc->ActPage->YGuides[yg]+Doc->ActPage->Yoffset > (ny-Doc->GrabRad)))
{
fg = true;
break;
}
}
}
if (Doc->ActPage->XGuides.count() != 0)
{
for (uint xg = 0; xg < Doc->ActPage->XGuides.count(); ++xg)
{
if ((Doc->ActPage->XGuides[xg]+Doc->ActPage->Xoffset < (nx+Doc->GrabRad)) &&
(Doc->ActPage->XGuides[xg]+Doc->ActPage->Xoffset > (nx-Doc->GrabRad)))
{
fg = true;
break;
}
}
}
if ((fg) && (m->button() == RightButton))
{
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
MoveGY = false;
MoveGX = false;
emit EditGuides();
return;
}
if (MoveGY)
{
Doc->ActPage->YGuides.remove(Doc->ActPage->YGuides[GyM]);
SetYGuide(m);
MoveGY = false;
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
updateContents();
return;
}
if (MoveGX)
{
Doc->ActPage->XGuides.remove(Doc->ActPage->XGuides[GxM]);
SetXGuide(m);
MoveGX = false;
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
updateContents();
return;
}
}
if (Doc->AppMode == 24)
{
QPainter p;
p.begin(viewport());
ToView(&p);
p.scale(Scale, Scale);
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 == 23)
return;
if (Doc->AppMode == 22)
{
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 = 1;
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 = 1;
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();
for (int rc = 0; rc < Rows; ++rc)
{
for (int cc = 0; cc < Cols; ++cc)
{
z = PaintText(Tx + offX, Ty + offY, deltaX, deltaY, Doc->Dwidth, Doc->DpenText);
b = Doc->Items.at(z);
b->isTableItem = true;
SelItem.append(b);
offX += deltaX;
}
offY += deltaY;
offX = 0.0;
}
for (int rc = 0; rc < Rows; ++rc)
{
for (int cc = 0; cc < Cols; ++cc)
{
b = SelItem.at((rc * Cols) + cc);
if (rc == 0)
b->TopLink = 0;
else
b->TopLink = SelItem.at(((rc-1)*Cols)+cc);
if (rc == Rows-1)
b->BottomLink = 0;
else
b->BottomLink = SelItem.at(((rc+1)*Cols)+cc);
if (cc == 0)
b->LeftLink = 0;
else
b->LeftLink = SelItem.at((rc*Cols)+cc-1);
if (cc == Cols-1)
b->RightLink = 0;
else
b->RightLink = SelItem.at((rc*Cols)+cc+1);
}
}
emit DoGroup();
}
Doc->AppMode = 1;
emit PaintingDone();
emit DocChanged();
updateContents();
return;
}
if (Doc->AppMode == 21)
{
Doc->AppMode = 1;
if (RecordP.size() > 1)
{
uint z = PaintPolyLine(0, 0, 1, 1, Doc->Dwidth, "None", Doc->Dpen);
b = Doc->Items.at(z);
b->PoLine.resize(0);
b->PoLine.addPoint(RecordP.point(0));
b->PoLine.addPoint(RecordP.point(0));
for (uint px = 1; px < RecordP.size()-1; ++px)
{
b->PoLine.addPoint(RecordP.point(px));
b->PoLine.addPoint(RecordP.point(px));
b->PoLine.addPoint(RecordP.point(px));
b->PoLine.addPoint(RecordP.point(px));
}
b->PoLine.addPoint(RecordP.point(RecordP.size()-1));
b->PoLine.addPoint(RecordP.point(RecordP.size()-1));
AdjustItemSize(b);
SelItem.clear();
SelItem.append(b);
b->ClipEdited = true;
b->Select = true;
b->FrameType = 3;
b->OwnPage = OnPage(b);
emit ItemPos(b->Xpos, b->Ypos);
emit SetSizeValue(b->Pwidth);
emit SetLineArt(b->PLineArt, b->PLineEnd, b->PLineJoin);
emit ItemFarben(b->Pcolor2, b->Pcolor, b->Shade2, b->Shade);
emit ItemGradient(b->GrType);
emit ItemTrans(b->Transparency, b->TranspStroke);
emit HaveSel(7);
}
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);
}
b = 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 = b->ContourLine;
else
Clip = b->PoLine;
for (uint a = 0; a < Clip.count(); ++a)
{
if (Clip.point(a).x() > 900000)
continue;
p.begin(viewport());
Transform(b, &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(b);
return;
}
if ((Doc->EditClip) && (SegP1 == -1) && (SegP2 == -1))
{
if (Imoved)
{
b = SelItem.at(0);
b->OldB2 = b->Width;
b->OldH2 = b->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), b->Xpos, b->Ypos, b->Rot, 1, 1);
MoveClipPoint(b, np);
}
updateContents();
Imoved = false;
return;
}
if ((Doc->EditClip) && (SegP1 != -1) && (SegP2 != -1))
{
SegP1 = -1;
SegP2 = -1;
b = SelItem.at(0);
Imoved = false;
updateContents();
return;
}
if ((!GetItem(&b)) && (m->button() == RightButton) && (!Doc->DragP) && (Doc->AppMode == 1))
{
int menid;
QPopupMenu *pmen = new QPopupMenu();
if (ScApp->Buffer2.startsWith("<SCRIBUSELEM"))
{
Mxp = m->x();
Myp = m->y();
pmen->insertItem( tr("&Paste") , this, SLOT(PasteToPage()));
pmen->insertSeparator();
}
menid = pmen->insertItem(tr("Show &Margins"), ScApp, SLOT(ToggleMarks()));
pmen->setItemChecked(menid, Prefs->MarginsShown);
menid = pmen->insertItem(tr("Show &Frames"), ScApp, SLOT(ToggleFrames()));
pmen->setItemChecked(menid, Prefs->FramesShown);
menid = pmen->insertItem(tr("Show &Images"), ScApp, SLOT(TogglePics()));
pmen->setItemChecked(menid, Doc->ShowPic);
menid = pmen->insertItem(tr("Show &Grid"), ScApp, SLOT(ToggleRaster()));
pmen->setItemChecked(menid, Prefs->GridShown);
menid = pmen->insertItem(tr("Show G&uides"), ScApp, SLOT(ToggleGuides()));
pmen->setItemChecked(menid, Prefs->GuidesShown);
menid = pmen->insertItem(tr("Show &Baseline Grid"), ScApp, SLOT(ToggleBase()));
pmen->setItemChecked(menid, Prefs->BaseShown);
pmen->insertSeparator();
int uRas = pmen->insertItem( tr("Sn&ap to Grid"), ScApp, SLOT(ToggleURaster()));
pmen->setItemChecked(uRas, Doc->useRaster);
int uGuide = pmen->insertItem( tr("Sna&p to Guides"), ScApp, SLOT(ToggleUGuides()));
pmen->setItemChecked(uGuide, Doc->SnapGuides);
pmen->exec(QCursor::pos());
delete pmen;
return;
}
if ((Doc->AppMode != 6) && (!Doc->EditClip) && (Doc->AppMode != 13))
{
if ((GetItem(&b)) && (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();
if ((b->PType == 4) || (b->PType == 2) || (b->PType == 8))
{
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 (b->PType == 2)
{
QFileInfo fi = QFileInfo(b->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(b->dpiX))+" x "+txtC2.setNum(qRound(b->dpiY)));
InfoGroupLayout->addWidget( WordC, 2, 1 );
CharCT->setText( tr("Actual PPI: "));
InfoGroupLayout->addWidget( CharCT, 3, 0, Qt::AlignRight );
CharC->setText(txtC.setNum(qRound(72.0 / b->LocalScX))+" x "+
txtC2.setNum(qRound(72.0 / b->LocalScY)));
InfoGroupLayout->addWidget( CharC, 3, 1 );
}
if ((b->PType == 4) || (b->PType == 8))
{
int Parag = 0;
int Words = 0;
int Chara = 0;
int ParagN = 0;
int WordsN = 0;
int CharaN = 0;
if (b->PType == 4)
{
if ((b->NextBox != 0) || (b->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(b, &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 (b->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);
}
if (b->PType == 2)
{
pmen->insertItem( tr("&Get Picture..."), this, SIGNAL(LoadPic()));
int px = pmen->insertItem( tr("I&mage Visible"), this, SLOT(TogglePic()));
pmen->setItemChecked(px, b->PicArt);
if (b->PicAvail)
pmen->insertItem( tr("&Update Picture"), this, SLOT(UpdatePic()));
if (b->PicAvail && b->isRaster)
pmen->insertItem( tr("&Edit Picture"), this, SLOT(CallGimp()));
if ((b->PicAvail) && (!b->isTableItem))
pmen->insertItem( tr("&Adjust Frame to Picture"), this, SLOT(FrameToPic()));
}
if (b->PType == 4)
{
pmen->insertItem( tr("&Get Text..."), this, SIGNAL(LoadPic()));
pmen->insertItem( tr("&Append Text..."), this, SIGNAL(AppendText()));
pmen->insertItem( tr("&Edit Text..."), this, SIGNAL(EditText()));
if (Doc->ActPage->PageNam == "")
{
int pxb = pmenPDF->insertItem( tr("Is PDF &Bookmark"), this, SLOT(ToggleBookmark()));
pmenPDF->setItemChecked(pxb, b->isBookmark);
pxb = pmenPDF->insertItem( tr("Is PDF A&nnotation"), this, SLOT(ToggleAnnotation()));
pmenPDF->setItemChecked(pxb, b->isAnnotation);
if (b->isAnnotation)
{
if ((b->AnType == 0) || (b->AnType == 1) || (b->AnType > 9))
pmenPDF->insertItem( tr("Annotation P&roperties"), this, SIGNAL(AnnotProps()));
else
pmenPDF->insertItem( tr("Field P&roperties"), this, SIGNAL(AnnotProps()));
}
}
pmen->insertItem( tr("&PDF Options"), pmenPDF);
}
if (b->PType == 8)
pmen->insertItem( tr("Edit Text..."), this, SIGNAL(EditText()));
if (!b->Locked)
pmen->insertItem( tr("&Lock"), this, SLOT(ToggleLock()));
else
pmen->insertItem( tr("Un&lock"), this, SLOT(ToggleLock()));
if (!b->LockRes)
pmen->insertItem( tr("Lock Object &Size"), this, SLOT(ToggleResize()));
else
pmen->insertItem( tr("Unlock Object &Size"), this, SLOT(ToggleResize()));
if (!b->isSingleSel)
{
pmen->insertItem( tr("Send to S&crapbook"), this, SLOT(sentToScrap()));
if (Doc->Layers.count() > 1)
{
for (uint lam=0; lam < Doc->Layers.count(); ++lam)
{
int lai = pmen3->insertItem(Doc->Layers[lam].Name);
if (static_cast<int>(lam) == Doc->ActiveLayer)
pmen3->setItemEnabled(lai, 0);
}
pmen->insertItem( tr("Send to La&yer"), pmen3);
}
connect(pmen3, SIGNAL(activated(int)), this, SLOT(sentToLayer(int)));
}
if (b->PType == 4)
pmen->insertItem( tr("&Insert Sample Text"), this, SLOT(LoremIpsum()));
if (!b->Locked)
{
if (SelItem.count() > 1)
{
bool isGroup = true;
int firstElem = -1;
if (b->Groups.count() != 0)
firstElem = b->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)
pmen->insertItem( tr("&Group"), this, SIGNAL(DoGroup()));
}
if (b->Groups.count() != 0)
pmen->insertItem( tr("Un&group"), this, SIGNAL(DoUnGroup()));
if ((!b->isTableItem) && (!b->isSingleSel))
{
pmen->insertItem( tr("Le&vel"), pmenLevel);
pmenLevel->insertItem( tr("Send to &Back"), this, SLOT(ToBack()));
pmenLevel->insertItem( tr("Bring to &Front"), this, SLOT(ToFront()));
pmenLevel->insertItem( tr("&Lower"), this, SLOT(LowerItem()));
pmenLevel->insertItem( tr("&Raise"), this, SLOT(RaiseItem()));
}
}
if (((b->PType == 4) || (b->PType == 2) || (b->PType == 6)) && (Doc->AppMode != 7))
{
if (b->PType == 4)
{
pmen2->insertItem( tr("&Picture Frame"), this, SLOT(ToPicFrame()));
if (!b->isTableItem)
{
pmen2->insertItem( tr("Pol&ygon"), this, SLOT(ToPolyFrame()));
pmen2->insertItem( tr("&Outlines"), this, SLOT(TextToPath()));
}
}
if (b->PType == 2)
{
pmen2->insertItem( tr("&Text Frame"), this, SLOT(ToTextFrame()));
if (!b->isTableItem)
pmen2->insertItem( tr("Pol&ygon"), this, SLOT(ToPolyFrame()));
}
if (b->PType == 6)
{
pmen2->insertItem( tr("&Text Frame"), this, SLOT(ToTextFrame()));
pmen2->insertItem( tr("&Picture Frame"), this, SLOT(ToPicFrame()));
pmen2->insertItem( tr("&Bezier Curve"), this, SLOT(ToBezierFrame()));
}
pmen->insertItem( tr("Conve&rt to"), pmen2);
}
pmen->insertSeparator();
if ((!b->Locked) && (!((b->isTableItem) && (b->isSingleSel))))
pmen->insertItem( tr("Cu&t"), this, SIGNAL(CutItem()));
if (!((b->isTableItem) && (b->isSingleSel)))
pmen->insertItem( tr("&Copy"), this, SIGNAL(CopyItem()));
if ((Doc->AppMode == 7) && (ScApp->Buffer2.startsWith("<SCRIBUSTEXT")) && (b->PType == 4))
pmen->insertItem( tr("&Paste"), ScApp, SLOT(slotEditPaste()));
if ((!b->Locked) && (Doc->AppMode != 7) && (!((b->isTableItem) && (b->isSingleSel))))
pmen->insertItem( tr("&Delete"), this, SLOT(DeleteItem()));
if ((b->PType == 2) || (b->PType == 4))
pmen->insertItem( tr("C&lear Contents"), this, SLOT(ClearItem()));
pmen->insertSeparator();
if (!ScApp->Mpal->isVisible())
pmen->insertItem( tr("Show P&roperties..."), ScApp, SLOT(ToggleMpal()));
else
pmen->insertItem( tr("Hide P&roperties..."), ScApp, SLOT(ToggleMpal()));
pmen->exec(QCursor::pos());
delete pmen;
delete pmen2;
disconnect(pmen3, SIGNAL(activated(int)), this, SLOT(sentToLayer(int)));
delete pmen3;
delete pmen4;
delete pmenLevel;
delete pmenPDF;
}
if (Doc->AppMode == 10)
{
updateContents();
if (Doc->ElemToLink != 0)
return;
}
if (Doc->AppMode == 12)
{
b = SelItem.at(0);
FPoint np1 = FPoint(m->x() / Scale, m->y() / Scale);
np1 = ApplyGridF(np1);
b->Width = np1.x() - b->Xpos;
b->Height = np1.y()- b->Ypos;
FPointArray cli = RegularPolygonF(b->Width, b->Height, PolyC, PolyS, PolyF, PolyR);
FPoint np = FPoint(cli.point(0));
b->PoLine.resize(2);
b->PoLine.setPoint(0, np);
b->PoLine.setPoint(1, np);
for (uint ax = 1; ax < cli.size(); ++ax)
{
np = FPoint(cli.point(ax));
b->PoLine.putPoints(b->PoLine.size(), 4, np.x(), np.y(), np.x(), np.y(), np.x(), np.y(), np.x(), np.y());
}
np = FPoint(cli.point(0));
b->PoLine.putPoints(b->PoLine.size(), 2, np.x(), np.y(), np.x(), np.y());
FPoint tp2 = GetMinClipF(b->PoLine);
if ((tp2.x() > -1) || (tp2.y() > -1))
{
SizeItem(b->Width - tp2.x(), b->Height - tp2.y(), b->ItemNr, false, false, false);
}
FPoint tp = GetMaxClipF(b->PoLine);
SizeItem(tp.x(), tp.y(), b->ItemNr, false, false, false);
b->Clip = FlattenPath(b->PoLine, b->Segments);
AdjustItemSize(b);
b->ContourLine = b->PoLine.copy();
updateContents();
}
if (Doc->AppMode == 8)
{
b = SelItem.at(0);
QPainter p;
p.begin(viewport());
Transform(b, &p);
QPoint np = p.xFormDev(m->pos());
p.end();
np = ApplyGrid(np);
b->Rot = xy2Deg(np.x(), np.y());
b->Width = sqrt(pow(np.x(),2.0)+pow(np.y(),2.0));
b->Height = 0;
b->Sizing = false;
UpdateClip(b);
updateContents();
}
if (GetItem(&b))
{
if (GroupSel)
{
if (mCG)
{
double gx, gy, gh, gw, nx, ny, scx, scy;
getGroupRect(&gx, &gy, &gw, &gh);
double sc = Scale;
QPoint np2 = QPoint(static_cast<int>(m->x()/sc), static_cast<int>(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 (b->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), b->Xpos, b->Ypos, b->Rot, 1, 1);
}
else
npx = ApplyGridF(transformPointI(FPoint(nx, ny), b->Xpos, b->Ypos, b->Rot, 1, 1));
if ((HowTo == 1) && (b->PType != 5) && (Doc->SnapGuides))
SizeItem(npx.x(), npx.y(), b->ItemNr);
bool sav = Doc->SnapGuides;
Doc->SnapGuides = false;
switch (HowTo)
{
case 1:
if (b->PType != 5)
{
if (b->isTableItem)
{
double dist;
if (b->LeftLink != 0)
dist = npx.y() - b->LeftLink->Height;
else if (b->RightLink != 0)
dist = npx.y() - b->RightLink->Height;
else
dist = npx.y() - b->Height;
PageItem* bb2;
PageItem* bb = b;
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 != b)
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 != b)
MoveSizeItem(FPoint(0, 0), FPoint(0, -dist), bb->ItemNr);
bb = b;
if (b->TopLink != 0)
dist = npx.x() - b->TopLink->Width;
else if (b->BottomLink != 0)
dist = npx.x() - b->BottomLink->Width;
else
dist = npx.x() - b->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 != b)
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 != b)
MoveSizeItem(FPoint(0, 0), FPoint(-dist, 0), bb->ItemNr);
}
if (b->flippedH % 2 != 0)
MoveItemI(-(b->Width - b->OldB2)/b->LocalScX, 0, b->ItemNr);
if (b->flippedV % 2 != 0)
MoveItemI(0, -(b->Height - b->OldH2)/b->LocalScY, b->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;
double r = atan2(ny - b->Ypos, nx - b->Xpos)*(180.0/3.1415927);
RotateItem(r, b->ItemNr);
double w = sqrt(pow(nx - b->Xpos, 2) + pow(ny - b->Ypos,2));
SizeItem(w, b->Height, b->ItemNr, true);
}
}
b->Sizing = false;
break;
case 2:
if (b->PType != 5)
{
if (b->isTableItem)
{
PageItem* bb2;
PageItem* bb = b;
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 = b;
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, b->ItemNr);
b->Sizing = false;
if (b->flippedH % 2 == 0)
MoveItemI((b->Width - b->OldB2)/b->LocalScX, 0, b->ItemNr);
if (b->flippedV % 2 == 0)
MoveItemI(0, (b->Height - b->OldH2)/b->LocalScY, b->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(b->Xpos, b->Ypos);
ma.rotate(b->Rot);
double mx = ma.m11() * b->Width + ma.m21() * b->Height + ma.dx();
double my = ma.m22() * b->Height + ma.m12() * b->Width + ma.dy();
double r = atan2(my-ny,mx-nx)*(180.0/3.1415927);
double w = sqrt(pow(mx-nx,2)+pow(my-ny,2));
MoveItem(nx - b->Xpos, ny - b->Ypos, b, true);
SizeItem(w, b->Height, b->ItemNr, true);
RotateItem(r, b->ItemNr);
b->Sizing = false;
}
}
break;
case 3:
if (b->isTableItem)
{
double dist = npx.x() - b->Width;
PageItem* bb2;
PageItem* bb = b;
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 = b;
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(b->Width - npx.x(), npx.y()), b->ItemNr);
b->Sizing = false;
if (b->flippedH % 2 != 0)
MoveItemI(-(b->Width - b->OldB2)/b->LocalScX, 0, b->ItemNr);
if (b->flippedV % 2 == 0)
MoveItemI(0, (b->Height - b->OldH2)/b->LocalScY, b->ItemNr);
break;
case 4:
if (b->isTableItem)
{
double dist = npx.y() - b->Height;
PageItem* bb2;
PageItem* bb = b;
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 = b;
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(), b->Height - npx.y()), b->ItemNr);
b->Sizing = false;
if (b->flippedH % 2 == 0)
MoveItemI((b->Width - b->OldB2)/b->LocalScX, 0, b->ItemNr);
if (b->flippedV % 2 != 0)
MoveItemI(0, -(b->Height - b->OldH2)/b->LocalScY, b->ItemNr);
break;
case 5:
if (b->isTableItem)
{
double dist = npx.y() - b->Height;
PageItem* bb2;
PageItem* bb = b;
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, b->Height - npx.y()), b->ItemNr);
if (b->flippedV % 2 != 0)
MoveItemI(0, -(b->Height - b->OldH2)/b->LocalScY, b->ItemNr);
b->Sizing = false;
break;
case 6:
if (b->isTableItem)
{
double dist = npx.x() - b->Width;
PageItem* bb2;
PageItem* bb = b;
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(b->Width - npx.x(), 0), b->ItemNr);
if (b->flippedH % 2 != 0)
MoveItemI(-(b->Width - b->OldB2)/b->LocalScX, 0, b->ItemNr);
b->Sizing = false;
break;
case 7:
if (b->isTableItem)
{
PageItem* bb2;
PageItem* bb = b;
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), b->ItemNr);
b->Sizing = false;
if (b->flippedH % 2 == 0)
MoveItemI((b->Width - b->OldB2)/b->LocalScX, 0, b->ItemNr);
if (b->flippedV % 2 != 0)
MoveItemI(0, -(b->Height - b->OldH2)/b->LocalScY, b->ItemNr);
break;
case 8:
if (b->isTableItem)
{
PageItem* bb2;
PageItem* bb = b;
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()), b->ItemNr);
b->Sizing = false;
if (b->flippedH % 2 != 0)
MoveItemI(-(b->Width - b->OldB2)/b->LocalScX, 0, b->ItemNr);
if (b->flippedV % 2 == 0)
MoveItemI(0, (b->Height - b->OldH2)/b->LocalScY, b->ItemNr);
break;
}
if ((b->PType == 4) && (m->state() & ShiftButton) && (m->state() & ControlButton))
{
double scx = b->Width / b->OldB2;
double scy = b->Height / b->OldH2;
scx = scx != scy ? scx / scy : 1.0;
if (b->Ptext.count() != 0)
{
b->ISize = QMAX(qRound(b->ISize * scy), 1);
b->LineSp = ((b->ISize / 10.0)* static_cast<double>(Doc->AutoLine) / 100) + (b->ISize / 10.0);
b->TxtScale = QMIN(QMAX(qRound(b->TxtScale * scx), 25), 400);
Doc->CurrTextScale = b->TxtScale;
Doc->CurrFontSize = b->ISize;
emit ItemTextAttr(b->LineSp);
emit ItemTextCols(b->Cols, b->ColGap);
emit ItemTextSize(b->ISize);
emit ItemTextSca(b->TxtScale);
for (uint aa = 0; aa < b->Ptext.count(); ++aa)
{
b->Ptext.at(aa)->csize = QMAX(qRound(b->Ptext.at(aa)->csize*scy), 1);
b->Ptext.at(aa)->cscale = QMAX(QMIN(qRound(b->Ptext.at(aa)->cscale*scx), 400), 25);
}
}
}
if (b->PType == 2)
{
AdjustPictScale(b);
AdjustPreview(b, false);
}
UpdateClip(b);
emit ItemTextCols(b->Cols, b->ColGap);
Doc->SnapGuides = sav;
updateContents();
emit DocChanged();
}
}
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
{
b = SelItem.at(0);
if (b->PType != 5)
{
if (fabs(b->Width) < 5)
b->Width = 5;
if (fabs(b->Height) < 5)
b->Height = 5;
}
if (Doc->useRaster)
{
double nx = b->Xpos;
double ny = b->Ypos;
if (!ApplyGuides(&nx, &ny))
{
FPoint npx;
npx = ApplyGridF(FPoint(nx, ny));
nx = npx.x();
ny = npx.y();
}
MoveItem(nx-b->Xpos, ny-b->Ypos, b);
}
else
MoveItem(0, 0, b, false);
}
Imoved = false;
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)
{
p.begin(viewport());
Transform(Doc->Items.at(a), &p);
QRegion apr = QRegion(p.xForm(Doc->Items.at(a)->Clip));
QRect apr2 = getRedrawBounding(Doc->Items.at(a));
p.end();
if (((Sele.contains(apr.boundingRect())) || (Sele.contains(apr2))) && (Doc->Items.at(a)->LayerNr == Doc->ActiveLayer))
SelectItemNr(a, false);
}
}
HaveSelRect = false;
}
if (Doc->AppMode != 7)
{
if (Doc->AppMode == 9)
Doc->RotMode = RotMode;
Doc->AppMode = 1;
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
emit PaintingDone();
}
if (GetItem(&b))
{
if (SelItem.count() > 1)
{
setGroupRect();
paintGroupRect();
emit HaveSel(b->PType);
double x, y, w, h;
getGroupRect(&x, &y, &w, &h);
emit ItemPos(x, y);
emit ItemGeom(w, h);
}
else
{
emit HaveSel(b->PType);
EmitValues(b);
}
}
}
if ((Doc->AppMode == 7) && !HanMove)
{
b = SelItem.at(0);
uint a;
if (b->PType == 4)
{
if (oldCp == b->CPos)
{
for (a = 0; a < b->Ptext.count(); ++a)
b->Ptext.at(a)->cselect = false;
b->HasSel = false;
emit HasNoTextSel();
RefreshItem(b);
}
}
else
emit DocChanged();
}
if (Doc->AppMode == 6)
{
if (HaveSelRect)
{
double sc = Scale;
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();
SetCPo(Mxp, Myp);
HaveSelRect = false;
Doc->AppMode = 1;
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);
HaveSelRect = false;
qApp->setOverrideCursor(QCursor(loadIcon("LupeZ.xpm")), true);
}
}
if ((Doc->AppMode == 13) && (m->button() == LeftButton))
{
b = SelItem.at(0);
b->ClipEdited = true;
b->FrameType = 3;
QPainter p;
QPointArray Bez(4);
p.begin(viewport());
Transform(b, &p);
FPoint npf = FPoint(p.xFormDev(m->pos()));
npf = ApplyGridF(npf);
b->PoLine.addPoint(npf);
bool ssiz = b->Sizing;
b->Sizing = true;
if ((b->PoLine.size() % 4 == 0) && (b->PoLine.size() > 3))
{
FPoint lxy = b->PoLine.point(b->PoLine.size()-2);
FPoint lk = b->PoLine.point(b->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);
b->PoLine.addPoint(lxy);
b->PoLine.addPoint(lk);
}
FPoint np2 = GetMinClipF(b->PoLine);
if (np2.x() < 0)
{
b->PoLine.translate(-np2.x(), 0);
MoveItem(np2.x(), 0, b);
}
if (np2.y() < 0)
{
b->PoLine.translate(0, -np2.y());
MoveItem(0, np2.y(), b);
}
if (FirstPoly)
{
FirstPoly = false;
b->Sizing = ssiz;
}
else
{
SizeItem(b->PoLine.WidthHeight().x(), b->PoLine.WidthHeight().y(), b->ItemNr, false, false, false);
SetPolyClip(b, qRound(QMAX(b->Pwidth / 2, 1)));
AdjustItemSize(b);
b->Sizing = ssiz;
b->ContourLine = b->PoLine.copy();
RefreshItem(b);
}
p.end();
}
if ((Doc->AppMode == 13) && (m->button() == RightButton))
{
b = SelItem.at(0);
b->PoLine.resize(b->PoLine.size()-2);
SizeItem(b->PoLine.WidthHeight().x(), b->PoLine.WidthHeight().y(), b->ItemNr, false, false);
SetPolyClip(b, qRound(QMAX(b->Pwidth / 2, 1)));
AdjustItemSize(b);
b->ContourLine = b->PoLine.copy();
Doc->AppMode = 1;
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;
}
void ScribusView::contentsMouseMoveEvent(QMouseEvent *m)
{
int newX, newY, c;
double nx, ny, dx, dy;
uint a;
PageItem *b;
QPoint np, np2, mop;
FPoint npf, npf2;
QPainter p;
QRect tx;
QPointArray Bez(4);
bool erf = false;
double sc = Scale;
HR->Draw(m->x());
VR->Draw(m->y());
emit MousePos(m->x()/Scale-Doc->ActPage->Xoffset, m->y()/Scale-Doc->ActPage->Yoffset);
if (Prefs->GuidesShown)
{
if (MoveGY)
{
FromHRuler(m);
if (((m->y()/sc) < Doc->ActPage->Yoffset) || ((m->y()/sc) > Doc->ActPage->Height+Doc->ActPage->Yoffset))
qApp->setOverrideCursor(QCursor(loadIcon("DelPoint.png")), true);
else
qApp->setOverrideCursor(QCursor(SPLITHC), true);
return;
}
if (MoveGX)
{
FromVRuler(m);
if (((m->x()/sc) < Doc->ActPage->Xoffset) || ((m->x()/sc) > Doc->ActPage->Width+Doc->ActPage->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->ActPage->parentWidget());
int cy = Anz->contentsY() - Anz->childY(doku->ActPage->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 == 24))
{
newX = m->x();
newY = m->y();
p.begin(viewport());
ToView(&p);
p.scale(Scale, Scale);
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;
emit MVals(Dxp/sc, Dyp/sc, newX/sc, newY/sc, -xy2Deg(newX/sc - Dxp*sc, newY/sc - Dyp/sc), sqrt(pow(newX/sc - Dxp/sc,2)+pow(newY/sc - Dyp/sc,2)), Doc->Einheit);
return;
}
if (Mpressed && (Doc->AppMode == 23))
{
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 == 21))
{
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(&b))
{
newX = static_cast<int>(m->x()/sc);
newY = static_cast<int>(m->y()/sc);
if ((Mpressed) && (m->state() == RightButton) && (!Doc->DragP) && (Doc->AppMode == 1) && (!b->Locked) && (!((b->isTableItem) && (b->isSingleSel))))
{
if ((abs(Dxp - newX) > 10) || (abs(Dyp - newY) > 10))
{
Doc->DragP = true;
Doc->leaveDrag = false;
Doc->DraggedElem = b;
Doc->DragElements.clear();
for (uint dre=0; dre<SelItem.count(); ++dre)
Doc->DragElements.append(SelItem.at(dre)->ItemNr);
ScriXmlDoc *ss = new ScriXmlDoc();
QDragObject *dr = new QTextDrag(ss->WriteElem(&SelItem, Doc, this), this);
dr->setPixmap(loadIcon("DragPix.xpm"));
dr->drag();
delete ss;
Doc->DragP = false;
Doc->leaveDrag = false;
Mpressed = false;
Doc->DraggedElem = 0;
Doc->DragElements.clear();
}
return;
}
if (Doc->DragP)
return;
if (Mpressed && (Doc->AppMode == 9))
{
double newW = xy2Deg(m->x()/sc - RCenter.x(), m->y()/sc - RCenter.y());
if (GroupSel)
RotateGroup(newW - oldW);
else
RotateItem(b->Rot - (oldW - newW), b->ItemNr);
oldW = newW;
emit DocChanged();
}
if (Doc->AppMode == 13)
{
p.begin(viewport());
ToView(&p);
p.scale(Scale, Scale);
p.setRasterOp(XorROP);
p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin));
if ((Doc->useRaster) && (OnPage(b) != -1))
{
newX = static_cast<int>(qRound(newX / Doc->minorGrid) * Doc->minorGrid);
newY = static_cast<int>(qRound(newY / Doc->minorGrid) * Doc->minorGrid);
}
if (!Mpressed)
{
QPoint a1 = b->PoLine.pointQ(b->PoLine.size()-2);
QPoint a2 = b->PoLine.pointQ(b->PoLine.size()-1);
a1 += QPoint(qRound(b->Xpos), qRound(b->Ypos));
a2 += QPoint(qRound(b->Xpos), qRound(b->Ypos));
BezierPoints(&Bez, a1, a2, QPoint(Mxp, Myp), QPoint(Mxp, Myp));
p.drawCubicBezier(Bez);
Bez.setPoint(2, QPoint(newX, newY));
Bez.setPoint(3, QPoint(newX, newY));
p.drawCubicBezier(Bez);
}
else
{
QPoint a2 = b->PoLine.pointQ(b->PoLine.size()-1);
a2 += QPoint(qRound(b->Xpos), qRound(b->Ypos));
if (b->PoLine.size() > 2)
{
QPoint a1 = b->PoLine.pointQ(b->PoLine.size()-2);
QPoint a3 = b->PoLine.pointQ(b->PoLine.size()-3);
a1 += QPoint(qRound(b->Xpos), qRound(b->Ypos));
a3 += QPoint(qRound(b->Xpos), qRound(b->Ypos));
BezierPoints(&Bez, a3, a1, QPoint(Mxp, Myp), a2);
p.drawCubicBezier(Bez);
Bez.setPoint(2, QPoint(newX, newY));
Bez.setPoint(3, a2);
p.drawCubicBezier(Bez);
}
p.drawLine(a2, QPoint(Mxp, Myp));
p.drawLine(a2, QPoint(newX, newY));
}
p.end();
Mxp = newX;
Myp = newY;
}
if (Mpressed && (Doc->AppMode == 12))
{
p.begin(viewport());
ToView(&p);
p.setRasterOp(XorROP);
p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin));
if (m->state() & ShiftButton)
{
mop = QPoint(m->x(), static_cast<int>((b->Ypos + (newX - b->Xpos)) * sc));
QCursor::setPos(mapToGlobal(mop));
newY = static_cast<int>(mop.y()/sc);
}
if ((Doc->useRaster) && (OnPage(b) != -1))
{
newX = static_cast<int>(qRound(newX / Doc->minorGrid) * Doc->minorGrid);
newY = static_cast<int>(qRound(newY / Doc->minorGrid) * Doc->minorGrid);
}
p.drawRect(static_cast<int>(b->Xpos*sc), static_cast<int>(b->Ypos*sc),
static_cast<int>(Mxp*sc-b->Xpos*sc), static_cast<int>(Myp*sc-b->Ypos*sc));
p.drawRect(static_cast<int>(b->Xpos*sc), static_cast<int>(b->Ypos*sc),
static_cast<int>(newX*sc-b->Xpos*sc), static_cast<int>(newY*sc-b->Ypos*sc));
p.end();
emit ItemGeom(newX - b->Xpos, newY - b->Ypos);
Mxp = newX;
Myp = newY;
}
if (Mpressed && (Doc->AppMode == 8))
{
p.begin(viewport());
ToView(&p);
p.setRasterOp(XorROP);
p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin));
if (Doc->useRaster)
{
newX = static_cast<int>(qRound(newX / Doc->minorGrid) * Doc->minorGrid);
newY = static_cast<int>(qRound(newY / Doc->minorGrid) * Doc->minorGrid);
}
p.drawLine(static_cast<int>(b->Xpos*sc), static_cast<int>(b->Ypos*sc), static_cast<int>(Mxp*sc), static_cast<int>(Myp*sc));
p.drawLine(static_cast<int>(b->Xpos*sc), static_cast<int>(b->Ypos*sc), static_cast<int>(newX*sc), static_cast<int>(newY*sc));
p.end();
emit SetAngle(xy2Deg(newX - b->Xpos, newY - b->Ypos));
emit ItemGeom(sqrt(pow(newX - b->Xpos,2)+pow(newY - b->Ypos,2)), 0);
Mxp = newX;
Myp = newY;
}
if (Mpressed && (Doc->AppMode == 7) && (!HanMove))
{
if (b->PType == 2)
{
MoveItemI((newX-Mxp)/b->LocalScX, (newY-Myp)/b->LocalScY, b->ItemNr);
Mxp = newX;
Myp = newY;
}
if (b->PType == 4)
{
for (a = 0; a < b->Ptext.count(); ++a)
b->Ptext.at(a)->cselect = false;
b->HasSel = false;
slotSetCurs(m->x(), m->y());
if (b->Ptext.count() > 0)
{
if (b->CPos < oldCp)
{
for (c = b->CPos; c < oldCp; ++c)
{
b->Ptext.at(c)->cselect = true;
b->HasSel = true;
}
}
if (b->CPos > oldCp)
{
for (c = oldCp; c < b->CPos; ++c)
{
b->Ptext.at(c)->cselect = true;
b->HasSel = true;
}
}
}
RefreshItem(b);
emit b->HasSel ? HasTextSel() : HasNoTextSel();
}
}
if (Mpressed && (m->state() & LeftButton) && ((Doc->AppMode == 1) || ((Doc->AppMode == 7) && HanMove)) && (!b->Locked))
{
if (Doc->EditClip)
{
if ((Mpressed) && (ClRe == -1) && (SegP1 == -1) && (SegP2 == -1))
{
newX = qRound(m->x()/sc);
newY = qRound(m->y()/sc);
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.drawRect(Mxp, Myp, newX-Mxp, newY-Myp);
p.end();
SeRx = newX;
SeRy = newY;
HaveSelRect = true;
return;
}
Imoved = true;
b = SelItem.at(0);
b->OldB2 = b->Width;
b->OldH2 = b->Height;
p.begin(viewport());
Transform(b, &p);
npf = FPoint(p.xFormDev(m->pos()));
p.end();
if ((SegP1 != -1) && (SegP2 != -1))
{
FPointArray Clip;
if (EditContour)
Clip = b->ContourLine;
else
Clip = b->PoLine;
p.begin(viewport());
p.translate(static_cast<int>(b->Xpos*Scale), static_cast<int>(b->Ypos*Scale));
p.rotate(b->Rot);
FPoint npfN = FPoint(p.xFormDev(QPoint(newX, newY)));
FPoint npfM = FPoint(p.xFormDev(QPoint(Mxp, Myp)));
npf.setX(Clip.point(SegP2).x() + (npfN.x()-npfM.x()));
npf.setY(Clip.point(SegP2).y() + (npfN.y()-npfM.y()));
ClRe = SegP2;
MoveClipPoint(b, npf);
b->OldB2 = b->Width;
b->OldH2 = b->Height;
if (EditContour)
Clip = b->ContourLine;
else
Clip = b->PoLine;
ClRe = SegP1;
npf2.setX(Clip.point(SegP1).x() + (npfN.x()-npfM.x()));
npf2.setY(Clip.point(SegP1).y() + (npfN.y()-npfM.y()));
MoveClipPoint(b, npf2);
p.end();
Mxp = newX;
Myp = newY;
}
else
{
if ((SelNode.count() != 0) && (EdPoints))
{
int storedClRe = ClRe;
FPointArray Clip;
if (EditContour)
Clip = b->ContourLine;
else
Clip = b->PoLine;
for (uint itm = 0; itm < SelNode.count(); ++itm)
{
p.begin(viewport());
p.translate(static_cast<int>(b->Xpos*Scale), static_cast<int>(b->Ypos*Scale));
p.rotate(b->Rot);
FPoint npfN = FPoint(p.xFormDev(QPoint(newX, newY)));
FPoint npfM = FPoint(p.xFormDev(QPoint(Mxp, Myp)));
p.end();
npf.setX(Clip.point(*SelNode.at(itm)).x() + (npfN.x()-npfM.x()));
npf.setY(Clip.point(*SelNode.at(itm)).y() + (npfN.y()-npfM.y()));
ClRe = *SelNode.at(itm);
b->OldB2 = b->Width;
b->OldH2 = b->Height;
MoveClipPoint(b, npf);
}
b->OldB2 = b->Width;
b->OldH2 = b->Height;
ClRe = storedClRe;
}
else
MoveClipPoint(b, npf);
Mxp = newX;
Myp = newY;
}
return;
}
if (mCG)
{
Imoved = false;
if (GroupSel)
{
double gx, gy, gh, gw;
getGroupRect(&gx, &gy, &gw, &gh);
int ox1 = qRound(gx*sc);
int oy1 = qRound(gy*sc);
int ox2 = qRound((gx+gw)*sc);
int oy2 = qRound((gy+gh)*sc);
np2 = QPoint(newX, newY);
np2 = ApplyGrid(np2);
double nx = np2.x();
double ny = np2.y();
ApplyGuides(&nx, &ny);
np2 = QPoint(qRound(nx*sc), qRound(ny*sc));
p.begin(viewport());
ToView(&p);
switch (HowTo)
{
case 1:
if (m->state() & ControlButton)
{
np2 = QPoint(m->x(), static_cast<int>((gy+(gh * ((newX-gx) / gw)))*sc));
QCursor::setPos(mapToGlobal(np2));
np2 = QPoint(qRound(np2.x()/sc), qRound(np2.y()/sc));
}
else
np2 = QPoint(qRound(m->x()/sc), qRound(m->y()/sc));
np2 = ApplyGrid(np2);
nx = np2.x();
ny = np2.y();
ApplyGuides(&nx, &ny);
np2 = QPoint(qRound(nx*sc), qRound(ny*sc));
PaintSizeRect(&p, QRect(QPoint(qRound(gx*sc), qRound(gy*sc)), np2));
break;
case 2:
PaintSizeRect(&p, QRect(np2, QPoint(ox2,oy2)));
break;
case 3:
PaintSizeRect(&p, QRect(np2, QPoint(ox1, oy2)));
break;
case 4:
PaintSizeRect(&p, QRect(np2, QPoint(ox2, oy1)));
break;
case 5:
PaintSizeRect(&p, QRect(QPoint(ox1, oy1), QPoint(ox2, np2.y())));
break;
case 6:
PaintSizeRect(&p, QRect(QPoint(np2.x(), oy2), QPoint(ox1,oy1)));
break;
case 7:
PaintSizeRect(&p, QRect(QPoint(np2.x(), oy1), QPoint(ox2, oy2)));
break;
case 8:
PaintSizeRect(&p, QRect(QPoint(ox1, qRound(np2.y())), QPoint(ox2, oy2)));
break;
}
Mxp = qRound(np2.x());
Myp = qRound(np2.y());
p.end();
}
else
{
for (a = 0; a < SelItem.count(); ++a)
{
b = SelItem.at(0);
if ((HowTo == 1) || (HowTo == 2))
{