14 #include <qstyleoption.h> 64 setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
180 int left, right, top, bottom;
181 getContentsMargins( &left, &top, &right, &bottom );
193 if ( align & Qt::AlignLeft || align & Qt::AlignRight )
195 else if ( align & Qt::AlignTop || align & Qt::AlignBottom )
199 sz += QSizeF( mw, mh );
201 return QSize( qCeil( sz.width() ), qCeil( sz.height() ) );
216 int left, right, top, bottom;
217 getContentsMargins( &left, &top, &right, &bottom );
220 if ( renderFlags & Qt::AlignLeft || renderFlags & Qt::AlignRight )
224 if ( ( renderFlags & Qt::AlignTop ) || ( renderFlags & Qt::AlignBottom ) )
238 QPainter painter(
this );
239 painter.setClipRegion( event->region() );
243 style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter,
this);
245 if ( !contentsRect().contains( event->rect() ) )
247 painter.setClipRegion( event->region() & frameRect() );
248 drawFrame( &painter );
251 painter.setClipRegion( event->region() & contentsRect() );
263 painter->setFont( font() );
264 painter->setPen( palette().color( QPalette::Active, QPalette::Text ) );
272 QRect focusRect = contentsRect().adjusted( m, m, -m + 1, -m + 1);
290 QRect r = contentsRect();
295 r.adjust( m, m, -m, -m );
308 if ( renderFlags & Qt::AlignLeft )
312 else if ( renderFlags & Qt::AlignRight )
314 r.setWidth( r.width() -
indent );
316 else if ( renderFlags & Qt::AlignTop )
320 else if ( renderFlags & Qt::AlignBottom )
322 r.setHeight( r.height() -
indent );
332 if ( frameWidth() <= 0 )
341 return QFontMetrics( fnt ).width(
'x' ) / 2;
virtual QSize sizeHint() const
Return a size hint.
virtual int heightForWidth(int) const
static void drawFocusRect(QPainter *, const QWidget *)
Draw a focus rectangle on a widget using its style.
void setText(const QString &, QwtText::TextFormat textFormat=AutoText)
void clear()
Clear the text and all QwtText attributes.
virtual ~QwtTextLabel()
Destructor.
void draw(QPainter *painter, const QRectF &rect) const
const QwtText & text() const
Return the text.
int defaultIndent() const
QwtTextLabel(QWidget *parent=NULL)
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
bool testPaintAttribute(PaintAttribute) const
CONSTEXPR_F fields align(second_tag, fields f) noexcept
QSizeF textSize(const QFont &=QFont()) const
virtual QSize minimumSizeHint() const
Return a minimum size hint.
A class representing a text.
virtual void drawContents(QPainter *)
Redraw the text and focus indicator.
virtual void paintEvent(QPaintEvent *e)
virtual void drawText(QPainter *, const QRectF &)
Redraw the text.
QFont font() const
Return the font.
The text has an individual font.
QString plainText() const
double heightForWidth(double width, const QFont &=QFont()) const
void setPlainText(const QString &)
void setText(const QString &, QwtText::TextFormat textFormat=QwtText::AutoText)