KChart

KChartAbstractAreaBase.h
1/*
2 * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3 *
4 * This file is part of the KD Chart library.
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#ifndef KCHARTABSTRACTAREABASE_H
10#define KCHARTABSTRACTAREABASE_H
11
12#include <QPointF>
13#include <QSizeF>
14#include <QRectF>
15
16#include "KChartGlobal.h"
17#include "KChartLayoutItems.h"
18#include "KChartRelativePosition.h"
19#include "KChartAbstractAreaBase.h"
20
21
22QT_BEGIN_NAMESPACE
23class QPainter;
24class QString;
25QT_END_NAMESPACE
26
27namespace KChart {
28 class TextAttributes;
29 class BackgroundAttributes;
30 class FrameAttributes;
31 class PaintContext;
32
33
34/**
35 * @class AbstractAreaBase KChartAbstractAreaBase.h
36 * @brief Base class for AbstractArea and AbstractAreaWidget: An area
37 * in the chart with a background, a frame, etc.
38 *
39 * AbstractAreaBase is the base class for all chart elements that have
40 * a set of background attributes and frame attributes, such as
41 * legends or axes.
42 *
43 * @note Normally you should not use AbstractAreaBase directly, but
44 * derive your classes from AbstractArea or AbstractAreaWidget.
45 *
46 * @note This classis not a QObject, so it is easier to inherit from
47 * it, if your are inheriting from a QObject too like AbstractAreaWidget does it.
48 *
49 * @sa AbstractArea, AbstractAreaWidget
50 */
51class KCHART_EXPORT AbstractAreaBase
52{
53 Q_DISABLE_COPY( AbstractAreaBase )
54 KCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC( AbstractAreaBase )
55
56protected:
58 virtual ~AbstractAreaBase() ;
59
60public:
61 /**
62 * Returns true if both areas have the same settings.
63 */
64 bool compare( const AbstractAreaBase* other ) const;
65
66 void alignToReferencePoint( const RelativePosition& position );
67
68 void setFrameAttributes( const FrameAttributes &a );
69 FrameAttributes frameAttributes() const;
70
71 void setBackgroundAttributes( const BackgroundAttributes &a );
72 BackgroundAttributes backgroundAttributes() const;
73
74 virtual void paintBackground( QPainter& painter, const QRect& rectangle );
75 virtual void paintFrame( QPainter& painter, const QRect& rectangle );
76
77 static void paintBackgroundAttributes( QPainter& painter, const QRect& rectangle,
78 const KChart::BackgroundAttributes& attributes );
79 static void paintFrameAttributes( QPainter& painter, const QRect& rectangle,
80 const KChart::FrameAttributes& attributes );
81
82 /** \internal
83 * \note Normally you should not call this method, but derive your classes
84 * from AbstractArea or AbstractAreaWidget.
85 * \sa AbstractArea, AbstractAreaWidget
86 */
87 void getFrameLeadings(int& left, int& top, int& right, int& bottom ) const;
88
89
90protected:
91 /** \internal
92 * \note Normally you should not call this method, but derive your classes
93 * from AbstractArea or AbstractAreaWidget.
94 * \sa AbstractArea, AbstractAreaWidget
95 */
96 QRect innerRect() const;
97
98 /** \internal
99 * This internal method is used by AbstractArea and AbstractAreaWidget
100 * to find out the real widget size.
101 * \sa AbstractArea, AbstractAreaWidget
102 */
103 virtual QRect areaGeometry() const = 0;
104
105 /** \internal
106 * This internal method can be overwritten by derived classes,
107 * if they want to emit a signal (or perform other actions, resp.)
108 * when the Position of the area has been changed.
109 * The default implementation does nothing.
110 */
111 virtual void positionHasChanged();
112
113}; // End of class AbstractAreaBase
114
115}
116#endif // KCHARTABSTRACTAREABASE_H
Contains KChart macros.
Base class for AbstractArea and AbstractAreaWidget: An area in the chart with a background,...
virtual QRect areaGeometry() const =0
Set of attributes usable for background pixmaps.
A set of attributes for frames around items.
Defines relative position information: reference area, position in this area (reference position),...
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.