Rev 9646 | 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" |
||
8508 | cbradney | 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> |
||
8501 | cbradney | 33 | #include <q3pointarray.h> |
3 | paul | 34 | #include <qstringlist.h> |
8501 | cbradney | 35 | #include <q3dragobject.h> |
3 | paul | 36 | #include <qimage.h> |
8501 | cbradney | 37 | #include <q3cstring.h> |
173 | Franz | 38 | #include <qfileinfo.h> |
456 | fschmid | 39 | #include <qfile.h> |
8501 | cbradney | 40 | #include <q3ptrstack.h> |
41 | //Added by qt3to4: |
||
42 | #include <QWheelEvent> |
||
43 | #include <Q3PtrList> |
||
44 | #include <QPaintEvent> |
||
45 | #include <QDragMoveEvent> |
||
46 | #include <QDragLeaveEvent> |
||
47 | #include <Q3StrList> |
||
48 | #include <QLabel> |
||
49 | #include <QDropEvent> |
||
50 | #include <Q3PopupMenu> |
||
9514 | fschmid | 51 | #include <QMenu> |
8501 | cbradney | 52 | #include <QDragEnterEvent> |
53 | #include <Q3ValueList> |
||
54 | #include <QMouseEvent> |
||
55 | #include <Q3GridLayout> |
||
9380 | fschmid | 56 | #include <QImageReader> |
9514 | fschmid | 57 | #include <QWidgetAction> |
307 | Franz | 58 | #include <cmath> |
456 | fschmid | 59 | #include <cstdio> |
60 | #include <cstdlib> |
||
2702 | craig | 61 | |
62 | #ifdef HAVE_UNISTD_H |
||
456 | fschmid | 63 | #include <unistd.h> |
2702 | craig | 64 | #endif |
65 | |||
8501 | cbradney | 66 | #include <q3url.h> |
456 | fschmid | 67 | #include <qdir.h> |
68 | #include <qevent.h> |
||
2880 | fschmid | 69 | #include <qsizegrip.h> |
456 | fschmid | 70 | #if QT_VERSION > 0x030102 |
8501 | cbradney | 71 | #define SPLITVC Qt::SplitHCursor |
72 | #define SPLITHC Qt::SplitVCursor |
||
456 | fschmid | 73 | #else |
8501 | cbradney | 74 | #define SPLITVC Qt::SplitVCursor |
75 | #define SPLITHC Qt::SplitHCursor |
||
456 | fschmid | 76 | #endif |
181 | Franz | 77 | #include "scribus.h" |
8221 | fschmid | 78 | //#include "tree.h" |
456 | fschmid | 79 | #include "mpalette.h" |
80 | #include "scribusXml.h" |
||
3903 | cbradney | 81 | #include "selection.h" |
456 | fschmid | 82 | #include "serializer.h" |
83 | #include "insertTable.h" |
||
838 | cbradney | 84 | #include "hruler.h" |
85 | #include "vruler.h" |
||
1151 | fschmid | 86 | #include "filewatcher.h" |
1226 | tsoots | 87 | #include "undomanager.h" |
1525 | cbradney | 88 | #include "units.h" |
1633 | fschmid | 89 | #include "extimageprops.h" |
3695 | cbradney | 90 | #include "page.h" |
1655 | cbradney | 91 | #include "pageitemattributes.h" |
3625 | avox | 92 | #include "pageitem_imageframe.h" |
93 | #include "pageitem_line.h" |
||
94 | #include "pageitem_pathtext.h" |
||
95 | #include "pageitem_polygon.h" |
||
96 | #include "pageitem_polyline.h" |
||
97 | #include "pageitem_textframe.h" |
||
3053 | avox | 98 | #include "pageselector.h" |
1693 | craig | 99 | #include "scpaths.h" |
2103 | cbradney | 100 | #include "actionmanager.h" |
6566 | fschmid | 101 | #include <tiffio.h> |
102 | #include CMS_INC |
||
68 | Franz | 103 | |
3942 | cbradney | 104 | #include "scmessagebox.h" |
2529 | craig | 105 | #include "util.h" |
2495 | cbradney | 106 | #include "story.h" |
2834 | cbradney | 107 | #include "prefsmanager.h" |
7284 | fschmid | 108 | #include "prefscontext.h" |
109 | #include "prefsfile.h" |
||
2868 | fschmid | 110 | #include "rulermover.h" |
3252 | craig | 111 | #include "hyphenator.h" |
3510 | cbradney | 112 | #include "commonstrings.h" |
5087 | subik | 113 | #include "guidemanager.h" |
7296 | fschmid | 114 | #include "oneclick.h" |
5184 | avox | 115 | #include "text/nlsconfig.h" |
5827 | fschmid | 116 | #include "scrap.h" |
117 | #include "stencilreader.h" |
||
2495 | cbradney | 118 | |
504 | cbradney | 119 | using namespace std; |
120 | |||
3 | paul | 121 | |
3205 | craig | 122 | |
5781 | cbradney | 123 | ScribusView::ScribusView(QWidget* win, ScribusMainWindow* mw, ScribusDoc *doc) : |
8501 | cbradney | 124 | Q3ScrollView(win, "s", Qt::WNoAutoErase | Qt::WStaticContents), |
3981 | craig | 125 | Doc(doc), |
126 | Prefs(&(PrefsManager::instance()->appPrefs)), |
||
3982 | craig | 127 | undoManager(UndoManager::instance()), |
128 | OldScale(0), |
||
7575 | cbradney | 129 | dragX(0), dragY(0), dragW(0), dragH(0), |
3982 | craig | 130 | oldW(-1), oldCp(-1), |
131 | Mxp(-1), Myp(-1), Dxp(-1), Dyp(-1), |
||
4663 | cbradney | 132 | frameResizeHandle(-1), |
3982 | craig | 133 | SeRx(-1), SeRy(-1), GyM(-1), GxM(-1), |
134 | ClRe(-1), ClRe2(-1), |
||
135 | SegP1(-1), SegP2(-1), |
||
136 | RotMode(0), |
||
137 | DrHY(-1), DrVX(-1), |
||
138 | EdPoints(true), |
||
4705 | cbradney | 139 | m_MouseButtonPressed(false), |
4663 | cbradney | 140 | operItemMoving(false), |
3982 | craig | 141 | MoveGY(false), MoveGX(false), |
142 | HaveSelRect(false), |
||
4663 | cbradney | 143 | operItemResizing(false), |
3982 | craig | 144 | EditContour(false), |
4049 | cbradney | 145 | //GroupSel(false), |
3982 | craig | 146 | DraggedGroup(false), |
147 | DraggedGroupFirst(false), |
||
4663 | cbradney | 148 | operItemResizeInEditMode(false), |
3982 | craig | 149 | MidButt(false), |
150 | updateOn(true), |
||
151 | FirstPoly(true), |
||
152 | Magnify(false), |
||
153 | MoveSym(false), |
||
154 | previewMode(false), |
||
155 | RCenter(-1,-1), |
||
156 | RecordP(), |
||
157 | Ready(false), |
||
158 | oldX(0), oldY(0), |
||
159 | _groupTransactionStarted(false), |
||
160 | _isGlobalMode(true), |
||
161 | evSpon(false), |
||
162 | forceRedraw(false), |
||
4654 | cbradney | 163 | Scale(Prefs->DisScale), |
6191 | tsoots | 164 | oldClip(0), |
4704 | cbradney | 165 | m_vhRulerHW(17), |
5781 | cbradney | 166 | m_cursorVisible(false), |
167 | m_ScMW(mw) |
||
3 | paul | 168 | { |
8501 | cbradney | 169 | setHScrollBarMode(Q3ScrollView::AlwaysOn); |
170 | setVScrollBarMode(Q3ScrollView::AlwaysOn); |
||
4654 | cbradney | 171 | setMargins(m_vhRulerHW, m_vhRulerHW, 0, 0); |
3 | paul | 172 | setResizePolicy(Manual); |
8528 | cbradney | 173 | viewport()->setBackgroundMode(Qt::PaletteBackground); |
3 | paul | 174 | QFont fo = QFont(font()); |
2887 | fschmid | 175 | int posi = fo.pointSize()-2; |
176 | fo.setPointSize(posi); |
||
3689 | cbradney | 177 | unitSwitcher = new QComboBox( false, this, "unitSwitcher" ); |
8573 | jghali | 178 | unitSwitcher->setFocusPolicy(Qt::NoFocus); |
2887 | fschmid | 179 | unitSwitcher->setFont(fo); |
8700 | fschmid | 180 | int maxUindex = unitGetMaxIndex() - 2; |
181 | for (int i = 0; i <= maxUindex; ++i) |
||
2966 | fschmid | 182 | unitSwitcher->insertItem(unitGetStrFromIndex(i)); |
8707 | fschmid | 183 | zoomSpinBox = new ScrSpinBox( 10, 3200, this, 6 ); |
7884 | fschmid | 184 | zoomSpinBox->setTabAdvance(false); |
3309 | cbradney | 185 | zoomSpinBox->setFont(fo); |
186 | zoomSpinBox->setValue( 100 ); |
||
8141 | cbradney | 187 | zoomSpinBox->setLineStepM(10); |
8573 | jghali | 188 | zoomSpinBox->setFocusPolicy(Qt::ClickFocus); |
3309 | cbradney | 189 | zoomSpinBox->setSuffix( tr( " %" ) ); |
3053 | avox | 190 | #if OPTION_USE_QTOOLBUTTON |
191 | zoomOutToolbarButton = new QToolButton(this); |
||
3274 | fschmid | 192 | zoomDefaultToolbarButton = new QToolButton(this); |
3053 | avox | 193 | zoomInToolbarButton = new QToolButton(this); |
6726 | fschmid | 194 | cmsToolbarButton = new QToolButton(this); |
6549 | fschmid | 195 | previewToolbarButton = new QToolButton(this); |
3274 | fschmid | 196 | zoomDefaultToolbarButton->setAutoRaise(OPTION_FLAT_BUTTON); |
3053 | avox | 197 | zoomOutToolbarButton->setAutoRaise(OPTION_FLAT_BUTTON); |
198 | zoomInToolbarButton->setAutoRaise(OPTION_FLAT_BUTTON); |
||
6726 | fschmid | 199 | cmsToolbarButton->setAutoRaise(OPTION_FLAT_BUTTON); |
200 | cmsToolbarButton->setToggleButton(true); |
||
8501 | cbradney | 201 | QIcon ic2; |
8700 | fschmid | 202 | ic2.addPixmap(loadIcon("cmsOff.png"), QIcon::Normal, QIcon::Off); |
203 | ic2.addPixmap(loadIcon("cmsOn.png"), QIcon::Normal, QIcon::On); |
||
204 | cmsToolbarButton->setIcon(ic2); |
||
6549 | fschmid | 205 | previewToolbarButton->setAutoRaise(OPTION_FLAT_BUTTON); |
206 | previewToolbarButton->setToggleButton(true); |
||
8501 | cbradney | 207 | QIcon ic; |
8700 | fschmid | 208 | ic.addPixmap(loadIcon("previewOff.png"), QIcon::Normal, QIcon::Off); |
209 | ic.addPixmap(loadIcon("previewOn.png"), QIcon::Normal, QIcon::On); |
||
210 | previewToolbarButton->setIcon(ic); |
||
3053 | avox | 211 | #else |
3274 | fschmid | 212 | zoomDefaultToolbarButton = new QPushButton(this); |
8501 | cbradney | 213 | zoomDefaultToolbarButton->setFocusPolicy(Qt::NoFocus); |
3274 | fschmid | 214 | zoomDefaultToolbarButton->setDefault( false ); |
215 | zoomDefaultToolbarButton->setAutoDefault( false ); |
||
216 | zoomDefaultToolbarButton->setFlat(OPTION_FLAT_BUTTON); |
||
1822 | cbradney | 217 | zoomOutToolbarButton = new QPushButton(this); |
8501 | cbradney | 218 | zoomOutToolbarButton->setFocusPolicy(Qt::NoFocus); |
3053 | avox | 219 | zoomOutToolbarButton->setDefault( false ); |
220 | zoomOutToolbarButton->setAutoDefault( false ); |
||
221 | zoomOutToolbarButton->setFlat(OPTION_FLAT_BUTTON); |
||
3274 | fschmid | 222 | zoomInToolbarButton = new QPushButton(this); |
8501 | cbradney | 223 | zoomInToolbarButton->setFocusPolicy(Qt::NoFocus); |
3053 | avox | 224 | zoomInToolbarButton->setDefault( false ); |
225 | zoomInToolbarButton->setAutoDefault( false ); |
||
226 | zoomInToolbarButton->setFlat(OPTION_FLAT_BUTTON); |
||
6549 | fschmid | 227 | previewToolbarButton = new QPushButton(this); |
8501 | cbradney | 228 | cmsToolbarButton->setFocusPolicy(Qt::NoFocus); |
6726 | fschmid | 229 | cmsToolbarButton->setDefault( false ); |
230 | cmsToolbarButton->setAutoDefault( false ); |
||
231 | cmsToolbarButton->setFlat(OPTION_FLAT_BUTTON); |
||
232 | cmsToolbarButton->setPixmap(loadIcon("cmsOn.png")); |
||
233 | previewToolbarButton = new QPushButton(this); |
||
8501 | cbradney | 234 | previewToolbarButton->setFocusPolicy(Qt::NoFocus); |
6549 | fschmid | 235 | previewToolbarButton->setDefault( false ); |
236 | previewToolbarButton->setAutoDefault( false ); |
||
237 | previewToolbarButton->setFlat(OPTION_FLAT_BUTTON); |
||
238 | previewToolbarButton->setPixmap(loadIcon("previewOn.png")); |
||
3053 | avox | 239 | #endif |
5287 | cbradney | 240 | //zoomDefaultToolbarButton->setText("1:1"); |
241 | zoomDefaultToolbarButton->setPixmap(loadIcon("16/zoom-original.png")); |
||
242 | zoomOutToolbarButton->setPixmap(loadIcon("16/zoom-out.png")); |
||
243 | zoomInToolbarButton->setPixmap(loadIcon("16/zoom-in.png")); |
||
7651 | cbradney | 244 | pageSelector = new PageSelector(this, Doc->Pages->count()); |
3309 | cbradney | 245 | pageSelector->setFont(fo); |
8573 | jghali | 246 | pageSelector->setFocusPolicy(Qt::ClickFocus); |
3309 | cbradney | 247 | layerMenu = new QComboBox( true, this, "LY" ); |
248 | layerMenu->setEditable(false); |
||
249 | layerMenu->setFont(fo); |
||
8573 | jghali | 250 | layerMenu->setFocusPolicy(Qt::NoFocus); |
6549 | fschmid | 251 | visualMenu = new QComboBox( false, this, "visualMenu" ); |
8573 | jghali | 252 | visualMenu->setFocusPolicy(Qt::NoFocus); |
6549 | fschmid | 253 | visualMenu->setFont(fo); |
254 | visualMenu->setEnabled(false); |
||
1612 | cbradney | 255 | horizRuler = new Hruler(this, Doc); |
256 | vertRuler = new Vruler(this, Doc); |
||
3309 | cbradney | 257 | rulerMover = new RulerMover(this); |
8573 | jghali | 258 | rulerMover->setFocusPolicy(Qt::NoFocus); |
3 | paul | 259 | Ready = true; |
456 | fschmid | 260 | viewport()->setMouseTracking(true); |
261 | setAcceptDrops(true); |
||
262 | viewport()->setAcceptDrops(true); |
||
263 | setDragAutoScroll(false); |
||
264 | Doc->DragP = false; |
||
265 | Doc->leaveDrag = false; |
||
1330 | fschmid | 266 | Doc->SubMode = -1; |
5237 | fschmid | 267 | storedFramesShown = Doc->guidesSettings.framesShown; |
7624 | fschmid | 268 | storedShowControls = Doc->guidesSettings.showControls; |
5235 | fschmid | 269 | viewAsPreview = false; |
6549 | fschmid | 270 | previewVisual = 0; |
6349 | fschmid | 271 | shiftSelItems = false; |
7284 | fschmid | 272 | inItemCreation = false; |
8720 | fschmid | 273 | redrawMode = 0; |
274 | redrawCount = 0; |
||
8994 | fschmid | 275 | redrawMarker = new QRubberBand(QRubberBand::Rectangle); |
8720 | fschmid | 276 | redrawMarker->hide(); |
9041 | fschmid | 277 | redrawPolygon.clear(); |
9431 | fschmid | 278 | specialRendering = false; |
279 | firstSpecial = false; |
||
280 | m_buffer = QPixmap(); |
||
7587 | cbradney | 281 | m_ScMW->scrActions["viewFitPreview"]->setOn(viewAsPreview); |
6477 | fschmid | 282 | m_SnapCounter = 0; |
1822 | cbradney | 283 | connect(zoomOutToolbarButton, SIGNAL(clicked()), this, SLOT(slotZoomOut())); |
284 | connect(zoomInToolbarButton, SIGNAL(clicked()), this, SLOT(slotZoomIn())); |
||
3274 | fschmid | 285 | connect(zoomDefaultToolbarButton, SIGNAL(clicked()), this, SLOT(slotZoom100())); |
8705 | fschmid | 286 | connect(zoomSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setZoom())); |
3309 | cbradney | 287 | connect(pageSelector, SIGNAL(GotoPage(int)), this, SLOT(GotoPa(int))); |
288 | connect(layerMenu, SIGNAL(activated(int)), this, SLOT(GotoLa(int))); |
||
2966 | fschmid | 289 | connect(unitSwitcher, SIGNAL(activated(int)), this, SLOT(ChgUnit(int))); |
6549 | fschmid | 290 | connect(previewToolbarButton, SIGNAL(clicked()), this, SLOT(togglePreview())); |
6726 | fschmid | 291 | connect(cmsToolbarButton, SIGNAL(clicked()), this, SLOT(toggleCMS())); |
6549 | fschmid | 292 | connect(visualMenu, SIGNAL(activated(int)), this, SLOT(switchPreviewVisual(int))); |
3 | paul | 293 | connect(this, SIGNAL(contentsMoving(int, int)), this, SLOT(setRulerPos(int, int))); |
1443 | tsoots | 294 | connect(this, SIGNAL(HaveSel(int)), this, SLOT(selectionChanged())); |
6549 | fschmid | 295 | languageChange(); |
9668 | fschmid | 296 | dragTimer = new QTimer(this); |
297 | connect(dragTimer, SIGNAL(timeout()), this, SLOT(dragTimerTimeOut())); |
||
298 | dragTimer->stop(); |
||
299 | dragTimerFired = false; |
||
3 | paul | 300 | } |
301 | |||
2199 | cbradney | 302 | void ScribusView::languageChange() |
303 | { |
||
6758 | fschmid | 304 | QToolTip::remove(cmsToolbarButton); |
305 | QToolTip::remove(previewToolbarButton); |
||
306 | QToolTip::remove(visualMenu); |
||
6769 | cbradney | 307 | QToolTip::add(cmsToolbarButton, tr("Switches Color Management on or off")); |
6758 | fschmid | 308 | QToolTip::add(previewToolbarButton, tr("Enables the Preview Mode")); |
309 | QToolTip::add(visualMenu, tr("Here you can select the visual appearance of the display\nYou can choose between normal and several color blindness forms")); |
||
6549 | fschmid | 310 | disconnect(visualMenu, SIGNAL(activated(int)), this, SLOT(switchPreviewVisual(int))); |
311 | visualMenu->clear(); |
||
7167 | cbradney | 312 | visualMenu->insertItem(CommonStrings::trVisionNormal); |
313 | visualMenu->insertItem(CommonStrings::trVisionProtanopia); |
||
314 | visualMenu->insertItem(CommonStrings::trVisionDeuteranopia); |
||
315 | visualMenu->insertItem(CommonStrings::trVisionTritanopia); |
||
316 | visualMenu->insertItem(CommonStrings::trVisionFullColorBlind); |
||
6549 | fschmid | 317 | visualMenu->setCurrentItem(previewVisual); |
318 | connect(visualMenu, SIGNAL(activated(int)), this, SLOT(switchPreviewVisual(int))); |
||
2199 | cbradney | 319 | } |
320 | |||
6726 | fschmid | 321 | void ScribusView::toggleCMS() |
322 | { |
||
323 | Doc->enableCMS(!Doc->HasCMS); |
||
324 | updateContents(); |
||
325 | } |
||
326 | |||
6549 | fschmid | 327 | void ScribusView::switchPreviewVisual(int vis) |
328 | { |
||
329 | previewVisual = vis; |
||
330 | Doc->recalculateColors(); |
||
331 | Doc->recalcPicturesRes(); |
||
332 | updateContents(); |
||
333 | } |
||
334 | |||
5235 | fschmid | 335 | void ScribusView::togglePreview() |
336 | { |
||
337 | viewAsPreview = !viewAsPreview; |
||
5237 | fschmid | 338 | if (viewAsPreview) |
339 | { |
||
340 | storedFramesShown = Doc->guidesSettings.framesShown; |
||
341 | Doc->guidesSettings.framesShown = false; |
||
7624 | fschmid | 342 | storedShowControls = Doc->guidesSettings.showControls; |
343 | Doc->guidesSettings.showControls = false; |
||
6802 | subik | 344 | // warning popping up in case colour management and out-of-gamut-display are active |
345 | // as from #4346: Add a preview for daltonian - PV |
||
7141 | fschmid | 346 | if (Doc->HasCMS && Doc->Gamut) |
7400 | cbradney | 347 | QMessageBox::information(m_ScMW, tr("Preview Mode"), |
348 | "<qt>" + tr("CMS is active. Therefore the color display may not match the perception by visually impaired") + "</qt>", |
||
349 | QMessageBox::Ok); |
||
5237 | fschmid | 350 | } |
351 | else |
||
7624 | fschmid | 352 | { |
5237 | fschmid | 353 | Doc->guidesSettings.framesShown = storedFramesShown; |
7624 | fschmid | 354 | Doc->guidesSettings.showControls = storedShowControls; |
355 | } |
||
7587 | cbradney | 356 | m_ScMW->scrActions["viewFitPreview"]->setOn(viewAsPreview); |
5781 | cbradney | 357 | m_ScMW->scrActions["viewShowMargins"]->setEnabled(!viewAsPreview); |
358 | m_ScMW->scrActions["viewShowFrames"]->setEnabled(!viewAsPreview); |
||
359 | m_ScMW->scrActions["viewShowLayerMarkers"]->setEnabled(!viewAsPreview); |
||
360 | m_ScMW->scrActions["viewShowGrid"]->setEnabled(!viewAsPreview); |
||
361 | m_ScMW->scrActions["viewShowGuides"]->setEnabled(!viewAsPreview); |
||
362 | m_ScMW->scrActions["viewShowColumnBorders"]->setEnabled(!viewAsPreview); |
||
363 | m_ScMW->scrActions["viewShowBaseline"]->setEnabled(!viewAsPreview); |
||
364 | m_ScMW->scrActions["viewShowTextChain"]->setEnabled(!viewAsPreview); |
||
365 | m_ScMW->scrActions["viewShowTextControls"]->setEnabled(!viewAsPreview); |
||
6549 | fschmid | 366 | #if OPTION_USE_QTOOLBUTTON |
367 | previewToolbarButton->setOn(viewAsPreview); |
||
368 | #endif |
||
369 | visualMenu->setEnabled(viewAsPreview); |
||
370 | Doc->recalculateColors(); |
||
371 | Doc->recalcPicturesRes(); |
||
5235 | fschmid | 372 | updateContents(); |
373 | } |
||
374 | |||
2171 | fschmid | 375 | void ScribusView::viewportPaintEvent ( QPaintEvent * p ) |
376 | { |
||
4011 | cbradney | 377 | #ifndef _WIN32 |
2171 | fschmid | 378 | if (p->spontaneous()) |
379 | evSpon = true; |
||
4011 | cbradney | 380 | #endif |
8501 | cbradney | 381 | Q3ScrollView::viewportPaintEvent(p); |
2171 | fschmid | 382 | } |
383 | |||
5373 | fschmid | 384 | void ScribusView::drawContents(QPainter *psx, int clipx, int clipy, int clipw, int cliph) |
456 | fschmid | 385 | { |
2891 | cbradney | 386 | if (Doc->isLoading()) |
456 | fschmid | 387 | return; |
388 | if (!updateOn) |
||
389 | return; |
||
390 | // QTime tim; |
||
391 | // tim.start(); |
||
392 | if ((clipw > 0) && (cliph > 0)) |
||
393 | { |
||
9431 | fschmid | 394 | |
395 | if ((specialRendering) || (Doc->EditClip && specialRendering)) |
||
396 | { |
||
397 | if (firstSpecial) |
||
398 | { |
||
399 | m_buffer = QPixmap::grabWindow(viewport()->winId(), 0, 0); |
||
400 | firstSpecial = false; |
||
401 | } |
||
402 | QPainter pp; |
||
403 | QPixmap ppx = m_buffer; |
||
404 | pp.begin(&ppx); |
||
405 | pp.setRenderHint(QPainter::Antialiasing, true); |
||
9441 | fschmid | 406 | if (redrawMode == 1) |
407 | { |
||
408 | pp.resetMatrix(); |
||
409 | pp.setBrush(Qt::NoBrush); |
||
410 | pp.setPen(QPen(Qt::black, 1.0, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin)); |
||
411 | QPoint nXY = redrawPolygon.point(0); |
||
412 | pp.drawLine(0, nXY.y(), viewport()->width(), nXY.y()); |
||
413 | pp.drawLine(nXY.x(), 0, nXY.x(), viewport()->height()); |
||
414 | redrawPolygon.clear(); |
||
415 | } |
||
9434 | fschmid | 416 | if ((Doc->appMode == modeDrawBezierLine) && (!redrawPolygon.isEmpty()) && (Doc->m_Selection->count() != 0)) |
417 | { |
||
418 | pp.setBrush(Qt::NoBrush); |
||
419 | pp.setPen(QPen(Qt::black, 1.0 / Scale, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin)); |
||
420 | pp.resetMatrix(); |
||
421 | QPoint out = contentsToViewport(QPoint(0, 0)); |
||
422 | pp.translate(out.x(), out.y()); |
||
423 | pp.translate(-qRound(Doc->minCanvasCoordinate.x()*Scale), -qRound(Doc->minCanvasCoordinate.y()*Scale)); |
||
424 | PageItem *currItem = Doc->m_Selection->itemAt(0); |
||
425 | Transform(currItem, &pp); |
||
426 | Q3PointArray Bez(4); |
||
427 | if (currItem->PoLine.size() > 1) |
||
428 | { |
||
429 | QPoint nXY = redrawPolygon.point(0); |
||
430 | if (!m_MouseButtonPressed) |
||
431 | { |
||
432 | QPoint a1 = currItem->PoLine.pointQ(currItem->PoLine.size()-2); |
||
433 | QPoint a2 = currItem->PoLine.pointQ(currItem->PoLine.size()-1); |
||
434 | BezierPoints(&Bez, a1, a2, nXY, nXY); |
||
435 | pp.drawCubicBezier(Bez); |
||
436 | } |
||
437 | else |
||
438 | { |
||
439 | QPoint a2 = currItem->PoLine.pointQ(currItem->PoLine.size()-1); |
||
440 | if (currItem->PoLine.size() > 2) |
||
441 | { |
||
442 | QPoint a1 = currItem->PoLine.pointQ(currItem->PoLine.size()-2); |
||
443 | QPoint a3 = currItem->PoLine.pointQ(currItem->PoLine.size()-3); |
||
444 | BezierPoints(&Bez, a3, a1, nXY, a2); |
||
445 | pp.drawCubicBezier(Bez); |
||
446 | } |
||
447 | pp.drawLine(a2, nXY); |
||
448 | } |
||
449 | } |
||
450 | else |
||
451 | { |
||
452 | QPoint a2 = currItem->PoLine.pointQ(currItem->PoLine.size()-1); |
||
453 | QPoint nXY = redrawPolygon.point(0); |
||
454 | pp.drawLine(a2, nXY); |
||
455 | } |
||
456 | redrawPolygon.clear(); |
||
457 | } |
||
9441 | fschmid | 458 | if (m_MouseButtonPressed && (Doc->appMode == modeMeasurementTool)) |
9431 | fschmid | 459 | { |
460 | pp.resetMatrix(); |
||
461 | QPoint out = contentsToViewport(QPoint(0, 0)); |
||
462 | pp.translate(out.x(), out.y()); |
||
9441 | fschmid | 463 | pp.setBrush(Qt::NoBrush); |
464 | pp.setPen(QPen(Qt::black, 1.0, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin)); |
||
465 | pp.drawPolyline(redrawPolygon); |
||
466 | redrawPolygon.clear(); |
||
467 | } |
||
468 | if (m_MouseButtonPressed && (Doc->appMode == modeDrawLine)) |
||
469 | { |
||
470 | QPoint out = contentsToViewport(QPoint(0, 0)); |
||
471 | pp.resetMatrix(); |
||
472 | pp.translate(out.x(), out.y()); |
||
9431 | fschmid | 473 | pp.translate(-qRound(Doc->minCanvasCoordinate.x()*Scale), -qRound(Doc->minCanvasCoordinate.y()*Scale)); |
9441 | fschmid | 474 | pp.scale(Scale, Scale); |
9431 | fschmid | 475 | pp.setBrush(Qt::NoBrush); |
476 | pp.setPen(QPen(Qt::black, 1.0 / Scale, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin)); |
||
477 | pp.drawPolyline(redrawPolygon); |
||
478 | redrawPolygon.clear(); |
||
479 | } |
||
480 | if (operItemMoving || operItemResizing) |
||
481 | { |
||
482 | if (operItemResizing) |
||
483 | { |
||
484 | if (!redrawPolygon.isEmpty()) |
||
485 | { |
||
486 | if (m_MouseButtonPressed && (Doc->appMode == modeDrawFreehandLine)) |
||
487 | { |
||
488 | pp.resetMatrix(); |
||
489 | QPoint out = contentsToViewport(QPoint(0, 0)); |
||
490 | pp.translate(out.x(), out.y()); |
||
491 | pp.translate(-qRound(Doc->minCanvasCoordinate.x()*Scale), -qRound(Doc->minCanvasCoordinate.y()*Scale)); |
||
492 | pp.scale(Scale, Scale); |
||
493 | pp.setBrush(Qt::NoBrush); |
||
494 | pp.setPen(QPen(Qt::black, 1.0 / Scale, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin)); |
||
495 | pp.drawPolyline(redrawPolygon); |
||
496 | redrawPolygon.clear(); |
||
497 | } |
||
498 | else |
||
499 | { |
||
500 | QColor drawColor = qApp->palette().color(QPalette::Active, QColorGroup::Highlight); |
||
501 | pp.setPen(QPen(drawColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); |
||
502 | drawColor.setAlpha(64); |
||
503 | pp.resetMatrix(); |
||
504 | QPoint out = contentsToViewport(QPoint(0, 0)); |
||
505 | pp.translate(out.x(), out.y()); |
||
9441 | fschmid | 506 | // pp.translate(-qRound(Doc->minCanvasCoordinate.x()*Scale), -qRound(Doc->minCanvasCoordinate.y()*Scale)); |
9431 | fschmid | 507 | pp.setBrush(drawColor); |
508 | pp.drawPolygon(redrawPolygon); |
||
509 | redrawPolygon.clear(); |
||
510 | } |
||
511 | } |
||
512 | } |
||
513 | else |
||
514 | { |
||
515 | if (Doc->m_Selection->count() != 0) |
||
516 | { |
||
517 | uint selectedItemCount = Doc->m_Selection->count(); |
||
518 | PageItem *currItem = Doc->m_Selection->itemAt(0); |
||
519 | if (selectedItemCount < moveWithBoxesOnlyThreshold) |
||
520 | { |
||
521 | for (uint cu = 0; cu < selectedItemCount; cu++) |
||
522 | { |
||
523 | currItem = Doc->m_Selection->itemAt(cu); |
||
524 | pp.resetMatrix(); |
||
525 | QPoint out = contentsToViewport(QPoint(0, 0)); |
||
526 | pp.translate(out.x(), out.y()); |
||
527 | pp.translate(-qRound(Doc->minCanvasCoordinate.x()*Scale), -qRound(Doc->minCanvasCoordinate.y()*Scale)); |
||
528 | Transform(currItem, &pp); |
||
529 | pp.setBrush(Qt::NoBrush); |
||
530 | pp.setPen(QPen(Qt::black, 1.0 / Scale, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin)); |
||
531 | if (selectedItemCount < moveWithFullOutlinesThreshold) |
||
532 | { |
||
533 | if (!(currItem->asLine())) |
||
534 | currItem->DrawPolyL(&pp, currItem->Clip); |
||
535 | else |
||
536 | { |
||
537 | if (currItem->asLine()) |
||
538 | { |
||
539 | int lw2 = 1; |
||
540 | int lw = 1; |
||
541 | Qt::PenCapStyle le = Qt::FlatCap; |
||
542 | if (currItem->NamedLStyle.isEmpty()) |
||
543 | { |
||
544 | lw2 = qRound(currItem->lineWidth() / 2.0); |
||
545 | lw = qRound(qMax(currItem->lineWidth(), 1.0)); |
||
546 | le = currItem->PLineEnd; |
||
547 | } |
||
548 | else |
||
549 | { |
||
550 | multiLine ml = Doc->MLineStyles[currItem->NamedLStyle]; |
||
551 | lw2 = qRound(ml[ml.size()-1].Width / 2.0); |
||
552 | lw = qRound(qMax(ml[ml.size()-1].Width, 1.0)); |
||
553 | le = static_cast<Qt::PenCapStyle>(ml[ml.size()-1].LineEnd); |
||
554 | } |
||
555 | if (le != Qt::FlatCap) |
||
556 | pp.drawRect(-lw2, -lw2, qRound(currItem->width())+lw, lw); |
||
557 | else |
||
558 | pp.drawRect(-1, -lw2, qRound(currItem->width()), lw); |
||
559 | } |
||
560 | } |
||
561 | } |
||
562 | else |
||
563 | pp.drawRect(0, 0, static_cast<int>(currItem->width())+1, static_cast<int>(currItem->height())+1); |
||
564 | } |
||
565 | } |
||
566 | else |
||
567 | { |
||
568 | double gx, gy, gw, gh; |
||
569 | Doc->m_Selection->setGroupRect(); |
||
570 | Doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh); |
||
571 | QPoint out = contentsToViewport(QPoint(0, 0)); |
||
572 | pp.resetMatrix(); |
||
573 | pp.translate(out.x(), out.y()); |
||
574 | pp.translate(-qRound(Doc->minCanvasCoordinate.x()*Scale), -qRound(Doc->minCanvasCoordinate.y()*Scale)); |
||
575 | pp.scale(Scale, Scale); |
||
576 | pp.translate(qRound(gx), qRound(gy)); |
||
577 | pp.drawRect(QRect(0, 0, qRound(gw), qRound(gh))); |
||
578 | } |
||
579 | } |
||
580 | } |
||
581 | } |
||
582 | else |
||
583 | { |
||
9434 | fschmid | 584 | if ((Doc->m_Selection->count() != 0) && (Doc->appMode != modeDrawBezierLine)) |
9431 | fschmid | 585 | { |
586 | PageItem *currItem = Doc->m_Selection->itemAt(0); |
||
587 | if ((Doc->EditClip) && (currItem->isSelected())) |
||
588 | { |
||
589 | if (EditContour) |
||
590 | MarkClip(&pp, currItem, currItem->ContourLine, true); |
||
591 | else |
||
592 | MarkClip(&pp, currItem, currItem->PoLine, true); |
||
593 | } |
||
594 | else |
||
595 | { |
||
596 | if (Doc->m_Selection->isMultipleSelection()) |
||
597 | { |
||
598 | pp.resetMatrix(); |
||
599 | QPoint out = contentsToViewport(QPoint(0, 0)); |
||
600 | pp.translate(out.x(), out.y()); |
||
601 | pp.translate(-qRound(Doc->minCanvasCoordinate.x()*Scale), -qRound(Doc->minCanvasCoordinate.y()*Scale)); |
||
602 | double x, y, w, h; |
||
603 | Doc->m_Selection->setGroupRect(); |
||
604 | Doc->m_Selection->getGroupRect(&x, &y, &w, &h); |
||
605 | x *= Scale; |
||
606 | y *= Scale; |
||
607 | w *= Scale; |
||
608 | h *= Scale; |
||
609 | pp.setPen(QPen(Qt::red, 1, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin)); |
||
610 | pp.setBrush(Qt::NoBrush); |
||
611 | pp.drawRect(QRectF(x, y, w, h)); |
||
612 | pp.setBrush(Qt::red); |
||
613 | pp.setPen(QPen(Qt::red, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); |
||
614 | pp.drawRect(QRectF(x+w-6, y+h-6, 6, 6)); |
||
615 | pp.drawRect(QRectF(x+w/2 - 3, y+h-6, 6, 6)); |
||
616 | pp.drawRect(QRectF(x+w/2 - 3, y, 6, 6)); |
||
617 | pp.drawRect(QRectF(x+w-6, y+h/2 - 3, 6, 6)); |
||
618 | pp.drawRect(QRectF(x+w-6, y, 6, 6)); |
||
619 | pp.drawRect(QRectF(x, y, 6, 6)); |
||
620 | pp.drawRect(QRectF(x, y+h/2 - 3, 6, 6)); |
||
621 | pp.drawRect(QRectF(x, y+h-6, 6, 6)); |
||
622 | } |
||
623 | else |
||
624 | { |
||
625 | pp.resetMatrix(); |
||
626 | QPoint out = contentsToViewport(QPoint(0, 0)); |
||
627 | pp.translate(out.x(), out.y()); |
||
628 | pp.translate(-qRound(Doc->minCanvasCoordinate.x()*Scale), -qRound(Doc->minCanvasCoordinate.y()*Scale)); |
||
629 | Transform(currItem, &pp); |
||
630 | currItem->paintObj(&pp); |
||
631 | } |
||
632 | } |
||
633 | } |
||
634 | } |
||
635 | pp.end(); |
||
636 | psx->resetMatrix(); |
||
637 | psx->drawPixmap(0, 0, ppx); |
||
638 | return; |
||
639 | } |
||
640 | |||
3313 | cbradney | 641 | QPoint vr = contentsToViewport(QPoint(clipx, clipy)); |
7643 | cbradney | 642 | ScPainter *painter=0; |
9319 | fschmid | 643 | QImage img = QImage(clipw, cliph, QImage::Format_ARGB32); |
5746 | fschmid | 644 | painter = new ScPainter(&img, img.width(), img.height(), 1.0, 0); |
7141 | fschmid | 645 | painter->clear(paletteBackgroundColor()); |
7290 | fschmid | 646 | painter->newPath(); |
647 | painter->moveTo(0, 0); |
||
648 | painter->lineTo(clipw, 0); |
||
649 | painter->lineTo(clipw, cliph); |
||
650 | painter->lineTo(0, cliph); |
||
651 | painter->closePath(); |
||
652 | painter->setClipPath(); |
||
7141 | fschmid | 653 | painter->translate(-clipx, -clipy); |
654 | painter->setZoomFactor(Scale); |
||
655 | painter->translate(-Doc->minCanvasCoordinate.x(), -Doc->minCanvasCoordinate.y()); |
||
656 | painter->setLineWidth(1); |
||
657 | painter->setFillMode(ScPainter::Solid); |
||
456 | fschmid | 658 | /* Draw Page Outlines */ |
3724 | cbradney | 659 | if (!Doc->masterPageMode()) |
456 | fschmid | 660 | { |
3724 | cbradney | 661 | uint docPagesCount=Doc->Pages->count(); |
7221 | fschmid | 662 | if (!viewAsPreview) |
663 | { |
||
664 | painter->setBrush(QColor(128,128,128)); |
||
665 | painter->setAntialiasing(false); |
||
666 | painter->beginLayer(1.0, 0); |
||
8501 | cbradney | 667 | painter->setPen(Qt::black, 1.0 / Scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
8703 | fschmid | 668 | Page *actPg; |
7221 | fschmid | 669 | for (int a = 0; a < static_cast<int>(docPagesCount); ++a) |
670 | { |
||
8703 | fschmid | 671 | actPg = Doc->Pages->at(a); |
7221 | fschmid | 672 | double bleedRight = 0.0; |
673 | double bleedLeft = 0.0; |
||
674 | double bleedBottom = 0.0; |
||
675 | double bleedTop = 0.0; |
||
8703 | fschmid | 676 | Doc->getBleeds(actPg, &bleedTop, &bleedBottom, &bleedLeft, &bleedRight); |
677 | double blx = (actPg->xOffset() - bleedLeft) * Scale; |
||
678 | double bly = (actPg->yOffset() - bleedTop) * Scale; |
||
679 | double blw = (actPg->width() + bleedLeft + bleedRight) * Scale; |
||
680 | double blh = (actPg->height() + bleedBottom + bleedTop) * Scale; |
||
7221 | fschmid | 681 | |
8703 | fschmid | 682 | QRectF drawRect = QRectF(blx-1, bly-1, blw+6, blh+6); |
683 | drawRect.translate(-Doc->minCanvasCoordinate.x() * Scale, -Doc->minCanvasCoordinate.y() * Scale); |
||
684 | if (drawRect.intersects(QRectF(clipx, clipy, clipw, cliph))) |
||
7221 | fschmid | 685 | { |
686 | painter->setFillMode(ScPainter::Solid); |
||
8703 | fschmid | 687 | double blx2 = actPg->xOffset(); |
688 | double bly2 = actPg->yOffset(); |
||
689 | double blw2 = actPg->width(); |
||
690 | double blh2 = actPg->height(); |
||
7221 | fschmid | 691 | if (Doc->guidesSettings.showBleed) |
692 | { |
||
8703 | fschmid | 693 | blx2 -= bleedLeft; |
694 | bly2 -= bleedTop; |
||
695 | blw2 += bleedLeft + bleedRight; |
||
696 | blh2 += bleedBottom + bleedTop; |
||
7221 | fschmid | 697 | } |
698 | painter->drawRect(blx2 + 5 / Scale, bly2 + 5 / Scale, blw2, blh2); |
||
7225 | cbradney | 699 | if (((Doc->bleeds.Bottom != 0.0) || (Doc->bleeds.Top != 0.0) || (Doc->bleeds.Left != 0.0) || (Doc->bleeds.Right != 0.0)) && (Doc->guidesSettings.showBleed)) |
7221 | fschmid | 700 | { |
701 | painter->setFillMode(ScPainter::None); |
||
8501 | cbradney | 702 | painter->setPen(Qt::black, 1.0 / Scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
7221 | fschmid | 703 | painter->drawRect(blx2, bly2 - 1 / Scale, blw2 + 1 / Scale, blh2 + 2 / Scale); |
704 | } |
||
705 | } |
||
706 | } |
||
7760 | fschmid | 707 | painter->endLayer(); |
7221 | fschmid | 708 | painter->setAntialiasing(true); |
709 | } |
||
710 | painter->setFillMode(ScPainter::Solid); |
||
8703 | fschmid | 711 | Page *actPg; |
5664 | fschmid | 712 | for (int a = 0; a < static_cast<int>(docPagesCount); ++a) |
456 | fschmid | 713 | { |
8703 | fschmid | 714 | actPg = Doc->Pages->at(a); |
715 | double x = actPg->xOffset(); |
||
716 | double y = actPg->yOffset(); |
||
717 | double w = actPg->width(); |
||
718 | double h = actPg->height(); |
||
7051 | fschmid | 719 | double bleedRight = 0.0; |
720 | double bleedLeft = 0.0; |
||
721 | double bleedBottom = 0.0; |
||
722 | double bleedTop = 0.0; |
||
6922 | fschmid | 723 | bool drawBleed = false; |
7225 | cbradney | 724 | if (((Doc->bleeds.Bottom != 0.0) || (Doc->bleeds.Top != 0.0) || (Doc->bleeds.Left != 0.0) || (Doc->bleeds.Right != 0.0)) && (Doc->guidesSettings.showBleed)) |
7051 | fschmid | 725 | { |
6922 | fschmid | 726 | drawBleed = true; |
7157 | fschmid | 727 | Doc->getBleeds(a, &bleedTop, &bleedBottom, &bleedLeft, &bleedRight); |
6922 | fschmid | 728 | } |
8703 | fschmid | 729 | double blx = (actPg->xOffset() - bleedLeft) * Scale; |
730 | double bly = (actPg->yOffset() - bleedTop) * Scale; |
||
731 | double blw = (actPg->width() + bleedLeft + bleedRight) * Scale; |
||
732 | double blh = (actPg->height() + bleedBottom + bleedTop) * Scale; |
||
6922 | fschmid | 733 | |
8703 | fschmid | 734 | QRectF drawRect = QRectF(blx, bly, blw+5, blh+5); |
735 | drawRect.translate(-Doc->minCanvasCoordinate.x() * Scale, -Doc->minCanvasCoordinate.y() * Scale); |
||
736 | if (drawRect.intersects(QRectF(clipx, clipy, clipw, cliph))) |
||
456 | fschmid | 737 | { |
7141 | fschmid | 738 | painter->setFillMode(ScPainter::Solid); |
8522 | cbradney | 739 | painter->setPen(Qt::black, 0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
7760 | fschmid | 740 | painter->setAntialiasing(false); |
5752 | fschmid | 741 | painter->beginLayer(1.0, 0); |
7157 | fschmid | 742 | painter->setLineWidth(0.0); |
5664 | fschmid | 743 | painter->setBrush(Doc->papColor); |
6922 | fschmid | 744 | if (!viewAsPreview) |
745 | { |
||
8703 | fschmid | 746 | double blx2 = actPg->xOffset() - bleedLeft; |
747 | double bly2 = actPg->yOffset() - bleedTop; |
||
748 | double blw2 = actPg->width() + bleedLeft + bleedRight; |
||
749 | double blh2 = actPg->height() + bleedBottom + bleedTop; |
||
7141 | fschmid | 750 | painter->drawRect(blx2, bly2, blw2, blh2); |
6922 | fschmid | 751 | if (drawBleed) |
752 | painter->drawRect(x, y, w, h); |
||
753 | } |
||
754 | else |
||
755 | painter->drawRect(x, y, w, h); |
||
7760 | fschmid | 756 | painter->endLayer(); |
6809 | fschmid | 757 | painter->setAntialiasing(true); |
456 | fschmid | 758 | } |
5664 | fschmid | 759 | } |
6534 | fschmid | 760 | if (viewAsPreview) |
761 | { |
||
762 | FPointArray PoLine; |
||
763 | bool first = true; |
||
8703 | fschmid | 764 | Page *actPg; |
6534 | fschmid | 765 | for (int a = 0; a < static_cast<int>(docPagesCount); ++a) |
766 | { |
||
767 | if (!first) |
||
768 | PoLine.setMarker(); |
||
769 | first = false; |
||
8703 | fschmid | 770 | actPg = Doc->Pages->at(a); |
771 | double x = actPg->xOffset(); |
||
772 | double y = actPg->yOffset(); |
||
773 | double w = actPg->width(); |
||
774 | double h = actPg->height(); |
||
6534 | fschmid | 775 | static double rect[] = {0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, |
776 | 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, |
||
777 | 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0}; |
||
778 | for (int a = 0; a < 29; a += 4) |
||
779 | { |
||
780 | PoLine.addPoint(x + w * rect[a], y + h * rect[a+1]); |
||
781 | PoLine.addPoint(x + w * rect[a+2], y + h * rect[a+3]); |
||
782 | } |
||
783 | } |
||
7049 | fschmid | 784 | painter->beginLayer(1.0, 0, &PoLine); |
6534 | fschmid | 785 | } |
786 | else |
||
7049 | fschmid | 787 | painter->beginLayer(1.0, 0); |
7157 | fschmid | 788 | if ((Doc->guidesSettings.before) && (!viewAsPreview)) |
789 | { |
||
8703 | fschmid | 790 | Page *actPg; |
7157 | fschmid | 791 | for (uint a = 0; a < docPagesCount; ++a) |
792 | { |
||
8703 | fschmid | 793 | actPg = Doc->Pages->at(a); |
794 | double x = actPg->xOffset() * Scale; |
||
795 | double y = actPg->yOffset() * Scale; |
||
796 | double w = actPg->width() * Scale; |
||
797 | double h = actPg->height() * Scale; |
||
798 | QRectF drawRect = QRectF(x, y, w+5, h+5); |
||
799 | drawRect.translate(-Doc->minCanvasCoordinate.x() * Scale, -Doc->minCanvasCoordinate.y() * Scale); |
||
800 | if (drawRect.intersects(QRectF(clipx, clipy, clipw, cliph))) |
||
7157 | fschmid | 801 | DrawPageMarks(painter, Doc->Pages->at(a), QRect(clipx, clipy, clipw, cliph)); |
802 | } |
||
803 | } |
||
7049 | fschmid | 804 | for (uint a = 0; a < docPagesCount; ++a) |
6534 | fschmid | 805 | { |
7049 | fschmid | 806 | DrawMasterItems(painter, Doc->Pages->at(a), QRect(clipx, clipy, clipw, cliph)); |
6534 | fschmid | 807 | } |
7049 | fschmid | 808 | DrawPageItems(painter, QRect(clipx, clipy, clipw, cliph)); |
809 | painter->endLayer(); |
||
5664 | fschmid | 810 | if ((!Doc->guidesSettings.before) && (!viewAsPreview)) |
811 | { |
||
8703 | fschmid | 812 | Page *actPg; |
5664 | fschmid | 813 | for (uint a = 0; a < docPagesCount; ++a) |
5235 | fschmid | 814 | { |
8703 | fschmid | 815 | actPg = Doc->Pages->at(a); |
816 | double x = actPg->xOffset() * Scale; |
||
817 | double y = actPg->yOffset() * Scale; |
||
818 | double w = actPg->width() * Scale; |
||
819 | double h = actPg->height() * Scale; |
||
820 | QRectF drawRect = QRectF(x, y, w+5, h+5); |
||
821 | drawRect.translate(-Doc->minCanvasCoordinate.x() * Scale, -Doc->minCanvasCoordinate.y() * Scale); |
||
822 | if (drawRect.intersects(QRectF(clipx, clipy, clipw, cliph))) |
||
5664 | fschmid | 823 | DrawPageMarks(painter, Doc->Pages->at(a), QRect(clipx, clipy, clipw, cliph)); |
5235 | fschmid | 824 | } |
456 | fschmid | 825 | } |
826 | } |
||
827 | else |
||
828 | { |
||
8703 | fschmid | 829 | double x = Doc->scratch.Left * Scale; |
830 | double y = Doc->scratch.Top * Scale; |
||
831 | double w = Doc->currentPage()->width() * Scale; |
||
832 | double h = Doc->currentPage()->height() * Scale; |
||
833 | QRectF drawRect = QRectF(x, y, w+5, h+5); |
||
834 | drawRect.translate(-Doc->minCanvasCoordinate.x() * Scale, -Doc->minCanvasCoordinate.y() * Scale); |
||
835 | if (drawRect.intersects(QRectF(clipx, clipy, clipw, cliph))) |
||
456 | fschmid | 836 | { |
7141 | fschmid | 837 | painter->setFillMode(ScPainter::Solid); |
838 | painter->setBrush(QColor(128,128,128)); |
||
8014 | fschmid | 839 | double bleedRight = 0.0; |
840 | double bleedLeft = 0.0; |
||
841 | double bleedBottom = 0.0; |
||
842 | double bleedTop = 0.0; |
||
843 | Doc->getBleeds(Doc->currentPage(), &bleedTop, &bleedBottom, &bleedLeft, &bleedRight); |
||
5752 | fschmid | 844 | painter->beginLayer(1.0, 0); |
7141 | fschmid | 845 | painter->setAntialiasing(false); |
8501 | cbradney | 846 | painter->setPen(Qt::black, 1 / Scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
8504 | cbradney | 847 | if (((Doc->bleeds.Bottom != 0.0) || (Doc->bleeds.Top != 0.0) || (Doc->bleeds.Left != 0.0) || (Doc->bleeds.Right != 0.0)) && (Doc->guidesSettings.showBleed)) |
8014 | fschmid | 848 | { |
8504 | cbradney | 849 | painter->drawRect(Doc->scratch.Left - bleedLeft+5 / Scale, Doc->scratch.Top - bleedTop+5 / Scale, Doc->currentPage()->width() + bleedLeft + bleedRight, Doc->currentPage()->height() + bleedBottom + bleedTop); |
8014 | fschmid | 850 | painter->setBrush(Doc->papColor); |
8504 | cbradney | 851 | painter->drawRect(Doc->scratch.Left - bleedLeft, Doc->scratch.Top - bleedTop, Doc->currentPage()->width() + bleedLeft + bleedRight, Doc->currentPage()->height() + bleedBottom + bleedTop); |
8014 | fschmid | 852 | } |
853 | else |
||
854 | { |
||
8504 | cbradney | 855 | painter->drawRect(Doc->scratch.Left+5 / Scale, Doc->scratch.Top+5 / Scale, Doc->currentPage()->width(), Doc->currentPage()->height()); |
8014 | fschmid | 856 | painter->setBrush(Doc->papColor); |
8504 | cbradney | 857 | painter->drawRect(Doc->scratch.Left, Doc->scratch.Top, Doc->currentPage()->width(), Doc->currentPage()->height()); |
8014 | fschmid | 858 | } |
7141 | fschmid | 859 | painter->setAntialiasing(true); |
1187 | fschmid | 860 | if (Doc->guidesSettings.before) |
5087 | subik | 861 | DrawPageMarks(painter, Doc->currentPage(), QRect(clipx, clipy, clipw, cliph)); |
5752 | fschmid | 862 | painter->endLayer(); |
456 | fschmid | 863 | } |
5752 | fschmid | 864 | painter->beginLayer(1.0, 0); |
456 | fschmid | 865 | DrawPageItems(painter, QRect(clipx, clipy, clipw, cliph)); |
5752 | fschmid | 866 | painter->endLayer(); |
2848 | fschmid | 867 | if ((!Doc->guidesSettings.before) && (drawRect.intersects(QRect(clipx, clipy, clipw, cliph)))) |
5087 | subik | 868 | DrawPageMarks(painter, Doc->currentPage(), QRect(clipx, clipy, clipw, cliph)); |
456 | fschmid | 869 | } |
5235 | fschmid | 870 | if (((Doc->m_Selection->count() != 0) || (linkedFramesToShow.count() != 0)) && (!viewAsPreview)) |
456 | fschmid | 871 | { |
872 | painter->save(); |
||
1957 | cbradney | 873 | PageItem *currItem; |
879 | fschmid | 874 | if ((Doc->guidesSettings.linkShown) && (linkedFramesToShow.count() != 0)) |
1957 | cbradney | 875 | currItem = linkedFramesToShow.at(0); |
705 | fschmid | 876 | else |
808 | fschmid | 877 | { |
878 | if (linkedFramesToShow.count() != 0) |
||
1957 | cbradney | 879 | currItem = linkedFramesToShow.at(0); |
808 | fschmid | 880 | else |
4847 | cbradney | 881 | currItem = Doc->m_Selection->itemAt(0); |
808 | fschmid | 882 | } |
3594 | cbradney | 883 | //Draw the frame links |
2603 | cbradney | 884 | if ((((Doc->appMode == modeLinkFrames) || (Doc->appMode == modeUnlinkFrames)) |
1957 | cbradney | 885 | && (currItem->itemType() == PageItem::TextFrame)) || (Doc->guidesSettings.linkShown)) |
456 | fschmid | 886 | { |
1957 | cbradney | 887 | PageItem *nextItem = currItem; |
879 | fschmid | 888 | if (Doc->guidesSettings.linkShown) |
456 | fschmid | 889 | { |
705 | fschmid | 890 | for (uint lks = 0; lks < linkedFramesToShow.count(); ++lks) |
891 | { |
||
1957 | cbradney | 892 | nextItem = linkedFramesToShow.at(lks); |
893 | while (nextItem != 0) |
||
705 | fschmid | 894 | { |
3954 | cbradney | 895 | //Calculate the link points of the frames |
3903 | cbradney | 896 | double x11 = nextItem->xPos(); |
897 | double y11 = nextItem->yPos(); |
||
3934 | cbradney | 898 | double x12 = x11+nextItem->width(); |
899 | double y12 = y11+nextItem->height(); |
||
3708 | cbradney | 900 | double x1mid = x11+(x12-x11)/2; |
901 | double y1mid = y11+(y12-y11)/2; |
||
814 | cbradney | 902 | |
3934 | cbradney | 903 | if (nextItem->rotation()!=0.000) |
814 | cbradney | 904 | { |
3934 | cbradney | 905 | FPoint tempPoint(0,0, x11, y11, nextItem->rotation(), 1, 1); |
814 | cbradney | 906 | x11=tempPoint.x(); |
907 | y11=tempPoint.y(); |
||
3934 | cbradney | 908 | FPoint tempPoint2(0,0, x12, y12, nextItem->rotation(), 1, 1); |
3242 | cbradney | 909 | x12=tempPoint2.x(); |
910 | y12=tempPoint2.y(); |
||
3934 | cbradney | 911 | FPoint tempPoint3(0,0, x1mid, y1mid, nextItem->rotation(), 1, 1); |
3242 | cbradney | 912 | x1mid=tempPoint3.x(); |
913 | y1mid=tempPoint3.y(); |
||
814 | cbradney | 914 | } |
915 | |||
1485 | tsoots | 916 | |
814 | cbradney | 917 | double a1, b1, a2, b2; |
823 | fschmid | 918 | a1 = a2 = b1 = b2 = 0; |
7994 | avox | 919 | if (nextItem->nextInChain() != NULL) |
814 | cbradney | 920 | { |
7994 | avox | 921 | double x21 = nextItem->nextInChain()->xPos(); |
922 | double y21 = nextItem->nextInChain()->yPos(); |
||
923 | double x22 = x21+nextItem->nextInChain()->width(); |
||
924 | double y22 = y21+nextItem->nextInChain()->height(); |
||
925 | double x2mid = x21 + nextItem->nextInChain()->width()/2; |
||
926 | double y2mid = y21 + nextItem->nextInChain()->height()/2; |
||
3708 | cbradney | 927 | //x2mid = x21+(x22-x21)/2; |
928 | //y2mid = y21+(y22-y21)/2; |
||
814 | cbradney | 929 | |
7994 | avox | 930 | if (nextItem->nextInChain()->rotation()!=0.000) |
814 | cbradney | 931 | { |
7994 | avox | 932 | FPoint tempPoint(0,0, x21, y21, nextItem->nextInChain()->rotation(), 1, 1); |
814 | cbradney | 933 | x21=tempPoint.x(); |
934 | y21=tempPoint.y(); |
||
7994 | avox | 935 | FPoint tempPoint2(0,0, x22, y22, nextItem->nextInChain()->rotation(), 1, 1); |
3242 | cbradney | 936 | x22=tempPoint2.x(); |
937 | y22=tempPoint2.y(); |
||
7994 | avox | 938 | FPoint tempPoint3(0,0, x2mid, y2mid, nextItem->nextInChain()->rotation(), 1, 1); |
3242 | cbradney | 939 | x2mid=tempPoint3.x(); |
940 | y2mid=tempPoint3.y(); |
||
814 | cbradney | 941 | } |
1485 | tsoots | 942 | |
814 | cbradney | 943 | if (x22<x11) { a1 = x11; a2 = x22; } |
944 | if (x21>x12) { a1 = x12; a2 = x21; } |
||
945 | if (y22<y11) { b1 = y11; b2 = y22; } |
||
946 | if (y21>y12) { b1 = y12; b2 = y21; } |
||
947 | |||
948 | if (x21<x12 && x21>x11) { a1 = x1mid; a2 = x2mid; } |
||
949 | if (x21<x11 && x22>x11) { a1 = x1mid; a2 = x2mid; } |
||
950 | |||
951 | if (y21<y12 && y21>y11) { b1 = y1mid; b2 = y2mid; } |
||
952 | if (y21<y11 && y22>y11) { b1 = y1mid; b2 = y2mid; } |
||
953 | |||
954 | } |
||
3954 | cbradney | 955 | //Draw the link frame lines |
3934 | cbradney | 956 | FPoint Start(a1-nextItem->xPos(), b1-nextItem->yPos(), nextItem->xPos(), nextItem->yPos(), nextItem->rotation(), 1, 1); |
3903 | cbradney | 957 | //FPoint Start = transformPoint(FPoint(nextItem->Width/2, nextItem->Height), nextItem->xPos(), nextItem->yPos(), nextItem->Rot, 1, 1); |
7994 | avox | 958 | nextItem = nextItem->nextInChain(); |
1957 | cbradney | 959 | if (nextItem != NULL) |
705 | fschmid | 960 | { |
3934 | cbradney | 961 | FPoint End(a2-nextItem->xPos(), b2-nextItem->yPos(), nextItem->xPos(), nextItem->yPos(), nextItem->rotation(), 1, 1); |
3954 | cbradney | 962 | drawLinkFrameLine(painter, Start, End); |
705 | fschmid | 963 | } |
964 | } |
||
965 | } |
||
456 | fschmid | 966 | } |
705 | fschmid | 967 | else |
456 | fschmid | 968 | { |
1957 | cbradney | 969 | while (nextItem != 0) |
456 | fschmid | 970 | { |
7994 | avox | 971 | if (nextItem->prevInChain() != 0) |
972 | nextItem = nextItem->prevInChain(); |
||
705 | fschmid | 973 | else |
974 | break; |
||
456 | fschmid | 975 | } |
1957 | cbradney | 976 | while (nextItem != 0) |
705 | fschmid | 977 | { |
3934 | cbradney | 978 | FPoint Start(nextItem->width()/2, nextItem->height(), nextItem->xPos(), nextItem->yPos(), nextItem->rotation(), 1, 1); |
7994 | avox | 979 | nextItem = nextItem->nextInChain(); |
3954 | cbradney | 980 | //Draw the link frame indicator for a new link |
981 | //CB unsure if we need to do this |
||
1957 | cbradney | 982 | if (nextItem != 0) |
705 | fschmid | 983 | { |
3934 | cbradney | 984 | FPoint End(nextItem->width()/2, 0, nextItem->xPos(), nextItem->yPos(), nextItem->rotation(), 1, 1); |
3954 | cbradney | 985 | drawLinkFrameLine(painter, Start, End); |
705 | fschmid | 986 | } |
987 | } |
||
456 | fschmid | 988 | } |
989 | } |
||
990 | painter->setLineWidth(1); |
||
991 | painter->setPenOpacity(1.0); |
||
992 | painter->restore(); |
||
993 | } |
||
994 | painter->end(); |
||
5373 | fschmid | 995 | psx->drawImage(clipx, clipy, img); |
456 | fschmid | 996 | delete painter; |
3708 | cbradney | 997 | painter=NULL; |
456 | fschmid | 998 | } |
9431 | fschmid | 999 | /* psx->setRenderHint(QPainter::Antialiasing, true); |
9041 | fschmid | 1000 | if (operItemMoving || operItemResizing) |
456 | fschmid | 1001 | { |
9041 | fschmid | 1002 | if (operItemResizing) |
2934 | fschmid | 1003 | { |
9041 | fschmid | 1004 | if (!redrawPolygon.isEmpty()) |
1005 | { |
||
9349 | fschmid | 1006 | if (m_MouseButtonPressed && (Doc->appMode == modeDrawFreehandLine)) |
1007 | { |
||
1008 | psx->resetMatrix(); |
||
1009 | QPoint out = contentsToViewport(QPoint(0, 0)); |
||
1010 | psx->translate(out.x(), out.y()); |
||
1011 | psx->translate(-qRound(Doc->minCanvasCoordinate.x()*Scale), -qRound(Doc->minCanvasCoordinate.y()*Scale)); |
||
1012 | psx->scale(Scale, Scale); |
||
1013 | psx->setBrush(Qt::NoBrush); |
||
1014 | psx->setPen(QPen(Qt::black, 1.0 / Scale, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin)); |
||
1015 | psx->drawPolyline(redrawPolygon); |
||
1016 | redrawPolygon.clear(); |
||
1017 | } |
||
1018 | else |
||
1019 | { |
||
1020 | QColor drawColor = qApp->palette().color(QPalette::Active, QColorGroup::Highlight); |
||
1021 | psx->setPen(QPen(drawColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); |
||
1022 | drawColor.setAlpha(64); |
||
1023 | psx->setBrush(drawColor); |
||
1024 | psx->drawPolygon(redrawPolygon); |
||
1025 | redrawPolygon.clear(); |
||
1026 | } |
||
9041 | fschmid | 1027 | } |
8994 | fschmid | 1028 | } |
1029 | else |
||
1030 | { |
||
1031 | if (Doc->m_Selection->count() != 0) |
||
8770 | fschmid | 1032 | { |
8994 | fschmid | 1033 | uint selectedItemCount = Doc->m_Selection->count(); |
1034 | PageItem *currItem = Doc->m_Selection->itemAt(0); |
||
1035 | if (selectedItemCount < moveWithBoxesOnlyThreshold) |
||
8770 | fschmid | 1036 | { |
9343 | fschmid | 1037 | for (uint cu = 0; cu < selectedItemCount; cu++) |
8770 | fschmid | 1038 | { |
9343 | fschmid | 1039 | currItem = Doc->m_Selection->itemAt(cu); |
1040 | psx->resetMatrix(); |
||
1041 | QPoint out = contentsToViewport(QPoint(0, 0)); |
||
1042 | psx->translate(out.x(), out.y()); |
||
9349 | fschmid | 1043 | psx->translate(-qRound(Doc->minCanvasCoordinate.x()*Scale), -qRound(Doc->minCanvasCoordinate.y()*Scale)); |
9343 | fschmid | 1044 | Transform(currItem, psx); |
1045 | psx->setBrush(Qt::NoBrush); |
||
1046 | psx->setPen(QPen(Qt::black, 1.0 / Scale, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin)); |
||
1047 | if (selectedItemCount < moveWithFullOutlinesThreshold) |
||
8770 | fschmid | 1048 | { |
9343 | fschmid | 1049 | if (!(currItem->asLine())) |
1050 | currItem->DrawPolyL(psx, currItem->Clip); |
||
1051 | else |
||
8770 | fschmid | 1052 | { |
9343 | fschmid | 1053 | if (currItem->asLine()) |
8994 | fschmid | 1054 | { |
9343 | fschmid | 1055 | int lw2 = 1; |
1056 | int lw = 1; |
||
1057 | Qt::PenCapStyle le = Qt::FlatCap; |
||
1058 | if (currItem->NamedLStyle.isEmpty()) |
||
1059 | { |
||
1060 | lw2 = qRound(currItem->lineWidth() / 2.0); |
||
1061 | lw = qRound(qMax(currItem->lineWidth(), 1.0)); |
||
1062 | le = currItem->PLineEnd; |
||
1063 | } |
||
1064 | else |
||
1065 | { |
||
1066 | multiLine ml = Doc->MLineStyles[currItem->NamedLStyle]; |
||
1067 | lw2 = qRound(ml[ml.size()-1].Width / 2.0); |
||
1068 | lw = qRound(qMax(ml[ml.size()-1].Width, 1.0)); |
||
1069 | le = static_cast<Qt::PenCapStyle>(ml[ml.size()-1].LineEnd); |
||
1070 | } |
||
1071 | if (le != Qt::FlatCap) |
||
1072 | psx->drawRect(-lw2, -lw2, qRound(currItem->width())+lw, lw); |
||
1073 | else |
||
1074 | psx->drawRect(-1, -lw2, qRound(currItem->width()), lw); |
||
8994 | fschmid | 1075 | } |
8770 | fschmid | 1076 | } |
1077 | } |
||
9343 | fschmid | 1078 | else |
1079 | psx->drawRect(0, 0, static_cast<int>(currItem->width())+1, static_cast<int>(currItem->height())+1); |
||
8770 | fschmid | 1080 | } |
1081 | } |
||
1082 | else |
||
8994 | fschmid | 1083 | { |
1084 | double gx, gy, gw, gh; |
||
1085 | Doc->m_Selection->setGroupRect(); |
||
1086 | getGroupRectScreen(&gx, &gy, &gw, &gh); |
||
1087 | QPoint out = contentsToViewport(QPoint(0, 0)); |
||
9327 | fschmid | 1088 | psx->resetMatrix(); |
9041 | fschmid | 1089 | psx->translate(-out.x(), -out.y()); |
8994 | fschmid | 1090 | psx->translate(qRound(gx), qRound(gy)); |
1091 | psx->scale(Scale, Scale); |
||
1092 | psx->drawRect(QRect(0, 0, qRound(gw), qRound(gh))); |
||
1093 | } |
||
8770 | fschmid | 1094 | } |
2934 | fschmid | 1095 | } |
8770 | fschmid | 1096 | } |
1097 | else |
||
9431 | fschmid | 1098 | { */ |
9434 | fschmid | 1099 | if ((Doc->m_Selection->count() != 0) && !(operItemMoving || operItemResizing) && (Doc->appMode != modeDrawBezierLine)) |
456 | fschmid | 1100 | { |
8770 | fschmid | 1101 | PageItem *currItem = Doc->m_Selection->itemAt(0); |
9431 | fschmid | 1102 | if ((Doc->EditClip) && (currItem->isSelected()) && (!specialRendering)) |
8770 | fschmid | 1103 | { |
9041 | fschmid | 1104 | if (EditContour) |
1105 | MarkClip(psx, currItem, currItem->ContourLine, true); |
||
1106 | else |
||
1107 | MarkClip(psx, currItem, currItem->PoLine, true); |
||
1108 | } |
||
8770 | fschmid | 1109 | else |
1110 | { |
||
9041 | fschmid | 1111 | if (Doc->m_Selection->isMultipleSelection()) |
1112 | { |
||
9477 | fschmid | 1113 | |
9431 | fschmid | 1114 | psx->resetMatrix(); |
9343 | fschmid | 1115 | QPoint out = contentsToViewport(QPoint(0, 0)); |
9431 | fschmid | 1116 | psx->translate(out.x(), out.y()); |
1117 | psx->translate(-qRound(Doc->minCanvasCoordinate.x()*Scale), -qRound(Doc->minCanvasCoordinate.y()*Scale)); |
||
9477 | fschmid | 1118 | if (Doc->m_Selection->count() != 0) |
1119 | { |
||
1120 | uint docSelectionCount = Doc->m_Selection->count(); |
||
1121 | PageItem *currItem; |
||
1122 | for (uint a=0; a<docSelectionCount; ++a) |
||
1123 | { |
||
1124 | currItem = Doc->m_Selection->itemAt(a); |
||
1125 | psx->save(); |
||
1126 | Transform(currItem, psx); |
||
1127 | currItem->paintObj(psx); |
||
1128 | psx->restore(); |
||
1129 | } |
||
1130 | } |
||
1131 | psx->resetMatrix(); |
||
1132 | psx->translate(out.x(), out.y()); |
||
1133 | psx->translate(-qRound(Doc->minCanvasCoordinate.x()*Scale), -qRound(Doc->minCanvasCoordinate.y()*Scale)); |
||
9041 | fschmid | 1134 | double x, y, w, h; |
1135 | Doc->m_Selection->setGroupRect(); |
||
9431 | fschmid | 1136 | Doc->m_Selection->getGroupRect(&x, &y, &w, &h); |
1137 | x *= Scale; |
||
1138 | y *= Scale; |
||
1139 | w *= Scale; |
||
1140 | h *= Scale; |
||
9041 | fschmid | 1141 | psx->setPen(QPen(Qt::red, 1, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin)); |
1142 | psx->setBrush(Qt::NoBrush); |
||
1143 | psx->drawRect(QRectF(x, y, w, h)); |
||
1144 | psx->setBrush(Qt::red); |
||
1145 | psx->setPen(QPen(Qt::red, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); |
||
1146 | psx->drawRect(QRectF(x+w-6, y+h-6, 6, 6)); |
||
1147 | psx->drawRect(QRectF(x+w/2 - 3, y+h-6, 6, 6)); |
||
1148 | psx->drawRect(QRectF(x+w/2 - 3, y, 6, 6)); |
||
1149 | psx->drawRect(QRectF(x+w-6, y+h/2 - 3, 6, 6)); |
||
1150 | psx->drawRect(QRectF(x+w-6, y, 6, 6)); |
||
1151 | psx->drawRect(QRectF(x, y, 6, 6)); |
||
1152 | psx->drawRect(QRectF(x, y+h/2 - 3, 6, 6)); |
||
1153 | psx->drawRect(QRectF(x, y+h-6, 6, 6)); |
||
1154 | } |
||
1155 | else |
||
9343 | fschmid | 1156 | { |
1157 | psx->resetMatrix(); |
||
1158 | QPoint out = contentsToViewport(QPoint(0, 0)); |
||
1159 | psx->translate(out.x(), out.y()); |
||
9349 | fschmid | 1160 | psx->translate(-qRound(Doc->minCanvasCoordinate.x()*Scale), -qRound(Doc->minCanvasCoordinate.y()*Scale)); |
9343 | fschmid | 1161 | Transform(currItem, psx); |
1162 | currItem->paintObj(psx); |
||
1163 | } |
||
9041 | fschmid | 1164 | } |
456 | fschmid | 1165 | } |
9431 | fschmid | 1166 | /* } */ |
2603 | cbradney | 1167 | if (Doc->appMode == modeEdit) |
456 | fschmid | 1168 | slotDoCurs(true); |
2603 | cbradney | 1169 | if (Doc->appMode == modeEditGradientVectors) |
735 | fschmid | 1170 | { |
4847 | cbradney | 1171 | PageItem *currItem = Doc->m_Selection->itemAt(0); |
9391 | fschmid | 1172 | psx->resetMatrix(); |
1173 | QPoint out = contentsToViewport(QPoint(0, 0)); |
||
1174 | psx->translate(out.x(), out.y()); |
||
1175 | psx->translate(-qRound(Doc->minCanvasCoordinate.x()*Scale), -qRound(Doc->minCanvasCoordinate.y()*Scale)); |
||
1176 | Transform(currItem, psx); |
||
1177 | psx->setPen(QPen(Qt::blue, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); |
||
1178 | psx->setBrush(Qt::NoBrush); |
||
1179 | psx->drawLine(QPointF(currItem->GrStartX, currItem->GrStartY), QPointF(currItem->GrEndX, currItem->GrEndY)); |
||
1180 | psx->setPen(QPen(Qt::magenta, 8, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin)); |
||
1181 | psx->drawPoint(QPointF(currItem->GrStartX, currItem->GrStartY)); |
||
1182 | psx->drawPoint(QPointF(currItem->GrEndX, currItem->GrEndY)); |
||
735 | fschmid | 1183 | } |
2171 | fschmid | 1184 | evSpon = false; |
2951 | fschmid | 1185 | forceRedraw = false; |
456 | fschmid | 1186 | // qDebug( "Time elapsed: %d ms", tim.elapsed() ); |
1187 | } |
||
1188 | |||
1189 | void ScribusView::DrawMasterItems(ScPainter *painter, Page *page, QRect clip) |
||
1190 | { |
||
7537 | fschmid | 1191 | QRect oldR; |
8501 | cbradney | 1192 | Q3PtrStack<PageItem> groupStack; |
1193 | Q3PtrStack<PageItem> groupStack2; |
||
2877 | cbradney | 1194 | if (!page->MPageNam.isEmpty()) |
456 | fschmid | 1195 | { |
1196 | Page* Mp = Doc->MasterPages.at(Doc->MasterNames[page->MPageNam]); |
||
1197 | if (page->FromMaster.count() != 0) |
||
1198 | { |
||
3313 | cbradney | 1199 | int Lnr; |
1200 | struct Layer ll; |
||
1201 | PageItem *currItem; |
||
1202 | ll.isViewable = false; |
||
1203 | ll.LNr = 0; |
||
456 | fschmid | 1204 | Lnr = 0; |
2951 | fschmid | 1205 | uint layerCount=Doc->layerCount(); |
2937 | cbradney | 1206 | for (uint la = 0; la < layerCount; ++la) |
456 | fschmid | 1207 | { |
1208 | Level2Layer(Doc, &ll, Lnr); |
||
1874 | fschmid | 1209 | bool pr = true; |
1210 | if ((previewMode) && (!ll.isPrintable)) |
||
1211 | pr = false; |
||
7137 | fschmid | 1212 | if ((viewAsPreview) && (!ll.isPrintable)) |
1213 | pr = false; |
||
1874 | fschmid | 1214 | if ((ll.isViewable) && (pr)) |
456 | fschmid | 1215 | { |
5373 | fschmid | 1216 | if ((layerCount > 1) || (ll.transparency != 1.0)) |
5375 | fschmid | 1217 | painter->beginLayer(ll.transparency, ll.blendMode); |
3689 | cbradney | 1218 | uint pageFromMasterCount=page->FromMaster.count(); |
1219 | for (uint a = 0; a < pageFromMasterCount; ++a) |
||
456 | fschmid | 1220 | { |
1957 | cbradney | 1221 | currItem = page->FromMaster.at(a); |
1222 | if (currItem->LayerNr != ll.LNr) |
||
456 | fschmid | 1223 | continue; |
3200 | cbradney | 1224 | if ((currItem->OwnPage != -1) && (currItem->OwnPage != static_cast<int>(Mp->pageNr()))) |
456 | fschmid | 1225 | continue; |
4698 | cbradney | 1226 | if ((previewMode) && (!currItem->printEnabled())) |
1874 | fschmid | 1227 | continue; |
7137 | fschmid | 1228 | if ((viewAsPreview) && (!currItem->printEnabled())) |
1229 | continue; |
||
7444 | fschmid | 1230 | double OldX = currItem->xPos(); |
1231 | double OldY = currItem->yPos(); |
||
1232 | double OldBX = currItem->BoundingX; |
||
1233 | double OldBY = currItem->BoundingY; |
||
1234 | if (!currItem->ChangedMasterItem) |
||
1235 | { |
||
1236 | //Hack to not check for undo changes, indicate drawing only |
||
1237 | currItem->moveBy(-Mp->xOffset() + page->xOffset(), -Mp->yOffset() + page->yOffset(), true); |
||
1238 | currItem->BoundingX = OldBX - Mp->xOffset() + page->xOffset(); |
||
1239 | currItem->BoundingY = OldBY - Mp->yOffset() + page->yOffset(); |
||
1240 | } |
||
7549 | fschmid | 1241 | oldR = currItem->getRedrawBounding(Scale); |
6451 | fschmid | 1242 | if (currItem->isGroupControl) |
1243 | { |
||
1244 | painter->save(); |
||
7549 | fschmid | 1245 | currItem->savedOwnPage = currItem->OwnPage; |
1246 | currItem->OwnPage = page->pageNr(); |
||
1247 | if ((clip.intersects(oldR)) && (Doc->guidesSettings.layerMarkersShown) && (Doc->layerCount() > 1)) |
||
1248 | currItem->DrawObj(painter, clip); |
||
7049 | fschmid | 1249 | FPointArray cl = currItem->PoLine.copy(); |
8501 | cbradney | 1250 | QMatrix mm; |
7049 | fschmid | 1251 | mm.translate(currItem->xPos(), currItem->yPos()); |
1252 | mm.rotate(currItem->rotation()); |
||
1253 | cl.map( mm ); |
||
1254 | painter->beginLayer(1.0 - currItem->fillTransparency(), currItem->fillBlendmode(), &cl); |
||
6451 | fschmid | 1255 | groupStack.push(currItem->groupsLastItem); |
7838 | fschmid | 1256 | groupStack2.push(currItem); |
7549 | fschmid | 1257 | currItem->OwnPage = currItem->savedOwnPage; |
7444 | fschmid | 1258 | if (!currItem->ChangedMasterItem) |
1259 | { |
||
1260 | //Hack to not check for undo changes, indicate drawing only |
||
1261 | currItem->setXYPos(OldX, OldY, true); |
||
1262 | currItem->BoundingX = OldBX; |
||
1263 | currItem->BoundingY = OldBY; |
||
1264 | } |
||
6451 | fschmid | 1265 | continue; |
1266 | } |
||
4401 | fschmid | 1267 | currItem->savedOwnPage = currItem->OwnPage; |
3200 | cbradney | 1268 | currItem->OwnPage = page->pageNr(); |
5387 | avox | 1269 | if (!evSpon || forceRedraw) |
5362 | avox | 1270 | currItem->invalid = true; |
537 | fschmid | 1271 | if (clip.intersects(oldR)) |
8770 | fschmid | 1272 | { |
8994 | fschmid | 1273 | if (!((operItemMoving || operItemResizeInEditMode) && (currItem->isSelected()))) |
8770 | fschmid | 1274 | currItem->DrawObj(painter, clip); |
1275 | } |
||
4401 | fschmid | 1276 | currItem->OwnPage = currItem->savedOwnPage; |
1957 | cbradney | 1277 | if (!currItem->ChangedMasterItem) |
456 | fschmid | 1278 | { |
4644 | cbradney | 1279 | //Hack to not check for undo changes, indicate drawing only |
1280 | currItem->setXYPos(OldX, OldY, true); |
||
1957 | cbradney | 1281 | currItem->BoundingX = OldBX; |
1282 | currItem->BoundingY = OldBY; |
||
456 | fschmid | 1283 | } |
6451 | fschmid | 1284 | if (groupStack.count() != 0) |
1285 | { |
||
1286 | while (currItem == groupStack.top()) |
||
1287 | { |
||
7049 | fschmid | 1288 | painter->endLayer(); |
6451 | fschmid | 1289 | painter->restore(); |
7549 | fschmid | 1290 | PageItem *cite = groupStack2.pop(); |
1291 | double OldX = cite->xPos(); |
||
1292 | double OldY = cite->yPos(); |
||
1293 | double OldBX = cite->BoundingX; |
||
1294 | double OldBY = cite->BoundingY; |
||
1295 | if (!cite->ChangedMasterItem) |
||
1296 | { |
||
1297 | //Hack to not check for undo changes, indicate drawing only |
||
1298 | cite->moveBy(-Mp->xOffset() + page->xOffset(), -Mp->yOffset() + page->yOffset(), true); |
||
1299 | cite->BoundingX = OldBX - Mp->xOffset() + page->xOffset(); |
||
1300 | cite->BoundingY = OldBY - Mp->yOffset() + page->yOffset(); |
||
1301 | } |
||
1302 | oldR = cite->getRedrawBounding(Scale); |
||
1303 | if ((clip.intersects(oldR)) && (Doc->guidesSettings.layerMarkersShown) && (Doc->layerCount() > 1)) |
||
1304 | cite->DrawObj(painter, clip); |
||
1305 | cite->OwnPage = cite->savedOwnPage; |
||
1306 | if (!currItem->ChangedMasterItem) |
||
1307 | { |
||
1308 | //Hack to not check for undo changes, indicate drawing only |
||
1309 | cite->setXYPos(OldX, OldY, true); |
||
1310 | cite->BoundingX = OldBX; |
||
1311 | cite->BoundingY = OldBY; |
||
1312 | } |
||
6451 | fschmid | 1313 | groupStack.pop(); |
1314 | } |
||
1315 | } |
||
456 | fschmid | 1316 | } |
3689 | cbradney | 1317 | for (uint a = 0; a < pageFromMasterCount; ++a) |
456 | fschmid | 1318 | { |
1957 | cbradney | 1319 | currItem = page->FromMaster.at(a); |
1320 | if (currItem->LayerNr != ll.LNr) |
||
456 | fschmid | 1321 | continue; |
1957 | cbradney | 1322 | if (!currItem->isTableItem) |
456 | fschmid | 1323 | continue; |
7137 | fschmid | 1324 | if ((previewMode) && (!currItem->printEnabled())) |
1325 | continue; |
||
1326 | if ((viewAsPreview) && (!currItem->printEnabled())) |
||
1327 | continue; |
||
3200 | cbradney | 1328 | if ((currItem->OwnPage != -1) && (currItem->OwnPage != static_cast<int>(Mp->pageNr()))) |
456 | fschmid | 1329 | continue; |
7444 | fschmid | 1330 | if (currItem->isGroupControl) |
1331 | continue; |
||
3903 | cbradney | 1332 | double OldX = currItem->xPos(); |
1333 | double OldY = currItem->yPos(); |
||
1957 | cbradney | 1334 | double OldBX = currItem->BoundingX; |
1335 | double OldBY = currItem->BoundingY; |
||
1336 | if (!currItem->ChangedMasterItem) |
||
456 | fschmid | 1337 | { |
4644 | cbradney | 1338 | //Hack to not check for undo changes, indicate drawing only |
1339 | currItem->setXYPos(OldX - Mp->xOffset() + page->xOffset(), OldY - Mp->yOffset() + page->yOffset(), true); |
||
3200 | cbradney | 1340 | currItem->BoundingX = OldBX - Mp->xOffset() + page->xOffset(); |
1341 | currItem->BoundingY = OldBY - Mp->yOffset() + page->yOffset(); |
||
456 | fschmid | 1342 | } |
7537 | fschmid | 1343 | oldR = currItem->getRedrawBounding(Scale); |
537 | fschmid | 1344 | if (clip.intersects(oldR)) |
456 | fschmid | 1345 | { |
7141 | fschmid | 1346 | painter->save(); |
1347 | painter->translate(currItem->xPos(), currItem->yPos()); |
||
3934 | cbradney | 1348 | painter->rotate(currItem->rotation()); |
6570 | fschmid | 1349 | if ((currItem->lineColor() != CommonStrings::None) && (currItem->lineWidth() != 0.0)) |
456 | fschmid | 1350 | { |
1351 | QColor tmp; |
||
1957 | cbradney | 1352 | currItem->SetFarbe(&tmp, currItem->lineColor(), currItem->lineShade()); |
1353 | if ((currItem->TopLine) || (currItem->RightLine) || (currItem->BottomLine) || (currItem->LeftLine)) |
||
456 | fschmid | 1354 | { |
4580 | cbradney | 1355 | painter->setPen(tmp, currItem->lineWidth(), currItem->PLineArt, Qt::SquareCap, currItem->PLineJoin); |
1957 | cbradney | 1356 | if (currItem->TopLine) |
3934 | cbradney | 1357 | painter->drawLine(FPoint(0.0, 0.0), FPoint(currItem->width(), 0.0)); |
1957 | cbradney | 1358 | if (currItem->RightLine) |
3934 | cbradney | 1359 | painter->drawLine(FPoint(currItem->width(), 0.0), FPoint(currItem->width(), currItem->height())); |
1957 | cbradney | 1360 | if (currItem->BottomLine) |
3934 | cbradney | 1361 | painter->drawLine(FPoint(currItem->width(), currItem->height()), FPoint(0.0, currItem->height())); |
1957 | cbradney | 1362 | if (currItem->LeftLine) |
3934 | cbradney | 1363 | painter->drawLine(FPoint(0.0, currItem->height()), FPoint(0.0, 0.0)); |
456 | fschmid | 1364 | } |
1365 | } |
||
1366 | painter->restore(); |
||
1367 | } |
||
1957 | cbradney | 1368 | if (!currItem->ChangedMasterItem) |
456 | fschmid | 1369 | { |
4644 | cbradney | 1370 | //Hack to not check for undo changes, indicate drawing only |
1371 | currItem->setXYPos(OldX, OldY, true); |
||
1957 | cbradney | 1372 | currItem->BoundingX = OldBX; |
1373 | currItem->BoundingY = OldBY; |
||
456 | fschmid | 1374 | } |
1375 | } |
||
5373 | fschmid | 1376 | if ((layerCount > 1) || (ll.transparency != 1.0)) |
1377 | painter->endLayer(); |
||
456 | fschmid | 1378 | } |
1379 | Lnr++; |
||
1380 | } |
||
1381 | } |
||
1382 | } |
||
1383 | } |
||
1384 | |||
1385 | void ScribusView::DrawPageItems(ScPainter *painter, QRect clip) |
||
1386 | { |
||
705 | fschmid | 1387 | linkedFramesToShow.clear(); |
7537 | fschmid | 1388 | QRect oldR; |
8501 | cbradney | 1389 | Q3PtrStack<PageItem> groupStack; |
1390 | Q3PtrStack<PageItem> groupStack2; |
||
3727 | cbradney | 1391 | if (Doc->Items->count() != 0) |
456 | fschmid | 1392 | { |
3313 | cbradney | 1393 | int Lnr=0; |
1394 | struct Layer ll; |
||
1395 | PageItem *currItem; |
||
1396 | ll.isViewable = false; |
||
1397 | ll.LNr = 0; |
||
2951 | fschmid | 1398 | uint layerCount=Doc->layerCount(); |
3689 | cbradney | 1399 | int docCurrPageNo=static_cast<int>(Doc->currentPageNumber()); |
2937 | cbradney | 1400 | for (uint la2 = 0; la2 < layerCount; ++la2) |
456 | fschmid | 1401 | { |
1402 | Level2Layer(Doc, &ll, Lnr); |
||
1874 | fschmid | 1403 | bool pr = true; |
1404 | if ((previewMode) && (!ll.isPrintable)) |
||
1405 | pr = false; |
||
7137 | fschmid | 1406 | if ((viewAsPreview) && (!ll.isPrintable)) |
1407 | pr = false; |
||
1874 | fschmid | 1408 | if ((ll.isViewable) && (pr)) |
456 | fschmid | 1409 | { |
5373 | fschmid | 1410 | if ((layerCount > 1) || (ll.transparency != 1.0)) |
5375 | fschmid | 1411 | painter->beginLayer(ll.transparency, ll.blendMode); |
8501 | cbradney | 1412 | Q3PtrListIterator<PageItem> docItem(*Doc->Items); |
3689 | cbradney | 1413 | while ( (currItem = docItem.current()) != 0) |
1414 | { |
||
2434 | fschmid | 1415 | ++docItem; |
1957 | cbradney | 1416 | if (currItem->LayerNr != ll.LNr) |
456 | fschmid | 1417 | continue; |
4698 | cbradney | 1418 | if ((previewMode) && (!currItem->printEnabled())) |
1874 | fschmid | 1419 | continue; |
7137 | fschmid | 1420 | if ((viewAsPreview) && (!currItem->printEnabled())) |
1421 | continue; |
||
3724 | cbradney | 1422 | if ((Doc->masterPageMode()) && ((currItem->OwnPage != -1) && (currItem->OwnPage != docCurrPageNo))) |
456 | fschmid | 1423 | continue; |
3724 | cbradney | 1424 | if (!Doc->masterPageMode() && !currItem->OnMasterPage.isEmpty()) |
1781 | fschmid | 1425 | { |
5685 | cbradney | 1426 | if (currItem->OnMasterPage != Doc->currentPage()->pageName()) |
1781 | fschmid | 1427 | continue; |
1428 | } |
||
7549 | fschmid | 1429 | oldR = currItem->getRedrawBounding(Scale); |
6451 | fschmid | 1430 | if (currItem->isGroupControl) |
1431 | { |
||
1432 | painter->save(); |
||
7049 | fschmid | 1433 | FPointArray cl = currItem->PoLine.copy(); |
8501 | cbradney | 1434 | QMatrix mm; |
7049 | fschmid | 1435 | mm.translate(currItem->xPos(), currItem->yPos()); |
1436 | mm.rotate(currItem->rotation()); |
||
1437 | cl.map( mm ); |
||
1438 | painter->beginLayer(1.0 - currItem->fillTransparency(), currItem->fillBlendmode(), &cl); |
||
6451 | fschmid | 1439 | groupStack.push(currItem->groupsLastItem); |
7549 | fschmid | 1440 | groupStack2.push(currItem); |
6451 | fschmid | 1441 | continue; |
1442 | } |
||
537 | fschmid | 1443 | if (clip.intersects(oldR)) |
456 | fschmid | 1444 | { |
5362 | avox | 1445 | if (!evSpon || forceRedraw) |
1446 | currItem->invalid = true; |
||
4704 | cbradney | 1447 | // if ((!m_MouseButtonPressed) || (Doc->EditClip)) |
9099 | fschmid | 1448 | if (!((operItemMoving || operItemResizeInEditMode) && (currItem->isSelected()))) |
8770 | fschmid | 1449 | currItem->DrawObj(painter, clip); |
5362 | avox | 1450 | // currItem->Redrawn = true; |
7994 | avox | 1451 | if ((currItem->asTextFrame()) && ((currItem->nextInChain() != 0) || (currItem->prevInChain() != 0))) |
705 | fschmid | 1452 | { |
1957 | cbradney | 1453 | PageItem *nextItem = currItem; |
1454 | while (nextItem != 0) |
||
705 | fschmid | 1455 | { |
7994 | avox | 1456 | if (nextItem->prevInChain() != 0) |
1457 | nextItem = nextItem->prevInChain(); |
||
705 | fschmid | 1458 | else |
1459 | break; |
||
1460 | } |
||
1957 | cbradney | 1461 | if (linkedFramesToShow.find(nextItem) == -1) |
1462 | linkedFramesToShow.append(nextItem); |
||
705 | fschmid | 1463 | } |
3934 | cbradney | 1464 | if ((Doc->appMode == modeEdit) && (currItem->isSelected()) && (currItem->itemType() == PageItem::TextFrame)) |
456 | fschmid | 1465 | { |
1764 | cbradney | 1466 | //CB 230305 Stop redrawing the horizontal ruler if it hasnt changed when typing text!!! |
3934 | cbradney | 1467 | if ((qRound(horizRuler->ItemPos*10000) != qRound((currItem->xPos())*10000)) || (qRound(horizRuler->ItemEndPos*10000) != qRound(((currItem->xPos()+currItem->width()) )*10000))) |
1764 | cbradney | 1468 | { |
5569 | avox | 1469 | horizRuler->setItem(currItem); |
4546 | subik | 1470 | if (currItem->lineColor() != CommonStrings::None) |
4580 | cbradney | 1471 | horizRuler->lineCorr = currItem->lineWidth() / 2.0; |
1764 | cbradney | 1472 | else |
1473 | horizRuler->lineCorr = 0; |
||
1957 | cbradney | 1474 | horizRuler->ColGap = currItem->ColGap; |
1475 | horizRuler->Cols = currItem->Cols; |
||
3988 | cbradney | 1476 | horizRuler->Extra = currItem->textToFrameDistLeft(); |
1477 | horizRuler->RExtra = currItem->textToFrameDistRight(); |
||
5569 | avox | 1478 | horizRuler->First = currItem->currentStyle().firstIndent(); |
1479 | horizRuler->Indent = currItem->currentStyle().leftMargin(); |
||
1480 | double columnWidth = (currItem->width() - (currItem->columnGap() * (currItem->columns() - 1)) |
||
1481 | - currItem->textToFrameDistLeft() - currItem->textToFrameDistLeft() |
||
1482 | - 2*horizRuler->lineCorr) / currItem->columns(); |
||
1483 | horizRuler->RMargin = columnWidth - currItem->currentStyle().rightMargin(); |
||
3988 | cbradney | 1484 | if (currItem->imageFlippedH() || (currItem->reversed())) |
1764 | cbradney | 1485 | horizRuler->Revers = true; |
1486 | else |
||
1487 | horizRuler->Revers = false; |
||
1488 | horizRuler->ItemPosValid = true; |
||
5569 | avox | 1489 | horizRuler->TabValues = currItem->currentStyle().tabValues(); |
9391 | fschmid | 1490 | horizRuler->update(); |
1764 | cbradney | 1491 | } |
456 | fschmid | 1492 | } |
1493 | } |
||
6451 | fschmid | 1494 | if (groupStack.count() != 0) |
1495 | { |
||
1496 | while (currItem == groupStack.top()) |
||
1497 | { |
||
7049 | fschmid | 1498 | painter->endLayer(); |
6451 | fschmid | 1499 | painter->restore(); |
7549 | fschmid | 1500 | PageItem *cite = groupStack2.pop(); |
1501 | oldR = cite->getRedrawBounding(Scale); |
||
8494 | fschmid | 1502 | if ((clip.intersects(oldR)) && (((Doc->guidesSettings.layerMarkersShown) && (Doc->layerCount() > 1)) || (cite->textFlowUsesContourLine()))) |
7549 | fschmid | 1503 | cite->DrawObj(painter, clip); |
6451 | fschmid | 1504 | groupStack.pop(); |
1505 | } |
||
1506 | } |
||
456 | fschmid | 1507 | } |
8501 | cbradney | 1508 | Q3PtrListIterator<PageItem> docItem2(*Doc->Items); |
3689 | cbradney | 1509 | while ( (currItem = docItem2.current()) != 0 ) |
1510 | { |
||
2538 | fschmid | 1511 | ++docItem2; |
1957 | cbradney | 1512 | if (currItem->LayerNr != ll.LNr) |
456 | fschmid | 1513 | continue; |
1957 | cbradney | 1514 | if (!currItem->isTableItem) |
456 | fschmid | 1515 | continue; |
7137 | fschmid | 1516 | if ((previewMode) && (!currItem->printEnabled())) |
1517 | continue; |
||
1518 | if ((viewAsPreview) && (!currItem->printEnabled())) |
||
1519 | continue; |
||
7537 | fschmid | 1520 | oldR = currItem->getRedrawBounding(Scale); |
537 | fschmid | 1521 | if (clip.intersects(oldR)) |
456 | fschmid | 1522 | { |
7141 | fschmid | 1523 | painter->save(); |
1524 | painter->translate(currItem->xPos(), currItem->yPos()); |
||
3934 | cbradney | 1525 | painter->rotate(currItem->rotation()); |
6570 | fschmid | 1526 | if ((currItem->lineColor() != CommonStrings::None) && (currItem->lineWidth() != 0.0)) |
456 | fschmid | 1527 | { |
1528 | QColor tmp; |
||
1957 | cbradney | 1529 | currItem->SetFarbe(&tmp, currItem->lineColor(), currItem->lineShade()); |
1530 | if ((currItem->TopLine) || (currItem->RightLine) || (currItem->BottomLine) || (currItem->LeftLine)) |
||
456 | fschmid | 1531 | { |
4580 | cbradney | 1532 | painter->setPen(tmp, currItem->lineWidth(), currItem->PLineArt, Qt::SquareCap, currItem->PLineJoin); |
1957 | cbradney | 1533 | if (currItem->TopLine) |
3934 | cbradney | 1534 | painter->drawLine(FPoint(0.0, 0.0), FPoint(currItem->width(), 0.0)); |
1957 | cbradney | 1535 | if (currItem->RightLine) |
3934 | cbradney | 1536 | painter->drawLine(FPoint(currItem->width(), 0.0), FPoint(currItem->width(), currItem->height())); |
1957 | cbradney | 1537 | if (currItem->BottomLine) |
3934 | cbradney | 1538 | painter->drawLine(FPoint(currItem->width(), currItem->height()), FPoint(0.0, currItem->height())); |
1957 | cbradney | 1539 | if (currItem->LeftLine) |
3934 | cbradney | 1540 | painter->drawLine(FPoint(0.0, currItem->height()), FPoint(0.0, 0.0)); |
456 | fschmid | 1541 | } |
1542 | } |
||
1543 | painter->restore(); |
||
1544 | } |
||
1545 | } |
||
5373 | fschmid | 1546 | if ((layerCount > 1) || (ll.transparency != 1.0)) |
1547 | painter->endLayer(); |
||
456 | fschmid | 1548 | } |
1549 | Lnr++; |
||
1550 | } |
||
1551 | } |
||
1552 | } |
||
1553 | |||
5166 | fschmid | 1554 | void ScribusView::DrawPageMarks(ScPainter *p, Page *page, QRect clip) |
456 | fschmid | 1555 | { |
1556 | p->save(); |
||
6809 | fschmid | 1557 | p->setAntialiasing(false); |
7141 | fschmid | 1558 | p->translate(page->xOffset(), page->yOffset()); |
6809 | fschmid | 1559 | double lineWidth = 1.0 / Scale; |
3226 | cbradney | 1560 | double pageHeight=page->height(); |
1561 | double pageWidth=page->width(); |
||
7157 | fschmid | 1562 | p->setFillMode(ScPainter::None); |
8522 | cbradney | 1563 | p->setPen(Qt::black, lineWidth, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
7157 | fschmid | 1564 | p->drawRect(0, 0, pageWidth, pageHeight); |
3962 | cbradney | 1565 | //Draw the margins |
879 | fschmid | 1566 | if (Doc->guidesSettings.marginsShown) |
456 | fschmid | 1567 | { |
879 | fschmid | 1568 | p->setPen(Doc->guidesSettings.margColor); |
1065 | cbradney | 1569 | if (Doc->marginColored) |
456 | fschmid | 1570 | { |
879 | fschmid | 1571 | p->setBrush(Doc->guidesSettings.margColor); |
3226 | cbradney | 1572 | p->drawRect(0, 0, pageWidth, page->Margins.Top); |
1573 | p->drawRect(0, page->Margins.Top, page->Margins.Left, pageHeight - page->Margins.Top); |
||
1574 | p->drawRect(page->Margins.Left, pageHeight - page->Margins.Bottom, pageWidth - page->Margins.Right - page->Margins.Left, page->Margins.Bottom); |
||
1575 | p->drawRect(pageWidth - page->Margins.Right, page->Margins.Top, page->Margins.Right, pageHeight-page->Margins.Top); |
||
456 | fschmid | 1576 | } |
7179 | fschmid | 1577 | // p->setPen(Doc->guidesSettings.margColor); |
1578 | p->setFillMode(ScPainter::None); |
||
7206 | fschmid | 1579 | p->drawRect(page->Margins.Left, page->Margins.Top, pageWidth - page->Margins.Left - page->Margins.Right, pageHeight - page->Margins.Top - page->Margins.Bottom); |
7179 | fschmid | 1580 | // p->drawLine(FPoint(0, page->Margins.Top), FPoint(pageWidth, page->Margins.Top)); |
1581 | // p->drawLine(FPoint(0, pageHeight - page->Margins.Bottom), FPoint(pageWidth, pageHeight - page->Margins.Bottom)); |
||
1582 | // p->drawLine(FPoint(page->Margins.Left, 0), FPoint(page->Margins.Left, pageHeight)); |
||
1583 | // p->drawLine(FPoint(pageWidth - page->Margins.Right, 0), FPoint(pageWidth - page->Margins.Right, pageHeight)); |
||
456 | fschmid | 1584 | } |
3962 | cbradney | 1585 | //Draw the baseline grid |
879 | fschmid | 1586 | if (Doc->guidesSettings.baseShown) |
456 | fschmid | 1587 | { |
8522 | cbradney | 1588 | p->setPen(Doc->guidesSettings.baseColor, lineWidth, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
3226 | cbradney | 1589 | for (double yg = Doc->typographicSettings.offsetBaseGrid; yg < pageHeight; yg += Doc->typographicSettings.valueBaseGrid) |
1590 | p->drawLine(FPoint(0, yg), FPoint(pageWidth, yg)); |
||
456 | fschmid | 1591 | } |
3962 | cbradney | 1592 | //Draw the grid lines |
879 | fschmid | 1593 | if (Doc->guidesSettings.gridShown) |
456 | fschmid | 1594 | { |
8573 | jghali | 1595 | double lowerBx = qMax(clip.x() / Scale + Doc->minCanvasCoordinate.x() - page->xOffset(), 0.0); |
1596 | double lowerBy = qMax(clip.y() / Scale + Doc->minCanvasCoordinate.y() - page->yOffset(), 0.0); |
||
8562 | jghali | 1597 | double highBx = qMin(lowerBx + clip.width() / Scale, pageWidth); |
1598 | double highBy = qMin(lowerBy + clip.height() / Scale, pageHeight); |
||
456 | fschmid | 1599 | if (Scale > 0.49) |
1600 | { |
||
1601 | double i,start; |
||
879 | fschmid | 1602 | i = Doc->guidesSettings.majorGrid; |
8522 | cbradney | 1603 | p->setPen(Doc->guidesSettings.majorColor, lineWidth, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
5233 | fschmid | 1604 | start=floor(lowerBy/i); |
456 | fschmid | 1605 | start*=i; |
5233 | fschmid | 1606 | for (double b = start; b <= highBy; b+=i) |
5166 | fschmid | 1607 | { |
8573 | jghali | 1608 | p->drawLine(FPoint(qMax(lowerBx, 0.0), b), FPoint(qMin(pageWidth, highBx), b)); |
5166 | fschmid | 1609 | } |
5233 | fschmid | 1610 | start=floor(lowerBx/i); |
456 | fschmid | 1611 | start*=i; |
5233 | fschmid | 1612 | for (double b = start; b <= highBx; b+=i) |
5166 | fschmid | 1613 | { |
8573 | jghali | 1614 | p->drawLine(FPoint(b, qMax(lowerBy, 0.0)), FPoint(b, qMin(pageHeight, highBy))); |
5166 | fschmid | 1615 | } |
879 | fschmid | 1616 | i = Doc->guidesSettings.minorGrid; |
8522 | cbradney | 1617 | p->setPen(Doc->guidesSettings.minorColor, lineWidth, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin); |
5233 | fschmid | 1618 | start=floor(lowerBy/i); |
456 | fschmid | 1619 | start*=i; |
5233 | fschmid | 1620 | for (double b = start; b <= highBy; b+=i) |
5166 | fschmid | 1621 | { |
8573 | jghali | 1622 | p->drawLine(FPoint(qMax(lowerBx, 0.0), b), FPoint(qMin(pageWidth, highBx), b)); |
5166 | fschmid | 1623 | } |
5233 | fschmid | 1624 | start=floor(lowerBx/i); |
456 | fschmid | 1625 | start*=i; |
5233 | fschmid | 1626 | for (double b = start; b <= highBx; b+=i) |
5166 | fschmid | 1627 | { |
8573 | jghali | 1628 | p->drawLine(FPoint(b, qMax(lowerBy, 0.0)), FPoint(b, qMin(pageHeight, highBy))); |
5166 | fschmid | 1629 | } |
456 | fschmid | 1630 | } |
1631 | } |
||
3962 | cbradney | 1632 | //Draw the guides |
879 | fschmid | 1633 | if (Doc->guidesSettings.guidesShown) |
5087 | subik | 1634 | page->guides.drawPage(p, Doc, lineWidth); |
7285 | fschmid | 1635 | if (Doc->currentPage() == page) |
1636 | { |
||
8501 | cbradney | 1637 | p->setPen(Prefs->DPageBorderColor, 2 / Scale, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
7285 | fschmid | 1638 | p->drawRect(0, 0, pageWidth, pageHeight); |
1639 | } |
||
6809 | fschmid | 1640 | p->setAntialiasing(true); |
1641 | |||
456 | fschmid | 1642 | p->restore(); |
1643 | } |
||
1644 | |||
6583 | fschmid | 1645 | void ScribusView::enterEvent(QEvent *) |
1646 | { |
||
1647 | if (!m_MouseButtonPressed) |
||
1648 | { |
||
1649 | switch (Doc->appMode) |
||
1650 | { |
||
1651 | case modeDrawShapes: |
||
9380 | fschmid | 1652 | qApp->changeOverrideCursor(QCursor(loadIcon("DrawFrame.xpm"))); |
6583 | fschmid | 1653 | break; |
1654 | case modeDrawPicture: |
||
9380 | fschmid | 1655 | qApp->changeOverrideCursor(QCursor(loadIcon("DrawImageFrame.xpm"))); |
6583 | fschmid | 1656 | break; |
1657 | case modeDrawText: |
||