#ifndef WDRAWINGBOARD_H
#define WDRAWINGBOARD_H

#include <math.h>
#include <QWidget>
#include <QToolBar>
#include <QAction>
#include <QSpinBox>
#include <QVBoxLayout>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsTextItem>
#include <QKeyEvent>
#include <QFileInfo>
#include <QFileDialog>
#include <QStandardPaths>
#include <QTimer>
#include "LoQClass/loqgraphicsview.h"
class eObject;
class wPageItem;
class wDrawingBoard : public QWidget
{
    Q_OBJECT
    Q_PROPERTY(int m_scale READ scale WRITE setScale NOTIFY scaleChanged)

public:
    explicit wDrawingBoard(const QSizeF &res, QWidget *parent = nullptr);
    virtual void keyReleaseEvent(QKeyEvent *event) override;
    virtual void wheelEvent(QWheelEvent*event) override;
//    virtual void mouseMoveEvent(QMouseEvent *e) override;

public:
    int scale() { return m_scale; }
    void setScale(int s) { m_scale = s; emit scaleChanged(s); }
    void setScene(QGraphicsScene *scene) { m_wView->setScene(scene); }
    QList<eObject*> getElementList();
    QList<eObject*> getElementSelectedList();
    eObject* getElementSelected();
    void refreshOrder();
    void setElementGeometry(eObject *element, const QRectF &r);
    void setRes(const QSizeF &s)  { m_resolution = s; }
    void setRes(qreal w, qreal h) { setRes(QSizeF(w, h)); }

signals:
    void scaleChanged(int);
    void sigElementSelected(eObject *element);

public slots:
    void onCreatElement(int type);
    void onScaleUp();
    void onScaleDown();
    void onScaleOrg();
    void onDelete();
    void onClean();
    void onCut();
    void onLayerUp();
    void onLayerDown();
    void onSelectionLeft();
    void onSelectionRight();
    void onSelectionTop();
    void onSelectionBottom();
    void onLayerTop();
    void onLayerBottom();
    void onTileFull();
    void onTileH();
    void onTileV();
    void onArrayBottom();
    void onArrayHCenter();
    void onArrayTop();
    void onArrayRight();
    void onArrayVCenter();
    void onArrayLeft();
    void OnCropImage(QRect rt);
    void OnCiTieProcess(bool b,int iTuoZhuaiDir);
public slots:
    void adjustTrans();
    void onSlotPageSelected(wPageItem *page);
    void onSelectionChanged();

private:
    wPageItem     *m_page;
    QGraphicsView *m_wView;
    int           m_scale;
    QSizeF        m_resolution;
    QSizeF        m_iScreen;
    int m_xOffset=0;
    int m_yOffset=0;
    int m_keyPressId=-1;

};

#endif // WDRAWINGBOARD_H
