File indexing completed on 2024-05-12 04:20:28
0001 /* 0002 * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved. 0003 * 0004 * This file is part of the KD Chart library. 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #ifndef KCHARTABSTRACTAREA_H 0010 #define KCHARTABSTRACTAREA_H 0011 0012 #include <QObject> 0013 0014 #include "KChartGlobal.h" 0015 #include "KChartAbstractAreaBase.h" 0016 #include "KChartLayoutItems.h" 0017 0018 namespace KChart { 0019 0020 0021 /** 0022 * @class AbstractArea KChartAbstractArea.h 0023 * @brief An area in the chart with a background, a frame, etc. 0024 * 0025 * AbstractArea is the base class for all non-widget chart elements that have 0026 * a set of background attributes and frame attributes, such as 0027 * coordinate planes or axes. 0028 * 0029 * @note This class inherits from AbstractAreaBase, AbstractLayoutItem, QObject. 0030 * The reason for this triple inheritance is that neither AbstractAreaBase nor 0031 * AbstractLayoutItem are QObject. 0032 */ 0033 class KCHART_EXPORT AbstractArea : public QObject, 0034 public AbstractAreaBase, 0035 public AbstractLayoutItem 0036 { 0037 Q_OBJECT 0038 0039 Q_DISABLE_COPY( AbstractArea ) 0040 KCHART_DECLARE_PRIVATE_DERIVED( AbstractArea ) 0041 0042 public: 0043 ~AbstractArea() override; 0044 0045 /** 0046 * @brief Draws the background and frame, then calls paint(). 0047 * 0048 * In most cases there is no need to overwrite this method in a derived 0049 * class, but you would overwrite AbstractLayoutItem::paint() instead. 0050 */ 0051 virtual void paintIntoRect( QPainter& painter, const QRect& rect ); 0052 0053 /** 0054 * Call paintAll, if you want the background and the frame to be drawn 0055 * before the normal paint() is invoked automatically. 0056 */ 0057 void paintAll( QPainter& painter ) override; 0058 0059 /** 0060 * This is called at layout time by KChart::AutoSpacerLayoutItem::sizeHint(). 0061 * 0062 * The method triggers AbstractArea::sizeHint() to find out the 0063 * amount of overlap at the left edge of the area. 0064 * 0065 * \note The default implementation is not using any caching, 0066 * it might make sense to implement a more sophisticated solution 0067 * for derived classes that have complex work to do in sizeHint(). 0068 * All we have here is a primitive flag to be set by the caller 0069 * if it is sure that no sizeHint() needs to be called. 0070 */ 0071 virtual int leftOverlap( bool doNotRecalculate=false ) const; 0072 /** 0073 * This is called at layout time by KChart::AutoSpacerLayoutItem::sizeHint(). 0074 * 0075 * The method triggers AbstractArea::sizeHint() to find out the 0076 * amount of overlap at the right edge of the area. 0077 * 0078 * \note The default implementation is not using any caching, 0079 * it might make sense to implement a more sophisticated solution 0080 * for derived classes that have complex work to do in sizeHint(). 0081 * All we have here is a primitive flag to be set by the caller 0082 * if it is sure that no sizeHint() needs to be called. 0083 */ 0084 virtual int rightOverlap( bool doNotRecalculate=false ) const; 0085 /** 0086 * This is called at layout time by KChart::AutoSpacerLayoutItem::sizeHint(). 0087 * 0088 * The method triggers AbstractArea::sizeHint() to find out the 0089 * amount of overlap at the top edge of the area. 0090 * 0091 * \note The default implementation is not using any caching, 0092 * it might make sense to implement a more sophisticated solution 0093 * for derived classes that have complex work to do in sizeHint(). 0094 * All we have here is a primitive flag to be set by the caller 0095 * if it is sure that no sizeHint() needs to be called. 0096 */ 0097 virtual int topOverlap( bool doNotRecalculate=false ) const; 0098 /** 0099 * This is called at layout time by KChart:AutoSpacerLayoutItem::sizeHint(). 0100 * 0101 * The method triggers AbstractArea::sizeHint() to find out the 0102 * amount of overlap at the bottom edge of the area. 0103 * 0104 * \note The default implementation is not using any caching, 0105 * it might make sense to implement a more sophisticated solution 0106 * for derived classes that have complex work to do in sizeHint(). 0107 * All we have here is a primitive flag to be set by the caller 0108 * if it is sure that no sizeHint() needs to be called. 0109 */ 0110 virtual int bottomOverlap( bool doNotRecalculate=false ) const; 0111 0112 protected: 0113 AbstractArea(); 0114 QRect areaGeometry() const override; 0115 void positionHasChanged() override; 0116 0117 Q_SIGNALS: 0118 void positionChanged( KChart::AbstractArea * ); 0119 }; // End of class AbstractArea 0120 0121 } 0122 #endif // KCHARTABSTRACTAREA_H