KDChart::Legend Class Reference

#include <KDChartLegend.h>

Inheritance diagram for KDChart::Legend:

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

Collaboration graph
[legend]
List of all members.

Detailed Description

Legend defines the interface for the legend drawing class.

Legend is the class for drawing legends for all kinds of diagrams ("chart types").

Legend is drawn on chart level, not per diagram, but you can have more than one legend per chart, using KDChart::Chart::addLegend().

Note:
Legend is different from all other classes ofd KD Chart, since it can be displayed outside of the Chart's area. If you want to, you can embedd the legend into your own widget, or into another part of a bigger grid, into which you might have inserted the Chart.
On the other hand, please note that you MUST call Chart::addLegend to get your legend positioned into the correct place of your chart - if you want to have the legend shown inside of the chart (that's probably true for most cases).

Definition at line 62 of file KDChartLegend.h.

Public Types

enum  LegendStyle {
  MarkersOnly = 0,
  LinesOnly = 1,
  MarkersAndLines = 2
}

Signals

void destroyedLegend (Legend *)
void positionChanged (AbstractAreaWidget *)
void propertiesChanged ()
 Emitted upon change of a property of the Legend or any of its components.

Public Member Functions

void addDiagram (KDChart::AbstractDiagram *newDiagram)
 Add the given diagram to the legend.
Qt::Alignment alignment () const
 Returns the alignment of a non-floating legend.
void alignToReferencePoint (const RelativePosition &position)
BackgroundAttributes backgroundAttributes () const
QBrush brush (uint dataset) const
const QMap< uint, QBrush > brushes () const
virtual Legendclone () const
 Creates an exact copy of this legend.
bool compare (const AbstractAreaBase *other) const
 Returns true if both areas have the same settings.
bool compare (const Legend *other) const
 Returns true if both legends have the same settings.
ConstDiagramList constDiagrams () const
 
Returns:
The list of diagrams associated with this coordinate plane.

uint datasetCount () const
KDChart::AbstractDiagramdiagram () const
 The first diagram of the legend or 0 if there was none added to the legend.
DiagramList diagrams () const
 The list of all diagrams associated with the legend.
const RelativePosition floatingPosition () const
 Returns the position of a floating legend.
virtual void forceRebuild ()
 Call this to trigger an unconditional re-building of the widget's internals.
FrameAttributes frameAttributes () const
void getFrameLeadings (int &left, int &top, int &right, int &bottom) const
 Legend (KDChart::AbstractDiagram *diagram, QWidget *parent)
 Legend (QWidget *parent=0)
LegendStyle legendStyle () const
const QMap< uint, MarkerAttributesmarkerAttributes () const
MarkerAttributes markerAttributes (uint dataset) const
virtual QSize minimumSizeHint () const
virtual void needSizeHint ()
 Call this to trigger an conditional re-building of the widget's internals.
Qt::Orientation orientation () const
virtual void paint (QPainter *painter)
 Overwrite this to paint the inner contents of your widget.
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 paintEvent (QPaintEvent *event)
 Draws the background and frame, then calls paint().
virtual void paintFrame (QPainter &painter, const QRect &rectangle)
virtual void paintIntoRect (QPainter &painter, const QRect &rect)
 Draws the background and frame, then calls paint().
QPen pen (uint dataset) const
const QMap< uint, QPen > pens () const
Position position () const
 Returns the position of a non-floating legend.
const QWidgetreferenceArea () const
 Returns the reference area, that is used for font size of title text, and for font size of the item texts, IF automatic area detection is set.
void removeDiagram (KDChart::AbstractDiagram *oldDiagram)
 Removes the diagram from the legend's list of diagrams.
void removeDiagrams ()
 Removes all of the diagram from the legend's list of diagrams.
void replaceDiagram (KDChart::AbstractDiagram *newDiagram, KDChart::AbstractDiagram *oldDiagram=0)
 Replaces the old diagram, or appends the new diagram, it there is none yet.
void resetTexts ()
 Removes all legend texts that might have been set by setText.
virtual void resizeEvent (QResizeEvent *event)
virtual void resizeLayout (const QSize &size)
void setAlignment (Qt::Alignment)
 Specify the alignment of a non-floating legend.
void setBackgroundAttributes (const BackgroundAttributes &a)
void setBrush (uint dataset, const QBrush &brush)
void setBrushesFromDiagram (KDChart::AbstractDiagram *diagram)
void setColor (uint dataset, const QColor &color)
 Note: there is no color() getter method, since setColor just sets a QBrush with the respective color, so the brush() getter method is sufficient.
void setDefaultColors ()
void setDiagram (KDChart::AbstractDiagram *newDiagram)
 A convenience method doing the same as replaceDiagram( newDiagram, 0 );.
void setFloatingPosition (const RelativePosition &relativePosition)
 Specify the position and alignment of a floating legend.
void setFrameAttributes (const FrameAttributes &a)
void setLegendStyle (LegendStyle style)
void setMarkerAttributes (uint dataset, const MarkerAttributes &)
 Note that any sizes specified via setMarkerAttributes are ignored, unless you disable the automatic size calculation, by saying setUseAutomaticMarkerSize( false ).
void setOrientation (Qt::Orientation orientation)
void setPen (uint dataset, const QPen &pen)
void setPosition (Position position)
 Specify the position of a non-floating legend.
void setRainbowColors ()
void setReferenceArea (const QWidget *area)
 Specifies the reference area for font size of title text, and for font size of the item texts, IF automatic area detection is set.
void setShowLines (bool legendShowLines)
void setSpacing (uint space)
void setSubduedColors (bool ordered=false)
void setText (uint dataset, const QString &text)
void setTextAttributes (const TextAttributes &a)
void setTitleText (const QString &text)
void setTitleTextAttributes (const TextAttributes &a)
void setUseAutomaticMarkerSize (bool useAutomaticMarkerSize)
 This option is on by default, it means that Marker sizes in the Legend will be the same as the font height used for their respective label texts.
virtual void setVisible (bool visible)
bool showLines () const
virtual QSize sizeHint () const
uint spacing () const
QString text (uint dataset) const
TextAttributes textAttributes () const
const QMap< uint, QString > texts () const
QString titleText () const
TextAttributes titleTextAttributes () const
bool useAutomaticMarkerSize () const
virtual ~Legend ()

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


Member Enumeration Documentation

enum KDChart::Legend::LegendStyle

Enumerator:
MarkersOnly 
LinesOnly 
MarkersAndLines 

Definition at line 75 of file KDChartLegend.h.

00075                      { MarkersOnly     = 0,
00076                        LinesOnly       = 1,
00077                        MarkersAndLines = 2 };


Constructor & Destructor Documentation

Legend::Legend ( QWidget parent = 0  )  [explicit]

Definition at line 85 of file KDChartLegend.cpp.

References d.

Referenced by clone().

00085                                 :
00086     AbstractAreaWidget( new Private(), parent )
00087 {
00088     d->referenceArea = parent;
00089     init();
00090 }

Legend::Legend ( KDChart::AbstractDiagram diagram,
QWidget parent 
) [explicit]

Definition at line 92 of file KDChartLegend.cpp.

References d, diagram(), and setDiagram().

00092                                                                  :
00093     AbstractAreaWidget( new Private(), parent )
00094 {
00095     d->referenceArea = parent;
00096     init();
00097     setDiagram( diagram );
00098 }

Legend::~Legend (  )  [virtual]

Definition at line 100 of file KDChartLegend.cpp.

References destroyedLegend().

00101 {
00102     emit destroyedLegend( this );
00103 }


Member Function Documentation

void Legend::addDiagram ( KDChart::AbstractDiagram newDiagram  ) 

Add the given diagram to the legend.

Parameters:
newDiagram The diagram to add.
See also:
diagram, diagrams, removeDiagram, removeDiagrams, replaceDiagram, setDiagram

Definition at line 337 of file KDChartLegend.cpp.

References d.

Referenced by replaceDiagram().

00338 {
00339     if ( newDiagram )
00340     {
00341         DiagramObserver* observer = new DiagramObserver( newDiagram, this );
00342 
00343         DiagramObserver* oldObs = d->findObserverForDiagram( newDiagram );
00344         if( oldObs ){
00345             delete oldObs;
00346             d->observers[ d->observers.indexOf( oldObs ) ] = observer;
00347         }else{
00348             d->observers.append( observer );
00349         }
00350         connect( observer, SIGNAL( diagramDestroyed(AbstractDiagram*) ),
00351                         SLOT( resetDiagram(AbstractDiagram*) ));
00352         connect( observer, SIGNAL( diagramDataChanged(AbstractDiagram*) ),
00353                  SLOT( setNeedRebuild() ));
00354         connect( observer, SIGNAL( diagramDataHidden(AbstractDiagram*) ),
00355                  SLOT( setNeedRebuild() ));
00356         connect( observer, SIGNAL( diagramAttributesChanged(AbstractDiagram*) ),
00357                         SLOT( setNeedRebuild() ));
00358         setNeedRebuild();
00359     }
00360 }

Qt::Alignment Legend::alignment (  )  const

Returns the alignment of a non-floating legend.

See also:
setAlignment

Definition at line 452 of file KDChartLegend.cpp.

References d.

Referenced by clone(), and compare().

00453 {
00454     return d->alignment;
00455 }

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 AbstractAreaWidget::areaGeometry (  )  const [protected, virtual, inherited]

Implements KDChart::AbstractAreaBase.

Definition at line 186 of file KDChartAbstractAreaWidget.cpp.

00187 {
00188     return geometry();
00189 }

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 }

