23 #ifndef KDCHARTPOSITION_H
24 #define KDCHARTPOSITION_H
29 #include <QCoreApplication>
36 template <
typename T>
class QList;
85 const char *name()
const;
86 QString printableName()
const;
88 bool isUnknown()
const;
90 bool isWestSide()
const;
91 bool isNorthSide()
const;
92 bool isEastSide()
const;
93 bool isSouthSide()
const;
95 bool isCorner()
const;
98 bool isFloating()
const;
116 IncludeFloating = 0x2 };
117 Q_DECLARE_FLAGS( Options, Option )
123 static
QList<QByteArray> names( Options options = Options(IncludeCenter | IncludeFloating) );
124 static QStringList printableNames( Options options = Options(IncludeCenter | IncludeFloating) );
126 static Position fromName(const
char * name);
127 static Position fromName(const QByteArray & name);
129 bool operator==( const Position& ) const;
130 bool operator==(
int ) const;
131 bool operator!=( const Position& ) const;
132 bool operator!=(
int ) const;
138 inline
bool Position::operator!=( const Position & other )
const {
return !
operator==( other ); }
160 : mPositionCenter( center )
161 , mPositionNorthWest( northWest )
162 , mPositionNorth( north )
163 , mPositionNorthEast( northEast )
164 , mPositionEast( east )
165 , mPositionSouthEast( southEast )
166 , mPositionSouth( south )
167 , mPositionSouthWest( southWest )
168 , mPositionWest( west )
171 const QPointF& onePointForAllPositions )
172 : mPositionCenter( onePointForAllPositions )
173 , mPositionNorthWest( onePointForAllPositions )
174 , mPositionNorth( onePointForAllPositions )
175 , mPositionNorthEast( onePointForAllPositions )
176 , mPositionEast( onePointForAllPositions )
177 , mPositionSouthEast( onePointForAllPositions )
178 , mPositionSouth( onePointForAllPositions )
179 , mPositionSouthWest( onePointForAllPositions )
180 , mPositionWest( onePointForAllPositions )
185 const QRectF r( rect.normalized() );
186 mPositionCenter = r.center();
187 mPositionNorthWest = r.topLeft();
188 mPositionNorth = QPointF(r.center().x(), r.top());
189 mPositionNorthEast = r.topRight();
190 mPositionEast = QPointF(r.right(), r.center().y());
191 mPositionSouthEast = r.bottomRight();
192 mPositionSouth = QPointF(r.center().x(), r.bottom());
193 mPositionSouthWest = r.bottomLeft();
194 mPositionWest = QPointF(r.left(), r.center().y());
201 : mPositionCenter( (northWest + southEast) / 2.0 )
202 , mPositionNorthWest( northWest )
203 , mPositionNorth( (northWest + northEast) / 2.0 )
204 , mPositionNorthEast( northEast )
205 , mPositionEast( (northEast + southEast) / 2.0 )
206 , mPositionSouthEast( southEast )
207 , mPositionSouth( (southWest + southEast) / 2.0 )
208 , mPositionSouthWest( southWest )
209 , mPositionWest( (northWest + southWest) / 2.0 )
214 mapOfDegrees[pos] = degrees;
217 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)
223 if ( mapOfDegrees.contains(pos) )
224 return mapOfDegrees[pos];
228 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)
229 const QPointF point( Position position )
const
231 QPointF point( Position position )
const
236 return mPositionCenter;
238 return mPositionNorthWest;
240 return mPositionNorth;
242 return mPositionNorthEast;
244 return mPositionEast;
246 return mPositionSouthEast;
248 return mPositionSouth;
250 return mPositionSouthWest;
252 return mPositionWest;
253 return mPositionUnknown;
259 mPositionUnknown.isNull() &&
260 mPositionCenter.isNull() &&
261 mPositionNorthWest.isNull() &&
262 mPositionNorth.isNull() &&
263 mPositionNorthEast.isNull() &&
264 mPositionEast.isNull() &&
265 mPositionSouthEast.isNull() &&
266 mPositionSouth.isNull() &&
267 mPositionSouthWest.isNull() &&
268 mPositionWest.isNull();
289 #if !defined(QT_NO_DEBUG_STREAM)
295 Q_DECLARE_OPERATORS_FOR_FLAGS( KDChart::Position::Options )
298 Q_DECLARE_METATYPE( KDChart::Position )
300 #endif // KDCHARTPOSITION_H