KDChart::MarkerLayoutItem Class Reference

#include <KDChartLayoutItems.h>

Inheritance diagram for KDChart::MarkerLayoutItem:

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

Collaboration graph
[legend]

List of all members.


Detailed Description

Layout item showing a data point marker.

Definition at line 223 of file KDChartLayoutItems.h.


Public Member Functions

virtual Qt::Orientations expandingDirections () const
virtual QRect geometry () const
virtual bool isEmpty () const
 MarkerLayoutItem (AbstractDiagram *diagram, const MarkerAttributes &marker, const QBrush &brush, const QPen &pen, Qt::Alignment alignment=0)
virtual QSize maximumSize () const
virtual QSize minimumSize () const
virtual void paint (QPainter *)
virtual void paintAll (QPainter &painter)
 Default impl: just call paint.
virtual void paintCtx (PaintContext *context)
 Default impl: Paint the complete item using its layouted position and size.
QLayout * parentLayout ()
void removeFromParentLayout ()
virtual void setGeometry (const QRect &r)
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 QSize sizeHint () const
virtual void sizeHintChanged () const
 Report changed size hint: ask the parent widget to recalculate the layout.

Static Public Member Functions

static void paintIntoRect (QPainter *painter, const QRect &rect, AbstractDiagram *diagram, const MarkerAttributes &marker, const QBrush &brush, const QPen &pen)

Protected Attributes

QWidgetmParent
QLayout * mParentLayout

Constructor & Destructor Documentation

KDChart::MarkerLayoutItem::MarkerLayoutItem ( KDChart::AbstractDiagram diagram,
const MarkerAttributes marker,
const QBrush &  brush,
const QPen &  pen,
Qt::Alignment  alignment = 0 
)

Definition at line 772 of file KDChartLayoutItems.cpp.

00776     : AbstractLayoutItem( alignment )
00777     , mDiagram( diagram )
00778     , mMarker( marker )
00779     , mBrush( brush )
00780     , mPen( pen )
00781 {
00782 }


Member Function Documentation

Qt::Orientations KDChart::MarkerLayoutItem::expandingDirections (  )  const [virtual]

Definition at line 784 of file KDChartLayoutItems.cpp.

00785 {
00786     return 0; // Grow neither vertically nor horizontally
00787 }

QRect KDChart::MarkerLayoutItem::geometry (  )  const [virtual]

Definition at line 789 of file KDChartLayoutItems.cpp.

00790 {
00791     return mRect;
00792 }

bool KDChart::MarkerLayoutItem::isEmpty (  )  const [virtual]

Definition at line 794 of file KDChartLayoutItems.cpp.

00795 {
00796     return false; // never empty, otherwise the layout item would not exist
00797 }

QSize KDChart::MarkerLayoutItem::maximumSize (  )  const [virtual]

Definition at line 799 of file KDChartLayoutItems.cpp.

References sizeHint().

00800 {
00801     return sizeHint(); // PENDING(kalle) Review, quite inflexible
00802 }

QSize KDChart::MarkerLayoutItem::minimumSize (  )  const [virtual]

Definition at line 804 of file KDChartLayoutItems.cpp.

References sizeHint().

00805 {
00806     return sizeHint(); // PENDING(kalle) Review, quite inflexible
00807 }

void KDChart::MarkerLayoutItem::paint ( QPainter *  painter  )  [virtual]

Implements KDChart::AbstractLayoutItem.

Definition at line 820 of file KDChartLayoutItems.cpp.

References paintIntoRect().

00821 {
00822     paintIntoRect( painter, mRect, mDiagram, mMarker, mBrush, mPen );
00823 }

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

Default impl: just call paint.

Derived classes like KDChart::AbstractArea are providing additional action here.

Reimplemented in KDChart::AbstractArea, KDChart::TextArea, and KDChart::TernaryAxis.

Definition at line 70 of file KDChartLayoutItems.cpp.

References KDChart::AbstractLayoutItem::paint().

00071 {
00072     paint( &painter );
00073 }

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 KDChart::MarkerLayoutItem::paintIntoRect ( QPainter *  painter,
const QRect &  rect,
AbstractDiagram diagram,
const MarkerAttributes marker,
const QBrush &  brush,
const QPen &  pen 
) [static]

Definition at line 825 of file KDChartLayoutItems.cpp.

References KDChart::MarkerAttributes::markerSize(), and KDChart::AbstractDiagram::paintMarker().

Referenced by KDChart::LineWithMarkerLayoutItem::paint(), and paint().

00832 {
00833     if( ! rect.isValid() )
00834         return;
00835 
00836     // The layout management may assign a larger rect than what we
00837     // wanted. We need to adjust the position.
00838     const QSize siz = marker.markerSize().toSize();
00839     QPointF pos = rect.topLeft();
00840     pos += QPointF( static_cast<qreal>(( rect.width()  - siz.width()) / 2.0 ),
00841                     static_cast<qreal>(( rect.height() - siz.height()) / 2.0 ) );
00842 
00843 #ifdef DEBUG_ITEMS_PAINT
00844     QPointF oldPos = pos;
00845 #endif
00846 
00847 // And finally, drawMarker() assumes the position to be the center
00848     // of the marker, adjust again.
00849     pos += QPointF( static_cast<qreal>( siz.width() ) / 2.0,
00850                     static_cast<qreal>( siz.height() )/ 2.0 );
00851 
00852     diagram->paintMarker( painter, marker, brush, pen, pos.toPoint(), siz );
00853 
00854 #ifdef DEBUG_ITEMS_PAINT
00855     const QPen oldPen( painter->pen() );
00856     painter->setPen( Qt::red );
00857     painter->drawRect( QRect(oldPos.toPoint(), siz) );
00858     painter->setPen( oldPen );
00859 #endif
00860 }

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

Definition at line 79 of file KDChartLayoutItems.h.

00080         {
00081             return mParentLayout;
00082         }

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::MarkerLayoutItem::setGeometry ( const QRect &  r  )  [virtual]

Definition at line 809 of file KDChartLayoutItems.cpp.

00810 {
00811     mRect = r;
00812 }

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 KDChart::HeaderFooter::setParent(), and KDChart::AbstractCartesianDiagram::takeAxis().

00066 {
00067     mParent = widget;
00068 }

QSize KDChart::MarkerLayoutItem::sizeHint (  )  const [virtual]

Definition at line 814 of file KDChartLayoutItems.cpp.

References KDChart::MarkerAttributes::markerSize().

Referenced by maximumSize(), and minimumSize().

00815 {
00816     //qDebug() << "KDChart::MarkerLayoutItem::sizeHint() returns:"<<mMarker.markerSize().toSize();
00817     return mMarker.markerSize().toSize();
00818 }

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 }


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:26:12 2010 for KD Chart 2 by  doxygen 1.5.4