57 lines
1.1 KiB
C++
57 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <QFrame>
|
|
#include <QLabel>
|
|
#include <QPixmap>
|
|
#include <QTimer>
|
|
#include <QWidget>
|
|
#include <functional>
|
|
|
|
namespace Dpi {
|
|
|
|
class Canvas;
|
|
|
|
// TTimer equivalent: QTimer already matches the VCL API closely.
|
|
using Timer = QTimer;
|
|
|
|
// TPanel equivalent.
|
|
class Panel : public QFrame {
|
|
Q_OBJECT
|
|
public:
|
|
explicit Panel(QWidget *parent = nullptr);
|
|
};
|
|
|
|
// TPaintBox equivalent: a plain widget exposing an OnPaint callback bound to
|
|
// a Dpi::Canvas, since custom drawing in Qt happens through QPainter in
|
|
// paintEvent rather than through a persistent handle-based canvas.
|
|
class PaintBox : public QWidget {
|
|
Q_OBJECT
|
|
public:
|
|
explicit PaintBox(QWidget *parent = nullptr);
|
|
|
|
std::function<void(Canvas &)> onPaint;
|
|
|
|
protected:
|
|
void paintEvent(QPaintEvent *event) override;
|
|
};
|
|
|
|
// TImage equivalent.
|
|
class Image : public QLabel {
|
|
Q_OBJECT
|
|
public:
|
|
explicit Image(QWidget *parent = nullptr);
|
|
|
|
bool stretch() const { return m_stretch; }
|
|
void setStretch(bool value);
|
|
|
|
void setPicture(const QPixmap &pixmap);
|
|
|
|
private:
|
|
void updatePixmap();
|
|
|
|
bool m_stretch = false;
|
|
QPixmap m_source;
|
|
};
|
|
|
|
} // namespace Dpi
|