示例#1
0
TextLabel::TextLabel(Karamba *k, int x, int y, int w, int h)
        :   Meter(k, x, y, w, h),
        alignment(Qt::AlignLeft),
        clip(0),
        bgColor(0, 0, 0),
        lineHeight(0),
        shadow(0),
        scrollSpeed(0, 0),
        scrollPos(0, 0),
        scrollGap(0),
        scrollPause(0),
        pauseCounter(0),
        scrollType(ScrollNone),
        m_clickable(false),
        m_sizeGiven(true)
{
    origPoint = QPoint(x, y);

    calculateTextSize();
    if (h != 0 || w != 0)
        clip = 0;
    else
        clip = Qt::TextDontClip;

    if (h <= 0 || w <= 0) {
        setWidth(-1);
        setHeight(-1);
        m_sizeGiven = false;
    }
}
示例#2
0
void Button::draw ( int _x, int _y )
{
	std::pair< int, int > dimensions = calculateTextSize();

	drawRectangle( _x, _y, dimensions.first + 2 * PADDING, dimensions.second + 2 * PADDING );
	drawText( _x + PADDING, _y + PADDING );
}
示例#3
0
void TextLabel::setAlignment(const QString &align)
{
    QString a = align.toUpper();
    if (a == "LEFT" || a.isEmpty())
        alignment = Qt::AlignLeft;
    if (a == "RIGHT")
        alignment = Qt::AlignRight;
    if (a == "CENTER")
        alignment = Qt::AlignHCenter;

    calculateTextSize();
}
示例#4
0
void TextLabel::setSize(int x, int y, int width, int height)
{
    origPoint = QPoint(x, y);

    if (height <= 0 || width <= 0) {
        m_sizeGiven = false;
    } else {
        m_sizeGiven = true;
    }

    Meter::setSize(x, y, width, height);

    calculateTextSize();
}
示例#5
0
void TextLabel::setTextProps(TextField *field)
{
    if (field) {
        text = *field;
        //lineHeight = t->getLineHeight();
        shadow = field->getShadow();
        alignment = field->getAlignment();
        setFontSize(field->getFontSize());
        setFont(field->getFont());

        setColor(field->getColor());
        setBGColor(field->getBGColor());
    }

    calculateTextSize();
}
示例#6
0
void TextLabel::setFontSize(int size)
{
    font.setPixelSize(size);
    calculateTextSize();
}
示例#7
0
void TextLabel::setFont(const QString &f)
{
    font.setFamily(f);
    calculateTextSize();
}
示例#8
0
void TextLabel::setValue(int v)
{
    value = QStringList(QString::number(v));

    calculateTextSize();
}
示例#9
0
void TextLabel::setValue(const QString &text)
{
    value = text.split('\n');

    calculateTextSize();
}