KDChart::HeaderFooter Class Reference

#include <KDChartHeaderFooter.h>

Inheritance diagram for KDChart::HeaderFooter:

Inheritance graph
[legend]
Collaboration diagram for KDChart::HeaderFooter:

Collaboration graph
[legend]

List of all members.


Detailed Description

A header or even footer displaying text above or below charts.

Definition at line 44 of file KDChartHeaderFooter.h.


Public Types

enum  HeaderFooterType {
  Header,
  Footer
}

Signals

void destroyedHeaderFooter (HeaderFooter *)
void positionChanged (TextArea *)
void positionChanged (HeaderFooter *)

Public Member Functions

void alignToReferencePoint (const RelativePosition &position)
const QObjectautoReferenceArea () const
BackgroundAttributes backgroundAttributes () const
virtual HeaderFooterclone () const
 Creates an exact copy of this header/footer.
bool compare (const AbstractAreaBase *other) const
 Returns true if both areas have the same settings.
bool compare (const HeaderFooter &other) const
virtual Qt::Orientations expandingDirections () const
 pure virtual in QLayoutItem
FrameAttributes frameAttributes () const
virtual QRect geometry () const
 pure virtual in QLayoutItem
void getFrameLeadings (int &left, int &top, int &right, int &bottom) const
 HeaderFooter (Chart *parent=0)
virtual bool intersects (const TextLayoutItem &other, const QPoint &myPos, const QPoint &otherPos) const
virtual bool intersects (const TextLayoutItem &other, const QPointF &myPos, const QPointF &otherPos) const
virtual bool isEmpty () const
 pure virtual in QLayoutItem
virtual QSize maximumSize () const
 pure virtual in QLayoutItem
virtual QSize minimumSize () const
 pure virtual in QLayoutItem
virtual void paint (QPainter *)
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 ()
Position position () const
virtual QFont realFont () const
virtual qreal realFontSize () const
void removeFromParentLayout ()
void setAutoReferenceArea (const QObject *area)
void setBackgroundAttributes (const BackgroundAttributes &a)
void setFrameAttributes (const FrameAttributes &a)
virtual void setGeometry (const QRect &r)
 pure virtual in QLayoutItem
void setParent (QObject *parent)
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.
void setPosition (Position position)
void setText (const QString &text)
void setTextAlignment (Qt::Alignment)
void setTextAttributes (const TextAttributes &a)
 Use this to specify the text attributes to be used for this item.
void setType (HeaderFooterType type)
virtual QSize sizeHint () const
 pure virtual in QLayoutItem
virtual QSize sizeHintAndRotatedCorners (QPoint &topLeftPt, QPoint &topRightPt, QPoint &bottomRightPt, QPoint &bottomLeftPt) const
virtual void sizeHintChanged () const
 Report changed size hint: ask the parent widget to recalculate the layout.
virtual QSize sizeHintUnrotated () const
QString text () const
Qt::Alignment textAlignment () const
TextAttributes textAttributes () const
 Returns the text attributes to be used for this item.
HeaderFooterType type () const
virtual ~HeaderFooter ()

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

virtual QRect areaGeometry () const
QRect innerRect () const
virtual void positionHasChanged ()

Protected Attributes

QWidgetmParent
QLayout * mParentLayout

Member Enumeration Documentation

enum KDChart::HeaderFooter::HeaderFooterType

Enumerator:
Header 
Footer 

Definition at line 59 of file KDChartHeaderFooter.h.

00059                          { Header,
00060                            Footer };


Constructor & Destructor Documentation

HeaderFooter::HeaderFooter ( Chart parent = 0  ) 

Definition at line 56 of file KDChartHeaderFooter.cpp.

References StockDiagram::init(), and setParent().

Referenced by clone().

00056                                           :
00057     TextArea( new Private() )
00058 {
00059     setParent( parent );
00060     init();
00061 }

HeaderFooter::~HeaderFooter (  )  [virtual]

Definition at line 63 of file KDChartHeaderFooter.cpp.

References destroyedHeaderFooter().

00064 {
00065     emit destroyedHeaderFooter( this );
00066 }


Member Function Documentation

void AbstractAreaBase::alignToReferencePoint ( const RelativePosition position  )  [inherited]

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 }

