QGIS API Documentation  master-6227475
src/core/composer/qgscomposerlabel.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                          qgscomposerlabel.h
00003                              -------------------
00004     begin                : January 2005
00005     copyright            : (C) 2005 by Radim Blazek
00006     email                : blazek@itc.it
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 #ifndef QGSCOMPOSERLABEL_H
00018 #define QGSCOMPOSERLABEL_H
00019 
00020 #include "qgscomposeritem.h"
00021 #include <QFont>
00022 
00023 class QgsVectorLayer;
00024 class QgsFeature;
00025 
00029 class CORE_EXPORT QgsComposerLabel: public QgsComposerItem
00030 {
00031     Q_OBJECT
00032   public:
00033     QgsComposerLabel( QgsComposition *composition );
00034     ~QgsComposerLabel();
00035 
00037     virtual int type() const { return ComposerLabel; }
00038 
00040     void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
00041 
00043     void adjustSizeToText();
00044 
00045     QString text() { return mText; }
00046     void setText( const QString& text );
00047 
00048     int htmlSate() { return mHtmlState; }
00049     void setHtmlSate( int state ) {mHtmlState = state;}
00050 
00053     QString displayText() const;
00054 
00056     void setExpressionContext( QgsFeature* feature, QgsVectorLayer* layer, QMap<QString, QVariant> substitutions = ( QMap<QString, QVariant>() ) );
00057 
00058     QFont font() const;
00059     void setFont( const QFont& f );
00063     Qt::AlignmentFlag vAlign() const { return mVAlignment; }
00067     Qt::AlignmentFlag hAlign() const { return mHAlignment; }
00072     void setHAlign( Qt::AlignmentFlag a ) {mHAlignment = a;}
00077     void setVAlign( Qt::AlignmentFlag a ) {mVAlignment = a;}
00079     double margin() {return mMargin;}
00081     void setMargin( double m ) {mMargin = m;}
00082 
00085     void setFontColor( const QColor& c ) {mFontColor = c;}
00088     QColor fontColor() const {return mFontColor;}
00089 
00090     void setSceneRect( const QRectF& rectangle );
00091 
00096     bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
00097 
00102     bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
00103 
00104   public slots:
00105     virtual void setRotation( double r );
00106 
00107   private slots:
00108     void loadingHtmlFinished( bool );
00109 
00110   private:
00111     // Text
00112     QString mText;
00113 
00114     // Html state
00115     int mHtmlState;
00116     double mHtmlUnitsToMM;
00117     double htmlUnitsToMM(); //calculate scale factor
00118     bool mHtmlLoaded;
00119 
00121     void itemShiftAdjustSize( double newWidth, double newHeight, double& xShift, double& yShift ) const;
00122 
00123     // Font
00124     QFont mFont;
00125 
00126     // Border between text and fram (in mm)
00127     double mMargin;
00128 
00129     // Font color
00130     QColor mFontColor;
00131 
00132     // Horizontal Alignment
00133     Qt::AlignmentFlag mHAlignment;
00134 
00135     // Vertical Alignment
00136     Qt::AlignmentFlag mVAlignment;
00137 
00139     void replaceDateText( QString& text ) const;
00140 
00142     double mTextBoxWidth;
00144     double mTextBoxHeight;
00145 
00146     QgsFeature* mExpressionFeature;
00147     QgsVectorLayer* mExpressionLayer;
00148     QMap<QString, QVariant> mSubstitutions;
00149 
00150 
00151 };
00152 
00153 #endif
00154 
00155 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines