| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause |
| 3 |
|
| 4 |
#ifndef RENDERAREA_H |
| 5 |
#define RENDERAREA_H |
| 6 |
|
| 7 |
#include <QBrush> |
| 8 |
#include <QPen> |
| 9 |
#include <QPixmap> |
| 10 |
#include <QWidget> |
| 11 |
|
| 12 |
//! [0] |
| 13 |
class RenderArea : public QWidget |
| 14 |
{ |
| 15 |
Q_OBJECT |
| 16 |
|
| 17 |
public: |
| 18 |
enum Shape { Line, Points, Polyline, Polygon, Rect, RoundedRect, Ellipse, Arc, |
| 19 |
Chord, Pie, Path, Text, Pixmap }; |
| 20 |
|
| 21 |
explicit RenderArea(QWidget *parent = nullptr); |
| 22 |
|
| 23 |
QSize minimumSizeHint() const override; |
| 24 |
QSize sizeHint() const override; |
| 25 |
|
| 26 |
public slots: |
| 27 |
void setShape(Shape shape); |
| 28 |
void setPen(const QPen &pen); |
| 29 |
void setBrush(const QBrush &brush); |
| 30 |
void setAntialiased(bool antialiased); |
| 31 |
void setTransformed(bool transformed); |
| 32 |
|
| 33 |
protected: |
| 34 |
void paintEvent(QPaintEvent *event) override; |
| 35 |
|
| 36 |
private: |
| 37 |
Shape shape; |
| 38 |
QPen pen; |
| 39 |
QBrush brush; |
| 40 |
bool antialiased; |
| 41 |
bool transformed; |
| 42 |
QPixmap pixmap; |
| 43 |
}; |
| 44 |
//! [0] |
| 45 |
|
| 46 |
#endif // RENDERAREA_H |