QBrush Legend::brush ( uint  dataset  )  const

Definition at line 558 of file KDChartLegend.cpp.

References d.

Referenced by setRainbowColors().

00559 {
00560     if( d->brushes.find( dataset ) != d->brushes.end() )
00561         return d->brushes[ dataset ];
00562     else
00563         return d->modelBrushes[ dataset ];
00564 }

const QMap< uint, QBrush > Legend::brushes (  )  const

Definition at line 566 of file KDChartLegend.cpp.

References d.

Referenced by compare().

00567 {
00568     return d->brushes;
00569 }

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

Creates an exact copy of this legend.

Definition at line 204 of file KDChartLegend.cpp.

References alignment(), d, KDChart::AbstractAreaBase::frameAttributes(), Legend(), legendStyle(), position(), setAlignment(), KDChart::AbstractAreaBase::setFrameAttributes(), setLegendStyle(), setPosition(), setTextAttributes(), setTitleTextAttributes(), setUseAutomaticMarkerSize(), textAttributes(), titleTextAttributes(), and useAutomaticMarkerSize().

00205 {
00206     Legend* legend = new Legend( new Private( *d ), 0 );
00207     legend->setTextAttributes( textAttributes() );
00208     legend->setTitleTextAttributes( titleTextAttributes() );
00209     legend->setFrameAttributes( frameAttributes() );
00210     legend->setUseAutomaticMarkerSize( useAutomaticMarkerSize() );
00211     legend->setPosition( position() );
00212     legend->setAlignment( alignment() );
00213     legend->setLegendStyle( legendStyle() );
00214     return legend;
00215 }

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 }

bool Legend::compare ( const Legend other  )  const

Returns true if both legends have the same settings.

Definition at line 218 of file KDChartLegend.cpp.

References alignment(), brushes(), floatingPosition(), legendStyle(), markerAttributes(), orientation(), pens(), position(), showLines(), spacing(), textAttributes(), texts(), titleText(), titleTextAttributes(), and useAutomaticMarkerSize().

