#ifndef GRIFODISPLAYWIDGET_H
#define GRIFODISPLAYWIDGET_H

#include <QFrame>

//#include <QMouseEvent>

//namespace Ui {
//class GrifoDisplayWidget;
//}
//class RdrGraphicsScene;

class GrifoDisplayWidget : public QFrame
{
    Q_OBJECT

    Q_PROPERTY(int offsetX READ offsetX WRITE setOffsetX)
    Q_PROPERTY(int offsetY READ offsetY WRITE setOffsetY)

public:
    enum DbgCrsFlag {
        DbgCrsFlagNone=0,
        DbgCrsFlagShowReferencePoint=2,
        DbgCrsFlagShowNearestSymInfo=4,
        DbgCrsFlagShowLockOnDes=8,
        DbgCrsFlagMiniZoom=16
    };
    Q_DECLARE_FLAGS(DbgCrsFlags, DbgCrsFlag)

    enum DbgSymFlag {
        DbgSymFlagEna=1,
        DbgSymFlagGrpEnable=2,
        DbgSymFlagEnaGeneric=4,
        DbgSymFlagEnaCritical=8,

        DbgSymFlagAntennaCaret=32,
        DbgSymFlagAntennaPath=128,
        DbgSymTgtAltitude=256,
        DbgSymHideAllSynth=1024,
        DbgSymShowModeInfo=2048
    };
    Q_DECLARE_FLAGS(DbgSymFlags, DbgSymFlag)

    explicit GrifoDisplayWidget(QWidget *parent = 0);
    ~GrifoDisplayWidget();

    void* videoMemory() const;

    int offsetX() const;
    int offsetY() const;

    void setIconFreeze(const QIcon&);
    void setIconOcclusion(const QIcon&);
    void setIconDbgMenu(const QIcon&);

public slots:
    void setOffsetX(int x);
    void setOffsetY(int y);

    void updateImage(const void*, unsigned int dx, unsigned dy, unsigned int pitch);
    void updatePalette(const uint32_t* p);

    void updateDisplay(bool updateSceneAlso=true);
    void updateScene();

    void showShortMessage(const QString& str);

    void _onActionSymDbg(bool checked);

signals:
    void freezeChanged(bool frozen);

    void dbgCrsFlagsChanged(DbgCrsFlags);
    void dbgSymFlagsChanged(DbgSymFlags);

    void rdrCursorSlew(bool active, int x, int y);

    void dbgCursorSlew(bool active, int x, int y);

    void antennaSlew(bool active, float daz, float del);

    //void rdrCursorEvent(Qt::MouseButtons, Qt::KeyboardModifiers, int x, int y);
    void rdrCursorEvent(int x, int y, unsigned int flags);

private:
    //Ui::GrifoDisplayWidget *ui;

    class Implementation;
    Implementation& p_;
};

Q_DECLARE_OPERATORS_FOR_FLAGS(GrifoDisplayWidget::DbgCrsFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(GrifoDisplayWidget::DbgSymFlags)

#endif // GRIFODISPLAYWIDGET_H
