formmanager.h
1/* This file is part of the KDE project
2 Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
3 Copyright (C) 2005 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 FORMMANAGER_H
22#define FORMMANAGER_H
23
24#include <tqobject.h>
25#include <tqdom.h>
26#include <tqptrlist.h>
27#include <tqtimer.h>
28#include <tqguardedptr.h>
29#include <tqstringlist.h>
30
31class TQWidget;
32class TQWorkspace;
33class TDEPopupMenu;
34class TDEActionCollection;
35class TDEAction;
36class TDEToggleAction;
37class KDialogBase;
38class KTextEdit;
39class KXMLGUIClient;
40class TDEMainWindow;
41
42namespace KoProperty {
43 class Editor;
44 class Set;
45 class Property;
46 class Widget;
47}
48
49namespace KFormDesigner {
50
51class WidgetPropertySet;
52class Form;
53class Container;
54class WidgetLibrary;
55class ObjectTreeView;
56class Connection;
57class FormManager;
58typedef TQPtrList<TDEAction> ActionList;
59
61//static FormManager* FormManager_static = 0;
62
64
72class KFORMEDITOR_EXPORT FormManager : public TQObject
73{
74 TQ_OBJECT
75
76
77 public:
80 FormManager(TQObject *parent = 0, int options = 0, const char *name = 0);
81
82 virtual ~FormManager();
83
86 static WidgetLibrary* createWidgetLibrary(FormManager* m,
87 const TQStringList& supportedFactoryGroups);
88
90 static FormManager* self();
91
95 enum Options { HideEventsInPopupMenu = 1, SkipFileActions = 2,
96 HideSignalSlotConnections = 4 }; //todo
97
104 ActionList createActions(WidgetLibrary *lib, TDEActionCollection* collection, KXMLGUIClient *client);
105
109 virtual void enableAction( const char* name, bool enable ) = 0;
110
112 virtual TDEAction* action(const char* name) = 0;
113
114 bool isPasteEnabled();
115
116// //! \return A pointer to the WidgetLibrary owned by this Manager.
117// WidgetLibrary* lib() const { return m_lib; }
118
120 WidgetPropertySet* propertySet() const { return m_propSet; }
121
124 bool isInserting() const { return m_inserting; }
125
128 TQCString selectedClass() const { return m_selectedClass; }
129
131 void setInsertPoint(const TQPoint &p);
132
134 bool isCreatingConnection() { return m_drawingSlot; }
135
137 Connection* createdConnection() { return m_connection; }
138
142 void resetCreatedConnection();
143
145 void createSignalMenu(TQWidget *w);
146
148 void createSlotMenu(TQWidget *w);
149
151 void emitCreateSlot(const TQString &widget, const TQString &value)
152 { emit createFormSlot(m_active, widget, value); }
153
156 Form* activeForm() const;
157
160 Form* formForWidget(TQWidget *w);
161
165 bool isTopLevel(TQWidget *w);
166
168 //unused KoProperty::Editor* propertyEditor() const { return m_editor; }
169
176 virtual void showPropertySet(WidgetPropertySet *set, bool forceReload = false,
177 const TQCString& propertyToSelect = TQCString());
178
179 void blockPropertyEditorUpdating(void *blockingObject);
180
181 void unblockPropertyEditorUpdating(void *blockingObject, WidgetPropertySet *set);
182
184 void setEditor(KoProperty::Editor *editor);
185
189 void setObjectTreeView(ObjectTreeView *treeview);
190
192 void previewForm(Form *form, TQWidget *w, Form *toForm=0);
193
195 void importForm(Form *form=0, bool preview=false);
196
198 void deleteForm(Form *form);
199
203 void createContextMenu(TQWidget *w, Container *container, bool popupAtCursor = true);
204
206 bool snapWidgetsToGrid();
207
209 int contextMenuKey() const { return m_contextMenuKey; }
210
212 void emitWidgetSelected( KFormDesigner::Form* form, bool multiple );
214 void emitFormWidgetSelected( KFormDesigner::Form* form );
216 void emitNoFormSelected();
217
221 bool isRedoing() const { return m_isRedoing; }
222
223 public slots:
225 void deleteWidget();
226
228 void copyWidget();
229
232 void cutWidget();
233
237 void pasteWidget();
238
240 void selectAll();
241
243 void clearWidgetContent();
244
245 void undo();
246 void redo();
247
250 void editTabOrder();
251
253 void adjustWidgetSize();
254
256 void editFormPixmapCollection();
257
259 void editConnections();
260
262 void layoutHBox();
264 void layoutVBox();
266 void layoutGrid();
268 void layoutHSplitter();
270 void layoutVSplitter();
272 void layoutHFlow();
274 void layoutVFlow();
275
277 void breakLayout();
278
279 void alignWidgetsToLeft();
280 void alignWidgetsToRight();
281 void alignWidgetsToTop();
282 void alignWidgetsToBottom();
283 void alignWidgetsToGrid();
284
285 void adjustSizeToGrid();
286
288 void adjustWidthToSmall();
289
291 void adjustWidthToBig();
292
294 void adjustHeightToSmall();
295
297 void adjustHeightToBig();
298
299 void bringWidgetToFront();
300 void sendWidgetToBack();
301
306 void insertWidget(const TQCString &classname);
307
309 void stopInsert();
310
312 void slotPointerClicked();
313
315 void startCreatingConnection();
316
318 void stopCreatingConnection();
319
324 void windowChanged(TQWidget *w);
325
327 void deleteWidgetLater( TQWidget *w );
328
331 void showFormUICode();
332
334 void changeFont();
335
336 signals:
340 void propertySetSwitched(KoProperty::Set *set, bool forceReload = false, const TQCString& propertyToSelect = TQCString());
341
344 void dirty(KFormDesigner::Form *form, bool isDirty=true);
345
349 void widgetSelected(KFormDesigner::Form *form, bool multiple);
350
354
358
361 void undoEnabled(bool enabled, const TQString &text = TQString());
362
365 void redoEnabled(bool enabled, const TQString &text = TQString());
366
370 void createFormSlot(KFormDesigner::Form *form, const TQString &widget, const TQString &signal);
371
375 void connectionCreated(KFormDesigner::Form *form, KFormDesigner::Connection &connection);
376
379
382
386
389
390 protected slots:
391 void deleteWidgetLaterTimeout();
392
394 void buddyChosen(int id);
395
399 void menuSignalChosen(int id);
400
402 void slotStyle();
403
404 void slotConnectionCreated(KFormDesigner::Form*, KFormDesigner::Connection&);
405
406 void slotSettingsChanged(int category);
407
408 protected:
410 void initForm(Form *form);
411
412#if 0
415 virtual bool loadFormFromDomInternal(Form *form, TQWidget *container, TQDomDocument &inBuf);
416
419 virtual bool saveFormToStringInternal(Form *form, TQString &dest, int indent = 0);
420#endif
424 void createLayout(int layoutType);
425
427 void alignWidgets(int type);
428
429 void enableFormActions();
430 void disableWidgetActions();
431 void emitUndoEnabled(bool enabled, const TQString &text);
432 void emitRedoEnabled(bool enabled, const TQString &text);
433
437
438 private:
439 static FormManager* _self;
440
442 enum { MenuTitle = 200, MenuCopy, MenuCut, MenuPaste, MenuDelete, MenuHBox = 301,
443 MenuVBox, MenuGrid, MenuHSplitter, MenuVSplitter, MenuNoBuddy = 501 };
444
445 WidgetPropertySet *m_propSet;
446// WidgetLibrary *m_lib;
447 TQGuardedPtr<KoProperty::Editor> m_editor;
448 TQGuardedPtr<ObjectTreeView> m_treeview;
449 // Forms
450 TQPtrList<Form> m_forms;
451 TQPtrList<Form> m_preview;
452 TQGuardedPtr<Form> m_active;
453
454 // Copy/Paste
455 TQDomDocument m_domDoc;
456 TDEPopupMenu *m_popup;
457 TQPoint m_insertPoint;
458 TQGuardedPtr<TQWidget> m_menuWidget;
459
460 // Insertion
461 bool m_inserting;
462 TQCString m_selectedClass;
463
464 // Connection stuff
465 bool m_drawingSlot;
466 Connection *m_connection;
467 TDEPopupMenu *m_sigSlotMenu;
468
469 // Actions
470 TDEActionCollection *m_collection;
471 TDEToggleAction *m_pointer, *m_dragConnection, *m_snapToGrid;
472
474 TQTimer m_deleteWidgetLater_timer;
475 TQPtrList<TQWidget> m_deleteWidgetLater_list;
476
477#ifdef KEXI_DEBUG_GUI
478 KDialogBase *m_uiCodeDialog;
479 KTextEdit *m_currentUICodeDialogEditor;
480 KTextEdit *m_originalUICodeDialogEditor;
481#endif
482
483 int m_options;
484 int m_contextMenuKey;
485
486 void *m_objectBlockingPropertyEditorUpdating;
487 bool m_isRedoing : 1;
488
489 friend class PropertyCommand;
490 friend class GeometryPropertyCommand;
491 friend class CutWidgetCommand;
492 friend class Form;
493};
494
495}
496
497#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
void dirty(KFormDesigner::Form *form, bool isDirty=true)
void createFormSlot(KFormDesigner::Form *form, const TQString &widget, const TQString &signal)
void connectionAborted(KFormDesigner::Form *form)
void aboutToDeleteForm(KFormDesigner::Form *form)
void autoTabStopsSet(KFormDesigner::Form *form, bool set)
TQCString selectedClass() const
void undoEnabled(bool enabled, const TQString &text=TQString())
void propertySetSwitched(KoProperty::Set *set, bool forceReload=false, const TQCString &propertyToSelect=TQCString())
virtual TDEAction * action(const char *name)=0
WidgetPropertySet * propertySet() const
void formCreated(KFormDesigner::Form *form)
Connection * createdConnection()
void connectionCreated(KFormDesigner::Form *form, KFormDesigner::Connection &connection)
void formWidgetSelected(KFormDesigner::Form *form)
virtual void enableAction(const char *name, bool enable)=0
void widgetSelected(KFormDesigner::Form *form, bool multiple)
void redoEnabled(bool enabled, const TQString &text=TQString())
void emitCreateSlot(const TQString &widget, const TQString &value)
Emits the signal createFormSlot(). Used by WidgetPropertySet.
A simple class representing a form.
Definition form.h:136
A graphical view of Form's ObjectTree. This is a TDEListView which represents an item for each widget...
This class searches for factories and provides TDEActions for widget creation.