QRect TextArea::areaGeometry (  )  const [protected, virtual, inherited]

Implements KDChart::AbstractAreaBase.

Definition at line 105 of file KDChartTextArea.cpp.

References KDChart::TextLayoutItem::geometry().

Referenced by KDChart::TextArea::paintAll().

00106 {
00107     return geometry();
00108 }

const QObject * KDChart::TextLayoutItem::autoReferenceArea (  )  const [inherited]

Definition at line 245 of file KDChartLayoutItems.cpp.

Referenced by KDChart::TextBubbleLayoutItem::autoReferenceArea(), compare(), and setParent().

00246 {
00247     return mAutoReferenceArea;
00248 }

BackgroundAttributes AbstractAreaBase::backgroundAttributes (  )  const [inherited]

Definition at line 121 of file KDChartAbstractAreaBase.cpp.

References d.

Referenced by KDChart::AbstractAreaBase::compare(), and updateCommonBrush().

00122 {
00123     return d->backgroundAttributes;
00124 }

HeaderFooter * HeaderFooter::clone (  )  const [virtual]

Creates an exact copy of this header/footer.

Definition at line 96 of file KDChartHeaderFooter.cpp.

References d, HeaderFooter(), position(), StockDiagram::Private::Private(), setPosition(), KDChart::TextLayoutItem::setText(), KDChart::TextLayoutItem::setTextAttributes(), setType(), KDChart::TextLayoutItem::text(), KDChart::TextLayoutItem::textAttributes(), and type().

00097 {
00098     HeaderFooter* headerFooter = new HeaderFooter( new Private( *d ), 0 );
00099     headerFooter->setType( type() );
00100     headerFooter->setPosition( position() );
00101     headerFooter->setText( text() );
00102     headerFooter->setTextAttributes( textAttributes() );
00103     return headerFooter;
00104 }

bool AbstractAreaBase::compare ( const AbstractAreaBase other  )  const [inherited]

Returns true if both areas have the same settings.

Definition at line 76 of file KDChartAbstractAreaBase.cpp.

References KDChart::AbstractAreaBase::backgroundAttributes(), and KDChart::AbstractAreaBase::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 }

bool HeaderFooter::compare ( const HeaderFooter other  )  const

Definition at line 106 of file KDChartHeaderFooter.cpp.

References KDChart::TextLayoutItem::autoReferenceArea(), position(), KDChart::TextLayoutItem::text(), KDChart::TextLayoutItem::textAttributes(), and type().

00107 {
00108     return  (type()           == other.type()) &&
00109             (position()       == other.position()) &&
00110             // also compare members inherited from the base class:
00111             (autoReferenceArea() == other.autoReferenceArea()) &&
00112             (text()              == other.text()) &&
00113             (textAttributes()    == other.textAttributes());
00114 }

void KDChart::HeaderFooter::destroyedHeaderFooter ( HeaderFooter  )  [signal]

Referenced by ~HeaderFooter().

Qt::Orientations KDChart::TextLayoutItem::expandingDirections (  )  const [virtual, inherited]

pure virtual in QLayoutItem

Definition at line 304 of file KDChartLayoutItems.cpp.

Referenced by KDChart::TextBubbleLayoutItem::expandingDirections().

00305 {
00306     return 0; // Grow neither vertically nor horizontally
00307 }

FrameAttributes AbstractAreaBase::frameAttributes (  )  const [inherited]

Definition at line 107 of file KDChartAbstractAreaBase.cpp.

References d.

Referenced by KDChart::Legend::clone(), KDChart::AbstractAreaBase::compare(), and updateCommonBrush().

00108 {
00109     return d->frameAttributes;
00110 }

QRect KDChart::TextLayoutItem::geometry (  )  const [virtual, inherited]

pure virtual in QLayoutItem

Definition at line 309 of file KDChartLayoutItems.cpp.

Referenced by KDChart::TextArea::areaGeometry(), KDChart::TextBubbleLayoutItem::geometry(), KDChart::TextLayoutItem::paint(), KDChart::TextArea::paintAll(), KDChart::CartesianAxis::paintCtx(), and KDChart::TextArea::paintIntoRect().

00310 {
00311     return mRect;
00312 }

