20#include "KPrObject2DIface.h"
21#include "KPrEllipseObject.h"
22#include "KPrGradient.h"
30#include <KoTextZoomHandler.h>
31#include <KoOasisContext.h>
35KPrEllipseObject::KPrEllipseObject()
40KPrEllipseObject::KPrEllipseObject(
const KoPen &_pen,
const TQBrush &_brush, FillType _fillType,
41 const TQColor &_gColor1,
const TQColor &_gColor2, BCType _gType,
42 bool _unbalanced,
int _xfactor,
int _yfactor)
43 : KPr2DObject( _pen, _brush, _fillType, _gColor1, _gColor2, _gType, _unbalanced, _xfactor, _yfactor )
47KPrEllipseObject &KPrEllipseObject::operator=(
const KPrEllipseObject & )
52DCOPObject* KPrEllipseObject::dcopObject()
55 dcop =
new KPrObject2DIface(
this );
59void KPrEllipseObject::paint( TQPainter* _painter, KoTextZoomHandler *_zoomHandler,
60 int ,
bool drawingShadow,
bool drawContour )
62 int ow = _zoomHandler->zoomItX( ext.width() );
63 int oh = _zoomHandler->zoomItY( ext.height() );
64 TQSize size( _zoomHandler->zoomSize( ext ) );
67 TQPen pen3( TQt::black, 1, TQt::DotLine );
68 _painter->setPen( pen3 );
69 _painter->setRasterOp( TQt::NotXorROP );
70 _painter->drawEllipse( 0, 0, ow, oh );
74 TQPen pen2 = pen.zoomedPen( _zoomHandler );
75 int pw = ( pen2.style() == TQt::NoPen ) ? 1 : pen2.width();
76 _painter->setPen( pen2 );
78 if ( drawingShadow || getFillType() == FT_BRUSH || !gradient )
79 _painter->setBrush( getBrush() );
81 if ( m_redrawGradientPix || gradient->size() != size ) {
82 m_redrawGradientPix =
false;
83 gradient->setSize( size );
84 TQRegion clipregion( 0, 0, ow - pw + 1, oh - pw + 1, TQRegion::Ellipse );
85 m_gradientPix.resize ( ow, oh );
86 m_gradientPix.fill( TQt::white );
88 p.begin( &m_gradientPix );
89 p.setClipRegion( clipregion );
90 p.drawPixmap( 0, 0, gradient->pixmap() );
93 m_gradientPix.setMask( m_gradientPix.createHeuristicMask() );
96 _painter->drawPixmap( pw / 2, pw / 2, m_gradientPix, 0, 0, ow - pw + 1, oh - pw + 1 );
98 _painter->setBrush( TQt::NoBrush );
100 _painter->drawEllipse( pw / 2, pw / 2, ow - pw + 1, oh - pw + 1 );
103KoSize KPrEllipseObject::getRealSize()
const {
106 if ( angle != 0.0 ) {
107 float angInRad = angle * M_PI / 180;
108 size.setWidth( sqrt( pow ( ext.width() * cos( angInRad ), 2) +
109 pow ( ext.height() * sin( angInRad ) ,2 ) ) );
110 size.setHeight( sqrt( pow ( ext.width() * sin( angInRad ), 2) +
111 pow ( ext.height() * cos( angInRad ) ,2 ) ) );
117bool KPrEllipseObject::saveOasisObjectAttributes( KPOasisSaveContext & )
const
123const char * KPrEllipseObject::getOasisElementName()
const
125 return ext.width() == ext.height() ?
"draw:circle" :
"draw:ellipse";