KDChart::TextAttributes Class Reference

#include <KDChartTextAttributes.h>

List of all members.


Detailed Description

A set of text attributes.

TextAttributes encapsulates settings that have to do with text. This includes font, fontsize, color, whether the text is rotated, etc

Definition at line 50 of file KDChartTextAttributes.h.


Public Member Functions

bool autoRotate () const
 
Returns:
Whether text is automatically rotated when space is constrained.

bool autoShrink () const
 
Returns:
Whether text is automatically shrunk if space is constraint.

const QFont calculatedFont (const QObject *autoReferenceArea, KDChartEnums::MeasureOrientation autoReferenceOrientation) const
 Returns the font in the size that is used at drawing time.
const qreal calculatedFontSize (const QObject *autoReferenceArea, KDChartEnums::MeasureOrientation autoReferenceOrientation) const
 Returns the font size that is used at drawing time.
QFont font () const
 
Returns:
The font that is used for rendering text.

Measure fontSize () const
 
Returns:
The measure used for the font size.

bool hasAbsoluteFontSize () const
 
Returns:
Whether the text has an absolute font size set.

bool isVisible () const
 
Returns:
Whether the text is visible.

Measure minimalFontSize () const
 
Returns:
The measure used for the minimal font size.

bool operator!= (const TextAttributes &other) const
TextAttributesoperator= (const TextAttributes &)
bool operator== (const TextAttributes &) const
QPen pen () const
 
Returns:
The pen used for rendering the text.

int rotation () const
 
Returns:
The rotation angle used for rendering the text.

void setAutoRotate (bool autoRotate)
 Set whether the text should be automatically rotated as needed when space is constraint.
void setAutoShrink (bool autoShrink)
 Set whether the text should automatically be shrunk, if space is constraint.
void setFont (const QFont &font)
 Set the font to be used for rendering the text.
void setFontSize (const Measure &measure)
 Set the size of the font used for rendering text.
void setMinimalFontSize (const Measure &measure)
 Set the minimal size of the font used for rendering text.
void setPen (const QPen &pen)
 Set the pen to use for rendering the text.
void setRotation (int rotation)
 Set the rotation angle to use for the text.
void setVisible (bool visible)
 Set whether the text is to be rendered at all.
 TextAttributes (const TextAttributes &)
 TextAttributes ()
 ~TextAttributes ()

Constructor & Destructor Documentation

TextAttributes::TextAttributes (  ) 

Definition at line 62 of file KDChartTextAttributes.cpp.

References setAutoRotate(), setAutoShrink(), setFont(), setPen(), setRotation(), and setVisible().

00063     : _d( new Private() )
00064 {
00065     setVisible( true );
00066     setFont( QApplication::font() );
00067     setAutoRotate( false );
00068     setAutoShrink( false );
00069     setRotation( 0 );
00070     setPen( QPen( Qt::black ) );
00071 }

TextAttributes::TextAttributes ( const TextAttributes r  ) 

Definition at line 73 of file KDChartTextAttributes.cpp.

00074     : _d( new Private( *r.d ) )
00075 {
00076 
00077 }

TextAttributes::~TextAttributes (  ) 

Definition at line 89 of file KDChartTextAttributes.cpp.

00090 {
00091     delete _d; _d = 0;
00092 }


Member Function Documentation

bool TextAttributes::autoRotate (  )  const

Returns:
Whether text is automatically rotated when space is constrained.

Definition at line 207 of file KDChartTextAttributes.cpp.

References d.

Referenced by operator<<(), and operator==().

00208 {
00209     return d->autoRotate;
00210 }

bool TextAttributes::autoShrink (  )  const

Returns:
Whether text is automatically shrunk if space is constraint.

Definition at line 217 of file KDChartTextAttributes.cpp.

References d.

Referenced by operator<<(), operator==(), and KDChart::TextLayoutItem::paint().

00218 {
00219     return d->autoShrink;
00220 }

const QFont TextAttributes::calculatedFont ( const QObject autoReferenceArea,
KDChartEnums::MeasureOrientation  autoReferenceOrientation 
) const

Returns the font in the size that is used at drawing time.

This method is called at drawing time. It returns the font as it is used for rendering text, taking into account any measures that were set via setFontSize and/or setMinimalFontSize.

Definition at line 187 of file KDChartTextAttributes.cpp.

References calculatedFontSize(), and d.

Referenced by KDChart::LeveyJenningsDiagram::iconRect().

00190 {
00191     const qreal size = calculatedFontSize( autoReferenceArea, autoReferenceOrientation );
00192     //qDebug() << "TextAttributes::calculatedFont() has   d->cachedFontSize" << d->cachedFontSize << "  calculatedFontSize" << size;
00193     if( size > 0.0 && d->cachedFontSize != size ){
00194         //qDebug() << "new into the cache:" << size;
00195         d->cachedFontSize = size;
00196         d->cachedFont.setPointSizeF( d->cachedFontSize );
00197     }
00198     return d->cachedFont;
00199 }

