formIO.h
1/* This file is part of the KDE project
2 Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
3 Copyright (C) 2005-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 FORMIO_H
22#define FORMIO_H
23
24#include <tqobject.h>
25#include <tqdict.h>
26#include <tqstring.h>
27#include <tqwidget.h>
28#include <tqmap.h>
29
30class TQString;
31class TQDomElement;
32class TQDomNode;
33class TQDomDocument;
34class TQDomText;
35class TQVariant;
36class TQLabel;
37
39class KFORMEDITOR_EXPORT CustomWidget : public TQWidget
40{
41 TQ_OBJECT
42
43
44 public:
45 CustomWidget(const TQCString &className, TQWidget *parent, const char *name);
46 virtual ~CustomWidget();
47
48 virtual void paintEvent(TQPaintEvent *ev);
49
50 private:
51 TQCString m_className;
52};
53
54namespace KFormDesigner {
55
56class WidgetPropertySet;
57class Form;
58class ObjectTreeItem;
59class Container;
60class WidgetLibrary;
61
64#define KFORMDESIGNER_VERSION 2
65
67KFORMEDITOR_EXPORT uint version();
68
75class KFORMEDITOR_EXPORT FormIO : public TQObject
76{
77 TQ_OBJECT
78
79
80 public:
81 FormIO();
82 ~FormIO();
83
87 static bool saveFormToDom(Form *form, TQDomDocument &domDoc);
88
94 static bool saveFormToFile(Form *form, const TQString &filename=TQString());
95
100 static bool saveFormToString(Form *form, TQString &dest, int indent = 0);
101
106 static bool saveFormToByteArray(Form *form, TQByteArray &dest);
107
110 static bool loadFormFromDom(Form *form, TQWidget *container, TQDomDocument &domDoc);
111
116 static bool loadFormFromByteArray(Form *form, TQWidget *container, TQByteArray &src,
117 bool preview=false);
118
119 static bool loadFormFromString(Form *form, TQWidget *container, TQString &src, bool preview=false);
120
127 static bool loadFormFromFile(Form *form, TQWidget *container, const TQString &filename=TQString());
128
136 static void saveWidget(ObjectTreeItem *item, TQDomElement &parent, TQDomDocument &domDoc,
137 bool insideGridLayout=false);
138
142 static void cleanClipboard(TQDomElement &uiElement);
143
149 static void loadWidget(Container *container,
150 const TQDomElement &el, TQWidget *parent=0);
151
157 static void savePropertyElement(TQDomElement &parentNode, TQDomDocument &domDoc, const TQString &tagName,
158 const TQString &property, const TQVariant &value);
159
165 static TQVariant readPropertyValue(TQDomNode node, TQObject *obj, const TQString &name);
166
177 static void savePropertyValue(TQDomElement &parentNode, TQDomDocument &parent, const char *name,
178 const TQVariant &value, TQWidget *w, WidgetLibrary *lib=0);
179
180 protected:
182 static void writeVariant(TQDomDocument &parent, TQDomElement &parentNode, TQVariant value);
183
188 static void createToplevelWidget(Form *form, TQWidget *container, TQDomElement &element);
189
195 static TQString saveImage(TQDomDocument &domDoc, const TQPixmap &pixmap);
196
201 static TQPixmap loadImage(TQDomDocument domDoc, const TQString& name);
202
204 static void readChildNodes(ObjectTreeItem *tree, Container *container,
205 const TQDomElement &el, TQWidget *w);
206
209 static void addIncludeFileName(const TQString &include, TQDomDocument &domDoc);
210
211 private:
212 // This dict stores buddies associations until the Form is completely loaded.
213 static TQDict<TQLabel> *m_buddies;
214
216 //static TQWidgdet *m_currentWidget;
217 static ObjectTreeItem *m_currentItem;
218 static Form *m_currentForm;
219 static bool m_savePixmapsInline;
220};
221
222}
223
224#endif
A blank widget displayed when class is not supported.
Definition formIO.h:40