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