9#ifndef KCHARTLAYOUTITEMS_H
10#define KCHARTLAYOUTITEMS_H
14#include <QFontMetricsF>
19#include "KChartTextAttributes.h"
20#include "KChartMarkerAttributes.h"
44 mParentLayout(
nullptr ) {}
77 void setParentLayout(
QLayout* lay )
85 void removeFromParentLayout()
87 if ( mParentLayout ) {
89 mParentLayout->removeWidget(
widget() );
91 mParentLayout->removeItem(
this );
103 class KCHART_EXPORT TextLayoutItem :
public AbstractLayoutItem
107 TextLayoutItem(
const QString& text,
109 const QObject* autoReferenceArea,
113 void setAutoReferenceArea(
const QObject* area );
114 const QObject* autoReferenceArea()
const;
116 void setText(
const QString & text);
151 virtual int marginWidth()
const;
153 virtual QSize sizeHintUnrotated()
const;
155 virtual bool intersects(
const TextLayoutItem& other,
const QPointF& myPos,
const QPointF& otherPos )
const;
156 virtual bool intersects(
const TextLayoutItem& other,
const QPoint& myPos,
const QPoint& otherPos )
const;
158 virtual qreal realFontSize()
const;
159 virtual QFont realFont()
const;
165 bool maybeUpdateRealFont()
const;
168 QSize calcSizeHint(
const QFont& font )
const;
169 int marginWidth(
const QSize& textSize )
const;
171 qreal fitFontSizeToGeometry()
const;
177 const QObject* mAutoReferenceArea;
179 mutable QSize cachedSizeHint;
180 mutable QPolygon mCachedBoundingPolygon;
181 mutable qreal cachedFontSize;
182 mutable QFont cachedFont;
188 TextBubbleLayoutItem();
189 TextBubbleLayoutItem(
const QString& text,
191 const QObject* autoReferenceArea,
195 ~TextBubbleLayoutItem()
override;
197 void setAutoReferenceArea(
const QObject* area );
198 const QObject* autoReferenceArea()
const;
200 void setText(
const QString & text);
207 bool isEmpty()
const override;
211 QSize maximumSize()
const override;
213 QSize minimumSize()
const override;
215 QSize sizeHint()
const override;
217 void setGeometry(
const QRect& r )
override;
219 QRect geometry()
const override;
221 void paint(
QPainter* painter )
override;
224 int borderWidth()
const;
234 class KCHART_EXPORT MarkerLayoutItem :
public AbstractLayoutItem
244 QRect geometry()
const override;
245 bool isEmpty()
const override;
246 QSize maximumSize()
const override;
247 QSize minimumSize()
const override;
248 void setGeometry(
const QRect& r )
override;
249 QSize sizeHint()
const override;
253 static void paintIntoRect(
273 class KCHART_EXPORT LineLayoutItem :
public AbstractLayoutItem
283 QRect geometry()
const override;
284 bool isEmpty()
const override;
285 QSize maximumSize()
const override;
286 QSize minimumSize()
const override;
287 void setGeometry(
const QRect& r )
override;
288 QSize sizeHint()
const override;
290 void setLegendLineSymbolAlignment(
Qt::Alignment legendLineSymbolAlignment);
295 static void paintIntoRect(
313 class KCHART_EXPORT LineWithMarkerLayoutItem :
public AbstractLayoutItem
321 const QBrush& markerBrush,
322 const QPen& markerPen,
326 QRect geometry()
const override;
327 bool isEmpty()
const override;
328 QSize maximumSize()
const override;
329 QSize minimumSize()
const override;
330 void setGeometry(
const QRect& r )
override;
331 QSize sizeHint()
const override;
351 class KCHART_EXPORT HorizontalLineLayoutItem :
public AbstractLayoutItem
354 HorizontalLineLayoutItem();
357 QRect geometry()
const override;
358 bool isEmpty()
const override;
359 QSize maximumSize()
const override;
360 QSize minimumSize()
const override;
361 void setGeometry(
const QRect& r )
override;
362 QSize sizeHint()
const override;
374 class KCHART_EXPORT VerticalLineLayoutItem :
public AbstractLayoutItem
377 VerticalLineLayoutItem();
380 QRect geometry()
const override;
381 bool isEmpty()
const override;
382 QSize maximumSize()
const override;
383 QSize minimumSize()
const override;
384 void setGeometry(
const QRect& r )
override;
385 QSize sizeHint()
const override;
463 class KCHART_EXPORT AutoSpacerLayoutItem :
public AbstractLayoutItem
466 AutoSpacerLayoutItem(
467 bool layoutIsAtTopPosition,
QHBoxLayout *rightLeftLayout,
468 bool layoutIsAtLeftPosition,
QVBoxLayout *topBottomLayout );
471 QRect geometry()
const override;
472 bool isEmpty()
const override;
473 QSize maximumSize()
const override;
474 QSize minimumSize()
const override;
475 void setGeometry(
const QRect& r )
override;
476 QSize sizeHint()
const override;
482 bool mLayoutIsAtTopPosition;
484 bool mLayoutIsAtLeftPosition;
487 mutable QBrush mCommonBrush;
488 mutable QSize mCachedSize;
MeasureOrientation
Measure orientation mode: the way how the absolute value of a KChart::Measure is determined during KC...
AbstractDiagram defines the interface for diagram classes.
Base class for all layout items of KChart.
virtual void setParentWidget(QWidget *widget)
Inform the item about its widget: This enables the item, to trigger that widget's update,...
virtual void paintAll(QPainter &painter)
Default impl: just call paint.
virtual void sizeHintChanged() const
Report changed size hint: ask the parent widget to recalculate the layout.
virtual void paintCtx(PaintContext *context)
Default impl: Paint the complete item using its layouted position and size.
A set of attributes controlling the appearance of data set markers.
Stores information about painting diagrams.
A set of text attributes.
Layout item showing a text.
QSize sizeHint() const override
pure virtual in QLayoutItem
Qt::Orientations expandingDirections() const override
pure virtual in QLayoutItem
void setTextAttributes(const TextAttributes &a)
Use this to specify the text attributes to be used for this item.
QRect geometry() const override
pure virtual in QLayoutItem
bool isEmpty() const override
pure virtual in QLayoutItem
QSize minimumSize() const override
pure virtual in QLayoutItem
void setGeometry(const QRect &r) override
pure virtual in QLayoutItem
TextAttributes textAttributes() const
Returns the text attributes to be used for this item.
QSize maximumSize() const override
pure virtual in QLayoutItem
KTextDocument is an internally used enhanced QTextDocument.
QLayoutItem(Qt::Alignment alignment)
Qt::Alignment alignment() const const