kivio_command.h
1/* This file is part of the KDE project
2 Copyright (C) 2002 Laurent Montel <lmontel@mandrakesoft.com>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef kiviocommand_h
21#define kiviocommand_h
22
23#include <kcommand.h>
24#include <tqfont.h>
25#include <tqcolor.h>
26#include <tqvaluelist.h>
27#include <KoRect.h>
28#include <KoPageLayout.h>
29#include <koffice_export.h>
30class KivioPage;
31class KivioLayer;
32class KivioStencil;
33class KivioGroupStencil;
34struct KoPageLayout;
35
36class KivioChangePageNameCommand : public KNamedCommand
37{
38public:
39 KivioChangePageNameCommand( const TQString &_name, const TQString & _oldPageName, const TQString & _newPageName, KivioPage *_page );
40 ~KivioChangePageNameCommand();
41
42 virtual void execute();
43 virtual void unexecute();
44
45protected:
46 TQString oldPageName;
47 TQString newPageName;
48 KivioPage * m_page;
49};
50
51class KivioHidePageCommand : public KNamedCommand
52{
53public:
54 KivioHidePageCommand( const TQString &_name, KivioPage *_page );
55 ~KivioHidePageCommand();
56
57 virtual void execute();
58 virtual void unexecute();
59
60protected:
61 KivioPage * m_page;
62};
63
64class KivioShowPageCommand : public KivioHidePageCommand
65{
66public:
67 KivioShowPageCommand( const TQString &_name, KivioPage *_page );
68 ~KivioShowPageCommand() {}
69
70 void execute() { KivioHidePageCommand::unexecute(); }
71 void unexecute() { KivioHidePageCommand::execute(); }
72};
73
74class KivioAddPageCommand : public KNamedCommand
75{
76public:
77 KivioAddPageCommand( const TQString &_name, KivioPage *_page );
78 ~KivioAddPageCommand();
79
80 virtual void execute();
81 virtual void unexecute();
82
83protected:
84 KivioPage * m_page;
85};
86
87class KivioRemovePageCommand : public KNamedCommand
88{
89public:
90 KivioRemovePageCommand( const TQString &_name, KivioPage *_page );
91 ~KivioRemovePageCommand();
92
93 virtual void execute();
94 virtual void unexecute();
95
96protected:
97 KivioPage * m_page;
98};
99
100class KivioAddStencilCommand : public KNamedCommand
101{
102public:
103 KivioAddStencilCommand( const TQString &_name, KivioPage *_page, KivioLayer * _layer, KivioStencil *_stencil );
104 ~KivioAddStencilCommand();
105
106 virtual void execute();
107 virtual void unexecute();
108
109protected:
110 KivioPage * m_page;
111 KivioLayer * m_layer;
112 KivioStencil *m_stencil;
113};
114
115
116class KivioRemoveStencilCommand : public KivioAddStencilCommand
117{
118public:
119 KivioRemoveStencilCommand(const TQString &_name, KivioPage *_page, KivioLayer * _layer, KivioStencil *_stencil );
120 ~KivioRemoveStencilCommand() {}
121
122 void execute() { KivioAddStencilCommand::unexecute(); }
123 void unexecute() { KivioAddStencilCommand::execute(); }
124};
125
126class KIVIO_EXPORT KivioChangeStencilTextCommand : public KNamedCommand
127{
128public:
129 KivioChangeStencilTextCommand( const TQString &_name, KivioStencil *_stencil, const TQString & _oldText, const TQString & _newText, KivioPage *_page, const TQString& textBoxName = TQString());
130 ~KivioChangeStencilTextCommand();
131 virtual void execute();
132 virtual void unexecute();
133protected:
134 KivioStencil *m_stencil;
135 TQString oldText;
136 TQString newText;
137 KivioPage *m_page;
138 TQString m_textBoxName;
139};
140
141class KivioAddLayerCommand : public KNamedCommand
142{
143public:
144 KivioAddLayerCommand( const TQString &_name, KivioPage *_page, KivioLayer * _layer,int _pos );
145 ~KivioAddLayerCommand();
146
147 virtual void execute();
148 virtual void unexecute();
149
150protected:
151 KivioPage * m_page;
152 KivioLayer *m_layer;
153 int layerPos;
154};
155
156class KivioRemoveLayerCommand : public KivioAddLayerCommand
157{
158public:
159 KivioRemoveLayerCommand( const TQString &_name, KivioPage *_page, KivioLayer * _layer, int _pos );
160 ~KivioRemoveLayerCommand() {}
161
162 void execute() { KivioAddLayerCommand::unexecute(); }
163 void unexecute() { KivioAddLayerCommand::execute(); }
164};
165
166class KivioRenameLayerCommand : public KNamedCommand
167{
168public:
169 KivioRenameLayerCommand( const TQString &_name, KivioLayer * _layer, const TQString & _oldName, const TQString & _newName);
170 ~KivioRenameLayerCommand();
171 virtual void execute();
172 virtual void unexecute();
173
174protected:
175 KivioLayer *m_layer;
176 TQString oldName;
177 TQString newName;
178
179};
180
181class KIVIO_EXPORT KivioResizeStencilCommand : public KNamedCommand
182{
183public:
184 KivioResizeStencilCommand(const TQString &_name, KivioStencil *_stencil, KoRect _initSize, KoRect _endSize, KivioPage *_page );
185 ~KivioResizeStencilCommand();
186
187 virtual void execute();
188 virtual void unexecute();
189
190protected:
191 KivioStencil *m_stencil;
192 KoRect initSize;
193 KoRect endSize;
194 KivioPage *m_page;
195};
196
197class KIVIO_EXPORT KivioMoveStencilCommand : public KNamedCommand
198{
199public:
200 KivioMoveStencilCommand(const TQString &_name, KivioStencil *_stencil, KoRect _initSize, KoRect _endSize, KivioPage *_page );
201 ~KivioMoveStencilCommand();
202
203 virtual void execute();
204 virtual void unexecute();
205
206protected:
207 KivioStencil *m_stencil;
208 KoRect initSize;
209 KoRect endSize;
210 KivioPage *m_page;
211};
212
213class KivioChangeLayoutCommand : public KNamedCommand
214{
215public:
216 KivioChangeLayoutCommand(const TQString &_name, KivioPage *_page, KoPageLayout _oldLayout, KoPageLayout _newLayout);
217 ~KivioChangeLayoutCommand();
218
219 virtual void execute();
220 virtual void unexecute();
221
222protected:
223 KivioPage *m_page;
224 KoPageLayout oldLayout;
225 KoPageLayout newLayout;
226};
227
228
229class KivioChangeStencilHAlignmentCommand : public KNamedCommand
230{
231 public:
232 KivioChangeStencilHAlignmentCommand(const TQString& _name, KivioPage* _page, KivioStencil* _stencil,
233 int _oldAlign, int _newAlign, const TQString& textBoxName = TQString());
234 ~KivioChangeStencilHAlignmentCommand();
235
236 virtual void execute();
237 virtual void unexecute();
238
239 protected:
240 KivioPage *m_page;
241 KivioStencil *m_stencil;
242 int oldAlign;
243 int newAlign;
244 TQString m_textBoxName;
245};
246
247class KivioChangeStencilVAlignmentCommand : public KNamedCommand
248{
249 public:
250 KivioChangeStencilVAlignmentCommand(const TQString& _name, KivioPage* _page, KivioStencil* _stencil,
251 int _oldAlign, int _newAlign, const TQString& textBoxName = TQString());
252 ~KivioChangeStencilVAlignmentCommand();
253
254 virtual void execute();
255 virtual void unexecute();
256
257 protected:
258 KivioPage *m_page;
259 KivioStencil *m_stencil;
260 int oldAlign;
261 int newAlign;
262 TQString m_textBoxName;
263};
264
265
266class KivioChangeStencilFontCommand : public KNamedCommand
267{
268 public:
269 KivioChangeStencilFontCommand(const TQString& _name, KivioPage* _page, KivioStencil* _stencil,
270 const TQFont& _oldFont, const TQFont& _newFont,
271 const TQString& textBoxName = TQString());
272 ~KivioChangeStencilFontCommand();
273
274 virtual void execute();
275 virtual void unexecute();
276
277 protected:
278 KivioPage *m_page;
279 KivioStencil *m_stencil;
280 TQFont oldFont;
281 TQFont newFont;
282 TQString m_textBoxName;
283};
284
285class KivioChangeStencilColorCommand : public KNamedCommand
286{
287 public:
288 enum ColorType { CT_TEXTCOLOR, CT_FGCOLOR, CT_BGCOLOR };
289 KivioChangeStencilColorCommand(const TQString& _name, KivioPage* _page, KivioStencil* _stencil,
290 const TQColor& _oldColor, const TQColor& _newColor, ColorType _type,
291 const TQString& textBoxName = TQString());
292 ~KivioChangeStencilColorCommand();
293
294 virtual void execute();
295 virtual void unexecute();
296
297 protected:
298 KivioPage *m_page;
299 KivioStencil *m_stencil;
300 TQColor oldColor;
301 TQColor newColor;
302 ColorType type;
303 TQString m_textBoxName;
304};
305
306class KivioChangeRotationCommand : public KNamedCommand
307{
308public:
309 KivioChangeRotationCommand( const TQString &_name, KivioPage *_page, KivioStencil * _stencil, int _oldValue, int _newValue);
310 ~KivioChangeRotationCommand();
311
312 virtual void execute();
313 virtual void unexecute();
314
315protected:
316 KivioPage *m_page;
317 KivioStencil *m_stencil;
318 int oldValue;
319 int newValue;
320};
321
322class KivioChangeLineStyleCommand : public KNamedCommand
323{
324public:
325 KivioChangeLineStyleCommand( const TQString &_name, KivioPage *_page, KivioStencil * _stencil, int _oldValue, int _newValue);
326 ~KivioChangeLineStyleCommand();
327
328 virtual void execute();
329 virtual void unexecute();
330
331protected:
332 KivioPage *m_page;
333 KivioStencil *m_stencil;
334 int oldValue;
335 int newValue;
336};
337
338
339class KivioChangeLineWidthCommand : public KNamedCommand
340{
341public:
342 KivioChangeLineWidthCommand( const TQString &_name, KivioPage *_page, KivioStencil * _stencil, double _oldValue, double _newValue);
343 ~KivioChangeLineWidthCommand();
344
345 virtual void execute();
346 virtual void unexecute();
347
348protected:
349 KivioPage *m_page;
350 KivioStencil *m_stencil;
351 double oldValue;
352 double newValue;
353};
354
355class KivioChangeBeginEndArrowCommand : public KNamedCommand
356{
357public:
358 KivioChangeBeginEndArrowCommand( const TQString &_name, KivioPage *_page, KivioStencil * _stencil, int _oldArrow, int _newArrow, bool _beginArrow);
359
360 ~KivioChangeBeginEndArrowCommand();
361
362 virtual void execute();
363 virtual void unexecute();
364
365protected:
366 KivioPage *m_page;
367 KivioStencil *m_stencil;
368 int oldArrow;
369 int newArrow;
370 bool beginArrow;
371};
372
373class KivioChangeBeginEndSizeArrowCommand : public KNamedCommand
374{
375public:
376 KivioChangeBeginEndSizeArrowCommand( const TQString &_name, KivioPage *_page, KivioStencil * _stencil, float _oldH,float _oldW, float _newH,float _newW, bool _beginArrow);
377
378 ~KivioChangeBeginEndSizeArrowCommand();
379
380 virtual void execute();
381 virtual void unexecute();
382
383protected:
384 KivioPage *m_page;
385 KivioStencil *m_stencil;
386 float oldWidth;
387 float oldLength;
388 float newWidth;
389 float newLength;
390
391 bool beginArrow;
392};
393
394class KivioChangeStencilProtectCommand : public KNamedCommand
395{
396public:
397 enum KVP_TYPE {KV_POSX, KV_POSY,KV_WIDTH, KV_HEIGHT, KV_ASPECT, KV_DELETE};
398 KivioChangeStencilProtectCommand( const TQString &_name, KivioPage *_page, KivioStencil * _stencil, bool _state, KVP_TYPE _type);
399
400 ~KivioChangeStencilProtectCommand(){};
401
402 virtual void execute();
403 virtual void unexecute();
404
405protected:
406 void changeValue( bool b );
407 KivioPage *m_page;
408 KivioStencil *m_stencil;
409 KVP_TYPE type;
410 bool m_bValue;
411};
412
413class KivioAddConnectorTargetCommand : public KNamedCommand
414{
415 public:
416 KivioAddConnectorTargetCommand(const TQString& name, KivioPage* page,
417 KivioStencil* stencil, const KoPoint& targetPoint);
418
419 virtual void execute();
420 virtual void unexecute();
421
422 protected:
423 KivioPage* m_page;
424 KivioStencil* m_stencil;
425 KoPoint m_targetPoint;
426};
427
428class KivioCustomDragCommand : public KNamedCommand
429{
430 public:
431 KivioCustomDragCommand(const TQString& name, KivioPage* page, KivioStencil* stencil,
432 int customID, const KoPoint& originalPoint, const KoPoint& newPoint);
433
434 virtual void execute();
435 virtual void unexecute();
436
437 protected:
438 KivioPage* m_page;
439 KivioStencil* m_stencil;
440
441 int m_customID;
442 KoPoint m_originalPoint;
443 KoPoint m_newPoint;
444};
445
446class KivioGroupCommand : public KNamedCommand
447{
448 public:
449 KivioGroupCommand(const TQString& name, KivioPage* page, KivioLayer* layer, KivioGroupStencil* group);
450
451 virtual void execute();
452 virtual void unexecute();
453
454 protected:
455 KivioPage* m_page;
456 KivioLayer* m_layer;
457
458 KivioGroupStencil* m_groupStencil;
459};
460
461class KivioUnGroupCommand : public KivioGroupCommand
462{
463 public:
464 KivioUnGroupCommand(const TQString& name, KivioPage* page, KivioLayer* layer, KivioGroupStencil* group)
465 : KivioGroupCommand(name, page, layer, group)
466 {}
467
468 virtual void execute() { KivioGroupCommand::unexecute(); }
469 virtual void unexecute() { KivioGroupCommand::execute(); }
470};
471
472#endif
473