void CanvasMode_CopyProperties::mousePressEvent(QMouseEvent *m) { // const double mouseX = m->globalX(); // const double mouseY = m->globalY(); const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos()); double Rxp = 0, Ryp = 0; PageItem *currItem; m_canvas->PaintSizeRect(QRect()); m_canvas->m_viewMode.m_MouseButtonPressed = true; m_canvas->m_viewMode.operItemMoving = false; m_view->HaveSelRect = false; m_doc->DragP = false; m_doc->leaveDrag = false; m->accept(); m_view->registerMousePress(m->globalPos()); Mxp = mousePointDoc.x(); //qRound(m->x()/m_canvas->scale() + 0*m_doc->minCanvasCoordinate.x()); Myp = mousePointDoc.y(); //qRound(m->y()/m_canvas->scale() + 0*m_doc->minCanvasCoordinate.y()); Rxp = m_doc->ApplyGridF(FPoint(Mxp, Myp)).x(); Mxp = qRound(Rxp); Ryp = m_doc->ApplyGridF(FPoint(Mxp, Myp)).y(); Myp = qRound(Ryp); if (m->button() == Qt::MidButton) { m_view->MidButt = true; if (m->modifiers() & Qt::ControlModifier) m_view->DrawNew(); return; } if (m->button() != Qt::LeftButton) return; SeleItem(m); if (GetItem(&currItem)) { double sx, sy, ex, ey, r, skx, sky, fx, fy, ss, sk, sp; currItem->ColGap = m_doc->ElemToLink->ColGap; currItem->Cols = m_doc->ElemToLink->Cols; currItem->BottomLine = m_doc->ElemToLink->BottomLine; currItem->TopLine = m_doc->ElemToLink->TopLine; currItem->LeftLine = m_doc->ElemToLink->LeftLine; currItem->RightLine = m_doc->ElemToLink->RightLine; currItem->setTextToFrameDist(m_doc->ElemToLink->textToFrameDistLeft(), m_doc->ElemToLink->textToFrameDistRight(), m_doc->ElemToLink->textToFrameDistTop(), m_doc->ElemToLink->textToFrameDistBottom()); // Stroke Properties currItem->setLineStyle(m_doc->ElemToLink->lineStyle()); currItem->setLineWidth(m_doc->ElemToLink->lineWidth()); currItem->setLineTransparency(m_doc->ElemToLink->lineTransparency()); currItem->setLineShade(m_doc->ElemToLink->lineShade()); currItem->setLineColor(m_doc->ElemToLink->lineColor()); currItem->setLineEnd(m_doc->ElemToLink->lineEnd()); currItem->setLineJoin(m_doc->ElemToLink->lineJoin()); currItem->setCustomLineStyle(m_doc->ElemToLink->customLineStyle()); currItem->setEndArrowIndex(m_doc->ElemToLink->endArrowIndex()); currItem->setStartArrowIndex(m_doc->ElemToLink->startArrowIndex()); currItem->setEndArrowScale(m_doc->ElemToLink->endArrowScale()); currItem->setStartArrowScale(m_doc->ElemToLink->startArrowScale()); // Fill Properties currItem->setFillColor(m_doc->ElemToLink->fillColor()); currItem->setFillShade(m_doc->ElemToLink->fillShade()); currItem->setFillTransparency(m_doc->ElemToLink->fillTransparency()); // Gradient Properties currItem->fill_gradient = m_doc->ElemToLink->fill_gradient; currItem->setGradient(m_doc->ElemToLink->gradient()); m_doc->ElemToLink->gradientVector(sx, sy, ex, ey, fx, fy, ss, sk); currItem->setGradientVector(sx, sy, ex, ey, fx, fy, ss, sk); // Pattern Properties currItem->setPattern(m_doc->ElemToLink->pattern()); m_doc->ElemToLink->patternTransform(sx, sy, ex, ey, r, skx, sky); currItem->setPatternTransform(sx, sy, ex, ey, r, skx, sky); currItem->setStrokePattern(m_doc->ElemToLink->strokePattern()); m_doc->ElemToLink->strokePatternTransform(sx, sy, ex, ey, r, skx, sky, sp); currItem->setStrokePatternTransform(sx, sy, ex, ey, r, skx, sky, sp); currItem->setStrokePatternToPath(m_doc->ElemToLink->isStrokePatternToPath()); // Set Gradient type after all properties currItem->setGradientType(m_doc->ElemToLink->gradientType()); currItem->stroke_gradient = m_doc->ElemToLink->stroke_gradient; currItem->setStrokeGradient(m_doc->ElemToLink->strokeGradient()); m_doc->ElemToLink->strokeGradientVector(sx, sy, ex, ey, fx, fy, ss, sk); currItem->setStrokeGradientVector(sx, sy, ex, ey, fx, fy, ss, sk); currItem->setStrokeGradientType(m_doc->ElemToLink->strokeGradientType()); // Update Item m_doc->ElemToLink = currItem; currItem->update(); // emit DocChanged(); // m_view->updateContents(); } else { m_doc->ElemToLink = NULL; m_view->requestMode(submodePaintingDone); } }
void CanvasMode_FrameLinks::mousePressEvent(QMouseEvent *m) { // const double mouseX = m->globalX(); // const double mouseY = m->globalY(); const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos()); double Rxp = 0; double Ryp = 0; PageItem *currItem, *bb; m_canvas->PaintSizeRect(QRect()); m_canvas->m_viewMode.m_MouseButtonPressed = true; m_canvas->m_viewMode.operItemMoving = false; m_view->HaveSelRect = false; m_doc->DragP = false; m_doc->leaveDrag = false; // oldClip = 0; m->accept(); m_view->registerMousePress(m->globalPos()); Mxp = mousePointDoc.x(); //qRound(m->x()/m_canvas->scale() + 0*m_doc->minCanvasCoordinate.x()); Myp = mousePointDoc.y(); //qRound(m->y()/m_canvas->scale() + 0*m_doc->minCanvasCoordinate.y()); Rxp = m_doc->ApplyGridF(FPoint(Mxp, Myp)).x(); Mxp = qRound(Rxp); Ryp = m_doc->ApplyGridF(FPoint(Mxp, Myp)).y(); Myp = qRound(Ryp); SeRx = Mxp; SeRy = Myp; if (m->button() == Qt::MidButton) { m_view->MidButt = true; if (m->modifiers() & Qt::ControlModifier) m_view->DrawNew(); return; } switch (m_doc->appMode) { case modeLinkFrames: if (m->button() != Qt::LeftButton) break; currItem = m_doc->ElemToLink; if (currItem==NULL) break; SeleItem(m); if (GetItem(&bb) && (bb->asTextFrame())) { PageItem* bblast = bb; while (bblast->nextInChain()) bblast = bblast->nextInChain(); if (currItem->nextInChain() == 0 && bb->prevInChain() == 0 && currItem != bblast) { currItem->link(bb); // CB We need to do this because we draw in the order of the item list // Which is also item number list.. but #3488: we must also renumber the items if (bb->ItemNr < currItem->ItemNr) { m_doc->Items->insert(currItem->ItemNr+1, bb); bb = m_doc->Items->takeAt(bb->ItemNr); m_doc->renumberItemsInListOrder(); } // m_view->updateContents(); // link calls PageItem::update // emit DocChanged(); m_doc->ElemToLink = bb; } else if (currItem == bblast) { //CB Mouse is released when this messagebox takes focus m_canvas->m_viewMode.m_MouseButtonPressed = false; QMessageBox::warning(m_view, ScribusView::tr("Linking Text Frames"), "<qt>" + ScribusView::tr("You are trying to link a frame to itself.") + "</qt>"); } else { //CB Mouse is released when this messagebox takes focus m_canvas->m_viewMode.m_MouseButtonPressed = false; QMessageBox::warning(m_view, ScribusView::tr("Linking Text Frames"), "<qt>" + ScribusView::tr("You are trying to link a frame which is already linked.") + "</qt>"); } } else m_doc->ElemToLink = NULL; break; case modeUnlinkFrames: if (m->button() != Qt::LeftButton) break; SeleItem(m); if (GetItem(&currItem) && (currItem->asTextFrame())) { if (currItem->prevInChain() != 0) { currItem->prevInChain()->unlink(); } // unlink calls PageItem::update emit DocChanged(); // m_view->updateContents(); } break; } }