Eneboo - Documentación para desarrolladores
|
00001 /********************************************************************** 00002 ** Copyright (C) 2005-2007 Trolltech ASA. All rights reserved. 00003 ** 00004 ** This file is part of Qt Designer. 00005 ** 00006 ** This file may be distributed and/or modified under the terms of the 00007 ** GNU General Public License version 2 as published by the Free Software 00008 ** Foundation and appearing in the file LICENSE.GPL included in the 00009 ** packaging of this file. 00010 ** 00011 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 00012 ** licenses may use this file in accordance with the Qt Commercial License 00013 ** Agreement provided with the Software. 00014 ** 00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00017 ** 00018 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00019 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00020 ** information about Qt Commercial License Agreements. 00021 ** 00022 ** Contact info@trolltech.com if any conditions of this licensing are 00023 ** not clear to you. 00024 ** 00025 **********************************************************************/ 00026 00027 #ifndef SIZEHANDLE_H 00028 #define SIZEHANDLE_H 00029 00030 #include <qwidget.h> 00031 #include <qintdict.h> 00032 #include <qptrdict.h> 00033 00034 class QMouseEvent; 00035 class FormWindow; 00036 class WidgetSelection; 00037 class QPaintEvent; 00038 00039 class SizeHandle : public QWidget 00040 { 00041 Q_OBJECT 00042 00043 public: 00044 enum Direction { LeftTop, Top, RightTop, Right, RightBottom, Bottom, LeftBottom, Left }; 00045 00046 SizeHandle( FormWindow *parent, Direction d, WidgetSelection *s ); 00047 void setWidget( QWidget *w ); 00048 void setActive( bool a ); 00049 void updateCursor(); 00050 00051 void setEnabled( bool ) {} 00052 00053 protected: 00054 void paintEvent( QPaintEvent *e ); 00055 void mousePressEvent( QMouseEvent *e ); 00056 void mouseMoveEvent( QMouseEvent *e ); 00057 void mouseReleaseEvent( QMouseEvent *e ); 00058 00059 private: 00060 void trySetGeometry( QWidget *w, int x, int y, int width, int height ); 00061 void tryResize( QWidget *w, int width, int height ); 00062 00063 private: 00064 QWidget *widget; 00065 Direction dir; 00066 QPoint oldPressPos; 00067 FormWindow *formWindow; 00068 WidgetSelection *sel; 00069 QRect geom, origGeom; 00070 bool active; 00071 00072 }; 00073 00074 class WidgetSelection 00075 { 00076 public: 00077 WidgetSelection( FormWindow *parent, QPtrDict<WidgetSelection> *selDict ); 00078 00079 void setWidget( QWidget *w, bool updateDict = TRUE ); 00080 bool isUsed() const; 00081 00082 void updateGeometry(); 00083 void hide(); 00084 void show(); 00085 void update(); 00086 00087 QWidget *widget() const; 00088 00089 protected: 00090 QIntDict<SizeHandle> handles; 00091 QWidget *wid; 00092 FormWindow *formWindow; 00093 QPtrDict<WidgetSelection> *selectionDict; 00094 00095 }; 00096 00097 #endif