00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "canvasmode_create.h"
00018
00019 #include <QApplication>
00020 #include <QButtonGroup>
00021 #include <QCheckBox>
00022 #include <QCursor>
00023 #include <QEvent>
00024 #include <QMessageBox>
00025 #include <QMouseEvent>
00026 #include <QPainterPath>
00027 #include <QPoint>
00028 #include <QRect>
00029 #include <QWidgetAction>
00030
00031
00032 #include "canvas.h"
00033 #include "canvasgesture_resize.h"
00034 #include "canvasgesture_linemove.h"
00035 #include "fpoint.h"
00036 #include "fpointarray.h"
00037 #include "hruler.h"
00038 #include "vruler.h"
00039 #include "hyphenator.h"
00040 #include "insertTable.h"
00041 #include "oneclick.h"
00042 #include "pageitem_textframe.h"
00043 #include "pageselector.h"
00044 #include "prefscontext.h"
00045 #include "prefsfile.h"
00046 #include "prefsmanager.h"
00047 #include "propertiespalette.h"
00048 #include "scraction.h"
00049 #include "scrapbookpalette.h"
00050 #include "scribus.h"
00051 #include "scribusdoc.h"
00052 #include "scribusview.h"
00053 #include "scribusXml.h"
00054 #include "selection.h"
00055 #include "undomanager.h"
00056 #include "units.h"
00057 #include "util.h"
00058 #include "util_icon.h"
00059 #include "util_math.h"
00060
00061
00062
00063 CreateMode::CreateMode(ScribusView* view) : CanvasMode(view)
00064 {
00065 GxM = GyM = -1;
00066 Mxp = Myp = -1;
00067 Dxp = Dyp = -1;
00068 MoveGX = MoveGY = false;
00069 oldCp = Cp = -1;
00070 frameResizeHandle = -1;
00071 RotMode = 0;
00072 inItemCreation = false;
00073 m_createTransaction = NULL;
00074 shiftSelItems = false;
00075 FirstPoly = true;
00076 resizeGesture = NULL;
00077 lineMoveGesture = NULL;
00078 }
00079
00080
00081 void CreateMode::drawControls(QPainter* p)
00082 {
00083
00084 }
00085
00086 inline bool CreateMode::GetItem(PageItem** pi)
00087 {
00088 *pi = m_doc->m_Selection->itemAt(0);
00089 return (*pi) != NULL;
00090 }
00091
00092
00093
00094
00095
00096
00097
00098 void CreateMode::enterEvent(QEvent *)
00099 {
00100 if (!m_MouseButtonPressed)
00101 {
00102 setModeCursor();
00103 }
00104 }
00105
00106
00107 void CreateMode::leaveEvent(QEvent *e)
00108 {
00109 if (!m_MouseButtonPressed)
00110 qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
00111 }
00112
00113
00114 void CreateMode::activate(bool fromGesture)
00115 {
00116 PageItem* currItem;
00117 qDebug() << "CreateMode::activate" << fromGesture;
00118 if (fromGesture && GetItem(&currItem) && m_createTransaction)
00119 {
00120 double itemX = fabs(currItem->width());
00121 double itemY = fabs(currItem->height());
00122 if ((!m_view->moveTimerElapsed()) || ((itemX < 2.0) && (itemY < 2.0)))
00123 {
00124 PrefsContext* sizes = PrefsManager::instance()->prefsFile->getContext("ObjectSize");
00125 double xSize, ySize;
00126 int originPoint;
00127 xSize = sizes->getDouble("defWidth", 100.0);
00128 ySize = sizes->getDouble("defHeight", 100.0);
00129 originPoint = sizes->getInt("Origin", 0);
00130 bool doRemember = sizes->getBool("Remember", true);
00131 bool doCreate = false;
00132
00133
00134
00135 {
00136 qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
00137 OneClick *dia = new OneClick(m_view, ScribusView::tr("Enter Object Size"), m_doc->unitIndex(), xSize, ySize, doRemember, originPoint, 0);
00138 if (dia->exec())
00139 {
00140 doRemember = dia->checkRemember->isChecked();
00141 xSize = dia->spinWidth->value() / unitGetRatioFromIndex(m_doc->unitIndex());
00142 ySize = dia->spinHeight->value() / unitGetRatioFromIndex(m_doc->unitIndex());
00143 originPoint = dia->RotationGroup->checkedId();
00144 if (doRemember)
00145 {
00146 sizes->set("defWidth", xSize);
00147 sizes->set("defHeight", ySize);
00148 sizes->set("Origin", originPoint);
00149 }
00150 sizes->set("Remember", doRemember);
00151 doCreate = true;
00152 }
00153 else
00154 {
00155 m_view->Deselect(false);
00156 m_doc->Items->removeAt(currItem->ItemNr);
00157 }
00158 delete dia;
00159 }
00160 if (doCreate)
00161 {
00162 bool oldSnap = m_doc->SnapGuides;
00163 m_doc->SnapGuides = false;
00164 currItem->Sizing = false;
00165 m_doc->SizeItem(xSize, ySize, currItem->ItemNr, false, true, false);
00166 m_doc->AdjustItemSize(currItem);
00167 currItem->ContourLine = currItem->PoLine.copy();
00168 switch (originPoint)
00169 {
00170 case 0:
00171 break;
00172 case 1:
00173 m_doc->MoveItem(-currItem->width(), 0.0, currItem, false);
00174 break;
00175 case 2:
00176 m_doc->MoveItem(-currItem->width() / 2.0, -currItem->height() / 2.0, currItem, false);
00177 break;
00178 case 3:
00179 m_doc->MoveItem(0.0, -currItem->height(), currItem, false);
00180 break;
00181 case 4:
00182 m_doc->MoveItem(-currItem->width(), -currItem->height(), currItem, false);
00183 break;
00184 }
00185 m_doc->setRedrawBounding(currItem);
00186 currItem->OwnPage = m_doc->OnPage(currItem);
00187 currItem->OldB2 = currItem->width();
00188 currItem->OldH2 = currItem->height();
00189 currItem->Sizing = false;
00190 m_view->resetMousePressed();
00191 currItem->checkChanges();
00192 QString targetName = Um::ScratchSpace;
00193 if (currItem->OwnPage > -1)
00194 targetName = m_doc->Pages->at(currItem->OwnPage)->getUName();
00195 m_createTransaction->commit(targetName, currItem->getUPixmap(),
00196 Um::Create + " " + currItem->getUName(), "", Um::ICreate);
00197 m_doc->SnapGuides = oldSnap;
00198 currItem->update();
00199 }
00200 else
00201 {
00202 m_createTransaction->cancel();
00203 }
00204 delete m_createTransaction;
00205 m_createTransaction = NULL;
00206 inItemCreation = false;
00207 }
00208 else
00209 {
00210 if (!currItem->asLine())
00211 m_doc->AdjustItemSize(currItem);
00212 else
00213 {
00214
00215
00216 currItem->updateClip();
00217 }
00218 currItem->ContourLine = currItem->PoLine.copy();
00219 m_doc->setRedrawBounding(currItem);
00220 currItem->OwnPage = m_doc->OnPage(currItem);
00221 currItem->Sizing = false;
00222 m_view->resetMousePressed();
00223 currItem->checkChanges();
00224 QString targetName = Um::ScratchSpace;
00225 if (currItem->OwnPage > -1)
00226 targetName = m_doc->Pages->at(currItem->OwnPage)->getUName();
00227 m_createTransaction->commit(targetName, currItem->getUPixmap(),
00228 Um::Create + " " + currItem->getUName(), "", Um::ICreate);
00229 delete m_createTransaction;
00230 m_createTransaction = NULL;
00231 currItem->update();
00232 inItemCreation = false;
00233 }
00234 m_doc->changed();
00235 if (!PrefsManager::instance()->appPrefs.stickyTools)
00236 {
00237 m_view->requestMode(modeNormal);
00238 }
00239 else
00240 m_view->updateCanvas();
00241 }
00242 else
00243 {
00244 if (m_createTransaction)
00245 {
00246 qDebug() << "canceling left over create Transaction";
00247 m_createTransaction->cancel();
00248 delete m_createTransaction;
00249 m_createTransaction = NULL;
00250 }
00251 GxM = GyM = -1;
00252 Mxp = Myp = -1;
00253 Dxp = Dyp = -1;
00254 MoveGX = MoveGY = false;
00255 oldCp = Cp = -1;
00256 frameResizeHandle = -1;
00257 RotMode = 0;
00258 inItemCreation = false;
00259 shiftSelItems = false;
00260 FirstPoly = true;
00261 }
00262 setModeCursor();
00263 }
00264
00265 void CreateMode::deactivate(bool forGesture)
00266 {
00267 qDebug() << "CreateMode::deactivate" << forGesture;
00268 m_view->redrawMarker->hide();
00269 if (!forGesture)
00270 {
00271 if (m_createTransaction)
00272 {
00273 qDebug() << "CreateMode::deactivate: canceling left over create Transaction";
00274 m_createTransaction->cancel();
00275 delete m_createTransaction;
00276 m_createTransaction = NULL;
00277 }
00278 }
00279 }
00280
00281 void CreateMode::mouseDoubleClickEvent(QMouseEvent *m)
00282 {
00283 m->accept();
00284 m_MouseButtonPressed = false;
00285 m_canvas->resetRenderMode();
00286 }
00287
00288
00289 void CreateMode::mouseMoveEvent(QMouseEvent *m)
00290 {
00291 const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
00292
00293 double newX, newY;
00294 PageItem *currItem;
00295 QPoint np, np2, mop;
00296 FPoint npf, npf2;
00297 QPainter p;
00298 QRect tx;
00299 m->accept();
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318 if (m_MouseButtonPressed && (m->buttons() & Qt::RightButton) && (m->modifiers() & Qt::ControlModifier))
00319 {
00320 m_view->requestMode(modePanning);
00321 }
00322
00323
00324 if ((GetItem(&currItem)) && (!shiftSelItems))
00325 {
00326 newX = qRound(mousePointDoc.x());
00327 newY = qRound(mousePointDoc.y());
00328
00329 if (m_doc->DragP)
00330 return;
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361 }
00362 else
00363 {
00364 if ((m_MouseButtonPressed) && (m->buttons() & Qt::LeftButton) && (GyM == -1) && (GxM == -1))
00365 {
00366 newX = qRound(mousePointDoc.x());
00367 if (m_doc->appMode == modeMagnifier)
00368 newY = qRound(Myp + ((SeRx - Mxp) * m_view->visibleHeight()) / m_view->visibleWidth());
00369 else
00370 newY = qRound(mousePointDoc.y());
00371 if (m_doc->appMode == modeDrawTable)
00372 {
00373 FPoint np2 = m_doc->ApplyGridF(FPoint(newX, newY));
00374 double nx = np2.x();
00375 double ny = np2.y();
00376 m_doc->ApplyGuides(&nx, &ny);
00377 newX = qRound(nx);
00378 newY = qRound(ny);
00379 GyM = -1;
00380 GxM = -1;
00381 SeRx = newX;
00382 SeRy = newY;
00383 QPoint startP = m_canvas->canvasToGlobal(QPointF(Mxp, Myp));
00384 m_view->redrawMarker->setGeometry(QRect(startP, m->globalPos()).normalized());
00385 if (!m_view->redrawMarker->isVisible())
00386 m_view->redrawMarker->show();
00387 m_view->HaveSelRect = true;
00388 }
00389 }
00390 }
00391 }
00392
00393 void CreateMode::mousePressEvent(QMouseEvent *m)
00394 {
00395 const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
00396
00397 int z;
00398 double Rxp = 0;
00399 double Ryp = 0;
00400 double Rxpd = 0;
00401 double Rypd = 0;
00402 PageItem *currItem;
00403 QPainter p;
00404
00405 FPoint npf, npf2;
00406 QRect tx;
00407 QMatrix pm;
00408 m_MouseButtonPressed = true;
00409 m_view->HaveSelRect = false;
00410 m_doc->DragP = false;
00411 m_doc->leaveDrag = false;
00412 MoveGX = MoveGY = false;
00413 inItemCreation = false;
00414
00415 m->accept();
00416 m_view->registerMousePress(m->globalPos());
00417 Mxp = mousePointDoc.x();
00418 Myp = mousePointDoc.y();
00419 QRect mpo(m->x()-m_doc->guidesSettings.grabRad, m->y()-m_doc->guidesSettings.grabRad, m_doc->guidesSettings.grabRad*2, m_doc->guidesSettings.grabRad*2);
00420
00421 Rxp = m_doc->ApplyGridF(FPoint(Mxp, Myp)).x();
00422 Rxpd = Mxp - Rxp;
00423 Mxp = qRound(Rxp);
00424 Ryp = m_doc->ApplyGridF(FPoint(Mxp, Myp)).y();
00425 Rypd = Myp - Ryp;
00426 Myp = qRound(Ryp);
00427 SeRx = Mxp;
00428 SeRy = Myp;
00429 if (m->button() == Qt::MidButton)
00430 {
00431 m_view->MidButt = true;
00432 m_view->DrawNew();
00433 return;
00434 }
00435 m_createTransaction = new UndoTransaction(Um::instance()->beginTransaction("creating"));
00436 switch (m_doc->appMode)
00437 {
00438 case modeDrawShapes:
00439 if (m->button() != Qt::LeftButton)
00440 break;
00441 selectPage(m);
00442 switch (m_doc->SubMode)
00443 {
00444 case 0:
00445 if (m->modifiers() == Qt::ShiftModifier)
00446 {
00447 z = m_doc->itemAddArea(PageItem::Polygon, PageItem::Rectangle, Rxp, Ryp, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, true);
00448 m_doc->Items->at(z)->FrameType = 0;
00449 SetupDrawNoResize(z);
00450 }
00451 else
00452 {
00453 m_doc->ApplyGuides(&Rxp, &Ryp);
00454 z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, true);
00455 m_doc->Items->at(z)->FrameType = 0;
00456 SetupDraw(z);
00457 }
00458 break;
00459 case 1:
00460 if (m->modifiers() == Qt::ShiftModifier)
00461 {
00462 z = m_doc->itemAddArea(PageItem::Polygon, PageItem::Ellipse, Rxp, Ryp, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, true);
00463 m_doc->Items->at(z)->FrameType = 1;
00464 SetupDrawNoResize(z);
00465 }
00466 else
00467 {
00468 m_doc->ApplyGuides(&Rxp, &Ryp);
00469 z = m_doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, true);
00470 m_doc->Items->at(z)->FrameType = 1;
00471 SetupDraw(z);
00472 }
00473 break;
00474 default:
00475 if (m->modifiers() == Qt::ShiftModifier)
00476 {
00477 z = m_doc->itemAddArea(PageItem::Polygon, PageItem::Unspecified, Rxp, Ryp, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, true);
00478 m_doc->Items->at(z)->SetFrameShape(m_doc->ValCount, m_doc->ShapeValues);
00479 m_doc->setRedrawBounding(m_doc->Items->at(z));
00480 m_doc->Items->at(z)->FrameType = m_doc->SubMode+2;
00481 SetupDrawNoResize(z);
00482 }
00483 else
00484 {
00485 m_doc->ApplyGuides(&Rxp, &Ryp);
00486 z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, true);
00487 m_doc->Items->at(z)->SetFrameShape(m_doc->ValCount, m_doc->ShapeValues);
00488 m_doc->setRedrawBounding(m_doc->Items->at(z));
00489 m_doc->Items->at(z)->FrameType = m_doc->SubMode+2;
00490 SetupDraw(z);
00491 }
00492 break;
00493 }
00494 break;
00495 case modeDrawLine:
00496 if (m->button() != Qt::LeftButton)
00497 break;
00498 selectPage(m);
00499 m_doc->ApplyGuides(&Rxp, &Ryp);
00500 z = m_doc->itemAdd(PageItem::Line, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1, m_doc->toolSettings.dWidthLine, CommonStrings::None, m_doc->toolSettings.dPenLine, true);
00501 SetupDraw(z);
00502 break;
00503 case modeDrawLatex:
00504 if (m->button() != Qt::LeftButton)
00505 break;
00506 selectPage(m);
00507 if (m->modifiers() == Qt::ShiftModifier)
00508 {
00509 z = m_doc->itemAddArea(PageItem::LatexFrame, PageItem::Unspecified, Rxp, Ryp, 1, m_doc->toolSettings.dBrushPict, CommonStrings::None, true);
00510 SetupDrawNoResize(z);
00511 }
00512 else
00513 {
00514 m_doc->ApplyGuides(&Rxp, &Ryp);
00515 z = m_doc->itemAdd(PageItem::LatexFrame, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, 1, m_doc->toolSettings.dBrushPict, CommonStrings::None, true);
00516 SetupDraw(z);
00517 }
00518 break;
00519 case modeDrawImage:
00520 if (m->button() != Qt::LeftButton)
00521 break;
00522 selectPage(m);
00523 if (m->modifiers() == Qt::ShiftModifier)
00524 {
00525 z = m_doc->itemAddArea(PageItem::ImageFrame, PageItem::Unspecified, Rxp, Ryp, 1, m_doc->toolSettings.dBrushPict, CommonStrings::None, true);
00526 SetupDrawNoResize(z);
00527 }
00528 else
00529 {
00530 m_doc->ApplyGuides(&Rxp, &Ryp);
00531 z = m_doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, 1, m_doc->toolSettings.dBrushPict, CommonStrings::None, true);
00532 SetupDraw(z);
00533 }
00534 break;
00535 case modeDrawText:
00536 if (m->button() != Qt::LeftButton)
00537 break;
00538 selectPage(m);
00539 if (m->modifiers() == Qt::ShiftModifier)
00540 {
00541 z = m_doc->itemAddArea(PageItem::TextFrame, PageItem::Unspecified, Rxp, Ryp, m_doc->toolSettings.dWidth, CommonStrings::None, m_doc->toolSettings.dPenText, true);
00542 SetupDrawNoResize(z);
00543 }
00544 else
00545 {
00546 m_doc->ApplyGuides(&Rxp, &Ryp);
00547 z = m_doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->toolSettings.dWidth, CommonStrings::None, m_doc->toolSettings.dPenText, true);
00548 SetupDraw(z);
00549 }
00550 break;
00551 case modeDrawRegularPolygon:
00552 {
00553 if (m->button() != Qt::LeftButton)
00554 break;
00555 selectPage(m);
00556 if (m->modifiers() == Qt::ShiftModifier)
00557 z = m_doc->itemAddArea(PageItem::Polygon, PageItem::Unspecified, Rxp, Ryp, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, true);
00558 else
00559 {
00560 m_doc->ApplyGuides(&Rxp, &Ryp);
00561 z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, true);
00562 }
00563 currItem = m_doc->Items->at(z);
00564 FPointArray cli = RegularPolygonF(currItem->width(), currItem->height(), m_doc->toolSettings.polyC, m_doc->toolSettings.polyS, m_doc->toolSettings.polyF, m_doc->toolSettings.polyR);
00565 FPoint np(cli.point(0));
00566 currItem->PoLine.resize(2);
00567 currItem->PoLine.setPoint(0, np);
00568 currItem->PoLine.setPoint(1, np);
00569 for (uint ax = 1; ax < cli.size(); ++ax)
00570 {
00571 np = FPoint(cli.point(ax));
00572 currItem->PoLine.putPoints(currItem->PoLine.size(), 4, np.x(), np.y(), np.x(), np.y(), np.x(), np.y(), np.x(), np.y());
00573 }
00574 np = FPoint(cli.point(0));
00575 currItem->PoLine.putPoints(currItem->PoLine.size(), 2, np.x(), np.y(), np.x(), np.y());
00576 currItem->Clip = FlattenPath(currItem->PoLine, currItem->Segments);
00577 if (m->modifiers() == Qt::ShiftModifier)
00578 {
00579 SetupDrawNoResize(z);
00580 }
00581 else
00582 {
00583 SetupDraw(z);
00584 }
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604 break;
00605 }
00606 case modeInsertPDFButton:
00607 case modeInsertPDFTextfield:
00608 case modeInsertPDFCheckbox:
00609 case modeInsertPDFCombobox:
00610 case modeInsertPDFListbox:
00611 case modeInsertPDFTextAnnotation:
00612 case modeInsertPDFLinkAnnotation:
00613 if (m->button() != Qt::LeftButton)
00614 break;
00615 selectPage(m);
00616 m_doc->ApplyGuides(&Rxp, &Ryp);
00617 z = m_doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->toolSettings.dWidth, CommonStrings::None, m_doc->toolSettings.dPenText, true);
00618 currItem = m_doc->Items->at(z);
00619 currItem->setIsAnnotation(true);
00620 currItem->AutoName = false;
00621 switch (m_doc->appMode)
00622 {
00623 case modeInsertPDFButton:
00624 currItem->annotation().setType(2);
00625 currItem->annotation().setFlag(65536);
00626 break;
00627 case modeInsertPDFTextfield:
00628 currItem->annotation().setType(3);
00629 break;
00630 case modeInsertPDFCheckbox:
00631 currItem->annotation().setType(4);
00632 break;
00633 case modeInsertPDFCombobox:
00634 currItem->annotation().setType(5);
00635 currItem->annotation().setFlag(131072);
00636 break;
00637 case modeInsertPDFListbox:
00638 currItem->annotation().setType(6);
00639 break;
00640 case modeInsertPDFTextAnnotation:
00641 currItem->annotation().setType(10);
00642 break;
00643 case modeInsertPDFLinkAnnotation:
00644 currItem->annotation().setType(11);
00645 currItem->annotation().setZiel(m_doc->currentPage()->pageNr());
00646 currItem->annotation().setAction("0 0");
00647 currItem->setTextFlowMode(PageItem::TextFlowDisabled);
00648 break;
00649 }
00650 SetupDraw(z);
00651 break;
00652 case modeDrawTable:
00653 if (m->button() != Qt::LeftButton)
00654 break;
00655 m_view->Deselect(false);
00656
00657
00658 Rxp = mousePointDoc.x();
00659 Ryp = mousePointDoc.y();
00660 npf = m_doc->ApplyGridF(FPoint(Rxp, Ryp));
00661 Rxp = npf.x();
00662 Ryp = npf.y();
00663 m_doc->ApplyGuides(&Rxp, &Ryp);
00664 GyM = -1;
00665 GxM = -1;
00666 Mxp = qRound(Rxp);
00667 Myp = qRound(Ryp);
00668 SeRx = Mxp;
00669 SeRy = Myp;
00670 Dxp = m->globalPos().x();
00671 Dyp = m->globalPos().y();
00672 m_view->redrawMarker->setGeometry(m->globalPos().x(), m->globalPos().y(), 1, 1);
00673 m_view->redrawMarker->show();
00674 break;
00675 }
00676 }
00677
00678
00679
00680 void CreateMode::mouseReleaseEvent(QMouseEvent *m)
00681 {
00682 const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
00683
00684 PageItem *currItem;
00685 m_MouseButtonPressed = false;
00686 m_canvas->resetRenderMode();
00687 m->accept();
00688 m_view->stopDragTimer();
00689 m_view->redrawMarker->hide();
00690
00691 if (GetItem(&currItem))
00692 {
00693 if ((m_doc->appMode == modeDrawRegularPolygon) && (inItemCreation))
00694 {
00695 double itemX = fabs(currItem->width());
00696 double itemY = fabs(currItem->height());
00697 if ((!m_view->moveTimerElapsed()) || ((itemX < 2.0) && (itemY < 2.0)))
00698 {
00699 PrefsContext* sizes = PrefsManager::instance()->prefsFile->getContext("ObjectSize");
00700 double xSize, ySize;
00701 int originPoint;
00702 xSize = sizes->getDouble("defWidth", 100.0);
00703 ySize = sizes->getDouble("defHeight", 100.0);
00704 originPoint = sizes->getInt("Origin", 0);
00705 bool doRemember = sizes->getBool("Remember", true);
00706 bool doCreate = false;
00707 if (m->modifiers() & (Qt::ShiftModifier | Qt::ControlModifier))
00708 doCreate = true;
00709 else
00710 {
00711 qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
00712 OneClick *dia = new OneClick(m_view, ScribusView::tr("Enter Object Size"), m_doc->unitIndex(), xSize, ySize, doRemember, originPoint, 0);
00713 if (dia->exec())
00714 {
00715 doRemember = dia->checkRemember->isChecked();
00716 xSize = dia->spinWidth->value() / unitGetRatioFromIndex(m_doc->unitIndex());
00717 ySize = dia->spinHeight->value() / unitGetRatioFromIndex(m_doc->unitIndex());
00718 originPoint = dia->RotationGroup->checkedId();
00719 if (doRemember)
00720 {
00721 sizes->set("defWidth", xSize);
00722 sizes->set("defHeight", ySize);
00723 sizes->