void AbstractAreaBase::getFrameLeadings ( int &  left,
int &  top,
int &  right,
int &  bottom 
) const [inherited]

Definition at line 213 of file KDChartAbstractAreaBase.cpp.

References d.

Referenced by KDChart::AbstractAreaBase::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, inherited]

Definition at line 229 of file KDChartAbstractAreaBase.cpp.

References KDChart::AbstractAreaBase::areaGeometry(), and KDChart::AbstractAreaBase::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 }

bool KDChart::TextLayoutItem::intersects ( const TextLayoutItem other,
const QPoint &  myPos,
const QPoint &  otherPos 
) const [virtual, inherited]

Definition at line 470 of file KDChartLayoutItems.cpp.

References KDChart::TextLayoutItem::mAttributes, PI, r, KDChart::TextLayoutItem::rotatedCorners(), KDChart::TextAttributes::rotation(), and KDChart::TextLayoutItem::unrotatedSizeHint().

00471 {
00472     if ( mAttributes.rotation() != other.mAttributes.rotation() )
00473     {
00474         // that's the code for the common case: the rotation angles don't need to match here
00475         QPolygon myPolygon(          rotatedCorners() );
00476         QPolygon otherPolygon( other.rotatedCorners() );
00477 
00478         // move the polygons to their positions
00479         myPolygon.translate( myPos );
00480         otherPolygon.translate( otherPos );
00481 
00482         // create regions out of it
00483         QRegion myRegion( myPolygon );
00484         QRegion otherRegion( otherPolygon );
00485 
00486         // now the question - do they intersect or not?
00487         return ! myRegion.intersect( otherRegion ).isEmpty();
00488 
00489     } else {
00490         // and that's the code for the special case: the rotation angles match, which is less time consuming in calculation
00491         const qreal angle = mAttributes.rotation() * PI / 180.0;
00492         // both sizes
00493         const QSizeF mySize(          unrotatedSizeHint() );
00494         const QSizeF otherSize( other.unrotatedSizeHint() );
00495 
00496         // that's myP1 relative to myPos
00497         QPointF myP1( mySize.height() * sin( angle ), 0.0 );
00498         // that's otherP1 to myPos
00499         QPointF otherP1 = QPointF( otherSize.height() * sin( angle ), 0.0 ) + otherPos - myPos;
00500 
00501         // now rotate both points the negative angle around myPos
00502         myP1 = QPointF( myP1.x() * cos( -angle ), myP1.x() * sin( -angle ) );
00503         qreal r = sqrt( otherP1.x() * otherP1.x() + otherP1.y() * otherP1.y() );
00504         otherP1 = QPointF( r * cos( -angle ), r * sin( -angle ) );
00505 
00506         // finally we look, whether both rectangles intersect or even not
00507         const bool res = QRectF( myP1, mySize ).intersects( QRectF( otherP1, otherSize ) );
00508         //qDebug() << res << QRectF( myP1, mySize ) << QRectF( otherP1, otherSize );
00509         return res;
00510     }
00511 }

bool KDChart::TextLayoutItem::intersects ( const TextLayoutItem other,
const QPointF &  myPos,
const QPointF &  otherPos 
) const [virtual, inherited]

Definition at line 465 of file KDChartLayoutItems.cpp.

Referenced by KDChart::CartesianAxis::paintCtx().

00466 {
00467     return intersects( other, myPos.toPoint(), otherPos.toPoint() );
00468 }

bool KDChart::TextLayoutItem::isEmpty (  )  const [virtual, inherited]

pure virtual in QLayoutItem

Definition at line 314 of file KDChartLayoutItems.cpp.

Referenced by KDChart::TextBubbleLayoutItem::isEmpty().

00315 {
00316     return false; // never empty, otherwise the layout item would not exist
00317 }

QSize KDChart::TextLayoutItem::maximumSize (  )  const [virtual, inherited]

pure virtual in QLayoutItem

Definition at line 319 of file KDChartLayoutItems.cpp.

References KDChart::TextLayoutItem::sizeHint().

Referenced by KDChart::TextBubbleLayoutItem::maximumSize().

00320 {
00321     return sizeHint(); // PENDING(kalle) Review, quite inflexible
00322 }

