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; } }
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 ); }
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(); }
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(); }
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(); }
void TextLabel::setFontSize(int size) { font.setPixelSize(size); calculateTextSize(); }
void TextLabel::setFont(const QString &f) { font.setFamily(f); calculateTextSize(); }
void TextLabel::setValue(int v) { value = QStringList(QString::number(v)); calculateTextSize(); }
void TextLabel::setValue(const QString &text) { value = text.split('\n'); calculateTextSize(); }