const qreal TextAttributes::calculatedFontSize ( const QObject autoReferenceArea,
KDChartEnums::MeasureOrientation  autoReferenceOrientation 
) const

Returns the font size that is used at drawing time.

This method is called at drawing time. It returns the font size as it is used for rendering text, taking into account any measures that were set via setFontSize and/or setMinimalFontSize.

Definition at line 176 of file KDChartTextAttributes.cpp.

References KDChart::Measure::calculatedValue(), fontSize(), and minimalFontSize().

Referenced by calculatedFont(), and KDChart::TextLayoutItem::realFontSize().

00179 {
00180     const qreal normalSize  = fontSize().calculatedValue(        autoReferenceArea, autoReferenceOrientation );
00181     const qreal minimalSize = minimalFontSize().calculatedValue( autoReferenceArea, autoReferenceOrientation );
00182     //qDebug() << "TextAttributes::calculatedFontSize() finds" << normalSize << "and" << minimalSize;
00183     return qMax( normalSize, minimalSize );
00184 }

QFont TextAttributes::font (  )  const

Returns:
The font that is used for rendering text.

Definition at line 141 of file KDChartTextAttributes.cpp.

References d.

Referenced by operator<<(), operator==(), and KDChart::TextLayoutItem::setTextAttributes().

00142 {
00143     return d->font;
00144 }

Measure TextAttributes::fontSize (  )  const

Returns:
The measure used for the font size.

Definition at line 151 of file KDChartTextAttributes.cpp.

References d.

Referenced by calculatedFontSize(), operator<<(), operator==(), and KDChart::CartesianAxis::titleTextAttributes().

00152 {
00153     return d->fontSize;
00154 }

bool TextAttributes::hasAbsoluteFontSize (  )  const

Returns:
Whether the text has an absolute font size set.

Definition at line 166 of file KDChartTextAttributes.cpp.

References d, and KDChartEnums::MeasureCalculationModeAbsolute.

00167 {
00168     return d->fontSize.calculationMode() == KDChartEnums::MeasureCalculationModeAbsolute
00169         && d->minimalFontSize.calculationMode() == KDChartEnums::MeasureCalculationModeAbsolute;
00170 }

bool TextAttributes::isVisible (  )  const

Returns:
Whether the text is visible.

Definition at line 128 of file KDChartTextAttributes.cpp.

References d.

Referenced by operator<<(), operator==(), KDChart::LeveyJenningsAxis::paintAsAbscissa(), KDChart::LeveyJenningsAxis::paintAsOrdinate(), and KDChart::CartesianAxis::paintCtx().

00129 {
00130     return d->visible;
00131 }

Measure TextAttributes::minimalFontSize (  )  const

Returns:
The measure used for the minimal font size.

Definition at line 161 of file KDChartTextAttributes.cpp.

References d.

Referenced by calculatedFontSize(), operator<<(), and operator==().

00162 {
00163     return d->minimalFontSize;
00164 }

bool KDChart::TextAttributes::operator!= ( const TextAttributes other  )  const

Definition at line 57 of file KDChartTextAttributes.h.

References KDGantt::operator==().

00058   { return !operator==(other); }

TextAttributes & TextAttributes::operator= ( const TextAttributes r  ) 

Definition at line 79 of file KDChartTextAttributes.cpp.

References d.

00080 {
00081     if( this == &r )
00082         return *this;
00083 
00084     *d = *r.d;
00085 
00086     return *this;
00087 }

bool TextAttributes::operator== ( const TextAttributes r  )  const

Definition at line 95 of file KDChartTextAttributes.cpp.

References autoRotate(), autoShrink(), font(), fontSize(), isVisible(), minimalFontSize(), pen(), and rotation().

00096 {
00097     // the following works around a bug in gcc 4.3.2
00098     // causing StyleHint to be set to Zero when copying a QFont
00099     const QFont myFont( font() );
00100     QFont r_font( r.font() );
00101     r_font.setStyleHint( myFont.styleHint(), myFont.styleStrategy() );
00102     /*
00103     qDebug() << "\nTextAttributes::operator== :" << ( isVisible() == r.isVisible())
00104             << " font:"<<(myFont == r_font)
00105             << " fontSize:"<<(fontSize() == r.fontSize())
00106             << " minimalFontSize:"<<(minimalFontSize() == r.minimalFontSize())
00107             << (autoRotate() == r.autoRotate())
00108             << (autoShrink() == r.autoShrink())
00109             << (rotation() == rotation())
00110             << (pen() == r.pen());
00111     */
00112     return ( isVisible() == r.isVisible() &&
00113             myFont == r_font &&
00114             fontSize() == r.fontSize() &&
00115             minimalFontSize() == r.minimalFontSize() &&
00116             autoRotate() == r.autoRotate() &&
00117             autoShrink() == r.autoShrink() &&
00118             rotation() == r.rotation() &&
00119             pen() == r.pen() );
00120 }

