2009-02-27 13:57:26 +00:00
|
|
|
/** \ingroup MapComposer
|
|
|
|
* A label that can be placed onto a map composition.
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
class QgsComposerLabel : QgsComposerItem
|
2009-02-27 13:57:26 +00:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgscomposerlabel.h"
|
|
|
|
%End
|
|
|
|
public:
|
2009-02-28 14:35:45 +00:00
|
|
|
QgsComposerLabel( QgsComposition *composition /TransferThis/);
|
2009-02-27 13:57:26 +00:00
|
|
|
~QgsComposerLabel();
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Return correct graphics item type. */
|
2010-11-25 21:45:52 +00:00
|
|
|
virtual int type() const;
|
|
|
|
|
2009-02-27 13:57:26 +00:00
|
|
|
/** \brief Reimplementation of QCanvasItem::paint*/
|
|
|
|
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Resizes the widget such that the text fits to the item. Keeps top left point*/
|
2009-02-27 13:57:26 +00:00
|
|
|
void adjustSizeToText();
|
|
|
|
|
|
|
|
QString text();
|
|
|
|
void setText( const QString& text );
|
2009-08-12 07:35:38 +00:00
|
|
|
|
2013-06-23 16:00:16 +02:00
|
|
|
int htmlState();
|
|
|
|
void setHtmlState( int state );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns the text as it appears on screen (with replaced data field) */
|
2009-08-12 07:35:38 +00:00
|
|
|
QString displayText() const;
|
2012-02-28 09:30:44 +02:00
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/** Sets the current feature, the current layer and a list of local variable substitutions for evaluating expressions.
|
|
|
|
* @deprecated use atlas features and setSubstitutions() instead
|
|
|
|
*/
|
2015-10-07 11:55:34 +11:00
|
|
|
void setExpressionContext( QgsFeature* feature, QgsVectorLayer* layer, const QMap<QString, QVariant>& substitutions = QMap<QString, QVariant>() ) /Deprecated/;
|
2015-08-13 09:27:25 +10:00
|
|
|
|
|
|
|
/** Sets the list of local variable substitutions for evaluating expressions in label text.
|
|
|
|
* @note added in QGIS 2.12
|
|
|
|
*/
|
2015-10-07 11:55:34 +11:00
|
|
|
void setSubstitutions( const QMap<QString, QVariant>& substitutions = QMap<QString, QVariant>() );
|
2012-10-02 14:27:42 +02:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
QFont font() const;
|
|
|
|
void setFont( const QFont& f );
|
2012-02-28 09:30:44 +02:00
|
|
|
/** Accessor for the vertical alignment of the label
|
|
|
|
* @returns Qt::AlignmentFlag
|
|
|
|
*/
|
|
|
|
Qt::AlignmentFlag vAlign() const;
|
|
|
|
/** Accessor for the horizontal alignment of the label
|
|
|
|
* @returns Qt::AlignmentFlag
|
|
|
|
*/
|
|
|
|
Qt::AlignmentFlag hAlign() const;
|
|
|
|
/** Mutator for the horizontal alignment of the label
|
2012-09-24 02:28:15 +02:00
|
|
|
* @param a alignment
|
2012-02-28 09:30:44 +02:00
|
|
|
* @returns void
|
|
|
|
*/
|
|
|
|
void setHAlign( Qt::AlignmentFlag a );
|
|
|
|
/** Mutator for the vertical alignment of the label
|
2012-09-24 02:28:15 +02:00
|
|
|
* @param a alignment
|
2012-02-28 09:30:44 +02:00
|
|
|
* @returns void
|
|
|
|
*/
|
|
|
|
void setVAlign( Qt::AlignmentFlag a );
|
2014-10-14 20:09:35 +11:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns the margin between the edge of the frame and the label contents
|
2014-10-14 20:09:35 +11:00
|
|
|
* @returns margin in mm
|
|
|
|
* @deprecated use marginX and marginY instead
|
2016-02-14 03:50:23 +01:00
|
|
|
*/
|
2014-10-14 20:09:35 +11:00
|
|
|
double margin() /Deprecated/;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns the horizontal margin between the edge of the frame and the label
|
2014-10-14 20:09:35 +11:00
|
|
|
* contents.
|
|
|
|
* @returns horizontal margin in mm
|
|
|
|
* @note added in QGIS 2.7
|
2016-02-14 03:50:23 +01:00
|
|
|
*/
|
2014-10-14 20:09:35 +11:00
|
|
|
double marginX() const;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns the vertical margin between the edge of the frame and the label
|
2014-10-14 20:09:35 +11:00
|
|
|
* contents.
|
|
|
|
* @returns vertical margin in mm
|
|
|
|
* @note added in QGIS 2.7
|
2016-02-14 03:50:23 +01:00
|
|
|
*/
|
2014-10-14 20:09:35 +11:00
|
|
|
double marginY() const;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Sets the margin between the edge of the frame and the label contents.
|
2014-10-14 20:09:35 +11:00
|
|
|
* This method sets both the horizontal and vertical margins to the same
|
|
|
|
* value. The margins can be individually controlled using the setMarginX
|
|
|
|
* and setMarginY methods.
|
|
|
|
* @param m margin in mm
|
|
|
|
* @see setMarginX
|
|
|
|
* @see setMarginY
|
2016-02-14 03:50:23 +01:00
|
|
|
*/
|
2014-10-14 20:09:35 +11:00
|
|
|
void setMargin( const double m );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Sets the horizontal margin between the edge of the frame and the label
|
2014-10-14 20:09:35 +11:00
|
|
|
* contents.
|
|
|
|
* @param margin horizontal margin in mm
|
|
|
|
* @see setMargin
|
|
|
|
* @see setMarginY
|
|
|
|
* @note added in QGIS 2.7
|
2016-02-14 03:50:23 +01:00
|
|
|
*/
|
2014-10-14 20:09:35 +11:00
|
|
|
void setMarginX( const double margin );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Sets the vertical margin between the edge of the frame and the label
|
2014-10-14 20:09:35 +11:00
|
|
|
* contents.
|
|
|
|
* @param margin vertical margin in mm
|
|
|
|
* @see setMargin
|
|
|
|
* @see setMarginX
|
|
|
|
* @note added in QGIS 2.7
|
2016-02-14 03:50:23 +01:00
|
|
|
*/
|
2014-10-14 20:09:35 +11:00
|
|
|
void setMarginY( const double margin );
|
2012-02-28 09:30:44 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Sets text color */
|
2012-09-24 02:28:15 +02:00
|
|
|
void setFontColor( const QColor& c );
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Get font color */
|
2009-11-20 09:43:39 +00:00
|
|
|
QColor fontColor() const;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Stores state in Dom element
|
2016-02-14 03:50:23 +01:00
|
|
|
* @param elem is Dom element corresponding to 'Composer' tag
|
|
|
|
* @param doc document
|
|
|
|
*/
|
2009-02-27 13:57:26 +00:00
|
|
|
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Sets state from Dom document
|
2016-02-14 03:50:23 +01:00
|
|
|
* @param itemElem is Dom element corresponding to 'ComposerLabel' tag
|
|
|
|
* @param doc document
|
|
|
|
*/
|
2009-02-27 13:57:26 +00:00
|
|
|
bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
|
2014-08-17 13:37:26 +02:00
|
|
|
|
2015-10-04 23:54:21 +02:00
|
|
|
//Overridden to contain part of label's text
|
2014-07-28 19:44:43 +10:00
|
|
|
virtual QString displayName() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** In case of negative margins, the bounding rect may be larger than the
|
2014-10-14 20:10:03 +11:00
|
|
|
* label's frame
|
2016-02-14 03:50:23 +01:00
|
|
|
*/
|
2014-10-14 20:10:03 +11:00
|
|
|
QRectF boundingRect() const;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Reimplemented to call prepareGeometryChange after toggling frame
|
2016-02-14 03:50:23 +01:00
|
|
|
*/
|
2014-10-14 20:10:03 +11:00
|
|
|
virtual void setFrameEnabled( const bool drawFrame );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Reimplemented to call prepareGeometryChange after changing outline width
|
2016-02-14 03:50:23 +01:00
|
|
|
*/
|
2014-10-14 20:10:03 +11:00
|
|
|
virtual void setFrameOutlineWidth( const double outlineWidth );
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
public slots:
|
2014-11-21 01:17:21 +01:00
|
|
|
void refreshExpressionContext();
|
2009-02-28 14:35:45 +00:00
|
|
|
};
|