// -*- C++ -*-
#ifndef _Resizer_h_
#define _Resizer_h_

#include <GG/Control.h>

class Dialog;
class Resizer : public GG::Control
{
public:
    using GG::Wnd::SizeMove;

    typedef GG::Wnd* WndPtr;

    Resizer(WndPtr wnd, const Dialog* dialog);
    ~Resizer();

    WndPtr GetWnd();

    virtual void Render();
    virtual void LDrag(const GG::Pt& pt, const GG::Pt& move, Uint32 keys);
    virtual void LButtonDown(const GG::Pt& pt, Uint32 keys);
    virtual void LButtonUp(const GG::Pt& pt, Uint32 keys);
    virtual void LClick(const GG::Pt& pt, Uint32 keys);
    virtual void SizeMove(const GG::Pt& ul, const GG::Pt& lr);

    mutable boost::signal<void (Resizer*)> ReselectedSignal;
    mutable boost::signal<void (Resizer*)> DeselectedSignal;
    mutable boost::signal<void (const std::string&)> DraggedOrResizedSignal;

    static std::set<Resizer*> s_all_resizers;
    static const int RESIZE_SQUARE_WIDTH = 6;

private:
    enum Handle {
        HANDLE_NONE,
        HANDLE_CLIENT_WND,
        HANDLE_UL,
        HANDLE_TOP,
        HANDLE_UR,
        HANDLE_LEFT,
        HANDLE_RIGHT,
        HANDLE_LL,
        HANDLE_BOTTOM,
        HANDLE_LR
    };

    GG::Pt WndUpperLeft() const;
    GG::Pt WndLowerRight() const;
    GG::Rect HandleRect(Handle handle);
    bool OnlyActiveResizer();

    WndPtr m_wnd;
    Handle m_handle_being_dragged;
    GG::Pt m_drag_offset;
    bool m_dragged;
    GG::Pt m_original_ul;
    GG::Pt m_original_size;

    static bool s_dragging_other_resizers;
};

#endif // _Resizer_h_
