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