File indexing completed on 2024-05-12 15:54:19

0001 /*
0002  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB.  All rights reserved.
0003  *
0004  * This file is part of the KD Chart library.
0005  *
0006  * This program is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU General Public License as
0008  * published by the Free Software Foundation; either version 2 of
0009  * the License, or (at your option) any later version.
0010  *
0011  * This program is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  * GNU General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU General Public License
0017  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
0018  */
0019 
0020 #ifndef KCHART_TEXT_AREA_H
0021 #define KCHART_TEXT_AREA_H
0022 
0023 #include <QObject>
0024 
0025 #include "KChartGlobal.h"
0026 #include "KChartAbstractAreaBase.h"
0027 #include "KChartLayoutItems.h"
0028 
0029 namespace KChart {
0030 
0031 
0032 /**
0033   * @class TextArea KChartTextArea.h
0034   * @brief A text area in the chart with a background, a frame, etc.
0035   *
0036   * TextArea is the base class for all text containing non-widget chart elements
0037   * that have a set of background attributes and frame attributes, such as
0038   * headers or footers.
0039   *
0040   * @note This class inherits AbstractAreaBase, TextLayoutItem, and QObject.
0041   * The reason for this triple inheritance is that neither AbstractAreaBase nor
0042   * TextLayoutItem inherit QObject.
0043   */
0044 class KCHART_EXPORT TextArea : public QObject, public AbstractAreaBase, public TextLayoutItem
0045 {
0046     Q_OBJECT
0047 
0048     Q_DISABLE_COPY( TextArea )
0049     KCHART_DECLARE_PRIVATE_DERIVED( TextArea )
0050 
0051 
0052 public:
0053     virtual ~TextArea() ;
0054 
0055 //    virtual TextArea * clone() const = 0;
0056     /**
0057       * @brief Draws the background and frame, then calls paint().
0058       *
0059       * In most cases there is no need to overwrite this method in a derived
0060       * class, but you would overwrite TextLayoutItem::paint() instead.
0061       */
0062     virtual void paintIntoRect( QPainter& painter, const QRect& rect );
0063 
0064     /**
0065       * Call paintAll, if you want the background and the frame to be drawn
0066       * before the normal paint() is invoked automatically.
0067       */
0068     void paintAll( QPainter& painter ) override;
0069 
0070 protected:
0071     TextArea();
0072     QRect areaGeometry() const override;
0073     void positionHasChanged() override;
0074 
0075 Q_SIGNALS:
0076     void positionChanged( TextArea * );
0077 
0078     //KCHART_DECLARE_PRIVATE_DERIVED(TextArea)
0079 }; // End of class TextArea
0080 
0081 }
0082 #endif // KCHART_TEXT_AREA_H