20#include "KPrObjectProperties.h"
23#include "KPrGroupObject.h"
24#include "KPrLineObject.h"
25#include "KPrRectObject.h"
26#include "KPrPolygonObject.h"
27#include "KPrPieObject.h"
28#include "KPrPixmapObject.h"
29#include "KPrPointObject.h"
30#include "KPrBezierCurveObject.h"
31#include "KPrTextObject.h"
33KPrObjectProperties::KPrObjectProperties(
const TQPtrList<KPrObject> &objects )
36, m_pen( KoPen( TQt::black, 1.0, TQt::SolidLine ), L_NORMAL, L_NORMAL )
37, m_protectContent( STATE_UNDEF )
39 getProperties( m_objects );
43KPrObjectProperties::~KPrObjectProperties()
48void KPrObjectProperties::getProperties(
const TQPtrList<KPrObject> &objects )
50 TQPtrListIterator<KPrObject> it( objects );
51 for ( ; it.current() ; ++it )
53 switch ( it.current()->getType() )
58 case OT_QUADRICBEZIERCURVE:
59 case OT_CUBICBEZIERCURVE:
60 getPenProperties( it.current() );
61 getLineEndsProperties( it.current() );
65 getPieProperties( it.current() );
68 getRectProperties( it.current() );
71 getPolygonSettings( it.current() );
74 getTextProperties( it.current() );
80 getPenProperties( it.current() );
81 getBrushProperties( it.current() );
86 getPictureProperties( it.current() );
90 KPrGroupObject *obj =
dynamic_cast<KPrGroupObject*
>( it.current() );
93 getProperties( obj->objectList() );
104void KPrObjectProperties::getPenProperties( KPrObject *
object )
106 if ( !( m_flags & PtPen ) )
111 m_pen.pen = obj->getPen();
116 if ( !( m_flags & PtPenWidth ) )
119 if ( obj && obj->getPen().style() != TQt::NoPen )
121 m_flags |= PtPenWidth;
127void KPrObjectProperties::getLineEndsProperties( KPrObject *
object )
129 if ( !( m_flags & PtLineEnds ) )
131 switch ( object->getType() )
135 KPrLineObject *obj =
dynamic_cast<KPrLineObject*
>( object );
138 m_pen.lineBegin = obj->getLineBegin();
139 m_pen.lineEnd = obj->getLineEnd();
141 m_flags |= PtLineEnds;
147 case OT_QUADRICBEZIERCURVE:
148 case OT_CUBICBEZIERCURVE:
150 KPrPointObject *obj =
dynamic_cast<KPrPointObject*
>( object );
153 m_pen.lineBegin = obj->getLineBegin();
154 m_pen.lineEnd = obj->getLineEnd();
156 m_flags |= PtLineEnds;
162 KPrPieObject *obj =
dynamic_cast<KPrPieObject*
>( object );
165 m_pen.lineBegin = obj->getLineBegin();
166 m_pen.lineEnd = obj->getLineEnd();
168 m_flags |= PtLineEnds;
179void KPrObjectProperties::getBrushProperties( KPrObject *
object )
181 if ( !( m_flags & PtBrush ) )
183 KPr2DObject * obj =
dynamic_cast<KPr2DObject*
>( object );
186 m_brush.brush = obj->getBrush();
187 m_brush.fillType = obj->getFillType();
188 m_brush.gColor1 = obj->getGColor1();
189 m_brush.gColor2 = obj->getGColor2();
190 m_brush.gType = obj->getGType();
191 m_brush.unbalanced = obj->getGUnbalanced();
192 m_brush.xfactor = obj->getGXFactor();
193 m_brush.yfactor = obj->getGYFactor();
201void KPrObjectProperties::getRectProperties( KPrObject *
object )
203 if ( !( m_flags & PtRectangle ) )
205 KPrRectObject *obj =
dynamic_cast<KPrRectObject*
>( object );
208 obj->getRnds( m_rectValues.xRnd, m_rectValues.yRnd );
210 getPenProperties(
object );
211 getBrushProperties(
object );
212 m_flags |= PtRectangle;
218void KPrObjectProperties::getPolygonSettings( KPrObject *
object )
220 if ( !( m_flags & PtPolygon ) )
222 KPrPolygonObject *obj =
dynamic_cast<KPrPolygonObject*
>( object );
225 m_polygonSettings.checkConcavePolygon = obj->getCheckConcavePolygon();
226 m_polygonSettings.cornersValue = obj->getCornersValue();
227 m_polygonSettings.sharpnessValue = obj->getSharpnessValue();
229 getPenProperties(
object );
230 getBrushProperties(
object );
231 m_flags |= PtPolygon;
237void KPrObjectProperties::getPieProperties( KPrObject *
object )
239 if ( !( m_flags & PtPie ) )
241 KPrPieObject *obj =
dynamic_cast<KPrPieObject*
>( object );
244 m_pieValues.pieType = obj->getPieType();
245 m_pieValues.pieAngle = obj->getPieAngle();
246 m_pieValues.pieLength = obj->getPieLength();
248 getPenProperties(
object );
249 if ( obj->getPieType() != PT_ARC )
251 getBrushProperties(
object );
255 getLineEndsProperties(
object );
264void KPrObjectProperties::getPictureProperties( KPrObject *
object )
266 if ( !( m_flags & PtPicture ) )
268 KPrPixmapObject *obj =
dynamic_cast<KPrPixmapObject*
>( object );
271 m_pictureSettings.mirrorType = obj->getPictureMirrorType();
272 m_pictureSettings.depth = obj->getPictureDepth();
273 m_pictureSettings.swapRGB = obj->getPictureSwapRGB();
274 m_pictureSettings.grayscal = obj->getPictureGrayscal();
275 m_pictureSettings.bright = obj->getPictureBright();
276 m_pixmap = obj->getOriginalPixmap();
278 getPenProperties(
object );
279 getBrushProperties(
object );
280 m_flags |= PtPicture;
286void KPrObjectProperties::getTextProperties( KPrObject *
object )
288 KPrTextObject *obj =
dynamic_cast<KPrTextObject*
>( object );
291 if ( !( m_flags & PtText ) )
293 m_marginsStruct = MarginsStruct( obj );
294 m_protectContent = obj->isProtectContent() ? STATE_ON : STATE_OFF;
296 getPenProperties(
object );
297 getBrushProperties(
object );
302 PropValue pv = obj->isProtectContent() ? STATE_ON : STATE_OFF;
303 if ( pv != m_protectContent )
305 m_protectContent = STATE_UNDEF;
Base class for objects with a pen and a brush, and which takes care of painting the shadow in draw() ...