formeditor/utils.h
1/* This file is part of the KDE project
2 Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
3 Copyright (C) 2007 Jaroslaw Staniek <js@iidea.pl>
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 as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef FORMEDITORUTILS_H
22#define FORMEDITORUTILS_H
23
24#include <tqptrlist.h>
25#include <tqtabbar.h>
26#include <tqtabwidget.h>
27
29#define TabWidgetBase TQTabWidget
30//#define USE_KTabWidget //todo: uncomment
31
32namespace KFormDesigner {
33
34class Form;
35
39template<class type>
40type* findParent(TQObject* o, const char* className, TQObject* &prevPrev)
41{
42 if (!o || !className || className[0]=='\0')
43 return 0;
44 TQObject *prev = o;
45 while ( ((o=o->parent())) && !o->inherits(className) ) {
46 prevPrev = prev;
47 prev = o;
48 }
49 return static_cast<type*>(o);
50}
51
53class KFORMEDITOR_EXPORT TabWidget : public TabWidgetBase
54{
55 TQ_OBJECT
56
57 public:
58 TabWidget(TQWidget *parent, const char *name)
59 : TabWidgetBase(parent, name) {}
60 virtual ~TabWidget() {}
61 int tabBarHeight() const { return tabBar()->height(); }
62};
63
65typedef TQPtrList<TQWidget> WidgetList;
66
68typedef TQPtrListIterator<TQWidget> WidgetListIterator;
69
72{
73 public:
75 virtual ~HorWidgetList();
76 protected:
77 virtual int compareItems(TQPtrCollection::Item item1, TQPtrCollection::Item item2);
78 TQWidget *m_topLevelWidget;
79};
80
83{
84 public:
86 virtual ~VerWidgetList();
87 protected:
88 virtual int compareItems(TQPtrCollection::Item item1, TQPtrCollection::Item item2);
89 TQWidget *m_topLevelWidget;
90};
91
94KFORMEDITOR_EXPORT void removeChildrenFromList(WidgetList &list);
95
99KFORMEDITOR_EXPORT void installRecursiveEventFilter(TQObject *object, TQObject *container);
100
104KFORMEDITOR_EXPORT void removeRecursiveEventFilter(TQObject *object, TQObject *container);
105
106KFORMEDITOR_EXPORT void setRecursiveCursor(TQWidget *w, Form *form);
107
109KFORMEDITOR_EXPORT TQSize getSizeFromChildren(TQWidget *widget, const char *inheritClass="TQWidget");
110
111}
112
113#endif
114
A simple class representing a form.
Definition form.h:136
A helper for sorting widgets horizontally.
A tab widget providing information about height of the tab bar.
A helper for sorting widgets vertically.
TQPtrList< TQWidget > WidgetList
A list of widget pointers.
KFORMEDITOR_EXPORT TQSize getSizeFromChildren(TQWidget *widget, const char *inheritClass="TQWidget")
TQPtrListIterator< TQWidget > WidgetListIterator
An iterator for WidgetList.
KFORMEDITOR_EXPORT void removeChildrenFromList(WidgetList &list)
KFORMEDITOR_EXPORT void installRecursiveEventFilter(TQObject *object, TQObject *container)
type * findParent(TQObject *o, const char *className, TQObject *&prevPrev)
KFORMEDITOR_EXPORT void removeRecursiveEventFilter(TQObject *object, TQObject *container)