QGIS API Documentation  2.6.0-Brighton
 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  void setStrikeOut( bool enable );
122  bool strikeOutIsSet() const;
123  bool strikeOut() const;
124 
125  void setSize( double size, int type );
126  bool sizeIsSet() const;
127  int sizeType() const;
128  double size() const;
129 
130  void setColor( const QColor &color );
131  bool colorIsSet() const;
132  const QColor & color() const;
133 
134  /* Offset */
135  void setOffset( double x, double y, int type );
136  bool offsetIsSet() const;
137  int offsetType() const;
138  double xOffset() const;
139  double yOffset() const;
140 
141  /* Angle */
142  void setAngle( double angle );
143  bool angleIsSet() const;
144  double angle() const;
145 
146  bool angleIsAuto() const;
147  void setAutoAngle( bool state );
148 
149  /* Alignment */
150  void setAlignment( int alignment );
151  bool alignmentIsSet() const;
152  int alignment() const;
153 
154  /* Buffer */
155  bool bufferEnabled() const;
156  void setBufferEnabled( bool useBufferFlag );
157  void setBufferSize( double size, int type );
158  bool bufferSizeIsSet() const;
159  int bufferSizeType() const;
160  double bufferSize() const;
161 
162  void setBufferColor( const QColor &color );
163  bool bufferColorIsSet() const;
164  QColor bufferColor() const;
165 
166  void setBufferStyle( Qt::BrushStyle style );
167  bool bufferStyleIsSet() const;
168  Qt::BrushStyle bufferStyle() const;
169 
170  /* Border */
171  void setBorderColor( const QColor &color );
172  bool borderColorIsSet() const;
173  QColor borderColor() const;
174 
175  void setBorderWidth( int width );
176  bool borderWidthIsSet() const;
177  int borderWidth() const;
178 
179  void setBorderStyle( Qt::PenStyle style );
180  bool borderStyleIsSet() const;
181  Qt::PenStyle borderStyle() const;
182 
183  bool multilineEnabled() const;
184  void setMultilineEnabled( bool useMultiline );
185 
186  /* label only selected features */
187  bool selectedOnly() const;
188  void setSelectedOnly( bool selectedonly );
189 
190  protected:
191  /* Text */
192  QString mText;
194 
196  QFont mFont;
202 
205  double mSize;
207 
209  QColor mColor;
211 
214  double mXOffset;
215  double mYOffset;
217 
219  double mAngle;
222 
226 
231  double mBufferSize;
233 
235  QBrush mBufferBrush;
238 
244 
247 
250 };
251 
252 #endif