kexi

resizehandle.h

00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
00003    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License version 2 as published by the Free Software Foundation.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef KFE_RESIZEHANDLER_H
00021 #define KFE_RESIZEHANDLER_H
00022 
00023 #include <qdict.h>
00024 #include <qguardedptr.h>
00025 #include <qwidget.h>
00026 
00031 namespace KFormDesigner
00032 {
00033 
00034 class Form;
00035 class ResizeHandleSet;
00036 
00041 class KFORMEDITOR_EXPORT ResizeHandle : public QWidget
00042 {
00043     Q_OBJECT
00044 
00045     public:
00046         enum HandlePos { TopLeft = 0, TopCenter = 2, TopRight = 4, LeftCenter = 8, RightCenter = 16,
00047             BottomLeft = 32, BottomCenter = 64, BottomRight = 128 };
00048         ResizeHandle(ResizeHandleSet *set, HandlePos pos, bool editing=false);
00049         virtual ~ResizeHandle();
00050         void setEditingMode(bool editing);
00051 
00052     protected:
00053         virtual void mousePressEvent(QMouseEvent *ev);
00054         virtual void mouseMoveEvent(QMouseEvent *ev);
00055         virtual void mouseReleaseEvent(QMouseEvent *ev);
00056         virtual void paintEvent( QPaintEvent *ev );
00057 
00058     protected slots:
00059         bool eventFilter(QObject *obj, QEvent *ev);
00060         void updatePos();
00061 
00062     private:
00063         ResizeHandleSet *m_set;
00064         HandlePos m_pos;
00065         //QWidget *m_buddy;
00066         bool m_dragging;
00067         //bool m_editing;
00068         int m_x;
00069         int m_y;
00070 };
00071 
00076 class KFORMEDITOR_EXPORT ResizeHandleSet: public QObject
00077 {
00078     Q_OBJECT
00079 
00080     public:
00081         typedef QDict<ResizeHandleSet> Dict;
00082 
00083         ResizeHandleSet(QWidget *modify, Form *form, bool editing = false);
00084         ~ResizeHandleSet();
00085 
00086         void setWidget(QWidget *modify, bool editing = false);
00087         QWidget *widget() const { return m_widget; }
00088         void raise();
00089         void setEditingMode(bool editing);
00090 
00091     private:
00092         QGuardedPtr<ResizeHandle> m_handles[8];
00093         QGuardedPtr<QWidget> m_widget;
00094         QGuardedPtr<Form>   m_form;
00095         bool  m_editing;
00096 
00097     friend class ResizeHandle;
00098 };
00099 
00100 }
00101 
00102 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys