[8127] | 1 | /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
---|
| 2 | * Qwt Widget Library
|
---|
| 3 | * Copyright (C) 1997 Josef Wilgen
|
---|
| 4 | * Copyright (C) 2002 Uwe Rathmann
|
---|
| 5 | *
|
---|
| 6 | * This library is free software; you can redistribute it and/or
|
---|
| 7 | * modify it under the terms of the Qwt License, Version 1.0
|
---|
| 8 | *****************************************************************************/
|
---|
| 9 |
|
---|
| 10 | #ifndef QWT_PLOT_LEGEND_ITEM_H
|
---|
| 11 | #define QWT_PLOT_LEGEND_ITEM_H
|
---|
| 12 |
|
---|
| 13 | #include "qwt_global.h"
|
---|
| 14 | #include "qwt_plot_item.h"
|
---|
| 15 | #include "qwt_legend_data.h"
|
---|
| 16 |
|
---|
| 17 | class QFont;
|
---|
| 18 |
|
---|
| 19 | /*!
|
---|
| 20 | \brief A class which draws a legend inside the plot canvas
|
---|
| 21 |
|
---|
| 22 | QwtPlotLegendItem can be used to draw a inside the plot canvas.
|
---|
| 23 | It can be used together with a QwtLegend or instead of it
|
---|
| 24 | to have more space for the plot canvas.
|
---|
| 25 |
|
---|
| 26 | In opposite to QwtLegend the legend item is not interactive.
|
---|
| 27 | To identify mouse clicks on a legend item an event filter
|
---|
| 28 | needs to be installed catching mouse events ob the plot canvas.
|
---|
| 29 | The geometries of the legend items are available using
|
---|
| 30 | legendGeometries().
|
---|
| 31 |
|
---|
| 32 | The legend item is aligned to plot canvas according to
|
---|
| 33 | its alignment() flags. It might have a background for the
|
---|
| 34 | complete legend ( usually semi transparent ) or for
|
---|
| 35 | each legend item.
|
---|
| 36 |
|
---|
| 37 | \note An external QwtLegend with a transparent background
|
---|
| 38 | on top the plot canvas might be another option
|
---|
| 39 | with a similar effect.
|
---|
| 40 | */
|
---|
| 41 |
|
---|
| 42 | class QWT_EXPORT QwtPlotLegendItem: public QwtPlotItem
|
---|
| 43 | {
|
---|
| 44 | public:
|
---|
| 45 | /*!
|
---|
| 46 | \brief Background mode
|
---|
| 47 |
|
---|
| 48 | Depending on the mode the complete legend or each item
|
---|
| 49 | might have an background.
|
---|
| 50 |
|
---|
| 51 | The default setting is LegendBackground.
|
---|
| 52 |
|
---|
| 53 | \sa setBackgroundMode(), setBackgroundBrush(), drawBackground()
|
---|
| 54 | */
|
---|
| 55 | enum BackgroundMode
|
---|
| 56 | {
|
---|
| 57 | //! The legend has a background
|
---|
| 58 | LegendBackground,
|
---|
| 59 |
|
---|
| 60 | //! Each item has a background
|
---|
| 61 | ItemBackground
|
---|
| 62 | };
|
---|
| 63 |
|
---|
| 64 | explicit QwtPlotLegendItem();
|
---|
| 65 | virtual ~QwtPlotLegendItem();
|
---|
| 66 |
|
---|
| 67 | virtual int rtti() const;
|
---|
| 68 |
|
---|
| 69 | void setAlignment( Qt::Alignment );
|
---|
| 70 | Qt::Alignment alignment() const;
|
---|
| 71 |
|
---|
| 72 | void setMaxColumns( uint );
|
---|
| 73 | uint maxColumns() const;
|
---|
| 74 |
|
---|
| 75 | void setMargin( int );
|
---|
| 76 | int margin() const;
|
---|
| 77 |
|
---|
| 78 | void setSpacing( int );
|
---|
| 79 | int spacing() const;
|
---|
| 80 |
|
---|
| 81 | void setItemMargin( int );
|
---|
| 82 | int itemMargin() const;
|
---|
| 83 |
|
---|
| 84 | void setItemSpacing( int );
|
---|
| 85 | int itemSpacing() const;
|
---|
| 86 |
|
---|
| 87 | void setFont( const QFont& );
|
---|
| 88 | QFont font() const;
|
---|
| 89 |
|
---|
| 90 | void setBorderDistance( int numPixels );
|
---|
| 91 | int borderDistance() const;
|
---|
| 92 |
|
---|
| 93 | void setBorderRadius( double );
|
---|
| 94 | double borderRadius() const;
|
---|
| 95 |
|
---|
| 96 | void setBorderPen( const QPen & );
|
---|
| 97 | QPen borderPen() const;
|
---|
| 98 |
|
---|
| 99 | void setBackgroundBrush( const QBrush & );
|
---|
| 100 | QBrush backgroundBrush() const;
|
---|
| 101 |
|
---|
| 102 | void setBackgroundMode( BackgroundMode );
|
---|
| 103 | BackgroundMode backgroundMode() const;
|
---|
| 104 |
|
---|
| 105 | void setTextPen( const QPen & );
|
---|
| 106 | QPen textPen() const;
|
---|
| 107 |
|
---|
| 108 | virtual void draw( QPainter *p,
|
---|
| 109 | const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
---|
| 110 | const QRectF &rect ) const;
|
---|
| 111 |
|
---|
| 112 | void clearLegend();
|
---|
| 113 |
|
---|
| 114 | virtual void updateLegend( const QwtPlotItem *,
|
---|
| 115 | const QList<QwtLegendData> & );
|
---|
| 116 |
|
---|
| 117 | virtual QRect geometry( const QRectF &canvasRect ) const;
|
---|
| 118 |
|
---|
| 119 | virtual QSize minimumSize( const QwtLegendData & ) const;
|
---|
| 120 | virtual int heightForWidth( const QwtLegendData &, int w ) const;
|
---|
| 121 |
|
---|
| 122 | QList< const QwtPlotItem * > plotItems() const;
|
---|
| 123 | QList< QRect > legendGeometries( const QwtPlotItem * ) const;
|
---|
| 124 |
|
---|
| 125 | protected:
|
---|
| 126 | virtual void drawLegendData( QPainter *painter,
|
---|
| 127 | const QwtPlotItem *, const QwtLegendData &, const QRectF & ) const;
|
---|
| 128 |
|
---|
| 129 | virtual void drawBackground( QPainter *, const QRectF &rect ) const;
|
---|
| 130 |
|
---|
| 131 | private:
|
---|
| 132 | class PrivateData;
|
---|
| 133 | PrivateData *d_data;
|
---|
| 134 | };
|
---|
| 135 |
|
---|
| 136 | #endif
|
---|