QSize KDChart::TextLayoutItem::minimumSize (  )  const [virtual, inherited]

pure virtual in QLayoutItem

Definition at line 324 of file KDChartLayoutItems.cpp.

References KDChart::TextLayoutItem::sizeHint().

Referenced by KDChart::TextBubbleLayoutItem::minimumSize().

00325 {
00326     return sizeHint(); // PENDING(kalle) Review, quite inflexible
00327 }

void KDChart::TextLayoutItem::paint ( QPainter *  painter  )  [virtual, inherited]

Implements KDChart::AbstractLayoutItem.

Definition at line 618 of file KDChartLayoutItems.cpp.

References KDChart::TextAttributes::autoShrink(), KDChart::TextLayoutItem::geometry(), KDChart::TextAttributes::pen(), KDChart::TextLayoutItem::realFont(), rotatedRect(), KDChart::TextAttributes::rotation(), and KDChart::PrintingParameters::scalePen().

Referenced by KDChart::TextBubbleLayoutItem::paint(), KDChart::TextArea::paintAll(), and KDChart::CartesianAxis::paintCtx().

00619 {
00620     // make sure, cached font is updated, if needed:
00621     // sizeHint();
00622 
00623     if( !mRect.isValid() )
00624         return;
00625 
00626     const PainterSaver painterSaver( painter );
00627     QFont f = realFont();
00628     if ( mAttributes.autoShrink() )
00629         f.setPointSizeF( fitFontSizeToGeometry() );
00630     painter->setFont( f );
00631     QRectF rect( geometry() );
00632 
00633 // #ifdef DEBUG_ITEMS_PAINT
00634 //     painter->setPen( Qt::black );
00635 //     painter->drawRect( rect );
00636 // #endif
00637     painter->translate( rect.center() );
00638     rect.moveTopLeft( QPointF( - rect.width() / 2, - rect.height() / 2 ) );
00639 #ifdef DEBUG_ITEMS_PAINT
00640     painter->setPen( Qt::blue );
00641     painter->drawRect( rect );
00642     painter->drawRect( QRect(QPoint((rect.topLeft().toPoint()  + rect.bottomLeft().toPoint())  / 2 - QPoint(2,2)), QSize(3,3)) );
00643     //painter->drawRect( QRect(QPoint((rect.topRight().toPoint() + rect.bottomRight().toPoint()) / 2 - QPoint(2,2)), QSize(3,3)) );
00644 #endif
00645     painter->rotate( mAttributes.rotation() );
00646     rect = rotatedRect( rect, mAttributes.rotation() );
00647 #ifdef DEBUG_ITEMS_PAINT
00648     painter->setPen( Qt::red );
00649     painter->drawRect( rect );
00650     painter->drawRect( QRect(QPoint((rect.topLeft().toPoint()  + rect.bottomLeft().toPoint())  / 2 - QPoint(2,2)), QSize(3,3)) );
00651     //painter->drawRect( QRect(QPoint((rect.topRight().toPoint() + rect.bottomRight().toPoint()) / 2 - QPoint(2,2)), QSize(3,3)) );
00652 #endif
00653     painter->setPen( PrintingParameters::scalePen( mAttributes.pen() ) );
00654     QFontMetrics fontMetrics( f );
00655     const int AHight = fontMetrics.boundingRect( QChar::fromAscii( 'A' ) ).height();
00656     const qreal AVCenter = fontMetrics.ascent() - AHight / 2.0;
00657     // Make sure that capital letters are vertically centered. This looks much
00658     // better than just centering the text's bounding rect.
00659     rect.translate( 0.0, rect.height() / 2.0 - AVCenter );
00660     //painter->drawText( rect, Qt::AlignHCenter | Qt::AlignTop, mText );
00661     painter->drawText( rect, mTextAlignment, mText );
00662 
00663 //    if (  calcSizeHint( realFont() ).width() > rect.width() )
00664 //        qDebug() << "rect.width()" << rect.width() << "text.width()" << calcSizeHint( realFont() ).width();
00665 //
00666 //    //painter->drawText( rect, Qt::AlignHCenter | Qt::AlignVCenter, mText );
00667 }

void TextArea::paintAll ( QPainter &  painter  )  [virtual, inherited]

