#include <KDChartAbstractAreaBase.h>
AbstractAreaBase is the base class for all chart elements that have a set of background attributes and frame attributes, such as legends or axes.
This classis not a QObject, so it is easier to inherit from it, if your are inheriting from a QObject too like AbstractAreaWidget does it.
Definition at line 69 of file KDChartAbstractAreaBase.h.
Public Member Functions | |
void | alignToReferencePoint (const RelativePosition &position) |
BackgroundAttributes | backgroundAttributes () const |
bool | compare (const AbstractAreaBase *other) const |
Returns true if both areas have the same settings. | |
FrameAttributes | frameAttributes () const |
void | getFrameLeadings (int &left, int &top, int &right, int &bottom) const |
virtual void | paintBackground (QPainter &painter, const QRect &rectangle) |
virtual void | paintFrame (QPainter &painter, const QRect &rectangle) |
void | setBackgroundAttributes (const BackgroundAttributes &a) |
void | setFrameAttributes (const FrameAttributes &a) |
Static Public Member Functions | |
static void | paintBackgroundAttributes (QPainter &painter, const QRect &rectangle, const KDChart::BackgroundAttributes &attributes) |
static void | paintFrameAttributes (QPainter &painter, const QRect &rectangle, const KDChart::FrameAttributes &attributes) |
Protected Member Functions | |
AbstractAreaBase () | |
virtual QRect | areaGeometry () const =0 |
QRect | innerRect () const |
virtual void | positionHasChanged () |
virtual | ~AbstractAreaBase () |
AbstractAreaBase::AbstractAreaBase | ( | ) | [protected] |
Definition at line 58 of file KDChartAbstractAreaBase.cpp.
00058 : 00059 _d( new Private() ) 00060 { 00061 }
AbstractAreaBase::~AbstractAreaBase | ( | ) | [protected, virtual] |
void AbstractAreaBase::alignToReferencePoint | ( | const RelativePosition & | position | ) |
Definition at line 91 of file KDChartAbstractAreaBase.cpp.
00092 { 00093 Q_UNUSED( position ); 00094 // PENDING(kalle) FIXME 00095 qWarning( "Sorry, not implemented: void AbstractAreaBase::alignToReferencePoint( const RelativePosition& position )" ); 00096 }
virtual QRect KDChart::AbstractAreaBase::areaGeometry | ( | ) | const [protected, pure virtual] |
Implemented in KDChart::AbstractArea, KDChart::AbstractAreaWidget, and KDChart::TextArea.
Referenced by innerRect().
BackgroundAttributes AbstractAreaBase::backgroundAttributes | ( | ) | const |
Definition at line 121 of file KDChartAbstractAreaBase.cpp.
References d.
Referenced by compare(), and updateCommonBrush().
00122 { 00123 return d->backgroundAttributes; 00124 }
bool AbstractAreaBase::compare | ( | const AbstractAreaBase * | other | ) | const |
Returns true if both areas have the same settings.
Definition at line 76 of file KDChartAbstractAreaBase.cpp.
References backgroundAttributes(), and frameAttributes().
00077 { 00078 if( other == this ) return true; 00079 if( ! other ){ 00080 //qDebug() << "CartesianAxis::compare() cannot compare to Null pointer"; 00081 return false; 00082 } 00083 /* 00084 qDebug() << "AbstractAreaBase:" << (frameAttributes() == other->frameAttributes()) 00085 << (backgroundAttributes() == other->backgroundAttributes()) << "\n"; 00086 */ 00087 return (frameAttributes() == other->frameAttributes()) && 00088 (backgroundAttributes() == other->backgroundAttributes()); 00089 }
FrameAttributes AbstractAreaBase::frameAttributes | ( | ) | const |
Definition at line 107 of file KDChartAbstractAreaBase.cpp.
References d.
Referenced by KDChart::Legend::clone(), compare(), and updateCommonBrush().
00108 { 00109 return d->frameAttributes; 00110 }
void AbstractAreaBase::getFrameLeadings | ( | int & | left, | |
int & | top, | |||
int & | right, | |||
int & | bottom | |||
) | const |
Definition at line 213 of file KDChartAbstractAreaBase.cpp.
References d.
Referenced by innerRect(), and KDChart::AbstractAreaWidget::paintAll().
00214 { 00215 if( d && d->frameAttributes.isVisible() ){ 00216 const int padding = qMax( d->frameAttributes.padding(), 0 ); 00217 left = padding; 00218 top = padding; 00219 right = padding; 00220 bottom = padding; 00221 }else{ 00222 left = 0; 00223 top = 0; 00224 right = 0; 00225 bottom = 0; 00226 } 00227 }
QRect AbstractAreaBase::innerRect | ( | ) | const [protected] |
Definition at line 229 of file KDChartAbstractAreaBase.cpp.
References areaGeometry(), and getFrameLeadings().
Referenced by KDChart::TextArea::paintAll(), and KDChart::AbstractArea::paintAll().
00230 { 00231 int left; 00232 int top; 00233 int right; 00234 int bottom; 00235 getFrameLeadings( left, top, right, bottom ); 00236 return 00237 QRect( QPoint(0,0), areaGeometry().size() ) 00238 .adjusted( left, top, -right, -bottom ); 00239 }
void AbstractAreaBase::paintBackground | ( | QPainter & | painter, | |
const QRect & | rectangle | |||
) | [virtual] |
Definition at line 197 of file KDChartAbstractAreaBase.cpp.
References d, and paintBackgroundAttributes().
Referenced by KDChart::TextArea::paintAll(), KDChart::AbstractAreaWidget::paintAll(), and KDChart::AbstractArea::paintAll().
00198 { 00199 Q_ASSERT_X ( d != 0, "AbstractAreaBase::paintBackground()", 00200 "Private class was not initialized!" ); 00201 paintBackgroundAttributes( painter, rect, d->backgroundAttributes ); 00202 }
void AbstractAreaBase::paintBackgroundAttributes | ( | QPainter & | painter, | |
const QRect & | rectangle, | |||
const KDChart::BackgroundAttributes & | attributes | |||
) | [static] |
Definition at line 128 of file KDChartAbstractAreaBase.cpp.
References KDChart::BackgroundAttributes::BackgroundPixmapModeCentered, KDChart::BackgroundAttributes::BackgroundPixmapModeNone, KDChart::BackgroundAttributes::BackgroundPixmapModeScaled, KDChart::BackgroundAttributes::BackgroundPixmapModeStretched, KDChart::BackgroundAttributes::brush(), KDChart::BackgroundAttributes::isVisible(), m, KDChart::BackgroundAttributes::pixmap(), and KDChart::BackgroundAttributes::pixmapMode().
Referenced by paintBackground().
00130 { 00131 if( !attributes.isVisible() ) return; 00132 00133 /* first draw the brush (may contain a pixmap)*/ 00134 if( Qt::NoBrush != attributes.brush().style() ) { 00135 KDChart::PainterSaver painterSaver( &painter ); 00136 painter.setPen( Qt::NoPen ); 00137 const QPointF newTopLeft( painter.deviceMatrix().map( rect.topLeft() ) ); 00138 painter.setBrushOrigin( newTopLeft ); 00139 painter.setBrush( attributes.brush() ); 00140 painter.drawRect( rect.adjusted( 0, 0, -1, -1 ) ); 00141 } 00142 /* next draw the backPixmap over the brush */ 00143 if( !attributes.pixmap().isNull() && 00144 attributes.pixmapMode() != BackgroundAttributes::BackgroundPixmapModeNone ) { 00145 QPointF ol = rect.topLeft(); 00146 if( BackgroundAttributes::BackgroundPixmapModeCentered == attributes.pixmapMode() ) 00147 { 00148 ol.setX( rect.center().x() - attributes.pixmap().width() / 2 ); 00149 ol.setY( rect.center().y() - attributes.pixmap().height()/ 2 ); 00150 painter.drawPixmap( ol, attributes.pixmap() ); 00151 } else { 00152 QMatrix m; 00153 double zW = (double)rect.width() / (double)attributes.pixmap().width(); 00154 double zH = (double)rect.height() / (double)attributes.pixmap().height(); 00155 switch( attributes.pixmapMode() ) { 00156 case BackgroundAttributes::BackgroundPixmapModeScaled: 00157 { 00158 double z; 00159 z = qMin( zW, zH ); 00160 m.scale( z, z ); 00161 } 00162 break; 00163 case BackgroundAttributes::BackgroundPixmapModeStretched: 00164 m.scale( zW, zH ); 00165 break; 00166 default: 00167 ; // Cannot happen, previously checked 00168 } 00169 QPixmap pm = attributes.pixmap().transformed( m ); 00170 ol.setX( rect.center().x() - pm.width() / 2 ); 00171 ol.setY( rect.center().y() - pm.height()/ 2 ); 00172 painter.drawPixmap( ol, pm ); 00173 } 00174 } 00175 }
void AbstractAreaBase::paintFrame | ( | QPainter & | painter, | |
const QRect & | rectangle | |||
) | [virtual] |
Definition at line 205 of file KDChartAbstractAreaBase.cpp.
References d, and paintFrameAttributes().
Referenced by KDChart::TextArea::paintAll(), KDChart::AbstractAreaWidget::paintAll(), and KDChart::AbstractArea::paintAll().
00206 { 00207 Q_ASSERT_X ( d != 0, "AbstractAreaBase::paintFrame()", 00208 "Private class was not initialized!" ); 00209 paintFrameAttributes( painter, rect, d->frameAttributes ); 00210 }
void AbstractAreaBase::paintFrameAttributes | ( | QPainter & | painter, | |
const QRect & | rectangle, | |||
const KDChart::FrameAttributes & | attributes | |||
) | [static] |
Definition at line 178 of file KDChartAbstractAreaBase.cpp.
References KDChart::FrameAttributes::isVisible(), KDChart::FrameAttributes::pen(), and KDChart::PrintingParameters::scalePen().
Referenced by paintFrame().
00180 { 00181 00182 if( !attributes.isVisible() ) return; 00183 00184 // Note: We set the brush to NoBrush explicitly here. 00185 // Otherwise we might get a filled rectangle, so any 00186 // previously drawn background would be overwritten by that area. 00187 00188 const QPen oldPen( painter.pen() ); 00189 const QBrush oldBrush( painter.brush() ); 00190 painter.setPen( PrintingParameters::scalePen( attributes.pen() ) ); 00191 painter.setBrush( Qt::NoBrush ); 00192 painter.drawRect( rect.adjusted( 0, 0, -1, -1 ) ); 00193 painter.setBrush( oldBrush ); 00194 painter.setPen( oldPen ); 00195 }
void AbstractAreaBase::positionHasChanged | ( | ) | [protected, virtual] |
Reimplemented in KDChart::AbstractArea, KDChart::AbstractAreaWidget, and KDChart::TextArea.
Definition at line 241 of file KDChartAbstractAreaBase.cpp.
Referenced by setBackgroundAttributes(), and setFrameAttributes().
void AbstractAreaBase::setBackgroundAttributes | ( | const BackgroundAttributes & | a | ) |
Definition at line 112 of file KDChartAbstractAreaBase.cpp.
References d, and positionHasChanged().
00113 { 00114 if( d->backgroundAttributes == a ) 00115 return; 00116 00117 d->backgroundAttributes = a; 00118 positionHasChanged(); 00119 }
void AbstractAreaBase::setFrameAttributes | ( | const FrameAttributes & | a | ) |
Definition at line 98 of file KDChartAbstractAreaBase.cpp.
References d, and positionHasChanged().
Referenced by KDChart::Legend::clone().
00099 { 00100 if( d->frameAttributes == a ) 00101 return; 00102 00103 d->frameAttributes = a; 00104 positionHasChanged(); 00105 }