00219 {
00220     if( other == this ) return true;
00221     if( ! other ){
00222         //qDebug() << "Legend::compare() cannot compare to Null pointer";
00223         return false;
00224     }
00225     /*
00226     qDebug() << ( static_cast<const AbstractAreaBase*>(this)->compare( other ) );
00227     qDebug() << (isVisible()              == other->isVisible());
00228     qDebug() << (position()               == other->position());
00229     qDebug() << (alignment()              == other->alignment());
00230     qDebug() << (floatingPosition()       == other->floatingPosition());
00231     qDebug() << (orientation()            == other->orientation());
00232     qDebug() << (showLines()              == other->showLines());
00233     qDebug() << (texts()                  == other->texts());
00234     qDebug() << (brushes()                == other->brushes());
00235     qDebug() << (pens()                   == other->pens());
00236     qDebug() << (markerAttributes()       == other->markerAttributes());
00237     qDebug() << (useAutomaticMarkerSize() == other->useAutomaticMarkerSize());
00238     qDebug() << (textAttributes()         == other->textAttributes());
00239     qDebug() << (titleText()              == other->titleText());
00240     qDebug() << (titleTextAttributes()    == other->titleTextAttributes());
00241     qDebug() << (spacing()                == other->spacing());
00242     qDebug() << (legendStyle()            == other->legendStyle());
00243     */
00244     return  ( static_cast<const AbstractAreaBase*>(this)->compare( other ) ) &&
00245             (isVisible()              == other->isVisible()) &&
00246             (position()               == other->position()) &&
00247             (alignment()              == other->alignment())&&
00248             (floatingPosition()       == other->floatingPosition()) &&
00249             (orientation()            == other->orientation())&&
00250             (showLines()              == other->showLines())&&
00251             (texts()                  == other->texts())&&
00252             (brushes()                == other->brushes())&&
00253             (pens()                   == other->pens())&&
00254             (markerAttributes()       == other->markerAttributes())&&
00255             (useAutomaticMarkerSize() == other->useAutomaticMarkerSize()) &&
00256             (textAttributes()         == other->textAttributes()) &&
00257             (titleText()              == other->titleText())&&
00258             (titleTextAttributes()    == other->titleTextAttributes()) &&
00259             (spacing()                == other->spacing()) &&
00260             (legendStyle()            == other->legendStyle());
00261 }

ConstDiagramList Legend::constDiagrams (  )  const

Returns:
The list of diagrams associated with this coordinate plane.

Definition at line 329 of file KDChartLegend.cpp.

References d.

00330 {
00331     ConstDiagramList list;
00332     for (int i = 0; i < d->observers.size(); ++i)
00333         list << d->observers.at(i)->diagram();
00334     return list;
00335 }

uint Legend::datasetCount (  )  const

Definition at line 286 of file KDChartLegend.cpp.

References d.

00287 {
00288     int modelLabelsCount = 0;
00289     int modelBrushesCount = 0;
00290     for (int i = 0; i < d->observers.size(); ++i) {
00291         DiagramObserver * obs = d->observers.at(i);
00292         modelLabelsCount  += obs->diagram()->datasetLabels().count();
00293         modelBrushesCount += obs->diagram()->datasetBrushes().count();
00294     }
00295     Q_ASSERT( modelLabelsCount == modelBrushesCount );
00296     return modelLabelsCount;
00297 }

void KDChart::Legend::destroyedLegend ( Legend  )  [signal]

Referenced by ~Legend().

AbstractDiagram * Legend::diagram (  )  const

The first diagram of the legend or 0 if there was none added to the legend.

Returns:
The first diagram of the legend or 0.
See also:
diagrams, addDiagram, removeDiagram, removeDiagrams, replaceDiagram, setDiagram

Definition at line 314 of file KDChartLegend.cpp.

References d.

Referenced by Legend(), paint(), and setBrushesFromDiagram().

00315 {
00316     if( d->observers.isEmpty() )
00317         return 0;
00318     return d->observers.first()->diagram();
00319 }

DiagramList Legend::diagrams (  )  const

The list of all diagrams associated with the legend.

Returns:
The list of all diagrams associated with the legend.
See also:
diagram, addDiagram, removeDiagram, removeDiagrams, replaceDiagram, setDiagram

Definition at line 321 of file KDChartLegend.cpp.

References d.

00322 {
00323     DiagramList list;
00324     for (int i = 0; i < d->observers.size(); ++i)
00325         list << d->observers.at(i)->diagram();
00326     return list;
00327 }

const RelativePosition Legend::floatingPosition (  )  const

Returns the position of a floating legend.

See also:
setFloatingPosition

Definition at line 466 of file KDChartLegend.cpp.

References d.

Referenced by compare(), and KDChart::Chart::reLayoutFloatingLegends().

00467 {
00468     return d->relativePosition;
00469 }

void Legend::forceRebuild (  )  [virtual]

Call this to trigger an unconditional re-building of the widget's internals.

Reimplemented from KDChart::AbstractAreaWidget.

Definition at line 670 of file KDChartLegend.cpp.

Referenced by resizeEvent().

00671 {
00672 #ifdef DEBUG_LEGEND_PAINT
00673     qDebug() << "entering Legend::forceRebuild()";
00674 #endif
00675     //setSpacing(d->layout->spacing());
00676     buildLegend();
00677 #ifdef DEBUG_LEGEND_PAINT
00678     qDebug() << "leaving Legend::forceRebuild()";
00679 #endif
00680 }

FrameAttributes AbstractAreaBase::frameAttributes (  )  const [inherited]

Definition at line 106 of file KDChartAbstractAreaBase.cpp.

References d.

Referenced by 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 KDChart::AbstractArea::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 }

Legend::LegendStyle Legend::legendStyle (  )  const

Definition at line 196 of file KDChartLegend.cpp.

References d.

Referenced by clone(), and compare().

00197 {
00198     return d->legendStyle;
00199 }

const QMap< uint, MarkerAttributes > Legend::markerAttributes (  )  const

Definition at line 628 of file KDChartLegend.cpp.

References d.

Referenced by compare(), and setMarkerAttributes().

00629 {
00630     return d->markerAttributes;
00631 }

