PyObject *scribus_newtable(PyObject* /* self */, PyObject* args) { double x, y, w, h; int numRows, numColumns; char *Name = const_cast<char*>(""); if (!PyArg_ParseTuple(args, "ddddii|es", &x, &y, &w, &h, &numRows, &numColumns, "utf-8", &Name)) return NULL; if (!checkHaveDocument()) return NULL; if (numRows < 1 || numColumns < 1) { PyErr_SetString(PyExc_ValueError, QObject::tr("Both numRows and numColumns must be greater than 0.","python error").toLocal8Bit().constData()); return NULL; } int i = ScCore->primaryMainWindow()->doc->itemAdd(PageItem::Table, PageItem::Unspecified, pageUnitXToDocX(x), pageUnitYToDocY(y), ValueToPoint(w), ValueToPoint(h), 0, // Unused. CommonStrings::None, // Unused. CommonStrings::None); // Unused. PageItem_Table *table = ScCore->primaryMainWindow()->doc->Items->at(i)->asTable(); table->insertRows(0, numRows - 1); table->insertColumns(0, numColumns - 1); table->adjustTableToFrame(); table->adjustFrameToTable(); if (strlen(Name) > 0) { QString objName = QString::fromUtf8(Name); if (!ItemExists(objName)) ScCore->primaryMainWindow()->doc->Items->at(i)->setItemName(objName); } return PyString_FromString(table->itemName().toUtf8()); }
PyObject *scribus_newrect(PyObject* /* self */, PyObject* args) { double x, y, w, h; char *Name = const_cast<char*>(""); if (!PyArg_ParseTuple(args, "dddd|es", &x, &y, &w, &h, "utf-8", &Name)) return NULL; if(!checkHaveDocument()) return NULL; // if (ItemExists(QString::fromUtf8(Name))) // { // PyErr_SetString(NameExistsError, QObject::tr("An object with the requested name already exists.","python error")); // return NULL; // } int i = ScCore->primaryMainWindow()->doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, pageUnitXToDocX(x), pageUnitYToDocY(y), ValueToPoint(w), ValueToPoint(h), ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineWidth, ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeFillColor, ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineColor, true); // ScCore->primaryMainWindow()->doc->setRedrawBounding(ScCore->primaryMainWindow()->doc->Items->at(i)); if (Name != EMPTY_STRING) { QString objName = QString::fromUtf8(Name); if (!ItemExists(objName)) ScCore->primaryMainWindow()->doc->Items->at(i)->setItemName(objName); } return PyString_FromString(ScCore->primaryMainWindow()->doc->Items->at(i)->itemName().toUtf8()); }
PyObject *scribus_settextdistances(PyObject* /* self */, PyObject* args) { char *Name = const_cast<char*>(""); double l,r,t,b; if (!PyArg_ParseTuple(args, "dddd|es", &l, &r, &t, &b, "utf-8", &Name)) return NULL; if(!checkHaveDocument()) return NULL; if (l < 0.0 || r < 0.0 || t < 0.0 || b < 0.0) { PyErr_SetString(PyExc_ValueError, QObject::tr("Text distances out of bounds, must be positive.","python error").toLocal8Bit().constData()); return NULL; } PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); if (i == NULL) return NULL; if (!i->asTextFrame()) { PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set text distances on a non-text frame.","python error").toLocal8Bit().constData()); return NULL; } i->setTextToFrameDist(ValueToPoint(l), ValueToPoint(r), ValueToPoint(t), ValueToPoint(b)); Py_INCREF(Py_None); return Py_None; }
PyObject *scribus_newellipse(PyObject* /* self */, PyObject* args) { double x, y, w, h; char *Name = const_cast<char*>(""); if (!PyArg_ParseTuple(args, "dddd|es", &x, &y, &w, &h, "utf-8", &Name)) return NULL; if(!checkHaveDocument()) return NULL; int i = ScCore->primaryMainWindow()->doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, pageUnitXToDocX(x), pageUnitYToDocY(y), ValueToPoint(w), ValueToPoint(h), ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineWidth, ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeFillColor, ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineColor, true); if (Name != EMPTY_STRING) { QString objName = QString::fromUtf8(Name); if (!ItemExists(objName)) ScCore->primaryMainWindow()->doc->Items->at(i)->setItemName(objName); } return PyString_FromString(ScCore->primaryMainWindow()->doc->Items->at(i)->itemName().toUtf8()); }
void ItemAPI::move(double dx, double dy) { if (!checkHaveDocument()) return; if (item==NULL) return; // Grab the old selection - but use it only where is there any Selection tempSelection(*ScCore->primaryMainWindow()->doc->m_Selection); bool hadOrigSelection = (tempSelection.count() != 0); ScCore->primaryMainWindow()->doc->m_Selection->clear(); // Clear the selection ScCore->primaryMainWindow()->view->Deselect(); // Select the item, which will also select its group if // there is one. ScCore->primaryMainWindow()->view->SelectItem(item); // Move the item, or items if (ScCore->primaryMainWindow()->doc->m_Selection->count() > 1) { ScCore->primaryMainWindow()->view->startGroupTransaction(Um::Move, "", Um::IMove); ScCore->primaryMainWindow()->doc->moveGroup(ValueToPoint(dx), ValueToPoint(dy)); ScCore->primaryMainWindow()->view->endGroupTransaction(); } else { ScCore->primaryMainWindow()->doc->MoveItem(ValueToPoint(dx), ValueToPoint(dy), item); } // Now restore the selection. ScCore->primaryMainWindow()->view->Deselect(); if (hadOrigSelection) *ScCore->primaryMainWindow()->doc->m_Selection=tempSelection; }
void ItemAPI::resize(double width, double height) { if (!checkHaveDocument()) return; if (item == NULL) return; ScCore->primaryMainWindow()->doc->SizeItem(ValueToPoint(width), ValueToPoint(height), item); }
PyObject *scribus_setcolumngap(PyObject* /* self */, PyObject* args) { char *Name = const_cast<char*>(""); double w; if (!PyArg_ParseTuple(args, "d|es", &w, "utf-8", &Name)) return NULL; if(!checkHaveDocument()) return NULL; if (w < 0.0) { PyErr_SetString(PyExc_ValueError, QObject::tr("Column gap out of bounds, must be positive.","python error").toLocal8Bit().constData()); return NULL; } PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); if (i == NULL) return NULL; if (!i->asTextFrame()) { PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set column gap on a non-text frame.","python error").toLocal8Bit().constData()); return NULL; } i->ColGap = ValueToPoint(w); // Py_INCREF(Py_None); // return Py_None; Py_RETURN_NONE; }
static int ScaleCoordsCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Scale *scalePtr = recordPtr; double value; int r = TCL_OK; if (objc < 2 || objc > 3) { Tcl_WrongNumArgs(interp, 1, objv, "coords ?value?"); return TCL_ERROR; } if (objc == 3) { r = Tcl_GetDoubleFromObj(interp, objv[2], &value); } else { r = Tcl_GetDoubleFromObj(interp, scalePtr->scale.valueObj, &value); } if (r == TCL_OK) { Tcl_Obj *point[2]; XPoint pt = ValueToPoint(scalePtr, value); point[0] = Tcl_NewIntObj(pt.x); point[1] = Tcl_NewIntObj(pt.y); Tcl_SetObjResult(interp, Tcl_NewListObj(2, point)); } return r; }
PyObject *scribus_setVguides(PyObject* /* self */, PyObject* args) { PyObject *l; if (!PyArg_ParseTuple(args, "O", &l)) return NULL; if(!checkHaveDocument()) return NULL; if (!PyList_Check(l)) { PyErr_SetString(PyExc_TypeError, QObject::tr("argument is not list: must be list of float values.","python error").toLocal8Bit().constData()); return NULL; } int i, n; n = PyList_Size(l); double guide; ScCore->primaryMainWindow()->doc->currentPage()->guides.clearVerticals(GuideManagerCore::Standard); for (i=0; i<n; i++) { if (!PyArg_Parse(PyList_GetItem(l, i), "d", &guide)) { PyErr_SetString(PyExc_TypeError, QObject::tr("argument contains no-numeric values: must be list of float values.","python error").toLocal8Bit().constData()); return NULL; } ScCore->primaryMainWindow()->doc->currentPage()->guides.addVertical(ValueToPoint(guide), GuideManagerCore::Standard); } // Py_INCREF(Py_None); // return Py_None; Py_RETURN_NONE; }
PyObject *scribus_setmargins(PyObject* /* self */, PyObject* args) { double lr, tpr, btr, rr; if (!PyArg_ParseTuple(args, "dddd", &lr, &rr, &tpr, &btr)) return NULL; if(!checkHaveDocument()) return NULL; MarginStruct margins(ValueToPoint(tpr), ValueToPoint(lr), ValueToPoint(btr), ValueToPoint(rr)); ScCore->primaryMainWindow()->doc->resetPage(margins, ScCore->primaryMainWindow()->doc->currentPageLayout); ScCore->primaryMainWindow()->view->reformPages(); ScCore->primaryMainWindow()->doc->setModified(true); ScCore->primaryMainWindow()->view->GotoPage(ScCore->primaryMainWindow()->doc->currentPageNumber()); ScCore->primaryMainWindow()->view->DrawNew(); // Py_INCREF(Py_None); // return Py_None; Py_RETURN_NONE; }
PyObject *scribus_setbaseline(PyObject* /* self */, PyObject* args) { double grid, offset; if (!PyArg_ParseTuple(args, "dd", &grid, &offset)) return NULL; if(!checkHaveDocument()) return NULL; ScCore->primaryMainWindow()->doc->guidesPrefs().valueBaselineGrid = ValueToPoint(grid); ScCore->primaryMainWindow()->doc->guidesPrefs().offsetBaselineGrid = ValueToPoint(offset); //ScCore->primaryMainWindow()->view->reformPages(); ScCore->primaryMainWindow()->doc->setModified(true); //ScCore->primaryMainWindow()->view->GotoPage(ScCore->primaryMainWindow()->doc->currentPageNumber()); ScCore->primaryMainWindow()->view->DrawNew(); // Py_INCREF(Py_None); // return Py_None; Py_RETURN_NONE; }
PyObject *scribus_setmargins(PyObject* /* self */, PyObject* args) { double lr, tpr, btr, rr; if (!PyArg_ParseTuple(args, "dddd", &lr, &rr, &tpr, &btr)) return nullptr; if (!checkHaveDocument()) return nullptr; MarginStruct margins(ValueToPoint(tpr), ValueToPoint(lr), ValueToPoint(btr), ValueToPoint(rr)); ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; ScribusView* currentView = ScCore->primaryMainWindow()->view; currentDoc->resetPage(currentDoc->pagePositioning(), &margins); currentView->reformPages(); currentDoc->setModified(true); currentView->GotoPage(currentDoc->currentPageNumber()); currentView->DrawNew(); Py_RETURN_NONE; }
PyObject *scribus_setbaseline(PyObject* /* self */, PyObject* args) { double grid, offset; if (!PyArg_ParseTuple(args, "dd", &grid, &offset)) return nullptr; if (!checkHaveDocument()) return nullptr; ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc; ScribusView* currentView = ScCore->primaryMainWindow()->view; currentDoc->guidesPrefs().valueBaselineGrid = ValueToPoint(grid); currentDoc->guidesPrefs().offsetBaselineGrid = ValueToPoint(offset); //currentView->reformPages(); currentDoc->setModified(true); //currentView->GotoPage(currentDoc->currentPageNumber()); currentView->DrawNew(); Py_RETURN_NONE; }
void ItemAPI::setColumnGap(double value) { if (!checkHaveDocument()) RAISE("No document open"); if (value < 0.0) { RAISE("Column gap out of bounds, must be positive."); } item->ColGap = ValueToPoint(value); }
PyObject *scribus_newimage(PyObject* /* self */, PyObject* args) { double x, y, w, h; char *Name = const_cast<char*>(""); if (!PyArg_ParseTuple(args, "dddd|es", &x, &y, &w, &h, "utf-8", &Name)) return NULL; if(!checkHaveDocument()) return NULL; int i = ScCore->primaryMainWindow()->doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, pageUnitXToDocX(x), pageUnitYToDocY(y), ValueToPoint(w), ValueToPoint(h), 1, ScCore->primaryMainWindow()->doc->itemToolPrefs().imageFillColor, ScCore->primaryMainWindow()->doc->itemToolPrefs().imageStrokeColor); if (strlen(Name) > 0) { QString objName = QString::fromUtf8(Name); if (!ItemExists(objName)) ScCore->primaryMainWindow()->doc->Items->at(i)->setItemName(objName); } return PyString_FromString(ScCore->primaryMainWindow()->doc->Items->at(i)->itemName().toUtf8()); }
//******************************************************************************* void CBCGPLinearGaugeImpl::CreatePointerPoints(CBCGPPointsArray& arPoints, int nPointerIndex, BOOL bShadow) { if (m_rect.IsRectEmpty()) { return; } CBCGPLinearGaugePointer* pData = DYNAMIC_DOWNCAST(CBCGPLinearGaugePointer, m_arData[nPointerIndex]); if (pData == NULL) { ASSERT(FALSE); return; } CBCGPGaugeScaleObject* pScale = GetScale(pData->GetScale()); if (pScale == NULL) { ASSERT(FALSE); return; } const double scaleRatio = GetScaleRatioMid(); double dblValue = pData->m_nAnimTimerID != 0 ? pData->m_dblAnimatedValue : pData->m_dblValue; double dblSizeMax = max(pScale->m_dblMajorTickMarkSize, 2. * pScale->m_dblMinorTickMarkSize) * scaleRatio; double dblSize = dblSizeMax; if (dblSize == 0) { dblSize = 8. * scaleRatio; } double dblSizePerc = bcg_clamp(pData->m_dblSize, 0.0, 1.0); if (dblSizePerc != 0.0) { dblSize = max(dblSize * dblSizePerc, 2.0); } CBCGPPoint point; if (!ValueToPoint(dblValue, point, pData->GetScale())) { return; } double offset = max(pScale->m_dblMajorTickMarkSize, pScale->m_dblMinorTickMarkSize) * scaleRatio; offset = max(offset, m_dblMaxRangeSize); double x = point.x; double y = point.y; if (dblSize < dblSizeMax && pData->GetPosition() != CBCGPLinearGaugePointer::BCGP_GAUGE_POSITION_NEAR) { double dblSizeDelta = dblSizeMax - dblSize; if (pData->GetPosition() == CBCGPLinearGaugePointer::BCGP_GAUGE_POSITION_CENTER) { dblSizeDelta /= 2.0; } if (m_bIsVertical) { x += dblSizeDelta; } else { y += dblSizeDelta; } } if (bShadow) { x += 2. * m_sizeScaleRatio.cx; y += 2. * m_sizeScaleRatio.cy; } const double delta = pData->m_dblWidth == 0 ? dblSize / 2 : (pData->m_dblWidth * scaleRatio) / 2; switch (pData->GetStyle()) { case CBCGPLinearGaugePointer::BCGP_GAUGE_NEEDLE_TRIANGLE: if (m_bIsVertical) { arPoints.Add(CBCGPPoint(x, y - delta)); arPoints.Add(CBCGPPoint(x, y + delta)); arPoints.Add(CBCGPPoint(x + dblSize, y)); } else { arPoints.Add(CBCGPPoint(x + delta, y)); arPoints.Add(CBCGPPoint(x - delta, y)); arPoints.Add(CBCGPPoint(x, y + dblSize)); } break; case CBCGPLinearGaugePointer::BCGP_GAUGE_NEEDLE_TRIANGLE_INV: if (m_bIsVertical) { arPoints.Add(CBCGPPoint(x + dblSize, y - delta)); arPoints.Add(CBCGPPoint(x + dblSize, y + delta)); arPoints.Add(CBCGPPoint(x, y)); } else { arPoints.Add(CBCGPPoint(x + delta, y + dblSize)); arPoints.Add(CBCGPPoint(x - delta, y + dblSize)); arPoints.Add(CBCGPPoint(x, y)); } break; case CBCGPLinearGaugePointer::BCGP_GAUGE_NEEDLE_RECT: case CBCGPLinearGaugePointer::BCGP_GAUGE_NEEDLE_CIRCLE: if (m_bIsVertical) { arPoints.Add(CBCGPPoint(x, y + delta)); arPoints.Add(CBCGPPoint(x, y - delta)); arPoints.Add(CBCGPPoint(x + dblSize, y - delta)); arPoints.Add(CBCGPPoint(x + dblSize, y + delta)); } else { arPoints.Add(CBCGPPoint(x + delta, y + dblSize)); arPoints.Add(CBCGPPoint(x - delta, y + dblSize)); arPoints.Add(CBCGPPoint(x - delta, y)); arPoints.Add(CBCGPPoint(x + delta, y)); } break; case CBCGPLinearGaugePointer::BCGP_GAUGE_NEEDLE_DIAMOND: if (m_bIsVertical) { arPoints.Add(CBCGPPoint(x + .5 * dblSize, y + delta)); arPoints.Add(CBCGPPoint(x, y)); arPoints.Add(CBCGPPoint(x + .5 * dblSize, y - delta)); arPoints.Add(CBCGPPoint(x + dblSize, y)); } else { arPoints.Add(CBCGPPoint(x, y + dblSize)); arPoints.Add(CBCGPPoint(x - delta, y + .5 * dblSize)); arPoints.Add(CBCGPPoint(x, y)); arPoints.Add(CBCGPPoint(x + delta, y + .5 * dblSize)); } } }
//******************************************************************************* BOOL CBCGPLinearGaugeImpl::GetRangeShape(CBCGPRect& rect, CBCGPPolygonGeometry& shape, double dblStartValue, double dblFinishValue, double dblStartWidth, double dblFinishWidth, double dblOffsetFromFrame, int nScale) { rect.SetRectEmpty(); shape.Clear(); CBCGPPoint pt1; if (!ValueToPoint(dblStartValue, pt1, nScale)) { return FALSE; } CBCGPPoint pt2; if (!ValueToPoint(dblFinishValue, pt2, nScale)) { return FALSE; } const double scaleRatio = GetScaleRatioMid(); if (dblStartWidth == 0.) { CBCGPGaugeScaleObject* pScale = GetScale(nScale); if (pScale != NULL) { dblStartWidth = pScale->m_dblMajorTickMarkSize + pScale->m_dblOffsetFromFrame; } } if (dblFinishWidth == 0.) { dblFinishWidth = dblStartWidth; } dblStartWidth *= scaleRatio; dblFinishWidth *= scaleRatio; dblOffsetFromFrame *= scaleRatio; if (dblFinishWidth == dblStartWidth) { if (m_bIsVertical) { rect.left = pt1.x + dblOffsetFromFrame; rect.top = pt1.y; rect.right = pt1.x + dblStartWidth + dblOffsetFromFrame; rect.bottom = pt2.y; } else { rect.left = pt1.x; rect.top = pt1.y + dblOffsetFromFrame; rect.right = pt2.x; rect.bottom = pt1.y + dblStartWidth + dblOffsetFromFrame; } } else { CBCGPPointsArray arPoints; if (m_bIsVertical) { arPoints.Add(CBCGPPoint(pt1.x + dblOffsetFromFrame, pt1.y)); arPoints.Add(CBCGPPoint(pt2.x + dblOffsetFromFrame, pt2.y)); arPoints.Add(CBCGPPoint(pt2.x + dblOffsetFromFrame + dblFinishWidth, pt2.y)); arPoints.Add(CBCGPPoint(pt1.x + dblOffsetFromFrame + dblStartWidth, pt1.y)); } else { arPoints.Add(CBCGPPoint(pt1.x, pt1.y + dblOffsetFromFrame)); arPoints.Add(CBCGPPoint(pt2.x, pt2.y + dblOffsetFromFrame)); arPoints.Add(CBCGPPoint(pt2.x, pt2.y + dblOffsetFromFrame + dblFinishWidth)); arPoints.Add(CBCGPPoint(pt1.x, pt1.y + dblOffsetFromFrame + dblStartWidth)); } shape.SetPoints(arPoints); } return TRUE; }
//******************************************************************************* void CBCGPLinearGaugeImpl::OnDrawScale(CBCGPGraphicsManager* pGM, int nScale) { CBCGPGaugeScaleObject* pScale = GetScale(nScale); if (pScale == NULL) { ASSERT(FALSE); return; } const double scaleRatio = GetScaleRatioMid(); const CBCGPBrush& brFill = pScale->m_brFill.IsEmpty() ? m_Colors.m_brScaleFill : pScale->m_brFill; const CBCGPBrush& brOutline = pScale->m_brOutline.IsEmpty() ? m_Colors.m_brScaleOutline : pScale->m_brOutline; if (!brFill.IsEmpty() || !brOutline.IsEmpty()) { CBCGPRect rectRange; CBCGPPolygonGeometry shapeRange; if (GetRangeShape(rectRange, shapeRange, pScale->m_dblStart, pScale->m_dblFinish, pScale->m_dblMajorTickMarkSize, pScale->m_dblMajorTickMarkSize, 0, nScale)) { if (!rectRange.IsRectEmpty()) { pGM->FillRectangle(rectRange, brFill); pGM->DrawRectangle(rectRange, brOutline, scaleRatio); } else { pGM->FillGeometry(shapeRange, brFill); pGM->DrawGeometry(shapeRange, brOutline, scaleRatio); } } } int i = 0; double dblStep = (pScale->m_dblFinish > pScale->m_dblStart) ? pScale->m_dblStep : -pScale->m_dblStep; double dblMinorTickSize = pScale->m_dblMinorTickMarkSize * scaleRatio; double dblMajorTickSize = pScale->m_dblMajorTickMarkSize * scaleRatio; CBCGPGaugeScaleObject::BCGP_TICKMARK_POSITION position = pScale->m_MinorTickMarkPosition; for (double dblVal = pScale->m_dblStart; (dblStep > 0. && dblVal <= pScale->m_dblFinish) || (dblStep < 0. && dblVal >= pScale->m_dblFinish); dblVal += dblStep, i++) { const BOOL bIsLastTick = (pScale->m_dblFinish > pScale->m_dblStart && dblVal + dblStep > pScale->m_dblFinish); BOOL bIsMajorTick = pScale->m_dblMajorTickMarkStep != 0. && ((i % bcg_round(pScale->m_dblMajorTickMarkStep)) == 0); if (!bIsMajorTick && (i == 0 || bIsLastTick)) { // Always draw first and last ticks bIsMajorTick = TRUE; } double dblCurrTickSize = bIsMajorTick ? dblMajorTickSize : dblMinorTickSize; CBCGPPoint ptFrom; ValueToPoint(dblVal, ptFrom, nScale); if (!bIsMajorTick && position != CBCGPGaugeScaleObject::BCGP_TICKMARK_POSITION_NEAR && dblCurrTickSize < dblMajorTickSize) { double dblDeltaTick = dblMajorTickSize - dblCurrTickSize; if (position == CBCGPGaugeScaleObject::BCGP_TICKMARK_POSITION_CENTER) { dblDeltaTick /= 2.0; } if (m_bIsVertical) { ptFrom.x += dblDeltaTick; } else { ptFrom.y += dblDeltaTick; } } CBCGPPoint ptTo = ptFrom; if (m_bIsVertical) { ptTo.x += dblCurrTickSize; } else { ptTo.y += dblCurrTickSize; } if (dblCurrTickSize > 0.) { OnDrawTickMark(pGM, ptFrom, ptTo, bIsMajorTick ? pScale->m_MajorTickMarkStyle : pScale->m_MinorTickMarkStyle, bIsMajorTick, dblVal, nScale, bIsMajorTick ? pScale->m_brTickMarkMajor : pScale->m_brTickMarkMinor, bIsMajorTick ? pScale->m_brTickMarkMajorOutline : pScale->m_brTickMarkMinorOutline); } if (bIsMajorTick) { CString strLabel; GetTickMarkLabel(strLabel, pScale->m_strLabelFormat, dblVal, nScale); if (!strLabel.IsEmpty()) { double offset = 0; if (pScale->m_dblMajorTickMarkSize == 0.) { offset = m_dblMaxRangeSize; } CBCGPRect rectText; double xLabel = ptTo.x; double yLabel = ptTo.y; CBCGPSize sizeText = GetTickMarkTextLabelSize(pGM, strLabel, m_textFormat); if (m_bIsVertical) { rectText.left = xLabel + 2 + offset; rectText.top = yLabel - sizeText.cy / 2; } else { rectText.left = xLabel - sizeText.cx / 2; rectText.top = yLabel + offset; } rectText.right = rectText.left + sizeText.cx; rectText.bottom = rectText.top + sizeText.cy; OnDrawTickMarkTextLabel(pGM, m_textFormat, rectText, strLabel, dblVal, nScale, pScale->m_brText.IsEmpty() ? m_Colors.m_brText : pScale->m_brText); } } } }
/// Convert a Y co-ordinate part in page units to a document co-ordinate /// in system units. The document co-ordinates have their origin somewere /// up and left of the first page, where page co-ordinates have their /// origin on the top left of the current page. double pageUnitYToDocY(double pageUnitY) { return ValueToPoint(pageUnitY) + ScCore->primaryMainWindow()->doc->currentPage()->yOffset(); }
/// Convert an X co-ordinate part in page units to a document co-ordinate /// in system units. double pageUnitXToDocX(double pageUnitX) { return ValueToPoint(pageUnitX) + ScCore->primaryMainWindow()->doc->currentPage()->xOffset(); }