/***************************************************************************
 *   Copyright (C) 2003-2005 by liuspider                                  *
 *   liuspider@users.sourceforge.net                                       *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 **************************************************************************/
#ifndef SCIMDRAGABLEFRAME_H
#define SCIMDRAGABLEFRAME_H

#include <qframe.h>
#include <qapplication.h>
class ScimDragableFrame : public QFrame
{
    Q_OBJECT
public:
    ScimDragableFrame( QWidget *body, QWidget *parent, const char *name = 0, WFlags f = 0 );
    virtual void reTopParent(QWidget *body);
    virtual QWidget* getTopParent() {return bodyWidget;};
    virtual void setKeepVisible(bool v) {keepVisible = v;};
    virtual bool isKeepVisible() {return keepVisible;};
    virtual bool scheduleAdjustSize();
    virtual bool screenContainsRect(QRect & visiblerect);
    virtual bool isMouseButtonPressed();
public slots:
    virtual void adjustSize();
signals:
    void doubleClicked();
//     void clicked();

protected:
    void mousePressEvent( QMouseEvent *e );
    void mouseMoveEvent( QMouseEvent *e );
    void mouseReleaseEvent( QMouseEvent *e );
    void mouseDoubleClickEvent( QMouseEvent *e );

    QRect screen;
    QPoint offset;
    uint keepVisible : 1;
    QWidget *bodyWidget;

private:
    uint hadDblClick    : 1;
    class QTimer * timer;
//     uint ctrlDown : 1;
};

#endif
