Rev 456 | Rev 504 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3 | paul | 1 | /*************************************************************************** |
2 | scribusview.cpp - description |
||
3 | ------------------- |
||
4 | begin : Fre Apr 6 21:47:55 CEST 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 "scribusview.h" |
||
19 | #include "scribusview.moc" |
||
128 | Franz | 20 | |
21 | #if (_MSC_VER >= 1200) |
||
22 | #include "win-config.h" |
||
23 | #else |
||
24 | #include "config.h" |
||
25 | #endif |
||
26 | |||
3 | paul | 27 | #include <qcolor.h> |
28 | #include <qfont.h> |
||
29 | #include <qfontmetrics.h> |
||
30 | #include <qpixmap.h> |
||
31 | #include <qpointarray.h> |
||
32 | #include <qstringlist.h> |
||
33 | #include <qimage.h> |
||
34 | #include <qcstring.h> |
||
173 | Franz | 35 | #include <qfileinfo.h> |
456 | fschmid | 36 | #include <qfile.h> |
307 | Franz | 37 | #include <cmath> |
456 | fschmid | 38 | #include <cstdio> |
39 | #include <cstdlib> |
||
40 | #include <unistd.h> |
||
41 | #include <qcursor.h> |
||
42 | #include <qurl.h> |
||
43 | #include <qdir.h> |
||
44 | #include <qevent.h> |
||
45 | #include <qeventloop.h> |
||
46 | #include <qprocess.h> |
||
47 | #if QT_VERSION > 0x030102 |
||
48 | #define SPLITVC SplitHCursor |
||
49 | #define SPLITHC SplitVCursor |
||
50 | #else |
||
51 | #define SPLITVC SplitVCursor |
||
52 | #define SPLITHC SplitHCursor |
||
53 | #endif |
||
181 | Franz | 54 | #include "scribus.h" |
456 | fschmid | 55 | #include "mpalette.h" |
56 | #include "scribusXml.h" |
||
57 | #include "serializer.h" |
||
58 | #include "insertTable.h" |
||
59 | #ifdef HAVE_TIFF |
||
60 | #include <tiffio.h> |
||
61 | #endif |
||
62 | #ifdef HAVE_CMS |
||
63 | #include CMS_INC |
||
64 | #endif |
||
68 | Franz | 65 | |
3 | paul | 66 | extern void Level2Layer(ScribusDoc *doc, struct Layer *ll, int Level); |
80 | Franz | 67 | extern double Cwidth(ScribusDoc *doc, QString name, QString ch, int Siz, QString ch2 = " "); |
181 | Franz | 68 | extern ScribusApp* ScApp; |
456 | fschmid | 69 | extern QPointArray FlattenPath(FPointArray ina, QValueList<uint> &Segs); |
70 | extern QPixmap loadIcon(QString nam); |
||
71 | extern double xy2Deg(double x, double y); |
||
72 | extern void BezierPoints(QPointArray *ar, QPoint n1, QPoint n2, QPoint n3, QPoint n4); |
||
73 | extern FPointArray RegularPolygonF(double w, double h, uint c, bool star, double factor, double rota); |
||
74 | extern FPoint GetMaxClipF(FPointArray Clip); |
||
75 | extern void WordAndPara(PageItem* b, int *w, int *p, int *c, int *wN, int *pN, int *cN); |
||
76 | #ifdef HAVE_CMS |
||
77 | QImage ProofPict(QImage *Im, QString Prof, int Rend, cmsHPROFILE emPr=0); |
||
78 | #else |
||
79 | QImage ProofPict(QImage *Im, QString Prof, int Rend); |
||
80 | #endif |
||
81 | extern int callGS(const QStringList & args); |
||
82 | extern double UmReFaktor; |
||
83 | extern int PolyC; |
||
84 | extern int PolyFd; |
||
85 | extern double PolyF; |
||
86 | extern bool PolyS; |
||
87 | extern double PolyR; |
||
88 | extern ProfilesL InputProfiles; |
||
3 | paul | 89 | |
456 | fschmid | 90 | ScribusView::ScribusView(QWidget *parent, ScribusDoc *doc, preV *prefs) : QScrollView(parent, "s", WRepaintNoErase | WNorthWestGravity) |
3 | paul | 91 | { |
92 | Ready = false; |
||
456 | fschmid | 93 | updateOn = true; |
3 | paul | 94 | Doc = doc; |
95 | Doc->PageC = 0; |
||
240 | Franz | 96 | Prefs = prefs; |
3 | paul | 97 | setHScrollBarMode(QScrollView::AlwaysOn); |
98 | setVScrollBarMode(QScrollView::AlwaysOn); |
||
99 | setMargins(25, 25, 0, 0); |
||
100 | setResizePolicy(Manual); |
||
240 | Franz | 101 | viewport()->setBackgroundMode(PaletteBackground); |
3 | paul | 102 | QFont fo = QFont(font()); |
103 | fo.setPointSize(10); |
||
333 | Franz | 104 | LE = new MSpinBox( 10, 3200, this, 2 ); |
3 | paul | 105 | LE->setFont(fo); |
240 | Franz | 106 | LE->setSuffix( tr( " %" ) ); |
146 | Franz | 107 | LE->setValue( 100 ); |
3 | paul | 108 | LE->setFocusPolicy(QWidget::ClickFocus); |
109 | SB1 = new QPushButton(this); |
||
110 | SB1->setPixmap(loadIcon("Klein.xpm")); |
||
111 | SB1->setFocusPolicy(QWidget::NoFocus); |
||
112 | SB2 = new QPushButton(this); |
||
113 | SB2->setFocusPolicy(QWidget::NoFocus); |
||
114 | SB2->setPixmap(loadIcon("Gross.xpm")); |
||
199 | Franz | 115 | PGS = new PageSelector(this, 1); |
160 | Franz | 116 | PGS->setFont(fo); |
170 | Franz | 117 | PGS->setFocusPolicy(QWidget::ClickFocus); |
3 | paul | 118 | LY = new QPushButton(this); |
119 | LY->setFont(fo); |
||
120 | Laymen = new QPopupMenu(this); |
||
121 | Laymen->setFont(fo); |
||
112 | Franz | 122 | LY->setText( tr("Layer")+" 0"); |
3 | paul | 123 | LY->setPopup(Laymen); |
124 | LY->setFocusPolicy(QWidget::NoFocus); |
||
125 | HR = new Hruler(this, Doc); |
||
126 | VR = new Vruler(this, Doc); |
||
127 | UN = new QToolButton(this); |
||
128 | Unitmen = new QPopupMenu(this); |
||
274 | Franz | 129 | Unitmen->insertItem(tr("pt")); |
130 | Unitmen->insertItem(tr("mm")); |
||
131 | Unitmen->insertItem(tr("in")); |
||
132 | Unitmen->insertItem(tr("p")); |
||
3 | paul | 133 | UN->setPopup(Unitmen); |
134 | UN->setFocusPolicy(QWidget::NoFocus); |
||
135 | UN->setPopupDelay(10); |
||
136 | switch (doc->Einheit) |
||
292 | Franz | 137 | { |
138 | case 0: |
||
139 | UN->setText( tr("pt")); |
||
140 | break; |
||
141 | case 1: |
||
142 | UN->setText( tr("mm")); |
||
143 | break; |
||
144 | case 2: |
||
145 | UN->setText( tr("in")); |
||
146 | break; |
||
147 | case 3: |
||
148 | UN->setText( tr("p")); |
||
149 | break; |
||
150 | } |
||
3 | paul | 151 | Ready = true; |
456 | fschmid | 152 | viewport()->setMouseTracking(true); |
153 | setAcceptDrops(true); |
||
154 | viewport()->setAcceptDrops(true); |
||
155 | setDragAutoScroll(false); |
||
156 | SelItem.clear(); |
||
157 | Doc->DragP = false; |
||
158 | Doc->leaveDrag = false; |
||
159 | Imoved = false; |
||
160 | Mpressed = false; |
||
161 | MidButt = false; |
||
162 | HaveSelRect = false; |
||
163 | Magnify = false; |
||
164 | FirstPoly = true; |
||
165 | EdPoints = true; |
||
166 | GroupSel = false; |
||
167 | DraggedGroup = false; |
||
168 | MoveGY = false; |
||
169 | MoveGX = false; |
||
170 | EditContour = false; |
||
171 | CursVis = false; |
||
172 | GroupX = 0; |
||
173 | GroupY = 0; |
||
174 | GroupW = 0; |
||
175 | GroupH = 0; |
||
176 | DrHY = -1; |
||
177 | DrVX = -1; |
||
178 | GyM = 0; |
||
179 | GxM = 0; |
||
180 | ClRe = -1; |
||
181 | ClRe2 = -1; |
||
3 | paul | 182 | connect(SB1, SIGNAL(clicked()), this, SLOT(slotZoomOut())); |
183 | connect(SB2, SIGNAL(clicked()), this, SLOT(slotZoomIn())); |
||
68 | Franz | 184 | connect(LE, SIGNAL(valueChanged(int)), this, SLOT(Zval())); |
199 | Franz | 185 | connect(PGS, SIGNAL(GotoPage(int)), this, SLOT(GotoPa(int))); |
3 | paul | 186 | connect(Laymen, SIGNAL(activated(int)), this, SLOT(GotoLa(int))); |
187 | connect(Unitmen, SIGNAL(activated(int)), this, SLOT(ChgUnit(int))); |
||
188 | connect(this, SIGNAL(contentsMoving(int, int)), this, SLOT(setRulerPos(int, int))); |
||
189 | } |
||
190 | |||
456 | fschmid | 191 | void ScribusView::drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph) |
192 | { |
||
193 | if (Doc->loading) |
||
194 | return; |
||
195 | if (!updateOn) |
||
196 | return; |
||
197 | // QTime tim; |
||
198 | // tim.start(); |
||
199 | if ((clipw > 0) && (cliph > 0)) |
||
200 | { |
||
201 | QPixmap pm = QPixmap(clipw, cliph); |
||
494 | fschmid | 202 | ScPainter *painter = new ScPainter(&pm, clipw, cliph); |
456 | fschmid | 203 | painter->clear(paletteBackgroundColor()); |
204 | painter->translate(-clipx, -clipy); |
||
205 | painter->setLineWidth(1); |
||
206 | painter->setFillMode(ScPainter::Solid); |
||
207 | painter->translate(0.5, 0.5); |
||
208 | painter->setZoomFactor(1.0); |
||
209 | /* Draw Page Outlines */ |
||
210 | if (!Doc->MasterP) |
||
211 | { |
||
212 | for (uint a = 0; a < Doc->Pages.count(); ++a) |
||
213 | { |
||
214 | int x = static_cast<int>(Doc->Pages.at(a)->Xoffset * Scale); |
||
215 | int y = static_cast<int>(Doc->Pages.at(a)->Yoffset * Scale); |
||
216 | int w = static_cast<int>(Doc->Pages.at(a)->Width * Scale); |
||
217 | int h = static_cast<int>(Doc->Pages.at(a)->Height * Scale); |
||
218 | if (QRect(x, y, w+5, h+5).intersects(QRect(clipx, clipy, clipw, cliph))) |
||
219 | { |
||
220 | painter->setFillMode(ScPainter::Solid); |
||
221 | painter->setPen(black, 1, SolidLine, FlatCap, MiterJoin); |
||
222 | painter->setBrush(QColor(128,128,128)); |
||
223 | painter->drawRect(x+5, y+5, w, h); |
||
224 | painter->setBrush(Doc->papColor); |
||
225 | painter->drawRect(x, y, w, h); |
||
226 | if (Doc->Before) |
||
227 | DrawPageMarks(painter, Doc->Pages.at(a), QRect(clipx, clipy, clipw, cliph)); |
||
228 | } |
||
229 | DrawMasterItems(painter, Doc->Pages.at(a), QRect(clipx, clipy, clipw, cliph)); |
||
230 | } |
||
231 | DrawPageItems(painter, QRect(clipx, clipy, clipw, cliph)); |
||
232 | if (!Doc->Before) |
||
233 | { |
||
234 | for (uint a = 0; a < Doc->Pages.count(); ++a) |
||
235 | { |
||
236 | int x = static_cast<int>(Doc->Pages.at(a)->Xoffset * Scale); |
||
237 | int y = static_cast<int>(Doc->Pages.at(a)->Yoffset * Scale); |
||
238 | int w = static_cast<int>(Doc->Pages.at(a)->Width * Scale); |
||
239 | int h = static_cast<int>(Doc->Pages.at(a)->Height * Scale); |
||
240 | if (QRect(x, y, w+5, h+5).intersects(QRect(clipx, clipy, clipw, cliph))) |
||
241 | DrawPageMarks(painter, Doc->Pages.at(a), QRect(clipx, clipy, clipw, cliph)); |
||
242 | } |
||
243 | } |
||
244 | } |
||
245 | else |
||
246 | { |
||
247 | int x = static_cast<int>(Doc->ScratchLeft * Scale); |
||
248 | int y = static_cast<int>(Doc->ScratchTop * Scale); |
||
249 | int w = static_cast<int>(Doc->ActPage->Width * Scale); |
||
250 | int h = static_cast<int>(Doc->ActPage->Height * Scale); |
||
251 | if (QRect(x, y, w+5, h+5).intersects(QRect(clipx, clipy, clipw, cliph))) |
||
252 | { |
||
253 | painter->setFillMode(ScPainter::Solid); |
||
254 | painter->setPen(black, 1, SolidLine, FlatCap, MiterJoin); |
||
255 | painter->setBrush(QColor(128,128,128)); |
||
256 | painter->drawRect(x+5, y+5, w, h); |
||
257 | painter->setBrush(Doc->papColor); |
||
258 | painter->drawRect(x, y, w, h); |
||
259 | if (Doc->Before) |
||
260 | DrawPageMarks(painter, Doc->ActPage, QRect(clipx, clipy, clipw, cliph)); |
||
261 | } |
||
262 | DrawPageItems(painter, QRect(clipx, clipy, clipw, cliph)); |
||
263 | if ((!Doc->Before) && (QRect(x, y, w+5, h+5).intersects(QRect(clipx, clipy, clipw, cliph)))) |
||
264 | DrawPageMarks(painter, Doc->ActPage, QRect(clipx, clipy, clipw, cliph)); |
||
265 | } |
||
266 | if (SelItem.count() != 0) |
||
267 | { |
||
268 | double z = painter->zoomFactor(); |
||
269 | painter->setZoomFactor(Scale); |
||
270 | painter->save(); |
||
271 | PageItem *b = SelItem.at(0); |
||
272 | if (((Doc->AppMode == 10) || (Doc->AppMode == 11)) && (b->PType == 4)) |
||
273 | { |
||
274 | PageItem *nb = b; |
||
275 | while (nb != 0) |
||
276 | { |
||
277 | if (nb->BackBox != 0) |
||
278 | nb = nb->BackBox; |
||
279 | else |
||
280 | break; |
||
281 | } |
||
282 | while (nb != 0) |
||
283 | { |
||
284 | FPoint Start = transformPoint(FPoint(nb->Width/2, nb->Height), nb->Xpos, nb->Ypos, nb->Rot, 1, 1); |
||
285 | nb = nb->NextBox; |
||
286 | if (nb != 0) |
||
287 | { |
||
288 | FPoint End = transformPoint(FPoint(nb->Width/2, 0), nb->Xpos, nb->Ypos, nb->Rot, 1, 1); |
||
289 | painter->setPen(black, 5.0 / Scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
||
290 | painter->setPenOpacity(0.3); |
||
291 | painter->drawLine(Start, End); |
||
292 | } |
||
293 | } |
||
294 | } |
||
295 | painter->setLineWidth(1); |
||
296 | painter->setPenOpacity(1.0); |
||
297 | painter->restore(); |
||
298 | painter->setZoomFactor(z); |
||
299 | } |
||
300 | painter->end(); |
||
494 | fschmid | 301 | QPoint vr = contentsToViewport(QPoint(clipx, clipy)); |
302 | bitBlt( viewport(), vr.x(), vr.y(), &pm, 0, 0, clipw, cliph ); |
||
456 | fschmid | 303 | delete painter; |
304 | } |
||
305 | if (SelItem.count() != 0) |
||
306 | { |
||
307 | PageItem *b = SelItem.at(0); |
||
308 | b->paintObj(); |
||
309 | if ((Doc->EditClip) && (b->Select)) |
||
310 | MarkClip(b); |
||
311 | if (GroupSel) |
||
312 | { |
||
313 | setGroupRect(); |
||
314 | paintGroupRect(); |
||
315 | } |
||
316 | } |
||
317 | if (Doc->AppMode == 7) |
||
318 | slotDoCurs(true); |
||
319 | // qDebug( "Time elapsed: %d ms", tim.elapsed() ); |
||
320 | } |
||
321 | |||
322 | void ScribusView::DrawMasterItems(ScPainter *painter, Page *page, QRect clip) |
||
323 | { |
||
324 | QPainter p; |
||
325 | int Lnr; |
||
326 | struct Layer ll; |
||
327 | PageItem* b; |
||
328 | ll.Sichtbar = false; |
||
329 | ll.LNr = 0; |
||
330 | double z = painter->zoomFactor(); |
||
331 | if (page->MPageNam != "") |
||
332 | { |
||
333 | Page* Mp = Doc->MasterPages.at(Doc->MasterNames[page->MPageNam]); |
||
334 | if (page->FromMaster.count() != 0) |
||
335 | { |
||
336 | Lnr = 0; |
||
337 | for (uint la = 0; la < Doc->Layers.count(); ++la) |
||
338 | { |
||
339 | Level2Layer(Doc, &ll, Lnr); |
||
340 | if (ll.Sichtbar) |
||
341 | { |
||
342 | for (uint a = 0; a < page->FromMaster.count(); ++a) |
||
343 | { |
||
344 | b = page->FromMaster.at(a); |
||
345 | if (b->LayerNr != ll.LNr) |
||
346 | continue; |
||
347 | if ((b->OwnPage != -1) && (b->OwnPage != static_cast<int>(Mp->PageNr))) |
||
348 | continue; |
||
349 | uint OldOwn = b->OwnPage; |
||
350 | double OldX = b->Xpos; |
||
351 | double OldY = b->Ypos; |
||
352 | double OldBX = b->BoundingX; |
||
353 | double OldBY = b->BoundingY; |
||
354 | b->OwnPage = page->PageNr; |
||
355 | if (!b->ChangedMasterItem) |
||
356 | { |
||
357 | b->Xpos = OldX - Mp->Xoffset + page->Xoffset; |
||
358 | b->Ypos = OldY - Mp->Yoffset + page->Yoffset; |
||
359 | b->BoundingX = OldBX - Mp->Xoffset + page->Xoffset; |
||
360 | b->BoundingY = OldBY - Mp->Yoffset + page->Yoffset; |
||
361 | } |
||
362 | QRect oldR = getRedrawBounding(b); |
||
363 | if (clip.intersects(oldR)) |
||
364 | b->DrawObj(painter, clip); |
||
365 | b->OwnPage = OldOwn; |
||
366 | if (!b->ChangedMasterItem) |
||
367 | { |
||
368 | b->Xpos = OldX; |
||
369 | b->Ypos = OldY; |
||
370 | b->BoundingX = OldBX; |
||
371 | b->BoundingY = OldBY; |
||
372 | } |
||
373 | } |
||
374 | for (uint a = 0; a < page->FromMaster.count(); ++a) |
||
375 | { |
||
376 | b = page->FromMaster.at(a); |
||
377 | if (b->LayerNr != ll.LNr) |
||
378 | continue; |
||
379 | if (!b->isTableItem) |
||
380 | continue; |
||
381 | if ((b->OwnPage != -1) && (b->OwnPage != static_cast<int>(Mp->PageNr))) |
||
382 | continue; |
||
383 | double OldX = b->Xpos; |
||
384 | double OldY = b->Ypos; |
||
385 | double OldBX = b->BoundingX; |
||
386 | double OldBY = b->BoundingY; |
||
387 | if (!b->ChangedMasterItem) |
||
388 | { |
||
389 | b->Xpos = OldX - Mp->Xoffset + page->Xoffset; |
||
390 | b->Ypos = OldY - Mp->Yoffset + page->Yoffset; |
||
391 | b->BoundingX = OldBX - Mp->Xoffset + page->Xoffset; |
||
392 | b->BoundingY = OldBY - Mp->Yoffset + page->Yoffset; |
||
393 | } |
||
394 | QRect oldR = getRedrawBounding(b); |
||
395 | if (clip.intersects(oldR)) |
||
396 | { |
||
397 | painter->setZoomFactor(Scale); |
||
398 | painter->save(); |
||
399 | painter->translate(b->Xpos*Scale, b->Ypos*Scale); |
||
400 | painter->rotate(b->Rot); |
||
401 | if (b->Pcolor2 != "None") |
||
402 | { |
||
403 | QColor tmp; |
||
404 | b->SetFarbe(&tmp, b->Pcolor2, b->Shade2); |
||
405 | if ((b->TopLine) || (b->RightLine) || (b->BottomLine) || (b->LeftLine)) |
||
406 | { |
||
407 | painter->setPen(tmp, b->Pwidth, b->PLineArt, Qt::SquareCap, b->PLineJoin); |
||
408 | if (b->TopLine) |
||
409 | painter->drawLine(FPoint(0.0, 0.0), FPoint(b->Width, 0.0)); |
||
410 | if (b->RightLine) |
||
411 | painter->drawLine(FPoint(b->Width, 0.0), FPoint(b->Width, b->Height)); |
||
412 | if (b->BottomLine) |
||
413 | painter->drawLine(FPoint(b->Width, b->Height), FPoint(0.0, b->Height)); |
||
414 | if (b->LeftLine) |
||
415 | painter->drawLine(FPoint(0.0, b->Height), FPoint(0.0, 0.0)); |
||
416 | } |
||
417 | } |
||
418 | painter->restore(); |
||
419 | } |
||
420 | if (!b->ChangedMasterItem) |
||
421 | { |
||
422 | b->Xpos = OldX; |
||
423 | b->Ypos = OldY; |
||
424 | b->BoundingX = OldBX; |
||
425 | b->BoundingY = OldBY; |
||
426 | } |
||
427 | } |
||
428 | } |
||
429 | Lnr++; |
||
430 | } |
||
431 | } |
||
432 | } |
||
433 | painter->setZoomFactor(z); |
||
434 | } |
||
435 | |||
436 | void ScribusView::DrawPageItems(ScPainter *painter, QRect clip) |
||
437 | { |
||
438 | QPainter p; |
||
439 | int Lnr; |
||
440 | struct Layer ll; |
||
441 | PageItem* b; |
||
442 | ll.Sichtbar = false; |
||
443 | ll.LNr = 0; |
||
444 | double z = painter->zoomFactor(); |
||
445 | if (Doc->Items.count() != 0) |
||
446 | { |
||
447 | Lnr = 0; |
||
448 | for (uint la2 = 0; la2 < Doc->Layers.count(); ++la2) |
||
449 | { |
||
450 | Level2Layer(Doc, &ll, Lnr); |
||
451 | if (ll.Sichtbar) |
||
452 | { |
||
453 | QPtrListIterator<PageItem> docItem(Doc->Items); |
||
454 | while ( (b = docItem.current()) != 0 ) |
||
455 | { |
||
456 | ++docItem; |
||
457 | if (b->LayerNr != ll.LNr) |
||
458 | continue; |
||
459 | if ((Doc->MasterP) && ((b->OwnPage != -1) && (b->OwnPage != static_cast<int>(Doc->ActPage->PageNr)))) |
||
460 | continue; |
||
461 | QRect oldR = getRedrawBounding(b); |
||
462 | if (clip.intersects(oldR)) |
||
463 | { |
||
464 | if (!((Doc->EditClip) && (Mpressed))) |
||
465 | b->DrawObj(painter, clip); |
||
466 | b->Redrawn = true; |
||
467 | if ((Doc->AppMode == 7) && (b->Select) && (b->PType == 4)) |
||
468 | { |
||
469 | HR->ItemPos = b->Xpos - Doc->ScratchLeft; |
||
470 | HR->ItemEndPos = (b->Xpos+b->Width) - Doc->ScratchLeft; |
||
471 | if (b->Pcolor2 != "None") |
||
472 | HR->lineCorr = b->Pwidth / 2.0; |
||
473 | else |
||
474 | HR->lineCorr = 0; |
||
475 | HR->ColGap = b->ColGap; |
||
476 | HR->Cols = b->Cols; |
||
477 | HR->Extra = b->Extra; |
||
478 | HR->RExtra = b->RExtra; |
||
479 | HR->First = Doc->Vorlagen[Doc->CurrentABStil].First; |
||
480 | HR->Indent = Doc->Vorlagen[Doc->CurrentABStil].Indent; |
||
481 | if ((b->flippedH % 2 != 0) || (b->Reverse)) |
||
482 | HR->Revers = true; |
||
483 | else |
||
484 | HR->Revers = false; |
||
485 | HR->ItemPosValid = true; |
||
486 | HR->repX = false; |
||
487 | if (Doc->CurrentABStil < 5) |
||
488 | HR->TabValues = b->TabValues; |
||
489 | else |
||
490 | HR->TabValues = Doc->Vorlagen[Doc->CurrentABStil].TabValues; |
||
491 | HR->repaint(); |
||
492 | } |
||
493 | } |
||
494 | } |
||
495 | QPtrListIterator<PageItem> docItem2(Doc->Items); |
||
496 | while ( (b = docItem2.current()) != 0 ) |
||
497 | { |
||
498 | ++docItem2; |
||
499 | if (b->LayerNr != ll.LNr) |
||
500 | continue; |
||
501 | if (!b->isTableItem) |
||
502 | continue; |
||
503 | QRect oldR = getRedrawBounding(b); |
||
504 | if (clip.intersects(oldR)) |
||
505 | { |
||
506 | painter->setZoomFactor(Scale); |
||
507 | painter->save(); |
||
508 | painter->translate(b->Xpos*Scale, b->Ypos*Scale); |
||
509 | painter->rotate(b->Rot); |
||
510 | if (b->Pcolor2 != "None") |
||
511 | { |
||
512 | QColor tmp; |
||
513 | b->SetFarbe(&tmp, b->Pcolor2, b->Shade2); |
||
514 | if ((b->TopLine) || (b->RightLine) || (b->BottomLine) || (b->LeftLine)) |
||
515 | { |
||
516 | painter->setPen(tmp, b->Pwidth, b->PLineArt, Qt::SquareCap, b->PLineJoin); |
||
517 | if (b->TopLine) |
||
518 | painter->drawLine(FPoint(0.0, 0.0), FPoint(b->Width, 0.0)); |
||
519 | if (b->RightLine) |
||
520 | painter->drawLine(FPoint(b->Width, 0.0), FPoint(b->Width, b->Height)); |
||
521 | if (b->BottomLine) |
||
522 | painter->drawLine(FPoint(b->Width, b->Height), FPoint(0.0, b->Height)); |
||
523 | if (b->LeftLine) |
||
524 | painter->drawLine(FPoint(0.0, b->Height), FPoint(0.0, 0.0)); |
||
525 | } |
||
526 | } |
||
527 | painter->restore(); |
||
528 | } |
||
529 | } |
||
530 | } |
||
531 | Lnr++; |
||
532 | } |
||
533 | } |
||
534 | painter->setZoomFactor(z); |
||
535 | } |
||
536 | |||
537 | void ScribusView::DrawPageMarks(ScPainter *p, Page *page, QRect clip) |
||
538 | { |
||
539 | double lw = 1.0 / Scale; |
||
540 | double z = p->zoomFactor(); |
||
541 | p->save(); |
||
542 | p->setZoomFactor(Scale); |
||
543 | p->translate(page->Xoffset * Scale, page->Yoffset * Scale); |
||
544 | p->setLineWidth(lw); |
||
545 | if (Prefs->MarginsShown) |
||
546 | { |
||
547 | p->setPen(Doc->margColor); |
||
548 | if (Doc->RandFarbig) |
||
549 | { |
||
550 | p->setBrush(Doc->margColor); |
||
551 | p->drawRect(0, 0, page->Width, page->Margins.Top); |
||
552 | p->drawRect(0, page->Margins.Top, page->Margins.Left, page->Height - page->Margins.Top); |
||
553 | p->drawRect(page->Margins.Left, page->Height - page->Margins.Bottom, page->Width - page->Margins.Right - page->Margins.Left, page->Margins.Bottom); |
||
554 | p->drawRect(page->Width - page->Margins.Right, page->Margins.Top, page->Margins.Right, page->Height); |
||
555 | } |
||
556 | p->setPen(Doc->margColor); |
||
557 | p->drawLine(FPoint(0, page->Margins.Top), FPoint(page->Width, page->Margins.Top)); |
||
558 | p->drawLine(FPoint(0, page->Height - page->Margins.Bottom), FPoint(page->Width, page->Height - page->Margins.Bottom)); |
||
559 | p->drawLine(FPoint(page->Margins.Left, 0), FPoint(page->Margins.Left, page->Height)); |
||
560 | p->drawLine(FPoint(page->Width - page->Margins.Right, 0), FPoint(page->Width - page->Margins.Right, page->Height)); |
||
561 | } |
||
562 | if (Prefs->BaseShown) |
||
563 | { |
||
564 | p->setPen(Doc->baseColor, lw, SolidLine, FlatCap, MiterJoin); |
||
565 | for (double yg = Doc->BaseOffs; yg < page->Height; yg += Doc->BaseGrid) |
||
566 | p->drawLine(FPoint(0, yg), FPoint(page->Width, yg)); |
||
567 | } |
||
568 | if (Prefs->GridShown) |
||
569 | { |
||
570 | double stx = 0; |
||
571 | double endx = page->Width; |
||
572 | double sty = 0; |
||
573 | double endy = page->Height; |
||
574 | /* double stx = clip.x() / Scale; |
||
575 | double endx = QMIN(stx + clip.width() / Scale, page->Width); |
||
576 | double sty = clip.y() / Scale; |
||
577 | double endy = QMIN(sty + clip.height() / Scale, page->Height); */ |
||
578 | if (Scale > 0.49) |
||
579 | { |
||
580 | double i,start; |
||
581 | i = Doc->majorGrid; |
||
582 | p->setPen(Doc->majorColor, lw, SolidLine, FlatCap, MiterJoin); |
||
583 | start=floor(sty/i); |
||
584 | start*=i; |
||
585 | for (double b = start; b < endy; b+=i) |
||
586 | { |
||
587 | p->drawLine(FPoint(0, b), FPoint(page->Width, b)); |
||
588 | } |
||
589 | start=floor(stx/i); |
||
590 | start*=i; |
||
591 | for (double b = start; b <= endx; b+=i) |
||
592 | { |
||
593 | p->drawLine(FPoint(b, 0), FPoint(b, page->Height)); |
||
594 | } |
||
595 | i = Doc->minorGrid; |
||
596 | p->setPen(Doc->minorColor, lw, DotLine, FlatCap, MiterJoin); |
||
597 | start=floor(sty/i); |
||
598 | start*=i; |
||
599 | for (double b = start; b < endy; b+=i) |
||
600 | { |
||
601 | p->drawLine(FPoint(0, b), FPoint(page->Width, b)); |
||
602 | } |
||
603 | start=floor(stx/i); |
||
604 | start*=i; |
||
605 | for (double b = start; b <= endx; b+=i) |
||
606 | { |
||
607 | p->drawLine(FPoint(b, 0), FPoint(b, page->Height)); |
||
608 | } |
||
609 | } |
||
610 | } |
||
611 | if (Prefs->GuidesShown) |
||
612 | { |
||
613 | p->setPen(Doc->guideColor, lw, DotLine, FlatCap, MiterJoin); |
||
614 | if (page->XGuides.count() != 0) |
||
615 | { |
||
616 | for (uint xg = 0; xg < page->XGuides.count(); ++xg) |
||
617 | p->drawLine(FPoint(page->XGuides[xg], 0), FPoint(page->XGuides[xg], page->Height)); |
||
618 | } |
||
619 | if (page->YGuides.count() != 0) |
||
620 | { |
||
621 | for (uint yg = 0; yg < page->YGuides.count(); ++yg) |
||
622 | p->drawLine(FPoint(0, page->YGuides[yg]), FPoint(page->Width, page->YGuides[yg])); |
||
623 | } |
||
624 | } |
||
625 | p->restore(); |
||
626 | p->setZoomFactor(z); |
||
627 | } |
||
628 | |||
629 | void ScribusView::leaveEvent(QEvent *) |
||
630 | { |
||
631 | /* if (BlockLeave) |
||
632 | return; */ |
||
633 | if (!Mpressed) |
||
634 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
635 | /* else |
||
636 | { |
||
637 | if ((SelItem.count() != 0) && (Mpressed) && (!doku->DragP) && (doku->AppMode == 1)) |
||
638 | { |
||
639 | PageItem *b = SelItem.at(0); |
||
640 | if ((b->Locked) || (b->Sizing)) |
||
641 | return; |
||
642 | doku->DragP = true; |
||
643 | doku->leaveDrag = true; |
||
644 | doku->DraggedElem = b; |
||
645 | doku->DragElements.clear(); |
||
646 | for (uint dre=0; dre<SelItem.count(); ++dre) |
||
647 | doku->DragElements.append(SelItem.at(dre)->ItemNr); |
||
648 | ScriXmlDoc *ss = new ScriXmlDoc(); |
||
649 | QDragObject *dr = new QTextDrag(ss->WriteElem(&SelItem, doku), this); |
||
650 | dr->setPixmap(loadIcon("DragPix.xpm")); |
||
651 | dr->drag(); |
||
652 | delete ss; |
||
653 | doku->DragP = false; |
||
654 | doku->leaveDrag = false; |
||
655 | Mpressed = false; |
||
656 | doku->DraggedElem = 0; |
||
657 | doku->DragElements.clear(); |
||
658 | } |
||
659 | } */ |
||
660 | } |
||
661 | |||
662 | void ScribusView::contentsDragEnterEvent(QDragEnterEvent *e) |
||
663 | { |
||
664 | QString text; |
||
665 | e->accept(QTextDrag::canDecode(e)); |
||
666 | if (QTextDrag::decode(e, text)) |
||
667 | { |
||
668 | double gx, gy, gw, gh; |
||
669 | setActiveWindow(); |
||
670 | raise(); |
||
671 | ScApp->newActWin(Doc->WinHan); |
||
672 | updateContents(); |
||
673 | // SeleItemPos(e->pos()); |
||
674 | QUrl ur(text); |
||
675 | QFileInfo fi = QFileInfo(ur.path()); |
||
676 | ScriXmlDoc *ss = new ScriXmlDoc(); |
||
677 | if (fi.exists()) |
||
678 | text = ur.path(); |
||
679 | if(ss->ReadElemHeader(text,fi.exists(), &gx, &gy, &gw, &gh)) |
||
680 | { |
||
681 | GroupX = e->pos().x() / Scale; |
||
682 | GroupY = e->pos().y() / Scale; |
||
683 | GroupW = gw; |
||
684 | GroupH = gh; |
||
685 | DraggedGroup = true; |
||
686 | DraggedGroupFirst = true; |
||
687 | GroupSel = false; |
||
688 | QPainter p; |
||
689 | p.begin(viewport()); |
||
690 | PaintSizeRect(&p, QRect()); |
||
691 | // QPoint pv = QPoint(qRound(gx), qRound(gy)); |
||
692 | // PaintSizeRect(&p, QRect(pv, QPoint(pv.x()+qRound(gw), pv.y()+qRound(gh)))); |
||
693 | p.end(); |
||
694 | } |
||
695 | delete ss; |
||
696 | } |
||
697 | } |
||
698 | |||
699 | void ScribusView::contentsDragMoveEvent(QDragMoveEvent *e) |
||
700 | { |
||
701 | QString text; |
||
702 | // PageItem *b; |
||
703 | // bool img; |
||
704 | e->accept(QTextDrag::canDecode(e)); |
||
705 | if (QTextDrag::decode(e, text)) |
||
706 | { |
||
707 | if (DraggedGroup) |
||
708 | { |
||
709 | double gx, gy, gw, gh; |
||
710 | GroupX = e->pos().x() / Scale; |
||
711 | GroupY = e->pos().y() / Scale; |
||
712 | getGroupRectScreen(&gx, &gy, &gw, &gh); |
||
713 | QPainter p; |
||
714 | p.begin(viewport()); |
||
715 | QPoint pv = QPoint(qRound(gx), qRound(gy)); |
||
716 | if (!DraggedGroupFirst) |
||
717 | PaintSizeRect(&p, QRect(pv, QPoint(pv.x()+qRound(gw), pv.y()+qRound(gh)))); |
||
718 | DraggedGroupFirst = false; |
||
719 | p.end(); |
||
720 | emit MousePos(GroupX-Doc->ActPage->Xoffset, GroupY-Doc->ActPage->Yoffset); |
||
721 | HR->Draw(e->pos().x()); |
||
722 | VR->Draw(e->pos().y()); |
||
723 | return; |
||
724 | } |
||
725 | /* QUrl ur(text); |
||
726 | QFileInfo fi = QFileInfo(ur.path()); |
||
727 | QString ext = fi.extension(false).upper(); |
||
728 | QStrList imfo = QImageIO::inputFormats(); |
||
729 | if (ext == "JPG") |
||
730 | ext = "JPEG"; |
||
731 | img = ((imfo.contains(ext))||(ext=="PS")||(ext=="EPS")||(ext=="TIF")); |
||
732 | if (!SeleItemPos(e->pos())) |
||
733 | { |
||
734 | if (SelItem.count() != 0) |
||
735 | Deselect(true); |
||
736 | } |
||
737 | else |
||
738 | { |
||
739 | b = SelItem.at(0); |
||
740 | if (img) |
||
741 | { |
||
742 | if (b->PType != 2) |
||
743 | Deselect(true); |
||
744 | } |
||
745 | else |
||
746 | { |
||
747 | if (b->PType != 4) |
||
748 | Deselect(true); |
||
749 | } |
||
750 | } */ |
||
751 | } |
||
752 | } |
||
753 | |||
754 | void ScribusView::contentsDragLeaveEvent(QDragLeaveEvent *e) |
||
755 | { |
||
756 | if (DraggedGroup) |
||
757 | { |
||
758 | updateContents(); |
||
759 | DraggedGroup = false; |
||
760 | DraggedGroupFirst = false; |
||
761 | } |
||
762 | } |
||
763 | |||
764 | void ScribusView::contentsDropEvent(QDropEvent *e) |
||
765 | { |
||
766 | QString text; |
||
767 | PageItem *b; |
||
768 | bool img = false; |
||
769 | // struct Pti *hg; |
||
770 | // uint a; |
||
771 | int re; |
||
772 | e->accept(QTextDrag::canDecode(e)); |
||
773 | DraggedGroupFirst = false; |
||
774 | if (QTextDrag::decode(e, text)) |
||
775 | { |
||
776 | QUrl ur(text); |
||
777 | QFileInfo fi = QFileInfo(ur.path()); |
||
778 | QString ext = fi.extension(false).upper(); |
||
779 | QStrList imfo = QImageIO::inputFormats(); |
||
780 | if (ext == "JPG") |
||
781 | ext = "JPEG"; |
||
782 | img = ((imfo.contains(ext))||(ext=="PS")||(ext=="EPS")||(ext=="PDF")||(ext=="TIF")); |
||
783 | /* if ((fi.exists()) && (img) && (!SeleItemPos(e->pos()))) |
||
784 | { |
||
785 | int z = PaintPict(qRound(e->pos().x()/doku->Scale), qRound(e->pos().y()/doku->Scale), 1, 1); |
||
786 | b = Items.at(z); |
||
787 | LoadPict(ur.path(), b->ItemNr); |
||
788 | b->Width = static_cast<double>(b->pixm.width()); |
||
789 | b->Height = static_cast<double>(b->pixm.height()); |
||
790 | b->OldB2 = b->Width; |
||
791 | b->OldH2 = b->Height; |
||
792 | UpdateClip(b); |
||
793 | emit DocChanged(); |
||
794 | update(); |
||
795 | return; |
||
796 | } */ |
||
797 | /* if ((SeleItemPos(e->pos())) && (!text.startsWith("<SCRIBUSELEM"))) |
||
798 | { |
||
799 | b = SelItem.at(0); |
||
800 | if (b->PType == 2) |
||
801 | { |
||
802 | if ((fi.exists()) && (img)) |
||
803 | { |
||
804 | LoadPict(ur.path(), b->ItemNr); |
||
805 | update(); |
||
806 | } |
||
807 | } |
||
808 | if (b->PType == 4) |
||
809 | { |
||
810 | if ((b->BackBox != 0) && (b->Ptext.count() == 0)) |
||
811 | return; |
||
812 | if ((fi.exists()) && (!img) && (fi.size() < 500000)) |
||
813 | { |
||
814 | Serializer *ss = new Serializer(ur.path()); |
||
815 | if (ss->Read()) |
||
816 | { |
||
817 | int st = doku->CurrentABStil; |
||
818 | ss->GetText(b, st, doku->Vorlagen[st].Font, doku->Vorlagen[st].FontSize); |
||
819 | emit DocChanged(); |
||
820 | } |
||
821 | delete ss; |
||
822 | update(); |
||
823 | } |
||
824 | else |
||
825 | { |
||
826 | slotDoCurs(false); |
||
827 | slotSetCurs(e->pos().x(), e->pos().y()); |
||
828 | if (text.startsWith("<SCRIBUSELEM")) |
||
829 | return; |
||
830 | for (a=0; a<text.length(); ++a) |
||
831 | { |
||
832 | hg = new Pti; |
||
833 | hg->ch = text.at(a); |
||
834 | if (hg->ch == QChar(10)) |
||
835 | hg->ch = QChar(13); |
||
836 | if (hg->ch == QChar(4)) |
||
837 | hg->ch = QChar(9); |
||
838 | if (hg->ch == QChar(5)) |
||
839 | hg->ch = QChar(13); |
||
840 | hg->cfont = b->IFont; |
||
841 | hg->csize = b->ISize; |
||
842 | hg->ccolor = b->TxtFill; |
||
843 | hg->cshade = b->ShTxtFill; |
||
844 | hg->cstroke = b->TxtStroke; |
||
845 | hg->cshade2 = b->ShTxtStroke; |
||
846 | hg->cselect = false; |
||
847 | hg->cscale = b->TxtScale; |
||
848 | hg->cextra = 0; |
||
849 | hg->cstyle = 0; |
||
850 | hg->cab = 0; |
||
851 | hg->xp = 0; |
||
852 | hg->yp = 0; |
||
853 | hg->PRot = 0; |
||
854 | hg->PtransX = 0; |
||
855 | hg->PtransY = 0; |
||
856 | b->Ptext.insert(b->CPos, hg); |
||
857 | b->CPos += 1; |
||
858 | } |
||
859 | emit DocChanged(); |
||
860 | update(); |
||
861 | } |
||
862 | } |
||
863 | } |
||
864 | else |
||
865 | { */ |
||
866 | uint ac = Doc->Items.count(); |
||
867 | if ((!img) && (Doc->DraggedElem == 0)) |
||
868 | emit LoadElem(QString(text), qRound(e->pos().x()/Scale), qRound(e->pos().y()/Scale), false, false, Doc, this); |
||
869 | else |
||
870 | { |
||
871 | if (Doc->DraggedElem != 0) |
||
872 | { |
||
873 | if (!Doc->leaveDrag) |
||
874 | { |
||
875 | QPopupMenu *pmen = new QPopupMenu(); |
||
876 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
877 | pmen->insertItem( tr("Copy Here")); |
||
878 | pmen->insertItem( tr("Move Here")); |
||
879 | pmen->insertItem( tr("Cancel")); |
||
880 | re = pmen->indexOf(pmen->exec(QCursor::pos())); |
||
881 | delete pmen; |
||
882 | } |
||
883 | else |
||
884 | re = 1; |
||
885 | if ((re == 2) || (re == -1)) |
||
886 | { |
||
887 | updateContents(); |
||
888 | return; |
||
889 | } |
||
890 | if ((re == 1) || (Doc->leaveDrag)) |
||
891 | { |
||
892 | QPtrList<PageItem> pasted; |
||
893 | emit LoadElem(QString(text), qRound(e->pos().x()/Scale), qRound(e->pos().y()/Scale), false, false, Doc, this); |
||
894 | for (uint as = ac; as < Doc->Items.count(); ++as) |
||
895 | { |
||
896 | pasted.append(Doc->Items.at(as)); |
||
897 | } |
||
898 | SelItem.clear(); |
||
899 | for (uint dre=0; dre<Doc->DragElements.count(); ++dre) |
||
900 | { |
||
901 | SelItem.append(Doc->Items.at(Doc->DragElements[dre])); |
||
902 | } |
||
903 | PageItem* bb; |
||
904 | int fin; |
||
905 | for (uint dre=0; dre<Doc->DragElements.count(); ++dre) |
||
906 | { |
||
907 | bb = pasted.at(dre); |
||
908 | b = SelItem.at(dre); |
||
909 | if ((b->PType == 4) && ((b->NextBox != 0) || (b->BackBox != 0))) |
||
910 | { |
||
911 | if (b->BackBox != 0) |
||
912 | { |
||
913 | bb->BackBox = b->BackBox; |
||
914 | fin = SelItem.find(b->BackBox); |
||
915 | if (fin != -1) |
||
916 | bb->BackBox = pasted.at(fin); |
||
917 | bb->BackBox->NextBox = bb; |
||
918 | } |
||
919 | if (b->NextBox != 0) |
||
920 | { |
||
921 | bb->NextBox = b->NextBox; |
||
922 | fin = SelItem.find(b->NextBox); |
||
923 | if (fin != -1) |
||
924 | bb->NextBox = pasted.at(fin); |
||
925 | bb->NextBox->BackBox = bb; |
||
926 | } |
||
927 | } |
||
928 | } |
||
929 | for (uint dre=0; dre<Doc->DragElements.count(); ++dre) |
||
930 | { |
||
931 | b = SelItem.at(dre); |
||
932 | b->NextBox = 0; |
||
933 | b->BackBox = 0; |
||
934 | } |
||
935 | pasted.clear(); |
||
936 | DeleteItem(); |
||
937 | } |
||
938 | } |
||
939 | if ((!img) && ((re == 0))) |
||
940 | emit LoadElem(QString(text), qRound(e->pos().x()/Scale), qRound(e->pos().y()/Scale), false, false, Doc, this); |
||
941 | Doc->DraggedElem = 0; |
||
942 | Doc->DragElements.clear(); |
||
943 | SelItem.clear(); |
||
944 | for (uint as = ac; as < Doc->Items.count(); ++as) |
||
945 | { |
||
946 | SelectItemNr(as); |
||
947 | } |
||
948 | updateContents(); |
||
949 | } |
||
950 | // } |
||
951 | } |
||
952 | } |
||
953 | |||
954 | void ScribusView::contentsMouseDoubleClickEvent(QMouseEvent *m) |
||
955 | { |
||
956 | m->accept(); |
||
957 | Mpressed = false; |
||
958 | PageItem *b = 0; |
||
959 | if (Doc->EditClip) |
||
960 | { |
||
961 | emit EndNodeEdit(); |
||
962 | return; |
||
963 | } |
||
964 | if ((GroupSel) || (Doc->AppMode != 1)) |
||
965 | { |
||
966 | if ((GroupSel) && (Doc->AppMode == 1)) |
||
967 | { |
||
968 | if (GetItem(&b)) |
||
969 | { |
||
970 | if (b->isTableItem) |
||
971 | { |
||
972 | Deselect(false); |
||
973 | SelItem.append(b); |
||
974 | b->isSingleSel = true; |
||
975 | b->Select = true; |
||
976 | emit HaveSel(b->PType); |
||
977 | EmitValues(b); |
||
978 | b->paintObj(); |
||
979 | } |
||
980 | } |
||
981 | } |
||
982 | else |
||
983 | contentsMousePressEvent(m); |
||
984 | return; |
||
985 | } |
||
986 | if (GetItem(&b)) |
||
987 | { |
||
988 | if ((b->PType == 6) || (b->PType == 7) || (b->PType == 2) || (b->PType == 8)) |
||
989 | { |
||
990 | if ((b->Locked) || (!b->ScaleType)) |
||
991 | { |
||
992 | contentsMousePressEvent(m); |
||
993 | return; |
||
994 | } |
||
995 | emit Amode(7); |
||
996 | } |
||
997 | else |
||
998 | if (b->PType == 4) |
||
999 | emit b->isAnnotation ? AnnotProps() : Amode(7); |
||
1000 | } |
||
1001 | } |
||
1002 | |||
1003 | void ScribusView::contentsMouseReleaseEvent(QMouseEvent *m) |
||
1004 | { |
||
1005 | PageItem *b; |
||
1006 | Mpressed = false; |
||
1007 | if (Prefs->GuidesShown) |
||
1008 | { |
||
1009 | bool fg = false; |
||
1010 | double nx = m->x()/Scale; |
||
1011 | double ny = m->y()/Scale; |
||
1012 | if (Doc->ActPage->YGuides.count() != 0) |
||
1013 | { |
||
1014 | for (uint yg = 0; yg < Doc->ActPage->YGuides.count(); ++yg) |
||
1015 | { |
||
1016 | if ((Doc->ActPage->YGuides[yg]+Doc->ActPage->Yoffset < (ny+Doc->GrabRad)) && |
||
1017 | (Doc->ActPage->YGuides[yg]+Doc->ActPage->Yoffset > (ny-Doc->GrabRad))) |
||
1018 | { |
||
1019 | fg = true; |
||
1020 | break; |
||
1021 | } |
||
1022 | } |
||
1023 | } |
||
1024 | if (Doc->ActPage->XGuides.count() != 0) |
||
1025 | { |
||
1026 | for (uint xg = 0; xg < Doc->ActPage->XGuides.count(); ++xg) |
||
1027 | { |
||
1028 | if ((Doc->ActPage->XGuides[xg]+Doc->ActPage->Xoffset < (nx+Doc->GrabRad)) && |
||
1029 | (Doc->ActPage->XGuides[xg]+Doc->ActPage->Xoffset > (nx-Doc->GrabRad))) |
||
1030 | { |
||
1031 | fg = true; |
||
1032 | break; |
||
1033 | } |
||
1034 | } |
||
1035 | } |
||
1036 | if ((fg) && (m->button() == RightButton)) |
||
1037 | { |
||
1038 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1039 | MoveGY = false; |
||
1040 | MoveGX = false; |
||
1041 | emit EditGuides(); |
||
1042 | return; |
||
1043 | } |
||
1044 | if (MoveGY) |
||
1045 | { |
||
1046 | Doc->ActPage->YGuides.remove(Doc->ActPage->YGuides[GyM]); |
||
1047 | SetYGuide(m); |
||
1048 | MoveGY = false; |
||
1049 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1050 | updateContents(); |
||
1051 | return; |
||
1052 | } |
||
1053 | if (MoveGX) |
||
1054 | { |
||
1055 | Doc->ActPage->XGuides.remove(Doc->ActPage->XGuides[GxM]); |
||
1056 | SetXGuide(m); |
||
1057 | MoveGX = false; |
||
1058 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1059 | updateContents(); |
||
1060 | return; |
||
1061 | } |
||
1062 | } |
||
1063 | if (Doc->AppMode == 24) |
||
1064 | { |
||
1065 | QPainter p; |
||
1066 | p.begin(viewport()); |
||
1067 | ToView(&p); |
||
1068 | p.scale(Scale, Scale); |
||
1069 | p.setRasterOp(XorROP); |
||
1070 | p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin)); |
||
1071 | p.drawLine(Dxp, Dyp, Mxp, Myp); |
||
1072 | p.end(); |
||
1073 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1074 | emit PaintingDone(); |
||
1075 | return; |
||
1076 | } |
||
1077 | if (Doc->AppMode == 23) |
||
1078 | return; |
||
1079 | if (Doc->AppMode == 22) |
||
1080 | { |
||
1081 | if ((SelItem.count() == 0) && (HaveSelRect) && (!MidButt)) |
||
1082 | { |
||
1083 | QRect AreaR = QRect(static_cast<int>(Mxp), static_cast<int>(Myp), static_cast<int>(SeRx-Mxp), static_cast<int>(SeRy-Myp)); |
||
1084 | QPainter p; |
||
1085 | p.begin(viewport()); |
||
1086 | ToView(&p); |
||
1087 | p.scale(Scale, Scale); |
||
1088 | p.setRasterOp(XorROP); |
||
1089 | p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin)); |
||
1090 | if(Mxp > SeRx) |
||
1091 | { |
||
1092 | double tmp=SeRx; |
||
1093 | SeRx=static_cast<int>(Mxp); |
||
1094 | Mxp=static_cast<int>(tmp); |
||
1095 | } |
||
1096 | if(Myp > SeRy) |
||
1097 | { |
||
1098 | double tmp=SeRy; |
||
1099 | SeRy=static_cast<int>(Myp); |
||
1100 | Myp=static_cast<int>(tmp); |
||
1101 | } |
||
1102 | HaveSelRect = false; |
||
1103 | double Tx, Ty, Tw, Th; |
||
1104 | Tx = Mxp; |
||
1105 | Ty = Myp; |
||
1106 | Tw = SeRx-Mxp; |
||
1107 | Th = SeRy-Myp; |
||
1108 | int z; |
||
1109 | int Cols, Rows; |
||
1110 | double deltaX, deltaY, offX, offY; |
||
1111 | if ((Th < 6) || (Tw < 6)) |
||
1112 | { |
||
1113 | p.drawRect(AreaR); |
||
1114 | p.end(); |
||
1115 | Doc->AppMode = 1; |
||
1116 | emit PaintingDone(); |
||
1117 | return; |
||
1118 | } |
||
1119 | InsertTable *dia = new InsertTable(this, static_cast<int>(Th / 6), static_cast<int>(Tw / 6)); |
||
1120 | if (!dia->exec()) |
||
1121 | { |
||
1122 | p.drawRect(AreaR); |
||
1123 | p.end(); |
||
1124 | Doc->AppMode = 1; |
||
1125 | emit PaintingDone(); |
||
1126 | delete dia; |
||
1127 | return; |
||
1128 | } |
||
1129 | p.end(); |
||
1130 | Cols = dia->Cols->value(); |
||
1131 | Rows = dia->Rows->value(); |
||
1132 | delete dia; |
||
1133 | deltaX = Tw / Cols; |
||
1134 | deltaY = Th / Rows; |
||
1135 | offX = 0.0; |
||
1136 | offY = 0.0; |
||
1137 | SelItem.clear(); |
||
1138 | for (int rc = 0; rc < Rows; ++rc) |
||
1139 | { |
||
1140 | for (int cc = 0; cc < Cols; ++cc) |
||
1141 | { |
||
1142 | z = PaintText(Tx + offX, Ty + offY, deltaX, deltaY, Doc->Dwidth, Doc->DpenText); |
||
1143 | b = Doc->Items.at(z); |
||
1144 | b->isTableItem = true; |
||
1145 | SelItem.append(b); |
||
1146 | offX += deltaX; |
||
1147 | } |
||
1148 | offY += deltaY; |
||
1149 | offX = 0.0; |
||
1150 | } |
||
1151 | for (int rc = 0; rc < Rows; ++rc) |
||
1152 | { |
||
1153 | for (int cc = 0; cc < Cols; ++cc) |
||
1154 | { |
||
1155 | b = SelItem.at((rc * Cols) + cc); |
||
1156 | if (rc == 0) |
||
1157 | b->TopLink = 0; |
||
1158 | else |
||
1159 | b->TopLink = SelItem.at(((rc-1)*Cols)+cc); |
||
1160 | if (rc == Rows-1) |
||
1161 | b->BottomLink = 0; |
||
1162 | else |
||
1163 | b->BottomLink = SelItem.at(((rc+1)*Cols)+cc); |
||
1164 | if (cc == 0) |
||
1165 | b->LeftLink = 0; |
||
1166 | else |
||
1167 | b->LeftLink = SelItem.at((rc*Cols)+cc-1); |
||
1168 | if (cc == Cols-1) |
||
1169 | b->RightLink = 0; |
||
1170 | else |
||
1171 | b->RightLink = SelItem.at((rc*Cols)+cc+1); |
||
1172 | } |
||
1173 | } |
||
1174 | emit DoGroup(); |
||
1175 | } |
||
1176 | Doc->AppMode = 1; |
||
1177 | emit PaintingDone(); |
||
1178 | emit DocChanged(); |
||
1179 | updateContents(); |
||
1180 | return; |
||
1181 | } |
||
1182 | if (Doc->AppMode == 21) |
||
1183 | { |
||
1184 | Doc->AppMode = 1; |
||
1185 | if (RecordP.size() > 1) |
||
1186 | { |
||
1187 | uint z = PaintPolyLine(0, 0, 1, 1, Doc->Dwidth, "None", Doc->Dpen); |
||
1188 | b = Doc->Items.at(z); |
||
1189 | b->PoLine.resize(0); |
||
1190 | b->PoLine.addPoint(RecordP.point(0)); |
||
1191 | b->PoLine.addPoint(RecordP.point(0)); |
||
1192 | for (uint px = 1; px < RecordP.size()-1; ++px) |
||
1193 | { |
||
1194 | b->PoLine.addPoint(RecordP.point(px)); |
||
1195 | b->PoLine.addPoint(RecordP.point(px)); |
||
1196 | b->PoLine.addPoint(RecordP.point(px)); |
||
1197 | b->PoLine.addPoint(RecordP.point(px)); |
||
1198 | } |
||
1199 | b->PoLine.addPoint(RecordP.point(RecordP.size()-1)); |
||
1200 | b->PoLine.addPoint(RecordP.point(RecordP.size()-1)); |
||
1201 | AdjustItemSize(b); |
||
1202 | SelItem.clear(); |
||
1203 | SelItem.append(b); |
||
1204 | b->ClipEdited = true; |
||
1205 | b->Select = true; |
||
1206 | b->FrameType = 3; |
||
1207 | b->OwnPage = OnPage(b); |
||
1208 | emit ItemPos(b->Xpos, b->Ypos); |
||
1209 | emit SetSizeValue(b->Pwidth); |
||
1210 | emit SetLineArt(b->PLineArt, b->PLineEnd, b->PLineJoin); |
||
1211 | emit ItemFarben(b->Pcolor2, b->Pcolor, b->Shade2, b->Shade); |
||
1212 | emit ItemGradient(b->GrType); |
||
1213 | emit ItemTrans(b->Transparency, b->TranspStroke); |
||
1214 | emit HaveSel(7); |
||
1215 | } |
||
1216 | updateContents(); |
||
1217 | emit PaintingDone(); |
||
1218 | emit DocChanged(); |
||
1219 | return; |
||
1220 | } |
||
1221 | if ((Doc->EditClip) && (ClRe == -1) && (HaveSelRect)) |
||
1222 | { |
||
1223 | double sc = Scale; |
||
1224 | QPainter p; |
||
1225 | p.begin(viewport()); |
||
1226 | ToView(&p); |
||
1227 | p.scale(Scale, Scale); |
||
1228 | p.setRasterOp(XorROP); |
||
1229 | p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin)); |
||
1230 | p.drawRect(Mxp, Myp, SeRx-Mxp, SeRy-Myp); |
||
1231 | p.end(); |
||
1232 | if(Mxp > SeRx) |
||
1233 | { |
||
1234 | double tmp=SeRx; |
||
1235 | SeRx=static_cast<int>(Mxp); |
||
1236 | Mxp=static_cast<int>(tmp); |
||
1237 | } |
||
1238 | if(Myp > SeRy) |
||
1239 | { |
||
1240 | double tmp=SeRy; |
||
1241 | SeRy=static_cast<int>(Myp); |
||
1242 | Myp=static_cast<int>(tmp); |
||
1243 | } |
||
1244 | b = SelItem.at(0); |
||
1245 | SelNode.clear(); |
||
1246 | QRect Sele = QRect(static_cast<int>(Mxp*sc), static_cast<int>(Myp*sc), static_cast<int>((SeRx-Mxp)*sc), static_cast<int>((SeRy-Myp)*sc)); |
||
1247 | FPointArray Clip; |
||
1248 | if (EditContour) |
||
1249 | Clip = b->ContourLine; |
||
1250 | else |
||
1251 | Clip = b->PoLine; |
||
1252 | for (uint a = 0; a < Clip.count(); ++a) |
||
1253 | { |
||
1254 | if (Clip.point(a).x() > 900000) |
||
1255 | continue; |
||
1256 | p.begin(viewport()); |
||
1257 | Transform(b, &p); |
||
1258 | QPoint npf = p.xForm(Clip.pointQ(a)); |
||
1259 | p.end(); |
||
1260 | if ((Sele.contains(npf)) && ((a == 0) || (((a-2) % 4) == 0))) |
||
1261 | { |
||
1262 | ClRe = a; |
||
1263 | SelNode.append(a); |
||
1264 | emit ClipPo(Clip.point(a).x(), Clip.point(a).y()); |
||
1265 | } |
||
1266 | } |
||
1267 | HaveSelRect = false; |
||
1268 | MarkClip(b); |
||
1269 | return; |
||
1270 | } |
||
1271 | if ((Doc->EditClip) && (SegP1 == -1) && (SegP2 == -1)) |
||
1272 | { |
||
1273 | if (Imoved) |
||
1274 | { |
||
1275 | b = SelItem.at(0); |
||
1276 | b->OldB2 = b->Width; |
||
1277 | b->OldH2 = b->Height; |
||
1278 | double nx = m->x()/Scale; |
||
1279 | double ny = m->y()/Scale; |
||
1280 | if (!ApplyGuides(&nx, &ny)) |
||
1281 | { |
||
1282 | FPoint npg = ApplyGridF(FPoint(nx, ny)); |
||
1283 | nx = npg.x(); |
||
1284 | ny = npg.y(); |
||
1285 | } |
||
1286 | FPoint np = transformPointI(FPoint(nx, ny), b->Xpos, b->Ypos, b->Rot, 1, 1); |
||
1287 | MoveClipPoint(b, np); |
||
1288 | } |
||
1289 | updateContents(); |
||
1290 | Imoved = false; |
||
1291 | return; |
||
1292 | } |
||
1293 | if ((Doc->EditClip) && (SegP1 != -1) && (SegP2 != -1)) |
||
1294 | { |
||
1295 | SegP1 = -1; |
||
1296 | SegP2 = -1; |
||
1297 | b = SelItem.at(0); |
||
1298 | Imoved = false; |
||
1299 | updateContents(); |
||
1300 | return; |
||
1301 | } |
||
1302 | if ((!GetItem(&b)) && (m->button() == RightButton) && (!Doc->DragP) && (Doc->AppMode == 1)) |
||
1303 | { |
||
1304 | int menid; |
||
1305 | QPopupMenu *pmen = new QPopupMenu(); |
||
1306 | if (ScApp->Buffer2.startsWith("<SCRIBUSELEM")) |
||
1307 | { |
||
1308 | Mxp = m->x(); |
||
1309 | Myp = m->y(); |
||
1310 | pmen->insertItem( tr("&Paste") , this, SLOT(PasteToPage())); |
||
1311 | pmen->insertSeparator(); |
||
1312 | } |
||
1313 | menid = pmen->insertItem(tr("Show &Margins"), ScApp, SLOT(ToggleMarks())); |
||
1314 | pmen->setItemChecked(menid, Prefs->MarginsShown); |
||
1315 | menid = pmen->insertItem(tr("Show &Frames"), ScApp, SLOT(ToggleFrames())); |
||
1316 | pmen->setItemChecked(menid, Prefs->FramesShown); |
||
1317 | menid = pmen->insertItem(tr("Show &Images"), ScApp, SLOT(TogglePics())); |
||
1318 | pmen->setItemChecked(menid, Doc->ShowPic); |
||
1319 | menid = pmen->insertItem(tr("Show &Grid"), ScApp, SLOT(ToggleRaster())); |
||
1320 | pmen->setItemChecked(menid, Prefs->GridShown); |
||
1321 | menid = pmen->insertItem(tr("Show G&uides"), ScApp, SLOT(ToggleGuides())); |
||
1322 | pmen->setItemChecked(menid, Prefs->GuidesShown); |
||
1323 | menid = pmen->insertItem(tr("Show &Baseline Grid"), ScApp, SLOT(ToggleBase())); |
||
1324 | pmen->setItemChecked(menid, Prefs->BaseShown); |
||
1325 | pmen->insertSeparator(); |
||
1326 | int uRas = pmen->insertItem( tr("Sn&ap to Grid"), ScApp, SLOT(ToggleURaster())); |
||
1327 | pmen->setItemChecked(uRas, Doc->useRaster); |
||
1328 | int uGuide = pmen->insertItem( tr("Sna&p to Guides"), ScApp, SLOT(ToggleUGuides())); |
||
1329 | pmen->setItemChecked(uGuide, Doc->SnapGuides); |
||
1330 | pmen->exec(QCursor::pos()); |
||
1331 | delete pmen; |
||
1332 | return; |
||
1333 | } |
||
1334 | if ((Doc->AppMode != 6) && (!Doc->EditClip) && (Doc->AppMode != 13)) |
||
1335 | { |
||
1336 | if ((GetItem(&b)) && (m->button() == RightButton) && (!Doc->DragP)) |
||
1337 | { |
||
1338 | QPopupMenu *pmen = new QPopupMenu(); |
||
1339 | QPopupMenu *pmen2 = new QPopupMenu(); |
||
1340 | pmen3 = new QPopupMenu(); |
||
1341 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1342 | QPopupMenu *pmen4 = new QPopupMenu(); |
||
1343 | QPopupMenu *pmenLevel = new QPopupMenu(); |
||
1344 | QPopupMenu *pmenPDF = new QPopupMenu(); |
||
1345 | |||
1346 | if ((b->PType == 4) || (b->PType == 2) || (b->PType == 8)) |
||
1347 | { |
||
1348 | QButtonGroup *InfoGroup = new QButtonGroup( this, "InfoGroup" ); |
||
1349 | InfoGroup->setFrameShape( QButtonGroup::NoFrame ); |
||
1350 | InfoGroup->setFrameShadow( QButtonGroup::Plain ); |
||
1351 | InfoGroup->setTitle(""); |
||
1352 | InfoGroup->setExclusive( true ); |
||
1353 | InfoGroup->setColumnLayout(0, Qt::Vertical ); |
||
1354 | InfoGroup->layout()->setSpacing( 0 ); |
||
1355 | InfoGroup->layout()->setMargin( 0 ); |
||
1356 | QGridLayout *InfoGroupLayout = new QGridLayout( InfoGroup->layout() ); |
||
1357 | InfoGroupLayout->setAlignment( Qt::AlignTop ); |
||
1358 | InfoGroupLayout->setSpacing( 2 ); |
||
1359 | InfoGroupLayout->setMargin( 0 ); |
||
1360 | QString txtC, txtC2; |
||
1361 | QLabel *InfoT = new QLabel(InfoGroup, "ct"); |
||
1362 | QLabel *ParCT = new QLabel(InfoGroup, "pt"); |
||
1363 | QLabel *ParC = new QLabel(InfoGroup, "pc"); |
||
1364 | QLabel *WordCT = new QLabel(InfoGroup, "wt"); |
||
1365 | QLabel *WordC = new QLabel(InfoGroup, "wc"); |
||
1366 | QLabel *CharCT = new QLabel(InfoGroup, "ct"); |
||
1367 | QLabel *CharC = new QLabel(InfoGroup, "cc"); |
||
1368 | QLabel *PrintCT = new QLabel(InfoGroup, "nt"); // <a.l.e> |
||
1369 | QLabel *PrintC = new QLabel(InfoGroup, "nc"); // </a.l.e> |
||
1370 | if (b->PType == 2) |
||
1371 | { |
||
1372 | QFileInfo fi = QFileInfo(b->Pfile); |
||
1373 | InfoT->setText( tr("Picture")); |
||
1374 | InfoGroupLayout->addMultiCellWidget( InfoT, 0, 0, 0, 1, Qt::AlignCenter ); |
||
1375 | ParCT->setText( tr("File: ")); |
||
1376 | InfoGroupLayout->addWidget( ParCT, 1, 0, Qt::AlignRight ); |
||
1377 | ParC->setText(fi.fileName()); |
||
1378 | InfoGroupLayout->addWidget( ParC, 1, 1 ); |
||
1379 | WordCT->setText( tr("Original PPI: ")); |
||
1380 | InfoGroupLayout->addWidget( WordCT, 2, 0, Qt::AlignRight ); |
||
1381 | WordC->setText(txtC.setNum(qRound(b->dpiX))+" x "+txtC2.setNum(qRound(b->dpiY))); |
||
1382 | InfoGroupLayout->addWidget( WordC, 2, 1 ); |
||
1383 | CharCT->setText( tr("Actual PPI: ")); |
||
1384 | InfoGroupLayout->addWidget( CharCT, 3, 0, Qt::AlignRight ); |
||
1385 | CharC->setText(txtC.setNum(qRound(72.0 / b->LocalScX))+" x "+ |
||
1386 | txtC2.setNum(qRound(72.0 / b->LocalScY))); |
||
1387 | InfoGroupLayout->addWidget( CharC, 3, 1 ); |
||
1388 | } |
||
1389 | if ((b->PType == 4) || (b->PType == 8)) |
||
1390 | { |
||
1391 | int Parag = 0; |
||
1392 | int Words = 0; |
||
1393 | int Chara = 0; |
||
1394 | int ParagN = 0; |
||
1395 | int WordsN = 0; |
||
1396 | int CharaN = 0; |
||
1397 | if (b->PType == 4) |
||
1398 | { |
||
1399 | if ((b->NextBox != 0) || (b->BackBox != 0)) |
||
1400 | InfoT->setText( tr("Linked Text")); |
||
1401 | else |
||
1402 | InfoT->setText( tr("Text Frame")); |
||
1403 | } |
||
1404 | else |
||
1405 | InfoT->setText( tr("Text on a Path")); |
||
1406 | InfoGroupLayout->addMultiCellWidget( InfoT, 0, 0, 0, 1, Qt::AlignCenter ); |
||
1407 | WordAndPara(b, &Words, &Parag, &Chara, &WordsN, &ParagN, &CharaN); |
||
1408 | ParCT->setText( tr("Paragraphs: ")); |
||
1409 | InfoGroupLayout->addWidget( ParCT, 1, 0, Qt::AlignRight ); |
||
1410 | if (ParagN != 0) |
||
1411 | ParC->setText(txtC.setNum(Parag+ParagN)+" ("+txtC2.setNum(ParagN)+")"); |
||
1412 | else |
||
1413 | ParC->setText(txtC.setNum(Parag)); |
||
1414 | InfoGroupLayout->addWidget( ParC, 1, 1 ); |
||
1415 | WordCT->setText( tr("Words: ")); |
||
1416 | InfoGroupLayout->addWidget( WordCT, 2, 0, Qt::AlignRight ); |
||
1417 | if (WordsN != 0) |
||
1418 | WordC->setText(txtC.setNum(Words+WordsN)+" ("+txtC2.setNum(WordsN)+")"); |
||
1419 | else |
||
1420 | WordC->setText(txtC.setNum(Words)); |
||
1421 | InfoGroupLayout->addWidget( WordC, 2, 1 ); |
||
1422 | CharCT->setText( tr("Chars: ")); |
||
1423 | InfoGroupLayout->addWidget( CharCT, 3, 0, Qt::AlignRight ); |
||
1424 | if (CharaN != 0) |
||
1425 | CharC->setText(txtC.setNum(Chara+CharaN)+" ("+txtC2.setNum(CharaN)+")"); |
||
1426 | else |
||
1427 | CharC->setText(txtC.setNum(Chara)); |
||
1428 | InfoGroupLayout->addWidget( CharC, 3, 1 ); |
||
1429 | } |
||
1430 | |||
1431 | int row = InfoGroupLayout->numRows(); // <a.l.e> |
||
1432 | |||
1433 | PrintCT->setText( tr("Print: ")); |
||
1434 | InfoGroupLayout->addWidget( PrintCT, row, 0, Qt::AlignRight ); |
||
1435 | if (b->isPrintable == true) |
||
1436 | PrintC->setText( tr("Enabled")); |
||
1437 | else |
||
1438 | PrintC->setText( tr("Disabled")); |
||
1439 | InfoGroupLayout->addWidget( PrintC, row, 1 ); // </a.l.e> |
||
1440 | |||
1441 | pmen4->insertItem(InfoGroup); |
||
1442 | |||
1443 | pmen->insertItem( tr("In&fo"), pmen4); |
||
1444 | } |
||
1445 | if (b->PType == 2) |
||
1446 | { |
||
1447 | pmen->insertItem( tr("&Get Picture..."), this, SIGNAL(LoadPic())); |
||
1448 | int px = pmen->insertItem( tr("I&mage Visible"), this, SLOT(TogglePic())); |
||
1449 | pmen->setItemChecked(px, b->PicArt); |
||
1450 | if (b->PicAvail) |
||
1451 | pmen->insertItem( tr("&Update Picture"), this, SLOT(UpdatePic())); |
||
1452 | if (b->PicAvail && b->isRaster) |
||
1453 | pmen->insertItem( tr("&Edit Picture"), this, SLOT(CallGimp())); |
||
1454 | if ((b->PicAvail) && (!b->isTableItem)) |
||
1455 | pmen->insertItem( tr("&Adjust Frame to Picture"), this, SLOT(FrameToPic())); |
||
1456 | } |
||
1457 | if (b->PType == 4) |
||
1458 | { |
||
1459 | pmen->insertItem( tr("&Get Text..."), this, SIGNAL(LoadPic())); |
||
1460 | pmen->insertItem( tr("&Append Text..."), this, SIGNAL(AppendText())); |
||
1461 | pmen->insertItem( tr("&Edit Text..."), this, SIGNAL(EditText())); |
||
1462 | if (Doc->ActPage->PageNam == "") |
||
1463 | { |
||
1464 | int pxb = pmenPDF->insertItem( tr("Is PDF &Bookmark"), this, SLOT(ToggleBookmark())); |
||
1465 | pmenPDF->setItemChecked(pxb, b->isBookmark); |
||
1466 | pxb = pmenPDF->insertItem( tr("Is PDF A&nnotation"), this, SLOT(ToggleAnnotation())); |
||
1467 | pmenPDF->setItemChecked(pxb, b->isAnnotation); |
||
1468 | if (b->isAnnotation) |
||
1469 | { |
||
1470 | if ((b->AnType == 0) || (b->AnType == 1) || (b->AnType > 9)) |
||
1471 | pmenPDF->insertItem( tr("Annotation P&roperties"), this, SIGNAL(AnnotProps())); |
||
1472 | else |
||
1473 | pmenPDF->insertItem( tr("Field P&roperties"), this, SIGNAL(AnnotProps())); |
||
1474 | } |
||
1475 | } |
||
1476 | pmen->insertItem( tr("&PDF Options"), pmenPDF); |
||
1477 | } |
||
1478 | if (b->PType == 8) |
||
1479 | pmen->insertItem( tr("Edit Text..."), this, SIGNAL(EditText())); |
||
1480 | if (!b->Locked) |
||
1481 | pmen->insertItem( tr("&Lock"), this, SLOT(ToggleLock())); |
||
1482 | else |
||
1483 | pmen->insertItem( tr("Un&lock"), this, SLOT(ToggleLock())); |
||
1484 | if (!b->LockRes) |
||
1485 | pmen->insertItem( tr("Lock Object &Size"), this, SLOT(ToggleResize())); |
||
1486 | else |
||
1487 | pmen->insertItem( tr("Unlock Object &Size"), this, SLOT(ToggleResize())); |
||
1488 | if (!b->isSingleSel) |
||
1489 | { |
||
1490 | pmen->insertItem( tr("Send to S&crapbook"), this, SLOT(sentToScrap())); |
||
1491 | if (Doc->Layers.count() > 1) |
||
1492 | { |
||
1493 | for (uint lam=0; lam < Doc->Layers.count(); ++lam) |
||
1494 | { |
||
1495 | int lai = pmen3->insertItem(Doc->Layers[lam].Name); |
||
1496 | if (static_cast<int>(lam) == Doc->ActiveLayer) |
||
1497 | pmen3->setItemEnabled(lai, 0); |
||
1498 | } |
||
1499 | pmen->insertItem( tr("Send to La&yer"), pmen3); |
||
1500 | } |
||
1501 | connect(pmen3, SIGNAL(activated(int)), this, SLOT(sentToLayer(int))); |
||
1502 | } |
||
1503 | if (b->PType == 4) |
||
1504 | pmen->insertItem( tr("&Insert Sample Text"), this, SLOT(LoremIpsum())); |
||
1505 | if (!b->Locked) |
||
1506 | { |
||
1507 | if (SelItem.count() > 1) |
||
1508 | { |
||
1509 | bool isGroup = true; |
||
1510 | int firstElem = -1; |
||
1511 | if (b->Groups.count() != 0) |
||
1512 | firstElem = b->Groups.top(); |
||
1513 | for (uint bx = 0; bx < SelItem.count(); ++bx) |
||
1514 | { |
||
1515 | if (SelItem.at(bx)->Groups.count() != 0) |
||
1516 | { |
||
1517 | if (SelItem.at(bx)->Groups.top() != firstElem) |
||
1518 | isGroup = false; |
||
1519 | } |
||
1520 | else |
||
1521 | isGroup = false; |
||
1522 | } |
||
1523 | if (!isGroup) |
||
1524 | pmen->insertItem( tr("&Group"), this, SIGNAL(DoGroup())); |
||
1525 | } |
||
1526 | if (b->Groups.count() != 0) |
||
1527 | pmen->insertItem( tr("Un&group"), this, SIGNAL(DoUnGroup())); |
||
1528 | if ((!b->isTableItem) && (!b->isSingleSel)) |
||
1529 | { |
||
1530 | pmen->insertItem( tr("Le&vel"), pmenLevel); |
||
1531 | pmenLevel->insertItem( tr("Send to &Back"), this, SLOT(ToBack())); |
||
1532 | pmenLevel->insertItem( tr("Bring to &Front"), this, SLOT(ToFront())); |
||
1533 | pmenLevel->insertItem( tr("&Lower"), this, SLOT(LowerItem())); |
||
1534 | pmenLevel->insertItem( tr("&Raise"), this, SLOT(RaiseItem())); |
||
1535 | } |
||
1536 | } |
||
1537 | if (((b->PType == 4) || (b->PType == 2) || (b->PType == 6)) && (Doc->AppMode != 7)) |
||
1538 | { |
||
1539 | if (b->PType == 4) |
||
1540 | { |
||
1541 | pmen2->insertItem( tr("&Picture Frame"), this, SLOT(ToPicFrame())); |
||
1542 | if (!b->isTableItem) |
||
1543 | { |
||
1544 | pmen2->insertItem( tr("Pol&ygon"), this, SLOT(ToPolyFrame())); |
||
1545 | pmen2->insertItem( tr("&Outlines"), this, SLOT(TextToPath())); |
||
1546 | } |
||
1547 | } |
||
1548 | if (b->PType == 2) |
||
1549 | { |
||
1550 | pmen2->insertItem( tr("&Text Frame"), this, SLOT(ToTextFrame())); |
||
1551 | if (!b->isTableItem) |
||
1552 | pmen2->insertItem( tr("Pol&ygon"), this, SLOT(ToPolyFrame())); |
||
1553 | } |
||
1554 | if (b->PType == 6) |
||
1555 | { |
||
1556 | pmen2->insertItem( tr("&Text Frame"), this, SLOT(ToTextFrame())); |
||
1557 | pmen2->insertItem( tr("&Picture Frame"), this, SLOT(ToPicFrame())); |
||
1558 | pmen2->insertItem( tr("&Bezier Curve"), this, SLOT(ToBezierFrame())); |
||
1559 | } |
||
1560 | pmen->insertItem( tr("Conve&rt to"), pmen2); |
||
1561 | } |
||
1562 | pmen->insertSeparator(); |
||
1563 | if ((!b->Locked) && (!((b->isTableItem) && (b->isSingleSel)))) |
||
1564 | pmen->insertItem( tr("Cu&t"), this, SIGNAL(CutItem())); |
||
1565 | if (!((b->isTableItem) && (b->isSingleSel))) |
||
1566 | pmen->insertItem( tr("&Copy"), this, SIGNAL(CopyItem())); |
||
1567 | if ((Doc->AppMode == 7) && (ScApp->Buffer2.startsWith("<SCRIBUSTEXT")) && (b->PType == 4)) |
||
1568 | pmen->insertItem( tr("&Paste"), ScApp, SLOT(slotEditPaste())); |
||
1569 | if ((!b->Locked) && (Doc->AppMode != 7) && (!((b->isTableItem) && (b->isSingleSel)))) |
||
1570 | pmen->insertItem( tr("&Delete"), this, SLOT(DeleteItem())); |
||
1571 | if ((b->PType == 2) || (b->PType == 4)) |
||
1572 | pmen->insertItem( tr("C&lear Contents"), this, SLOT(ClearItem())); |
||
1573 | pmen->insertSeparator(); |
||
1574 | if (!ScApp->Mpal->isVisible()) |
||
1575 | pmen->insertItem( tr("Show P&roperties..."), ScApp, SLOT(ToggleMpal())); |
||
1576 | else |
||
1577 | pmen->insertItem( tr("Hide P&roperties..."), ScApp, SLOT(ToggleMpal())); |
||
1578 | pmen->exec(QCursor::pos()); |
||
1579 | delete pmen; |
||
1580 | delete pmen2; |
||
1581 | disconnect(pmen3, SIGNAL(activated(int)), this, SLOT(sentToLayer(int))); |
||
1582 | delete pmen3; |
||
1583 | delete pmen4; |
||
1584 | delete pmenLevel; |
||
1585 | delete pmenPDF; |
||
1586 | } |
||
1587 | if (Doc->AppMode == 10) |
||
1588 | { |
||
1589 | updateContents(); |
||
1590 | if (Doc->ElemToLink != 0) |
||
1591 | return; |
||
1592 | } |
||
1593 | if (Doc->AppMode == 12) |
||
1594 | { |
||
1595 | b = SelItem.at(0); |
||
1596 | FPoint np1 = FPoint(m->x() / Scale, m->y() / Scale); |
||
1597 | np1 = ApplyGridF(np1); |
||
1598 | b->Width = np1.x() - b->Xpos; |
||
1599 | b->Height = np1.y()- b->Ypos; |
||
1600 | FPointArray cli = RegularPolygonF(b->Width, b->Height, PolyC, PolyS, PolyF, PolyR); |
||
1601 | FPoint np = FPoint(cli.point(0)); |
||
1602 | b->PoLine.resize(2); |
||
1603 | b->PoLine.setPoint(0, np); |
||
1604 | b->PoLine.setPoint(1, np); |
||
1605 | for (uint ax = 1; ax < cli.size(); ++ax) |
||
1606 | { |
||
1607 | np = FPoint(cli.point(ax)); |
||
1608 | b->PoLine.putPoints(b->PoLine.size(), 4, np.x(), np.y(), np.x(), np.y(), np.x(), np.y(), np.x(), np.y()); |
||
1609 | } |
||
1610 | np = FPoint(cli.point(0)); |
||
1611 | b->PoLine.putPoints(b->PoLine.size(), 2, np.x(), np.y(), np.x(), np.y()); |
||
1612 | FPoint tp2 = GetMinClipF(b->PoLine); |
||
1613 | if ((tp2.x() > -1) || (tp2.y() > -1)) |
||
1614 | { |
||
1615 | SizeItem(b->Width - tp2.x(), b->Height - tp2.y(), b->ItemNr, false, false, false); |
||
1616 | } |
||
1617 | FPoint tp = GetMaxClipF(b->PoLine); |
||
1618 | SizeItem(tp.x(), tp.y(), b->ItemNr, false, false, false); |
||
1619 | b->Clip = FlattenPath(b->PoLine, b->Segments); |
||
1620 | AdjustItemSize(b); |
||
1621 | b->ContourLine = b->PoLine.copy(); |
||
1622 | updateContents(); |
||
1623 | } |
||
1624 | if (Doc->AppMode == 8) |
||
1625 | { |
||
1626 | b = SelItem.at(0); |
||
1627 | QPainter p; |
||
1628 | p.begin(viewport()); |
||
1629 | Transform(b, &p); |
||
1630 | QPoint np = p.xFormDev(m->pos()); |
||
1631 | p.end(); |
||
1632 | np = ApplyGrid(np); |
||
1633 | b->Rot = xy2Deg(np.x(), np.y()); |
||
1634 | b->Width = sqrt(pow(np.x(),2)+pow(np.y(),2)); |
||
1635 | b->Height = 0; |
||
1636 | b->Sizing = false; |
||
1637 | UpdateClip(b); |
||
1638 | updateContents(); |
||
1639 | } |
||
1640 | if (GetItem(&b)) |
||
1641 | { |
||
1642 | if (GroupSel) |
||
1643 | { |
||
1644 | if (mCG) |
||
1645 | { |
||
1646 | double gx, gy, gh, gw, nx, ny, scx, scy; |
||
1647 | getGroupRect(&gx, &gy, &gw, &gh); |
||
1648 | double sc = Scale; |
||
1649 | QPoint np2 = QPoint(static_cast<int>(m->x()/sc), static_cast<int>(m->y()/sc)); |
||
1650 | nx = np2.x(); |
||
1651 | ny = np2.y(); |
||
1652 | if (!ApplyGuides(&nx, &ny)) |
||
1653 | { |
||
1654 | np2 = ApplyGrid(np2); |
||
1655 | nx = np2.x(); |
||
1656 | ny = np2.y(); |
||
1657 | } |
||
1658 | switch (HowTo) |
||
1659 | { |
||
1660 | case 1: |
||
1661 | scx = fabs(nx-gx) / gw; |
||
1662 | scy = fabs(ny-gy) / gh; |
||
1663 | break; |
||
1664 | case 2: |
||
1665 | scx = fabs(nx-(gx+gw)) / gw; |
||
1666 | scy = fabs(ny-(gy+gh)) / gh; |
||
1667 | break; |
||
1668 | case 3: |
||
1669 | scx = fabs(nx-gx) / gw; |
||
1670 | scy = fabs(ny-(gy+gh)) / gh; |
||
1671 | break; |
||
1672 | case 4: |
||
1673 | scx = fabs(nx-(gx+gw)) / gw; |
||
1674 | scy = fabs(ny-gy) / gh; |
||
1675 | break; |
||
1676 | case 5: |
||
1677 | scx = 1.0; |
||
1678 | scy = fabs(ny-gy) / gh; |
||
1679 | break; |
||
1680 | case 6: |
||
1681 | scx = fabs(nx-gx) / gw; |
||
1682 | scy = 1.0; |
||
1683 | break; |
||
1684 | case 7: |
||
1685 | scx = fabs(nx-(gx+gw)) / gw; |
||
1686 | scy = 1.0; |
||
1687 | break; |
||
1688 | case 8: |
||
1689 | scx = 1.0; |
||
1690 | scy = fabs(ny-(gy+gh)) / gh; |
||
1691 | break; |
||
1692 | } |
||
1693 | RotMode = Doc->RotMode; |
||
1694 | Doc->RotMode = 0; |
||
1695 | scaleGroup(scx, scy); |
||
1696 | if ((HowTo == 3) || (HowTo == 8)) |
||
1697 | moveGroup(0, ny-gy); |
||
1698 | if (HowTo == 2) |
||
1699 | moveGroup(nx-gx, ny-gy); |
||
1700 | if ((HowTo == 7) || (HowTo == 4)) |
||
1701 | moveGroup(nx-gx, 0); |
||
1702 | Doc->RotMode = RotMode; |
||
1703 | updateContents(); |
||
1704 | emit DocChanged(); |
||
1705 | } |
||
1706 | } |
||
1707 | else |
||
1708 | { |
||
1709 | if (b->Sizing) |
||
1710 | { |
||
1711 | FPoint npx; |
||
1712 | double nx = m->pos().x()/Scale; |
||
1713 | double ny = m->pos().y()/Scale; |
||
1714 | if (Doc->SnapGuides) |
||
1715 | { |
||
1716 | ApplyGuides(&nx, &ny); |
||
1717 | npx = transformPointI(FPoint(nx, ny), b->Xpos, b->Ypos, b->Rot, 1, 1); |
||
1718 | } |
||
1719 | else |
||
1720 | npx = ApplyGridF(transformPointI(FPoint(nx, ny), b->Xpos, b->Ypos, b->Rot, 1, 1)); |
||
1721 | if ((HowTo == 1) && (b->PType != 5) && (Doc->SnapGuides)) |
||
1722 | SizeItem(npx.x(), npx.y(), b->ItemNr); |
||
1723 | bool sav = Doc->SnapGuides; |
||
1724 | Doc->SnapGuides = false; |
||
1725 | switch (HowTo) |
||
1726 | { |
||
1727 | case 1: |
||
1728 | if (b->PType != 5) |
||
1729 | { |
||
1730 | if (b->isTableItem) |
||
1731 | { |
||
1732 | double dist; |
||
1733 | if (b->LeftLink != 0) |
||
1734 | dist = npx.y() - b->LeftLink->Height; |
||
1735 | else if (b->RightLink != 0) |
||
1736 | dist = npx.y() - b->RightLink->Height; |
||
1737 | else |
||
1738 | dist = npx.y() - b->Height; |
||
1739 | PageItem* bb2; |
||
1740 | PageItem* bb = b; |
||
1741 | while (bb->LeftLink != 0) |
||
1742 | { |
||
1743 | bb = bb->LeftLink; |
||
1744 | } |
||
1745 | while (bb->RightLink != 0) |
||
1746 | { |
||
1747 | bb2 = bb; |
||
1748 | while (bb2->BottomLink != 0) |
||
1749 | { |
||
1750 | MoveRotated(bb2->BottomLink, FPoint(0, dist)); |
||
1751 | bb2 = bb2->BottomLink; |
||
1752 | } |
||
1753 | if (bb != b) |
||
1754 | MoveSizeItem(FPoint(0, 0), FPoint(0, -dist), bb->ItemNr); |
||
1755 | bb = bb->RightLink; |
||
1756 | } |
||
1757 | bb2 = bb; |
||
1758 | while (bb2->BottomLink != 0) |
||
1759 | { |
||
1760 | MoveRotated(bb2->BottomLink, FPoint(0, dist)); |
||
1761 | bb2 = bb2->BottomLink; |
||
1762 | } |
||
1763 | if (bb != b) |
||
1764 | MoveSizeItem(FPoint(0, 0), FPoint(0, -dist), bb->ItemNr); |
||
1765 | bb = b; |
||
1766 | if (b->TopLink != 0) |
||
1767 | dist = npx.x() - b->TopLink->Width; |
||
1768 | else if (b->BottomLink != 0) |
||
1769 | dist = npx.x() - b->BottomLink->Width; |
||
1770 | else |
||
1771 | dist = npx.x() - b->Width; |
||
1772 | while (bb->TopLink != 0) |
||
1773 | { |
||
1774 | bb = bb->TopLink; |
||
1775 | } |
||
1776 | while (bb->BottomLink != 0) |
||
1777 | { |
||
1778 | bb2 = bb; |
||
1779 | while (bb2->RightLink != 0) |
||
1780 | { |
||
1781 | MoveRotated(bb2->RightLink, FPoint(dist, 0)); |
||
1782 | bb2 = bb2->RightLink; |
||
1783 | } |
||
1784 | if (bb != b) |
||
1785 | MoveSizeItem(FPoint(0, 0), FPoint(-dist, 0), bb->ItemNr); |
||
1786 | bb = bb->BottomLink; |
||
1787 | } |
||
1788 | bb2 = bb; |
||
1789 | while (bb2->RightLink != 0) |
||
1790 | { |
||
1791 | MoveRotated(bb2->RightLink, FPoint(dist, 0)); |
||
1792 | bb2 = bb2->RightLink; |
||
1793 | } |
||
1794 | if (bb != b) |
||
1795 | MoveSizeItem(FPoint(0, 0), FPoint(-dist, 0), bb->ItemNr); |
||
1796 | } |
||
1797 | if (b->flippedH % 2 != 0) |
||
1798 | MoveItemI(-(b->Width - b->OldB2)/b->LocalScX, 0, b->ItemNr); |
||
1799 | if (b->flippedV % 2 != 0) |
||
1800 | MoveItemI(0, -(b->Height - b->OldH2)/b->LocalScY, b->ItemNr); |
||
1801 | } |
||
1802 | else |
||
1803 | { |
||
1804 | if (sav) |
||
1805 | { |
||
1806 | double nx = m->pos().x()/Scale; |
||
1807 | double ny = m->pos().y()/Scale; |
||
1808 | if (Doc->useRaster) |
||
1809 | { |
||
1810 | FPoint ra = ApplyGridF(FPoint(nx, ny)); |
||
1811 | nx = ra.x(); |
||
1812 | ny = ra.y(); |
||
1813 | } |
||
1814 | Doc->SnapGuides = sav; |
||
1815 | ApplyGuides(&nx, &ny); |
||
1816 | Doc->SnapGuides = false; |
||
1817 | double r = atan2(ny - b->Ypos, nx - b->Xpos)*(180.0/3.1415927); |
||
1818 | RotateItem(r, b->ItemNr); |
||
1819 | double w = sqrt(pow(nx - b->Xpos, 2) + pow(ny - b->Ypos,2)); |
||
1820 | SizeItem(w, b->Height, b->ItemNr, true); |
||
1821 | } |
||
1822 | } |
||
1823 | b->Sizing = false; |
||
1824 | break; |
||
1825 | case 2: |
||
1826 | if (b->PType != 5) |
||
1827 | { |
||
1828 | if (b->isTableItem) |
||
1829 | { |
||
1830 | PageItem* bb2; |
||
1831 | PageItem* bb = b; |
||
1832 | while (bb->TopLink != 0) |
||
1833 | { |
||
1834 | bb = bb->TopLink; |
||
1835 | } |
||
1836 | while (bb->BottomLink != 0) |
||
1837 | { |
||
1838 | bb2 = bb; |
||
1839 | while (bb2->LeftLink != 0) |
||
1840 | { |
||
1841 | MoveRotated(bb2->LeftLink, FPoint(npx.x(), 0)); |
||
1842 | bb2 = bb2->LeftLink; |
||
1843 | } |
||
1844 | MoveSizeItem(FPoint(npx.x(), 0), FPoint(npx.x(), 0), bb->ItemNr); |
||
1845 | bb = bb->BottomLink; |
||
1846 | } |
||
1847 | bb2 = bb; |
||
1848 | while (bb2->LeftLink != 0) |
||
1849 | { |
||
1850 | MoveRotated(bb2->LeftLink, FPoint(npx.x(), 0)); |
||
1851 | bb2 = bb2->LeftLink; |
||
1852 | } |
||
1853 | MoveSizeItem(FPoint(npx.x(), 0), FPoint(npx.x(), 0), bb->ItemNr); |
||
1854 | bb = b; |
||
1855 | while (bb->LeftLink != 0) |
||
1856 | { |
||
1857 | bb = bb->LeftLink; |
||
1858 | } |
||
1859 | while (bb->RightLink != 0) |
||
1860 | { |
||
1861 | bb2 = bb; |
||
1862 | while (bb2->TopLink != 0) |
||
1863 | { |
||
1864 | MoveRotated(bb2->TopLink, FPoint(0, npx.y())); |
||
1865 | bb2 = bb2->TopLink; |
||
1866 | } |
||
1867 | MoveSizeItem(FPoint(0, npx.y()), FPoint(0, npx.y()), bb->ItemNr); |
||
1868 | bb = bb->RightLink; |
||
1869 | } |
||
1870 | bb2 = bb; |
||
1871 | while (bb2->TopLink != 0) |
||
1872 | { |
||
1873 | MoveRotated(bb2->TopLink, FPoint(0, npx.y())); |
||
1874 | bb2 = bb2->TopLink; |
||
1875 | } |
||
1876 | MoveSizeItem(FPoint(0, npx.y()), FPoint(0, npx.y()), bb->ItemNr); |
||
1877 | } |
||
1878 | else |
||
1879 | MoveSizeItem(npx, npx, b->ItemNr); |
||
1880 | b->Sizing = false; |
||
1881 | if (b->flippedH % 2 == 0) |
||
1882 | MoveItemI((b->Width - b->OldB2)/b->LocalScX, 0, b->ItemNr); |
||
1883 | if (b->flippedV % 2 == 0) |
||
1884 | MoveItemI(0, (b->Height - b->OldH2)/b->LocalScY, b->ItemNr); |
||
1885 | } |
||
1886 | else |
||
1887 | { |
||
1888 | if (sav) |
||
1889 | { |
||
1890 | double nx = m->pos().x()/Scale; |
||
1891 | double ny = m->pos().y()/Scale; |
||
1892 | if (Doc->useRaster) |
||
1893 | { |
||
1894 | FPoint ra = ApplyGridF(FPoint(nx, ny)); |
||
1895 | nx = ra.x(); |
||
1896 | ny = ra.y(); |
||
1897 | } |
||
1898 | Doc->SnapGuides = sav; |
||
1899 | ApplyGuides(&nx, &ny); |
||
1900 | Doc->SnapGuides = false; |
||
1901 | QWMatrix ma; |
||
1902 | ma.translate(b->Xpos, b->Ypos); |
||
1903 | ma.rotate(b->Rot); |
||
1904 | double mx = ma.m11() * b->Width + ma.m21() * b->Height + ma.dx(); |
||
1905 | double my = ma.m22() * b->Height + ma.m12() * b->Width + ma.dy(); |
||
1906 | double r = atan2(my-ny,mx-nx)*(180.0/3.1415927); |
||
1907 | double w = sqrt(pow(mx-nx,2)+pow(my-ny,2)); |
||
1908 | MoveItem(nx - b->Xpos, ny - b->Ypos, b, true); |
||
1909 | SizeItem(w, b->Height, b->ItemNr, true); |
||
1910 | RotateItem(r, b->ItemNr); |
||
1911 | b->Sizing = false; |
||
1912 | } |
||
1913 | } |
||
1914 | break; |
||
1915 | case 3: |
||
1916 | if (b->isTableItem) |
||
1917 | { |
||
1918 | double dist = npx.x() - b->Width; |
||
1919 | PageItem* bb2; |
||
1920 | PageItem* bb = b; |
||
1921 | while (bb->TopLink != 0) |
||
1922 | { |
||
1923 | bb = bb->TopLink; |
||
1924 | } |
||
1925 | while (bb->BottomLink != 0) |
||
1926 | { |
||
1927 | bb2 = bb; |
||
1928 | while (bb2->RightLink != 0) |
||
1929 | { |
||
1930 | MoveRotated(bb2->RightLink, FPoint(dist, 0)); |
||
1931 | bb2 = bb2->RightLink; |
||
1932 | } |
||
1933 | MoveSizeItem(FPoint(0, 0), FPoint(-dist, 0), bb->ItemNr); |
||
1934 | bb = bb->BottomLink; |
||
1935 | } |
||
1936 | bb2 = bb; |
||
1937 | while (bb2->RightLink != 0) |
||
1938 | { |
||
1939 | MoveRotated(bb2->RightLink, FPoint(dist, 0)); |
||
1940 | bb2 = bb2->RightLink; |
||
1941 | } |
||
1942 | MoveSizeItem(FPoint(0, 0), FPoint(-dist, 0), bb->ItemNr); |
||
1943 | bb = b; |
||
1944 | while (bb->LeftLink != 0) |
||
1945 | { |
||
1946 | bb = bb->LeftLink; |
||
1947 | } |
||
1948 | while (bb->RightLink != 0) |
||
1949 | { |
||
1950 | bb2 = bb; |
||
1951 | while (bb2->TopLink != 0) |
||
1952 | { |
||
1953 | MoveRotated(bb2->TopLink, FPoint(0, npx.y())); |
||
1954 | bb2 = bb2->TopLink; |
||
1955 | } |
||
1956 | MoveSizeItem(FPoint(0, npx.y()), FPoint(0, npx.y()), bb->ItemNr); |
||
1957 | bb = bb->RightLink; |
||
1958 | } |
||
1959 | bb2 = bb; |
||
1960 | while (bb2->TopLink != 0) |
||
1961 | { |
||
1962 | MoveRotated(bb2->TopLink, FPoint(0, npx.y())); |
||
1963 | bb2 = bb2->TopLink; |
||
1964 | } |
||
1965 | MoveSizeItem(FPoint(0, npx.y()), FPoint(0, npx.y()), bb->ItemNr); |
||
1966 | } |
||
1967 | else |
||
1968 | MoveSizeItem(FPoint(0, npx.y()), FPoint(b->Width - npx.x(), npx.y()), b->ItemNr); |
||
1969 | b->Sizing = false; |
||
1970 | if (b->flippedH % 2 != 0) |
||
1971 | MoveItemI(-(b->Width - b->OldB2)/b->LocalScX, 0, b->ItemNr); |
||
1972 | if (b->flippedV % 2 == 0) |
||
1973 | MoveItemI(0, (b->Height - b->OldH2)/b->LocalScY, b->ItemNr); |
||
1974 | break; |
||
1975 | case 4: |
||
1976 | if (b->isTableItem) |
||
1977 | { |
||
1978 | double dist = npx.y() - b->Height; |
||
1979 | PageItem* bb2; |
||
1980 | PageItem* bb = b; |
||
1981 | while (bb->LeftLink != 0) |
||
1982 | { |
||
1983 | bb = bb->LeftLink; |
||
1984 | } |
||
1985 | while (bb->RightLink != 0) |
||