TextBox::TextBox(shared_ptr<Style> style)
 :
 Shape(style),
 fontSize(0),
 wrap(false),
 lineHeight(0),
 lineHeightFactor(0),
 overflowX(false),
 overflowY(false),
 offsetX(0),
 offsetY(0),
 textColor(style->textColor),
 fill(style->fill),
 updateWrapRequest(false),
 updateWidthRequest(false),
 updateHeightRequest(false),
 updateLineHeightRequest(false)
 {
     setFont(style->font);
     setFontSize(style->fontSize);
     setWrap(style->wrap);
     setTextAlign(style->textAlignX, style->textAlignY);
     
     if (style->lineHeight > 0)
     {
         setLineHeight(style->lineHeight);
     }
     else if (style->lineHeightFactor > 0)
     {
         setLineHeightFactor(style->lineHeightFactor);
     }
 }
Example #2
0
void Text3DOverlay::setProperties(const QVariantMap& properties) {
    Billboard3DOverlay::setProperties(properties);

    auto text = properties["text"];
    if (text.isValid()) {
        setText(text.toString());
    }

    auto textAlpha = properties["textAlpha"];
    if (textAlpha.isValid()) {
        float prevTextAlpha = getTextAlpha();
        setTextAlpha(textAlpha.toFloat());
        // Update our payload key if necessary to handle transparency
        if ((prevTextAlpha < 1.0f && _textAlpha >= 1.0f) || (prevTextAlpha >= 1.0f && _textAlpha < 1.0f)) {
            auto itemID = getRenderItemID();
            if (render::Item::isValidID(itemID)) {
                render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
                render::Transaction transaction;
                transaction.updateItem(itemID);
                scene->enqueueTransaction(transaction);
            }
        }
    }

    bool valid;
    auto backgroundColor = properties["backgroundColor"];
    if (backgroundColor.isValid()) {
        auto color = u8vec3FromVariant(backgroundColor, valid);
        if (valid) {
            _backgroundColor = color;
        }
    }

    if (properties["backgroundAlpha"].isValid()) {
        setAlpha(properties["backgroundAlpha"].toFloat());
    }

    if (properties["lineHeight"].isValid()) {
        setLineHeight(properties["lineHeight"].toFloat());
    }

    if (properties["leftMargin"].isValid()) {
        setLeftMargin(properties["leftMargin"].toFloat());
    }

    if (properties["topMargin"].isValid()) {
        setTopMargin(properties["topMargin"].toFloat());
    }

    if (properties["rightMargin"].isValid()) {
        setRightMargin(properties["rightMargin"].toFloat());
    }

    if (properties["bottomMargin"].isValid()) {
        setBottomMargin(properties["bottomMargin"].toFloat());
    }
}
// Reset text formatting parameters.
void Adafruit_Thermal::setDefault(){
  online();
  justify('L');
  inverseOff();
  doubleHeightOff();
  setLineHeight(32);
  boldOff();
  underlineOff();
  setBarcodeHeight(50);
  setSize('s');
}
Example #4
0
void Text3DOverlay::setProperties(const QScriptValue& properties) {
    Planar3DOverlay::setProperties(properties);
    
    QScriptValue text = properties.property("text");
    if (text.isValid()) {
        setText(text.toVariant().toString());
    }

    QScriptValue backgroundColor = properties.property("backgroundColor");
    if (backgroundColor.isValid()) {
        QScriptValue red = backgroundColor.property("red");
        QScriptValue green = backgroundColor.property("green");
        QScriptValue blue = backgroundColor.property("blue");
        if (red.isValid() && green.isValid() && blue.isValid()) {
            _backgroundColor.red = red.toVariant().toInt();
            _backgroundColor.green = green.toVariant().toInt();
            _backgroundColor.blue = blue.toVariant().toInt();
        }
    }

    if (properties.property("backgroundAlpha").isValid()) {
        _backgroundAlpha = properties.property("backgroundAlpha").toVariant().toFloat();
    }

    if (properties.property("lineHeight").isValid()) {
        setLineHeight(properties.property("lineHeight").toVariant().toFloat());
    }

    if (properties.property("leftMargin").isValid()) {
        setLeftMargin(properties.property("leftMargin").toVariant().toFloat());
    }

    if (properties.property("topMargin").isValid()) {
        setTopMargin(properties.property("topMargin").toVariant().toFloat());
    }

    if (properties.property("rightMargin").isValid()) {
        setRightMargin(properties.property("rightMargin").toVariant().toFloat());
    }

    if (properties.property("bottomMargin").isValid()) {
        setBottomMargin(properties.property("bottomMargin").toVariant().toFloat());
    }

    QScriptValue isFacingAvatarValue = properties.property("isFacingAvatar");
    if (isFacingAvatarValue.isValid()) {
        _isFacingAvatar = isFacingAvatarValue.toVariant().toBool();
    }

}
void KisShadeSelectorLineComboBox::updateSettings()
{
    m_currentLine->updateSettings();
    for(int i=0; i<m_popup->layout()->count(); i++) {
        KisShadeSelectorLine* item = dynamic_cast<KisShadeSelectorLine*>(m_popup->layout()->itemAt(i)->widget());
        if(item!=0) {
            item->updateSettings();
            item->m_lineHeight=30;
            item->setMaximumHeight(30);
            item->setMinimumHeight(30);
        }
    }

    setLineHeight(m_currentLine->m_lineHeight);
}
Example #6
0
	void FormatDocument(QTextDocument &doc, const int lineHeight)
	{
		assert(lineHeight > 0);

        if (platform::is_apple())
        {
            doc.setDocumentMargin(0);

            return;
        }

		for (auto block = doc.firstBlock(); block.isValid(); block = block.next())
		{
			QTextCursor c(block);
			auto f = c.blockFormat();
			f.setLineHeight(lineHeight, QTextBlockFormat::FixedHeight);
			c.setBlockFormat(f);
		}

		doc.setDocumentMargin(0);
	}
