#ifndef QVIDEOPANELLABEL_H
#define QVIDEOPANELLABEL_H

#include <QLabel>
#include <Windows.h>

#include "nss_toolkit.h"

#define TEXT_COUNT (3)
#define MASK_COUNT (4)

class QVideoPanelLabel : public QLabel
{
    Q_OBJECT

    struct VideoDrawRectParams
    {
        bool draw_rect_now;
        QPoint draw_rect_start_pos;
    };

    struct DrawTextInfo {
        RECT scale_rc;
        RECT sub_rc;
        bool draw;
        QPoint begin_pos;
        QString text;
        DrawTextInfo() {
            draw = false;
        }
    };
public:
    class VideoPanelDelegate {
    public:
        virtual ~VideoPanelDelegate() {}

        virtual void OnVideoPanelMousePress(QVideoPanelLabel* panel_label) = 0;
        virtual void OnVideoPanelDblClick(QVideoPanelLabel* panel_label) = 0;
    };

    QVideoPanelLabel(QWidget *parent,const NsstChannel& nsst_channel);
    ~QVideoPanelLabel();

    void SetDelegate(VideoPanelDelegate* delegate) {delegate_ = delegate;}

    void ResetDeviceId(DEVICE_ID id);

    void StartDrawText(int index,POINT* start,const QString& text);

    void StopDrawText(int index);

    int GetActiveText(const QPoint& pos);

    bool GetTextPosition(int index,RECT* rc);

    void StartDrawAlarmGrid(QMouseEvent* ev);
    void ShowAlarmGrid();
    void StopDrawAlarmGrid();
    void SetAllAlarmGrid(int* area);
    void ClearDrawAlarmGrid();
protected:
    virtual void mousePressEvent(QMouseEvent *ev);
// 
    virtual void mouseMoveEvent(QMouseEvent *ev);

    virtual void mouseReleaseEvent(QMouseEvent *ev);

    virtual void mouseDoubleClickEvent(QMouseEvent *);

private:
    VideoPanelDelegate*  delegate_;

    VideoDrawRectParams draw_rect_params_;

    bool can_draw_grid_;
    QPoint draw_grid_start_pos_;

    NsstChannel nsst_channel_;

    DrawTextInfo  text_info_[TEXT_COUNT];
    int text_active_index_;
};

#endif // QVIDEOPANELLABEL_H
