23#include "vselection.h"
26#include "vstrokecmd.h"
29VStrokeCmd::VStrokeCmd(
VDocument *doc,
const VStroke *stroke,
const TQString& icon )
30 :
VCommand( doc, i18n(
"Stroke Objects" ), icon ), m_stroke( *stroke )
32 m_selection = document()->selection()->clone();
35 if( m_selection->objects().count() == 1 )
36 setName( i18n(
"Stroke Object" ) );
39VStrokeCmd::VStrokeCmd(
VDocument *doc, VGradient *gradient )
40 :
VCommand( doc, i18n(
"Stroke Objects" ),
"14_gradient" )
42 m_selection = document()->selection()->clone();
44 m_stroke.gradient() = *gradient;
46 if( m_selection->objects().count() == 1 )
47 setName( i18n(
"Stroke Object" ) );
50VStrokeCmd::VStrokeCmd(
VDocument *doc, VPattern *pattern )
51 :
VCommand( doc, i18n(
"Stroke Objects" ),
"14_pattern" )
53 m_selection = document()->selection()->clone();
55 m_stroke.pattern() = *pattern;
57 if( m_selection->objects().count() == 1 )
58 setName( i18n(
"Stroke Object" ) );
61VStrokeCmd::VStrokeCmd(
VDocument *doc,
double width )
62 :
VCommand( doc, i18n(
"Stroke Width" ),
"linewidth" )
64 m_selection = document()->selection()->clone();
66 m_stroke.setLineWidth( width );
70 :
VCommand( doc, i18n(
"Stroke Color" ),
"linewidth" )
72 m_selection = document()->selection()->clone();
74 m_stroke.setColor( color );
77VStrokeCmd::VStrokeCmd(
VDocument *doc,
const TQValueList<float>& array )
78 :
VCommand( doc, i18n(
"Dash Pattern" ),
"linewidth" )
80 m_selection = document()->selection()->clone();
82 m_stroke.dashPattern().setArray( array );
85VStrokeCmd::~VStrokeCmd()
87 delete( m_selection );
91VStrokeCmd::changeStroke(
const VColor &color )
94 m_stroke.setColor( color );
96 VObjectListIterator itr( m_selection->objects() );
97 for ( ; itr.current() ; ++itr )
102 m_oldstrokes.push_back( *itr.current()->stroke() );
104 VStroke stroke( *itr.current()->stroke() );
105 stroke.setParent( itr.current() );
107 stroke.setColor( m_stroke.color() );
110 itr.current()->setStroke( stroke );
119 VObjectListIterator itr( m_selection->objects() );
120 for ( ; itr.current() ; ++itr )
125 m_oldstrokes.push_back( *itr.current()->stroke() );
127 VStroke stroke( *itr.current()->stroke() );
128 stroke.setParent( itr.current() );
129 if( m_state == LineWidth )
130 stroke.setLineWidth( m_stroke.lineWidth() );
131 else if( m_state == Color )
133 stroke.setColor( m_stroke.color() );
136 else if( m_state == Gradient )
138 stroke.gradient() = m_stroke.gradient();
141 else if( m_state == Pattern )
143 stroke.pattern() = m_stroke.pattern();
146 else if( m_state == Stroke )
148 stroke.setLineCap( m_stroke.lineCap() );
149 stroke.setLineJoin( m_stroke.lineJoin() );
150 stroke.setLineWidth( m_stroke.lineWidth() );
151 if( m_stroke.type() == VStroke::none )
153 stroke.setType( VStroke::none );
157 stroke.setColor( m_stroke.color() );
162 stroke.gradient() = m_stroke.gradient();
167 stroke.pattern() = m_stroke.pattern();
171 else if( m_state == Dash )
173 stroke.dashPattern() = m_stroke.dashPattern();
175 itr.current()->setStroke( stroke );
184 VObjectListIterator itr( m_selection->objects() );
186 for ( ; itr.current() ; ++itr )
188 itr.current()->setStroke( m_oldstrokes[ i++ ] );
This class keeps track of color properties.
The base class for all karbon commands.
virtual void unexecute()
Unexecutes the command.
virtual void execute()=0
Executes the command.
All non-visual, static doc info is in here.
Manages stroke properties.
void setSuccess(bool success=true)
Set the success property.