Rev 418 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3 | paul | 1 | /*************************************************************************** |
2 | page.cpp - description |
||
3 | ------------------- |
||
4 | begin : Sat Apr 7 2001 |
||
5 | copyright : (C) 2001 by Franz Schmid |
||
6 | email : Franz.Schmid@altmuehlnet.de |
||
7 | ***************************************************************************/ |
||
8 | |||
9 | /*************************************************************************** |
||
10 | * * |
||
11 | * This program is free software; you can redistribute it and/or modify * |
||
12 | * it under the terms of the GNU General Public License as published by * |
||
13 | * the Free Software Foundation; either version 2 of the License, or * |
||
14 | * (at your option) any later version. * |
||
15 | * * |
||
16 | ***************************************************************************/ |
||
17 | |||
18 | #include "page.h" |
||
19 | #include "page.moc" |
||
20 | #include "pageitem.h" |
||
21 | #include "serializer.h" |
||
22 | #include "scribusXml.h" |
||
132 | Franz | 23 | #include "scribus.h" |
232 | Franz | 24 | #include "insertTable.h" |
265 | Franz | 25 | #include "mpalette.h" |
128 | Franz | 26 | |
27 | #if (_MSC_VER >= 1200) |
||
28 | #include "win-config.h" |
||
29 | #else |
||
30 | #include "config.h" |
||
31 | #endif |
||
32 | |||
3 | paul | 33 | #include <qapplication.h> |
34 | #include <qcolor.h> |
||
35 | #include <qrect.h> |
||
36 | #include <qpointarray.h> |
||
37 | #include <qregion.h> |
||
38 | #include <qcursor.h> |
||
39 | #include <qimage.h> |
||
40 | #include <qfileinfo.h> |
||
41 | #include <qfile.h> |
||
42 | #include <qtextstream.h> |
||
43 | #include <qcstring.h> |
||
44 | #include <qdragobject.h> |
||
45 | #include <qurl.h> |
||
46 | #include <cmath> |
||
47 | #include <cstdio> |
||
48 | #include <cstdlib> |
||
49 | #include <qbitmap.h> |
||
50 | #include <qwmatrix.h> |
||
51 | #include <qpopupmenu.h> |
||
125 | Franz | 52 | #include <qbuttongroup.h> |
53 | #include <qlayout.h> |
||
214 | Franz | 54 | #include <qevent.h> |
55 | #include <qeventloop.h> |
||
56 | #include <qprocess.h> |
||
237 | Franz | 57 | #include <qscrollbar.h> |
356 | Franz | 58 | #include <qmessagebox.h> |
239 | Franz | 59 | #include <unistd.h> |
272 | Franz | 60 | #if QT_VERSION > 0x030102 |
61 | #define SPLITVC SplitHCursor |
||
62 | #define SPLITHC SplitVCursor |
||
63 | #else |
||
64 | #define SPLITVC SplitVCursor |
||
65 | #define SPLITHC SplitHCursor |
||
66 | #endif |
||
3 | paul | 67 | |
284 | Franz | 68 | #include <unistd.h> |
69 | |||
3 | paul | 70 | #ifdef HAVE_TIFF |
71 | #include <tiffio.h> |
||
72 | #endif |
||
73 | #ifdef HAVE_CMS |
||
44 | Franz | 74 | #include CMS_INC |
3 | paul | 75 | #endif |
418 | Franz | 76 | |
3 | paul | 77 | extern int PolyC; |
78 | extern int PolyFd; |
||
80 | Franz | 79 | extern double PolyF; |
3 | paul | 80 | extern bool PolyS; |
80 | Franz | 81 | extern double PolyR; |
294 | Franz | 82 | extern double UmReFaktor; |
3 | paul | 83 | extern ProfilesL InputProfiles; |
84 | extern QPixmap loadIcon(QString nam); |
||
80 | Franz | 85 | extern double Cwidth(ScribusDoc *doc, QString name, QString ch, int Siz, QString ch2 = " "); |
3 | paul | 86 | #ifdef HAVE_CMS |
87 | QImage ProofPict(QImage *Im, QString Prof, int Rend, cmsHPROFILE emPr=0); |
||
88 | #else |
||
89 | QImage ProofPict(QImage *Im, QString Prof, int Rend); |
||
90 | #endif |
||
80 | Franz | 91 | extern FPointArray RegularPolygonF(double w, double h, uint c, bool star, double factor, double rota); |
3 | paul | 92 | extern QPointArray FlattenPath(FPointArray ina, QValueList<uint> &Segs); |
80 | Franz | 93 | extern double xy2Deg(double x, double y); |
3 | paul | 94 | extern void BezierPoints(QPointArray *ar, QPoint n1, QPoint n2, QPoint n3, QPoint n4); |
95 | extern void Level2Layer(ScribusDoc *doc, struct Layer *ll, int Level); |
||
95 | Franz | 96 | extern FPoint GetMaxClipF(FPointArray Clip); |
125 | Franz | 97 | extern void WordAndPara(PageItem* b, int *w, int *p, int *c, int *wN, int *pN, int *cN); |
132 | Franz | 98 | extern ScribusApp* ScApp; |
204 | Franz | 99 | extern int callGS(const QStringList & args); |
3 | paul | 100 | |
101 | Page::Page(QWidget *pa, int x, int y, int b, int h, ScribusDoc *doc, QScrollView *view) |
||
217 | Franz | 102 | : QWidget(pa, "ps", WRepaintNoErase) |
3 | paul | 103 | { |
104 | resize(b, h); |
||
105 | move(x, y); |
||
106 | setEraseColor(doc->papColor); |
||
107 | doku = doc; |
||
108 | Anz = view; |
||
109 | Items.clear(); |
||
110 | Items.setAutoDelete(true); |
||
111 | Margins.Top = 9; |
||
112 | Margins.Left = 9; |
||
113 | Margins.Right = 9; |
||
114 | Margins.Bottom = 40; |
||
115 | SelItem.clear(); |
||
116 | ClRe = -1; |
||
117 | ClRe2 = -1; |
||
118 | setAcceptDrops(true); |
||
119 | emit DocChanged(); |
||
120 | doku->DragP = false; |
||
227 | Franz | 121 | doku->leaveDrag = false; |
3 | paul | 122 | Imoved = false; |
123 | Mpressed = false; |
||
124 | MidButt = false; |
||
125 | HaveSelRect = false; |
||
126 | PageNam = ""; |
||
127 | LeftPg = false; |
||
128 | Magnify = false; |
||
129 | FirstPoly = true; |
||
130 | EdPoints = true; |
||
131 | MoveSym = false; |
||
132 | GroupSel = false; |
||
133 | DraggedGroup = false; |
||
134 | GroupX = 0; |
||
135 | GroupY = 0; |
||
136 | GroupW = 0; |
||
137 | GroupH = 0; |
||
138 | DrHY = -1; |
||
139 | DrVX = -1; |
||
140 | XGuides.clear(); |
||
141 | YGuides.clear(); |
||
142 | GyM = 0; |
||
143 | MoveGY = false; |
||
144 | GxM = 0; |
||
145 | MoveGX = false; |
||
266 | Franz | 146 | CursVis = false; |
340 | Franz | 147 | EditContour = false; |
3 | paul | 148 | } |
149 | |||
150 | void Page::dragLeaveEvent(QDragLeaveEvent *e) |
||
151 | { |
||
152 | if (DraggedGroup) |
||
167 | Franz | 153 | { |
80 | Franz | 154 | double gx, gy, gw, gh; |
3 | paul | 155 | getGroupRectScreen(&gx, &gy, &gw, &gh); |
156 | repaint(static_cast<int>(gx), static_cast<int>(gy), static_cast<int>(gw), static_cast<int>(gh)); |
||
157 | DraggedGroup = false; |
||
167 | Franz | 158 | } |
3 | paul | 159 | } |
160 | |||
161 | void Page::dragEnterEvent(QDragEnterEvent *e) |
||
162 | { |
||
163 | QString text; |
||
164 | e->accept(QTextDrag::canDecode(e)); |
||
165 | if (QTextDrag::decode(e, text)) |
||
167 | Franz | 166 | { |
80 | Franz | 167 | double gx, gy, gw, gh; |
3 | paul | 168 | QUrl ur(text); |
169 | QFileInfo fi = QFileInfo(ur.path()); |
||
217 | Franz | 170 | ScriXmlDoc *ss = new ScriXmlDoc(); |
3 | paul | 171 | if (fi.exists()) |
172 | text = ur.path(); |
||
217 | Franz | 173 | if(ss->ReadElemHeader(text,fi.exists(), &gx, &gy, &gw, &gh)) |
167 | Franz | 174 | { |
3 | paul | 175 | GroupX = e->pos().x() / doku->Scale; |
176 | GroupY = e->pos().y() / doku->Scale; |
||
177 | GroupW = gw; |
||
178 | GroupH = gh; |
||
179 | DraggedGroup = true; |
||
180 | GroupSel = false; |
||
167 | Franz | 181 | } |
3 | paul | 182 | delete ss; |
183 | setActiveWindow(); |
||
184 | raise(); |
||
228 | Franz | 185 | ScApp->newActWin(doku->WinHan); |
3 | paul | 186 | SeleItemPos(e->pos()); |
167 | Franz | 187 | } |
3 | paul | 188 | } |
189 | |||
190 | void Page::dragMoveEvent(QDragMoveEvent *e) |
||
191 | { |
||
192 | QString text; |
||
193 | PageItem *b; |
||
194 | bool img; |
||
195 | e->accept(QTextDrag::canDecode(e)); |
||
196 | if (QTextDrag::decode(e, text)) |
||
167 | Franz | 197 | { |
198 | if (DraggedGroup) |
||
3 | paul | 199 | { |
80 | Franz | 200 | double gx, gy, gw, gh; |
3 | paul | 201 | getGroupRectScreen(&gx, &gy, &gw, &gh); |
202 | repaint(static_cast<int>(gx), static_cast<int>(gy), static_cast<int>(gw), static_cast<int>(gh)); |
||
203 | GroupX = e->pos().x() / doku->Scale; |
||
204 | GroupY = e->pos().y() / doku->Scale; |
||
205 | paintGroupRect(false); |
||
206 | emit MousePos(GroupX, GroupY); |
||
207 | emit Hrule(e->pos().x()+Anz->childX(parentWidget())); |
||
208 | emit Vrule(e->pos().y()+Anz->childY(parentWidget())); |
||
209 | return; |
||
167 | Franz | 210 | } |
3 | paul | 211 | QUrl ur(text); |
212 | QFileInfo fi = QFileInfo(ur.path()); |
||
213 | QString ext = fi.extension(false).upper(); |
||
214 | QStrList imfo = QImageIO::inputFormats(); |
||
215 | if (ext == "JPG") |
||
216 | ext = "JPEG"; |
||
217 | img = ((imfo.contains(ext))||(ext=="PS")||(ext=="EPS")||(ext=="TIF")); |
||
218 | if (!SeleItemPos(e->pos())) |
||
167 | Franz | 219 | { |
3 | paul | 220 | if (SelItem.count() != 0) |
221 | Deselect(true); |
||
167 | Franz | 222 | } |
3 | paul | 223 | else |
167 | Franz | 224 | { |
3 | paul | 225 | b = SelItem.at(0); |
226 | if (img) |
||
167 | Franz | 227 | { |
3 | paul | 228 | if (b->PType != 2) |
229 | Deselect(true); |
||
167 | Franz | 230 | } |
3 | paul | 231 | else |
167 | Franz | 232 | { |
3 | paul | 233 | if (b->PType != 4) |
234 | Deselect(true); |
||
235 | } |
||
236 | } |
||
167 | Franz | 237 | } |
3 | paul | 238 | } |
239 | |||
240 | void Page::dropEvent(QDropEvent *e) |
||
241 | { |
||
242 | QString text; |
||
243 | PageItem *b; |
||
75 | Franz | 244 | bool img = false; |
3 | paul | 245 | struct Pti *hg; |
246 | uint a; |
||
247 | int re; |
||
275 | Franz | 248 | e->accept(QTextDrag::canDecode(e)); |
3 | paul | 249 | if (QTextDrag::decode(e, text)) |
167 | Franz | 250 | { |
3 | paul | 251 | QUrl ur(text); |
252 | QFileInfo fi = QFileInfo(ur.path()); |
||
253 | QString ext = fi.extension(false).upper(); |
||
254 | QStrList imfo = QImageIO::inputFormats(); |
||
255 | if (ext == "JPG") |
||
256 | ext = "JPEG"; |
||
98 | Franz | 257 | img = ((imfo.contains(ext))||(ext=="PS")||(ext=="EPS")||(ext=="PDF")||(ext=="TIF")); |
97 | Franz | 258 | if ((fi.exists()) && (img) && (!SeleItemPos(e->pos()))) |
167 | Franz | 259 | { |
97 | Franz | 260 | int z = PaintPict(qRound(e->pos().x()/doku->Scale), qRound(e->pos().y()/doku->Scale), 1, 1); |
261 | b = Items.at(z); |
||
217 | Franz | 262 | LoadPict(ur.path(), b->ItemNr); |
97 | Franz | 263 | b->Width = static_cast<double>(b->pixm.width()); |
264 | b->Height = static_cast<double>(b->pixm.height()); |
||
265 | b->OldB2 = b->Width; |
||
266 | b->OldH2 = b->Height; |
||
267 | UpdateClip(b); |
||
268 | emit DocChanged(); |
||
269 | update(); |
||
270 | return; |
||
167 | Franz | 271 | } |
3 | paul | 272 | if ((SeleItemPos(e->pos())) && (!text.startsWith("<SCRIBUSELEM"))) |
167 | Franz | 273 | { |
3 | paul | 274 | b = SelItem.at(0); |
275 | if (b->PType == 2) |
||
167 | Franz | 276 | { |
277 | if ((fi.exists()) && (img)) |
||
3 | paul | 278 | { |
217 | Franz | 279 | LoadPict(ur.path(), b->ItemNr); |
280 | update(); |
||
3 | paul | 281 | } |
167 | Franz | 282 | } |
3 | paul | 283 | if (b->PType == 4) |
167 | Franz | 284 | { |
3 | paul | 285 | if ((b->BackBox != 0) && (b->Ptext.count() == 0)) |
286 | return; |
||
287 | if ((fi.exists()) && (!img) && (fi.size() < 500000)) |
||
167 | Franz | 288 | { |
217 | Franz | 289 | Serializer *ss = new Serializer(ur.path()); |
290 | if (ss->Read()) |
||
291 | { |
||
24 | Franz | 292 | int st = doku->CurrentABStil; |
217 | Franz | 293 | ss->GetText(b, st, doku->Vorlagen[st].Font, doku->Vorlagen[st].FontSize); |
3 | paul | 294 | emit DocChanged(); |
217 | Franz | 295 | } |
296 | delete ss; |
||
297 | update(); |
||
298 | } |
||
3 | paul | 299 | else |
167 | Franz | 300 | { |
3 | paul | 301 | slotDoCurs(false); |
302 | slotSetCurs(e->pos().x(), e->pos().y()); |
||
303 | if (text.startsWith("<SCRIBUSELEM")) |
||
304 | return; |
||
305 | for (a=0; a<text.length(); ++a) |
||
167 | Franz | 306 | { |
3 | paul | 307 | hg = new Pti; |
308 | hg->ch = text.at(a); |
||
68 | Franz | 309 | if (hg->ch == QChar(10)) |
217 | Franz | 310 | hg->ch = QChar(13); |
139 | Franz | 311 | if (hg->ch == QChar(4)) |
217 | Franz | 312 | hg->ch = QChar(9); |
3 | paul | 313 | if (hg->ch == QChar(5)) |
68 | Franz | 314 | hg->ch = QChar(13); |
3 | paul | 315 | hg->cfont = b->IFont; |
316 | hg->csize = b->ISize; |
||
68 | Franz | 317 | hg->ccolor = b->TxtFill; |
318 | hg->cshade = b->ShTxtFill; |
||
319 | hg->cstroke = b->TxtStroke; |
||
320 | hg->cshade2 = b->ShTxtStroke; |
||
321 | hg->cselect = false; |
||
322 | hg->cscale = b->TxtScale; |
||
3 | paul | 323 | hg->cextra = 0; |
324 | hg->cstyle = 0; |
||
325 | hg->cab = 0; |
||
326 | hg->xp = 0; |
||
327 | hg->yp = 0; |
||
328 | hg->PRot = 0; |
||
329 | hg->PtransX = 0; |
||
330 | hg->PtransY = 0; |
||
331 | b->Ptext.insert(b->CPos, hg); |
||
217 | Franz | 332 | b->CPos += 1; |
167 | Franz | 333 | } |
3 | paul | 334 | emit DocChanged(); |
335 | update(); |
||
336 | } |
||
337 | } |
||
167 | Franz | 338 | } |
3 | paul | 339 | else |
167 | Franz | 340 | { |
335 | Franz | 341 | uint ac = Items.count(); |
227 | Franz | 342 | if ((!img) && (doku->DraggedElem == 0)) |
343 | emit LoadElem(QString(text), qRound(e->pos().x()/doku->Scale), qRound(e->pos().y()/doku->Scale), false, false, doku); |
||
279 | Franz | 344 | else |
167 | Franz | 345 | { |
346 | if (doku->DraggedElem != 0) |
||
3 | paul | 347 | { |
227 | Franz | 348 | if (!doku->leaveDrag) |
167 | Franz | 349 | { |
227 | Franz | 350 | QPopupMenu *pmen = new QPopupMenu(); |
351 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
352 | pmen->insertItem( tr("Copy Here")); |
||
353 | pmen->insertItem( tr("Move Here")); |
||
354 | pmen->insertItem( tr("Cancel")); |
||
355 | re = pmen->indexOf(pmen->exec(QCursor::pos())); |
||
356 | delete pmen; |
||
357 | } |
||
358 | else |
||
359 | re = 1; |
||
344 | Franz | 360 | if ((re == 2) || (re == -1)) |
227 | Franz | 361 | { |
362 | update(); |
||
363 | return; |
||
364 | } |
||
365 | if ((re == 1) || (doku->leaveDrag)) |
||
366 | { |
||
228 | Franz | 367 | QPtrList<PageItem> pasted; |
368 | emit LoadElem(QString(text), qRound(e->pos().x()/doku->Scale), qRound(e->pos().y()/doku->Scale), false, false, doku); |
||
369 | for (uint as = ac; as < doku->ActPage->Items.count(); ++as) |
||
370 | { |
||
371 | pasted.append(Items.at(as)); |
||
372 | } |
||
3 | paul | 373 | doku->DraggedElem->OwnPage->SelItem.clear(); |
374 | for (uint dre=0; dre<doku->DragElements.count(); ++dre) |
||
167 | Franz | 375 | { |
227 | Franz | 376 | doku->DraggedElem->OwnPage->SelItem.append(doku->DraggedElem->OwnPage->Items.at(doku->DragElements[dre])); |
167 | Franz | 377 | } |
228 | Franz | 378 | PageItem* bb; |
379 | int fin; |
||
380 | for (uint dre=0; dre<doku->DragElements.count(); ++dre) |
||
381 | { |
||
382 | bb = pasted.at(dre); |
||
383 | b = doku->DraggedElem->OwnPage->SelItem.at(dre); |
||
384 | if ((b->PType == 4) && ((b->NextBox != 0) || (b->BackBox != 0))) |
||
385 | { |
||
386 | if (b->BackBox != 0) |
||
387 | { |
||
388 | bb->BackBox = b->BackBox; |
||
389 | fin = doku->DraggedElem->OwnPage->SelItem.find(b->BackBox); |
||
390 | if (fin != -1) |
||
391 | bb->BackBox = pasted.at(fin); |
||
392 | bb->BackBox->NextBox = bb; |
||
393 | } |
||
394 | if (b->NextBox != 0) |
||
395 | { |
||
396 | bb->NextBox = b->NextBox; |
||
397 | fin = doku->DraggedElem->OwnPage->SelItem.find(b->NextBox); |
||
398 | if (fin != -1) |
||
399 | bb->NextBox = pasted.at(fin); |
||
400 | bb->NextBox->BackBox = bb; |
||
401 | } |
||
402 | } |
||
403 | } |
||
404 | for (uint dre=0; dre<doku->DragElements.count(); ++dre) |
||
405 | { |
||
406 | b = doku->DraggedElem->OwnPage->SelItem.at(dre); |
||
407 | b->NextBox = 0; |
||
408 | b->BackBox = 0; |
||
409 | } |
||
410 | pasted.clear(); |
||
3 | paul | 411 | doku->DraggedElem->OwnPage->DeleteItem(); |
412 | } |
||
167 | Franz | 413 | } |
228 | Franz | 414 | if ((!img) && ((re == 0))) |
227 | Franz | 415 | emit LoadElem(QString(text), qRound(e->pos().x()/doku->Scale), qRound(e->pos().y()/doku->Scale), false, false, doku); |
3 | paul | 416 | doku->DraggedElem = 0; |
417 | doku->DragElements.clear(); |
||
335 | Franz | 418 | doku->ActPage->SelItem.clear(); |
419 | for (uint as = ac; as < doku->ActPage->Items.count(); ++as) |
||
420 | { |
||
421 | doku->ActPage->SelectItemNr(as); |
||
422 | } |
||
125 | Franz | 423 | update(); |
282 | Franz | 424 | } |
3 | paul | 425 | } |
167 | Franz | 426 | } |
3 | paul | 427 | } |
227 | Franz | 428 | void Page::leaveEvent(QEvent *) |
429 | { |
||
228 | Franz | 430 | if (BlockLeave) |
431 | return; |
||
227 | Franz | 432 | if (!Mpressed) |
433 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
434 | else |
||
435 | { |
||
436 | if ((SelItem.count() != 0) && (Mpressed) && (!doku->DragP) && (doku->AppMode == 1)) |
||
437 | { |
||
438 | PageItem *b = SelItem.at(0); |
||
439 | if ((b->Locked) || (b->Sizing)) |
||
440 | return; |
||
441 | doku->DragP = true; |
||
442 | doku->leaveDrag = true; |
||
443 | doku->DraggedElem = b; |
||
444 | doku->DragElements.clear(); |
||
445 | for (uint dre=0; dre<SelItem.count(); ++dre) |
||
446 | doku->DragElements.append(SelItem.at(dre)->ItemNr); |
||
447 | ScriXmlDoc *ss = new ScriXmlDoc(); |
||
448 | QDragObject *dr = new QTextDrag(ss->WriteElem(&SelItem, doku), this); |
||
449 | dr->setPixmap(loadIcon("DragPix.xpm")); |
||
450 | dr->drag(); |
||
451 | delete ss; |
||
452 | doku->DragP = false; |
||
453 | doku->leaveDrag = false; |
||
454 | Mpressed = false; |
||
455 | doku->DraggedElem = 0; |
||
456 | doku->DragElements.clear(); |
||
457 | } |
||
458 | } |
||
459 | } |
||
3 | paul | 460 | |
68 | Franz | 461 | void Page::paintEvent(QPaintEvent *e) |
3 | paul | 462 | { |
377 | Franz | 463 | if (doku->loading) |
464 | return; |
||
68 | Franz | 465 | QRect vr = ViewReg().boundingRect().intersect(e->rect()); |
466 | if ((vr.width() < 1) || (vr.height() < 1)) |
||
467 | return; |
||
444 | fschmid | 468 | // QTime tim; |
469 | // tim.start(); |
||
266 | Franz | 470 | if (doku->AppMode == 7) |
471 | slotDoCurs(false); |
||
386 | Franz | 472 | bool sp = e->spontaneous(); |
68 | Franz | 473 | QPixmap pgPix(vr.width(), vr.height()); |
474 | ScPainter *painter = new ScPainter(&pgPix, pgPix.width(), pgPix.height()); |
||
214 | Franz | 475 | painter->clear(doku->papColor); |
68 | Franz | 476 | painter->translate(0.5, 0.5); |
477 | if (doku->Before) |
||
108 | Franz | 478 | DrawPageMarks(painter, vr); |
386 | Franz | 479 | DrawPageItems(painter, vr, sp); |
68 | Franz | 480 | if (!doku->Before) |
108 | Franz | 481 | DrawPageMarks(painter, vr); |
68 | Franz | 482 | painter->end(); |
483 | bitBlt( this, vr.x(), vr.y(), &pgPix, 0, 0, pgPix.width(), pgPix.height() ); |
||
3 | paul | 484 | QPainter p; |
68 | Franz | 485 | p.begin(this); |
486 | p.setPen(QColor(0, 0, 0)); |
||
487 | p.setBrush(NoBrush); |
||
488 | p.drawRect(0, 0, width(), height()); |
||
217 | Franz | 489 | p.end(); |
167 | Franz | 490 | if (SelItem.count() != 0) |
217 | Franz | 491 | { |
68 | Franz | 492 | PageItem *b = SelItem.at(0); |
493 | b->paintObj(e->rect()); |
||
494 | if ((doku->EditClip) && (b->Select)) |
||
495 | MarkClip(b); |
||
496 | if (GroupSel) |
||
167 | Franz | 497 | { |
68 | Franz | 498 | setGroupRect(); |
499 | paintGroupRect(); |
||
500 | } |
||
167 | Franz | 501 | } |
68 | Franz | 502 | delete painter; |
266 | Franz | 503 | if (doku->AppMode == 7) |
504 | slotDoCurs(true); |
||
444 | fschmid | 505 | // qDebug( "Time elapsed: %d ms", tim.elapsed() ); |
68 | Franz | 506 | } |
507 | |||
108 | Franz | 508 | void Page::DrawPageMarks(ScPainter *p, QRect rd) |
68 | Franz | 509 | { |
80 | Franz | 510 | double b; |
68 | Franz | 511 | if ((rd.width() == 0) || (rd.height() == 0)) |
512 | return; |
||
80 | Franz | 513 | double lw = 1.0 / doku->Scale; |
68 | Franz | 514 | p->setZoomFactor(doku->Scale); |
515 | QWMatrix ma = p->worldMatrix(); |
||
516 | QWMatrix ma2 = p->worldMatrix(); |
||
517 | ma.translate(-rd.x(), -rd.y()); |
||
518 | p->setWorldMatrix(ma); |
||
519 | p->setLineWidth(lw); |
||
243 | Franz | 520 | if (ScApp->Prefs.MarginsShown) |
167 | Franz | 521 | { |
68 | Franz | 522 | p->setPen(doku->margColor); |
3 | paul | 523 | if (doku->RandFarbig) |
167 | Franz | 524 | { |
68 | Franz | 525 | p->setBrush(doku->margColor); |
526 | p->drawRect(0, 0, width()/doku->Scale, Margins.Top); |
||
527 | p->drawRect(0, Margins.Top, Margins.Left, height()/doku->Scale-Margins.Top); |
||
167 | Franz | 528 | p->drawRect(Margins.Left, height()/doku->Scale-Margins.Bottom, |
217 | Franz | 529 | width()/doku->Scale-Margins.Right-Margins.Left, Margins.Bottom); |
68 | Franz | 530 | p->drawRect(width()/doku->Scale-Margins.Right, Margins.Top, Margins.Right, height()/doku->Scale); |
167 | Franz | 531 | } |
68 | Franz | 532 | p->setPen(doku->margColor); |
533 | p->drawLine(FPoint(0, Margins.Top), FPoint(width()/doku->Scale, Margins.Top)); |
||
167 | Franz | 534 | p->drawLine(FPoint(0, height()/doku->Scale-Margins.Bottom), FPoint(width()/doku->Scale, |
217 | Franz | 535 | height()/doku->Scale-Margins.Bottom)); |
68 | Franz | 536 | p->drawLine(FPoint(Margins.Left, 0), FPoint(Margins.Left, height()/doku->Scale)); |
167 | Franz | 537 | p->drawLine(FPoint(width()/doku->Scale-Margins.Right, 0), FPoint(width()/doku->Scale-Margins.Right, |
217 | Franz | 538 | height()/doku->Scale)); |
167 | Franz | 539 | } |
243 | Franz | 540 | if (ScApp->Prefs.BaseShown) |
241 | Franz | 541 | { |
338 | Franz | 542 | p->setPen(doku->baseColor, lw, SolidLine, FlatCap, MiterJoin); |
241 | Franz | 543 | for (double yg = doku->BaseOffs; yg < doku->PageH; yg += doku->BaseGrid) |
544 | p->drawLine(FPoint(0, yg), FPoint(doku->PageB, yg)); |
||
545 | } |
||
243 | Franz | 546 | if (ScApp->Prefs.GridShown) |
167 | Franz | 547 | { |
108 | Franz | 548 | double stx = rd.x()/doku->Scale; |
549 | double endx = rd.x()/doku->Scale+rd.width()/doku->Scale; |
||
550 | double sty = rd.y()/doku->Scale; |
||
551 | double endy = rd.y()/doku->Scale+rd.height()/doku->Scale; |
||
3 | paul | 552 | if (doku->Scale > 0.49) |
167 | Franz | 553 | { |
80 | Franz | 554 | double i,start; |
125 | Franz | 555 | i=doku->majorGrid; |
68 | Franz | 556 | p->setPen(doku->majorColor, lw, SolidLine, FlatCap, MiterJoin); |
3 | paul | 557 | start=floor(sty/i); |
558 | start*=i; |
||
559 | for (b = start; b < endy; b+=i) |
||
217 | Franz | 560 | p->drawLine(FPoint(0, b), FPoint(width()/doku->Scale, b)); |
3 | paul | 561 | start=floor(stx/i); |
562 | start*=i; |
||
563 | for (b = start; b <= endx; b+=i) |
||
167 | Franz | 564 | p->drawLine(FPoint(b, 0), FPoint(b, height()/doku->Scale)); |
125 | Franz | 565 | i=doku->minorGrid; |
68 | Franz | 566 | p->setPen(doku->minorColor, lw, DotLine, FlatCap, MiterJoin); |
3 | paul | 567 | start=floor(sty/i); |
568 | start*=i; |
||
569 | for (b = start; b < endy; b+=i) |
||
167 | Franz | 570 | p->drawLine(FPoint(0, b), FPoint(width()/doku->Scale, b)); |
3 | paul | 571 | start=floor(stx/i); |
572 | start*=i; |
||
573 | for (b = start; b <= endx; b+=i) |
||
217 | Franz | 574 | p->drawLine(FPoint(b, 0), FPoint(b, height()/doku->Scale)); |
575 | } |
||
576 | } |
||
243 | Franz | 577 | if (ScApp->Prefs.GuidesShown) |
167 | Franz | 578 | { |
579 | if (XGuides.count() != 0) |
||
3 | paul | 580 | { |
333 | Franz | 581 | p->setPen(doku->guideColor, lw, DotLine, FlatCap, MiterJoin); |
3 | paul | 582 | for (uint xg = 0; xg < XGuides.count(); ++xg) |
68 | Franz | 583 | p->drawLine(FPoint(XGuides[xg], 0), FPoint(XGuides[xg], doku->PageH)); |
167 | Franz | 584 | } |
3 | paul | 585 | if (YGuides.count() != 0) |
167 | Franz | 586 | { |
333 | Franz | 587 | p->setPen(doku->guideColor, lw, DotLine, FlatCap, MiterJoin); |
3 | paul | 588 | for (uint yg = 0; yg < YGuides.count(); ++yg) |
68 | Franz | 589 | p->drawLine(FPoint(0, YGuides[yg]), FPoint(doku->PageB, YGuides[yg])); |
3 | paul | 590 | } |
167 | Franz | 591 | } |
68 | Franz | 592 | p->setWorldMatrix(ma2); |
3 | paul | 593 | } |
594 | |||
386 | Franz | 595 | void Page::DrawPageItems(ScPainter *painter, QRect rd, bool sp) |
3 | paul | 596 | { |
597 | QPainter p; |
||
598 | uint a; |
||
599 | int Lnr; |
||
600 | struct Layer ll; |
||
601 | PageItem* b; |
||
602 | ll.Sichtbar = false; |
||
603 | ll.LNr = 0; |
||
604 | ScribusView* vi = (ScribusView*)Anz; |
||
68 | Franz | 605 | if ((rd.width() == 0) || (rd.height() == 0)) |
606 | return; |
||
3 | paul | 607 | if (MPageNam != "") |
167 | Franz | 608 | { |
3 | paul | 609 | Page* Mp = vi->MasterPages.at(vi->MasterNames[MPageNam]); |
610 | QWidget* Opa; |
||
611 | Page* Opa2; |
||
612 | if (Mp->Items.count() != 0) |
||
167 | Franz | 613 | { |
3 | paul | 614 | Lnr = 0; |
615 | for (uint la = 0; la < doku->Layers.count(); ++la) |
||
167 | Franz | 616 | { |
3 | paul | 617 | Level2Layer(doku, &ll, Lnr); |
618 | if (ll.Sichtbar) |
||
167 | Franz | 619 | { |
620 | for (a = 0; a < Mp->Items.count(); ++a) |
||
3 | paul | 621 | { |
622 | b = Mp->Items.at(a); |
||
623 | if (b->LayerNr != ll.LNr) |
||
624 | continue; |
||
625 | Opa = b->Parent; |
||
626 | Opa2 = b->OwnPage; |
||
627 | b->Parent = this; |
||
628 | b->OwnPage = this; |
||
236 | Franz | 629 | QPainter p; |
630 | p.begin(this); |
||
631 | Transform(b, &p); |
||
632 | QRegion apr = QRegion(p.xForm(b->Clip)); |
||
238 | Franz | 633 | QRegion apr2 = QRegion(p.xForm(QRect(-1, -1, static_cast<int>(b->Width), static_cast<int>(b->Height)))); |
236 | Franz | 634 | p.end(); |
635 | if ((rd.intersects(apr.boundingRect())) || (rd.intersects(apr2.boundingRect()))) |
||
636 | b->DrawObj(painter, rd); |
||
3 | paul | 637 | b->Parent = Opa; |
638 | b->OwnPage = Opa2; |
||
639 | } |
||
236 | Franz | 640 | for (a = 0; a < Mp->Items.count(); ++a) |
641 | { |
||
642 | b = Mp->Items.at(a); |
||
643 | if (b->LayerNr != ll.LNr) |
||
644 | continue; |
||
645 | if (!b->isTableItem) |
||
646 | continue; |
||
647 | Opa = b->Parent; |
||
648 | Opa2 = b->OwnPage; |
||
649 | b->Parent = this; |
||
650 | b->OwnPage = this; |
||
651 | QPainter p; |
||
652 | p.begin(this); |
||
653 | Transform(b, &p); |
||
654 | QRegion apr = QRegion(p.xForm(b->Clip)); |
||
238 | Franz | 655 | QRegion apr2 = QRegion(p.xForm(QRect(-1, -1, static_cast<int>(b->Width), static_cast<int>(b->Height)))); |
236 | Franz | 656 | p.end(); |
657 | if ((rd.intersects(apr.boundingRect())) || (rd.intersects(apr2.boundingRect()))) |
||
658 | { |
||
659 | painter->setZoomFactor(doku->Scale); |
||
660 | painter->save(); |
||
661 | painter->translate(-rd.x(), -rd.y()); |
||
662 | painter->translate(b->Xpos*doku->Scale, b->Ypos*doku->Scale); |
||
663 | painter->rotate(b->Rot); |
||
664 | if (b->Pcolor2 != "None") |
||
665 | { |
||
666 | QColor tmp; |
||
667 | b->SetFarbe(&tmp, b->Pcolor2, b->Shade2); |
||
668 | if ((b->TopLine) || (b->RightLine) || (b->BottomLine) || (b->LeftLine)) |
||
669 | { |
||
670 | painter->setPen(tmp, b->Pwidth, b->PLineArt, Qt::SquareCap, b->PLineJoin); |
||
671 | if (b->TopLine) |
||
262 | Franz | 672 | painter->drawLine(FPoint(0.0, 0.0), FPoint(b->Width, 0.0)); |
236 | Franz | 673 | if (b->RightLine) |
262 | Franz | 674 | painter->drawLine(FPoint(b->Width, 0.0), FPoint(b->Width, b->Height)); |
236 | Franz | 675 | if (b->BottomLine) |
262 | Franz | 676 | painter->drawLine(FPoint(b->Width, b->Height), FPoint(0.0, b->Height)); |
236 | Franz | 677 | if (b->LeftLine) |
262 | Franz | 678 | painter->drawLine(FPoint(0.0, b->Height), FPoint(0.0, 0.0)); |
236 | Franz | 679 | } |
680 | } |
||
681 | painter->restore(); |
||
682 | } |
||
683 | b->Parent = Opa; |
||
684 | b->OwnPage = Opa2; |
||
685 | } |
||
167 | Franz | 686 | } |
3 | paul | 687 | Lnr++; |
688 | } |
||
689 | } |
||
167 | Franz | 690 | } |
3 | paul | 691 | if (Items.count() != 0) |
167 | Franz | 692 | { |
3 | paul | 693 | Lnr = 0; |
694 | for (uint la2 = 0; la2 < doku->Layers.count(); ++la2) |
||
167 | Franz | 695 | { |
3 | paul | 696 | Level2Layer(doku, &ll, Lnr); |
697 | if (ll.Sichtbar) |
||
167 | Franz | 698 | { |
699 | for (a = 0; a < Items.count(); ++a) |
||
3 | paul | 700 | { |
701 | b = Items.at(a); |
||
702 | if (b->LayerNr != ll.LNr) |
||
703 | continue; |
||
704 | QPainter p; |
||
705 | p.begin(this); |
||
706 | Transform(b, &p); |
||
707 | QRegion apr = QRegion(p.xForm(b->Clip)); |
||
262 | Franz | 708 | QRegion apr2 = QRegion(p.xForm(QRect(-1, -1, static_cast<int>(b->Width), static_cast<int>(b->Height)))); |
3 | paul | 709 | p.end(); |
68 | Franz | 710 | if ((rd.intersects(apr.boundingRect())) || (rd.intersects(apr2.boundingRect()))) |
167 | Franz | 711 | { |
387 | Franz | 712 | // if ((sp) && (b->Ptext.count() >= b->MaxChars)) |
713 | // b->Dirty = true; |
||
262 | Franz | 714 | if (!((doku->EditClip) && (Mpressed))) |
715 | b->DrawObj(painter, rd); |
||
74 | Franz | 716 | b->Redrawn = true; |
272 | Franz | 717 | if ((doku->AppMode == 7) && (b->Select) && (b->PType == 4)) |
718 | { |
||
719 | vi->HR->ItemPos = b->Xpos; |
||
720 | vi->HR->ItemEndPos = b->Xpos+b->Width; |
||
721 | if (b->Pcolor2 != "None") |
||
722 | vi->HR->lineCorr = b->Pwidth / 2.0; |
||
723 | else |
||
724 | vi->HR->lineCorr = 0; |
||
725 | vi->HR->ColGap = b->ColGap; |
||
726 | vi->HR->Cols = b->Cols; |
||
727 | vi->HR->Extra = b->Extra; |
||
728 | vi->HR->RExtra = b->RExtra; |
||
729 | vi->HR->First = doku->Vorlagen[doku->CurrentABStil].First; |
||
730 | vi->HR->Indent = doku->Vorlagen[doku->CurrentABStil].Indent; |
||
731 | if ((b->flippedH % 2 != 0) || (b->Reverse)) |
||
732 | vi->HR->Revers = true; |
||
733 | else |
||
734 | vi->HR->Revers = false; |
||
735 | vi->HR->ItemPosValid = true; |
||
736 | vi->HR->repX = false; |
||
737 | if (doku->CurrentABStil < 5) |
||
738 | vi->HR->TabValues = b->TabValues; |
||
739 | else |
||
740 | vi->HR->TabValues = doku->Vorlagen[doku->CurrentABStil].TabValues; |
||
741 | vi->HR->repaint(); |
||
742 | } |
||
3 | paul | 743 | } |
744 | } |
||
236 | Franz | 745 | for (a = 0; a < Items.count(); ++a) |
746 | { |
||
747 | b = Items.at(a); |
||
748 | if (b->LayerNr != ll.LNr) |
||
749 | continue; |
||
750 | if (!b->isTableItem) |
||
751 | continue; |
||
752 | QPainter p; |
||
753 | p.begin(this); |
||
754 | Transform(b, &p); |
||
755 | QRegion apr = QRegion(p.xForm(b->Clip)); |
||
262 | Franz | 756 | QRegion apr2 = QRegion(p.xForm(QRect(-1, -1, static_cast<int>(b->Width), static_cast<int>(b->Height)))); |
236 | Franz | 757 | p.end(); |
758 | if ((rd.intersects(apr.boundingRect())) || (rd.intersects(apr2.boundingRect()))) |
||
759 | { |
||
760 | painter->setZoomFactor(doku->Scale); |
||
761 | painter->save(); |
||
762 | painter->translate(-rd.x(), -rd.y()); |
||
763 | painter->translate(b->Xpos*doku->Scale, b->Ypos*doku->Scale); |
||
764 | painter->rotate(b->Rot); |
||
765 | if (b->Pcolor2 != "None") |
||
766 | { |
||
767 | QColor tmp; |
||
768 | b->SetFarbe(&tmp, b->Pcolor2, b->Shade2); |
||
769 | if ((b->TopLine) || (b->RightLine) || (b->BottomLine) || (b->LeftLine)) |
||
770 | { |
||
771 | painter->setPen(tmp, b->Pwidth, b->PLineArt, Qt::SquareCap, b->PLineJoin); |
||
772 | if (b->TopLine) |
||
262 | Franz | 773 | painter->drawLine(FPoint(0.0, 0.0), FPoint(b->Width, 0.0)); |
236 | Franz | 774 | if (b->RightLine) |
262 | Franz | 775 | painter->drawLine(FPoint(b->Width, 0.0), FPoint(b->Width, b->Height)); |
236 | Franz | 776 | if (b->BottomLine) |
262 | Franz | 777 | painter->drawLine(FPoint(b->Width, b->Height), FPoint(0.0, b->Height)); |
236 | Franz | 778 | if (b->LeftLine) |
262 | Franz | 779 | painter->drawLine(FPoint(0.0, b->Height), FPoint(0.0, 0.0)); |
236 | Franz | 780 | } |
781 | } |
||
782 | painter->restore(); |
||
783 | } |
||
784 | } |
||
167 | Franz | 785 | } |
3 | paul | 786 | Lnr++; |
787 | } |
||
167 | Franz | 788 | } |
3 | paul | 789 | } |
790 | |||
791 | void Page::setGroupRect() |
||
792 | { |
||
793 | PageItem* b; |
||
80 | Franz | 794 | double minx = 99999.9; |
795 | double miny = 99999.9; |
||
796 | double maxx = -99999.9; |
||
797 | double maxy = -99999.9; |
||
3 | paul | 798 | for (uint gc = 0; gc < SelItem.count(); ++gc) |
167 | Franz | 799 | { |
3 | paul | 800 | b = SelItem.at(gc); |
75 | Franz | 801 | if (b->Rot != 0) |
167 | Franz | 802 | { |
217 | Franz | 803 | FPointArray pb; |
133 | Franz | 804 | FPoint p1; |
805 | pb.resize(0); |
||
806 | pb.addPoint(FPoint(b->Xpos, b->Ypos)); |
||
807 | p1 = transformPoint(FPoint(b->Width, 0.0), b->Xpos, b->Ypos, b->Rot, 1.0, 1.0); |
||
808 | pb.addPoint(p1); |
||
809 | p1 = transformPoint(FPoint(b->Width, b->Height), b->Xpos, b->Ypos, b->Rot, 1.0, 1.0); |
||
810 | pb.addPoint(p1); |
||
811 | p1 = transformPoint(FPoint(0.0, b->Height), b->Xpos, b->Ypos, b->Rot, 1.0, 1.0); |
||
812 | pb.addPoint(p1); |
||
813 | for (uint pc = 0; pc < 4; ++pc) |
||
167 | Franz | 814 | { |
133 | Franz | 815 | minx = QMIN(minx, pb.point(pc).x()); |
816 | miny = QMIN(miny, pb.point(pc).y()); |
||
817 | maxx = QMAX(maxx, pb.point(pc).x()); |
||
818 | maxy = QMAX(maxy, pb.point(pc).y()); |
||
75 | Franz | 819 | } |
167 | Franz | 820 | } |
75 | Franz | 821 | else |
167 | Franz | 822 | { |
75 | Franz | 823 | minx = QMIN(minx, b->Xpos); |
824 | miny = QMIN(miny, b->Ypos); |
||
825 | maxx = QMAX(maxx, b->Xpos + b->Width); |
||
826 | maxy = QMAX(maxy, b->Ypos + b->Height); |
||
3 | paul | 827 | } |
167 | Franz | 828 | } |
3 | paul | 829 | GroupX = minx; |
830 | GroupY = miny; |
||
831 | GroupW = maxx - minx; |
||
832 | GroupH = maxy - miny; |
||
833 | GroupSel = true; |
||
834 | } |
||
835 | |||
80 | Franz | 836 | void Page::moveGroup(double x, double y, bool fromMP) |
3 | paul | 837 | { |
838 | PageItem* b; |
||
314 | Franz | 839 | QPainter p; |
80 | Franz | 840 | double gx, gy, gw, gh; |
3 | paul | 841 | if (GroupSel) |
318 | Franz | 842 | { |
843 | p.begin(this); |
||
3 | paul | 844 | getGroupRectScreen(&gx, &gy, &gw, &gh); |
318 | Franz | 845 | PaintSizeRect(&p, QRect(qRound(gx), qRound(gy), qRound(gw), qRound(gh))); |
846 | p.end(); |
||
847 | } |
||
3 | paul | 848 | for (uint a = 0; a < SelItem.count(); ++a) |
167 | Franz | 849 | { |
3 | paul | 850 | b = SelItem.at(a); |
314 | Franz | 851 | if (!fromMP) |
852 | { |
||
853 | p.begin(this); |
||
854 | Transform(b, &p); |
||
855 | p.setRasterOp(XorROP); |
||
856 | p.setBrush(NoBrush); |
||
857 | p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin)); |
||
858 | if ((b->PType != 5) && (b->FrameType != 0) || (b->PType == 7)) |
||
859 | b->DrawPolyL(&p, b->Clip); |
||
860 | else |
||
861 | p.drawRect(0, 0, static_cast<int>(b->Width)+1, static_cast<int>(b->Height)+1); |
||
862 | p.end(); |
||
863 | } |
||
3 | paul | 864 | MoveItem(x, y, b, fromMP); |
314 | Franz | 865 | if (!fromMP) |
866 | { |
||
867 | p.begin(this); |
||
868 | Transform(b, &p); |
||
869 | p.setRasterOp(XorROP); |
||
870 | p.setBrush(NoBrush); |
||
871 | p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin)); |
||
872 | if ((b->PType != 5) && (b->FrameType != 0) || (b->PType == 7)) |
||
873 | b->DrawPolyL(&p, b->Clip); |
||
874 | else |
||
875 | p.drawRect(0, 0, static_cast<int>(b->Width)+1, static_cast<int>(b->Height)+1); |
||
876 | p.end(); |
||
877 | } |
||
167 | Franz | 878 | } |
314 | Franz | 879 | if ((GroupSel) && (fromMP)) |
238 | Franz | 880 | repaint(QRect(static_cast<int>(gx-5), static_cast<int>(gy-5), static_cast<int>(gw+10), static_cast<int>(gh+10))); |
3 | paul | 881 | } |
882 | |||
80 | Franz | 883 | void Page::getGroupRect(double *x, double *y, double *w, double *h) |
3 | paul | 884 | { |
885 | *x = GroupX; |
||
886 | *y = GroupY; |
||
887 | *w = GroupW; |
||
888 | *h = GroupH; |
||
889 | } |
||
890 | |||
80 | Franz | 891 | void Page::getGroupRectScreen(double *x, double *y, double *w, double *h) |
3 | paul | 892 | { |
80 | Franz | 893 | double sc = doku->Scale; |
3 | paul | 894 | *x = GroupX*sc; |
895 | *y = GroupY*sc; |
||
896 | *w = GroupW*sc; |
||
897 | *h = GroupH*sc; |
||
898 | } |
||
899 | |||
900 | void Page::paintGroupRect(bool norm) |
||
901 | { |
||
80 | Franz | 902 | double x, y, w, h; |
3 | paul | 903 | getGroupRectScreen(&x, &y, &w, &h); |
904 | QPainter pgc; |
||
905 | pgc.begin(this); |
||
217 | Franz | 906 | pgc.setPen(QPen((norm ? red : black), 1, DotLine, FlatCap, MiterJoin)); |
3 | paul | 907 | pgc.setBrush(NoBrush); |
908 | pgc.drawRect(static_cast<int>(x), static_cast<int>(y), static_cast<int>(w), static_cast<int>(h)); |
||
909 | pgc.setBrush(red); |
||
910 | if (norm) |
||
167 | Franz | 911 | { |
3 | paul | 912 | pgc.setPen(QPen(red, 1, SolidLine, FlatCap, MiterJoin)); |
238 | Franz | 913 | pgc.drawRect(qRound(x+w-6), qRound(y+h-6), 6, 6); |
914 | pgc.drawRect(qRound(x+w/2 - 3), qRound(y+h-6), 6, 6); |
||
915 | pgc.drawRect(qRound(x+w/2 - 3), qRound(y), 6, 6); |
||
916 | pgc.drawRect(qRound(x+w-6), qRound(y+h/2 - 3), 6, 6); |
||
917 | pgc.drawRect(qRound(x+w-6), qRound(y), 6, 6); |
||
918 | pgc.drawRect(qRound(x), qRound(y), 6, 6); |
||
919 | pgc.drawRect(qRound(x), qRound(y+h/2 - 3), 6, 6); |
||
920 | pgc.drawRect(qRound(x), qRound(y+h-6), 6, 6); |
||
167 | Franz | 921 | } |
3 | paul | 922 | pgc.end(); |
923 | } |
||
924 | |||
925 | void Page::storeUndoInf(PageItem* b) |
||
926 | { |
||
927 | if ((doku->UnData.UnCode == 0) && (doku->UnDoValid)) |
||
928 | delete doku->UnData.Item; |
||
929 | doku->UnDoValid = false; |
||
930 | doku->UnData.Xpos = b->Xpos; |
||
931 | doku->UnData.Ypos = b->Ypos; |
||
932 | doku->UnData.Width = b->Width; |
||
933 | doku->UnData.Height = b->Height; |
||
934 | doku->UnData.Rot = b->Rot; |
||
935 | doku->UnData.Item = b; |
||
936 | doku->UnData.PageNr = PageNr; |
||
937 | doku->UnData.ItemNr = b->ItemNr; |
||
938 | } |
||
939 | |||
940 | QRegion Page::ViewReg() |
||
941 | { |
||
68 | Franz | 942 | int cx = Anz->contentsX() - Anz->childX(parentWidget()); |
943 | int cy = Anz->contentsY() - Anz->childY(parentWidget()); |
||
3 | paul | 944 | int cw = Anz->visibleWidth(); |
945 | int ch = Anz->visibleHeight(); |
||
946 | return QRegion(QRect(cx, cy, cw, ch)); |
||
947 | } |
||
948 | |||
949 | void Page::Transform(PageItem *b, QPainter *p) |
||
950 | { |
||
230 | Franz | 951 | p->translate(static_cast<int>(b->Xpos*doku->Scale), static_cast<int>(b->Ypos*doku->Scale)); |
3 | paul | 952 | p->scale(doku->Scale, doku->Scale); |
953 | p->rotate(b->Rot); |
||
954 | } |
||
955 | |||
956 | bool Page::GetItem(PageItem **b, int nr) |
||
957 | { |
||
217 | Franz | 958 | if (SelItem.count() != 0) |
959 | { |
||
3 | paul | 960 | if (nr == -1) |
217 | Franz | 961 | *(b) = SelItem.at(0); |
3 | paul | 962 | else |
217 | Franz | 963 | *(b) = SelItem.at(nr); |
3 | paul | 964 | return true; |
217 | Franz | 965 | } |
3 | paul | 966 | else |
217 | Franz | 967 | { |
3 | paul | 968 | *(b) = 0; |
969 | return false; |
||
217 | Franz | 970 | } |
3 | paul | 971 | } |
972 | |||
973 | void Page::TransformM(PageItem *b, QPainter *p) |
||
974 | { |
||
975 | if (b->flippedH % 2 != 0) |
||
167 | Franz | 976 | { |
3 | paul | 977 | p->translate(b->Width, 0); |
978 | p->scale(-1, 1); |
||
167 | Franz | 979 | } |
3 | paul | 980 | if (b->flippedV % 2 != 0) |
167 | Franz | 981 | { |
3 | paul | 982 | p->translate(0, b->Height); |
983 | p->scale(1, -1); |
||
167 | Franz | 984 | } |
3 | paul | 985 | } |
986 | |||
237 | Franz | 987 | void Page::PaintSizeRect(QPainter *p, QRect neu) |
3 | paul | 988 | { |
237 | Franz | 989 | static QRect old; |
990 | if (!neu.isNull()) |
||
991 | { |
||
992 | QWMatrix ma = p->worldMatrix(); |
||
993 | ma.setTransformationMode ( QWMatrix::Areas ); |
||
994 | p->setWorldMatrix(ma); |
||
995 | p->setRasterOp(XorROP); |
||
996 | p->setBrush(NoBrush); |
||
997 | p->setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin)); |
||
998 | if (!old.isNull()) |
||
999 | p->drawRect(old); |
||
238 | Franz | 1000 | p->drawRect(neu); |
237 | Franz | 1001 | } |
1002 | old = neu; |
||
3 | paul | 1003 | } |
1004 | |||
1005 | QPoint Page::ApplyGrid(QPoint in) |
||
1006 | { |
||
1007 | QPoint np; |
||
1008 | if (doku->useRaster) |
||
167 | Franz | 1009 | { |
3 | paul | 1010 | np.setX(static_cast<int>(qRound(in.x() / doku->minorGrid) * doku->minorGrid)); |
1011 | np.setY(static_cast<int>(qRound(in.y() / doku->minorGrid) * doku->minorGrid)); |
||
167 | Franz | 1012 | } |
3 | paul | 1013 | else |
1014 | np = in; |
||
1015 | return np; |
||
1016 | } |
||
1017 | |||
315 | Franz | 1018 | bool Page::ApplyGuides(double *x, double *y) |
3 | paul | 1019 | { |
315 | Franz | 1020 | bool ret = false; |
3 | paul | 1021 | if (doku->SnapGuides) |
167 | Franz | 1022 | { |
1023 | if (YGuides.count() != 0) |
||
3 | paul | 1024 | { |
167 | Franz | 1025 | for (uint yg = 0; yg < YGuides.count(); ++yg) |
3 | paul | 1026 | { |
167 | Franz | 1027 | if ((YGuides[yg] < (*y+doku->GuideRad)) && (YGuides[yg] > (*y-doku->GuideRad))) |
3 | paul | 1028 | { |
1029 | *y= YGuides[yg]; |
||
315 | Franz | 1030 | ret = true; |
3 | paul | 1031 | break; |
1032 | } |
||
1033 | } |
||
167 | Franz | 1034 | } |
3 | paul | 1035 | if (XGuides.count() != 0) |
167 | Franz | 1036 | { |
1037 | for (uint xg = 0; xg < XGuides.count(); ++xg) |
||
3 | paul | 1038 | { |
167 | Franz | 1039 | if ((XGuides[xg] < (*x+doku->GuideRad)) && (XGuides[xg] > (*x-doku->GuideRad))) |
3 | paul | 1040 | { |
1041 | *x = XGuides[xg]; |
||
315 | Franz | 1042 | ret = true; |
3 | paul | 1043 | break; |
1044 | } |
||
1045 | } |
||
1046 | } |
||
319 | Franz | 1047 | if ((doku->PageM.Left < (*x+doku->GuideRad)) && (doku->PageM.Left > (*x-doku->GuideRad))) |
1048 | { |
||
1049 | *x = doku->PageM.Left; |
||
1050 | ret = true; |
||
1051 | } |
||
1052 | if (((doku->PageB - doku->PageM.Right) < (*x+doku->GuideRad)) && ((doku->PageB - doku->PageM.Right) > (*x-doku->GuideRad))) |
||
1053 | { |
||
1054 | *x = doku->PageB - doku->PageM.Right; |
||
1055 | ret = true; |
||
1056 | } |
||
1057 | if ((doku->PageM.Top < (*y+doku->GuideRad)) && (doku->PageM.Top > (*y-doku->GuideRad))) |
||
1058 | { |
||
1059 | *y = doku->PageM.Top; |
||
1060 | ret = true; |
||
1061 | } |
||
1062 | if (((doku->PageH - doku->PageM.Bottom) < (*y+doku->GuideRad)) && ((doku->PageH - doku->PageM.Bottom) > (*y-doku->GuideRad))) |
||
1063 | { |
||
1064 | *y = doku->PageH - doku->PageM.Bottom; |
||
1065 | ret = true; |
||
1066 | } |
||
167 | Franz | 1067 | } |
315 | Franz | 1068 | return ret; |
3 | paul | 1069 | } |
1070 | |||
1071 | FPoint Page::ApplyGridF(FPoint in) |
||
1072 | { |
||
1073 | FPoint np; |
||
1074 | if (doku->useRaster) |
||
167 | Franz | 1075 | { |
3 | paul | 1076 | np.setX(qRound(in.x() / doku->minorGrid) * doku->minorGrid); |
1077 | np.setY(qRound(in.y() / doku->minorGrid) * doku->minorGrid); |
||
167 | Franz | 1078 | } |
3 | paul | 1079 | else |
1080 | np = in; |
||
1081 | return np; |
||
1082 | } |
||
1083 | |||
74 | Franz | 1084 | void Page::RefreshItem(PageItem *b, bool single) |
3 | paul | 1085 | { |
272 | Franz | 1086 | bool dirtyT = b->Dirty; |
3 | paul | 1087 | QPainter p; |
1088 | p.begin(this); |
||
1089 | Transform(b, &p); |
||
287 | Franz | 1090 | QRect rd; |
1091 | rd = QRect(qRound(ceil(-b->OldPwidth / 2.0))-2, |
||
1092 | qRound(ceil(-b->OldPwidth / 2.0))-2, |
||
1093 | qRound(ceil(b->Width+b->OldPwidth*2))+4, |
||
1094 | qRound(ceil(b->Height+b->OldPwidth*2))+4); |
||
263 | Franz | 1095 | if ((b->isTableItem) && (b->Pcolor2 != "None")) |
1096 | { |
||
1097 | if (!b->TopLine) |
||
1098 | { |
||
1099 | rd.setY(rd.y()+qRound(ceil(b->OldPwidth / 2.0))); |
||
1100 | rd.setHeight(rd.height()-qRound(ceil(b->OldPwidth))); |
||
1101 | } |
||
1102 | if (!b->RightLine) |
||
1103 | rd.setWidth(rd.width()-qRound(ceil(b->OldPwidth))); |
||
1104 | if (!b->BottomLine) |
||
1105 | rd.setHeight(rd.height()-qRound(ceil(b->OldPwidth))); |
||
1106 | if (!b->LeftLine) |
||
1107 | { |
||
1108 | rd.setX(rd.x()+qRound(ceil(b->OldPwidth / 2.0))); |
||
1109 | rd.setWidth(rd.width()-qRound(ceil(b->OldPwidth))); |
||
1110 | } |
||
1111 | } |
||
74 | Franz | 1112 | if (single) |
125 | Franz | 1113 | RepaintTextRegion(b, QRegion(p.xForm(rd)), true); |
3 | paul | 1114 | else |
266 | Franz | 1115 | { |
1116 | if (doku->AppMode == 7) |
||
1117 | slotDoCurs(false); |
||
125 | Franz | 1118 | update(QRegion(p.xForm(rd)).intersect(ViewReg()).boundingRect()); |
266 | Franz | 1119 | if (doku->AppMode == 7) |
272 | Franz | 1120 | { |
266 | Franz | 1121 | slotDoCurs(true); |
272 | Franz | 1122 | if ((b->PType == 4) && (!dirtyT)) |
1123 | { |
||
1124 | ScribusView* vi = (ScribusView*)Anz; |
||
1125 | vi->HR->ItemPos = b->Xpos; |
||
1126 | vi->HR->ItemEndPos = b->Xpos+b->Width; |
||
1127 | if (b->Pcolor2 != "None") |
||
1128 | vi->HR->lineCorr = b->Pwidth / 2.0; |
||
1129 | else |
||
1130 | vi->HR->lineCorr = 0; |
||
1131 | vi->HR->ColGap = b->ColGap; |
||
1132 | vi->HR->Cols = b->Cols; |
||
1133 | vi->HR->Extra = b->Extra; |
||
1134 | vi->HR->RExtra = b->RExtra; |
||
1135 | vi->HR->First = doku->Vorlagen[doku->CurrentABStil].First; |
||
1136 | vi->HR->Indent = doku->Vorlagen[doku->CurrentABStil].Indent; |
||
1137 | if ((b->flippedH % 2 != 0) || (b->Reverse)) |
||
1138 | vi->HR->Revers = true; |
||
1139 | else |
||
1140 | vi->HR->Revers = false; |
||
1141 | vi->HR->ItemPosValid = true; |
||
1142 | vi->HR->repX = false; |
||
1143 | if (doku->CurrentABStil < 5) |
||
1144 | vi->HR->TabValues = b->TabValues; |
||
1145 | else |
||
1146 | vi->HR->TabValues = doku->Vorlagen[doku->CurrentABStil].TabValues; |
||
1147 | vi->HR->repaint(); |
||
1148 | } |
||
1149 | } |
||
266 | Franz | 1150 | } |
3 | paul | 1151 | p.end(); |
263 | Franz | 1152 | b->OldPwidth = b->Pwidth; |
3 | paul | 1153 | } |
1154 | |||
75 | Franz | 1155 | void Page::RepaintTextRegion(PageItem *b, QRegion alt, bool single) |
3 | paul | 1156 | { |
167 | Franz | 1157 | if (!isUpdatesEnabled()) |
1158 | return; |
||
272 | Franz | 1159 | bool dirtyT = b->Dirty; |
266 | Franz | 1160 | if (doku->AppMode == 7) |
1161 | slotDoCurs(false); |
||
3 | paul | 1162 | QPainter p; |
1163 | QRegion neu; |
||
1164 | p.begin(this); |
||
1165 | Transform(b, &p); |
||
1166 | neu = QRegion(p.xForm(QRect(0, 0, static_cast<int>(b->Width+1), static_cast<int>(b->Height+1)))).unite(alt); |
||
1167 | p.end(); |
||
1168 | QRect g = neu.boundingRect(); |
||
263 | Franz | 1169 | if (!single) |
1170 | { |
||
287 | Franz | 1171 | g.setX(g.x()-static_cast<int>(QMAX(0.0, b->OldPwidth * 1.4))-4); |
1172 | g.setY(g.y()-static_cast<int>(QMAX(0.0, b->OldPwidth * 1.4))-4); |
||
1173 | g.setWidth(g.width()+static_cast<int>(QMAX(0.0, b->OldPwidth * 1.4))+8); |
||
1174 | g.setHeight(g.height()+static_cast<int>(QMAX(0.0, b->OldPwidth * 1.4))+8); |
||
263 | Franz | 1175 | } |
75 | Franz | 1176 | if (single) |
167 | Franz | 1177 | { |
75 | Franz | 1178 | QRect rd = ViewReg().boundingRect().intersect(g); |
1179 | if ((rd.width() < 1) || (rd.height() < 1)) |
||
1180 | return; |
||
1181 | QPixmap pgPix(rd.width(), rd.height()); |
||
1182 | ScPainter *painter = new ScPainter(&pgPix, pgPix.width(), pgPix.height()); |
||
1183 | painter->translate(0.5, 0.5); |
||
108 | Franz | 1184 | if (doku->Before) |
1185 | DrawPageMarks(painter, rd); |
||
238 | Franz | 1186 | if (!((doku->EditClip) && (Mpressed))) |
1187 | b->DrawObj(painter, rd); |
||
108 | Franz | 1188 | if (!doku->Before) |
1189 | DrawPageMarks(painter, rd); |
||
263 | Franz | 1190 | if (b->isTableItem) |
1191 | { |
||
1192 | painter->setZoomFactor(doku->Scale); |
||
1193 | painter->save(); |
||
1194 | painter->translate(-rd.x(), -rd.y()); |
||
1195 | painter->translate(b->Xpos*doku->Scale, b->Ypos*doku->Scale); |
||
1196 | painter->rotate(b->Rot); |
||
1197 | if (b->Pcolor2 != "None") |
||
1198 | { |
||
1199 | QColor tmp; |
||
1200 | b->SetFarbe(&tmp, b->Pcolor2, b->Shade2); |
||
1201 | if ((b->TopLine) || (b->RightLine) || (b->BottomLine) || (b->LeftLine)) |
||
1202 | { |
||
1203 | painter->setPen(tmp, b->Pwidth, b->PLineArt, Qt::SquareCap, b->PLineJoin); |
||
1204 | if (b->TopLine) |
||
1205 | painter->drawLine(FPoint(0.0, 0.0), FPoint(b->Width, 0.0)); |
||
1206 | if (b->RightLine) |
||
1207 | painter->drawLine(FPoint(b->Width, 0.0), FPoint(b->Width, b->Height)); |
||
1208 | if (b->BottomLine) |
||
1209 | painter->drawLine(FPoint(b->Width, b->Height), FPoint(0.0, b->Height)); |
||
1210 | if (b->LeftLine) |
||
1211 | painter->drawLine(FPoint(0.0, b->Height), FPoint(0.0, 0.0)); |
||
1212 | } |
||
1213 | } |
||
1214 | painter->restore(); |
||
1215 | } |
||
75 | Franz | 1216 | painter->end(); |
1217 | bitBlt( this, rd.x(), rd.y(), &pgPix, 0, 0, pgPix.width(), pgPix.height() ); |
||
1218 | QPainter px; |
||
1219 | px.begin(this); |
||
1220 | px.setPen(QColor(0, 0, 0)); |
||
1221 | px.setBrush(NoBrush); |
||
1222 | px.drawRect(0, 0, width(), height()); |
||
217 | Franz | 1223 | px.end(); |
75 | Franz | 1224 | b->paintObj(rd); |
1225 | if ((doku->EditClip) && (b->Select)) |
||
1226 | MarkClip(b); |
||
1227 | if (GroupSel) |
||
167 | Franz | 1228 | { |
75 | Franz | 1229 | setGroupRect(); |
1230 | paintGroupRect(); |
||
167 | Franz | 1231 | } |
75 | Franz | 1232 | delete painter; |
167 | Franz | 1233 | } |
75 | Franz | 1234 | else |
167 | Franz | 1235 | { |
75 | Franz | 1236 | neu = QRegion(g); |
1237 | update(neu.intersect(ViewReg()).boundingRect()); |
||
167 | Franz | 1238 | } |
266 | Franz | 1239 | if (doku->AppMode == 7) |
272 | Franz | 1240 | { |
266 | Franz | 1241 | slotDoCurs(true); |
272 | Franz | 1242 | if ((b->PType == 4) && (!dirtyT)) |
1243 | { |
||
1244 | ScribusView* vi = (ScribusView*)Anz; |
||
1245 | vi->HR->ItemPos = b->Xpos; |
||
1246 | vi->HR->ItemEndPos = b->Xpos+b->Width; |
||
1247 | if (b->Pcolor2 != "None") |
||
1248 | vi->HR->lineCorr = b->Pwidth / 2.0; |
||
1249 | else |
||
1250 | vi->HR->lineCorr = 0; |
||
1251 | vi->HR->ColGap = b->ColGap; |
||
1252 | vi->HR->Cols = b->Cols; |
||
1253 | vi->HR->Extra = b->Extra; |
||
1254 | vi->HR->RExtra = b->RExtra; |
||
1255 | vi->HR->First = doku->Vorlagen[doku->CurrentABStil].First; |
||
1256 | vi->HR->Indent = doku->Vorlagen[doku->CurrentABStil].Indent; |
||
1257 | if ((b->flippedH % 2 != 0) || (b->Reverse)) |
||
1258 | vi->HR->Revers = true; |
||
1259 | else |
||
1260 | vi->HR->Revers = false; |
||
1261 | vi->HR->ItemPosValid = true; |
||
1262 | vi->HR->repX = false; |
||
1263 | if (doku->CurrentABStil < 5) |
||
1264 | vi->HR->TabValues = b->TabValues; |
||
1265 | else |
||
1266 | vi->HR->TabValues = doku->Vorlagen[doku->CurrentABStil].TabValues; |
||
1267 | vi->HR->repaint(); |
||
1268 | } |
||
1269 | } |
||
3 | paul | 1270 | } |
1271 | |||
222 | Franz | 1272 | void Page::AdjustPreview(PageItem *b, bool reload) |
3 | paul | 1273 | { |
1274 | int neww, newh, fho, fvo; |
||
63 | Franz | 1275 | bool savF; |
3 | paul | 1276 | if ((b->LocalViewX < 1.0) || (b->LocalViewY < 1.0)) |
167 | Franz | 1277 | { |
1278 | if ((b->Pfile != "") && (b->PicAvail)) |
||
3 | paul | 1279 | { |
167 | Franz | 1280 | if (!b->Sizing) |
3 | paul | 1281 | { |
1282 | fho = b->flippedH; |
||
1283 | fvo = b->flippedV; |
||
63 | Franz | 1284 | savF = b->PicArt; |
204 | Franz | 1285 | if ( !b->pixmOrg.isNull() ) |
1286 | { |
||
1287 | b->pixm = b->pixmOrg.copy(); |
||
1288 | b->OrigW = b->pixm.width(); |
||
1289 | b->OrigH = b->pixm.height(); |
||
1290 | b->LocalViewX = b->LocalScX; |
||
1291 | b->LocalViewY = b->LocalScY; |
||
1292 | } |
||
222 | Franz | 1293 | else if (reload == false ) // jjsa begin |
1294 | { |
||
1295 | b->OrigW = b->pixm.width(); |
||
1296 | b->OrigH = b->pixm.height(); |
||
1297 | b->LocalViewX = b->LocalScX; |
||
1298 | b->LocalViewY = b->LocalScY; // jjsa end |
||
1299 | } |
||
204 | Franz | 1300 | else |
1301 | LoadPict(b->Pfile, b->ItemNr); |
||
3 | paul | 1302 | b->flippedH = fho; |
1303 | b->flippedV = fvo; |
||
63 | Franz | 1304 | b->PicArt = savF; |
167 | Franz | 1305 | } |
3 | paul | 1306 | neww = qRound(b->pixm.width() * b->LocalViewX); |
1307 | newh = qRound(b->pixm.height() * b->LocalViewY); |
||
1308 | b->pixm = b->pixm.smoothScale(neww, newh); |
||
1309 | b->LocalViewX = 1; |
||
1310 | b->LocalViewY = 1; |
||
1311 | } |
||
167 | Franz | 1312 | } |
3 | paul | 1313 | } |
222 | Franz | 1314 | void Page::AdjustPictScale(PageItem *b, bool reload) |
3 | paul | 1315 | { |
1316 | if (b->ScaleType) |
||
1317 | return; |
||
238 | Franz | 1318 | if ((b->OrigW == 0) || (b->OrigH == 0)) |
1319 | return; |
||
167 | Franz | 1320 | bool savF; |
3 | paul | 1321 | b->LocalX = 0; |
1322 | b->LocalY = 0; |
||
80 | Franz | 1323 | double xs = b->Width / static_cast<double>(b->OrigW); |
1324 | double ys = b->Height / static_cast<double>(b->OrigH); |
||
3 | paul | 1325 | if (!b->Sizing) |
167 | Franz | 1326 | { |
1327 | int fho = b->flippedH, fvo = b->flippedV; |
||
63 | Franz | 1328 | savF = b->PicArt; |
204 | Franz | 1329 | if (!b->pixmOrg.isNull()) |
1330 | { |
||
1331 | b->pixm = b->pixmOrg.copy(); |
||
1332 | b->OrigW = b->pixm.width(); |
||
1333 | b->OrigH = b->pixm.height(); |
||
1334 | b->LocalViewX = b->LocalScX; |
||
1335 | b->LocalViewY = b->LocalScY; |
||
1336 | } |
||
222 | Franz | 1337 | else if ( reload == false ) // jjsa begin |
1338 | { |
||
1339 | b->OrigW = b->pixm.width(); |
||
1340 | b->OrigH = b->pixm.height(); |
||
1341 | b->LocalViewX = b->LocalScX; |
||
1342 | b->LocalViewY = b->LocalScY; |
||
1343 | } |
||
1344 | else // jjsa end |
||
204 | Franz | 1345 | LoadPict(b->Pfile, b->ItemNr); |
3 | paul | 1346 | b->flippedH = fho; |
1347 | b->flippedV = fvo; |
||
63 | Franz | 1348 | b->PicArt = savF; |
167 | Franz | 1349 | } |
3 | paul | 1350 | if (b->AspectRatio) |
167 | Franz | 1351 | { |
3 | paul | 1352 | b->LocalScX = QMIN(xs, ys); |
1353 | b->LocalScY = QMIN(xs, ys); |
||
1354 | b->LocalViewX = QMIN(xs, ys); |
||
1355 | b->LocalViewY = QMIN(xs, ys); |
||
167 | Franz | 1356 | } |
3 | paul | 1357 | else |
167 | Franz | 1358 | { |
3 | paul | 1359 | b->LocalScX = xs; |
1360 | b->LocalScY = ys; |
||
1361 | b->LocalViewX = xs; |
||
1362 | b->LocalViewY = ys; |
||
167 | Franz | 1363 | } |
3 | paul | 1364 | emit SetLocalValues(b->LocalScX, b->LocalScY, b->LocalX, b->LocalY ); |
1365 | } |
||
1366 | |||
236 | Franz | 1367 | bool Page::MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP) |
3 | paul | 1368 | { |
1369 | QRegion alt; |
||
1370 | QPainter p; |
||
1371 | PageItem *b = Items.at(ite); |
||
1372 | p.begin(this); |
||
1373 | Transform(b, &p); |
||
1374 | alt = QRegion(p.xForm(QRect(0, 0, static_cast<int>(b->Width), static_cast<int>(b->Height)))); |
||
1375 | p.end(); |
||
1376 | if (b->PType == 5) |
||
167 | Franz | 1377 | { |
3 | paul | 1378 | QWMatrix ma; |
1379 | ma.translate(b->Xpos, b->Ypos); |
||
1380 | ma.rotate(b->Rot); |
||
80 | Franz | 1381 | double mx = ma.m11() * b->Width + ma.m21() * b->Height + ma.dx(); |
1382 | double my = ma.m22() * b->Height + ma.m12() * b->Width + ma.dy(); |
||
236 | Franz | 1383 | MoveItem(newX.x(), newX.y(), b, fromMP); |
3 | paul | 1384 | b->Rot = xy2Deg(mx - b->Xpos, my - b->Ypos); |
1385 | b->Width = sqrt(pow(mx - b->Xpos,2)+pow(my - b->Ypos,2)); |
||
1386 | b->Height = 0; |
||
1387 | UpdateClip(b); |
||
1388 | RepaintTextRegion(b, alt); |
||
1389 | emit ItemPos(b->Xpos, b->Ypos); |
||
1390 | emit ItemGeom(b->Width, b->Height); |
||
1391 | emit SetAngle(b->Rot); |
||
167 | Franz | 1392 | } |
3 | paul | 1393 | else |
167 | Franz | 1394 | { |
236 | Franz | 1395 | b->OldB2 = b->Width; |
1396 | b->OldH2 = b->Height; |
||
167 | Franz | 1397 | if (b->Rot != 0) |
3 | paul | 1398 | { |
1399 | FPoint npv = FPoint(newX.x(), newX.y()); |
||
1400 | QWMatrix ma3; |
||
1401 | ma3.translate(b->Xpos, b->Ypos); |
||
1402 | ma3.rotate(b->Rot); |
||
80 | Franz | 1403 | double mxc3 = b->Xpos - (ma3.m11() * npv.x() + ma3.m21() * npv.y() + ma3.dx()); |
1404 | double myc3 = b->Ypos - (ma3.m22() * npv.y() + ma3.m12() * npv.x() + ma3.dy()); |
||
236 | Franz | 1405 | SizeItem(b->Width - newY.x(), b->Height - newY.y(), ite, fromMP); |
1406 | MoveItem(-mxc3, -myc3, b, fromMP); |
||
167 | Franz | 1407 | } |
3 | paul | 1408 | else |
167 | Franz | 1409 | { |
236 | Franz | 1410 | SizeItem(b->Width - newY.x(), b->Height - newY.y(), ite, fromMP); |
1411 | MoveItem(newX.x(), newX.y(), b, fromMP); |
||
3 | paul | 1412 | } |
167 | Franz | 1413 | } |
3 | paul | 1414 | return true; |
1415 | } |
||
1416 | |||
1417 | void Page::UpdateClip(PageItem* b) |
||
1418 | { |
||
232 | Franz | 1419 | if (doku->AppMode == 13) |
1420 | return; |
||
3 | paul | 1421 | int ph = static_cast<int>(QMAX(1.0, b->Pwidth / 2.0)); |
1422 | switch (b->PType) |
||
167 | Franz | 1423 | { |
217 | Franz | 1424 | case 5: |
1425 | b->Clip.setPoints(4, -ph,-ph, static_cast<int>(b->Width+ph),-ph, |
||
1426 | static_cast<int>(b->Width+ph),static_cast<int>(b->Height+ph), |
||
1427 | -ph,static_cast<int>(b->Height+ph)); |
||
1428 | break; |
||
1429 | default: |
||
376 | Franz | 1430 | if ((!b->ClipEdited) || (b->FrameType < 3)) |
217 | Franz | 1431 | { |
1432 | switch (b->FrameType) |
||
167 | Franz | 1433 | { |
217 | Franz | 1434 | case 0: |
1435 | SetRectFrame(b); |
||
1436 | break; |
||
1437 | case 1: |
||
1438 | SetOvalFrame(b); |
||
1439 | break; |
||
1440 | case 2: |
||
1441 | SetFrameRound(b); |
||
1442 | break; |
||
376 | Franz | 1443 | default: |
1444 | break; |
||
167 | Franz | 1445 | } |
295 | Franz | 1446 | if ((b->OldB2 != 0) && (b->OldH2 != 0)) |
1447 | { |
||
1448 | double scx = b->Width / b->OldB2; |
||
1449 | double scy = b->Height / b->OldH2; |
||
1450 | QWMatrix ma; |
||
1451 | ma.scale(scx, scy); |
||
1452 | FPointArray gr; |
||
1453 | gr.addPoint(b->GrStartX, b->GrStartY); |
||
1454 | gr.addPoint(b->GrEndX, b->GrEndY); |
||
1455 | gr.map(ma); |
||
1456 | b->GrStartX = gr.point(0).x(); |
||
1457 | b->GrStartY = gr.point(0).y(); |
||
1458 | b->GrEndX = gr.point(1).x(); |
||
1459 | b->GrEndY = gr.point(0).y(); |
||
376 | Franz | 1460 | if (b->FrameType > 2) |
1461 | { |
||
1462 | b->PoLine.map(ma); |
||
1463 | b->ContourLine.map(ma); |
||
1464 | if (b->PType == 8) |
||
1465 | UpdatePolyClip(b); |
||
1466 | else |
||
1467 | b->Clip = FlattenPath(b->PoLine, b->Segments); |
||
1468 | } |
||
295 | Franz | 1469 | } |
217 | Franz | 1470 | b->OldB2 = b->Width; |
1471 | b->OldH2 = b->Height; |
||
376 | Franz | 1472 | if (b->FrameType < 3) |
1473 | b->ContourLine = b->PoLine.copy(); |
||
217 | Franz | 1474 | } |
1475 | else |
||
1476 | { |
||
1477 | if (doku->SubMode != -1) |
||
167 | Franz | 1478 | { |
217 | Franz | 1479 | switch (doku->SubMode) |
80 | Franz | 1480 | { |
217 | Franz | 1481 | case 0: |
1482 | SetRectFrame(b); |
||
1483 | break; |
||
1484 | case 1: |
||
1485 | SetOvalFrame(b); |
||
1486 | break; |
||
1487 | default: |
||
1488 | SetFrameShape(b, doku->ValCount, doku->ShapeValues); |
||
1489 | break; |
||
167 | Franz | 1490 | } |
3 | paul | 1491 | b->OldB2 = b->Width; |
1492 | b->OldH2 = b->Height; |
||
340 | Franz | 1493 | b->ContourLine = b->PoLine.copy(); |
167 | Franz | 1494 | } |
217 | Franz | 1495 | if ((b->OldB2 == 0) || (b->OldH2 == 0)) |
1496 | return; |
||
1497 | double scx = b->Width / b->OldB2; |
||
1498 | double scy = b->Height / b->OldH2; |
||
1499 | QWMatrix ma; |
||
1500 | ma.scale(scx, scy); |
||
292 | Franz | 1501 | FPointArray gr; |
1502 | gr.addPoint(b->GrStartX, b->GrStartY); |
||
1503 | gr.addPoint(b->GrEndX, b->GrEndY); |
||
1504 | gr.map(ma); |
||
1505 | b->GrStartX = gr.point(0).x(); |
||
1506 | b->GrStartY = gr.point(0).y(); |
||
1507 | b->GrEndX = gr.point(1).x(); |
||
1508 | b->GrEndY = gr.point(0).y(); |
||
217 | Franz | 1509 | b->PoLine.map(ma); |
340 | Franz | 1510 | b->ContourLine.map(ma); |
217 | Franz | 1511 | if (b->PType == 8) |
1512 | UpdatePolyClip(b); |
||
1513 | else |
||
1514 | b->Clip = FlattenPath(b->PoLine, b->Segments); |
||
1515 | b->OldB2 = b->Width; |
||
1516 | b->OldH2 = b->Height; |
||
1517 | } |
||
1518 | break; |
||
167 | Franz | 1519 | } |
294 | Franz | 1520 | updateGradientVectors(b); |
3 | paul | 1521 | } |
1522 | |||
80 | Franz | 1523 | bool Page::SizeItem(double newX, double newY, int ite, bool fromMP, bool DoUpdateClip) |
3 | paul | 1524 | { |
1525 | PageItem *b = Items.at(ite); |
||
1526 | if (b->Locked) |
||
1527 | return false; |
||
167 | Franz | 1528 | QRegion alt, neu; |
1529 | QPainter p; |
||
3 | paul | 1530 | if (b->PType != 5) |
167 | Franz | 1531 | { |
68 | Franz | 1532 | newX = QMAX(newX, 1); |
1533 | newY = QMAX(newY, 1); |
||
167 | Franz | 1534 | } |
3 | paul | 1535 | int ph = static_cast<int>(QMAX(1.0, b->Pwidth / 2.0)); |
1536 | p.begin(this); |
||
1537 | Transform(b, &p); |
||
1538 | alt = QRegion(p.xForm(QRect(0, 0, static_cast<int>(b->Width), static_cast<int>(b->Height)))); |
||
1539 | p.end(); |
||
132 | Franz | 1540 | QWMatrix ma; |
1541 | ma.rotate(b->Rot); |
||
1542 | double dX = ma.m11() * (b->Width - newX) + ma.m21() * (b->Height - newY) + ma.dx(); |
||
1543 | double dY = ma.m22() * (b->Height - newY) + ma.m12() * (b->Width - newX) + ma.dy(); |
||
3 | paul | 1544 | b->Width = newX; |
1545 | b->Height = newY; |
||
132 | Franz | 1546 | if ((doku->RotMode != 0) && (fromMP)) |
167 | Franz | 1547 | { |
1548 | switch (doku->RotMode) |
||
132 | Franz | 1549 | { |
217 | Franz | 1550 | case 2: |
1551 | MoveItem(dX / 2.0, dY / 2.0, b); |
||
1552 | break; |
||
1553 | case 4: |
||
1554 | MoveItem(dX, dY, b); |
||
1555 | break; |
||
1556 | case 3: |
||
1557 | MoveItem(0.0, dY, b); |
||
1558 | break; |
||
1559 | case 1: |
||
1560 | MoveItem(dX, 0.0, b); |
||
1561 | break; |
||
132 | Franz | 1562 | } |
167 | Franz | 1563 | } |
1564 | b->RadRect = QMIN(b->RadRect, QMIN(b->Width,b->Height)/2); |
||
3 | paul | 1565 | if ((b->PType == 2) && (!b->Sizing) && (!doku->EditClip)) |
167 | Franz | 1566 | { |
3 | paul | 1567 | AdjustPictScale(b); |
222 | Franz | 1568 | AdjustPreview(b, false); |
167 | Franz | 1569 | } |
3 | paul | 1570 | if (b->PType == 5) |
167 | Franz | 1571 | { |
1572 | if (!fromMP) |
||
3 | paul | 1573 | { |
1574 | b->Rot = atan2(b->Height,b->Width)*(180.0/3.1415927); |
||
1575 | b->Width = sqrt(pow(b->Width,2)+pow(b->Height,2)); |
||
1576 | b->Height = 0; |
||
1577 | emit SetAngle(b->Rot); |
||
1578 | } |
||
167 | Franz | 1579 | b->Clip.setPoints(4, -ph,-ph, static_cast<int>(b->Width+ph),-ph, |
217 | Franz | 1580 | static_cast<int>(b->Width+ph),static_cast<int>(b->Height+ph), |
1581 | -ph,static_cast<int>(b->Height+ph)); |
||
167 | Franz | 1582 | } |
3 | paul | 1583 | if (b->Sizing) |
167 | Franz | 1584 | { |
230 | Franz | 1585 | emit ItemGeom(b->Width, b->Height); |
1586 | emit ItemRadius(b->RadRect); |
||
3 | paul | 1587 | b->FrameOnly = true; |
1588 | b->Tinput = true; |
||
1589 | if ((HowTo == 1) && (b->PType != 5)) |
||
1590 | b->paintObj(); |
||
231 | Franz | 1591 | if ((b->FrameType == 0) || (b->PType == 5) || (HowTo != 1)) |
230 | Franz | 1592 | return true; |
1593 | QPainter p; |
||
1594 | p.begin(this); |
||
1595 | Transform(b, &p); |
||
1596 | p.setRasterOp(XorROP); |
||
1597 | p.setBrush(NoBrush); |
||
1598 | p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin)); |
||
1599 | b->DrawPolyL(&p, b->Clip); |
||
1600 | UpdateClip(b); |
||
1601 | b->DrawPolyL(&p, b->Clip); |
||
1602 | p.end(); |
||
3 | paul | 1603 | return true; |
167 | Franz | 1604 | } |
3 | paul | 1605 | if (DoUpdateClip) |
167 | Franz | 1606 | { |
1607 | if (fromMP) |
||
3 | paul | 1608 | { |
1609 | if (b->flippedH % 2 != 0) |
||
1610 | MoveItemI(-(b->Width - b->OldB2)/b->LocalScX, 0, b->ItemNr); |
||
1611 | if (b->flippedV % 2 != 0) |
||
1612 | MoveItemI(0, -(b->Height - b->OldH2)/b->LocalScY, b->ItemNr); |
||
167 | Franz | 1613 | } |
3 | paul | 1614 | else |
167 | Franz | 1615 | { |
3 | paul | 1616 | if (b->flippedH % 2 == 0) |
1617 | MoveItemI((b->Width - b->OldB2)/b->LocalScX, 0, b->ItemNr); |
||
1618 | if (b->flippedV % 2 == 0) |
||
1619 | MoveItemI(0, (b->Height - b->OldH2)/b->LocalScY, b->ItemNr); |
||
167 | Franz | 1620 | } |
3 | paul | 1621 | UpdateClip(b); |
167 | Franz | 1622 | } |
295 | Franz | 1623 | updateGradientVectors(b); |
3 | paul | 1624 | RepaintTextRegion(b, alt); |
1625 | if (!fromMP) |
||
167 | Franz | 1626 | { |
1627 | if (GroupSel) |
||
3 | paul | 1628 | { |
80 | Franz | 1629 | double gx, gy, gh, gw; |
3 | paul | 1630 | setGroupRect(); |
1631 | getGroupRect(&gx, &gy, &gw, &gh); |
||
1632 | emit ItemGeom(gw, gh); |
||
167 | Franz | 1633 | } |
3 | paul | 1634 | else |
1635 | emit ItemGeom(b->Width, b->Height); |
||
167 | Franz | 1636 | } |
3 | paul | 1637 | emit ItemRadius(b->RadRect); |
80 | Franz | 1638 | return true; |
3 | paul | 1639 | } |
1640 | |||
80 | Franz | 1641 | void Page::MoveItemI(double newX, double newY, int ite) |
3 | paul | 1642 | { |
1643 | PageItem *b = Items.at(ite); |
||
167 | Franz | 1644 | if ((b->Locked) || (!b->ScaleType)) |
3 | paul | 1645 | return; |
167 | Franz | 1646 | QPainter p; |
3 | paul | 1647 | p.begin(this); |
1648 | Transform(b, &p); |
||
1649 | TransformM(b, &p); |
||
1650 | QRegion alt = QRegion(p.xForm(QRect(0, 0, static_cast<int>(b->Width), static_cast<int>(b->Height)))); |
||
1651 | p.end(); |
||
1652 | if (b->flippedH % 2 != 0) |
||
1653 | b->LocalX -= newX; |
||
1654 | else |
||
1655 | b->LocalX += newX; |
||
1656 | if (b->flippedV % 2 != 0) |
||
1657 | b->LocalY -= newY; |
||
1658 | else |
||
1659 | b->LocalY += newY; |
||
272 | Franz | 1660 | RepaintTextRegion(b, alt, true); |
80 | Franz | 1661 | emit SetLocalValues(b->LocalScX, b->LocalScY, b->LocalX, b->LocalY); |
3 | paul | 1662 | } |
1663 | |||
80 | Franz | 1664 | bool Page::MoveItem(double newX, double newY, PageItem* b, bool fromMP) |
3 | paul | 1665 | { |
167 | Franz | 1666 | if (b->Locked) |
1667 | return false; |
||
3 | paul | 1668 | QRegion alt; |
1669 | bool retw = false; |
||
80 | Franz | 1670 | double oldx = b->Xpos; |
1671 | double oldy = b->Ypos; |
||
3 | paul | 1672 | if (!Imoved) |
167 | Franz | 1673 | { |
3 | paul | 1674 | QPainter p; |
1675 | p.begin(this); |
||
1676 | Transform(b, &p); |
||
1677 | alt = QRegion(p.xForm(QRect(0, 0, static_cast<int>(b->Width), static_cast<int>(b->Height)))); |
||
1678 | p.end(); |
||
167 | Franz | 1679 | } |
3 | paul | 1680 | b->Xpos += newX; |
1681 | b->Ypos += newY; |
||
254 | Franz | 1682 | if ((doku->useRaster) && (!Imoved) && (!fromMP)) |
167 | Franz | 1683 | { |
3 | paul | 1684 | b->Xpos = qRound(b->Xpos / doku->minorGrid) * doku->minorGrid; |
1685 | b->Ypos = qRound(b->Ypos / doku->minorGrid) * doku->minorGrid; |
||
167 | Franz | 1686 | } |
254 | Franz | 1687 | if ((doku->SnapGuides) && (!Imoved) && (doku->AppMode == 1) && (!doku->EditClip) && (!fromMP)) |
3 | paul | 1688 | SnapToGuides(b); |
1689 | if ((b->Xpos != oldx) || (b->Ypos != oldy)) |
||
1690 | retw = true; |
||
1691 | if ((!Imoved) && (!b->Sizing)) |
||
1692 | RepaintTextRegion(b, alt); |
||
1693 | if (!fromMP) |
||
167 | Franz | 1694 | { |
1695 | if (GroupSel) |
||
3 | paul | 1696 | { |
80 | Franz | 1697 | double gx, gy, gh, gw; |
3 | paul | 1698 | setGroupRect(); |
1699 | getGroupRect(&gx, &gy, &gw, &gh); |
||
1700 | emit ItemPos(gx, gy); |
||
167 | Franz | 1701 | } |
3 | paul | 1702 | else |
1703 | emit ItemPos(b->Xpos, b->Ypos); |
||
167 | Franz | 1704 | } |
91 | Franz | 1705 | if (!doku->loading) |
1706 | emit UpdtObj(PageNr, b->ItemNr); |
||
80 | Franz | 1707 | return retw; |
3 | paul | 1708 | } |
1709 | |||
128 | Franz | 1710 | void Page::RotateGroup(double win) |
1711 | { |
||
129 | Franz | 1712 | double gxS, gyS, ghS, gwS; |
128 | Franz | 1713 | PageItem* b; |
1714 | FPoint n; |
||
1715 | getGroupRectScreen(&gxS, &gyS, &gwS, &ghS); |
||
129 | Franz | 1716 | QWMatrix ma; |
1717 | ma.translate(RCenter.x(), RCenter.y()); |
||
1718 | ma.scale(1, 1); |
||
1719 | ma.rotate(win); |
||
167 | Franz | 1720 | QRect alt = QRect(static_cast<int>(gxS-5), static_cast<int>(gyS-5), static_cast<int>(gwS+10), |
217 | Franz | 1721 | static_cast<int>(ghS+10)); |
128 | Franz | 1722 | for (uint a = 0; a < SelItem.count(); ++a) |
167 | Franz | 1723 | { |
128 | Franz | 1724 | b = SelItem.at(a); |
129 | Franz | 1725 | n = FPoint(b->Xpos - RCenter.x(), b->Ypos - RCenter.y()); |
128 | Franz | 1726 | b->Xpos = ma.m11() * n.x() + ma.m21() * n.y() + ma.dx(); |
1727 | b->Ypos = ma.m22() * n.y() + ma.m12() * n.x() + ma.dy(); |
||
129 | Franz | 1728 | b->Rot += win; |
167 | Franz | 1729 | } |
128 | Franz | 1730 | setGroupRect(); |
1731 | getGroupRectScreen(&gxS, &gyS, &gwS, &ghS); |
||
167 | Franz | 1732 | repaint(QRect(static_cast<int>(gxS-5), static_cast<int>(gyS-5), static_cast<int>(gwS+10), |
217 | Franz | 1733 | static_cast<int>(ghS+10)).unite(alt)); |
128 | Franz | 1734 | } |
1735 | |||
80 | Franz | 1736 | void Page::RotateItem(double win, int ite) |
3 | paul | 1737 | { |
1738 | PageItem *b; |
||
1739 | b = Items.at(ite); |
||
1740 | if (b->Locked) |
||
1741 | return; |
||
167 | Franz | 1742 | QRegion alt, neu; |
1743 | QPainter p; |
||
1744 | FPoint n; |
||
3 | paul | 1745 | p.begin(this); |
1746 | Transform(b, &p); |
||
1747 | alt = QRegion(p.xForm(QRect(0, 0, static_cast<int>(b->Width), static_cast<int>(b->Height)))); |
||
1748 | p.end(); |
||
1749 | if ((doku->RotMode != 0) && (b->PType != 5)) |
||
167 | Franz | 1750 | { |
3 | paul | 1751 | QWMatrix ma; |
1752 | ma.translate(b->Xpos, b->Ypos); |
||
1753 | ma.scale(1, 1); |
||
1754 | ma.rotate(b->Rot); |
||
80 | Franz | 1755 | double ro = win-b->Rot; |
3 | paul | 1756 | b->Rot = win; |
1757 | switch (doku->RotMode) |
||
167 | Franz | 1758 | { |
217 | Franz | 1759 | case 2: |
1760 | ma.translate(b->Width/2, b->Height/2); |
||
1761 | n = FPoint(-b->Width/2, -b->Height/2); |
||
1762 | break; |
||
1763 | case 4: |
||
1764 | ma.translate(b->Width, b->Height); |
||
1765 | n = FPoint(-b->Width, -b->Height); |
||
1766 | break; |
||
1767 | case 3: |
||
1768 | ma.translate(0, b->Height); |
||
1769 | n = FPoint(0, -b->Height); |
||
1770 | break; |
||
1771 | case 1: |
||
1772 | ma.translate(b->Width, 0); |
||
1773 | n = FPoint(-b->Width, 0); |
||
1774 | break; |
||
167 | Franz | 1775 | } |
3 | paul | 1776 | ma.rotate(ro); |
80 | Franz | 1777 | double x = ma.m11() * n.x() + ma.m21() * n.y() + ma.dx(); |
1778 | double y = ma.m22() * n.y() + ma.m12() * n.x() + ma.dy(); |
||
3 | paul | 1779 | MoveItem(x-b->Xpos, y-b->Ypos, b); |
167 | Franz | 1780 | } |
3 | paul | 1781 | else |
1782 | b->Rot = win; |
||
1783 | RepaintTextRegion(b, alt); |
||
1784 | emit SetAngle(b->Rot); |
||
1785 | } |
||
1786 | |||
1787 | void Page::SnapToGuides(PageItem* b) |
||
1788 | { |
||
1789 | if (YGuides.count() != 0) |
||
167 | Franz | 1790 | { |
1791 | for (uint yg = 0; yg < YGuides.count(); ++yg) |
||
3 | paul | 1792 | { |
167 | Franz | 1793 | if ((YGuides[yg] < (b->Ypos+doku->GuideRad)) && (YGuides[yg] > (b->Ypos-doku->GuideRad))) |
3 | paul | 1794 | { |
1795 | b->Ypos = YGuides[yg]; |
||
1796 | break; |
||
167 | Franz | 1797 | } |
3 | paul | 1798 | if (b->PType == 5) |
167 | Franz | 1799 | { |
3 | paul | 1800 | QWMatrix ma; |
1801 | ma.translate(b->Xpos, b->Ypos); |
||
1802 | ma.rotate(b->Rot); |
||
80 | Franz | 1803 | double my = ma.m22() * b->Height + ma.m12() * b->Width + ma.dy(); |
3 | paul | 1804 | if ((YGuides[yg] < (my+doku->GuideRad)) && (YGuides[yg] > (my-doku->GuideRad))) |
167 | Franz | 1805 | { |
3 | paul | 1806 | b->Ypos = b->Ypos + YGuides[yg] - my; |
1807 | break; |
||
1808 | } |
||
167 | Franz | 1809 | } |
3 | paul | 1810 | else |
167 | Franz | 1811 | { |
217 | Franz | 1812 | if ((YGuides[yg] < (b->Ypos+b->Height+doku->GuideRad)) && |
1813 | (YGuides[yg] > ((b->Ypos+b->Height)-doku->GuideRad))) |
||
3 | paul | 1814 | { |
1815 | b->Ypos = YGuides[yg]-b->Height; |
||
1816 | break; |
||
1817 | } |
||
1818 | } |
||
1819 | } |
||
167 | Franz | 1820 | } |
3 | paul | 1821 | if (XGuides.count() != 0) |
167 | Franz | 1822 | { |
1823 | for (uint xg = 0; xg < XGuides.count(); ++xg) |
||
3 | paul | 1824 | { |
167 | Franz | 1825 | if ((XGuides[xg] < (b->Xpos+doku->GuideRad)) && (XGuides[xg] > (b->Xpos-doku->GuideRad))) |
3 | paul | 1826 | { |
1827 | b->Xpos = XGuides[xg]; |
||
1828 | break; |
||
167 | Franz | 1829 | } |
3 | paul | 1830 | if (b->PType == 5) |
167 | Franz | 1831 | { |
3 | paul | 1832 | QWMatrix ma; |
1833 | ma.translate(b->Xpos, b->Ypos); |
||
1834 | ma.rotate(b->Rot); |
||
80 | Franz | 1835 | double mx = ma.m11() * b->Width + ma.m21() * b->Height + ma.dx(); |
3 | paul | 1836 | if ((XGuides[xg] < (mx+doku->GuideRad)) && (XGuides[xg] > (mx-doku->GuideRad))) |
167 | Franz | 1837 | { |
3 | paul | 1838 | b->Xpos = b->Xpos + XGuides[xg] - mx; |
1839 | break; |
||
1840 | } |
||
167 | Franz | 1841 | } |
3 | paul | 1842 | else |
167 | Franz | 1843 | { |
217 | Franz | 1844 | if ((XGuides[xg] < (b->Xpos+b->Width+doku->GuideRad)) && |
1845 | (XGuides[xg] > ((b->Xpos+b->Width)-doku->GuideRad))) |
||
3 | paul | 1846 | { |
1847 | b->Xpos = XGuides[xg]-b->Width; |
||
1848 | break; |
||
1849 | } |
||
1850 | } |
||
1851 | } |
||
167 | Franz | 1852 | } |
3 | paul | 1853 | } |
1854 | |||
1855 | void Page::sentToScrap() |
||
1856 | { |
||
1857 | ScriXmlDoc *ss = new ScriXmlDoc(); |
||
1858 | emit ToScrap(ss->WriteElem(&SelItem, doku)); |
||
1859 | delete ss; |
||
1860 | } |
||
1861 | |||
1862 | void Page::sentToLayer(int id) |
||
80 | Franz | 1863 | { |
3 | paul | 1864 | int d = pmen3->indexOf(id); |
153 | Franz | 1865 | int dd = doku->Layers[d].LNr; |
167 | Franz | 1866 | if (SelItem.count() != 0) |
217 | Franz | 1867 | { |
1868 | for (uint a = 0; a < SelItem.count(); ++a) |
||
1869 | { |
||
142 | Franz | 1870 | PageItem *b = SelItem.at(a); |
153 | Franz | 1871 | b->LayerNr = dd; |
142 | Franz | 1872 | } |
167 | Franz | 1873 | } |
3 | paul | 1874 | Deselect(true); |
167 | Franz | 1875 | update(); |
268 | Franz | 1876 | emit DocChanged(); |
3 | paul | 1877 | } |
1878 | |||
1879 | bool Page::PointOnLine(QPoint Start, QPoint Ende, QRect MArea) |
||
1880 | { |
||
1881 | QPoint an, en; |
||
1882 | if (Start.x() == Ende.x()) |
||
167 | Franz | 1883 | { |
1884 | an = Start.y() > Ende.y() ? Ende : Start; |
||
1885 | en = an == Ende ? Start : Ende; |
||
1886 | for (int a=an.y(); a<en.y(< |