MarkerAttributes Legend::markerAttributes ( uint  dataset  )  const

Definition at line 619 of file KDChartLegend.cpp.

References d.

Referenced by compare().

00620 {
00621     if( d->markerAttributes.find( dataset ) != d->markerAttributes.end() )
00622         return d->markerAttributes[ dataset ];
00623     else if ( static_cast<uint>( d->modelMarkers.count() ) > dataset )
00624         return d->modelMarkers[ dataset ];
00625     return MarkerAttributes();
00626 }

QSize Legend::minimumSizeHint (  )  const [virtual]

Definition at line 143 of file KDChartLegend.cpp.

References sizeHint().

00144 {
00145     return sizeHint();
00146 }

void Legend::needSizeHint (  )  [virtual]

Call this to trigger an conditional re-building of the widget's internals.

e.g. AbstractAreaWidget call this, before calling layout()->setGeometry()

Reimplemented from KDChart::AbstractAreaWidget.

Definition at line 161 of file KDChartLegend.cpp.

00162 {
00163     // Re-build the Legend's content, if it has not been build yet,
00164     // or if the Legend's geometry has changed, resp.
00165     buildLegend();
00166 }

Qt::Orientation Legend::orientation (  )  const

Definition at line 479 of file KDChartLegend.cpp.

References d.

Referenced by compare().

00480 {
00481     return d->orientation;
00482 }

void Legend::paint ( QPainter *  painter  )  [virtual]

Overwrite this to paint the inner contents of your widget.

Note:
When overriding this method, please let your widget draw itself at the top/left corner of the painter. You should call rect() (or width(), height(), resp.) to find the drawable area's size: While the paint() method is being executed the frame of the widget is outside of its rect(), so you can use all of rect() for your custom drawing!
See also:
paint, paintIntoRect

Implements KDChart::AbstractAreaWidget.

Definition at line 264 of file KDChartLegend.cpp.

References d, diagram(), and KDChart::AbstractLayoutItem::paint().

00265 {
00266 #ifdef DEBUG_LEGEND_PAINT
00267     qDebug() << "entering Legend::paint( QPainter* painter )";
00268 #endif
00269     // rule: We do not show a legend, if there is no diagram.
00270     if( ! diagram() ) return;
00271 
00272     // re-calculate/adjust the Legend's internal layout and contents, if needed:
00273     //buildLegend();
00274 
00275     // PENDING(kalle) Support palette
00276 
00277     Q_FOREACH( KDChart::AbstractLayoutItem* layoutItem, d->layoutItems ) {
00278         layoutItem->paint( painter );
00279     }
00280 #ifdef DEBUG_LEGEND_PAINT
00281     qDebug() << "leaving Legend::paint( QPainter* painter )";
00282 #endif
00283 }

void AbstractAreaWidget::paintAll ( QPainter &  painter  )  [inherited]

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

Definition at line 145 of file KDChartAbstractAreaWidget.cpp.

References KDChart::AbstractAreaBase::getFrameLeadings(), KDChart::AbstractAreaWidget::paint(), KDChart::AbstractAreaBase::paintBackground(), and KDChart::AbstractAreaBase::paintFrame().

Referenced by KDChart::AbstractAreaWidget::paintEvent(), and KDChart::AbstractAreaWidget::paintIntoRect().