QPen TextAttributes::pen (  )  const

Returns:
The pen used for rendering the text.

Definition at line 237 of file KDChartTextAttributes.cpp.

References d.

Referenced by operator<<(), operator==(), KDChart::TextLayoutItem::paint(), KDChart::LeveyJenningsAxis::paintAsOrdinate(), KDChart::CartesianAxis::paintCtx(), and KDChart::LeveyJenningsAxis::setType().

00238 {
00239     return d->pen;
00240 }

int TextAttributes::rotation (  )  const

Returns:
The rotation angle used for rendering the text.

Definition at line 227 of file KDChartTextAttributes.cpp.

References d.

Referenced by KDChart::TextLayoutItem::intersects(), operator<<(), operator==(), KDChart::TextLayoutItem::paint(), KDChart::CartesianAxis::paintCtx(), and KDChart::TextLayoutItem::sizeHintAndRotatedCorners().

00228 {
00229     return d->rotation;
00230 }

void TextAttributes::setAutoRotate ( bool  autoRotate  ) 

Set whether the text should be automatically rotated as needed when space is constraint.

Parameters:
autoRotate Whether text should be automatically rotated.

Definition at line 202 of file KDChartTextAttributes.cpp.

References d.

Referenced by TextAttributes().

00203 {
00204     d->autoRotate = autoRotate;
00205 }

void TextAttributes::setAutoShrink ( bool  autoShrink  ) 

Set whether the text should automatically be shrunk, if space is constraint.

Parameters:
autoShrink Whether text should be auto-shrunk.

Definition at line 212 of file KDChartTextAttributes.cpp.

References d.

Referenced by TextAttributes().

00213 {
00214     d->autoShrink = autoShrink;
00215 }

void TextAttributes::setFont ( const QFont &  font  ) 

Set the font to be used for rendering the text.

Note:
All of the font's attributes will be used - except of its size! To specify the size please use setFontSize (or setMinimalFontSize, resp.)
Parameters:
font The font to use.
See also:
setFontSize, setMinimalFontSize

Definition at line 133 of file KDChartTextAttributes.cpp.

References d.

Referenced by TextAttributes().

00134 {
00135     d->font       = font;
00136     d->cachedFont = font; // note: we do not set the font's size here, but in calculatedFont()
00137     //qDebug() << "resetting cached font size";
00138     d->cachedFontSize = -1.0;
00139 }

void TextAttributes::setFontSize ( const Measure measure  ) 

Set the size of the font used for rendering text.

Parameters:
measure The measure to use.
See also:
Measure

Definition at line 146 of file KDChartTextAttributes.cpp.

References d.

Referenced by KDChart::Chart::addLegend(), KDChart::LeveyJenningsDiagram::iconRect(), and KDChart::CartesianAxis::titleTextAttributes().

00147 {
00148     d->fontSize = measure;
00149 }

void TextAttributes::setMinimalFontSize ( const Measure measure  ) 

Set the minimal size of the font used for rendering text.

Parameters:
measure The measure to use.
See also:
Measure

Definition at line 156 of file KDChartTextAttributes.cpp.

References d.

00157 {
00158     d->minimalFontSize = measure;
00159 }

void TextAttributes::setPen ( const QPen &  pen  ) 

Set the pen to use for rendering the text.

Parameters:
pen The pen to use.

Definition at line 232 of file KDChartTextAttributes.cpp.

References d.

Referenced by KDChart::LeveyJenningsAxis::setType(), and TextAttributes().

00233 {
00234     d->pen = pen;
00235 }

void TextAttributes::setRotation ( int  rotation  ) 

Set the rotation angle to use for the text.

Note:
For axis titles the rotation angle can be set to one of the following angles: 0, 90, 180, 270 Any other values specified will be replaced by the next smaller one of the allowed values, so no matter what you set the rotation will always be one of these four values.
Parameters:
rotation The rotation angle.

Definition at line 222 of file KDChartTextAttributes.cpp.

References d.

Referenced by TextAttributes().

00223 {
00224     d->rotation = rotation;
00225 }

void TextAttributes::setVisible ( bool  visible  ) 

Set whether the text is to be rendered at all.

Parameters:
visible Whether the text is visible.

Definition at line 123 of file KDChartTextAttributes.cpp.

References d.

Referenced by TextAttributes().

00124 {
00125     d->visible = visible;
00126 }


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