24#include "vtransformcmd.h"
26#include "vselection.h"
30VAlignCmd::VAlignCmd(
VDocument *doc, Align align )
31 :
VCommand( doc, i18n(
"Align Objects" ) ), m_align( align )
33 m_trafoCmds.setAutoDelete(
true );
36VAlignCmd::~VAlignCmd()
43 if(
document()->selection()->objects().count() == 0 )
48 if(
document()->selection()->objects().count() == 1 )
53 VObjectListIterator itr( objs );
54 VTranslateCmd *trafoCmd = 0L;
55 for( ; itr.current() ; ++itr )
58 bbox = itr.current()->boundingBox();
61 case ALIGN_HORIZONTAL_LEFT : dx = r.topLeft().x() - bbox.topLeft().x(); dy = 0;
break;
62 case ALIGN_HORIZONTAL_CENTER: dx = r.center().x() - bbox.center().x(); dy = 0;
break;
63 case ALIGN_HORIZONTAL_RIGHT : dx = r.topRight().x() - bbox.topRight().x(); dy = 0;
break;
64 case ALIGN_VERTICAL_TOP : dx = 0; dy = r.bottomRight().y() - bbox.bottomRight().y();
break;
65 case ALIGN_VERTICAL_CENTER : dx = 0; dy = r.center().y() - bbox.center().y();
break;
66 case ALIGN_VERTICAL_BOTTOM : dx = 0; dy = r.topLeft().y() - bbox.topLeft().y();
break;
69 trafoCmd =
new VTranslateCmd(
document(), dx, dy );
70 m_trafoCmds.append( trafoCmd );
74 for( ; itr.current() ; ++itr )
82 TQPtrListIterator<VTranslateCmd> itr( m_trafoCmds );
83 for( ; itr.current() ; ++itr )
84 itr.current()->unexecute();
The base class for all karbon commands.
virtual void unexecute()
Unexecutes the command.
VDocument * document() const
Returns the document the command works on.
virtual void execute()=0
Executes the command.
All non-visual, static doc info is in here.
VSelection * selection() const
Returns a pointer to the selection.
virtual const KoRect & boundingBox() const
Calculates the tightest bounding box around the object.
const VObjectList & objects() const
Read only access to the selected objects.
void append()
Adds all objects to the selection.
void clear()
Removes the references to all objects, not the objects themselves.
virtual const KoRect & boundingBox() const
Calculates the tightest bounding box around the object.
void setSuccess(bool success=true)
Set the success property.