1 /*
2  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB.  All rights reserved.
3  *
4  * This file is part of the KD Chart library.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef KCHART_TEXT_AREA_H
21 #define KCHART_TEXT_AREA_H
22 
23 #include <QObject>
24 
25 #include "KChartGlobal.h"
26 #include "KChartAbstractAreaBase.h"
27 #include "KChartLayoutItems.h"
28 
29 namespace KChart {
30 
31 
32 /**
33   * @class TextArea KChartTextArea.h
34   * @brief A text area in the chart with a background, a frame, etc.
35   *
36   * TextArea is the base class for all text containing non-widget chart elements
37   * that have a set of background attributes and frame attributes, such as
38   * headers or footers.
39   *
40   * @note This class inherits AbstractAreaBase, TextLayoutItem, and QObject.
41   * The reason for this triple inheritance is that neither AbstractAreaBase nor
42   * TextLayoutItem inherit QObject.
43   */
44 class KCHART_EXPORT TextArea : public QObject, public AbstractAreaBase, public TextLayoutItem
45 {
46     Q_OBJECT
47 
48     Q_DISABLE_COPY( TextArea )
49     KCHART_DECLARE_PRIVATE_DERIVED( TextArea )
50 
51 
52 public:
53     virtual ~TextArea() ;
54 
55 //    virtual TextArea * clone() const = 0;
56     /**
57       * @brief Draws the background and frame, then calls paint().
58       *
59       * In most cases there is no need to overwrite this method in a derived
60       * class, but you would overwrite TextLayoutItem::paint() instead.
61       */
62     virtual void paintIntoRect( QPainter& painter, const QRect& rect );
63 
64     /**
65       * Call paintAll, if you want the background and the frame to be drawn
66       * before the normal paint() is invoked automatically.
67       */
68     void paintAll( QPainter& painter ) override;
69 
70 protected:
71     TextArea();
72     QRect areaGeometry() const override;
73     void positionHasChanged() override;
74 
75 Q_SIGNALS:
76     void positionChanged( TextArea * );
77 
78     //KCHART_DECLARE_PRIVATE_DERIVED(TextArea)
79 }; // End of class TextArea
80 
81 }
82 #endif // KCHART_TEXT_AREA_H
83