Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "KDChartAbstractArea.h"
00024 #include "KDChartAbstractArea_p.h"
00025
00026 #include <qglobal.h>
00027
00028 #include <QPainter>
00029 #include <QRect>
00030
00031 #include <KDABLibFakes>
00032
00033
00034 using namespace KDChart;
00035
00036 #define d (d_func())
00037
00038 AbstractArea::Private::Private() :
00039 AbstractAreaBase::Private()
00040 {
00041
00042 }
00043
00044
00045 AbstractArea::Private::~Private()
00046 {
00047
00048 }
00049
00050
00051 AbstractArea::AbstractArea()
00052 : QObject()
00053 , KDChart::AbstractAreaBase()
00054 , KDChart::AbstractLayoutItem()
00055 {
00056 init();
00057 }
00058
00059 AbstractArea::~AbstractArea()
00060 {
00061
00062 }
00063
00064
00065 void AbstractArea::init()
00066 {
00067 d->amountOfLeftOverlap = 0;
00068 d->amountOfRightOverlap = 0;
00069 d->amountOfTopOverlap = 0;
00070 d->amountOfBottomOverlap = 0;
00071 }
00072
00073
00074 int AbstractArea::leftOverlap( bool doNotRecalculate ) const
00075 {
00076
00077
00078 if( ! doNotRecalculate )
00079 sizeHint();
00080 return d->amountOfLeftOverlap;
00081 }
00082 int AbstractArea::rightOverlap( bool doNotRecalculate ) const
00083 {
00084
00085
00086 if( ! doNotRecalculate )
00087 sizeHint();
00088 return d->amountOfRightOverlap;
00089 }
00090 int AbstractArea::topOverlap( bool doNotRecalculate ) const
00091 {
00092
00093
00094 if( ! doNotRecalculate )
00095 sizeHint();
00096 return d->amountOfTopOverlap;
00097 }
00098 int AbstractArea::bottomOverlap( bool doNotRecalculate ) const
00099 {
00100
00101
00102 if( ! doNotRecalculate )
00103 sizeHint();
00104 return d->amountOfBottomOverlap;
00105 }
00106
00107
00108 void AbstractArea::paintIntoRect( QPainter& painter, const QRect& rect )
00109 {
00110 const QRect oldGeometry( geometry() );
00111 if( oldGeometry != rect )
00112 setGeometry( rect );
00113 painter.translate( rect.left(), rect.top() );
00114 paintAll( painter );
00115 painter.translate( -rect.left(), -rect.top() );
00116 if( oldGeometry != rect )
00117 setGeometry( oldGeometry );
00118 }
00119
00120 void AbstractArea::paintAll( QPainter& painter )
00121 {
00122
00123 const QRect overlappingArea( geometry().adjusted(
00124 -d->amountOfLeftOverlap,
00125 -d->amountOfTopOverlap,
00126 d->amountOfRightOverlap,
00127 d->amountOfBottomOverlap ) );
00128 paintBackground( painter, overlappingArea );
00129 paintFrame( painter, overlappingArea );
00130
00131
00132
00133 const QRect oldGeometry( areaGeometry() );
00134 QRect inner( innerRect() );
00135 inner.moveTo(
00136 oldGeometry.left() + inner.left(),
00137 oldGeometry.top() + inner.top() );
00138 const bool needAdjustGeometry = oldGeometry != inner;
00139 if( needAdjustGeometry )
00140 setGeometry( inner );
00141 paint( &painter );
00142 if( needAdjustGeometry )
00143 setGeometry( oldGeometry );
00144
00145 }
00146
00147 QRect AbstractArea::areaGeometry() const
00148 {
00149 return geometry();
00150 }
00151
00152 void AbstractArea::positionHasChanged()
00153 {
00154 emit positionChanged( this );
00155 }
00156