kexi

commands.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 KFORMEDITOR_COMMANDS_H
22#define KFORMEDITOR_COMMANDS_H
23
24#include <tqmap.h>
25#include <tqdict.h>
26#include <tqptrlist.h>
27#include <tqptrdict.h>
28#include <tqvariant.h>
29#include <tqdom.h>
30
31#include <kcommand.h>
32#include "utils.h"
33
34class TQWidget;
35class TQRect;
36class TQPoint;
37class TQStringList;
38class TQCString;
39
40namespace KFormDesigner {
41
42class WidgetPropertySet;
43class ObjectTreeItem;
44class Container;
45class Form;
46
48class KFORMEDITOR_EXPORT Command : public KCommand
49{
50 public:
51 Command();
52 virtual ~Command();
53
54 virtual void debug() = 0;
55};
56
61class KFORMEDITOR_EXPORT PropertyCommand : public Command
62{
63 public:
64 PropertyCommand(WidgetPropertySet *set, const TQCString &wname, const TQVariant &oldValue,
65 const TQVariant &value, const TQCString &property);
66 PropertyCommand(WidgetPropertySet *set, const TQMap<TQCString, TQVariant> &oldvalues,
67 const TQVariant &value, const TQCString &property);
68
69 virtual void execute();
70 virtual void unexecute();
71 virtual TQString name() const;
72 TQCString property() const { return m_property; }
73
74 void setValue(const TQVariant &value);
75 const TQMap<TQCString, TQVariant>& oldValues() const { return m_oldvalues; }
76 virtual void debug();
77
78 protected:
79 WidgetPropertySet *m_propSet;
80 TQVariant m_value;
81 TQMap<TQCString, TQVariant> m_oldvalues;
82 TQCString m_property;
83};
84
88class KFORMEDITOR_EXPORT GeometryPropertyCommand : public Command
89{
90 public:
91 GeometryPropertyCommand(WidgetPropertySet *set, const TQStringList &names, const TQPoint& oldPos);
92
93 virtual void execute();
94 virtual void unexecute();
95 virtual TQString name() const;
96 void setPos(const TQPoint& pos);
97 virtual void debug();
98
99 protected:
100 WidgetPropertySet *m_propSet;
101 TQStringList m_names;
102 TQPoint m_oldPos;
103 TQPoint m_pos;
104};
105
109class KFORMEDITOR_EXPORT AlignWidgetsCommand : public Command
110{
111 public:
112 enum { AlignToGrid = 100, AlignToLeft, AlignToRight, AlignToTop, AlignToBottom };
113
114 AlignWidgetsCommand(int type, WidgetList &list, Form *form);
115
116 virtual void execute();
117 virtual void unexecute();
118 virtual TQString name() const;
119 virtual void debug();
120
121 protected:
122 Form *m_form;
123 int m_type;
124 TQMap<TQCString, TQPoint> m_pos;
125};
126
130class KFORMEDITOR_EXPORT AdjustSizeCommand : public Command
131{
132 public:
133 enum { SizeToGrid = 200, SizeToFit, SizeToSmallWidth, SizeToBigWidth,
134 SizeToSmallHeight, SizeToBigHeight };
135
136 AdjustSizeCommand(int type, WidgetList &list, Form *form);
137
138 virtual void execute();
139 virtual void unexecute();
140 virtual TQString name() const;
141 virtual void debug();
142
143 protected:
144 TQSize getSizeFromChildren(ObjectTreeItem *item);
145
146 protected:
147 Form *m_form;
148 int m_type;
149 TQMap<TQCString, TQPoint> m_pos;
150 TQMap<TQCString, TQSize> m_sizes;
151};
152
155class KFORMEDITOR_EXPORT LayoutPropertyCommand : public PropertyCommand
156{
157 public:
158 LayoutPropertyCommand(WidgetPropertySet *set, const TQCString &wname,
159 const TQVariant &oldValue, const TQVariant &value);
160
161 virtual void execute();
162 virtual void unexecute();
163 virtual TQString name() const;
164 virtual void debug();
165
166 protected:
167 Form *m_form;
168 TQMap<TQCString,TQRect> m_geometries;
169};
170
174class KFORMEDITOR_EXPORT InsertWidgetCommand : public Command
175{
176 public:
177 InsertWidgetCommand(Container *container);
178
186 InsertWidgetCommand(Container *container, const TQCString& className,
187 const TQPoint& pos, const TQCString& namePrefix = TQCString());
188
189 virtual void execute();
190 virtual void unexecute();
191 virtual TQString name() const;
192 virtual void debug();
193
195 TQCString widgetName() const { return m_name; }
196
197 protected:
198 Form *m_form;
199 TQString m_containername;
200 TQPoint m_point;
201 TQCString m_name;
202 TQCString m_class;
203 TQRect m_insertRect;
204};
205
209class KFORMEDITOR_EXPORT CreateLayoutCommand : public Command
210{
211 public:
212 CreateLayoutCommand(int layoutType, WidgetList &list, Form *form);
213 CreateLayoutCommand() {;} // for BreakLayoutCommand
214
215 virtual void execute();
216 virtual void unexecute();
217 virtual TQString name() const;
218 virtual void debug();
219
220 protected:
221 Form *m_form;
222 TQString m_containername;
223 TQString m_name;
224 TQMap<TQCString,TQRect> m_pos;
225 int m_type;
226};
227
230class KFORMEDITOR_EXPORT BreakLayoutCommand : public CreateLayoutCommand
231{
232 public:
233 BreakLayoutCommand(Container *container);
234
235 virtual void execute();
236 virtual void unexecute();
237 virtual TQString name() const;
238 virtual void debug();
239};
240
243class KFORMEDITOR_EXPORT PasteWidgetCommand : public Command
244{
245 public:
246 PasteWidgetCommand(TQDomDocument &domDoc, Container *container, const TQPoint& p = TQPoint());
247
248 virtual void execute();
249 virtual void unexecute();
250 virtual TQString name() const;
251 virtual void debug();
252
253 protected:
257 void changePos(TQDomElement &widg, const TQPoint &newpos);
261 void fixPos(TQDomElement &el, Container *container);
262 void moveWidgetBy(TQDomElement &el, Container *container, const TQPoint &p);
269 void fixNames(TQDomElement &el);
270
271 protected:
272 Form *m_form;
273 TQCString m_data;
274 TQString m_containername;
275 TQPoint m_point;
276 TQStringList m_names;
277};
278
281class KFORMEDITOR_EXPORT DeleteWidgetCommand : public Command
282{
283 public:
284 DeleteWidgetCommand(WidgetList &list, Form *form);
285
286 virtual void execute();
287 virtual void unexecute();
288 virtual TQString name() const;
289 virtual void debug();
290
291 protected:
292 TQDomDocument m_domDoc;
293 Form *m_form;
294 TQMap<TQCString, TQCString> m_containers;
295 TQMap<TQCString, TQCString> m_parents;
296};
297
300class KFORMEDITOR_EXPORT CutWidgetCommand : public DeleteWidgetCommand
301{
302 public:
303 CutWidgetCommand(WidgetList &list, Form *form);
304
305 virtual void execute();
306 virtual void unexecute();
307 virtual TQString name() const;
308 virtual void debug();
309
310 protected:
311 TQCString m_data;
312};
313
321class KFORMEDITOR_EXPORT CommandGroup : public Command
322{
323 public:
324 CommandGroup( const TQString & name, WidgetPropertySet *propSet );
325 virtual ~CommandGroup();
326
343 void addCommand(KCommand *command, bool allowExecute);
344
349 virtual void execute();
350
353 virtual void unexecute();
354
355 virtual TQString name() const;
356
360 const TQPtrList<KCommand>& commands() const;
361
366
367 virtual void debug();
368
369 protected:
370 class SubCommands;
371 SubCommands *m_subCommands;
375 WidgetPropertySet *m_propSet;
376};
377
378}
379
380#endif
BreakLayoutCommand(Container *container)
BreakLayoutCommand ///////////////.
const TQPtrList< KCommand > & commands() const
TQPtrDict< char > m_commandsShouldntBeExecuted
Definition commands.h:374
void addCommand(KCommand *command, bool allowExecute)
This class makes a container out of any TQWidget.
Definition container.h:74
CreateLayoutCommand(int layoutType, WidgetList &list, Form *form)
CreateLayoutCommand ///////////////.
Definition commands.cpp:847
A simple class representing a form.
Definition form.h:136
InsertWidgetCommand(Container *container)
Definition commands.cpp:670
An item representing a widget Holds the properties of a widget (classname, name, parent,...
Definition objecttree.h:59
void fixNames(TQDomElement &el)
void fixPos(TQDomElement &el, Container *container)
void changePos(TQDomElement &widg, const TQPoint &newpos)
TQPtrList< TQWidget > WidgetList
A list of widget pointers.