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 160 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 ( AbstractDiagram diagram,
const MarkerAttributes marker,
const QBrush &  brush,
const QPen &  pen,
Qt::Alignment  alignment = 0 
)

Definition at line 525 of file KDChartLayoutItems.cpp.

00529     : AbstractLayoutItem( alignment )
00530     , mDiagram( diagram )
00531     , mMarker( marker )
00532     , mBrush( brush )
00533     , mPen( pen )
00534 {
00535 }


Member Function Documentation

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

Definition at line 537 of file KDChartLayoutItems.cpp.

00538 {
00539     return 0; // Grow neither vertically nor horizontally
00540 }

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

Definition at line 542 of file KDChartLayoutItems.cpp.

00543 {
00544     return mRect;
00545 }

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

Definition at line 547 of file KDChartLayoutItems.cpp.

00548 {
00549     return false; // never empty, otherwise the layout item would not exist
00550 }

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

Definition at line 552 of file KDChartLayoutItems.cpp.

References sizeHint().

00553 {
00554     return sizeHint(); // PENDING(kalle) Review, quite inflexible
00555 }

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

Definition at line 557 of file KDChartLayoutItems.cpp.

References sizeHint().

00558 {
00559     return sizeHint(); // PENDING(kalle) Review, quite inflexible
00560 }

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

Implements KDChart::AbstractLayoutItem.

Definition at line 573 of file KDChartLayoutItems.cpp.

References paintIntoRect().

00574 {
00575     paintIntoRect( painter, mRect, mDiagram, mMarker, mBrush, mPen );
00576 }

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

References KDChart::AbstractLayoutItem::paint().

00070 {
00071     paint( &painter );
00072 }

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

Definition at line 578 of file KDChartLayoutItems.cpp.

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

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

00585 {
00586     if( ! rect.isValid() )
00587         return;
00588 
00589     // The layout management may assign a larger rect than what we
00590     // wanted. We need to adjust the position.
00591     const QSize siz = marker.markerSize().toSize();
00592     QPointF pos = rect.topLeft();
00593     pos += QPointF( static_cast<qreal>(( rect.width()  - siz.width()) / 2.0 ),
00594                     static_cast<qreal>(( rect.height() - siz.height()) / 2.0 ) );
00595 
00596 #ifdef DEBUG_ITEMS_PAINT
00597     QPointF oldPos = pos;
00598 #endif
00599 
00600 // And finally, drawMarker() assumes the position to be the center
00601     // of the marker, adjust again.
00602     pos += QPointF( static_cast<qreal>( siz.width() ) / 2.0,
00603                     static_cast<qreal>( siz.height() )/ 2.0 );
00604 
00605     diagram->paintMarker( painter, marker, brush, pen, pos.toPoint(), siz );
00606 
00607 #ifdef DEBUG_ITEMS_PAINT
00608     const QPen oldPen( painter->pen() );
00609     painter->setPen( Qt::red );
00610     painter->drawRect( QRect(oldPos.toPoint(), siz) );
00611     painter->setPen( oldPen );
00612 #endif
00613 }

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

Definition at line 76 of file KDChartLayoutItems.h.

00077         {
00078             return mParentLayout;
00079         }

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         }

void KDChart::MarkerLayoutItem::setGeometry ( const QRect &  r  )  [virtual]

Definition at line 562 of file KDChartLayoutItems.cpp.

00563 {
00564     mRect = r;
00565 }

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

Definition at line 72 of file KDChartLayoutItems.h.

00073         {
00074             mParentLayout = lay;
00075         }

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 }

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

Definition at line 567 of file KDChartLayoutItems.cpp.

References KDChart::MarkerAttributes::markerSize().

Referenced by maximumSize(), and minimumSize().

00568 {
00569     //qDebug() << "KDChart::MarkerLayoutItem::sizeHint() returns:"<<mMarker.markerSize().toSize();
00570     return mMarker.markerSize().toSize();
00571 }

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 }


Member Data Documentation

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().


The documentation for this class was generated from the following files:
Generated on Mon Sep 17 16:18:21 2007 for KD Chart 2 by  doxygen 1.5.1