source: trunk/src/widgets/qwidgetresizehandler_p.h

Last change on this file was 2, checked in by dmik, 20 years ago

Imported xplatform parts of the official release 3.3.1 from Trolltech

  • Property svn:keywords set to Id
File size: 3.8 KB
Line 
1/****************************************************************************
2** $Id: qwidgetresizehandler_p.h 2 2005-11-16 15:49:26Z dmik $
3**
4** Definition of the QWidgetResizeHandler class
5**
6** Created : 001010
7**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9**
10** This file is part of the workspace module of the Qt GUI Toolkit.
11**
12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file.
15**
16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition licenses may use this
22** file in accordance with the Qt Commercial License Agreement provided
23** with the Software.
24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#ifndef QWIDGETRESIZEHANDLER_P_H
39#define QWIDGETRESIZEHANDLER_P_H
40
41//
42// W A R N I N G
43// -------------
44//
45// This file is not part of the Qt API. This header file may
46// change from version to version without notice, or even be
47// removed.
48//
49// We mean it.
50//
51//
52
53#ifndef QT_H
54#include "qobject.h"
55#endif // QT_H
56#ifndef QT_NO_RESIZEHANDLER
57class QMouseEvent;
58class QKeyEvent;
59
60class Q_EXPORT QWidgetResizeHandler : public QObject
61{
62 Q_OBJECT
63
64public:
65 enum Action {
66 Move = 0x01,
67 Resize = 0x02,
68 Any = Move|Resize
69 };
70
71 QWidgetResizeHandler( QWidget *parent, QWidget *cw = 0, const char *name = 0 );
72 void setActive( bool b ) { setActive( Any, b ); }
73 void setActive( Action ac, bool b );
74 bool isActive() const { return isActive( Any ); }
75 bool isActive( Action ac ) const;
76 void setMovingEnabled( bool b ) { moving = b; }
77 bool isMovingEnabled() const { return moving; }
78
79 bool isButtonDown() const { return buttonDown; }
80
81 void setExtraHeight( int h ) { extrahei = h; }
82 void setSizeProtection( bool b ) { sizeprotect = b; }
83
84 void doResize();
85 void doMove();
86
87signals:
88 void activate();
89
90protected:
91 bool eventFilter( QObject *o, QEvent *e );
92 void mouseMoveEvent( QMouseEvent *e );
93 void keyPressEvent( QKeyEvent *e );
94
95private:
96 enum MousePosition {
97 Nowhere,
98 TopLeft, BottomRight, BottomLeft, TopRight,
99 Top, Bottom, Left, Right,
100 Center
101 };
102
103 QWidget *widget;
104 QWidget *childWidget;
105 QPoint moveOffset;
106 QPoint invertedMoveOffset;
107 MousePosition mode;
108 int extrahei;
109 int range;
110 uint buttonDown :1;
111 uint moveResizeMode :1;
112 uint activeForResize :1;
113 uint sizeprotect :1;
114 uint moving :1;
115 uint activeForMove :1;
116
117 void setMouseCursor( MousePosition m );
118 bool isMove() const {
119 return moveResizeMode && mode == Center;
120 }
121 bool isResize() const {
122 return moveResizeMode && !isMove();
123 }
124
125private: // Disabled copy constructor and operator=
126#if defined(Q_DISABLE_COPY)
127 QWidgetResizeHandler( const QWidgetResizeHandler & );
128 QWidgetResizeHandler& operator=( const QWidgetResizeHandler & );
129#endif
130
131};
132
133#endif //QT_NO_RESIZEHANDLER
134#endif
Note: See TracBrowser for help on using the repository browser.