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