Call paintAll, if you want the background and the frame to be drawn before the normal paint() is invoked automatically.

Reimplemented from KDChart::AbstractLayoutItem.

Definition at line 83 of file KDChartTextArea.cpp.

References KDChart::TextArea::areaGeometry(), KDChart::TextLayoutItem::geometry(), KDChart::AbstractAreaBase::innerRect(), KDChart::TextLayoutItem::paint(), KDChart::AbstractAreaBase::paintBackground(), KDChart::AbstractAreaBase::paintFrame(), and KDChart::TextLayoutItem::setGeometry().

Referenced by KDChart::TextArea::paintIntoRect().

00084 {
00085     // Paint the background and frame
00086     paintBackground( painter, geometry() );
00087     paintFrame(      painter, geometry() );
00088 
00089     // temporarily adjust the widget size, to be sure all content gets calculated
00090     // to fit into the inner rectangle
00091     const QRect oldGeometry( areaGeometry()  );
00092     QRect inner( innerRect() );
00093     inner.moveTo(
00094         oldGeometry.left() + inner.left(),
00095         oldGeometry.top()  + inner.top() );
00096     const bool needAdjustGeometry = oldGeometry != inner;
00097     if( needAdjustGeometry )
00098         setGeometry( inner );
00099     paint( &painter );
00100     if( needAdjustGeometry )
00101         setGeometry( oldGeometry );
00102     //qDebug() << "TextAreaWidget::paintAll() done.";
00103 }

void AbstractAreaBase::paintBackground ( QPainter &  painter,
const QRect &  rectangle 
) [virtual, inherited]

Definition at line 197 of file KDChartAbstractAreaBase.cpp.

References d, and KDChart::AbstractAreaBase::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, inherited]

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 KDChart::AbstractAreaBase::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 KDChart::AbstractLayoutItem::paintCtx ( PaintContext context  )  [virtual, inherited]

Default impl: Paint the complete item using its layouted position and size.

Reimplemented in KDChart::CartesianAxis, KDChart::LeveyJenningsAxis, and KDChart::TernaryAxis.

Definition at line 78 of file KDChartLayoutItems.cpp.

References KDChart::AbstractLayoutItem::paint(), and KDChart::PaintContext::painter().

00079 {
00080     if( context )
00081         paint( context->painter() );
00082 }

void AbstractAreaBase::paintFrame ( QPainter &  painter,
const QRect &  rectangle 
) [virtual, inherited]

Definition at line 205 of file KDChartAbstractAreaBase.cpp.

References d, and KDChart::AbstractAreaBase::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, inherited]

Definition at line 178 of file KDChartAbstractAreaBase.cpp.

References KDChart::FrameAttributes::isVisible(), KDChart::FrameAttributes::pen(), and KDChart::PrintingParameters::scalePen().

Referenced by KDChart::AbstractAreaBase::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 TextArea::paintIntoRect ( QPainter &  painter,
const QRect &  rect 
) [virtual, inherited]

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 TextLayoutItem::paint() instead.

Definition at line 71 of file KDChartTextArea.cpp.

References KDChart::TextLayoutItem::geometry(), KDChart::TextArea::paintAll(), and KDChart::TextLayoutItem::setGeometry().

00072 {
00073     const QRect oldGeometry( geometry() );
00074     if( oldGeometry != rect )
00075         setGeometry( rect );
00076     painter.translate( rect.left(), rect.top() );
00077     paintAll( painter );
00078     painter.translate( -rect.left(), -rect.top() );
00079     if( oldGeometry != rect )
00080         setGeometry( oldGeometry );
00081 }

QLayout* KDChart::AbstractLayoutItem::parentLayout (  )  [inherited]

Definition at line 79 of file KDChartLayoutItems.h.

00080         {
00081             return mParentLayout;
00082         }

Position HeaderFooter::position (  )  const

Definition at line 133 of file KDChartHeaderFooter.cpp.

References d.

Referenced by clone(), and compare().

00134 {
00135     return d->position;
00136 }

void KDChart::TextArea::positionChanged ( TextArea  )  [signal, inherited]

Referenced by KDChart::TextArea::positionHasChanged().

void KDChart::HeaderFooter::positionChanged ( HeaderFooter  )  [signal]

