#include <qwidget.h>
#include <qtimer.h>
class QPopupMenu;
class v4lxif;
class PicturePropDialog;
class AviCapDialog;
class ClosedCaption;
class QLabel;
class V4LWindow: public QWidget
{
friend class AviCapDialog;
    Q_OBJECT
protected:    
    v4lxif* m_pDev;
private:    
    QPopupMenu* m_pPopup;
    PicturePropDialog* m_pPicConfig;
    AviCapDialog* m_pCapDialog;
    ClosedCaption* m_pCC;
    bool m_bForce4x3;
    bool m_bSubtitles;
    bool known_pos;
    bool m_bAutoRecord;
    QTimer m_timer;
    QTimer m_cctimer;
    QLabel* m_pLabel;
public:
    V4LWindow(v4lxif * pDev, QWidget * pParent=0);
    void setupDevice();
    void setAutoRecord() { m_bAutoRecord = true; }
    void unregisterCapDialog() { m_pCapDialog = 0; }
protected:
    virtual void moveEvent( QMoveEvent * );
    virtual void showEvent( QShowEvent * );
    virtual void hideEvent( QHideEvent * );
    virtual void focusInEvent( QFocusEvent * );
    virtual void focusOutEvent( QFocusEvent * );
    virtual void enterEvent( QEvent * );
    virtual void leaveEvent( QEvent * );    
    virtual void resizeEvent( QResizeEvent * );
    virtual void mouseReleaseEvent( QMouseEvent * );
    virtual void keyPressEvent( QKeyEvent * );
    virtual bool x11Event( XEvent * );    
public slots:
    void config();
    void hidePopup();
    void force4x3();
    void captureAVI();
    void captureBMP();
    void captureJPG();
    void picprop();
    void timerStop();
    void showsub();
    void updatesub();
public:
    void get_clips();
    ClosedCaption* getcc() { return m_pCC; }
protected: // x11 stuff for handling overlay clipping
    void add_clip(int x1, int y1, int x2, int y2);

    int wmap;    
    /*
	case MapNotify:
	    wmap=1;
	case UnmapNotify:
	    wmap=0;
*/
    int  visibility;
/*
	case VisibilityNotify:
	    if (event->xvisibility.window == WINDOW(video)) {
		visibility = event->xvisibility.state;
*/

    int oc_count;
    int conf;
    struct OVERLAY_CLIP
    {
	int x1, y1, x2, y2;
    };
    OVERLAY_CLIP   oc[32];
protected:
    void setupPicDimensions(int* =0, int* =0);
};