00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef QWIDGETRESIZEHANDLER_P_H
00039 #define QWIDGETRESIZEHANDLER_P_H
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #ifndef QT_H
00054 #include "qobject.h"
00055 #endif // QT_H
00056 #ifndef QT_NO_RESIZEHANDLER
00057 class QMouseEvent;
00058 class QKeyEvent;
00059
00060 class Q_EXPORT QWidgetResizeHandler : public QObject
00061 {
00062 Q_OBJECT
00063
00064 public:
00065 QWidgetResizeHandler( QWidget *parent, QWidget *cw = 0, const char *name = 0 );
00066 void setActive( bool b ) { active = b; if ( !active ) setMouseCursor( Nowhere ); }
00067 bool isActive() const { return active; }
00068 void setMovingEnabled( bool b ) { moving = b; }
00069 bool isMovingEnabled() const { return moving; }
00070
00071 bool isButtonDown() const { return buttonDown; }
00072
00073 void setExtraHeight( int h ) { extrahei = h; }
00074 void setSizeProtection( bool b ) { sizeprotect = b; }
00075
00076 void doResize();
00077 void doMove();
00078
00079 signals:
00080 void activate();
00081
00082 protected:
00083 bool eventFilter( QObject *o, QEvent *e );
00084 void mouseMoveEvent( QMouseEvent *e );
00085 void keyPressEvent( QKeyEvent *e );
00086
00087 private:
00088 enum MousePosition {
00089 Nowhere,
00090 TopLeft, BottomRight, BottomLeft, TopRight,
00091 Top, Bottom, Left, Right,
00092 Center
00093 };
00094
00095 QWidget *widget;
00096 QWidget *childWidget;
00097 QPoint moveOffset;
00098 QPoint invertedMoveOffset;
00099 MousePosition mode;
00100 int extrahei;
00101 int range;
00102 uint buttonDown :1;
00103 uint moveResizeMode :1;
00104 uint active :1;
00105 uint sizeprotect :1;
00106 uint moving :1;
00107
00108 void setMouseCursor( MousePosition m );
00109 bool isMove() const {
00110 return moveResizeMode && mode == Center;
00111 }
00112 bool isResize() const {
00113 return moveResizeMode && !isMove();
00114 }
00115
00116 private:
00117 #if defined(Q_DISABLE_COPY)
00118 QWidgetResizeHandler( const QWidgetResizeHandler & );
00119 QWidgetResizeHandler& operator=( const QWidgetResizeHandler & );
00120 #endif
00121
00122 };
00123
00124 #endif //QT_NO_RESIZEHANDLER
00125 #endif