Referenced by setPosition(), and setType().

void TextArea::positionHasChanged (  )  [protected, virtual, inherited]

Reimplemented from KDChart::AbstractAreaBase.

Definition at line 110 of file KDChartTextArea.cpp.

References KDChart::TextArea::positionChanged().

00111 {
00112     emit positionChanged( this );
00113 }

QFont KDChart::TextLayoutItem::realFont (  )  const [virtual, inherited]

Definition at line 442 of file KDChartLayoutItems.cpp.

Referenced by KDChart::TextLayoutItem::paint(), and KDChart::CartesianAxis::paintCtx().

00443 {
00444     realFontWasRecalculated(); // we can safely ignore the boolean return value
00445     return cachedFont;
00446 }

qreal KDChart::TextLayoutItem::realFontSize (  )  const [virtual, inherited]

Definition at line 422 of file KDChartLayoutItems.cpp.

References KDChart::TextAttributes::calculatedFontSize().

00423 {
00424     return mAttributes.calculatedFontSize( mAutoReferenceArea, mAutoReferenceOrientation );
00425 }

void KDChart::AbstractLayoutItem::removeFromParentLayout (  )  [inherited]

Definition at line 83 of file KDChartLayoutItems.h.

Referenced by KDChart::Chart::takeCoordinatePlane().

00084         {
00085             if( mParentLayout ){
00086                 if( widget() )
00087                     mParentLayout->removeWidget( widget() );
00088                 else
00089                     mParentLayout->removeItem( this );
00090             }
00091         }

void KDChart::TextLayoutItem::setAutoReferenceArea ( const QObject area  )  [inherited]

Definition at line 238 of file KDChartLayoutItems.cpp.

References KDChart::TextLayoutItem::sizeHint().

Referenced by KDChart::TextBubbleLayoutItem::setAutoReferenceArea(), and setParent().

00239 {
00240     mAutoReferenceArea = area;
00241     cachedSizeHint = QSize();
00242     sizeHint();
00243 }

void AbstractAreaBase::setBackgroundAttributes ( const BackgroundAttributes a  )  [inherited]

Definition at line 112 of file KDChartAbstractAreaBase.cpp.

References d, and KDChart::AbstractAreaBase::positionHasChanged().

00113 {
00114     if( d->backgroundAttributes == a )
00115         return;
00116 
00117     d->backgroundAttributes = a;
00118     positionHasChanged();
00119 }

void AbstractAreaBase::setFrameAttributes ( const FrameAttributes a  )  [inherited]

Definition at line 98 of file KDChartAbstractAreaBase.cpp.

References d, and KDChart::AbstractAreaBase::positionHasChanged().

Referenced by KDChart::Legend::clone().

00099 {
00100     if( d->frameAttributes == a )
00101         return;
00102 
00103     d->frameAttributes = a;
00104     positionHasChanged();
00105 }

void KDChart::TextLayoutItem::setGeometry ( const QRect &  r  )  [virtual, inherited]

pure virtual in QLayoutItem

Definition at line 329 of file KDChartLayoutItems.cpp.

Referenced by KDChart::TextArea::paintAll(), KDChart::CartesianAxis::paintCtx(), KDChart::TextArea::paintIntoRect(), and KDChart::TextBubbleLayoutItem::setGeometry().

00330 {
00331     mRect = r;
00332 }

void HeaderFooter::setParent ( QObject parent  ) 

Definition at line 68 of file KDChartHeaderFooter.cpp.

References KDChart::TextLayoutItem::autoReferenceArea(), KDChart::TextLayoutItem::setAutoReferenceArea(), and KDChart::AbstractLayoutItem::setParentWidget().

Referenced by KDChart::Widget::addHeaderFooter(), KDChart::Chart::addHeaderFooter(), HeaderFooter(), KDChart::Widget::replaceHeaderFooter(), and KDChart::Chart::takeHeaderFooter().

00069 {
00070     QObject::setParent( parent );
00071     setParentWidget( qobject_cast<QWidget*>( parent ) );
00072     if( parent && ! autoReferenceArea() )
00073         setAutoReferenceArea( parent );
00074 }

void KDChart::AbstractLayoutItem::setParentLayout ( QLayout *  lay  )  [inherited]

