kexi

resizehandle.h
1/* This file is part of the KDE libraries
2 Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
3 Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KFE_RESIZEHANDLER_H
21#define KFE_RESIZEHANDLER_H
22
23#include <tqdict.h>
24#include <tqguardedptr.h>
25#include <tqwidget.h>
26
30
31namespace KFormDesigner
32{
33
34class Form;
35class ResizeHandleSet;
36
41class KFORMEDITOR_EXPORT ResizeHandle : public TQWidget
42{
43 TQ_OBJECT
44
45
46 public:
47 enum HandlePos { TopLeft = 0, TopCenter = 2, TopRight = 4, LeftCenter = 8, RightCenter = 16,
48 BottomLeft = 32, BottomCenter = 64, BottomRight = 128 };
49 ResizeHandle(ResizeHandleSet *set, HandlePos pos, bool editing=false);
50 virtual ~ResizeHandle();
51 void setEditingMode(bool editing);
52
53 protected:
54 virtual void mousePressEvent(TQMouseEvent *ev);
55 virtual void mouseMoveEvent(TQMouseEvent *ev);
56 virtual void mouseReleaseEvent(TQMouseEvent *ev);
57 virtual void paintEvent( TQPaintEvent *ev );
58
59 protected slots:
60 bool eventFilter(TQObject *obj, TQEvent *ev);
61 void updatePos();
62
63 private:
64 ResizeHandleSet *m_set;
65 HandlePos m_pos;
66 //TQWidget *m_buddy;
67 bool m_dragging;
68 //bool m_editing;
69 int m_x;
70 int m_y;
71};
72
77class KFORMEDITOR_EXPORT ResizeHandleSet: public TQObject
78{
79 TQ_OBJECT
80
81
82 public:
83 typedef TQDict<ResizeHandleSet> Dict;
84
85 ResizeHandleSet(TQWidget *modify, Form *form, bool editing = false);
86 ~ResizeHandleSet();
87
88 void setWidget(TQWidget *modify, bool editing = false);
89 TQWidget *widget() const { return m_widget; }
90 void raise();
91 void setEditingMode(bool editing);
92
93 private:
94 TQGuardedPtr<ResizeHandle> m_handles[8];
95 TQGuardedPtr<TQWidget> m_widget;
96 TQGuardedPtr<Form> m_form;
97 bool m_editing;
98
99 friend class ResizeHandle;
100};
101
102}
103
104#endif
A simple class representing a form.
Definition form.h:136
a set of resize handles (for resizing widgets)