#pragma once #include "Dpi/DpiGraphics.h" #include #include namespace Cevo { // TButtonBase equivalent: a lightweight, sprite-painted push button with // manual mouse tracking (no native QAbstractButton state machine), matching // the original TGraphicControl-based design and its Down/Permanent model. class ButtonBase : public QWidget { Q_OBJECT public: explicit ButtonBase(QWidget *parent = nullptr); bool down() const { return m_down; } void setDown(bool value); bool permanent() const { return m_permanent; } void setPermanent(bool value) { m_permanent = value; } Dpi::Bitmap *graphic() const { return m_graphic; } void setGraphic(Dpi::Bitmap *value) { m_graphic = value; } std::function onClick; std::function onDownChanged; protected: virtual void paint(Dpi::Canvas &canvas) { Q_UNUSED(canvas); } void mousePressEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; Dpi::Bitmap *m_graphic = nullptr; bool m_down = false; private: void paintEvent(QPaintEvent *event) override final; void trackMouse(const QPoint &pos, bool leftPressed); void setDownState(bool value); bool m_permanent = false; bool m_active = false; }; } // namespace Cevo