Example #7
0
int QDeclarativeText::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDeclarativeImplicitSizeItem::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 17)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 17;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = text(); break;
        case 1: *reinterpret_cast< QFont*>(_v) = font(); break;
        case 2: *reinterpret_cast< QColor*>(_v) = color(); break;
        case 3: *reinterpret_cast< TextStyle*>(_v) = style(); break;
        case 4: *reinterpret_cast< QColor*>(_v) = styleColor(); break;
        case 5: *reinterpret_cast< HAlignment*>(_v) = hAlign(); break;
        case 6: *reinterpret_cast< VAlignment*>(_v) = vAlign(); break;
        case 7: *reinterpret_cast< WrapMode*>(_v) = wrapMode(); break;
        case 8: *reinterpret_cast< int*>(_v) = lineCount(); break;
        case 9: *reinterpret_cast< bool*>(_v) = truncated(); break;
        case 10: *reinterpret_cast< int*>(_v) = maximumLineCount(); break;
        case 11: *reinterpret_cast< TextFormat*>(_v) = textFormat(); break;
        case 12: *reinterpret_cast< TextElideMode*>(_v) = elideMode(); break;
        case 13: *reinterpret_cast< qreal*>(_v) = paintedWidth(); break;
        case 14: *reinterpret_cast< qreal*>(_v) = paintedHeight(); break;
        case 15: *reinterpret_cast< qreal*>(_v) = lineHeight(); break;
        case 16: *reinterpret_cast< LineHeightMode*>(_v) = lineHeightMode(); break;
        }
        _id -= 17;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setText(*reinterpret_cast< QString*>(_v)); break;
        case 1: setFont(*reinterpret_cast< QFont*>(_v)); break;
        case 2: setColor(*reinterpret_cast< QColor*>(_v)); break;
        case 3: setStyle(*reinterpret_cast< TextStyle*>(_v)); break;
        case 4: setStyleColor(*reinterpret_cast< QColor*>(_v)); break;
        case 5: setHAlign(*reinterpret_cast< HAlignment*>(_v)); break;
        case 6: setVAlign(*reinterpret_cast< VAlignment*>(_v)); break;
        case 7: setWrapMode(*reinterpret_cast< WrapMode*>(_v)); break;
        case 10: setMaximumLineCount(*reinterpret_cast< int*>(_v)); break;
        case 11: setTextFormat(*reinterpret_cast< TextFormat*>(_v)); break;
        case 12: setElideMode(*reinterpret_cast< TextElideMode*>(_v)); break;
        case 15: setLineHeight(*reinterpret_cast< qreal*>(_v)); break;
        case 16: setLineHeightMode(*reinterpret_cast< LineHeightMode*>(_v)); break;
        }
        _id -= 17;
    } else if (_c == QMetaObject::ResetProperty) {
        switch (_id) {
        case 5: resetHAlign(); break;
        case 10: resetMaximumLineCount(); break;
        }
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 17;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}