.Simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QCPlot::QCPPlottableLegendItem Class Reference

A legend item representing a plottable with an icon and the plottable name. More...

Inheritance diagram for QCPlot::QCPPlottableLegendItem:
QCPlot::QCPAbstractLegendItem

Public Member Functions

 QCPPlottableLegendItem (QCPLegend *parent, QCPAbstractPlottable *plottable)
 Creates a new legend item associated with plottable. More...
 
QCPAbstractPlottableplottable ()
 
bool textWrap () const
 
void setTextWrap (bool wrap)
 Sets whether the text of the legend item is wrapped at word boundaries to fit the with of the legend. More...
 
- Public Member Functions inherited from QCPlot::QCPAbstractLegendItem
 QCPAbstractLegendItem (QCPLegend *parent)
 Constructs a QCPAbstractLegendItem and associates it with the QCPLegend parent. More...
 
bool antialiased () const
 
QFont font () const
 
QColor textColor () const
 
QFont selectedFont () const
 
QColor selectedTextColor () const
 
bool selectable () const
 
bool selected () const
 
void setAntialiased (bool enabled)
 Sets whether this legend item is drawn antialiased or not. More...
 
void setFont (const QFont &font)
 Sets the default font of this specific legend item to font. More...
 
void setTextColor (const QColor &color)
 Sets the default text color of this specific legend item to color. More...
 
void setSelectedFont (const QFont &font)
 When this legend item is selected, font is used to draw generic text, instead of the normal font set with setFont. More...
 
void setSelectedTextColor (const QColor &color)
 When this legend item is selected, color is used to draw generic text, instead of the normal color set with setTextColor. More...
 
void setSelectable (bool selectable)
 Sets whether this specific legend item is selectable. More...
 
void setSelected (bool selected)
 Sets whether this specific legend item is selected. More...
 

Protected Member Functions

QPen getIconBorderPen () const
 
QColor getTextColor () const
 
QFont getFont () const
 
virtual void draw (QCPPainter *painter, const QRect &rect) const
 Draws this legend item with painter inside the specified rect. More...
 
virtual QSize size (const QSize &targetSize) const
 Returns the size this item occupies in the legend. More...
 
- Protected Member Functions inherited from QCPlot::QCPAbstractLegendItem
void applyAntialiasingHint (QCPPainter *painter) const
 

Protected Attributes

QCPAbstractPlottablemPlottable
 
bool mTextWrap
 
- Protected Attributes inherited from QCPlot::QCPAbstractLegendItem
QCPLegendmParentLegend
 
bool mAntialiased
 
QFont mFont
 
QColor mTextColor
 
QFont mSelectedFont
 
QColor mSelectedTextColor
 
bool mSelectable
 
bool mSelected
 

Additional Inherited Members

- Signals inherited from QCPlot::QCPAbstractLegendItem
void selectionChanged (bool selected)
 This signal is emitted when the selection state of this legend item has changed, either by user interaction or by a direct call to setSelected.
 

Detailed Description

A legend item representing a plottable with an icon and the plottable name.

This is the standard legend item for plottables. It displays an icon of the plottable next to the plottable name. The icon is drawn by the respective plottable itself (QCPAbstractPlottable::drawLegendIcon), and tries to give an intuitive symbol for the plottable. For example, the QCPGraph draws a centered horizontal line with a single scatter point in the middle and filling (if enabled) below.

Legend items of this type are always associated with one plottable (retrievable via the plottable() function and settable with the constructor). You may change the font of the plottable name with setFont. If setTextWrap is set to true, the plottable name will wrap at the right legend boundary (see QCPLegend::setMinimumSize). Icon padding and border pen is taken from the parent QCPLegend, see QCPLegend::setIconBorderPen and QCPLegend::setIconTextPadding.

The function QCPAbstractPlottable::addToLegend/QCPAbstractPlottable::removeFromLegend creates/removes legend items of this type in the default implementation. However, these functions may be reimplemented such that a different kind of legend item (e.g a direct subclass of QCPAbstractLegendItem) is used for that plottable.

Constructor & Destructor Documentation

QCPlot::QCPPlottableLegendItem::QCPPlottableLegendItem ( QCPLegend parent,
QCPAbstractPlottable plottable 
)

Creates a new legend item associated with plottable.

Once it's created, it can be added to the legend via QCPLegend::addItem.

A more convenient way of adding/removing a plottable to/from the legend is via the functions QCPAbstractPlottable::addToLegend and QCPAbstractPlottable::removeFromLegend.

Member Function Documentation

void QCPlot::QCPPlottableLegendItem::draw ( QCPPainter painter,
const QRect &  rect 
) const
protectedvirtual

Draws this legend item with painter inside the specified rect.

The rect typically has the size which was returned from a preceding size call.

Implements QCPlot::QCPAbstractLegendItem.

void QCPlot::QCPPlottableLegendItem::setTextWrap ( bool  wrap)

Sets whether the text of the legend item is wrapped at word boundaries to fit the with of the legend.

To prevent the legend autoSize feature (QCPLegend::setAutoSize) from compressing the text too strong by wrapping it very often, set an appropriate minimum width with QCPLegend::setMinimumSize.

QSize QCPlot::QCPPlottableLegendItem::size ( const QSize &  targetSize) const
protectedvirtual

Returns the size this item occupies in the legend.

The legend will adapt its layout with the help of this function. If this legend item can have a variable width (e.g. auto-wrapping text), this function tries to find a size with a width close to the width of targetSize. The height of targetSize only may have meaning in specific sublasses. Typically, it's ignored.

Implements QCPlot::QCPAbstractLegendItem.


The documentation for this class was generated from the following files: