#pragma once

#include "Drawing.h"

namespace Framework
{
    class Model2D;       //! Model2D.h
    class Model2DData;   //! Model2D.h
    class Border;        //! Border.h
    class AlphaField;     //! AlphaField.h
    struct MouseEvent; //! MouseEvent.h

    //! A 2D GUI framework drawing that displays a 2D model
    class M2DPreview : public DrawableBackground
    {
    public:
        class Style : public DrawableBackground::Style
        {
        public:
            //! If this style is set, the user can scale the model
            //! by scrolling
            static const __int64 UsrScale = 0x001000;
            //! If this style is set, the user can move the model
            //! via drag and drop
            static const __int64 UsrMove = 0x002000;
            //! If this style is set, the user can rotate the model
            //! with the right mouse button
            static const __int64 UsrRot = 0x004000;
        };

    private:
        Model2D* mdl;
        Border* ram;
        AlphaField* af;
        int bgF;
        int mx;
        int my;
        //! Processes mouse messages
        //! \param me The event triggered by the mouse input
        DLLEXPORT void doMouseEvent(MouseEvent& me, bool userRet) override;

    public:
        //! Constructor
        DLLEXPORT M2DPreview();
        //! Destructor
        DLLEXPORT virtual ~M2DPreview();
        //! Sets a pointer to the model to display
        //! \param mdl The model
        DLLEXPORT void setModel2DZ(Model2D* mdl);
        //! Sets the data of the model to display
        //! \param mdl The data
        DLLEXPORT void setModel2D(Model2DData* mdl);
        //! Updates the object. Called by the framework
        //! \param tickVal The time in seconds since the last call
        //! of this function \return 1 if something changed
        //! and the image needs to be redrawn. 0 otherwise
        DLLEXPORT bool tick(double tv) override;
        //! Draws the object to zRObj if it is visible
        //! \param zRObj The image to draw into
        DLLEXPORT void render(Image& rb) override;
        //! Returns the displayed model without increased reference counter
        DLLEXPORT Model2D* zModel() const;
        //! Returns the displayed model
        DLLEXPORT Model2D* getModel() const;
        //! Creates a copy of the drawing that can be used without affecting the
        //! original
        DLLEXPORT Drawable* duplicate() const override;
    };
} // namespace Framework