Definition at line 75 of file KDChartLayoutItems.h.

00076         {
00077             mParentLayout = lay;
00078         }

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 65 of file KDChartLayoutItems.cpp.

References KDChart::AbstractLayoutItem::mParent.

Referenced by setParent(), and KDChart::AbstractCartesianDiagram::takeAxis().

00066 {
00067     mParent = widget;
00068 }

void HeaderFooter::setPosition ( Position  position  ) 

Definition at line 127 of file KDChartHeaderFooter.cpp.

References d, and positionChanged().

Referenced by KDChart::Widget::addHeaderFooter(), and clone().

00128 {
00129     d->position = position;
00130     emit positionChanged( this );
00131 }

void KDChart::TextLayoutItem::setText ( const QString &  text  )  [inherited]

Definition at line 250 of file KDChartLayoutItems.cpp.

References KDChart::AbstractLayoutItem::mParent, and KDChart::TextLayoutItem::sizeHint().

Referenced by KDChart::Widget::addHeaderFooter(), clone(), KDChart::CartesianAxis::paintCtx(), and KDChart::TextBubbleLayoutItem::setText().

00251 {
00252     mText = text;
00253     cachedSizeHint = QSize();
00254     sizeHint();
00255     if( mParent )
00256         mParent->update();
00257 }

void KDChart::TextLayoutItem::setTextAlignment ( Qt::Alignment  alignment  )  [inherited]

Definition at line 264 of file KDChartLayoutItems.cpp.

References KDChart::AbstractLayoutItem::mParent.

00265 {
00266     if( mTextAlignment == alignment )
00267         return;
00268     mTextAlignment = alignment;
00269     if( mParent )
00270         mParent->update();
00271 }

void KDChart::TextLayoutItem::setTextAttributes ( const TextAttributes a  )  [inherited]

Use this to specify the text attributes to be used for this item.

See also:
textAttributes

Definition at line 283 of file KDChartLayoutItems.cpp.

References KDChart::TextAttributes::font(), KDChart::AbstractLayoutItem::mParent, and KDChart::TextLayoutItem::sizeHint().

Referenced by clone(), and KDChart::TextBubbleLayoutItem::setTextAttributes().

00284 {
00285     mAttributes = a;
00286     cachedFont = a.font();
00287     cachedSizeHint = QSize(); // invalidate size hint
00288     sizeHint();
00289     if( mParent )
00290         mParent->update();
00291 }

void HeaderFooter::setType ( HeaderFooterType  type  ) 

Definition at line 116 of file KDChartHeaderFooter.cpp.

References d, and positionChanged().

Referenced by KDChart::Widget::addHeaderFooter(), and clone().

00117 {
00118     d->type = type;
00119     emit positionChanged( this );
00120 }

QSize KDChart::TextLayoutItem::sizeHint (  )  const [virtual, inherited]

pure virtual in QLayoutItem

Definition at line 513 of file KDChartLayoutItems.cpp.

References KDChart::TextLayoutItem::sizeHintAndRotatedCorners().

Referenced by KDChart::TextLayoutItem::maximumSize(), KDChart::TextLayoutItem::minimumSize(), KDChart::CartesianAxis::paintCtx(), KDChart::TextLayoutItem::setAutoReferenceArea(), KDChart::TextLayoutItem::setText(), KDChart::TextLayoutItem::setTextAttributes(), and KDChart::TextBubbleLayoutItem::sizeHint().

00514 {
00515     QPoint dummy;
00516     return sizeHintAndRotatedCorners(dummy,dummy,dummy,dummy);
00517 }

QSize KDChart::TextLayoutItem::sizeHintAndRotatedCorners ( QPoint &  topLeftPt,
QPoint &  topRightPt,
QPoint &  bottomRightPt,
QPoint &  bottomLeftPt 
) const [virtual, inherited]

Definition at line 519 of file KDChartLayoutItems.cpp.

References KDChart::TextAttributes::rotation(), and KDChart::AbstractLayoutItem::sizeHintChanged().

Referenced by KDChart::CartesianAxis::paintCtx(), and KDChart::TextLayoutItem::sizeHint().

