17 #include <qdrawutil.h> 21 #include <qstyleoption.h> 22 #include <qapplication.h> 32 const int ph = w->style()->pixelMetric(
33 QStyle::PM_ButtonShiftHorizontal, &option, w );
34 const int pv = w->style()->pixelMetric(
35 QStyle::PM_ButtonShiftVertical, &option, w );
36 return QSize( ph, pv );
68 const bool doUpdate = updatesEnabled();
70 setUpdatesEnabled(
false );
79 setUpdatesEnabled(
true );
117 const int flags = Qt::AlignLeft | Qt::AlignVCenter
118 | Qt::TextExpandTabs | Qt::TextWordWrap;
141 ? Qt::TabFocus : Qt::NoFocus );
169 if ( icon.width() > 0 )
192 spacing = qMax( spacing, 0 );
224 const bool isBlocked = signalsBlocked();
225 blockSignals(
true );
229 blockSignals( isBlocked );
273 sz.setHeight( qMax( sz.height(),
d_data->
icon.height() + 4 ) );
278 sz = sz.expandedTo( QApplication::globalStrut() );
287 const QRect cr = contentsRect();
289 QPainter painter(
this );
290 painter.setClipRegion( e->region() );
294 qDrawWinButton( &painter, 0, 0, width(), height(),
303 painter.translate( shiftSize.width(), shiftSize.height() );
306 painter.setClipRect( cr );
313 iconRect.setX( iconRect.x() +
margin() );
318 iconRect.moveCenter( QPoint( iconRect.center().x(), cr.center().y() ) );
329 if ( e->button() == Qt::LeftButton )
346 QwtTextLabel::mousePressEvent( e );
352 if ( e->button() == Qt::LeftButton )
368 QwtTextLabel::mouseReleaseEvent( e );
374 if ( e->key() == Qt::Key_Space )
380 if ( !e->isAutoRepeat() )
386 if ( !e->isAutoRepeat() )
394 QwtTextLabel::keyPressEvent( e );
400 if ( e->key() == Qt::Key_Space )
406 if ( !e->isAutoRepeat() )
418 QwtTextLabel::keyReleaseEvent( e );
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 QSize sizeHint() const
Return a size hint.
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.
QPixmap toPixmap() const
Convert the graphic to a QPixmap.
virtual void keyReleaseEvent(QKeyEvent *)
Handle key release events.
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.
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
virtual void mouseReleaseEvent(QMouseEvent *)
Handle mouse release events.
bool hasRole(int role) const
virtual QSize sizeHint() const
Return a size hint.
QwtLegendData::Mode itemMode
void setRenderFlags(int flags)
Change the render flags.
virtual ~QwtLegendLabel()
Destructor.
A class representing a text.
virtual void drawContents(QPainter *)
Redraw the text and focus indicator.
static QSize buttonShift(const QwtLegendLabel *w)
QwtLegendLabel(QWidget *parent=0)
void checked(bool)
Signal, when the legend item has been toggled.
virtual void keyPressEvent(QKeyEvent *)
Handle key press events.
void setIcon(const QPixmap &)
void released()
Signal, when the legend item has been released.
QwtLegendData::Mode itemMode() const
virtual void mousePressEvent(QMouseEvent *)
Handle mouse press events.
void setData(const QwtLegendData &)
virtual void setText(const QwtText &)
Mode
Mode defining how a legend entry interacts.
virtual void paintEvent(QPaintEvent *)
Paint event.
bool isDown() const
Return true, if the item is down.
static const int ButtonFrame
Attributes of an entry on a legend.
void setItemMode(QwtLegendData::Mode)
void setText(const QString &, QwtText::TextFormat textFormat=QwtText::AutoText)