![]() |
.Simulation
|
A legend item representing a plottable with an icon and the plottable name. More...
Public Member Functions | |
QCPPlottableLegendItem (QCPLegend *parent, QCPAbstractPlottable *plottable) | |
Creates a new legend item associated with plottable. More... | |
QCPAbstractPlottable * | plottable () |
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... | |
![]() | |
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... | |
![]() | |
void | applyAntialiasingHint (QCPPainter *painter) const |
Protected Attributes | |
QCPAbstractPlottable * | mPlottable |
bool | mTextWrap |
![]() | |
QCPLegend * | mParentLegend |
bool | mAntialiased |
QFont | mFont |
QColor | mTextColor |
QFont | mSelectedFont |
QColor | mSelectedTextColor |
bool | mSelectable |
bool | mSelected |
Additional Inherited Members | |
![]() | |
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. | |
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.
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.
|
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.
|
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.