QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgslabelattributes.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslabelattributes.h - render vector labels
3  -------------------
4  begin : August 2004
5  copyright : (C) 2004 by Radim Blazek
6  email : [email protected]
7  ***************************************************************************/
8 /***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 #ifndef QGSLABELATTRIBUTES_H
17 #define QGSLABELATTRIBUTES_H
18 
19 #include <QBrush>
20 #include <QFont>
21 #include <QPen>
22 
23 class QString;
24 class QColor;
25 
76 class CORE_EXPORT QgsLabelAttributes
77 {
78  public:
82  QgsLabelAttributes( bool def = true );
83 
85 
86  /* Units type */
87  enum Units
88  {
89  MapUnits = 0,
90  PointUnits
91  };
92 
93  static QString unitsName( int units );
94  static int unitsCode( const QString &name );
95 
96  static QString alignmentName( int alignment );
97  static int alignmentCode( const QString &name );
98 
99  /* Text */
100  void setText( const QString & text );
101  bool textIsSet() const;
102  const QString text() const;
103 
104  /* Font */
105  void setFamily( const QString & family );
106  bool familyIsSet() const;
107  const QString family() const;
108 
109  void setBold( bool enable );
110  bool boldIsSet() const;
111  bool bold() const;
112 
113  void setItalic( bool enable );
114  bool italicIsSet() const;
115  bool italic() const;
116 
117  void setUnderline( bool enable );
118  bool underlineIsSet() const;
119  bool underline() const;
120 
121  /* strikeout added in 1.5 */
122  void setStrikeOut( bool enable );
123  bool strikeOutIsSet() const;
124  bool strikeOut() const;
125 
126  void setSize( double size, int type );
127  bool sizeIsSet() const;
128  int sizeType() const;
129  double size() const;
130 
131  void setColor( const QColor &color );
132  bool colorIsSet() const;
133  const QColor & color() const;
134 
135  /* Offset */
136  void setOffset( double x, double y, int type );
137  bool offsetIsSet() const;
138  int offsetType() const;
139  double xOffset() const;
140  double yOffset() const;
141 
142  /* Angle */
143  void setAngle( double angle );
144  bool angleIsSet() const;
145  double angle() const;
146 
147  bool angleIsAuto() const;
148  void setAutoAngle( bool state );
149 
150  /* Alignment */
151  void setAlignment( int alignment );
152  bool alignmentIsSet() const;
153  int alignment() const;
154 
155  /* Buffer */
156  bool bufferEnabled() const;
157  void setBufferEnabled( bool useBufferFlag );
158  void setBufferSize( double size, int type );
159  bool bufferSizeIsSet() const;
160  int bufferSizeType() const;
161  double bufferSize() const;
162 
163  void setBufferColor( const QColor &color );
164  bool bufferColorIsSet() const;
165  QColor bufferColor() const;
166 
167  void setBufferStyle( Qt::BrushStyle style );
168  bool bufferStyleIsSet() const;
169  Qt::BrushStyle bufferStyle() const;
170 
171  /* Border */
172  void setBorderColor( const QColor &color );
173  bool borderColorIsSet() const;
174  QColor borderColor() const;
175 
176  void setBorderWidth( int width );
177  bool borderWidthIsSet() const;
178  int borderWidth() const;
179 
180  void setBorderStyle( Qt::PenStyle style );
181  bool borderStyleIsSet() const;
182  Qt::PenStyle borderStyle() const;
183 
184  bool multilineEnabled() const;
185  void setMultilineEnabled( bool useMultiline );
186 
187  /* label only selected features
188  * added in 1.5
189  */
190  bool selectedOnly() const;
191  void setSelectedOnly( bool selectedonly );
192 
193  protected:
194  /* Text */
195  QString mText;
197 
199  QFont mFont;
205 
208  double mSize;
210 
212  QColor mColor;
214 
217  double mXOffset;
218  double mYOffset;
220 
222  double mAngle;
225 
229 
234  double mBufferSize;
236 
238  QBrush mBufferBrush;
241 
247 
250 
253 };
254 
255 #endif