#include <KDChartAbstractArea.h>
Inheritance diagram for KDChart::AbstractArea:
AbstractArea is the base class for all non-widget chart elements that have a set of background attributes and frame attributes, such as coordinate planes or axes.
Definition at line 54 of file KDChartAbstractArea.h.
Signals | |
void | positionChanged (AbstractArea *) |
Public Member Functions | |
void | alignToReferencePoint (const RelativePosition &position) |
BackgroundAttributes | backgroundAttributes () const |
virtual int | bottomOverlap (bool doNotRecalculate=false) const |
This is called at layout time by KDChart:AutoSpacerLayoutItem::sizeHint(). | |
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 int | leftOverlap (bool doNotRecalculate=false) const |
This is called at layout time by KDChart::AutoSpacerLayoutItem::sizeHint(). | |
virtual void | paint (QPainter *)=0 |
virtual void | paintAll (QPainter &painter) |
Call paintAll, if you want the background and the frame to be drawn before the normal paint() is invoked automatically. | |
virtual void | paintBackground (QPainter &painter, const QRect &rectangle) |
virtual void | paintCtx (PaintContext *context) |
Default impl: Paint the complete item using its layouted position and size. | |
virtual void | paintFrame (QPainter &painter, const QRect &rectangle) |
virtual void | paintIntoRect (QPainter &painter, const QRect &rect) |
Draws the background and frame, then calls paint(). | |
QLayout * | parentLayout () |
void | removeFromParentLayout () |
virtual int | rightOverlap (bool doNotRecalculate=false) const |
This is called at layout time by KDChart::AutoSpacerLayoutItem::sizeHint(). | |
void | setBackgroundAttributes (const BackgroundAttributes &a) |
void | setFrameAttributes (const FrameAttributes &a) |
void | setParentLayout (QLayout *lay) |
virtual void | setParentWidget (QWidget *widget) |
Inform the item about its widget: This enables the item, to trigger that widget's update, whenever the size of the item's contents has changed. | |
virtual void | sizeHintChanged () const |
Report changed size hint: ask the parent widget to recalculate the layout. | |
virtual int | topOverlap (bool doNotRecalculate=false) const |
This is called at layout time by KDChart::AutoSpacerLayoutItem::sizeHint(). | |
virtual | ~AbstractArea () |
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 | |
AbstractArea () | |
virtual QRect | areaGeometry () const |
QRect | innerRect () const |
virtual void | positionHasChanged () |
Protected Attributes | |
QWidget * | mParent |
QLayout * | mParentLayout |
AbstractArea::~AbstractArea | ( | ) | [virtual] |
AbstractArea::AbstractArea | ( | ) | [protected] |
Definition at line 54 of file KDChartAbstractArea.cpp.
00055 : QObject() 00056 , KDChart::AbstractAreaBase() 00057 , KDChart::AbstractLayoutItem() 00058 { 00059 init(); 00060 }
void AbstractAreaBase::alignToReferencePoint | ( | const RelativePosition & | position | ) | [inherited] |
Definition at line 90 of file KDChartAbstractAreaBase.cpp.
00091 { 00092 Q_UNUSED( position ); 00093 // PENDING(kalle) FIXME 00094 qWarning( "Sorry, not implemented: void AbstractAreaBase::alignToReferencePoint( const RelativePosition& position )" ); 00095 }
QRect AbstractArea::areaGeometry | ( | ) | const [protected, virtual] |
Implements KDChart::AbstractAreaBase.
Definition at line 150 of file KDChartAbstractArea.cpp.
Referenced by KDChart::CartesianCoordinatePlane::drawingArea(), KDChart::TernaryCoordinatePlane::layoutDiagrams(), KDChart::PolarCoordinatePlane::layoutDiagrams(), KDChart::TernaryCoordinatePlane::paint(), KDChart::CartesianAxis::paint(), paintAll(), and KDChart::CartesianAxis::paintCtx().
BackgroundAttributes AbstractAreaBase::backgroundAttributes | ( | ) | const [inherited] |
Definition at line 120 of file KDChartAbstractAreaBase.cpp.
References d.
Referenced by KDChart::AbstractAreaBase::compare(), and updateCommonBrush().
00121 { 00122 return d->backgroundAttributes; 00123 }
int AbstractArea::bottomOverlap | ( | bool | doNotRecalculate = false |
) | const [virtual] |
This is called at layout time by KDChart:AutoSpacerLayoutItem::sizeHint().
The method triggers AbstractArea::sizeHint() to find out the amount of overlap at the bottom edge of the area.
Definition at line 101 of file KDChartAbstractArea.cpp.
References d.
Referenced by KDChart::CartesianAxis::maximumSize().
00102 { 00103 // Re-calculate the sizes, 00104 // so we also get the amountOf..Overlap members set newly: 00105 if( ! doNotRecalculate ) 00106 sizeHint(); 00107 return d->amountOfBottomOverlap; 00108 }
bool AbstractAreaBase::compare | ( | const AbstractAreaBase * | other | ) | const [inherited] |
Returns true if both areas have the same settings.
Definition at line 75 of file KDChartAbstractAreaBase.cpp.
References KDChart::AbstractAreaBase::backgroundAttributes(), and KDChart::AbstractAreaBase::frameAttributes().
00076 { 00077 if( other == this ) return true; 00078 if( ! other ){ 00079 //qDebug() << "CartesianAxis::compare() cannot compare to Null pointer"; 00080 return false; 00081 } 00082 /* 00083 qDebug() << "AbstractAreaBase:" << (frameAttributes() == other->frameAttributes()) 00084 << (backgroundAttributes() == other->backgroundAttributes()) << "\n"; 00085 */ 00086 return (frameAttributes() == other->frameAttributes()) && 00087 (backgroundAttributes() == other->backgroundAttributes()); 00088 }
FrameAttributes AbstractAreaBase::frameAttributes | ( | ) | const [inherited] |
Definition at line 106 of file KDChartAbstractAreaBase.cpp.
References d.
Referenced by KDChart::Legend::clone(), KDChart::AbstractAreaBase::compare(), and updateCommonBrush().
00107 { 00108 return d->frameAttributes; 00109 }
void AbstractAreaBase::getFrameLeadings | ( | int & | left, | |
int & | top, | |||
int & | right, | |||
int & | bottom | |||
) | const [inherited] |
Definition at line 212 of file KDChartAbstractAreaBase.cpp.
References d.
Referenced by KDChart::AbstractAreaBase::innerRect(), and KDChart::AbstractAreaWidget::paintAll().
00213 { 00214 if( d && d->frameAttributes.isVisible() ){ 00215 const int padding = qMax( d->frameAttributes.padding(), 0 ); 00216 left = padding; 00217 top = padding; 00218 right = padding; 00219 bottom = padding; 00220 }else{ 00221 left = 0; 00222 top = 0; 00223 right = 0; 00224 bottom = 0; 00225 } 00226 }
QRect AbstractAreaBase::innerRect | ( | ) | const [protected, inherited] |
Definition at line 228 of file KDChartAbstractAreaBase.cpp.
References KDChart::AbstractAreaBase::areaGeometry(), and KDChart::AbstractAreaBase::getFrameLeadings().
Referenced by KDChart::TextArea::paintAll(), and paintAll().
00229 { 00230 int left; 00231 int top; 00232 int right; 00233 int bottom; 00234 getFrameLeadings( left, top, right, bottom ); 00235 return 00236 QRect( QPoint(0,0), areaGeometry().size() ) 00237 .adjusted( left, top, -right, -bottom ); 00238 }
int AbstractArea::leftOverlap | ( | bool | doNotRecalculate = false |
) | const [virtual] |
This is called at layout time by KDChart::AutoSpacerLayoutItem::sizeHint().
The method triggers AbstractArea::sizeHint() to find out the amount of overlap at the left edge of the area.
Definition at line 77 of file KDChartAbstractArea.cpp.
References d.
Referenced by KDChart::CartesianAxis::maximumSize().
00078 { 00079 // Re-calculate the sizes, 00080 // so we also get the amountOf..Overlap members set newly: 00081 if( ! doNotRecalculate ) 00082 sizeHint(); 00083 return d->amountOfLeftOverlap; 00084 }
virtual void KDChart::AbstractLayoutItem::paint | ( | QPainter * | ) | [pure virtual, inherited] |
Implemented in KDChart::CartesianAxis, KDChart::CartesianCoordinatePlane, KDChart::TextLayoutItem, KDChart::MarkerLayoutItem, KDChart::LineLayoutItem, KDChart::LineWithMarkerLayoutItem, KDChart::HorizontalLineLayoutItem, KDChart::VerticalLineLayoutItem, KDChart::AutoSpacerLayoutItem, KDChart::PolarCoordinatePlane, KDChart::TernaryAxis, and KDChart::TernaryCoordinatePlane.
Referenced by KDChart::Legend::paint(), KDChart::AbstractLayoutItem::paintAll(), paintAll(), and KDChart::AbstractLayoutItem::paintCtx().
void AbstractArea::paintAll | ( | QPainter & | painter | ) | [virtual] |
Call paintAll, if you want the background and the frame to be drawn before the normal paint() is invoked automatically.
Reimplemented from KDChart::AbstractLayoutItem.
Reimplemented in KDChart::TernaryAxis.
Definition at line 123 of file KDChartAbstractArea.cpp.
References areaGeometry(), d, KDChart::AbstractAreaBase::innerRect(), KDChart::AbstractLayoutItem::paint(), KDChart::AbstractAreaBase::paintBackground(), and KDChart::AbstractAreaBase::paintFrame().
Referenced by paintIntoRect().
00124 { 00125 // Paint the background and frame 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 // temporarily adjust the widget size, to be sure all content gets calculated 00135 // to fit into the inner rectangle 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 //qDebug() << "AbstractAreaWidget::paintAll() done."; 00148 }
void AbstractAreaBase::paintBackground | ( | QPainter & | painter, | |
const QRect & | rectangle | |||
) | [virtual, inherited] |
Definition at line 196 of file KDChartAbstractAreaBase.cpp.
References d, and KDChart::AbstractAreaBase::paintBackgroundAttributes().
Referenced by KDChart::TextArea::paintAll(), KDChart::AbstractAreaWidget::paintAll(), and paintAll().
00197 { 00198 Q_ASSERT_X ( d != 0, "AbstractAreaBase::paintBackground()", 00199 "Private class was not initialized!" ); 00200 paintBackgroundAttributes( painter, rect, d->backgroundAttributes ); 00201 }
void AbstractAreaBase::paintBackgroundAttributes | ( | QPainter & | painter, | |
const QRect & | rectangle, | |||
const KDChart::BackgroundAttributes & | attributes | |||
) | [static, inherited] |
Definition at line 127 of file KDChartAbstractAreaBase.cpp.
References KDChart::BackgroundAttributes::BackgroundPixmapModeCentered, KDChart::BackgroundAttributes::BackgroundPixmapModeNone, KDChart::BackgroundAttributes::BackgroundPixmapModeScaled, KDChart::BackgroundAttributes::BackgroundPixmapModeStretched, KDChart::BackgroundAttributes::brush(), KDChart::BackgroundAttributes::isVisible(), KDChart::BackgroundAttributes::pixmap(), and KDChart::BackgroundAttributes::pixmapMode().
Referenced by KDChart::AbstractAreaBase::paintBackground().
00129 { 00130 if( !attributes.isVisible() ) return; 00131 00132 /* first draw the brush (may contain a pixmap)*/ 00133 if( Qt::NoBrush != attributes.brush().style() ) { 00134 KDChart::PainterSaver painterSaver( &painter ); 00135 painter.setPen( Qt::NoPen ); 00136 const QPointF newTopLeft( painter.deviceMatrix().map( rect.topLeft() ) ); 00137 painter.setBrushOrigin( newTopLeft ); 00138 painter.setBrush( attributes.brush() ); 00139 painter.drawRect( rect.adjusted( 0, 0, -1, -1 ) ); 00140 } 00141 /* next draw the backPixmap over the brush */ 00142 if( !attributes.pixmap().isNull() && 00143 attributes.pixmapMode() != BackgroundAttributes::BackgroundPixmapModeNone ) { 00144 QPointF ol = rect.topLeft(); 00145 if( BackgroundAttributes::BackgroundPixmapModeCentered == attributes.pixmapMode() ) 00146 { 00147 ol.setX( rect.center().x() - attributes.pixmap().width() / 2 ); 00148 ol.setY( rect.center().y() - attributes.pixmap().height()/ 2 ); 00149 painter.drawPixmap( ol, attributes.pixmap() ); 00150 } else { 00151 QMatrix m; 00152 double zW = (double)rect.width() / (double)attributes.pixmap().width(); 00153 double zH = (double)rect.height() / (double)attributes.pixmap().height(); 00154 switch( attributes.pixmapMode() ) { 00155 case BackgroundAttributes::BackgroundPixmapModeScaled: 00156 { 00157 double z; 00158 z = qMin( zW, zH ); 00159 m.scale( z, z ); 00160 } 00161 break; 00162 case BackgroundAttributes::BackgroundPixmapModeStretched: 00163 m.scale( zW, zH ); 00164 break; 00165 default: 00166 ; // Cannot happen, previously checked 00167 } 00168 QPixmap pm = attributes.pixmap().transformed( m ); 00169 ol.setX( rect.center().x() - pm.width() / 2 ); 00170 ol.setY( rect.center().y() - pm.height()/ 2 ); 00171 painter.drawPixmap( ol, pm ); 00172 } 00173 } 00174 }
void KDChart::AbstractLayoutItem::paintCtx | ( | PaintContext * | context | ) | [virtual, inherited] |
Default impl: Paint the complete item using its layouted position and size.
Reimplemented in KDChart::CartesianAxis, and KDChart::TernaryAxis.
Definition at line 77 of file KDChartLayoutItems.cpp.
References KDChart::AbstractLayoutItem::paint(), and KDChart::PaintContext::painter().
00078 { 00079 if( context ) 00080 paint( context->painter() ); 00081 }
void AbstractAreaBase::paintFrame | ( | QPainter & | painter, | |
const QRect & | rectangle | |||
) | [virtual, inherited] |
Definition at line 204 of file KDChartAbstractAreaBase.cpp.
References d, and KDChart::AbstractAreaBase::paintFrameAttributes().
Referenced by KDChart::TextArea::paintAll(), KDChart::AbstractAreaWidget::paintAll(), and paintAll().
00205 { 00206 Q_ASSERT_X ( d != 0, "AbstractAreaBase::paintFrame()", 00207 "Private class was not initialized!" ); 00208 paintFrameAttributes( painter, rect, d->frameAttributes ); 00209 }
void AbstractAreaBase::paintFrameAttributes | ( | QPainter & | painter, | |
const QRect & | rectangle, | |||
const KDChart::FrameAttributes & | attributes | |||
) | [static, inherited] |
Definition at line 177 of file KDChartAbstractAreaBase.cpp.
References KDChart::FrameAttributes::isVisible(), and KDChart::FrameAttributes::pen().
Referenced by KDChart::AbstractAreaBase::paintFrame().
00179 { 00180 00181 if( !attributes.isVisible() ) return; 00182 00183 // Note: We set the brush to NoBrush explicitely here. 00184 // Otherwise we might get a filled rectangle, so any 00185 // previously drawn background would be overwritten by that area. 00186 00187 const QPen oldPen( painter.pen() ); 00188 const QBrush oldBrush( painter.brush() ); 00189 painter.setPen( attributes.pen() ); 00190 painter.setBrush( Qt::NoBrush ); 00191 painter.drawRect( rect.adjusted( 0, 0, -1, -1 ) ); 00192 painter.setBrush( oldBrush ); 00193 painter.setPen( oldPen ); 00194 }
void AbstractArea::paintIntoRect | ( | QPainter & | painter, | |
const QRect & | rect | |||
) | [virtual] |
Draws the background and frame, then calls paint().
In most cases there is no need to overwrite this method in a derived class, but you would overwrite AbstractLayoutItem::paint() instead.
Definition at line 111 of file KDChartAbstractArea.cpp.
References paintAll().
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 }
QLayout* KDChart::AbstractLayoutItem::parentLayout | ( | ) | [inherited] |
void KDChart::AbstractArea::positionChanged | ( | AbstractArea * | ) | [signal] |
Referenced by positionHasChanged().
void AbstractArea::positionHasChanged | ( | ) | [protected, virtual] |
Reimplemented from KDChart::AbstractAreaBase.
Definition at line 155 of file KDChartAbstractArea.cpp.
References positionChanged().
00156 { 00157 emit positionChanged( this ); 00158 }
void KDChart::AbstractLayoutItem::removeFromParentLayout | ( | ) | [inherited] |
Definition at line 80 of file KDChartLayoutItems.h.
Referenced by KDChart::Chart::takeCoordinatePlane().
00081 { 00082 if( mParentLayout ){ 00083 if( widget() ) 00084 mParentLayout->removeWidget( widget() ); 00085 else 00086 mParentLayout->removeItem( this ); 00087 } 00088 }
int AbstractArea::rightOverlap | ( | bool | doNotRecalculate = false |
) | const [virtual] |
This is called at layout time by KDChart::AutoSpacerLayoutItem::sizeHint().
The method triggers AbstractArea::sizeHint() to find out the amount of overlap at the right edge of the area.
Definition at line 85 of file KDChartAbstractArea.cpp.
References d.
Referenced by KDChart::CartesianAxis::maximumSize().
00086 { 00087 // Re-calculate the sizes, 00088 // so we also get the amountOf..Overlap members set newly: 00089 if( ! doNotRecalculate ) 00090 sizeHint(); 00091 return d->amountOfRightOverlap; 00092 }
void AbstractAreaBase::setBackgroundAttributes | ( | const BackgroundAttributes & | a | ) | [inherited] |
Definition at line 111 of file KDChartAbstractAreaBase.cpp.
References d, and KDChart::AbstractAreaBase::positionHasChanged().
00112 { 00113 if( d->backgroundAttributes == a ) 00114 return; 00115 00116 d->backgroundAttributes = a; 00117 positionHasChanged(); 00118 }
void AbstractAreaBase::setFrameAttributes | ( | const FrameAttributes & | a | ) | [inherited] |
Definition at line 97 of file KDChartAbstractAreaBase.cpp.
References d, and KDChart::AbstractAreaBase::positionHasChanged().
Referenced by KDChart::Legend::clone().
00098 { 00099 if( d->frameAttributes == a ) 00100 return; 00101 00102 d->frameAttributes = a; 00103 positionHasChanged(); 00104 }
void KDChart::AbstractLayoutItem::setParentLayout | ( | QLayout * | lay | ) | [inherited] |
void KDChart::AbstractLayoutItem::setParentWidget | ( | QWidget * | widget | ) | [virtual, inherited] |
Inform the item about its widget: This enables the item, to trigger that widget's update, whenever the size of the item's contents has changed.
Thus, you need to call setParentWidget on every item, that has a non-fixed size.
Definition at line 64 of file KDChartLayoutItems.cpp.
References KDChart::AbstractLayoutItem::mParent.
Referenced by KDChart::HeaderFooter::setParent(), and KDChart::AbstractCartesianDiagram::takeAxis().
00065 { 00066 mParent = widget; 00067 }
void KDChart::AbstractLayoutItem::sizeHintChanged | ( | ) | const [virtual, inherited] |
Report changed size hint: ask the parent widget to recalculate the layout.
Definition at line 86 of file KDChartLayoutItems.cpp.
References KDChart::AbstractLayoutItem::mParent.
Referenced by KDChart::TextLayoutItem::sizeHint().
00087 { 00088 // This is exactly like what QWidget::updateGeometry does. 00089 // qDebug("KDChart::AbstractLayoutItem::sizeHintChanged() called"); 00090 if( mParent ) { 00091 if ( mParent->layout() ) 00092 mParent->layout()->invalidate(); 00093 else 00094 QApplication::postEvent( mParent, new QEvent( QEvent::LayoutRequest ) ); 00095 } 00096 }
int AbstractArea::topOverlap | ( | bool | doNotRecalculate = false |
) | const [virtual] |
This is called at layout time by KDChart::AutoSpacerLayoutItem::sizeHint().
The method triggers AbstractArea::sizeHint() to find out the amount of overlap at the top edge of the area.
Definition at line 93 of file KDChartAbstractArea.cpp.
References d.
Referenced by KDChart::CartesianAxis::maximumSize().
00094 { 00095 // Re-calculate the sizes, 00096 // so we also get the amountOf..Overlap members set newly: 00097 if( ! doNotRecalculate ) 00098 sizeHint(); 00099 return d->amountOfTopOverlap; 00100 }
QWidget* KDChart::AbstractLayoutItem::mParent [protected, inherited] |
Definition at line 90 of file KDChartLayoutItems.h.
Referenced by KDChart::AbstractLayoutItem::setParentWidget(), KDChart::TextLayoutItem::setText(), KDChart::TextLayoutItem::setTextAttributes(), and KDChart::AbstractLayoutItem::sizeHintChanged().
QLayout* KDChart::AbstractLayoutItem::mParentLayout [protected, inherited] |
Definition at line 91 of file KDChartLayoutItems.h.
Referenced by KDChart::AutoSpacerLayoutItem::paint().