00521 {
00522     if( realFontWasRecalculated() || mAttributes.rotation() )
00523     {
00524         const QSize newSizeHint( calcSizeHint( cachedFont,
00525                                                topLeftPt, topRightPt, bottomRightPt, bottomLeftPt ) );
00526         if( newSizeHint != cachedSizeHint ){
00527             cachedSizeHint = newSizeHint;
00528             sizeHintChanged();
00529         }
00530         cachedTopLeft     = topLeftPt;
00531         cachedTopRight    = topRightPt;
00532         cachedBottomRight = bottomRightPt;
00533         cachedBottomLeft  = bottomLeftPt;
00534     }else{
00535         topLeftPt     = cachedTopLeft;
00536         topRightPt    = cachedTopRight;
00537         bottomRightPt = cachedBottomRight;
00538         bottomLeftPt  = cachedBottomLeft;
00539     }
00540     //qDebug() << "-------- KDChart::TextLayoutItem::sizeHint() returns:"<<cachedSizeHint<<" ----------";
00541     return cachedSizeHint;
00542 }

void KDChart::AbstractLayoutItem::sizeHintChanged (  )  const [virtual, inherited]

Report changed size hint: ask the parent widget to recalculate the layout.

Definition at line 87 of file KDChartLayoutItems.cpp.

References KDChart::AbstractLayoutItem::mParent.

Referenced by KDChart::TextLayoutItem::sizeHintAndRotatedCorners().

00088 {
00089     // This is exactly like what QWidget::updateGeometry does.
00090 //  qDebug("KDChart::AbstractLayoutItem::sizeHintChanged() called");
00091     if( mParent ) {
00092         if ( mParent->layout() )
00093             mParent->layout()->invalidate();
00094         else
00095             QApplication::postEvent( mParent, new QEvent( QEvent::LayoutRequest ) );
00096     }
00097 }

QSize KDChart::TextLayoutItem::sizeHintUnrotated (  )  const [virtual, inherited]

Definition at line 544 of file KDChartLayoutItems.cpp.

Referenced by KDChart::CartesianAxis::paintCtx().

00545 {
00546     realFontWasRecalculated(); // make sure the cached font is updated if needed
00547     return unrotatedSizeHint( cachedFont );
00548 }

QString KDChart::TextLayoutItem::text (  )  const [inherited]

Definition at line 259 of file KDChartLayoutItems.cpp.

Referenced by clone(), compare(), KDChart::CartesianAxis::paintCtx(), and KDChart::TextBubbleLayoutItem::text().

00260 {
00261     return mText;
00262 }

Qt::Alignment KDChart::TextLayoutItem::textAlignment (  )  const [inherited]

Definition at line 273 of file KDChartLayoutItems.cpp.

00274 {
00275     return mTextAlignment;
00276 }

KDChart::TextAttributes KDChart::TextLayoutItem::textAttributes (  )  const [inherited]

Returns the text attributes to be used for this item.

See also:
setTextAttributes

Definition at line 298 of file KDChartLayoutItems.cpp.

Referenced by clone(), compare(), and KDChart::TextBubbleLayoutItem::textAttributes().

00299 {
00300     return mAttributes;
00301 }

HeaderFooter::HeaderFooterType HeaderFooter::type (  )  const

Definition at line 122 of file KDChartHeaderFooter.cpp.

References d.

Referenced by clone(), and compare().

00123 {
00124     return d->type;
00125 }


Member Data Documentation

QWidget* KDChart::AbstractLayoutItem::mParent [protected, inherited]

Definition at line 93 of file KDChartLayoutItems.h.

Referenced by KDChart::AbstractLayoutItem::setParentWidget(), KDChart::TextLayoutItem::setText(), KDChart::TextLayoutItem::setTextAlignment(), KDChart::TextLayoutItem::setTextAttributes(), and KDChart::AbstractLayoutItem::sizeHintChanged().

QLayout* KDChart::AbstractLayoutItem::mParentLayout [protected, inherited]

Definition at line 94 of file KDChartLayoutItems.h.

Referenced by KDChart::AutoSpacerLayoutItem::paint().


The documentation for this class was generated from the following files:
Generated on Thu Mar 4 23:25:56 2010 for KD Chart 2 by  doxygen 1.5.4