Rev 4451 | Rev 4473 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4430 | cbradney | 1 | /* |
2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
||
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
3 | paul | 7 | /*************************************************************************** |
8 | scribusview.cpp - description |
||
9 | ------------------- |
||
10 | begin : Fre Apr 6 21:47:55 CEST 2001 |
||
11 | copyright : (C) 2001 by Franz Schmid |
||
12 | email : Franz.Schmid@altmuehlnet.de |
||
13 | ***************************************************************************/ |
||
14 | |||
15 | /*************************************************************************** |
||
16 | * * |
||
17 | * This program is free software; you can redistribute it and/or modify * |
||
18 | * it under the terms of the GNU General Public License as published by * |
||
19 | * the Free Software Foundation; either version 2 of the License, or * |
||
20 | * (at your option) any later version. * |
||
21 | * * |
||
22 | ***************************************************************************/ |
||
23 | |||
24 | #include "scribusview.h" |
||
25 | #include "scribusview.moc" |
||
128 | Franz | 26 | |
2688 | craig | 27 | #include "scconfig.h" |
128 | Franz | 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> |
||
1525 | cbradney | 35 | #include <qdragobject.h> |
3 | paul | 36 | #include <qimage.h> |
37 | #include <qcstring.h> |
||
173 | Franz | 38 | #include <qfileinfo.h> |
456 | fschmid | 39 | #include <qfile.h> |
307 | Franz | 40 | #include <cmath> |
456 | fschmid | 41 | #include <cstdio> |
42 | #include <cstdlib> |
||
2702 | craig | 43 | |
44 | #ifdef HAVE_UNISTD_H |
||
456 | fschmid | 45 | #include <unistd.h> |
2702 | craig | 46 | #endif |
47 | |||
456 | fschmid | 48 | #include <qcursor.h> |
49 | #include <qurl.h> |
||
50 | #include <qdir.h> |
||
51 | #include <qevent.h> |
||
2880 | fschmid | 52 | #include <qsizegrip.h> |
456 | fschmid | 53 | #if QT_VERSION > 0x030102 |
54 | #define SPLITVC SplitHCursor |
||
55 | #define SPLITHC SplitVCursor |
||
56 | #else |
||
57 | #define SPLITVC SplitVCursor |
||
58 | #define SPLITHC SplitHCursor |
||
59 | #endif |
||
181 | Franz | 60 | #include "scribus.h" |
1427 | fschmid | 61 | #include "tree.h" |
456 | fschmid | 62 | #include "mpalette.h" |
63 | #include "scribusXml.h" |
||
3903 | cbradney | 64 | #include "selection.h" |
456 | fschmid | 65 | #include "serializer.h" |
66 | #include "insertTable.h" |
||
838 | cbradney | 67 | #include "hruler.h" |
68 | #include "vruler.h" |
||
1151 | fschmid | 69 | #include "filewatcher.h" |
1226 | tsoots | 70 | #include "undomanager.h" |
1525 | cbradney | 71 | #include "units.h" |
1633 | fschmid | 72 | #include "extimageprops.h" |
3695 | cbradney | 73 | #include "page.h" |
1655 | cbradney | 74 | #include "pageitemattributes.h" |
3625 | avox | 75 | #include "pageitem_imageframe.h" |
76 | #include "pageitem_line.h" |
||
77 | #include "pageitem_pathtext.h" |
||
78 | #include "pageitem_polygon.h" |
||
79 | #include "pageitem_polyline.h" |
||
80 | #include "pageitem_textframe.h" |
||
3053 | avox | 81 | #include "pageselector.h" |
1693 | craig | 82 | #include "scpaths.h" |
2103 | cbradney | 83 | #include "actionmanager.h" |
456 | fschmid | 84 | #ifdef HAVE_TIFF |
85 | #include <tiffio.h> |
||
86 | #endif |
||
87 | #ifdef HAVE_CMS |
||
88 | #include CMS_INC |
||
89 | #endif |
||
68 | Franz | 90 | |
2529 | craig | 91 | #include "scfontmetrics.h" |
3942 | cbradney | 92 | #include "scmessagebox.h" |
2529 | craig | 93 | #include "util.h" |
2495 | cbradney | 94 | #include "story.h" |
2834 | cbradney | 95 | #include "prefsmanager.h" |
2868 | fschmid | 96 | #include "rulermover.h" |
3252 | craig | 97 | #include "hyphenator.h" |
3510 | cbradney | 98 | #include "commonstrings.h" |
2495 | cbradney | 99 | |
504 | cbradney | 100 | using namespace std; |
101 | |||
3 | paul | 102 | |
3205 | craig | 103 | |
3981 | craig | 104 | ScribusView::ScribusView(QWidget *parent, ScribusDoc *doc) : |
105 | QScrollView(parent, "s", WRepaintNoErase | WNorthWestGravity), |
||
106 | Doc(doc), |
||
107 | Prefs(&(PrefsManager::instance()->appPrefs)), |
||
3982 | craig | 108 | undoManager(UndoManager::instance()), |
109 | OldScale(0), |
||
110 | GroupX(0), GroupY(0), GroupW(0), GroupH(0), |
||
111 | oldW(-1), oldCp(-1), |
||
112 | Mxp(-1), Myp(-1), Dxp(-1), Dyp(-1), |
||
113 | HowTo(-1), |
||
114 | SeRx(-1), SeRy(-1), GyM(-1), GxM(-1), |
||
115 | ClRe(-1), ClRe2(-1), |
||
116 | SegP1(-1), SegP2(-1), |
||
117 | RotMode(0), |
||
118 | DrHY(-1), DrVX(-1), |
||
119 | EdPoints(true), |
||
120 | Mpressed(false), |
||
121 | Imoved(false), |
||
122 | MoveGY(false), MoveGX(false), |
||
123 | HaveSelRect(false), |
||
124 | mCG(false), |
||
125 | EditContour(false), |
||
4049 | cbradney | 126 | //GroupSel(false), |
3982 | craig | 127 | DraggedGroup(false), |
128 | DraggedGroupFirst(false), |
||
129 | HanMove(false), |
||
130 | MidButt(false), |
||
131 | updateOn(true), |
||
132 | FirstPoly(true), |
||
133 | Magnify(false), |
||
134 | MoveSym(false), |
||
135 | CursVis(false), |
||
136 | previewMode(false), |
||
137 | RCenter(-1,-1), |
||
138 | RecordP(), |
||
139 | Ready(false), |
||
140 | oldX(0), oldY(0), |
||
141 | _groupTransactionStarted(false), |
||
142 | _isGlobalMode(true), |
||
143 | evSpon(false), |
||
144 | forceRedraw(false), |
||
145 | Scale(Prefs->DisScale) |
||
3 | paul | 146 | { |
147 | setHScrollBarMode(QScrollView::AlwaysOn); |
||
148 | setVScrollBarMode(QScrollView::AlwaysOn); |
||
2892 | fschmid | 149 | setMargins(17, 17, 0, 0); |
3 | paul | 150 | setResizePolicy(Manual); |
240 | Franz | 151 | viewport()->setBackgroundMode(PaletteBackground); |
3 | paul | 152 | QFont fo = QFont(font()); |
2887 | fschmid | 153 | int posi = fo.pointSize()-2; |
154 | fo.setPointSize(posi); |
||
3689 | cbradney | 155 | unitSwitcher = new QComboBox( false, this, "unitSwitcher" ); |
2887 | fschmid | 156 | unitSwitcher->setFocusPolicy(QWidget::NoFocus); |
157 | unitSwitcher->setFont(fo); |
||
2966 | fschmid | 158 | for (int i=0;i<=unitGetMaxIndex();++i) |
159 | unitSwitcher->insertItem(unitGetStrFromIndex(i)); |
||
3309 | cbradney | 160 | zoomSpinBox = new MSpinBox( 10, 3200, this, 2 ); |
161 | zoomSpinBox->setFont(fo); |
||
162 | zoomSpinBox->setValue( 100 ); |
||
163 | zoomSpinBox->setFocusPolicy(QWidget::ClickFocus); |
||
164 | zoomSpinBox->setSuffix( tr( " %" ) ); |
||
3053 | avox | 165 | #if OPTION_USE_QTOOLBUTTON |
166 | zoomOutToolbarButton = new QToolButton(this); |
||
3274 | fschmid | 167 | zoomDefaultToolbarButton = new QToolButton(this); |
3053 | avox | 168 | zoomInToolbarButton = new QToolButton(this); |
3274 | fschmid | 169 | zoomDefaultToolbarButton->setAutoRaise(OPTION_FLAT_BUTTON); |
3053 | avox | 170 | zoomOutToolbarButton->setAutoRaise(OPTION_FLAT_BUTTON); |
171 | zoomInToolbarButton->setAutoRaise(OPTION_FLAT_BUTTON); |
||
172 | #else |
||
3274 | fschmid | 173 | zoomDefaultToolbarButton = new QPushButton(this); |
174 | zoomDefaultToolbarButton->setFocusPolicy(QWidget::NoFocus); |
||
175 | zoomDefaultToolbarButton->setDefault( false ); |
||
176 | zoomDefaultToolbarButton->setAutoDefault( false ); |
||
177 | zoomDefaultToolbarButton->setFlat(OPTION_FLAT_BUTTON); |
||
1822 | cbradney | 178 | zoomOutToolbarButton = new QPushButton(this); |
179 | zoomOutToolbarButton->setFocusPolicy(QWidget::NoFocus); |
||
3053 | avox | 180 | zoomOutToolbarButton->setDefault( false ); |
181 | zoomOutToolbarButton->setAutoDefault( false ); |
||
182 | zoomOutToolbarButton->setFlat(OPTION_FLAT_BUTTON); |
||
3274 | fschmid | 183 | zoomInToolbarButton = new QPushButton(this); |
184 | zoomInToolbarButton->setFocusPolicy(QWidget::NoFocus); |
||
3053 | avox | 185 | zoomInToolbarButton->setDefault( false ); |
186 | zoomInToolbarButton->setAutoDefault( false ); |
||
187 | zoomInToolbarButton->setFlat(OPTION_FLAT_BUTTON); |
||
188 | #endif |
||
3296 | fschmid | 189 | zoomDefaultToolbarButton->setText("1:1"); |
190 | // zoomDefaultToolbarButton->setPixmap(loadIcon("viewmag1.png")); |
||
3274 | fschmid | 191 | zoomOutToolbarButton->setPixmap(loadIcon("viewmagout.png")); |
192 | zoomInToolbarButton->setPixmap(loadIcon("viewmagin.png")); |
||
3309 | cbradney | 193 | pageSelector = new PageSelector(this, 1); |
194 | pageSelector->setFont(fo); |
||
195 | pageSelector->setFocusPolicy(QWidget::ClickFocus); |
||
196 | layerMenu = new QComboBox( true, this, "LY" ); |
||
197 | layerMenu->setEditable(false); |
||
198 | layerMenu->setFont(fo); |
||
199 | layerMenu->setFocusPolicy(QWidget::NoFocus); |
||
1612 | cbradney | 200 | horizRuler = new Hruler(this, Doc); |
201 | vertRuler = new Vruler(this, Doc); |
||
3309 | cbradney | 202 | rulerMover = new RulerMover(this); |
203 | rulerMover->setFocusPolicy(QWidget::NoFocus); |
||
3 | paul | 204 | Ready = true; |
456 | fschmid | 205 | viewport()->setMouseTracking(true); |
206 | setAcceptDrops(true); |
||
207 | viewport()->setAcceptDrops(true); |
||
208 | setDragAutoScroll(false); |
||
3990 | cbradney | 209 | //languageChange(); |
456 | fschmid | 210 | Doc->DragP = false; |
211 | Doc->leaveDrag = false; |
||
1330 | fschmid | 212 | Doc->SubMode = -1; |
1822 | cbradney | 213 | connect(zoomOutToolbarButton, SIGNAL(clicked()), this, SLOT(slotZoomOut())); |
214 | connect(zoomInToolbarButton, SIGNAL(clicked()), this, SLOT(slotZoomIn())); |
||
3274 | fschmid | 215 | connect(zoomDefaultToolbarButton, SIGNAL(clicked()), this, SLOT(slotZoom100())); |
3309 | cbradney | 216 | connect(zoomSpinBox, SIGNAL(valueChanged(int)), this, SLOT(Zval())); |
217 | connect(pageSelector, SIGNAL(GotoPage(int)), this, SLOT(GotoPa(int))); |
||
218 | connect(layerMenu, SIGNAL(activated(int)), this, SLOT(GotoLa(int))); |
||
2966 | fschmid | 219 | connect(unitSwitcher, SIGNAL(activated(int)), this, SLOT(ChgUnit(int))); |
3 | paul | 220 | connect(this, SIGNAL(contentsMoving(int, int)), this, SLOT(setRulerPos(int, int))); |
1443 | tsoots | 221 | connect(this, SIGNAL(HaveSel(int)), this, SLOT(selectionChanged())); |
3 | paul | 222 | } |
223 | |||
2199 | cbradney | 224 | void ScribusView::languageChange() |
225 | { |
||
3309 | cbradney | 226 | disconnect(layerMenu, SIGNAL(activated(int)), this, SLOT(GotoLa(int))); |
2966 | fschmid | 227 | disconnect(unitSwitcher, SIGNAL(activated(int)), this, SLOT(ChgUnit(int))); |
3309 | cbradney | 228 | zoomSpinBox->setSuffix( tr( " %" ) ); |
229 | layerMenu->setCurrentText( tr("Layer")+" 0"); |
||
2199 | cbradney | 230 | //CB TODO Convert to actions later |
2966 | fschmid | 231 | unitSwitcher->clear(); |
2199 | cbradney | 232 | for (int i=0;i<=unitGetMaxIndex();++i) |
2966 | fschmid | 233 | unitSwitcher->insertItem(unitGetStrFromIndex(i)); |
234 | unitSwitcher->setCurrentText(unitGetStrFromIndex(Doc->unitIndex())); |
||
3309 | cbradney | 235 | connect(layerMenu, SIGNAL(activated(int)), this, SLOT(GotoLa(int))); |
2966 | fschmid | 236 | connect(unitSwitcher, SIGNAL(activated(int)), this, SLOT(ChgUnit(int))); |
2199 | cbradney | 237 | } |
238 | |||
2171 | fschmid | 239 | void ScribusView::viewportPaintEvent ( QPaintEvent * p ) |
240 | { |
||
4011 | cbradney | 241 | #ifndef _WIN32 |
2171 | fschmid | 242 | if (p->spontaneous()) |
243 | evSpon = true; |
||
4011 | cbradney | 244 | #endif |
2171 | fschmid | 245 | QScrollView::viewportPaintEvent(p); |
246 | } |
||
247 | |||
693 | fschmid | 248 | void ScribusView::drawContents(QPainter *, int clipx, int clipy, int clipw, int cliph) |
456 | fschmid | 249 | { |
2891 | cbradney | 250 | if (Doc->isLoading()) |
456 | fschmid | 251 | return; |
252 | if (!updateOn) |
||
253 | return; |
||
254 | // QTime tim; |
||
255 | // tim.start(); |
||
256 | if ((clipw > 0) && (cliph > 0)) |
||
257 | { |
||
3313 | cbradney | 258 | QPoint vr = contentsToViewport(QPoint(clipx, clipy)); |
1624 | fschmid | 259 | ScPainter *painter = new ScPainter(viewport(), clipw, cliph, vr.x(), vr.y()); |
456 | fschmid | 260 | painter->clear(paletteBackgroundColor()); |
2848 | fschmid | 261 | painter->translate(-Doc->minCanvasCoordinate.x()*Scale, -Doc->minCanvasCoordinate.y()*Scale); |
456 | fschmid | 262 | painter->translate(-clipx, -clipy); |
263 | painter->setLineWidth(1); |
||
264 | painter->setFillMode(ScPainter::Solid); |
||
2538 | fschmid | 265 | // painter->translate(0.5, 0.5); |
456 | fschmid | 266 | painter->setZoomFactor(1.0); |
267 | /* Draw Page Outlines */ |
||
3724 | cbradney | 268 | if (!Doc->masterPageMode()) |
456 | fschmid | 269 | { |
3724 | cbradney | 270 | uint docPagesCount=Doc->Pages->count(); |
3698 | cbradney | 271 | for (int a = 0; a < static_cast<int>(docPagesCount); ++a) |
456 | fschmid | 272 | { |
3724 | cbradney | 273 | int x = static_cast<int>(Doc->Pages->at(a)->xOffset() * Scale); |
274 | int y = static_cast<int>(Doc->Pages->at(a)->yOffset() * Scale); |
||
275 | int w = static_cast<int>(Doc->Pages->at(a)->width() * Scale); |
||
276 | int h = static_cast<int>(Doc->Pages->at(a)->height() * Scale); |
||
2848 | fschmid | 277 | QRect drawRect = QRect(x, y, w+5, h+5); |
278 | drawRect.moveBy(qRound(-Doc->minCanvasCoordinate.x() * Scale), qRound(-Doc->minCanvasCoordinate.y() * Scale)); |
||
279 | if (drawRect.intersects(QRect(clipx, clipy, clipw, cliph))) |
||
456 | fschmid | 280 | { |
281 | painter->setFillMode(ScPainter::Solid); |
||
282 | painter->setPen(black, 1, SolidLine, FlatCap, MiterJoin); |
||
283 | painter->setBrush(QColor(128,128,128)); |
||
284 | painter->drawRect(x+5, y+5, w, h); |
||
3689 | cbradney | 285 | if (a == Doc->currentPageNumber()) |
745 | fschmid | 286 | painter->setPen(red, 2, SolidLine, FlatCap, MiterJoin); |
287 | else |
||
288 | painter->setPen(black, 1, SolidLine, FlatCap, MiterJoin); |
||
456 | fschmid | 289 | painter->setBrush(Doc->papColor); |
290 | painter->drawRect(x, y, w, h); |
||
1187 | fschmid | 291 | if (Doc->guidesSettings.before) |
3724 | cbradney | 292 | DrawPageMarks(painter, Doc->Pages->at(a), QRect(clipx, clipy, clipw, cliph)); |
456 | fschmid | 293 | } |
3724 | cbradney | 294 | DrawMasterItems(painter, Doc->Pages->at(a), QRect(clipx, clipy, clipw, cliph)); |
456 | fschmid | 295 | } |
296 | DrawPageItems(painter, QRect(clipx, clipy, clipw, cliph)); |
||
1187 | fschmid | 297 | if (!Doc->guidesSettings.before) |
456 | fschmid | 298 | { |
3689 | cbradney | 299 | for (uint a = 0; a < docPagesCount; ++a) |
456 | fschmid | 300 | { |
3724 | cbradney | 301 | int x = static_cast<int>(Doc->Pages->at(a)->xOffset() * Scale); |
302 | int y = static_cast<int>(Doc->Pages->at(a)->yOffset() * Scale); |
||
303 | int w = static_cast<int>(Doc->Pages->at(a)->width() * Scale); |
||
304 | int h = static_cast<int>(Doc->Pages->at(a)->height() * Scale); |
||
2848 | fschmid | 305 | QRect drawRect = QRect(x, y, w+5, h+5); |
306 | drawRect.moveBy(qRound(-Doc->minCanvasCoordinate.x() * Scale), qRound(-Doc->minCanvasCoordinate.y() * Scale)); |
||
307 | if (drawRect.intersects(QRect(clipx, clipy, clipw, cliph))) |
||
3724 | cbradney | 308 | DrawPageMarks(painter, Doc->Pages->at(a), QRect(clipx, clipy, clipw, cliph)); |
456 | fschmid | 309 | } |
310 | } |
||
311 | } |
||
312 | else |
||
313 | { |
||
314 | int x = static_cast<int>(Doc->ScratchLeft * Scale); |
||
315 | int y = static_cast<int>(Doc->ScratchTop * Scale); |
||
3200 | cbradney | 316 | int w = static_cast<int>(Doc->currentPage->width() * Scale); |
317 | int h = static_cast<int>(Doc->currentPage->height() * Scale); |
||
2848 | fschmid | 318 | QRect drawRect = QRect(x, y, w+5, h+5); |
319 | drawRect.moveBy(qRound(-Doc->minCanvasCoordinate.x() * Scale), qRound(-Doc->minCanvasCoordinate.y() * Scale)); |
||
320 | if (drawRect.intersects(QRect(clipx, clipy, clipw, cliph))) |
||
456 | fschmid | 321 | { |
322 | painter->setFillMode(ScPainter::Solid); |
||
323 | painter->setPen(black, 1, SolidLine, FlatCap, MiterJoin); |
||
324 | painter->setBrush(QColor(128,128,128)); |
||
325 | painter->drawRect(x+5, y+5, w, h); |
||
326 | painter->setBrush(Doc->papColor); |
||
327 | painter->drawRect(x, y, w, h); |
||
1187 | fschmid | 328 | if (Doc->guidesSettings.before) |
1065 | cbradney | 329 | DrawPageMarks(painter, Doc->currentPage, QRect(clipx, clipy, clipw, cliph)); |
456 | fschmid | 330 | } |
331 | DrawPageItems(painter, QRect(clipx, clipy, clipw, cliph)); |
||
2848 | fschmid | 332 | if ((!Doc->guidesSettings.before) && (drawRect.intersects(QRect(clipx, clipy, clipw, cliph)))) |
1065 | cbradney | 333 | DrawPageMarks(painter, Doc->currentPage, QRect(clipx, clipy, clipw, cliph)); |
456 | fschmid | 334 | } |
3934 | cbradney | 335 | if ((Doc->selection->count() != 0) || (linkedFramesToShow.count() != 0)) |
456 | fschmid | 336 | { |
337 | double z = painter->zoomFactor(); |
||
338 | painter->setZoomFactor(Scale); |
||
339 | painter->save(); |
||
1957 | cbradney | 340 | PageItem *currItem; |
879 | fschmid | 341 | if ((Doc->guidesSettings.linkShown) && (linkedFramesToShow.count() != 0)) |
1957 | cbradney | 342 | currItem = linkedFramesToShow.at(0); |
705 | fschmid | 343 | else |
808 | fschmid | 344 | { |
345 | if (linkedFramesToShow.count() != 0) |
||
1957 | cbradney | 346 | currItem = linkedFramesToShow.at(0); |
808 | fschmid | 347 | else |
3934 | cbradney | 348 | currItem = Doc->selection->itemAt(0); |
808 | fschmid | 349 | } |
3594 | cbradney | 350 | //Draw the frame links |
2603 | cbradney | 351 | if ((((Doc->appMode == modeLinkFrames) || (Doc->appMode == modeUnlinkFrames)) |
1957 | cbradney | 352 | && (currItem->itemType() == PageItem::TextFrame)) || (Doc->guidesSettings.linkShown)) |
456 | fschmid | 353 | { |
1957 | cbradney | 354 | PageItem *nextItem = currItem; |
879 | fschmid | 355 | if (Doc->guidesSettings.linkShown) |
456 | fschmid | 356 | { |
705 | fschmid | 357 | for (uint lks = 0; lks < linkedFramesToShow.count(); ++lks) |
358 | { |
||
1957 | cbradney | 359 | nextItem = linkedFramesToShow.at(lks); |
360 | while (nextItem != 0) |
||
705 | fschmid | 361 | { |
3954 | cbradney | 362 | //Calculate the link points of the frames |
3903 | cbradney | 363 | double x11 = nextItem->xPos(); |
364 | double y11 = nextItem->yPos(); |
||
3934 | cbradney | 365 | double x12 = x11+nextItem->width(); |
366 | double y12 = y11+nextItem->height(); |
||
3708 | cbradney | 367 | double x1mid = x11+(x12-x11)/2; |
368 | double y1mid = y11+(y12-y11)/2; |
||
814 | cbradney | 369 | |
3934 | cbradney | 370 | if (nextItem->rotation()!=0.000) |
814 | cbradney | 371 | { |
3934 | cbradney | 372 | FPoint tempPoint(0,0, x11, y11, nextItem->rotation(), 1, 1); |
814 | cbradney | 373 | x11=tempPoint.x(); |
374 | y11=tempPoint.y(); |
||
3934 | cbradney | 375 | FPoint tempPoint2(0,0, x12, y12, nextItem->rotation(), 1, 1); |
3242 | cbradney | 376 | x12=tempPoint2.x(); |
377 | y12=tempPoint2.y(); |
||
3934 | cbradney | 378 | FPoint tempPoint3(0,0, x1mid, y1mid, nextItem->rotation(), 1, 1); |
3242 | cbradney | 379 | x1mid=tempPoint3.x(); |
380 | y1mid=tempPoint3.y(); |
||
814 | cbradney | 381 | } |
382 | |||
1485 | tsoots | 383 | |
814 | cbradney | 384 | double a1, b1, a2, b2; |
823 | fschmid | 385 | a1 = a2 = b1 = b2 = 0; |
1957 | cbradney | 386 | if (nextItem->NextBox!=NULL) |
814 | cbradney | 387 | { |
3903 | cbradney | 388 | double x21 = nextItem->NextBox->xPos(); |
389 | double y21 = nextItem->NextBox->yPos(); |
||
3934 | cbradney | 390 | double x22 = x21+nextItem->NextBox->width(); |
391 | double y22 = y21+nextItem->NextBox->height(); |
||
392 | double x2mid = x21 + nextItem->NextBox->width()/2; |
||
393 | double y2mid = y21 + nextItem->NextBox->height()/2; |
||
3708 | cbradney | 394 | //x2mid = x21+(x22-x21)/2; |
395 | //y2mid = y21+(y22-y21)/2; |
||
814 | cbradney | 396 | |
3934 | cbradney | 397 | if (nextItem->NextBox->rotation()!=0.000) |
814 | cbradney | 398 | { |
3934 | cbradney | 399 | FPoint tempPoint(0,0, x21, y21, nextItem->NextBox->rotation(), 1, 1); |
814 | cbradney | 400 | x21=tempPoint.x(); |
401 | y21=tempPoint.y(); |
||
3934 | cbradney | 402 | FPoint tempPoint2(0,0, x22, y22, nextItem->NextBox->rotation(), 1, 1); |
3242 | cbradney | 403 | x22=tempPoint2.x(); |
404 | y22=tempPoint2.y(); |
||
3934 | cbradney | 405 | FPoint tempPoint3(0,0, x2mid, y2mid, nextItem->NextBox->rotation(), 1, 1); |
3242 | cbradney | 406 | x2mid=tempPoint3.x(); |
407 | y2mid=tempPoint3.y(); |
||
814 | cbradney | 408 | } |
1485 | tsoots | 409 | |
814 | cbradney | 410 | if (x22<x11) { a1 = x11; a2 = x22; } |
411 | if (x21>x12) { a1 = x12; a2 = x21; } |
||
412 | if (y22<y11) { b1 = y11; b2 = y22; } |
||
413 | if (y21>y12) { b1 = y12; b2 = y21; } |
||
414 | |||
415 | if (x21<x12 && x21>x11) { a1 = x1mid; a2 = x2mid; } |
||
416 | if (x21<x11 && x22>x11) { a1 = x1mid; a2 = x2mid; } |
||
417 | |||
418 | if (y21<y12 && y21>y11) { b1 = y1mid; b2 = y2mid; } |
||
419 | if (y21<y11 && y22>y11) { b1 = y1mid; b2 = y2mid; } |
||
420 | |||
421 | } |
||
3954 | cbradney | 422 | //Draw the link frame lines |
3934 | cbradney | 423 | FPoint Start(a1-nextItem->xPos(), b1-nextItem->yPos(), nextItem->xPos(), nextItem->yPos(), nextItem->rotation(), 1, 1); |
3903 | cbradney | 424 | //FPoint Start = transformPoint(FPoint(nextItem->Width/2, nextItem->Height), nextItem->xPos(), nextItem->yPos(), nextItem->Rot, 1, 1); |
1957 | cbradney | 425 | nextItem = nextItem->NextBox; |
426 | if (nextItem != NULL) |
||
705 | fschmid | 427 | { |
3934 | cbradney | 428 | FPoint End(a2-nextItem->xPos(), b2-nextItem->yPos(), nextItem->xPos(), nextItem->yPos(), nextItem->rotation(), 1, 1); |
3954 | cbradney | 429 | drawLinkFrameLine(painter, Start, End); |
705 | fschmid | 430 | } |
431 | } |
||
432 | } |
||
456 | fschmid | 433 | } |
705 | fschmid | 434 | else |
456 | fschmid | 435 | { |
1957 | cbradney | 436 | while (nextItem != 0) |
456 | fschmid | 437 | { |
1957 | cbradney | 438 | if (nextItem->BackBox != 0) |
439 | nextItem = nextItem->BackBox; |
||
705 | fschmid | 440 | else |
441 | break; |
||
456 | fschmid | 442 | } |
1957 | cbradney | 443 | while (nextItem != 0) |
705 | fschmid | 444 | { |
3934 | cbradney | 445 | FPoint Start(nextItem->width()/2, nextItem->height(), nextItem->xPos(), nextItem->yPos(), nextItem->rotation(), 1, 1); |
1957 | cbradney | 446 | nextItem = nextItem->NextBox; |
3954 | cbradney | 447 | //Draw the link frame indicator for a new link |
448 | //CB unsure if we need to do this |
||
1957 | cbradney | 449 | if (nextItem != 0) |
705 | fschmid | 450 | { |
3934 | cbradney | 451 | FPoint End(nextItem->width()/2, 0, nextItem->xPos(), nextItem->yPos(), nextItem->rotation(), 1, 1); |
3954 | cbradney | 452 | drawLinkFrameLine(painter, Start, End); |
705 | fschmid | 453 | } |
454 | } |
||
456 | fschmid | 455 | } |
456 | } |
||
457 | painter->setLineWidth(1); |
||
458 | painter->setPenOpacity(1.0); |
||
459 | painter->restore(); |
||
460 | painter->setZoomFactor(z); |
||
461 | } |
||
462 | painter->end(); |
||
463 | delete painter; |
||
3708 | cbradney | 464 | painter=NULL; |
456 | fschmid | 465 | } |
3934 | cbradney | 466 | if (Doc->selection->count() != 0) |
456 | fschmid | 467 | { |
3934 | cbradney | 468 | PageItem *currItem = Doc->selection->itemAt(0); |
1957 | cbradney | 469 | currItem->paintObj(); |
3934 | cbradney | 470 | if ((Doc->EditClip) && (currItem->isSelected())) |
2934 | fschmid | 471 | { |
472 | if (EditContour) |
||
473 | MarkClip(currItem, currItem->ContourLine, true); |
||
474 | else |
||
475 | MarkClip(currItem, currItem->PoLine, true); |
||
476 | } |
||
4049 | cbradney | 477 | if (Doc->selection->isMultipleSelection()) |
456 | fschmid | 478 | { |
479 | setGroupRect(); |
||
480 | paintGroupRect(); |
||
481 | } |
||
482 | } |
||
2603 | cbradney | 483 | if (Doc->appMode == modeEdit) |
456 | fschmid | 484 | slotDoCurs(true); |
2603 | cbradney | 485 | if (Doc->appMode == modeEditGradientVectors) |
735 | fschmid | 486 | { |
3934 | cbradney | 487 | PageItem *currItem = Doc->selection->itemAt(0); |
735 | fschmid | 488 | QPainter p; |
489 | p.begin(viewport()); |
||
490 | ToView(&p); |
||
1957 | cbradney | 491 | Transform(currItem, &p); |
735 | fschmid | 492 | p.setPen(QPen(blue, 1, SolidLine, FlatCap, MiterJoin)); |
493 | p.setBrush(NoBrush); |
||
1957 | cbradney | 494 | p.drawLine(QPoint(qRound(currItem->GrStartX), qRound(currItem->GrStartY)), QPoint(qRound(currItem->GrEndX), qRound(currItem->GrEndY))); |
735 | fschmid | 495 | p.setPen(QPen(magenta, 8, SolidLine, RoundCap, MiterJoin)); |
1957 | cbradney | 496 | p.drawLine(QPoint(qRound(currItem->GrStartX), qRound(currItem->GrStartY)), QPoint(qRound(currItem->GrStartX), qRound(currItem->GrStartY))); |
497 | p.drawLine(QPoint(qRound(currItem->GrEndX), qRound(currItem->GrEndY)), QPoint(qRound(currItem->GrEndX), qRound(currItem->GrEndY))); |
||
735 | fschmid | 498 | p.end(); |
499 | } |
||
2171 | fschmid | 500 | evSpon = false; |
2951 | fschmid | 501 | forceRedraw = false; |
456 | fschmid | 502 | // qDebug( "Time elapsed: %d ms", tim.elapsed() ); |
503 | } |
||
504 | |||
505 | void ScribusView::DrawMasterItems(ScPainter *painter, Page *page, QRect clip) |
||
506 | { |
||
507 | double z = painter->zoomFactor(); |
||
2877 | cbradney | 508 | if (!page->MPageNam.isEmpty()) |
456 | fschmid | 509 | { |
510 | Page* Mp = Doc->MasterPages.at(Doc->MasterNames[page->MPageNam]); |
||
511 | if (page->FromMaster.count() != 0) |
||
512 | { |
||
3313 | cbradney | 513 | QPainter p; |
514 | int Lnr; |
||
515 | struct Layer ll; |
||
516 | PageItem *currItem; |
||
517 | ll.isViewable = false; |
||
518 | ll.LNr = 0; |
||
456 | fschmid | 519 | Lnr = 0; |
2951 | fschmid | 520 | uint layerCount=Doc->layerCount(); |
2937 | cbradney | 521 | for (uint la = 0; la < layerCount; ++la) |
456 | fschmid | 522 | { |
523 | Level2Layer(Doc, &ll, Lnr); |
||
1874 | fschmid | 524 | bool pr = true; |
525 | if ((previewMode) && (!ll.isPrintable)) |
||
526 | pr = false; |
||
527 | if ((ll.isViewable) && (pr)) |
||
456 | fschmid | 528 | { |
3689 | cbradney | 529 | uint pageFromMasterCount=page->FromMaster.count(); |
530 | for (uint a = 0; a < pageFromMasterCount; ++a) |
||
456 | fschmid | 531 | { |
1957 | cbradney | 532 | currItem = page->FromMaster.at(a); |
533 | if (currItem->LayerNr != ll.LNr) |
||
456 | fschmid | 534 | continue; |
3200 | cbradney | 535 | if ((currItem->OwnPage != -1) && (currItem->OwnPage != static_cast<int>(Mp->pageNr()))) |
456 | fschmid | 536 | continue; |
2449 | cbradney | 537 | if ((previewMode) && (!currItem->printable())) |
1874 | fschmid | 538 | continue; |
4401 | fschmid | 539 | currItem->savedOwnPage = currItem->OwnPage; |
540 | // int savedOwnPage = currItem->OwnPage; |
||
3903 | cbradney | 541 | double OldX = currItem->xPos(); |
542 | double OldY = currItem->yPos(); |
||
1957 | cbradney | 543 | double OldBX = currItem->BoundingX; |
544 | double OldBY = currItem->BoundingY; |
||
3200 | cbradney | 545 | currItem->OwnPage = page->pageNr(); |
1957 | cbradney | 546 | if (!currItem->ChangedMasterItem) |
456 | fschmid | 547 | { |
3934 | cbradney | 548 | currItem->moveBy(-Mp->xOffset() + page->xOffset(), -Mp->yOffset() + page->yOffset()); |
3200 | cbradney | 549 | currItem->BoundingX = OldBX - Mp->xOffset() + page->xOffset(); |
550 | currItem->BoundingY = OldBY - Mp->yOffset() + page->yOffset(); |
||
456 | fschmid | 551 | } |
2171 | fschmid | 552 | if (evSpon) |
553 | currItem->Dirty = true; |
||
3656 | cbradney | 554 | QRect oldR(currItem->getRedrawBounding(Scale)); |
537 | fschmid | 555 | if (clip.intersects(oldR)) |
1957 | cbradney | 556 | currItem->DrawObj(painter, clip); |
4401 | fschmid | 557 | currItem->OwnPage = currItem->savedOwnPage; |
558 | // currItem->OwnPage = savedOwnPage; |
||
1957 | cbradney | 559 | if (!currItem->ChangedMasterItem) |
456 | fschmid | 560 | { |
3934 | cbradney | 561 | currItem->setXYPos(OldX, OldY); |
1957 | cbradney | 562 | currItem->BoundingX = OldBX; |
563 | currItem->BoundingY = OldBY; |
||
456 | fschmid | 564 | } |
565 | } |
||
3689 | cbradney | 566 | for (uint a = 0; a < pageFromMasterCount; ++a) |
456 | fschmid | 567 | { |
1957 | cbradney | 568 | currItem = page->FromMaster.at(a); |
569 | if (currItem->LayerNr != ll.LNr) |
||
456 | fschmid | 570 | continue; |
1957 | cbradney | 571 | if (!currItem->isTableItem) |
456 | fschmid | 572 | continue; |
3200 | cbradney | 573 | if ((currItem->OwnPage != -1) && (currItem->OwnPage != static_cast<int>(Mp->pageNr()))) |
456 | fschmid | 574 | continue; |
3903 | cbradney | 575 | double OldX = currItem->xPos(); |
576 | double OldY = currItem->yPos(); |
||
1957 | cbradney | 577 | double OldBX = currItem->BoundingX; |
578 | double OldBY = currItem->BoundingY; |
||
579 | if (!currItem->ChangedMasterItem) |
||
456 | fschmid | 580 | { |
3934 | cbradney | 581 | currItem->setXYPos(OldX - Mp->xOffset() + page->xOffset(), OldY - Mp->yOffset() + page->yOffset()); |
3200 | cbradney | 582 | currItem->BoundingX = OldBX - Mp->xOffset() + page->xOffset(); |
583 | currItem->BoundingY = OldBY - Mp->yOffset() + page->yOffset(); |
||
456 | fschmid | 584 | } |
3656 | cbradney | 585 | QRect oldR(currItem->getRedrawBounding(Scale)); |
537 | fschmid | 586 | if (clip.intersects(oldR)) |
456 | fschmid | 587 | { |
588 | painter->setZoomFactor(Scale); |
||
589 | painter->save(); |
||
3903 | cbradney | 590 | painter->translate(currItem->xPos()*Scale, currItem->yPos()*Scale); |
3934 | cbradney | 591 | painter->rotate(currItem->rotation()); |
1957 | cbradney | 592 | if (currItem->lineColor() != "None") |
456 | fschmid | 593 | { |
594 | QColor tmp; |
||
1957 | cbradney | 595 | currItem->SetFarbe(&tmp, currItem->lineColor(), currItem->lineShade()); |
596 | if ((currItem->TopLine) || (currItem->RightLine) || (currItem->BottomLine) || (currItem->LeftLine)) |
||
456 | fschmid | 597 | { |
1957 | cbradney | 598 | painter->setPen(tmp, currItem->Pwidth, currItem->PLineArt, Qt::SquareCap, currItem->PLineJoin); |
599 | if (currItem->TopLine) |
||
3934 | cbradney | 600 | painter->drawLine(FPoint(0.0, 0.0), FPoint(currItem->width(), 0.0)); |
1957 | cbradney | 601 | if (currItem->RightLine) |
3934 | cbradney | 602 | painter->drawLine(FPoint(currItem->width(), 0.0), FPoint(currItem->width(), currItem->height())); |
1957 | cbradney | 603 | if (currItem->BottomLine) |
3934 | cbradney | 604 | painter->drawLine(FPoint(currItem->width(), currItem->height()), FPoint(0.0, currItem->height())); |
1957 | cbradney | 605 | if (currItem->LeftLine) |
3934 | cbradney | 606 | painter->drawLine(FPoint(0.0, currItem->height()), FPoint(0.0, 0.0)); |
456 | fschmid | 607 | } |
608 | } |
||
609 | painter->restore(); |
||
610 | } |
||
1957 | cbradney | 611 | if (!currItem->ChangedMasterItem) |
456 | fschmid | 612 | { |
3934 | cbradney | 613 | currItem->setXYPos(OldX, OldY); |
1957 | cbradney | 614 | currItem->BoundingX = OldBX; |
615 | currItem->BoundingY = OldBY; |
||
456 | fschmid | 616 | } |
617 | } |
||
618 | } |
||
619 | Lnr++; |
||
620 | } |
||
621 | } |
||
622 | } |
||
623 | painter->setZoomFactor(z); |
||
624 | } |
||
625 | |||
626 | void ScribusView::DrawPageItems(ScPainter *painter, QRect clip) |
||
627 | { |
||
705 | fschmid | 628 | linkedFramesToShow.clear(); |
456 | fschmid | 629 | double z = painter->zoomFactor(); |
3727 | cbradney | 630 | if (Doc->Items->count() != 0) |
456 | fschmid | 631 | { |
3313 | cbradney | 632 | QPainter p; |
633 | int Lnr=0; |
||
634 | struct Layer ll; |
||
635 | PageItem *currItem; |
||
636 | ll.isViewable = false; |
||
637 | ll.LNr = 0; |
||
2951 | fschmid | 638 | uint layerCount=Doc->layerCount(); |
3689 | cbradney | 639 | int docCurrPageNo=static_cast<int>(Doc->currentPageNumber()); |
2937 | cbradney | 640 | for (uint la2 = 0; la2 < layerCount; ++la2) |
456 | fschmid | 641 | { |
642 | Level2Layer(Doc, &ll, Lnr); |
||
1874 | fschmid | 643 | bool pr = true; |
644 | if ((previewMode) && (!ll.isPrintable)) |
||
645 | pr = false; |
||
646 | if ((ll.isViewable) && (pr)) |
||
456 | fschmid | 647 | { |
3727 | cbradney | 648 | QPtrListIterator<PageItem> docItem(*Doc->Items); |
3689 | cbradney | 649 | while ( (currItem = docItem.current()) != 0) |
650 | { |
||
2434 | fschmid | 651 | ++docItem; |
1957 | cbradney | 652 | if (currItem->LayerNr != ll.LNr) |
456 | fschmid | 653 | continue; |
2449 | cbradney | 654 | if ((previewMode) && (!currItem->printable())) |
1874 | fschmid | 655 | continue; |
3724 | cbradney | 656 | if ((Doc->masterPageMode()) && ((currItem->OwnPage != -1) && (currItem->OwnPage != docCurrPageNo))) |
456 | fschmid | 657 | continue; |
3724 | cbradney | 658 | if (!Doc->masterPageMode() && !currItem->OnMasterPage.isEmpty()) |
1781 | fschmid | 659 | { |
1957 | cbradney | 660 | if (currItem->OnMasterPage != Doc->currentPage->PageNam) |
1781 | fschmid | 661 | continue; |
662 | } |
||
3656 | cbradney | 663 | QRect oldR(currItem->getRedrawBounding(Scale)); |
537 | fschmid | 664 | if (clip.intersects(oldR)) |
456 | fschmid | 665 | { |
2171 | fschmid | 666 | if (evSpon) |
667 | currItem->Dirty = true; |
||
2951 | fschmid | 668 | if (forceRedraw) |
669 | currItem->Dirty = false; |
||
3763 | fschmid | 670 | // if ((!Mpressed) || (Doc->EditClip)) |
671 | currItem->DrawObj(painter, clip); |
||
1957 | cbradney | 672 | currItem->Redrawn = true; |
3625 | avox | 673 | if ((currItem->asTextFrame()) && ((currItem->NextBox != 0) || (currItem->BackBox != 0))) |
705 | fschmid | 674 | { |
1957 | cbradney | 675 | PageItem *nextItem = currItem; |
676 | while (nextItem != 0) |
||
705 | fschmid | 677 | { |
1957 | cbradney | 678 | if (nextItem->BackBox != 0) |
679 | nextItem = nextItem->BackBox; |
||
705 | fschmid | 680 | else |
681 | break; |
||
682 | } |
||
1957 | cbradney | 683 | if (linkedFramesToShow.find(nextItem) == -1) |
684 | linkedFramesToShow.append(nextItem); |
||
705 | fschmid | 685 | } |
3934 | cbradney | 686 | if ((Doc->appMode == modeEdit) && (currItem->isSelected()) && (currItem->itemType() == PageItem::TextFrame)) |
456 | fschmid | 687 | { |
1764 | cbradney | 688 | //CB 230305 Stop redrawing the horizontal ruler if it hasnt changed when typing text!!! |
3934 | cbradney | 689 | if ((qRound(horizRuler->ItemPos*10000) != qRound((currItem->xPos())*10000)) || (qRound(horizRuler->ItemEndPos*10000) != qRound(((currItem->xPos()+currItem->width()) )*10000))) |
1764 | cbradney | 690 | { |
3934 | cbradney | 691 | horizRuler->setItemPosition(currItem->xPos(), currItem->width()); |
1957 | cbradney | 692 | if (currItem->lineColor() != "None") |
693 | horizRuler->lineCorr = currItem->Pwidth / 2.0; |
||
1764 | cbradney | 694 | else |
695 | horizRuler->lineCorr = 0; |
||
1957 | cbradney | 696 | horizRuler->ColGap = currItem->ColGap; |
697 | horizRuler->Cols = currItem->Cols; |
||
3988 | cbradney | 698 | horizRuler->Extra = currItem->textToFrameDistLeft(); |
699 | horizRuler->RExtra = currItem->textToFrameDistRight(); |
||
1764 | cbradney | 700 | horizRuler->First = Doc->docParagraphStyles[Doc->currentParaStyle].First; |
701 | horizRuler->Indent = Doc->docParagraphStyles[Doc->currentParaStyle].Indent; |
||
3988 | cbradney | 702 | if (currItem->imageFlippedH() || (currItem->reversed())) |
1764 | cbradney | 703 | horizRuler->Revers = true; |
704 | else |
||
705 | horizRuler->Revers = false; |
||
706 | horizRuler->ItemPosValid = true; |
||
707 | if (Doc->currentParaStyle < 5) |
||
1957 | cbradney | 708 | horizRuler->TabValues = currItem->TabValues; |
1764 | cbradney | 709 | else |
710 | horizRuler->TabValues = Doc->docParagraphStyles[Doc->currentParaStyle].TabValues; |
||
711 | horizRuler->repaint(); |
||
712 | } |
||
456 | fschmid | 713 | } |
714 | } |
||
715 | } |
||
3727 | cbradney | 716 | QPtrListIterator<PageItem> docItem2(*Doc->Items); |
3689 | cbradney | 717 | while ( (currItem = docItem2.current()) != 0 ) |
718 | { |
||
2538 | fschmid | 719 | ++docItem2; |
1957 | cbradney | 720 | if (currItem->LayerNr != ll.LNr) |
456 | fschmid | 721 | continue; |
1957 | cbradney | 722 | if (!currItem->isTableItem) |
456 | fschmid | 723 | continue; |
3656 | cbradney | 724 | QRect oldR(currItem->getRedrawBounding(Scale)); |
537 | fschmid | 725 | if (clip.intersects(oldR)) |
456 | fschmid | 726 | { |
727 | painter->setZoomFactor(Scale); |
||
728 | painter->save(); |
||
3903 | cbradney | 729 | painter->translate(currItem->xPos()*Scale, currItem->yPos()*Scale); |
3934 | cbradney | 730 | painter->rotate(currItem->rotation()); |
1957 | cbradney | 731 | if (currItem->lineColor() != "None") |
456 | fschmid | 732 | { |
733 | QColor tmp; |
||
1957 | cbradney | 734 | currItem->SetFarbe(&tmp, currItem->lineColor(), currItem->lineShade()); |
735 | if ((currItem->TopLine) || (currItem->RightLine) || (currItem->BottomLine) || (currItem->LeftLine)) |
||
456 | fschmid | 736 | { |
1957 | cbradney | 737 | painter->setPen(tmp, currItem->Pwidth, currItem->PLineArt, Qt::SquareCap, currItem->PLineJoin); |
738 | if (currItem->TopLine) |
||
3934 | cbradney | 739 | painter->drawLine(FPoint(0.0, 0.0), FPoint(currItem->width(), 0.0)); |
1957 | cbradney | 740 | if (currItem->RightLine) |
3934 | cbradney | 741 | painter->drawLine(FPoint(currItem->width(), 0.0), FPoint(currItem->width(), currItem->height())); |
1957 | cbradney | 742 | if (currItem->BottomLine) |
3934 | cbradney | 743 | painter->drawLine(FPoint(currItem->width(), currItem->height()), FPoint(0.0, currItem->height())); |
1957 | cbradney | 744 | if (currItem->LeftLine) |
3934 | cbradney | 745 | painter->drawLine(FPoint(0.0, currItem->height()), FPoint(0.0, 0.0)); |
456 | fschmid | 746 | } |
747 | } |
||
748 | painter->restore(); |
||
749 | } |
||
750 | } |
||
751 | } |
||
752 | Lnr++; |
||
753 | } |
||
754 | } |
||
755 | painter->setZoomFactor(z); |
||
756 | } |
||
757 | |||
693 | fschmid | 758 | void ScribusView::DrawPageMarks(ScPainter *p, Page *page, QRect) |
456 | fschmid | 759 | { |
4012 | cbradney | 760 | double lw = 0.5 / Scale; |
456 | fschmid | 761 | double z = p->zoomFactor(); |
762 | p->save(); |
||
763 | p->setZoomFactor(Scale); |
||
3200 | cbradney | 764 | p->translate(page->xOffset() * Scale, page->yOffset() * Scale); |
456 | fschmid | 765 | p->setLineWidth(lw); |
3226 | cbradney | 766 | double pageHeight=page->height(); |
767 | double pageWidth=page->width(); |
||
3962 | cbradney | 768 | //Draw the margins |
879 | fschmid | 769 | if (Doc->guidesSettings.marginsShown) |
456 | fschmid | 770 | { |
879 | fschmid | 771 | p->setPen(Doc->guidesSettings.margColor); |
1065 | cbradney | 772 | if (Doc->marginColored) |
456 | fschmid | 773 | { |
879 | fschmid | 774 | p->setBrush(Doc->guidesSettings.margColor); |
3226 | cbradney | 775 | p->drawRect(0, 0, pageWidth, page->Margins.Top); |
776 | p->drawRect(0, page->Margins.Top, page->Margins.Left, pageHeight - page->Margins.Top); |
||
777 | p->drawRect(page->Margins.Left, pageHeight - page->Margins.Bottom, pageWidth - page->Margins.Right - page->Margins.Left, page->Margins.Bottom); |
||
778 | p->drawRect(pageWidth - page->Margins.Right, page->Margins.Top, page->Margins.Right, pageHeight-page->Margins.Top); |
||
456 | fschmid | 779 | } |
879 | fschmid | 780 | p->setPen(Doc->guidesSettings.margColor); |
3226 | cbradney | 781 | p->drawLine(FPoint(0, page->Margins.Top), FPoint(pageWidth, page->Margins.Top)); |
782 | p->drawLine(FPoint(0, pageHeight - page->Margins.Bottom), FPoint(pageWidth, pageHeight - page->Margins.Bottom)); |
||
783 | p->drawLine(FPoint(page->Margins.Left, 0), FPoint(page->Margins.Left, pageHeight)); |
||
784 | p->drawLine(FPoint(pageWidth - page->Margins.Right, 0), FPoint(pageWidth - page->Margins.Right, pageHeight)); |
||
456 | fschmid | 785 | } |
3962 | cbradney | 786 | //Draw the baseline grid |
879 | fschmid | 787 | if (Doc->guidesSettings.baseShown) |
456 | fschmid | 788 | { |
879 | fschmid | 789 | p->setPen(Doc->guidesSettings.baseColor, lw, SolidLine, FlatCap, MiterJoin); |
3226 | cbradney | 790 | for (double yg = Doc->typographicSettings.offsetBaseGrid; yg < pageHeight; yg += Doc->typographicSettings.valueBaseGrid) |
791 | p->drawLine(FPoint(0, yg), FPoint(pageWidth, yg)); |
||
456 | fschmid | 792 | } |
3962 | cbradney | 793 | //Draw the grid lines |
879 | fschmid | 794 | if (Doc->guidesSettings.gridShown) |
456 | fschmid | 795 | { |
796 | double stx = 0; |
||
3226 | cbradney | 797 | double endx = pageWidth; |
456 | fschmid | 798 | double sty = 0; |
3226 | cbradney | 799 | double endy = pageHeight; |
1781 | fschmid | 800 | /* double stx = QMAX((clip.x() - page->Xoffset) / Scale, 0); |
3200 | cbradney | 801 | double endx = QMIN(stx + clip.width() / Scale, page->width()); |
1781 | fschmid | 802 | double sty = QMAX((clip.y() - page->Yoffset) / Scale, 0); |
3200 | cbradney | 803 | double endy = QMIN(sty + clip.height() / Scale, page->height()); */ |
456 | fschmid | 804 | if (Scale > 0.49) |
805 | { |
||
806 | double i,start; |
||
879 | fschmid | 807 | i = Doc->guidesSettings.majorGrid; |
808 | p->setPen(Doc->guidesSettings.majorColor, lw, SolidLine, FlatCap, MiterJoin); |
||
456 | fschmid | 809 | start=floor(sty/i); |
810 | start*=i; |
||
811 | for (double b = start; b < endy; b+=i) |
||
3226 | cbradney | 812 | p->drawLine(FPoint(0, b), FPoint(pageWidth, b)); |
456 | fschmid | 813 | start=floor(stx/i); |
814 | start*=i; |
||
815 | for (double b = start; b <= endx; b+=i) |
||
3226 | cbradney | 816 | p->drawLine(FPoint(b, 0), FPoint(b, pageHeight)); |
879 | fschmid | 817 | i = Doc->guidesSettings.minorGrid; |
818 | p->setPen(Doc->guidesSettings.minorColor, lw, DotLine, FlatCap, MiterJoin); |
||
456 | fschmid | 819 | start=floor(sty/i); |
820 | start*=i; |
||
821 | for (double b = start; b < endy; b+=i) |
||
3226 | cbradney | 822 | p->drawLine(FPoint(0, b), FPoint(pageWidth, b)); |
456 | fschmid | 823 | start=floor(stx/i); |
824 | start*=i; |
||
825 | for (double b = start; b <= endx; b+=i) |
||
3226 | cbradney | 826 | p->drawLine(FPoint(b, 0), FPoint(b, pageHeight)); |
456 | fschmid | 827 | } |
828 | } |
||
3962 | cbradney | 829 | //Draw the guides |
879 | fschmid | 830 | if (Doc->guidesSettings.guidesShown) |
456 | fschmid | 831 | { |
879 | fschmid | 832 | p->setPen(Doc->guidesSettings.guideColor, lw, DotLine, FlatCap, MiterJoin); |
456 | fschmid | 833 | if (page->XGuides.count() != 0) |
834 | { |
||
835 | for (uint xg = 0; xg < page->XGuides.count(); ++xg) |
||
3016 | fschmid | 836 | { |
3200 | cbradney | 837 | if ((page->XGuides[xg] >= 0) && (page->XGuides[xg] <= page->width())) |
3226 | cbradney | 838 | p->drawLine(FPoint(page->XGuides[xg], 0), FPoint(page->XGuides[xg], pageHeight)); |
3016 | fschmid | 839 | } |
456 | fschmid | 840 | } |
841 | if (page->YGuides.count() != 0) |
||
842 | { |
||
843 | for (uint yg = 0; yg < page->YGuides.count(); ++yg) |
||
3016 | fschmid | 844 | { |
3226 | cbradney | 845 | if ((page->YGuides[yg] >= 0) && (page->YGuides[yg] <= pageHeight)) |
3200 | cbradney | 846 | p->drawLine(FPoint(0, page->YGuides[yg]), FPoint(page->width(), page->YGuides[yg])); |
3016 | fschmid | 847 | } |
456 | fschmid | 848 | } |
849 | } |
||
850 | p->restore(); |
||
851 | p->setZoomFactor(z); |
||
852 | } |
||
853 | |||
854 | void ScribusView::leaveEvent(QEvent *) |
||
855 | { |
||
856 | /* if (BlockLeave) |
||
857 | return; */ |
||
858 | if (!Mpressed) |
||
859 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
860 | /* else |
||
861 | { |
||
1065 | cbradney | 862 | if ((SelItem.count() != 0) && (Mpressed) && (!doku->DragP) && (doku->appMode == 1)) |
456 | fschmid | 863 | { |
1957 | cbradney | 864 | PageItem *currItem = SelItem.at(0); |
456 | fschmid | 865 | if ((b->Locked) || (b->Sizing)) |
866 | return; |
||
867 | doku->DragP = true; |
||
868 | doku->leaveDrag = true; |
||
869 | doku->DraggedElem = b; |
||
870 | doku->DragElements.clear(); |
||
871 | for (uint dre=0; dre<SelItem.count(); ++dre) |
||
872 | doku->DragElements.append(SelItem.at(dre)->ItemNr); |
||
873 | ScriXmlDoc *ss = new ScriXmlDoc(); |
||
874 | QDragObject *dr = new QTextDrag(ss->WriteElem(&SelItem, doku), this); |
||
875 | dr->setPixmap(loadIcon("DragPix.xpm")); |
||
876 | dr->drag(); |
||
877 | delete ss; |
||
3708 | cbradney | 878 | ss=NULL; |
456 | fschmid | 879 | doku->DragP = false; |
880 | doku->leaveDrag = false; |
||
881 | Mpressed = false; |
||
882 | doku->DraggedElem = 0; |
||
883 | doku->DragElements.clear(); |
||
884 | } |
||
885 | } */ |
||
886 | } |
||
887 | |||
888 | void ScribusView::contentsDragEnterEvent(QDragEnterEvent *e) |
||
889 | { |
||
890 | QString text; |
||
891 | e->accept(QTextDrag::canDecode(e)); |
||
892 | if (QTextDrag::decode(e, text)) |
||
893 | { |
||
894 | double gx, gy, gw, gh; |
||
895 | setActiveWindow(); |
||
896 | raise(); |
||
4026 | craig | 897 | ScMW->newActWin(Doc->WinHan); |
456 | fschmid | 898 | updateContents(); |
899 | // SeleItemPos(e->pos()); |
||
900 | QUrl ur(text); |
||
901 | QFileInfo fi = QFileInfo(ur.path()); |
||
902 | ScriXmlDoc *ss = new ScriXmlDoc(); |
||
903 | if (fi.exists()) |
||
904 | text = ur.path(); |
||
905 | if(ss->ReadElemHeader(text,fi.exists(), &gx, &gy, &gw, &gh)) |
||
906 | { |
||
907 | GroupX = e->pos().x() / Scale; |
||
908 | GroupY = e->pos().y() / Scale; |
||
909 | GroupW = gw; |
||
910 | GroupH = gh; |
||
911 | DraggedGroup = true; |
||
912 | DraggedGroupFirst = true; |
||
4049 | cbradney | 913 | //GroupSel = false; |
456 | fschmid | 914 | QPainter p; |
915 | p.begin(viewport()); |
||
916 | PaintSizeRect(&p, QRect()); |
||
3640 | fschmid | 917 | emit ItemGeom(gw, gh); |
456 | fschmid | 918 | // QPoint pv = QPoint(qRound(gx), qRound(gy)); |
919 | // PaintSizeRect(&p, QRect(pv, QPoint(pv.x()+qRound(gw), pv.y()+qRound(gh)))); |
||
920 | p.end(); |
||
921 | } |
||
922 | delete ss; |
||
3708 | cbradney | 923 | ss=NULL; |
456 | fschmid | 924 | } |
925 | } |
||
926 | |||
927 | void ScribusView::contentsDragMoveEvent(QDragMoveEvent *e) |
||
928 | { |
||
929 | QString text; |
||
1957 | cbradney | 930 | // PageItem *currItem; |
456 | fschmid | 931 | // bool img; |
932 | e->accept(QTextDrag::canDecode(e)); |
||
933 | if (QTextDrag::decode(e, text)) |
||
934 | { |
||
935 | if (DraggedGroup) |
||
936 | { |
||
937 | double gx, gy, gw, gh; |
||
938 | GroupX = e->pos().x() / Scale; |
||
939 | GroupY = e->pos().y() / Scale; |
||
940 | getGroupRectScreen(&gx, &gy, &gw, &gh); |
||
941 | QPainter p; |
||
942 | p.begin(viewport()); |
||
2852 | fschmid | 943 | gx += Doc->minCanvasCoordinate.x(); |
944 | gy += Doc->minCanvasCoordinate.y(); |
||
456 | fschmid | 945 | QPoint pv = QPoint(qRound(gx), qRound(gy)); |
946 | if (!DraggedGroupFirst) |
||
947 | PaintSizeRect(&p, QRect(pv, QPoint(pv.x()+qRound(gw), pv.y()+qRound(gh)))); |
||
948 | DraggedGroupFirst = false; |
||
949 | p.end(); |
||
2867 | fschmid | 950 | emit MousePos(GroupX+Doc->minCanvasCoordinate.x(), GroupY+Doc->minCanvasCoordinate.y()); |
1612 | cbradney | 951 | horizRuler->Draw(e->pos().x()); |
952 | vertRuler->Draw(e->pos().y()); |
||
456 | fschmid | 953 | return; |
954 | } |
||
955 | /* QUrl ur(text); |
||
956 | QFileInfo fi = QFileInfo(ur.path()); |
||
957 | QString ext = fi.extension(false).upper(); |
||
958 | QStrList imfo = QImageIO::inputFormats(); |
||
959 | if (ext == "JPG") |
||
960 | ext = "JPEG"; |
||
961 | img = ((imfo.contains(ext))||(ext=="PS")||(ext=="EPS")||(ext=="TIF")); |
||
962 | if (!SeleItemPos(e->pos())) |
||
963 | { |
||
964 | if (SelItem.count() != 0) |
||
965 | Deselect(true); |
||
966 | } |
||
967 | else |
||
968 | { |
||
969 | b = SelItem.at(0); |
||
970 | if (img) |
||
971 | { |
||
972 | if (b->PType != 2) |
||
973 | Deselect(true); |
||
974 | } |
||
975 | else |
||
976 | { |
||
977 | if (b->PType != 4) |
||
978 | Deselect(true); |
||
979 | } |
||
980 | } */ |
||
981 | } |
||
982 | } |
||
983 | |||
632 | fschmid | 984 | void ScribusView::contentsDragLeaveEvent(QDragLeaveEvent *) |
456 | fschmid | 985 | { |
986 | if (DraggedGroup) |
||
987 | { |
||
988 | updateContents(); |
||
989 | DraggedGroup = false; |
||
990 | DraggedGroupFirst = false; |
||
991 | } |
||
992 | } |
||
993 | |||
994 | void ScribusView::contentsDropEvent(QDropEvent *e) |
||
995 | { |
||
996 | QString text; |
||
1957 | cbradney | 997 | PageItem *currItem; |
456 | fschmid | 998 | bool img = false; |
1065 | cbradney | 999 | // struct ScText *hg; |
456 | fschmid | 1000 | // uint a; |
693 | fschmid | 1001 | int re = 0; |
456 | fschmid | 1002 | e->accept(QTextDrag::canDecode(e)); |
1003 | DraggedGroupFirst = false; |
||
2852 | fschmid | 1004 | int ex = qRound(e->pos().x()/Scale + Doc->minCanvasCoordinate.x()); |
1005 | int ey = qRound(e->pos().y()/Scale + Doc->minCanvasCoordinate.y()); |
||
456 | fschmid | 1006 | if (QTextDrag::decode(e, text)) |
1007 | { |
||
1008 | QUrl ur(text); |
||
1009 | QFileInfo fi = QFileInfo(ur.path()); |
||
1010 | QString ext = fi.extension(false).upper(); |
||
1011 | QStrList imfo = QImageIO::inputFormats(); |
||
1012 | if (ext == "JPG") |
||
1013 | ext = "JPEG"; |
||
4020 | cbradney | 1014 | //CB Need to handle this ugly file extension list elsewhere... some capabilities class perhaps |
1015 | img = ((imfo.contains(ext))||(ext=="PS")||(ext=="EPS")||(ext=="PDF")||(ext=="TIF")||(ext=="PSD")); |
||
4019 | cbradney | 1016 | bool selectedItemByDrag=false; |
1017 | int pscx=qRound(e->pos().x()/Scale), pscy=qRound(e->pos().y()/Scale); |
||
1018 | //Loop through all items and see which one(s) were under the drop point on the current layer |
||
1019 | //Should make a nice function for this. |
||
4049 | cbradney | 1020 | for (uint i=0; i<Doc->Items->count(); ++i) |
4019 | cbradney | 1021 | { |
1022 | if (Doc->Items->at(i)->LayerNr==Doc->activeLayer()) |
||
1023 | { |
||
1024 | if (Doc->Items->at(i)->pointWithinItem(pscx, pscy)) |
||
1025 | { |
||
1026 | Deselect(false); |
||
1027 | SelectItem(Doc->Items->at(i)); |
||
1028 | selectedItemByDrag=true; |
||
1029 | break; |
||
1030 | } |
||
1031 | } |
||
1032 | } |
||
4018 | cbradney | 1033 | //CB When we drag an image to a page from outside |
1034 | //SeleItemPos is from 1.2.x. Needs reenabling for dragging *TO* a frame |
||
4019 | cbradney | 1035 | if ((fi.exists()) && (img) && !selectedItemByDrag)// && (!SeleItemPos(e->pos()))) |
456 | fschmid | 1036 | { |
4018 | cbradney | 1037 | //int z = PaintPict(qRound(e->pos().x()/doku->Scale), qRound(e->pos().y()/doku->Scale), 1, 1); |
4019 | cbradney | 1038 | int z = Doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, pscx, pscy, 1, 1, 1, Doc->toolSettings.dBrushPict, "None", true); |
4018 | cbradney | 1039 | PageItem *b = Doc->Items->at(z); |
1040 | Doc->LoadPict(ur.path(), b->ItemNr); |
||
1041 | b->setWidth(static_cast<double>(b->pixm.width())); |
||
1042 | b->setHeight(static_cast<double>(b->pixm.height())); |
||
1043 | b->OldB2 = b->width(); |
||
1044 | b->OldH2 = b->height(); |
||
456 | fschmid | 1045 | UpdateClip(b); |
1046 | emit DocChanged(); |
||
1047 | update(); |
||
1048 | return; |
||
4019 | cbradney | 1049 | } |
1050 | |||
1051 | //if ((SeleItemPos(e->pos())) && (!text.startsWith("<SCRIBUSELEM"))) |
||
1052 | if (Doc->selection->count()>0) |
||
456 | fschmid | 1053 | { |
4019 | cbradney | 1054 | if (Doc->selection->itemAt(0)->pointWithinItem(pscx, pscy) && (!text.startsWith("<SCRIBUSELEM"))) |
456 | fschmid | 1055 | { |
4019 | cbradney | 1056 | PageItem *b = Doc->selection->itemAt(0); |
1057 | if (b->itemType() == PageItem::ImageFrame) |
||
456 | fschmid | 1058 | { |
4019 | cbradney | 1059 | if ((fi.exists()) && (img)) |
456 | fschmid | 1060 | { |
4019 | cbradney | 1061 | Doc->LoadPict(ur.path(), b->ItemNr); |
1062 | update(); |
||
456 | fschmid | 1063 | } |
1064 | } |
||
4042 | subik | 1065 | /* CB leaving this out for now... |
4019 | cbradney | 1066 | if (b->PType == 4) |
456 | fschmid | 1067 | { |
4019 | cbradney | 1068 | if ((b->BackBox != 0) && (b->itemText.count() == 0)) |
456 | fschmid | 1069 | return; |
4019 | cbradney | 1070 | if ((fi.exists()) && (!img) && (fi.size() < 500000)) |
456 | fschmid | 1071 | { |
4019 | cbradney | 1072 | Serializer *ss = new Serializer(ur.path()); |
1073 | if (ss->Read()) |
||
1074 | { |
||
1075 | int st = doku->currentParaStyle; |
||
1076 | ss->GetText(b, st, doku->docParagraphStyles[st].Font, doku->docParagraphStyles[st].FontSize, true); |
||
1077 | emit DocChanged(); |
||
1078 | } |
||
1079 | delete ss; |
||
1080 | ss=NULL; |
||
1081 | update(); |
||
456 | fschmid | 1082 | } |
4019 | cbradney | 1083 | else |
1084 | { |
||
1085 | slotDoCurs(false); |
||
1086 | slotSetCurs(e->pos().x(), e->pos().y()); |
||
1087 | if (text.startsWith("<SCRIBUSELEM")) |
||
1088 | return; |
||
1089 | for (a=0; a<text.length(); ++a) |
||
1090 | { |
||
1091 | hg = new ScText; |
||
1092 | hg->ch = text.at(a); |
||
1093 | if (hg->ch == QChar(10)) |
||
1094 | hg->ch = QChar(13); |
||
1095 | if (hg->ch == QChar(4)) |
||
1096 | hg->ch = QChar(9); |
||
1097 | if (hg->ch == QChar(5)) |
||
1098 | hg->ch = QChar(13); |
||
1099 | hg->cfont = b->IFont; |
||
1100 | hg->csize = b->ISize; |
||
1101 | hg->ccolor = b->TxtFill; |
||
1102 | hg->cshade = b->ShTxtFill; |
||
1103 | hg->cstroke = b->TxtStroke; |
||
1104 | hg->cshade2 = b->ShTxtStroke; |
||
1105 | hg->cselect = false; |
||
1106 | hg->cscale = b->TxtScale; |
||
1107 | hg->cextra = 0; |
||
1108 | hg->cstyle = 0; |
||
1109 | hg->cab = 0; |
||
1110 | hg->xp = 0; |
||
1111 | hg->yp = 0; |
||
1112 | hg->PRot = 0; |
||
1113 | hg->PtransX = 0; |
||
1114 | hg->PtransY = 0; |
||
1115 | b->itemText.insert(b->CPos, hg); |
||
1116 | b->CPos += 1; |
||
1117 | } |
||
1118 | emit DocChanged(); |
||
1119 | update(); |
||
1120 | } |
||
1121 | }*/ |
||
456 | fschmid | 1122 | } |
1123 | } |
||
1124 | else |
||
4042 | subik | 1125 | { |
3727 | cbradney | 1126 | for (uint as = 0; as < Doc->Items->count(); ++as) |
855 | fschmid | 1127 | { |
3934 | cbradney | 1128 | Doc->Items->at(as)->setSelected(false); |
855 | fschmid | 1129 | } |
3934 | cbradney | 1130 | uint oldDocItemCount = Doc->Items->count(); |
456 | fschmid | 1131 | if ((!img) && (Doc->DraggedElem == 0)) |
1163 | fschmid | 1132 | { |
1133 | if ((fi.exists()) && (!img)) |
||
2852 | fschmid | 1134 | emit LoadElem(ur.path(), ex, ey, true, false, Doc, this); |
1163 | fschmid | 1135 | else |
2852 | fschmid | 1136 | emit LoadElem(QString(text), ex, ey, false, false, Doc, this); |
3934 | cbradney | 1137 | Doc->selection->clear(); |
1138 | for (uint as = oldDocItemCount; as < Doc->Items->count(); ++as) |
||
2233 | fschmid | 1139 | { |
3727 | cbradney | 1140 | currItem = Doc->Items->at(as); |
3934 | cbradney | 1141 | Doc->selection->addItem(currItem); |
2233 | fschmid | 1142 | if (currItem->isBookmark) |
1143 | emit AddBM(currItem); |
||
1144 | } |
||
1163 | fschmid | 1145 | } |
456 | fschmid | 1146 | else |
1147 | { |
||
1148 | if (Doc->DraggedElem != 0) |
||
1149 | { |
||
1150 | if (!Doc->leaveDrag) |
||
1151 | { |
||
1152 | QPopupMenu *pmen = new QPopupMenu(); |
||
1153 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1154 | pmen->insertItem( tr("Copy Here")); |
||
1155 | pmen->insertItem( tr("Move Here")); |
||
1156 | pmen->insertItem( tr("Cancel")); |
||
1157 | re = pmen->indexOf(pmen->exec(QCursor::pos())); |
||
1158 | delete pmen; |
||
3708 | cbradney | 1159 | pmen=NULL; |
456 | fschmid | 1160 | } |
1161 | else |
||
1162 | re = 1; |
||
1163 | if ((re == 2) || (re == -1)) |
||
1164 | { |
||
1165 | updateContents(); |
||
1166 | return; |
||
1167 | } |
||
1168 | if ((re == 1) || (Doc->leaveDrag)) |
||
1169 | { |
||
1170 | QPtrList<PageItem> pasted; |
||
2852 | fschmid | 1171 | emit LoadElem(QString(text), ex, ey, false, false, Doc, this); |
3934 | cbradney | 1172 | for (uint as = oldDocItemCount; as < Doc->Items->count(); ++as) |
456 | fschmid | 1173 | { |
3727 | cbradney | 1174 | pasted.append(Doc->Items->at(as)); |
456 | fschmid | 1175 | } |
3934 | cbradney | 1176 | Doc->selection->clear(); |
456 | fschmid | 1177 | for (uint dre=0; dre<Doc->DragElements.count(); ++dre) |
1178 | { |
||
3934 | cbradney | 1179 | Doc->selection->addItem(Doc->Items->at(Doc->DragElements[dre])); |
456 | fschmid | 1180 | } |
1181 | PageItem* bb; |
||
1182 | int fin; |
||
1183 | for (uint dre=0; dre<Doc->DragElements.count(); ++dre) |
||
1184 | { |
||
1185 | bb = pasted.at(dre); |
||
3934 | cbradney | 1186 | currItem = Doc->selection->itemAt(dre); |
3625 | avox | 1187 | if ((currItem->asTextFrame()) && ((currItem->NextBox != 0) || (currItem->BackBox != 0))) |
456 | fschmid | 1188 | { |
1957 | cbradney | 1189 | if (currItem->BackBox != 0) |
456 | fschmid | 1190 | { |
1957 | cbradney | 1191 | bb->BackBox = currItem->BackBox; |
3934 | cbradney | 1192 | fin = Doc->selection->findItem(currItem->BackBox); |
456 | fschmid | 1193 | if (fin != -1) |
1194 | bb->BackBox = pasted.at(fin); |
||
1195 | bb->BackBox->NextBox = bb; |
||
1196 | } |
||
1957 | cbradney | 1197 | if (currItem->NextBox != 0) |
456 | fschmid | 1198 | { |
1957 | cbradney | 1199 | bb->NextBox = currItem->NextBox; |
3934 | cbradney | 1200 | fin = Doc->selection->findItem(currItem->NextBox); |
456 | fschmid | 1201 | if (fin != -1) |
1202 | bb->NextBox = pasted.at(fin); |
||
1203 | bb->NextBox->BackBox = bb; |
||
1204 | } |
||
1205 | } |
||
1206 | } |
||
1207 | for (uint dre=0; dre<Doc->DragElements.count(); ++dre) |
||
1208 | { |
||
3934 | cbradney | 1209 | currItem = Doc->selection->itemAt(dre); |
1957 | cbradney | 1210 | currItem->NextBox = 0; |
1211 | currItem->BackBox = 0; |
||
456 | fschmid | 1212 | } |
1213 | pasted.clear(); |
||
1214 | DeleteItem(); |
||
1215 | } |
||
1216 | } |
||
1217 | if ((!img) && ((re == 0))) |
||
2852 | fschmid | 1218 | emit LoadElem(QString(text), ex, ey, false, false, Doc, this); |
456 | fschmid | 1219 | Doc->DraggedElem = 0; |
1220 | Doc->DragElements.clear(); |
||
3934 | cbradney | 1221 | Doc->selection->clear(); |
1222 | for (uint as = oldDocItemCount; as < Doc->Items->count(); ++as) |
||
456 | fschmid | 1223 | { |
3727 | cbradney | 1224 | currItem = Doc->Items->at(as); |
3934 | cbradney | 1225 | Doc->selection->addItem(currItem); |
2193 | fschmid | 1226 | if (currItem->isBookmark) |
1227 | emit AddBM(currItem); |
||
456 | fschmid | 1228 | } |
1229 | } |
||
3934 | cbradney | 1230 | if (Doc->selection->count() > 1) |
3640 | fschmid | 1231 | { |
1232 | setGroupRect(); |
||
1233 | paintGroupRect(); |
||
1234 | double x, y, w, h; |
||
1235 | getGroupRect(&x, &y, &w, &h); |
||
1236 | emit ItemPos(x, y); |
||
1237 | emit ItemGeom(w, h); |
||
1238 | } |
||
3941 | cbradney | 1239 | updateContents(); |
4019 | cbradney | 1240 | } |
456 | fschmid | 1241 | } |
1242 | } |
||
1243 | |||
1244 | void ScribusView::contentsMouseDoubleClickEvent(QMouseEvent *m) |
||
1245 | { |
||
1246 | m->accept(); |
||
1247 | Mpressed = false; |
||
1957 | cbradney | 1248 | PageItem *currItem = 0; |
456 | fschmid | 1249 | if (Doc->EditClip) |
1250 | { |
||
1251 | emit EndNodeEdit(); |
||
1252 | return; |
||
1253 | } |
||
4049 | cbradney | 1254 | if ((Doc->selection->isMultipleSelection()) || (Doc->appMode != modeNormal)) |
456 | fschmid | 1255 | { |
4049 | cbradney | 1256 | if ((Doc->selection->isMultipleSelection()) && (Doc->appMode == modeNormal)) |
456 | fschmid | 1257 | { |
1957 | cbradney | 1258 | if (GetItem(&currItem)) |
456 | fschmid | 1259 | { |
1957 | cbradney | 1260 | if (currItem->isTableItem) |
456 | fschmid | 1261 | { |
1262 | Deselect(false); |
||
3934 | cbradney | 1263 | Doc->selection->addItem(currItem); |
1957 | cbradney | 1264 | currItem->isSingleSel = true; |
3946 | cbradney | 1265 | //CB FIXME dont call this if the added item is item 0 |
4010 | cbradney | 1266 | if (!Doc->selection->primarySelectionIs(currItem)) |
1267 | currItem->emitAllToGUI(); |
||
1957 | cbradney | 1268 | currItem->paintObj(); |
456 | fschmid | 1269 | } |
1270 | } |
||
4351 | cbradney | 1271 | return; |
456 | fschmid | 1272 | } |
1273 | else |
||
4351 | cbradney | 1274 | { |
1275 | if (!(GetItem(&currItem) && (Doc->appMode == modeEdit) && currItem->asTextFrame())) |
||
1276 | { |
||
1277 | contentsMousePressEvent(m); |
||
1278 | return; |
||
1279 | } |
||
1280 | } |
||
456 | fschmid | 1281 | } |
1957 | cbradney | 1282 | if (GetItem(&currItem)) |
456 | fschmid | 1283 | { |
1957 | cbradney | 1284 | if ((currItem->itemType() == PageItem::Polygon) || (currItem->itemType() == PageItem::PolyLine) || (currItem->itemType() == PageItem::ImageFrame) || (currItem->itemType() == PageItem::PathText)) |
456 | fschmid | 1285 | { |
1957 | cbradney | 1286 | if ((currItem->locked()) || (!currItem->ScaleType)) |
456 | fschmid | 1287 | { |
1288 | contentsMousePressEvent(m); |
||
1289 | return; |
||
1290 | } |
||
3962 | cbradney | 1291 | //If we double click on an image frame and theres no image assigned, open the |
1292 | //load picture dialog, else put it into edit mode |
||
2877 | cbradney | 1293 | if ((currItem->itemType() == PageItem::ImageFrame) && (currItem->Pfile.isEmpty())) |
2318 | fschmid | 1294 | emit LoadPic(); |
1295 | else |
||
2603 | cbradney | 1296 | emit Amode(modeEdit); |
456 | fschmid | 1297 | } |
1298 | else |
||
1957 | cbradney | 1299 | if (currItem->itemType() == PageItem::TextFrame) |
837 | fschmid | 1300 | { |
4351 | cbradney | 1301 | //CB old code |
1302 | //emit currItem->isAnnotation() ? AnnotProps() : Amode(modeEdit); |
||
1303 | //contentsMousePressEvent(m); |
||
1304 | //CB if annotation, open the annotation dialog |
||
1305 | if (currItem->isAnnotation()) |
||
1306 | { |
||
1307 | emit AnnotProps(); |
||
1308 | contentsMousePressEvent(m); |
||
1309 | } |
||
1310 | //else if not in mode edit, set mode edit |
||
1311 | else if (Doc->appMode != modeEdit) |
||
1312 | { |
||
1313 | Amode(modeEdit); |
||
1314 | //CB ignore the double click and go with a single one |
||
1315 | //if we werent in mode edit before. |
||
1316 | //unsure if this is correct, but its ok given we had no |
||
1317 | //double click select until now. |
||
1318 | contentsMousePressEvent(m); |
||
1319 | } |
||
1320 | //otherwise, select between the whitespace |
||
1321 | else |
||
1322 | { //Double click in a frame to select a word |
||
1323 | PageItem_TextFrame *cItem=currItem->asTextFrame(); |
||
1324 | bool inText = slotSetCurs(m->x(), m->y()); |
||
1325 | if (!inText) |
||
1326 | { |
||
1327 | Deselect(true); |
||
1328 | slotDoCurs(true); |
||
1329 | emit Amode(modeNormal); |
||
1330 | return; |
||
1331 | } |
||
1332 | int a=cItem->CPos; |
||
1333 | while(a>0) |
||
1334 | { |
||
1335 | if (cItem->itemText.at(a-1)->ch.at(0).isLetterOrNumber()) |
||
1336 | --a; |
||
1337 | else |
||
1338 | break; |
||
1339 | } |
||
1340 | uint b=cItem->CPos; |
||
1341 | while(b<cItem->itemText.count()) |
||
1342 | { |
||
1343 | if (cItem->itemText.at(b)->ch.at(0).isLetterOrNumber()) |
||
1344 | ++b; |
||
1345 | else |
||
1346 | break; |
||
1347 | } |
||
1348 | oldCp=a; |
||
1349 | cItem->CPos=b; |
||
1350 | cItem->ExpandSel(1, oldCp); |
||
1351 | slotDoCurs(true); |
||
1352 | } |
||
837 | fschmid | 1353 | } |
456 | fschmid | 1354 | } |
1355 | } |
||
1356 | |||
1357 | void ScribusView::contentsMouseReleaseEvent(QMouseEvent *m) |
||
1358 | { |
||
1957 | cbradney | 1359 | PageItem *currItem; |
456 | fschmid | 1360 | Mpressed = false; |
879 | fschmid | 1361 | if (Doc->guidesSettings.guidesShown) |
456 | fschmid | 1362 | { |
3962 | cbradney | 1363 | bool foundGuide = false; |
2848 | fschmid | 1364 | double nx = m->x()/Scale + Doc->minCanvasCoordinate.x(); |
1365 | double ny = m->y()/Scale + Doc->minCanvasCoordinate.y(); |
||
1065 | cbradney | 1366 | if (Doc->currentPage->YGuides.count() != 0) |
456 | fschmid | 1367 | { |
1065 | cbradney | 1368 | for (uint yg = 0; yg < Doc->currentPage->YGuides.count(); ++yg) |
456 | fschmid | 1369 | { |
3200 | cbradney | 1370 | if ((Doc->currentPage->YGuides[yg]+Doc->currentPage->yOffset()< (ny+Doc->guidesSettings.grabRad)) && |
1371 | (Doc->currentPage->YGuides[yg]+Doc->currentPage->yOffset()> (ny-Doc->guidesSettings.grabRad))) |
||
456 | fschmid | 1372 | { |
3962 | cbradney | 1373 | foundGuide = true; |
456 | fschmid | 1374 | break; |
1375 | } |
||
1376 | } |
||
1377 | } |
||
1065 | cbradney | 1378 | if (Doc->currentPage->XGuides.count() != 0) |
456 | fschmid | 1379 | { |
1065 | cbradney | 1380 | for (uint xg = 0; xg < Doc->currentPage->XGuides.count(); ++xg) |
456 | fschmid | 1381 | { |
3200 | cbradney | 1382 | if ((Doc->currentPage->XGuides[xg]+Doc->currentPage->xOffset()< (nx+Doc->guidesSettings.grabRad)) && |
1383 | (Doc->currentPage->XGuides[xg]+Doc->currentPage->xOffset()> (nx-Doc->guidesSettings.grabRad))) |
||
456 | fschmid | 1384 | { |
3962 | cbradney | 1385 | foundGuide = true; |
456 | fschmid | 1386 | break; |
1387 | } |
||
1388 | } |
||
1389 | } |
||
3962 | cbradney | 1390 | if ((foundGuide) && (m->button() == RightButton) && (!GetItem(&currItem))) |
456 | fschmid | 1391 | { |
1392 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1393 | MoveGY = false; |
||
1394 | MoveGX = false; |
||
1395 | emit EditGuides(); |
||
1396 | return; |
||
1397 | } |
||
1398 | if (MoveGY) |
||
1399 | { |
||
1115 | tsoots | 1400 | SetYGuide(m, GyM); |
456 | fschmid | 1401 | MoveGY = false; |
1402 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1403 | updateContents(); |
||
2966 | fschmid | 1404 | GyM = -1; |
456 | fschmid | 1405 | return; |
1406 | } |
||
1407 | if (MoveGX) |
||
1408 | { |
||
1115 | tsoots | 1409 | SetXGuide(m, GxM); |
456 | fschmid | 1410 | MoveGX = false; |
1411 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1412 | updateContents(); |
||
2966 | fschmid | 1413 | GxM = -1; |
456 | fschmid | 1414 | return; |
1415 | } |
||
1416 | } |
||
2603 | cbradney | 1417 | if (Doc->appMode == modeEditGradientVectors) |
735 | fschmid | 1418 | return; |
2603 | cbradney | 1419 | if (Doc->appMode == modeCopyProperties) |
1840 | fschmid | 1420 | return; |
2603 | cbradney | 1421 | if (Doc->appMode == modeMeasurementTool) |
456 | fschmid | 1422 | { |
1423 | QPainter p; |
||
1424 | p.begin(viewport()); |
||
2854 | fschmid | 1425 | QPoint out = contentsToViewport(QPoint(0, 0)); |
1426 | p.translate(out.x(), out.y()); |
||
456 | fschmid | 1427 | p.setRasterOp(XorROP); |
1428 | p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin)); |
||
1429 | p.drawLine(Dxp, Dyp, Mxp, Myp); |
||
1430 | p.end(); |
||
1431 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1525 | cbradney | 1432 | //emit PaintingDone(); |
456 | fschmid | 1433 | return; |
1434 | } |
||
2603 | cbradney | 1435 | if (Doc->appMode == modePanning) |
4105 | cbradney | 1436 | { |
1437 | if ((m->state() & Qt::RightButton) && (m->state() & Qt::ControlButton)) |
||
1438 | { |
||
1439 | ScMW->setAppMode(modeNormal); |
||
1440 | } |
||
456 | fschmid | 1441 | return; |
4105 | cbradney | 1442 | } |
2603 | cbradney | 1443 | if (Doc->appMode == modeDrawTable) |
456 | fschmid | 1444 | { |
3934 | cbradney | 1445 | if ((Doc->selection->count() == 0) && (HaveSelRect) && (!MidButt)) |
456 | fschmid | 1446 | { |
1447 | QRect AreaR = QRect(static_cast<int>(Mxp), static_cast<int>(Myp), static_cast<int>(SeRx-Mxp), static_cast<int>(SeRy-Myp)); |
||
1448 | QPainter p; |
||
1449 | p.begin(viewport()); |
||
1450 | ToView(&p); |
||
1451 | p.scale(Scale, Scale); |
||
1452 | p.setRasterOp(XorROP); |
||
1453 | p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin)); |
||
1454 | if(Mxp > SeRx) |
||
1455 | { |
||
1456 | double tmp=SeRx; |
||
1457 | SeRx=static_cast<int>(Mxp); |
||
1458 | Mxp=static_cast<int>(tmp); |
||
1459 | } |
||
1460 | if(Myp > SeRy) |
||
1461 | { |
||
1462 | double tmp=SeRy; |
||
1463 | SeRy=static_cast<int>(Myp); |
||
1464 | Myp=static_cast<int>(tmp); |
||
1465 | } |
||
1466 | HaveSelRect = false; |
||
1467 | double Tx, Ty, Tw, Th; |
||
1468 | Tx = Mxp; |
||
1469 | Ty = Myp; |
||
1470 | Tw = SeRx-Mxp; |
||
1471 | Th = SeRy-Myp; |
||
1472 | int z; |
||
1473 | int Cols, Rows; |
||
1474 | double deltaX, deltaY, offX, offY; |
||
1475 | if ((Th < 6) || (Tw < 6)) |
||
1476 | { |
||
1477 | p.drawRect(AreaR); |
||
1478 | p.end(); |
||
2603 | cbradney | 1479 | Doc->appMode = modeNormal; |
456 | fschmid | 1480 | emit PaintingDone(); |
1481 | return; |
||
1482 | } |
||
1483 | InsertTable *dia = new InsertTable(this, static_cast<int>(Th / 6), static_cast<int>(Tw / 6)); |
||
1484 | if (!dia->exec()) |
||
1485 | { |
||
1486 | p.drawRect(AreaR); |
||
1487 | p.end(); |
||
2603 | cbradney | 1488 | Doc->appMode = modeNormal; |
456 | fschmid | 1489 | emit PaintingDone(); |
1490 | delete dia; |
||
3708 | cbradney | 1491 | dia=NULL; |
456 | fschmid | 1492 | return; |
1493 | } |
||
1494 | p.end(); |
||
1495 | Cols = dia->Cols->value(); |
||
1496 | Rows = dia->Rows->value(); |
||
1497 | delete dia; |
||
3708 | cbradney | 1498 | dia=NULL; |
456 | fschmid | 1499 | deltaX = Tw / Cols; |
1500 | deltaY = Th / Rows; |
||
1501 | offX = 0.0; |
||
1502 | offY = 0.0; |
||
3934 | cbradney | 1503 | Doc->selection->clear(); |
1396 | tsoots | 1504 | if (UndoManager::undoEnabled()) |
1505 | undoManager->beginTransaction(Doc->currentPage->getUName(), Um::ITable, Um::CreateTable, |
||
1506 | QString(Um::RowsCols).arg(Rows).arg(Cols), Um::ICreate); |
||
456 | fschmid | 1507 | for (int rc = 0; rc < Rows; ++rc) |
1508 | { |
||
1509 | for (int cc = 0; cc < Cols; ++cc) |
||
1510 | { |
||
3292 | cbradney | 1511 | //z = PaintText(Tx + offX, Ty + offY, deltaX, deltaY, Doc->toolSettings.dWidth, Doc->toolSettings.dPenText); |
1512 | z = Doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, Tx + offX, Ty + offY, deltaX, deltaY, Doc->toolSettings.dWidth, "None", Doc->toolSettings.dPenText, !Mpressed); |
||
3727 | cbradney | 1513 | currItem = Doc->Items->at(z); |
1957 | cbradney | 1514 | currItem->isTableItem = true; |
3225 | fschmid | 1515 | currItem->setTextFlowsAroundFrame(true); |
1516 | currItem->setTextFlowUsesBoundingBox(true); |
||
3934 | cbradney | 1517 | Doc->selection->addItem(currItem); |
456 | fschmid | 1518 | offX += deltaX; |
1519 | } |
||
1520 | offY += deltaY; |
||
1521 | offX = 0.0; |
||
1522 | } |
||
1523 | for (int rc = 0; rc < Rows; ++rc) |
||
1524 | { |
||
1525 | for (int cc = 0; cc < Cols; ++cc) |
||
1526 | { |
||
3934 | cbradney | 1527 | currItem = Doc->selection->itemAt((rc * Cols) + cc); |
456 | fschmid | 1528 | if (rc == 0) |
1957 | cbradney | 1529 | currItem->TopLink = 0; |
456 | fschmid | 1530 | else |
3934 | cbradney | 1531 | currItem->TopLink = Doc->selection->itemAt(((rc-1)*Cols)+cc); |
456 | fschmid | 1532 | if (rc == Rows-1) |
1957 | cbradney | 1533 | currItem->BottomLink = 0; |
456 | fschmid | 1534 | else |
3934 | cbradney | 1535 | currItem->BottomLink = Doc->selection->itemAt(((rc+1)*Cols)+cc); |
456 | fschmid | 1536 | if (cc == 0) |
1957 | cbradney | 1537 | currItem->LeftLink = 0; |
456 | fschmid | 1538 | else |
3934 | cbradney | 1539 | currItem->LeftLink = Doc->selection->itemAt((rc*Cols)+cc-1); |
456 | fschmid | 1540 | if (cc == Cols-1) |
1957 | cbradney | 1541 | currItem->RightLink = 0; |
456 | fschmid | 1542 | else |
3934 | cbradney | 1543 | currItem->RightLink = Doc->selection->itemAt((rc*Cols)+cc+1); |
456 | fschmid | 1544 | } |
1545 | } |
||
1546 | emit DoGroup(); |
||
1396 | tsoots | 1547 | if (UndoManager::undoEnabled()) |
1548 | undoManager->commit(); |
||
456 | fschmid | 1549 | } |
2603 | cbradney | 1550 | Doc->appMode = modeNormal; |
456 | fschmid | 1551 | emit PaintingDone(); |
1552 | emit DocChanged(); |
||
1553 | updateContents(); |
||
1554 | return; |
||
1555 | } |
||
2603 | cbradney | 1556 | if (Doc->appMode == modeDrawFreehandLine) |
456 | fschmid | 1557 | { |
1558 | if (RecordP.size() > 1) |
||
1559 | { |
||
3292 | cbradney | 1560 | //uint z = PaintPolyLine(0, 0, 1, 1, Doc->toolSettings.dWidth, "None", Doc->toolSettings.dPenLine); |
1561 | uint z = Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, 0, 0, 1, 1, Doc->toolSettings.dWidth, "None", Doc->toolSettings.dPenLine, !Mpressed); |
||
3727 | cbradney | 1562 | currItem = Doc->Items->at(z); |
1957 | cbradney | 1563 | currItem->PoLine.resize(0); |
1564 | currItem->PoLine.addPoint(RecordP.point(0)); |
||
1565 | currItem->PoLine.addPoint(RecordP.point(0)); |
||
456 | fschmid | 1566 | for (uint px = 1; px < RecordP.size()-1; ++px) |
1567 | { |
||
1957 | cbradney | 1568 | currItem->PoLine.addPoint(RecordP.point(px)); |
1569 | currItem->PoLine.addPoint(RecordP.point(px)); |
||
1570 | currItem->PoLine.addPoint(RecordP.point(px)); |
||
1571 | currItem->PoLine.addPoint(RecordP.point(px)); |
||
456 | fschmid | 1572 | } |
1957 | cbradney | 1573 | currItem->PoLine.addPoint(RecordP.point(RecordP.size()-1)); |
1574 | currItem->PoLine.addPoint(RecordP.point(RecordP.size()-1)); |
||
1575 | AdjustItemSize(currItem); |
||
3934 | cbradney | 1576 | Doc->selection->clear(); |
1577 | Doc->selection->addItem(currItem); |
||
1957 | cbradney | 1578 | currItem->ClipEdited = true; |
3934 | cbradney | 1579 | //currItem->Select = true; |
1957 | cbradney | 1580 | currItem->FrameType = 3; |
3657 | cbradney | 1581 | currItem->OwnPage = Doc->OnPage(currItem); |
3934 | cbradney | 1582 | //qDebug("emit ItemPos(currItem->xPos(), currItem->yPos());"); |
3991 | cbradney | 1583 | /*CB Done with addItem |
1957 | cbradney | 1584 | emit SetSizeValue(currItem->Pwidth); |
1585 | emit SetLineArt(currItem->PLineArt, currItem->PLineEnd, currItem->PLineJoin); |
||
1586 | emit ItemFarben(currItem->lineColor(), currItem->fillColor(), currItem->lineShade(), currItem->fillShade()); |
||
1587 | emit ItemGradient(currItem->GrType); |
||
1588 | emit ItemTrans(currItem->fillTransparency(), currItem->lineTransparency()); |
||
3991 | cbradney | 1589 | */ |
3946 | cbradney | 1590 | //emit HaveSel(PageItem::PolyLine); |
456 | fschmid | 1591 | } |
4054 | fschmid | 1592 | Doc->appMode = modeNormal; |
456 | fschmid | 1593 | updateContents(); |
1594 | emit PaintingDone(); |
||
1595 | emit DocChanged(); |
||
1596 | return; |
||
1597 | } |
||
1598 | if ((Doc->EditClip) && (ClRe == -1) && (HaveSelRect)) |
||
1599 | { |
||
1600 | double sc = Scale; |
||
1601 | QPainter p; |
||
1602 | p.begin(viewport()); |
||
1603 | ToView(&p); |
||
1604 | p.scale(Scale, Scale); |
||
1605 | p.setRasterOp(XorROP); |
||
1606 | p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin)); |
||
1607 | p.drawRect(Mxp, Myp, SeRx-Mxp, SeRy-Myp); |
||
1608 | p.end(); |
||
1609 | if(Mxp > SeRx) |
||
1610 | { |
||
1611 | double tmp=SeRx; |
||
1612 | SeRx=static_cast<int>(Mxp); |
||
1613 | Mxp=static_cast<int>(tmp); |
||
1614 | } |
||
1615 | if(Myp > SeRy) |
||
1616 | { |
||
1617 | double tmp=SeRy; |
||
1618 | SeRy=static_cast<int>(Myp); |
||
1619 | Myp=static_cast<int>(tmp); |
||
1620 | } |
||
3934 | cbradney | 1621 | currItem = Doc->selection->itemAt(0); |
456 | fschmid | 1622 | SelNode.clear(); |
1623 | 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)); |
||
1624 | FPointArray Clip; |
||
1625 | if (EditContour) |
||
1957 | cbradney | 1626 | Clip = currItem->ContourLine; |
456 | fschmid | 1627 | else |
1957 | cbradney | 1628 | Clip = currItem->PoLine; |
1884 | fschmid | 1629 | for (uint a = 0; a < Clip.size(); ++a) |
456 | fschmid | 1630 | { |
1631 | if (Clip.point(a).x() > 900000) |
||
1632 | continue; |
||
1633 | p.begin(viewport()); |
||
1957 | cbradney | 1634 | Transform(currItem, &p); |
456 | fschmid | 1635 | QPoint npf = p.xForm(Clip.pointQ(a)); |
1636 | p.end(); |
||
1637 | if ((Sele.contains(npf)) && ((a == 0) || (((a-2) % 4) == 0))) |
||
1638 | { |
||
1639 | ClRe = a; |
||
1640 | SelNode.append(a); |
||
1641 | emit ClipPo(Clip.point(a).x(), Clip.point(a).y()); |
||
1642 | } |
||
1643 | } |
||
1644 | HaveSelRect = false; |
||
2934 | fschmid | 1645 | if (EditContour) |
1646 | MarkClip(currItem, currItem->ContourLine, true); |
||
1647 | else |
||
1648 | MarkClip(currItem, currItem->PoLine, true); |
||
456 | fschmid | 1649 | return; |
1650 | } |
||
1651 | if ((Doc->EditClip) && (SegP1 == -1) && (SegP2 == -1)) |
||
1652 | { |
||
3934 | cbradney | 1653 | currItem = Doc->selection->itemAt(0); |
456 | fschmid | 1654 | if (Imoved) |
1655 | { |
||
3934 | cbradney | 1656 | currItem->OldB2 = currItem->width(); |
1657 | currItem->OldH2 = currItem->height(); |
||
2851 | fschmid | 1658 | double nx = m->x()/Scale + Doc->minCanvasCoordinate.x(); |
1659 | double ny = m->y()/Scale + Doc->minCanvasCoordinate.y(); |
||
456 | fschmid | 1660 | if (!ApplyGuides(&nx, &ny)) |
1661 | { |
||
3993 | cbradney | 1662 | FPoint npg(ApplyGridF(FPoint(nx, ny))); |
456 | fschmid | 1663 | nx = npg.x(); |
1664 | ny = npg.y(); |
||
1665 | } |
||
3934 | cbradney | 1666 | FPoint np(nx, ny, currItem->xPos(), currItem->yPos(), currItem->rotation(), 1, 1, true); |
1957 | cbradney | 1667 | MoveClipPoint(currItem, np); |
456 | fschmid | 1668 | } |
2934 | fschmid | 1669 | AdjustItemSize(currItem); |
4078 | fschmid | 1670 | emit DocChanged(); |
456 | fschmid | 1671 | updateContents(); |
1672 | Imoved = false; |
||
1673 | return; |
||
1674 | } |
||
1675 | if ((Doc->EditClip) && (SegP1 != -1) && (SegP2 != -1)) |
||
1676 | { |
||
1677 | SegP1 = -1; |
||
1678 | SegP2 = -1; |
||
3934 | cbradney | 1679 | currItem = Doc->selection->itemAt(0); |
456 | fschmid | 1680 | Imoved = false; |
2934 | fschmid | 1681 | AdjustItemSize(currItem); |
4078 | fschmid | 1682 | emit DocChanged(); |
456 | fschmid | 1683 | updateContents(); |
1684 | return; |
||
1685 | } |
||
2603 | cbradney | 1686 | if ((!GetItem(&currItem)) && (m->button() == RightButton) && (!Doc->DragP) && (Doc->appMode == modeNormal)) |
456 | fschmid | 1687 | { |
1688 | QPopupMenu *pmen = new QPopupMenu(); |
||
4026 | craig | 1689 | if (ScMW->Buffer2.startsWith("<SCRIBUSELEM")) |
456 | fschmid | 1690 | { |
1691 | Mxp = m->x(); |
||
1692 | Myp = m->y(); |
||
1693 | pmen->insertItem( tr("&Paste") , this, SLOT(PasteToPage())); |
||
1694 | pmen->insertSeparator(); |
||
1695 | } |
||
1461 | tsoots | 1696 | setObjectUndoMode(); |
4026 | craig | 1697 | ScMW->scrActions["editUndoAction"]->addTo(pmen); |
1698 | ScMW->scrActions["editRedoAction"]->addTo(pmen); |
||
1461 | tsoots | 1699 | pmen->insertSeparator(); |
4026 | craig | 1700 | ScMW->scrActions["viewShowMargins"]->addTo(pmen); |
1701 | ScMW->scrActions["viewShowFrames"]->addTo(pmen); |
||
1702 | ScMW->scrActions["viewShowImages"]->addTo(pmen); |
||
1703 | ScMW->scrActions["viewShowGrid"]->addTo(pmen); |
||
1704 | ScMW->scrActions["viewShowGuides"]->addTo(pmen); |
||
1705 | ScMW->scrActions["viewShowBaseline"]->addTo(pmen); |
||
1706 | ScMW->scrActions["viewShowTextChain"]->addTo(pmen); |
||
1707 | ScMW->scrActions["viewRulerMode"]->addTo(pmen); |
||
456 | fschmid | 1708 | pmen->insertSeparator(); |
2966 | fschmid | 1709 | // pmen->insertItem( tr("Unit"), unitSwitcher); |
1710 | // pmen->insertSeparator(); |
||
4026 | craig | 1711 | ScMW->scrActions["viewSnapToGrid"]->addTo(pmen); |
1712 | ScMW->scrActions["viewSnapToGuides"]->addTo(pmen); |
||
2872 | fschmid | 1713 | pmen->insertSeparator(); |
4026 | craig | 1714 | ScMW->scrActions["pageApplyMasterPage"]->addTo(pmen); |
1715 | ScMW->scrActions["pageManageGuides"]->addTo(pmen); |
||
1716 | ScMW->scrActions["pageManageMargins"]->addTo(pmen); |
||
456 | fschmid | 1717 | pmen->exec(QCursor::pos()); |
1461 | tsoots | 1718 | setGlobalUndoMode(); |
456 | fschmid | 1719 | delete pmen; |
3708 | cbradney | 1720 | pmen=NULL; |
456 | fschmid | 1721 | return; |
1722 | } |
||
2603 | cbradney | 1723 | if ((Doc->appMode != modeMagnifier) && (!Doc->EditClip) && (Doc->appMode != modeDrawBezierLine)) |
456 | fschmid | 1724 | { |
1957 | cbradney | 1725 | if ((GetItem(&currItem)) && (m->button() == RightButton) && (!Doc->DragP)) |
456 | fschmid | 1726 | { |
1727 | QPopupMenu *pmen = new QPopupMenu(); |
||
1728 | QPopupMenu *pmen2 = new QPopupMenu(); |
||
1729 | pmen3 = new QPopupMenu(); |
||
1730 | qApp->setOverrideCursor(QCursor(ArrowCursor), true); |
||
1731 | QPopupMenu *pmen4 = new QPopupMenu(); |
||
1732 | QPopupMenu *pmenLevel = new QPopupMenu(); |
||
1733 | QPopupMenu *pmenPDF = new QPopupMenu(); |
||
2173 | fschmid | 1734 | pmenResolution = new QPopupMenu(); |
1461 | tsoots | 1735 | setObjectUndoMode(); |
1957 | cbradney | 1736 | if ((currItem->itemType() == PageItem::TextFrame) || (currItem->itemType() == PageItem::ImageFrame) || (currItem->itemType() == PageItem::PathText)) |
456 | fschmid | 1737 | { |
1738 | QButtonGroup *InfoGroup = new QButtonGroup( this, "InfoGroup" ); |
||
1739 | InfoGroup->setFrameShape( QButtonGroup::NoFrame ); |
||
1740 | InfoGroup->setFrameShadow( QButtonGroup::Plain ); |
||
1741 | InfoGroup->setTitle(""); |
||
1742 | InfoGroup->setExclusive( true ); |
||
1743 | InfoGroup->setColumnLayout(0, Qt::Vertical ); |
||
1744 | InfoGroup->layout()->setSpacing( 0 ); |
||
1745 | InfoGroup->layout()->setMargin( 0 ); |
||
1746 | QGridLayout *InfoGroupLayout = new QGridLayout( InfoGroup->layout() ); |
||
1747 | InfoGroupLayout->setAlignment( Qt::AlignTop ); |
||
1748 | InfoGroupLayout->setSpacing( 2 ); |
||
1749 | InfoGroupLayout->setMargin( 0 ); |
||
1750 | QString txtC, txtC2; |
||
1751 | QLabel *InfoT = new QLabel(InfoGroup, "ct"); |
||
1752 | QLabel *ParCT = new QLabel(InfoGroup, "pt"); |
||
1753 | QLabel *ParC = new QLabel(InfoGroup, "pc"); |
||
1754 | QLabel *WordCT = new QLabel(InfoGroup, "wt"); |
||
1755 | QLabel *WordC = new QLabel(InfoGroup, "wc"); |
||
1756 | QLabel *CharCT = new QLabel(InfoGroup, "ct"); |
||
1757 | QLabel *CharC = new QLabel(InfoGroup, "cc"); |
||
3703 | fschmid | 1758 | QLabel *ColCT = new QLabel(InfoGroup, "ct"); |
1759 | QLabel *ColC = new QLabel(InfoGroup, "cc"); |
||
456 | fschmid | 1760 | QLabel *PrintCT = new QLabel(InfoGroup, "nt"); // <a.l.e> |
1761 | QLabel *PrintC = new QLabel(InfoGroup, "nc"); // </a.l.e> |
||
1957 | cbradney | 1762 | if (currItem->itemType() == PageItem::ImageFrame) |
456 | fschmid | 1763 | { |
1957 | cbradney | 1764 | QFileInfo fi = QFileInfo(currItem->Pfile); |
456 | fschmid | 1765 | InfoT->setText( tr("Picture")); |
1766 | InfoGroupLayout->addMultiCellWidget( InfoT, 0, 0, 0, 1, Qt::AlignCenter ); |
||
1767 | ParCT->setText( tr("File: ")); |
||
1768 | InfoGroupLayout->addWidget( ParCT, 1, 0, Qt::AlignRight ); |
||
1769 | ParC->setText(fi.fileName()); |
||
1770 | InfoGroupLayout->addWidget( ParC, 1, 1 ); |
||
1771 | WordCT->setText( tr("Original PPI: ")); |
||
1772 | InfoGroupLayout->addWidget( WordCT, 2, 0, Qt::AlignRight ); |
||
2004 | fschmid | 1773 | WordC->setText(txtC.setNum(qRound(currItem->pixm.imgInfo.xres))+" x "+txtC2.setNum(qRound(currItem->pixm.imgInfo.yres))); |
456 | fschmid | 1774 | InfoGroupLayout->addWidget( WordC, 2, 1 ); |
1775 | CharCT->setText( tr("Actual PPI: ")); |
||
1776 | &nb |