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