#ifndef ToolTip_H
#define ToolTip_H

#include <functional>

#include "Array.h"
#include "Drawing.h"

namespace Framework
{
    class Font;       //! Font.h
    class Image;          //! Image.h
    class AlphaField;     //! AlphaField.h
    class Text;          //! Text.h
    class Border;        //! Border.h
    struct MouseEvent; //! MouseEvent.h
    class Screen;    //! Screen.h

#ifdef WIN32
#    pragma vtordisp(push, 2)
#endif
    class ToolTip : public DrawableBackground
    {
    private:
        RCArray<Drawable>* members;
        Point size;
        double animationSpeed;
        double warten;
        double wartenCount;
        double tval;
        bool mouseIn;
        unsigned char alpha;
        bool visible;
        bool zeichnen;
        bool mouseIn2;
        Screen* bildschirm;
        std::function<void(ToolTip*)> onShow;
        std::function<void(ToolTip*)> onHide;
        //! Processes mouse messages
        //! \param me The event triggered by the mouse input
        DLLEXPORT void doMouseEvent(MouseEvent& me, bool userRet) override;

    public:
        //! Constructor
        DLLEXPORT ToolTip(Screen* zSceen);
        //! Destructor
        DLLEXPORT ~ToolTip();
        //! Adds a drawing to the tooltip
        //! \param m The new drawing
        DLLEXPORT void addMember(Drawable* m);
        //! Removes a drawing from the tooltip
        //! \param m The drawing
        DLLEXPORT void removeMember(Drawable* zM);
        //! Removes a drawing from the tooltip
        //! \param i The index of the drawing
        DLLEXPORT void removeMember(int i);
        //! Sets a function that is called when the tooltip is shown
        //! \param onShow The function
        DLLEXPORT void setShowEvent(std::function<void(ToolTip*)> onShow);
        //! Sets a function that is called when the tooltip is no longer shown
        //! \param onShow The function
        DLLEXPORT void setHideEvent(std::function<void(ToolTip*)> onHide);
        //! Sets the number of seconds to wait before the tip appears
        //! \param warten The number of seconds
        DLLEXPORT void setWarten(double warten);
        //! Sets how fast the tip appears
        //! \param speed Number of pixels faded in per second. (Default: 250)
        DLLEXPORT void setAnimationSpeed(double speed);
        //! Sets whether the mouse is inside the drawing the tip belongs to
        //! \param mouseIn 1 if the mouse is inside the drawing. 0 otherwise
        DLLEXPORT void setMouseIn(bool mouseIn);
        //! Resets the counter that tracks when the tip should appear
        DLLEXPORT void waitReset();
        //! Indicates that the drawing the tip belongs to was drawn,
        //! so the tip could also be drawn
        DLLEXPORT void setDrawing();
        //! Updates the tip. 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 tickVal) override;
        //! Draws the tip to zRObj if it is visible and the associated
        //! drawing was also drawn \param zRObj The image to draw into
        DLLEXPORT void render(Image& zRObj) override;
        //! Returns a pointer to the screen without increased reference counter
        //! that this tooltip belongs to
        DLLEXPORT Screen* zScreen() const;
        //! Returns a specific member (without increased reference counter)
        //! \param i The index of the member
        DLLEXPORT Drawable* zMember(int i) const;
        //! Returns a specific member
        //! \param i The index of the member
        DLLEXPORT Drawable* getMember(int i) const;
        //! Returns the number of drawings belonging to the tooltip
        DLLEXPORT int getMemberCount() const;
        //! Creates a complete copy of a tooltip
        DLLEXPORT Drawable* duplicate() const override;
        //! Checks whether the tooltip is currently visible
        DLLEXPORT bool isVisible() const;
    };
#ifdef WIN32
#    pragma vtordisp(pop)
#endif
} // namespace Framework

#endif