1 /************************************************************************** 2 ** 3 ** This file is part of Qt Creator 4 ** 5 ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 6 ** 7 ** Contact: Qt Software Information (qt-info@nokia.com) 8 ** 9 ** Commercial Usage 10 ** 11 ** Licensees holding valid Qt Commercial licenses may use this file in 12 ** accordance with the Qt Commercial License Agreement provided with the 13 ** Software or, alternatively, in accordance with the terms contained in 14 ** a written agreement between you and Nokia. 15 ** 16 ** GNU Lesser General Public License Usage 17 ** 18 ** Alternatively, this file may be used under the terms of the GNU Lesser 19 ** General Public License version 2.1 as published by the Free Software 20 ** Foundation and appearing in the file LICENSE.LGPL included in the 21 ** packaging of this file. Please review the following information to 22 ** ensure the GNU Lesser General Public License version 2.1 requirements 23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 ** 25 ** If you are unsure which license is appropriate for your use, please 26 ** contact the sales department at qt-sales@nokia.com. 27 ** 28 **************************************************************************/ 29 #ifndef SIZEHANDLERECT_H 30 #define SIZEHANDLERECT_H 31 32 #include "namespace_global.h" 33 34 #include "widgethostconstants.h" 35 36 #include <QWidget> 37 #include <QPoint> 38 39 namespace SharedTools { 40 namespace Internal { 41 42 class SizeHandleRect : public QWidget 43 { 44 Q_OBJECT 45 public: 46 enum Direction { LeftTop, Top, RightTop, Right, RightBottom, Bottom, LeftBottom, Left }; 47 48 SizeHandleRect(QWidget *parent, Direction d, QWidget *resizable); 49 dir()50 Direction dir() const { return m_dir; } 51 void updateCursor(); 52 void setState(SelectionHandleState st); 53 54 signals: 55 56 void mouseButtonReleased(const QRect &, const QRect &); 57 58 protected: 59 void paintEvent(QPaintEvent *e); 60 void mousePressEvent(QMouseEvent *e); 61 void mouseMoveEvent(QMouseEvent *e); 62 void mouseReleaseEvent(QMouseEvent *e); 63 64 private: 65 void tryResize(const QSize &delta); 66 67 private: 68 const Direction m_dir; 69 QPoint m_startPos; 70 QPoint m_curPos; 71 QSize m_startSize; 72 QSize m_curSize; 73 QWidget *m_resizable; 74 SelectionHandleState m_state; 75 }; 76 77 } 78 } // namespace SharedTools 79 80 81 #endif // SIZEHANDLERECT_H 82 83