00146 {
00147     //qDebug() << "AbstractAreaWidget::paintAll() called";
00148 
00149     // Paint the background and frame
00150     paintBackground( painter, QRect(QPoint(0, 0), size() ) );
00151     paintFrame(      painter, QRect(QPoint(0, 0), size() ) );
00152 
00153 /*
00154     we do not call setContentsMargins() now,
00155     but we call resizeLayout() whenever the size or the frame has changed
00156 
00157     // adjust the widget's content margins,
00158     // to be sure all content gets calculated
00159     // to fit into the inner rectangle
00160     const QRect oldGeometry( areaGeometry()  );
00161     const QRect inner( innerRect() );
00162     //qDebug() << "areaGeometry():" << oldGeometry
00163     //         << "  contentsRect():" << contentsRect() << "  inner:" << inner;
00164     if( contentsRect() != inner ){
00165         //qDebug() << "old contentsRect():" << contentsRect() << "  new innerRect:" << inner;
00166         setContentsMargins(
00167             inner.left(),
00168             inner.top(),
00169             oldGeometry.width() -inner.width()-1,
00170             oldGeometry.height()-inner.height()-1 );
00171         //forceRebuild();
00172     }
00173 */
00174     int left;
00175     int top;
00176     int right;
00177     int bottom;
00178     getFrameLeadings( left, top, right, bottom );
00179     const QPoint translation( left, top );
00180     painter.translate( translation );
00181     paint( &painter );
00182     painter.translate( -translation.x(), -translation.y() );
00183      //qDebug() << "AbstractAreaWidget::paintAll() done.";
00184 }

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 KDChart::AbstractArea::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 AbstractAreaWidget::paintEvent ( QPaintEvent *  event  )  [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 paint() instead.

See also:
paint

Definition at line 99 of file KDChartAbstractAreaWidget.cpp.

References d, and KDChart::AbstractAreaWidget::paintAll().

00100 {
00101     Q_UNUSED( event );
00102     QPainter painter( this );
00103     if( size() != d->currentLayoutSize ){
00104         d->resizeLayout( this, size() );
00105     }
00106     paintAll( painter );
00107 }

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 KDChart::AbstractArea::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 AbstractAreaWidget::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 paint() instead.

Definition at line 109 of file KDChartAbstractAreaWidget.cpp.

References d, and KDChart::AbstractAreaWidget::paintAll().

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

00110 {
00111     //qDebug() << "AbstractAreaWidget::paintIntoRect() called rect=" << rect;
00112 
00113     if( rect.isEmpty() ) return;
00114 
00115     d->resizeLayout( this, rect.size() );
00116 
00117     const QPoint translation( rect.topLeft() );
00118     painter.translate( translation );
00119     paintAll( painter );
00120     painter.translate( -translation.x(), -translation.y() );
00121 
00122 /*
00123     // make sure, the contents of the widget have been set up,
00124     // so we get a usefull geometry:
00125     needSizeHint();
00126 
00127     const QRect oldGeometry( layout()->geometry() );
00128     const QRect newGeo( QPoint(0,0), rect.size() );
00129     const bool mustChangeGeo = layout() && oldGeometry != newGeo;
00130     if( mustChangeGeo )
00131         layout()->setGeometry( newGeo );
00132     painter.translate( rect.left(), rect.top() );
00133     paintAll( painter );
00134     painter.translate( -rect.left(), -rect.top() );
00135     if( mustChangeGeo )
00136         layout()->setGeometry( oldGeometry );
00137 */
00138 }

QPen Legend::pen ( uint  dataset  )  const

Definition at line 597 of file KDChartLegend.cpp.

References d.

00598 {
00599     if( d->pens.find( dataset ) != d->pens.end() )
00600         return d->pens[dataset];
00601     else
00602         return d->modelPens[ dataset ];
00603 }

const QMap< uint, QPen > Legend::pens (  )  const

Definition at line 605 of file KDChartLegend.cpp.

References d.

Referenced by compare().

00606 {
00607     return d->pens;
00608 }

Position Legend::position (  )  const

Returns the position of a non-floating legend.

See also:
setPosition

Definition at line 439 of file KDChartLegend.cpp.

References d.

Referenced by clone(), compare(), KDChart::Chart::reLayoutFloatingLegends(), and setPosition().

00440 {
00441     return d->position;
00442 }

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

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

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

Reimplemented from KDChart::AbstractAreaBase.

Definition at line 191 of file KDChartAbstractAreaWidget.cpp.

References KDChart::AbstractAreaWidget::positionChanged().

00192 {
00193     emit positionChanged( this );
00194 }

void KDChart::Legend::propertiesChanged (  )  [signal]

Emitted upon change of a property of the Legend or any of its components.

const QWidget * Legend::referenceArea (  )  const

Returns the reference area, that is used for font size of title text, and for font size of the item texts, IF automatic area detection is set.

See also:
setReferenceArea

Definition at line 307 of file KDChartLegend.cpp.

References d.

00308 {
00309     //qDebug() << d->referenceArea;
00310     return (d->referenceArea ? d->referenceArea : static_cast<const QWidget*>(parent()));
00311 }

void Legend::removeDiagram ( KDChart::AbstractDiagram oldDiagram  ) 

Removes the diagram from the legend's list of diagrams.

See also:
diagram, diagrams, addDiagram, removeDiagrams, replaceDiagram, setDiagram

Definition at line 362 of file KDChartLegend.cpp.

References d.

Referenced by removeDiagrams(), and replaceDiagram().

00363 {
00364     if( oldDiagram ){
00365         DiagramObserver* oldObs = d->findObserverForDiagram( oldDiagram );
00366         if( oldObs ){
00367             //qDebug() << "before delete oldObs;";
00368             delete oldObs;
00369             //qDebug() << "after delete oldObs;";
00370             d->observers.removeAt( d->observers.indexOf( oldObs ) );
00371             //qDebug() << "after d->observers.removeAt()";
00372         }
00373         setNeedRebuild();
00374     }
00375 }

void Legend::removeDiagrams (  ) 

Removes all of the diagram from the legend's list of diagrams.

See also:
diagram, diagrams, addDiagram, removeDiagram, replaceDiagram, setDiagram

Definition at line 377 of file KDChartLegend.cpp.

References d, and removeDiagram().

00378 {
00379     for (int i = 0; i < d->observers.size(); ++i)
00380         removeDiagram( d->observers.at(i)->diagram() );
00381 }

void Legend::replaceDiagram ( KDChart::AbstractDiagram newDiagram,
KDChart::AbstractDiagram oldDiagram = 0 
)

Replaces the old diagram, or appends the new diagram, it there is none yet.

Parameters:
newDiagram The diagram to be used instead of the old one. If this parameter is zero, the first diagram will just be removed.
oldDiagram The diagram to be removed by the new one. This diagram will be deleted automatically. If the parameter is omitted, the very first diagram will be replaced. In case, there was no diagram yet, the new diagram will just be added.
See also:
diagram, diagrams, addDiagram, removeDiagram, removeDiagrams, setDiagram

Definition at line 383 of file KDChartLegend.cpp.

References addDiagram(), d, and removeDiagram().

Referenced by setDiagram().

00385 {
00386     KDChart::AbstractDiagram* old = oldDiagram;
00387     if( ! d->observers.isEmpty() && ! old ){
00388         old = d->observers.first()->diagram();
00389         if( ! old )
00390             d->observers.removeFirst(); // first entry had a 0 diagram
00391     }
00392     if( old )
00393         removeDiagram( old );
00394     if( newDiagram )
00395         addDiagram( newDiagram );
00396 }

void Legend::resetTexts (  ) 

Removes all legend texts that might have been set by setText.

This resets the Legend to default behaviour: Texts are created automatically.

Definition at line 514 of file KDChartLegend.cpp.

References d.

00515 {
00516     if( ! d->texts.count() ) return;
00517     d->texts.clear();
00518     setNeedRebuild();
00519 }

void Legend::resizeEvent ( QResizeEvent *  event  )  [virtual]

Definition at line 773 of file KDChartLegend.cpp.

References forceRebuild(), and sizeHint().

00774 {
00775     Q_UNUSED( event );
00776 #ifdef DEBUG_LEGEND_PAINT
00777     qDebug() << "Legend::resizeEvent() called";
00778 #endif
00779     forceRebuild();
00780     sizeHint();
00781     QTimer::singleShot(0, this, SLOT(emitPositionChanged()));
00782 }

void Legend::resizeLayout ( const QSize &  size  )  [virtual]

Reimplemented from KDChart::AbstractAreaWidget.

Definition at line 168 of file KDChartLegend.cpp.

References d.

00169 {
00170 #ifdef DEBUG_LEGEND_PAINT
00171     qDebug() << "Legend::resizeLayout started";
00172 #endif
00173     if( d->layout ){
00174         d->layout->setGeometry( QRect(QPoint(0,0), size) );
00175         activateTheLayout();
00176     }
00177 #ifdef DEBUG_LEGEND_PAINT
00178     qDebug() << "Legend::resizeLayout done";
00179 #endif
00180 }

void Legend::setAlignment ( Qt::Alignment   ) 

Specify the alignment of a non-floating legend.

Use setFloatingPosition to set position and alignment if your legend is floating.

See also:
alignment, setPosition, setFloatingPosition

Definition at line 444 of file KDChartLegend.cpp.

References d.

Referenced by clone().

00445 {
00446     if( d->alignment == alignment )
00447         return;
00448     d->alignment = alignment;
00449     emitPositionChanged();
00450 }

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 Legend::setBrush ( uint  dataset,
const QBrush &  brush 
)

Definition at line 550 of file KDChartLegend.cpp.

References d.

00551 {
00552     if( d->brushes[ dataset ] == brush ) return;
00553     d->brushes[ dataset ] = brush;
00554     setNeedRebuild();
00555     update();
00556 }

void Legend::setBrushesFromDiagram ( KDChart::AbstractDiagram diagram  ) 

Definition at line 572 of file KDChartLegend.cpp.

References d, KDChart::AbstractDiagram::datasetBrushes(), and diagram().

00573 {
00574     bool bChangesDone = false;
00575     QList<QBrush> datasetBrushes = diagram->datasetBrushes();
00576     for( int i = 0; i < datasetBrushes.count(); i++ ){
00577         if( d->brushes[ i ] != datasetBrushes[ i ] ){
00578             d->brushes[ i ]  = datasetBrushes[ i ];
00579             bChangesDone = true;
00580         }
00581     }
00582     if( bChangesDone ) {
00583         setNeedRebuild();
00584         update();
00585     }
00586 }

void Legend::setColor ( uint  dataset,
const QColor &  color 
)

Note: there is no color() getter method, since setColor just sets a QBrush with the respective color, so the brush() getter method is sufficient.

Definition at line 542 of file KDChartLegend.cpp.

References d.

Referenced by setDefaultColors(), setRainbowColors(), and setSubduedColors().

00543 {
00544     if( d->brushes[ dataset ] == color ) return;
00545     d->brushes[ dataset ] = color;
00546     setNeedRebuild();
00547     update();
00548 }

void Legend::setDefaultColors (  ) 

Definition at line 695 of file KDChartLegend.cpp.

References setColor().

00696 {
00697     setColor(  0, Qt::red );
00698     setColor(  1, Qt::green );
00699     setColor(  2, Qt::blue );
00700     setColor(  3, Qt::cyan );
00701     setColor(  4, Qt::magenta );
00702     setColor(  5, Qt::yellow );
00703     setColor(  6, Qt::darkRed );
00704     setColor(  7, Qt::darkGreen );
00705     setColor(  8, Qt::darkBlue );
00706     setColor(  9, Qt::darkCyan );
00707     setColor( 10, Qt::darkMagenta );
00708     setColor( 11, Qt::darkYellow );
00709 }

void Legend::setDiagram ( KDChart::AbstractDiagram newDiagram  ) 

A convenience method doing the same as replaceDiagram( newDiagram, 0 );.

Replaces the first diagram by the given diagram. If the legend's list of diagram is empty the given diagram is added to the list.

See also:
diagram, diagrams, addDiagram, removeDiagram, removeDiagrams, replaceDiagram

Definition at line 398 of file KDChartLegend.cpp.

References replaceDiagram().

Referenced by KDChart::Widget::addLegend(), Legend(), KDChart::Widget::replaceLegend(), and KDChart::Widget::setType().

00399 {
00400     replaceDiagram( newDiagram );
00401 }

void Legend::setFloatingPosition ( const RelativePosition relativePosition  ) 

Specify the position and alignment of a floating legend.

Use setPosition and setAlignment to set position and alignment if your legend is non-floating.

Note:
When setFloatingPosition is called, the Legend's position value is set to KDChart::Position::Floating automatically.
If your Chart is pointed to by m_chart, your could have the floating legend alligned exactly to the chart's coordinate plane's top-right corner with the following commands:
KDChart::RelativePosition relativePosition;
relativePosition.setReferenceArea( m_chart->coordinatePlane() );
relativePosition.setReferencePosition( Position::NorthEast );
relativePosition.setAlignment( Qt::AlignTop | Qt::AlignRight );
relativePosition.setHorizontalPadding(
    KDChart::Measure( -1.0, KDChartEnums::MeasureCalculationModeAbsolute ) );
relativePosition.setVerticalPadding(
    KDChart::Measure( 0.0, KDChartEnums::MeasureCalculationModeAbsolute ) );
m_legend->setFloatingPosition( relativePosition );

To have the legend positioned at a fixed point, measured from the QPainter's top left corner, you could use the following code code:

KDChart::RelativePosition relativePosition;
relativePosition.setReferencePoints( PositionPoints( QPointF( 0.0, 0.0 ) ) );
relativePosition.setReferencePosition( Position::NorthWest );
relativePosition.setAlignment( Qt::AlignTop | Qt::AlignLeft );
relativePosition.setHorizontalPadding(
    KDChart::Measure( 4.0, KDChartEnums::MeasureCalculationModeAbsolute ) );
relativePosition.setVerticalPadding(
    KDChart::Measure( 4.0, KDChartEnums::MeasureCalculationModeAbsolute ) );
m_legend->setFloatingPosition( relativePosition );
Actually that's exactly the code KD Chart is using as default position for any floating legends, so if you just say setPosition( KDChart::Position::Floating ) without calling setFloatingPosition your legend will be positioned at point 4/4.

See also:
setPosition, setAlignment

Definition at line 457 of file KDChartLegend.cpp.

References d, and KDChart::Position::Floating.

00458 {
00459     d->position = Position::Floating;
00460     if( d->relativePosition != relativePosition ){
00461         d->relativePosition  = relativePosition;
00462         emitPositionChanged();
00463     }
00464 }

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

Definition at line 97 of file KDChartAbstractAreaBase.cpp.

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

Referenced by clone().

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

void Legend::setLegendStyle ( LegendStyle  style  ) 

Definition at line 189 of file KDChartLegend.cpp.

References d.

Referenced by clone().

00190 {
00191     if( d->legendStyle == style ) return;
00192     d->legendStyle = style;
00193     setNeedRebuild();
00194 }

void Legend::setMarkerAttributes ( uint  dataset,
const MarkerAttributes  
)

Note that any sizes specified via setMarkerAttributes are ignored, unless you disable the automatic size calculation, by saying setUseAutomaticMarkerSize( false ).

Definition at line 611 of file KDChartLegend.cpp.

References d, and markerAttributes().

00612 {
00613     if( d->markerAttributes[dataset] == markerAttributes ) return;
00614     d->markerAttributes[ dataset ] = markerAttributes;
00615     setNeedRebuild();
00616     update();
00617 }

void Legend::setOrientation ( Qt::Orientation  orientation  ) 

Definition at line 471 of file KDChartLegend.cpp.

References d.

00472 {
00473     if( d->orientation == orientation ) return;
00474     d->orientation = orientation;
00475     setNeedRebuild();
00476     emitPositionChanged();
00477 }

void Legend::setPen ( uint  dataset,
const QPen &  pen 
)

Definition at line 589 of file KDChartLegend.cpp.

References d.

00590 {
00591     if( d->pens[dataset] == pen ) return;
00592     d->pens[dataset] = pen;
00593     setNeedRebuild();
00594     update();
00595 }

void Legend::setPosition ( Position  position  ) 

Specify the position of a non-floating legend.

Use setFloatingPosition to set position and alignment if your legend is floating.

See also:
setAlignment, setFloatingPosition

Definition at line 424 of file KDChartLegend.cpp.

References d, and position().

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

00425 {
00426     if( d->position == position )
00427         return;
00428     d->position = position;
00429     emitPositionChanged();
00430 }

void Legend::setRainbowColors (  ) 

Definition at line 711 of file KDChartLegend.cpp.

References brush(), and setColor().

00712 {
00713     setColor(  0, QColor(255,  0,196) );
00714     setColor(  1, QColor(255,  0, 96) );
00715     setColor(  2, QColor(255, 128,64) );
00716     setColor(  3, Qt::yellow );
00717     setColor(  4, Qt::green );
00718     setColor(  5, Qt::cyan );
00719     setColor(  6, QColor( 96, 96,255) );
00720     setColor(  7, QColor(160,  0,255) );
00721     for( int i = 8; i < 16; ++i )
00722         setColor( i, brush( i - 8 ).color().light() );
00723 }

void Legend::setReferenceArea ( const QWidget area  ) 

Specifies the reference area for font size of title text, and for font size of the item texts, IF automatic area detection is set.

Note:
This parameter is ignored, if the Measure given for setTitleTextAttributes (or setTextAttributes, resp.) is not specifying automatic area detection.
If no reference area is specified, but automatic area detection is set, then the size of the legend's parent widget will be used.

See also:
KDChart::Measure, KDChartEnums::MeasureCalculationMode

Definition at line 300 of file KDChartLegend.cpp.

References d.

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

00301 {
00302     if( area == d->referenceArea ) return;
00303     d->referenceArea = area;
00304     setNeedRebuild();
00305 }

void Legend::setShowLines ( bool  legendShowLines  ) 

Definition at line 484 of file KDChartLegend.cpp.

References d.

00485 {
00486     if( d->showLines == legendShowLines ) return;
00487     d->showLines = legendShowLines;
00488     setNeedRebuild();
00489     emitPositionChanged();
00490 }

void Legend::setSpacing ( uint  space  ) 

Definition at line 682 of file KDChartLegend.cpp.

References d.

00683 {
00684     if( d->spacing == space && d->layout->spacing() == static_cast<int>(space) ) return;
00685     d->spacing = space;
00686     d->layout->setSpacing( space );
00687     setNeedRebuild();
00688 }

void Legend::setSubduedColors ( bool  ordered = false  ) 

Definition at line 725 of file KDChartLegend.cpp.

References setColor().

00726 {
00727 static const int NUM_SUBDUEDCOLORS = 18;
00728 static const QColor SUBDUEDCOLORS[ NUM_SUBDUEDCOLORS ] = {
00729     QColor( 0xe0,0x7f,0x70 ),
00730     QColor( 0xe2,0xa5,0x6f ),
00731     QColor( 0xe0,0xc9,0x70 ),
00732     QColor( 0xd1,0xe0,0x70 ),
00733     QColor( 0xac,0xe0,0x70 ),
00734     QColor( 0x86,0xe0,0x70 ),
00735     QColor( 0x70,0xe0,0x7f ),
00736     QColor( 0x70,0xe0,0xa4 ),
00737     QColor( 0x70,0xe0,0xc9 ),
00738     QColor( 0x70,0xd1,0xe0 ),
00739     QColor( 0x70,0xac,0xe0 ),
00740     QColor( 0x70,0x86,0xe0 ),
00741     QColor( 0x7f,0x70,0xe0 ),
00742     QColor( 0xa4,0x70,0xe0 ),
00743     QColor( 0xc9,0x70,0xe0 ),
00744     QColor( 0xe0,0x70,0xd1 ),
00745     QColor( 0xe0,0x70,0xac ),
00746     QColor( 0xe0,0x70,0x86 ),
00747 };
00748     if( ordered )
00749         for(int i=0; i<NUM_SUBDUEDCOLORS; ++i)
00750             setColor( i, SUBDUEDCOLORS[i] );
00751     else{
00752         setColor( 0, SUBDUEDCOLORS[ 0] );
00753         setColor( 1, SUBDUEDCOLORS[ 5] );
00754         setColor( 2, SUBDUEDCOLORS[10] );
00755         setColor( 3, SUBDUEDCOLORS[15] );
00756         setColor( 4, SUBDUEDCOLORS[ 2] );
00757         setColor( 5, SUBDUEDCOLORS[ 7] );
00758         setColor( 6, SUBDUEDCOLORS[12] );
00759         setColor( 7, SUBDUEDCOLORS[17] );
00760         setColor( 8, SUBDUEDCOLORS[ 4] );
00761         setColor( 9, SUBDUEDCOLORS[ 9] );
00762         setColor(10, SUBDUEDCOLORS[14] );
00763         setColor(11, SUBDUEDCOLORS[ 1] );
00764         setColor(12, SUBDUEDCOLORS[ 6] );
00765         setColor(13, SUBDUEDCOLORS[11] );
00766         setColor(14, SUBDUEDCOLORS[16] );
00767         setColor(15, SUBDUEDCOLORS[ 3] );
00768         setColor(16, SUBDUEDCOLORS[ 8] );
00769         setColor(17, SUBDUEDCOLORS[13] );
00770     }
00771 }

void Legend::setText ( uint  dataset,
const QString &  text 
)

Definition at line 521 of file KDChartLegend.cpp.

References d.

00522 {
00523     if( d->texts[ dataset ] == text ) return;
00524     d->texts[ dataset ] = text;
00525     setNeedRebuild();
00526 }

void Legend::setTextAttributes ( const TextAttributes a  ) 

Definition at line 634 of file KDChartLegend.cpp.

References d.

Referenced by KDChart::Chart::addLegend(), and clone().

00635 {
00636     if( d->textAttributes == a ) return;
00637     d->textAttributes = a;
00638     setNeedRebuild();
00639 }

void Legend::setTitleText ( const QString &  text  ) 

Definition at line 646 of file KDChartLegend.cpp.

References d.

00647 {
00648     if( d->titleText == text ) return;
00649     d->titleText = text;
00650     setNeedRebuild();
00651 }

void Legend::setTitleTextAttributes ( const TextAttributes a  ) 

Definition at line 658 of file KDChartLegend.cpp.

References d.

Referenced by KDChart::Chart::addLegend(), and clone().

00659 {
00660     if( d->titleTextAttributes == a ) return;
00661     d->titleTextAttributes = a;
00662     setNeedRebuild();
00663 }

void Legend::setUseAutomaticMarkerSize ( bool  useAutomaticMarkerSize  ) 

This option is on by default, it means that Marker sizes in the Legend will be the same as the font height used for their respective label texts.

Set this to false, if you want to specify the marker sizes via setMarkerAttributes or if you want the Legend to use the same marker sizes as they are used in the Diagrams.

Definition at line 497 of file KDChartLegend.cpp.

References d.

Referenced by clone().

00498 {
00499     d->useAutomaticMarkerSize = useAutomaticMarkerSize;
00500     setNeedRebuild();
00501     emitPositionChanged();
00502 }

void Legend::setVisible ( bool  visible  )  [virtual]

Definition at line 409 of file KDChartLegend.cpp.

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

00410 {
00411     if( isVisible() == visible )
00412         return;
00413     QWidget::setVisible( visible );
00414     emitPositionChanged();
00415 }

bool Legend::showLines (  )  const

Definition at line 492 of file KDChartLegend.cpp.

References d.

Referenced by compare().

00493 {
00494     return d->showLines;
00495 }

QSize Legend::sizeHint (  )  const [virtual]

Definition at line 150 of file KDChartLegend.cpp.

References d.

Referenced by minimumSizeHint(), KDChart::Chart::reLayoutFloatingLegends(), and resizeEvent().

00151 {
00152 #ifdef DEBUG_LEGEND_PAINT
00153     qDebug()  << "Legend::sizeHint() started";
00154 #endif
00155     Q_FOREACH( KDChart::AbstractLayoutItem* layoutItem, d->layoutItems ) {
00156         layoutItem->sizeHint();
00157     }
00158     return AbstractAreaWidget::sizeHint();
00159 }

uint Legend::spacing (  )  const

Definition at line 690 of file KDChartLegend.cpp.

References d.

Referenced by compare().

00691 {
00692     return d->spacing;
00693 }

QString Legend::text ( uint  dataset  )  const

Definition at line 528 of file KDChartLegend.cpp.

References d.

00529 {
00530     if( d->texts.find( dataset ) != d->texts.end() ){
00531         return d->texts[ dataset ];
00532     }else{
00533         return d->modelLabels[ dataset ];
00534     }
00535 }

TextAttributes Legend::textAttributes (  )  const

Definition at line 641 of file KDChartLegend.cpp.

References d.

Referenced by KDChart::Chart::addLegend(), clone(), and compare().

00642 {
00643     return d->textAttributes;
00644 }

const QMap< uint, QString > Legend::texts (  )  const

Definition at line 537 of file KDChartLegend.cpp.

References d.

Referenced by compare().

00538 {
00539     return d->texts;
00540 }

QString Legend::titleText (  )  const

Definition at line 653 of file KDChartLegend.cpp.

References d.

Referenced by compare().

00654 {
00655     return d->titleText;
00656 }

TextAttributes Legend::titleTextAttributes (  )  const

Definition at line 665 of file KDChartLegend.cpp.

References d.

Referenced by KDChart::Chart::addLegend(), clone(), and compare().

00666 {
00667     return d->titleTextAttributes;
00668 }

bool Legend::useAutomaticMarkerSize (  )  const

Definition at line 504 of file KDChartLegend.cpp.

References d.

Referenced by clone(), and compare().

00505 {
00506     return d->useAutomaticMarkerSize;
00507 }


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