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