16 #include <qdrawutil.h> 19 #include <qstyleoption.h> 29 const int ph = w->style()->pixelMetric(
30 QStyle::PM_ButtonShiftHorizontal, &option, w );
31 const int pv = w->style()->pixelMetric(
32 QStyle::PM_ButtonShiftVertical, &option, w );
33 return QSize( ph, pv );
65 const bool doUpdate = updatesEnabled();
67 setUpdatesEnabled(
false );
76 setUpdatesEnabled(
true );
114 const int flags = Qt::AlignLeft | Qt::AlignVCenter
115 | Qt::TextExpandTabs | Qt::TextWordWrap;
138 ? Qt::TabFocus : Qt::NoFocus );
166 if ( icon.width() > 0 )
189 spacing = qMax( spacing, 0 );
221 const bool isBlocked = signalsBlocked();
222 blockSignals(
true );
226 blockSignals( isBlocked );
270 sz.setHeight( qMax( sz.height(),
d_data->
icon.height() + 4 ) );
284 const QRect cr = contentsRect();
286 QPainter painter(
this );
287 painter.setClipRegion( e->region() );
291 qDrawWinButton( &painter, 0, 0, width(), height(),
300 painter.translate( shiftSize.width(), shiftSize.height() );
303 painter.setClipRect( cr );
310 iconRect.setX( iconRect.x() +
margin() );
315 iconRect.moveCenter( QPoint( iconRect.center().x(), cr.center().y() ) );
326 if ( e->button() == Qt::LeftButton )
343 QwtTextLabel::mousePressEvent( e );
349 if ( e->button() == Qt::LeftButton )
365 QwtTextLabel::mouseReleaseEvent( e );
371 if ( e->key() == Qt::Key_Space )
377 if ( !e->isAutoRepeat() )
383 if ( !e->isAutoRepeat() )
391 QwtTextLabel::keyPressEvent( e );
397 if ( e->key() == Qt::Key_Space )
403 if ( !e->isAutoRepeat() )
415 QwtTextLabel::keyReleaseEvent( e );
419 #include "moc_qwt_legend_label.cpp" void pressed()
Signal, when the legend item has been pressed.
A widget representing something on a QwtLegend.
The legend item is checkable, like a checkable button.
virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE
Paint event.
bool isChecked() const
Return true, if the item is checked.
A Widget which displays a QwtText.
void clicked()
Signal, when the legend item has been clicked.
void setRenderFlags(int)
Change the render flags.
QSize qwtExpandedToGlobalStrut(const QSize &size)
const QwtLegendData & data() const
The legend item is not interactive, like a label.
The legend item is clickable, like a push button.
const QwtText & text() const
Return the text.
void setDown(bool)
Set the item being down.
void setSpacing(int spacing)
Change the spacing between icon and text.
bool hasRole(int role) const
QwtLegendData::Mode itemMode
virtual ~QwtLegendLabel()
Destructor.
virtual QSize sizeHint() const QWT_OVERRIDE
Return a size hint.
virtual void keyReleaseEvent(QKeyEvent *) QWT_OVERRIDE
Handle key release events.
virtual void keyPressEvent(QKeyEvent *) QWT_OVERRIDE
Handle key press events.
A class representing a text.
virtual void drawContents(QPainter *)
Redraw the text and focus indicator.
virtual void setText(const QwtText &) QWT_OVERRIDE
virtual void mousePressEvent(QMouseEvent *) QWT_OVERRIDE
Handle mouse press events.
static QSize buttonShift(const QwtLegendLabel *w)
QwtLegendLabel(QWidget *parent=0)
void checked(bool)
Signal, when the legend item has been toggled.
QPixmap toPixmap(qreal devicePixelRatio=0.0) const
Convert the graphic to a QPixmap.
void setIcon(const QPixmap &)
void released()
Signal, when the legend item has been released.
QwtLegendData::Mode itemMode() const
void setData(const QwtLegendData &)
Mode
Mode defining how a legend entry interacts.
bool isDown() const
Return true, if the item is down.
virtual QSize sizeHint() const QWT_OVERRIDE
Return a size hint.
static const int ButtonFrame
Attributes of an entry on a legend.
void setItemMode(QwtLegendData::Mode)
virtual void mouseReleaseEvent(QMouseEvent *) QWT_OVERRIDE
Handle mouse release events.
void setText(const QString &, QwtText::TextFormat textFormat=QwtText::AutoText)