本文整理汇总了C++中QTextOption::setUseDesignMetrics方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextOption::setUseDesignMetrics方法的具体用法?C++ QTextOption::setUseDesignMetrics怎么用?C++ QTextOption::setUseDesignMetrics使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextOption
的用法示例。
在下文中一共展示了QTextOption::setUseDesignMetrics方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: layout
void Text::layout()
{
if (styled() && !_editMode) {
SimpleText::layout();
}
else {
_doc->setDefaultFont(textStyle().font(spatium()));
qreal w = -1.0;
qreal x = 0.0;
qreal y = 0.0;
if (parent() && layoutToParentWidth()) {
w = parent()->width();
if (parent()->type() == HBOX || parent()->type() == VBOX || parent()->type() == TBOX) {
Box* box = static_cast<Box*>(parent());
x += box->leftMargin() * MScore::DPMM;
y += box->topMargin() * MScore::DPMM;
w = box->width() - ((box->leftMargin() + box->rightMargin()) * MScore::DPMM);
}
}
QTextOption to = _doc->defaultTextOption();
to.setUseDesignMetrics(true);
to.setWrapMode(w <= 0.0 ? QTextOption::NoWrap : QTextOption::WrapAtWordBoundaryOrAnywhere);
_doc->setDefaultTextOption(to);
if (w < 0.0)
w = _doc->idealWidth();
_doc->setTextWidth(w);
setbbox(QRectF(QPointF(0.0, 0.0), _doc->size()));
if (hasFrame())
layoutFrame();
_doc->setModified(false);
textStyle().layout(this); // process alignment
#if 0 // TODO TEXT_STYLE_TEXTLINE
if ((textStyle().align() & ALIGN_VCENTER) && (textStyle() == TEXT_STYLE_TEXTLINE)) {
// special case: vertically centered text with TextLine needs to
// take into account the line width
TextLineSegment* tls = static_cast<TextLineSegment*>(parent());
TextLine* tl = tls->textLine();
if (tl) {
qreal textlineLineWidth = point(tl->lineWidth());
rypos() -= textlineLineWidth * .5;
}
}
#endif
rxpos() += x;
rypos() += y;
}
if (parent() && parent()->type() == SEGMENT) {
Segment* s = static_cast<Segment*>(parent());
rypos() += s ? s->measure()->system()->staff(staffIdx())->y() : 0.0;
}
adjustReadPos();
}
示例2: setText
void NodeLabel::setText(const QString & text)
{
// update the text
m_text = QStaticText(text);
m_text.setTextFormat(Qt::PlainText);
QTextOption textOption =
QTextOption(Qt::AlignHCenter | Qt::AlignBaseline);
textOption.setUseDesignMetrics(false);
m_text.setTextOption(textOption);
updateStyle();
}
示例3: createDoc
void Text::createDoc()
{
_doc = new QTextDocument(0);
_doc->setDocumentMargin(-2.0);
_doc->setUseDesignMetrics(true);
_doc->setUndoRedoEnabled(true);
_doc->documentLayout()->setProperty("cursorWidth", QVariant(2));
QTextOption to = _doc->defaultTextOption();
to.setUseDesignMetrics(true);
to.setWrapMode(QTextOption::NoWrap);
_doc->setDefaultTextOption(to);
_doc->setDefaultFont(textStyle().font(spatium()));
}
示例4: sipNoMethod
static PyObject *meth_QTextOption_setUseDesignMetrics(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
bool a0;
QTextOption *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "Bb", &sipSelf, sipType_QTextOption, &sipCpp, &a0))
{
sipCpp->setUseDesignMetrics(a0);
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QTextOption, sipName_setUseDesignMetrics, doc_QTextOption_setUseDesignMetrics);
return NULL;
}
示例5: Element
Text::Text(Score* s)
: Element(s)
{
#if 0
_doc = new QTextDocument(0);
_doc->setDocumentMargin(1.0);
_doc->setUseDesignMetrics(true);
_doc->setUndoRedoEnabled(true);
QTextOption to = _doc->defaultTextOption();
to.setUseDesignMetrics(true);
to.setWrapMode(QTextOption::NoWrap);
_doc->setDefaultTextOption(to);
#endif
setFlag(ELEMENT_MOVABLE, true);
_textStyle = TEXT_STYLE_INVALID;
_styled = false;
_layoutToParentWidth = false;
setSubtype(0);
_lineSpacing = 0.0;
_lineHeight = 0.0;
_baseLine = 0.0;
}
示例6: o
void Text::layout1()
{
if (styled() && !_editMode)
SimpleText::layout();
else {
_doc->setDefaultFont(textStyle().font(spatium()));
qreal w = -1.0;
QPointF o(textStyle().offset(spatium()));
if (parent() && layoutToParentWidth()) {
Element* e = parent();
w = e->width();
if (e->type() == HBOX || e->type() == VBOX || e->type() == TBOX) {
Box* b = static_cast<Box*>(e);
w -= ((b->leftMargin() + b->rightMargin()) * MScore::DPMM);
}
}
QTextOption to = _doc->defaultTextOption();
to.setUseDesignMetrics(true);
to.setWrapMode(w <= 0.0 ? QTextOption::NoWrap : QTextOption::WrapAtWordBoundaryOrAnywhere);
_doc->setDefaultTextOption(to);
if (w <= 0.0)
w = _doc->idealWidth();
_doc->setTextWidth(w);
QSizeF size(_doc->size());
if (align() & ALIGN_BOTTOM)
o.ry() -= size.height();
else if (align() & ALIGN_VCENTER)
o.ry() -= (size.height() * .5);
else if (align() & ALIGN_BASELINE)
o.ry() -= baseLine();
if (align() & ALIGN_RIGHT)
o.rx() -= size.width();
else if (align() & ALIGN_HCENTER)
o.rx() -= (size.width() * .5);
setbbox(QRectF(QPointF(0.0, 0.0), size));
_doc->setModified(false);
setPos(o);
}
if (parent()) {
Element* e = parent();
qreal w, h, xo, yo;
if (layoutToParentWidth()) {
if (e->type() == HBOX || e->type() == VBOX || e->type() == TBOX) {
// consider inner margins of frame
Box* b = static_cast<Box*>(e);
xo = b->leftMargin() * MScore::DPMM;
yo = b->topMargin() * MScore::DPMM;
w = b->width() - xo - b->rightMargin() * MScore::DPMM;
h = b->height() - yo - b->bottomMargin() * MScore::DPMM;
}
else {
w = e->width();
h = e->height();
xo = 0.0;
yo = 0.0;
}
QPointF ro(_textStyle.reloff() * .01);
rxpos() += xo + ro.x() * w;
rypos() += yo + ro.y() * h;
}
if (e->type() == SEGMENT) {
Segment* s = static_cast<Segment*>(e);
rypos() += s->measure()->system()->staff(staffIdx())->y();
}
}
if (hasFrame())
layoutFrame();
}
示例7: layout
void Text::layout()
{
#if 0
QSizeF pageSize(-1.0, 1000000);
setPos(0.0, 0.0);
if (parent() && _layoutToParentWidth) {
pageSize.setWidth(parent()->width());
if (parent()->type() == HBOX || parent()->type() == VBOX || parent()->type() == TBOX) {
Box* box = static_cast<Box*>(parent());
rxpos() += box->leftMargin() * DPMM;
rypos() += box->topMargin() * DPMM;
// pageSize.setHeight(box->height() - (box->topMargin() + box->bottomMargin()) * DPMM);
pageSize.setWidth(box->width() - (box->leftMargin() + box->rightMargin()) * DPMM);
}
}
QTextOption to = _doc->defaultTextOption();
to.setUseDesignMetrics(true);
to.setWrapMode(pageSize.width() <= 0.0 ? QTextOption::NoWrap : QTextOption::WrapAtWordBoundaryOrAnywhere);
_doc->setDefaultTextOption(to);
if (pageSize.width() <= 0.0)
_doc->setTextWidth(_doc->idealWidth());
else
_doc->setPageSize(pageSize);
if (hasFrame()) {
frame = QRectF();
for (QTextBlock tb = _doc->begin(); tb.isValid(); tb = tb.next()) {
QTextLayout* tl = tb.layout();
int n = tl->lineCount();
for (int i = 0; i < n; ++i)
// frame |= tl->lineAt(0).naturalTextRect().translated(tl->position());
frame |= tl->lineAt(0).rect().translated(tl->position());
}
if (circle()) {
if (frame.width() > frame.height()) {
frame.setY(frame.y() + (frame.width() - frame.height()) * -.5);
frame.setHeight(frame.width());
}
else {
frame.setX(frame.x() + (frame.height() - frame.width()) * -.5);
frame.setWidth(frame.height());
}
}
qreal w = (paddingWidth() + frameWidth() * .5) * DPMM;
frame.adjust(-w, -w, w, w);
w = frameWidth() * DPMM;
_bbox = frame.adjusted(-w, -w, w, w);
}
else {
_bbox = QRectF(QPointF(0.0, 0.0), _doc->size()); //_doc->documentLayout()->frameBoundingRect(_doc->rootFrame());
}
_doc->setModified(false);
style().layout(this); // process alignment
if ((style().align() & ALIGN_VCENTER) && (subtype() == TEXT_TEXTLINE)) {
// special case: vertically centered text with TextLine needs to
// take into account the line width
TextLineSegment* tls = (TextLineSegment*)parent();
TextLine* tl = (TextLine*)(tls->line());
qreal textlineLineWidth = point(tl->lineWidth());
rypos() -= textlineLineWidth * .5;
}
if (parent() == 0)
return;
if (parent()->type() == SEGMENT) {
Segment* s = static_cast<Segment*>(parent());
rypos() += s ? s->measure()->system()->staff(staffIdx())->y() : 0.0;
}
#endif
Font f = style().font(spatium());
qreal asc, desc, leading;
qreal w = textMetrics(f.family(), _text, f.size(), &asc, &desc, &leading);
// printf("text(%s) asc %f desc %f leading %f w %f\n", qPrintable(_text), asc, desc, leading, w);
_lineHeight = asc + desc;
_lineSpacing = _lineHeight + leading;
_baseLine = asc;
setbbox(QRectF(0.0, -asc, w, _lineHeight));
#if 0
if (parent() && _layoutToParentWidth) {
qreal wi = parent()->width();
qreal ph = parent()->height();
qreal x;
qreal y = pos.y();
if (align() & ALIGN_HCENTER)
x = (wi - w) * .5;
else if (align() & ALIGN_RIGHT)
x = wi - w;
else
x = 0.0;
if (align() & ALIGN_VCENTER)
y = (ph - asc) * .5;
else if (align() & ALIGN_BOTTOM)
y = ph - asc;
else
y = asc;
//.........这里部分代码省略.........
示例8: setUseDesignMetrics
int TextOption::setUseDesignMetrics( lua_State * L ) // ( bool enable )void
{
QTextOption* lhs = ValueInstaller2<QTextOption>::check( L, 1 );
lhs->setUseDesignMetrics( Util::toBool( L, 2 ) );
return 0;
}