form.h
1/* This file is part of the KDE project
2 Copyright (C) 2003 Lucijan Busch <lucijan@gmx.at>
3 Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
4 Copyright (C) 2004-2007 Jaroslaw Staniek <js@iidea.pl>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20*/
21
22#ifndef KFORMDESIGNERFORM_H
23#define KFORMDESIGNERFORM_H
24
25#include <tqobject.h>
26#include <tqptrlist.h>
27
28#include "resizehandle.h"
29#include "utils.h"
30#include "objecttree.h"
31
32class TQWidget;
33class TQDomElement;
34class TDEActionCollection;
35class KCommandHistory;
36class KCommand;
38
39namespace KFormDesigner {
40
41class Container;
42class WidgetPropertySet;
43class WidgetLibrary;
44class FormManager;
45class ObjectTree;
46class ObjectTreeItem;
47class ConnectionBuffer;
48
50
53class KFORMEDITOR_EXPORT FormWidget
54{
55 public:
56 FormWidget();
57 virtual ~FormWidget();
58
63 virtual void drawRects(const TQValueList<TQRect> &list, int type) = 0;
64
65 virtual void drawRect(const TQRect &r, int type) = 0;
66
68 virtual void initBuffer() = 0;
69
71 virtual void clearForm() = 0;
72
75 virtual void highlightWidgets(TQWidget *from, TQWidget *to) = 0;
76
77 protected:
78 Form *m_form;
79
80 friend class Form;
81};
82
84class FormPrivate
85{
86 public:
87 FormPrivate();
88 ~FormPrivate();
89
90// FormManager *manager;
92 ObjectTree *topTree;
93 TQGuardedPtr<TQWidget> widget;
94
95 WidgetList selected;
96 ResizeHandleSet::Dict resizeHandles;
97
98 bool dirty;
99 bool interactive;
100 bool design;
101 TQString filename;
102
103 KCommandHistory *history;
104 TDEActionCollection *collection;
105
106 ObjectTreeList tabstops;
107 bool autoTabstops;
108 ConnectionBuffer *connBuffer;
109
110 PixmapCollection *pixcollection;
111
113 TQMap<TQObject*,TQCursor> cursors;
114
116 TQStringList *mouseTrackers;
117
118 FormWidget *formWidget;
119
122 TQMap<TQCString,TQString> headerProperties;
123
125 uint formatVersion;
127 uint originalFormatVersion;
128};
129
135class KFORMEDITOR_EXPORT Form : public TQObject
136{
137 TQ_OBJECT
138
139
140 public:
143 Form(WidgetLibrary* library, const char *name=0, bool designMode = true);
144 ~Form();
145
147 WidgetLibrary* library() const { return m_lib; }
148
156 void createToplevel(TQWidget *container, FormWidget *formWidget =0,
157 const TQCString &classname="TQWidget");
158
161 Container* toplevelContainer() const { return d->toplevel; }
162
164 FormWidget* formWidget() const { return d->formWidget; }
165
167 ObjectTree* objectTree() const { return d->topTree; }
168
170 TQWidget* widget() const;
171
172// //! \return the FormManager parent of this form.
173// FormManager* manager() const { return d->manager; }
174
178 Container* activeContainer();
179
184 Container* parentContainer(TQWidget *w=0);
185
189 ObjectTreeItem* commonParentContainer(WidgetList *wlist);
190
192 WidgetList* selectedWidgets() const {return &(d->selected);}
193
197 TQWidget* selectedWidget() const { return d->selected.count()==1 ? d->selected.first() : 0; }
198
201 void emitActionSignals(bool withUndoAction=true);
202
205 void emitSelectionSignals();
206
210 void setInteractiveMode(bool interactive) { d->interactive = interactive; }
211
218 bool interactiveMode() const { return d->interactive; }
219
223 void setDesignMode(bool design);
224
226 bool designMode() const { return d->design; }
227
228 bool isModified() { return d->dirty; }
229
232 int gridSize() { return 10; }
233
235 int defaultMargin() { return 11;}
236
238 int defaultSpacing() { return 6;}
239
241 void emitChildAdded(ObjectTreeItem *item);
242
244 void emitChildRemoved(ObjectTreeItem *item);
245
248 TQString filename() const { return d->filename; }
249
251 void setFilename(const TQString &file) { d->filename = file; }
252
253 KCommandHistory* commandHistory() const { return d->history; }
254 ConnectionBuffer* connectionBuffer() const { return d->connBuffer; }
255 PixmapCollection* pixmapCollection() const { return d->pixcollection; }
256
259 void addCommand(KCommand *command, bool execute);
260
262 void clearCommandHistory();
263
267 ObjectTreeList* tabStops() const { return &(d->tabstops); }
268
269 inline ObjectTreeListIterator tabStopsIterator() const { return ObjectTreeListIterator(d->tabstops); }
270
273 void updateTabStopsOrder();
274
276 void addWidgetToTabStops(ObjectTreeItem *it);
277
279 bool autoTabStops() const { return d->autoTabstops; }
280
286 void setAutoTabStops(bool autoTab) { d->autoTabstops = autoTab;}
287
293 void autoAssignTabStops();
294
295#ifdef KEXI_DEBUG_GUI
297 TQString m_recentlyLoadedUICode;
298#endif
299
303// void resizeHandleDraggingStarted(TQWidget *draggedWidget);
304
305 ResizeHandleSet* resizeHandlesForWidget(TQWidget* w);
306
309 TQMap<TQCString,TQString>* headerProperties() const { return &d->headerProperties; }
310
313 uint formatVersion() const;
314 void setFormatVersion(uint ver);
315
318 uint originalFormatVersion() const;
319 void setOriginalFormatVersion(uint ver);
320
321 public slots:
325 void changeName(const TQCString &oldname, const TQCString &newname);
326
333 void setSelectedWidget(TQWidget *selected, bool add=false, bool dontRaise=false,
334 bool moreWillBeSelected = false);
335
338 void unSelectWidget(TQWidget *w);
339
341 void selectFormWidget();
342
343 void clearSelection();
344
345 protected slots:
349 void formDeleted();
350
351 void emitUndoEnabled();
352 void emitRedoEnabled();
353
356 void slotCommandExecuted();
357
361 void slotFormRestored();
362
363 signals:
368 void selectionChanged(TQWidget *w, bool add, bool moreWillBeSelected = false);
369
374
379
382
383 protected:
384 void setConnectionBuffer(ConnectionBuffer *b) { d->connBuffer = b; }
385
386 void setFormWidget(FormWidget* w);
387 private:
388 WidgetLibrary *m_lib;
389 FormPrivate *d;
390
391 friend class FormManager;
392 friend class FormWidget;
393 friend class ConnectionDialog;
394};
395
396}
397
398#endif
This class makes a container out of any TQWidget.
Definition container.h:74
A class to manage (create/load/save) Forms.
Definition formmanager.h:73
Base (virtual) class for all form widgets.
Definition form.h:54
virtual void clearForm()=0
virtual void highlightWidgets(TQWidget *from, TQWidget *to)=0
virtual void initBuffer()=0
virtual void drawRects(const TQValueList< TQRect > &list, int type)=0
A simple class representing a form.
Definition form.h:136
void childAdded(ObjectTreeItem *it)
void destroying()
This signal emitted when Form is about to be destroyed.
int defaultMargin()
Definition form.h:235
TQMap< TQCString, TQString > * headerProperties() const
Definition form.h:309
bool autoTabStops() const
Definition form.h:279
void setAutoTabStops(bool autoTab)
Definition form.h:286
bool interactiveMode() const
Definition form.h:218
TQWidget * selectedWidget() const
Definition form.h:197
Container * toplevelContainer() const
Definition form.h:161
WidgetLibrary * library() const
Definition form.h:147
WidgetList * selectedWidgets() const
Definition form.h:192
void selectionChanged(TQWidget *w, bool add, bool moreWillBeSelected=false)
ObjectTree * objectTree() const
Definition form.h:167
bool designMode() const
Definition form.h:226
void setFilename(const TQString &file)
Sets the filename of this Form to filename.
Definition form.h:251
FormWidget * formWidget() const
Definition form.h:164
TQString filename() const
Definition form.h:248
ObjectTreeList * tabStops() const
Definition form.h:267
void setInteractiveMode(bool interactive)
Definition form.h:210
void childRemoved(ObjectTreeItem *it)
int defaultSpacing()
Definition form.h:238
An item representing a widget Holds the properties of a widget (classname, name, parent,...
Definition objecttree.h:59
Represents all the objects available within a form. This class holds ObjectTreeItem for each widget i...
Definition objecttree.h:140
a set of resize handles (for resizing widgets)
This class searches for factories and provides TDEActions for widget creation.
A class that store pixmaps (by path or by name for KDE icons)
TQPtrList< TQWidget > WidgetList
A list of widget pointers.
TQPtrList< ObjectTreeItem > ObjectTreeList
An list of ObjectTreeItem pointers.
Definition objecttree.h:42
TQPtrListIterator< ObjectTreeItem > ObjectTreeListIterator
An iterator for ObjectTreeList.
Definition objecttree.h:45
type * findParent(TQObject *o, const char *className, TQObject *&prevPrev)