KChart

KChartAbstractAreaWidget.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 KCHARTABSTRACTAREAWIDGET_H
10#define KCHARTABSTRACTAREAWIDGET_H
11
12#include <QWidget>
13#include <QPaintEvent>
14#include <QPainter>
15#include <QRect>
16
17#include "KChartAbstractAreaBase.h"
18
19namespace KChart {
20
21
22/**
23 * @class AbstractAreaWidget KChartAbstractArea.h
24 * @brief An area in the chart with a background, a frame, etc.
25 *
26 * AbstractAreaWidget is the base for all widget classes that have
27 * a set of background attributes and frame attributes, such as
28 * KChart::Chart and KChart::Legend.
29 */
30class KCHART_EXPORT AbstractAreaWidget : public QWidget, public AbstractAreaBase
31{
32 Q_OBJECT
33
34 Q_DISABLE_COPY( AbstractAreaWidget )
35 KCHART_DECLARE_PRIVATE_DERIVED_QWIDGET( AbstractAreaWidget )
36
37public:
38 explicit AbstractAreaWidget( QWidget* parent = nullptr );
39
40 /**
41 * @brief Draws the background and frame, then calls paint().
42 *
43 * In most cases there is no need to overwrite this method in a derived
44 * class, but you would overwrite paint() instead.
45 * @sa paint
46 */
47 void paintEvent( QPaintEvent* event ) override;
48
49 /**
50 * @brief Draws the background and frame, then calls paint().
51 *
52 * In most cases there is no need to overwrite this method in a derived
53 * class, but you would overwrite paint() instead.
54 */
55 virtual void paintIntoRect( QPainter& painter, const QRect& rect );
56
57 /**
58 * Overwrite this to paint the inner contents of your widget.
59 *
60 * @note When overriding this method, please let your widget draw
61 * itself at the top/left corner of the painter. You should call rect()
62 * (or width(), height(), resp.) to find the drawable area's size:
63 * While the paint() method is being executed the frame of the widget
64 * is outside of its rect(), so you can use all of rect() for
65 * your custom drawing!
66 * @sa paint, paintIntoRect
67 */
68 virtual void paint( QPainter* painter ) = 0;
69
70 /**
71 * Call paintAll, if you want the background and the frame to be drawn
72 * before the normal paint() is invoked automatically.
73 */
74 void paintAll( QPainter& painter );
75
76 /**
77 * Call this to trigger an unconditional re-building of the widget's internals.
78 */
79 virtual void forceRebuild();
80
81 /**
82 * Call this to trigger an conditional re-building of the widget's internals.
83 *
84 * e.g. AbstractAreaWidget call this, before calling layout()->setGeometry()
85 */
86 virtual void needSizeHint();
87 virtual void resizeLayout( const QSize& );
88
89Q_SIGNALS:
90 void positionChanged( KChart::AbstractAreaWidget * );
91
92protected:
93 ~AbstractAreaWidget() override;
94 QRect areaGeometry() const override;
95 void positionHasChanged() override;
96};
97
98}
99#endif // KCHARTABSTRACTAREAWIDGET_H
Base class for AbstractArea and AbstractAreaWidget: An area in the chart with a background,...
An area in the chart with a background, a frame, etc.
virtual void paint(QPainter *painter)=0
Overwrite this to paint the inner contents of your widget.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:24 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.