#include <KDChartTextAttributes.h>
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 |
| |
bool | autoShrink () const |
| |
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 |
| |
Measure | fontSize () const |
| |
bool | hasAbsoluteFontSize () const |
| |
bool | isVisible () const |
| |
Measure | minimalFontSize () const |
| |
bool | operator!= (const TextAttributes &other) const |
TextAttributes & | operator= (const TextAttributes &) |
bool | operator== (const TextAttributes &) const |
QPen | pen () const |
| |
int | rotation () const |
| |
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 () |
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 & | ) |
TextAttributes::~TextAttributes | ( | ) |
bool TextAttributes::autoRotate | ( | ) | const |
Definition at line 197 of file KDChartTextAttributes.cpp.
References d.
Referenced by operator<<(), and operator==().
00198 { 00199 return d->autoRotate; 00200 }
bool TextAttributes::autoShrink | ( | ) | const |
Definition at line 207 of file KDChartTextAttributes.cpp.
References d.
Referenced by operator<<(), and operator==().
00208 { 00209 return d->autoShrink; 00210 }
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 178 of file KDChartTextAttributes.cpp.
References calculatedFontSize(), and d.
00181 { 00182 const qreal size = calculatedFontSize( autoReferenceArea, autoReferenceOrientation ); 00183 //qDebug() << "TextAttributes::calculatedFont() has d->cachedFontSize" << d->cachedFontSize << " calculatedFontSize" << calculatedFontSize; 00184 if( size > 0.0 && d->cachedFontSize != size ){ 00185 d->cachedFontSize = size; 00186 d->cachedFont.setPointSizeF( d->cachedFontSize ); 00187 } 00188 return d->cachedFont; 00189 }
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 167 of file KDChartTextAttributes.cpp.
References KDChart::Measure::calculatedValue(), fontSize(), and minimalFontSize().
Referenced by calculatedFont(), and KDChart::TextLayoutItem::realFontSize().
00170 { 00171 const qreal normalSize = fontSize().calculatedValue( autoReferenceArea, autoReferenceOrientation ); 00172 const qreal minimalSize = minimalFontSize().calculatedValue( autoReferenceArea, autoReferenceOrientation ); 00173 //qDebug() << "TextAttributes::calculatedFontSize() finds" << normalSize << "and" << minimalSize; 00174 return qMax( normalSize, minimalSize ); 00175 }
QFont TextAttributes::font | ( | ) | const |
Definition at line 135 of file KDChartTextAttributes.cpp.
References d.
Referenced by operator<<(), and operator==().
00136 { 00137 return d->font; 00138 }
Measure TextAttributes::fontSize | ( | ) | const |
Definition at line 145 of file KDChartTextAttributes.cpp.
References d.
Referenced by calculatedFontSize(), operator<<(), operator==(), and KDChart::CartesianAxis::titleTextAttributes().
00146 { 00147 return d->fontSize; 00148 }
bool TextAttributes::hasAbsoluteFontSize | ( | ) | const |
Definition at line 160 of file KDChartTextAttributes.cpp.
References d, and KDChartEnums::MeasureCalculationModeAbsolute.
00161 { 00162 return d->fontSize.calculationMode() == KDChartEnums::MeasureCalculationModeAbsolute 00163 && d->minimalFontSize.calculationMode() == KDChartEnums::MeasureCalculationModeAbsolute; 00164 }
bool TextAttributes::isVisible | ( | ) | const |
Definition at line 123 of file KDChartTextAttributes.cpp.
References d.
Referenced by KDChart::CartesianAxis::maximumSize(), operator<<(), operator==(), and KDChart::CartesianAxis::paintCtx().
00124 { 00125 return d->visible; 00126 }
Measure TextAttributes::minimalFontSize | ( | ) | const |
Definition at line 155 of file KDChartTextAttributes.cpp.
References d.
Referenced by calculatedFontSize(), operator<<(), and operator==().
00156 { 00157 return d->minimalFontSize; 00158 }
bool KDChart::TextAttributes::operator!= | ( | const TextAttributes & | other | ) | const |
TextAttributes & TextAttributes::operator= | ( | const TextAttributes & | ) |
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 & | ) | const |
Definition at line 95 of file KDChartTextAttributes.cpp.
References autoRotate(), autoShrink(), font(), fontSize(), isVisible(), minimalFontSize(), pen(), and rotation().
00096 { 00097 /* 00098 qDebug() << "\n" << "TextAttributes::operator== :" << ( isVisible() == r.isVisible()) 00099 << (font() == r.font()) 00100 << (fontSize() == r.fontSize()) 00101 << (minimalFontSize() == r.minimalFontSize()) 00102 << (autoRotate() == r.autoRotate()) 00103 << (autoShrink() == r.autoShrink()) 00104 << (rotation() == rotation()) 00105 << (pen() == r.pen()); 00106 */ 00107 return ( isVisible() == r.isVisible() && 00108 font() == r.font() && 00109 fontSize() == r.fontSize() && 00110 minimalFontSize() == r.minimalFontSize() && 00111 autoRotate() == r.autoRotate() && 00112 autoShrink() == r.autoShrink() && 00113 rotation() == r.rotation() && 00114 pen() == r.pen() ); 00115 }
QPen TextAttributes::pen | ( | ) | const |
Definition at line 227 of file KDChartTextAttributes.cpp.
References d.
Referenced by operator<<(), operator==(), KDChart::TextLayoutItem::paint(), and KDChart::CartesianAxis::paintCtx().
00228 { 00229 return d->pen; 00230 }
int TextAttributes::rotation | ( | ) | const |
Definition at line 217 of file KDChartTextAttributes.cpp.
References d.
Referenced by KDChart::TextLayoutItem::intersects(), operator<<(), operator==(), and KDChart::TextLayoutItem::paint().
00218 { 00219 return d->rotation; 00220 }
void TextAttributes::setAutoRotate | ( | bool | autoRotate | ) |
Set whether the text should be automatically rotated as needed when space is constraint.
autoRotate | Whether text should be automatically rotated. |
Definition at line 192 of file KDChartTextAttributes.cpp.
References d.
Referenced by TextAttributes().
00193 { 00194 d->autoRotate = autoRotate; 00195 }
void TextAttributes::setAutoShrink | ( | bool | autoShrink | ) |
Set whether the text should automatically be shrunk, if space is constraint.
autoShrink | Whether text should be auto-shrunk. |
Definition at line 202 of file KDChartTextAttributes.cpp.
References d.
Referenced by TextAttributes().
00203 { 00204 d->autoShrink = autoShrink; 00205 }
void TextAttributes::setFont | ( | const QFont & | font | ) |
Set the font to be used for rendering the text.
font | The font to use. |
Definition at line 128 of file KDChartTextAttributes.cpp.
References d.
Referenced by TextAttributes().
00129 { 00130 d->font = font; 00131 d->cachedFont = font; // note: we do not set the font's size here, but in calculatedFont() 00132 d->cachedFontSize = -1.0; 00133 }
void TextAttributes::setFontSize | ( | const Measure & | measure | ) |
Set the size of the font used for rendering text.
measure | The measure to use. |
Definition at line 140 of file KDChartTextAttributes.cpp.
References d.
Referenced by KDChart::Chart::addLegend(), and KDChart::CartesianAxis::titleTextAttributes().
00141 { 00142 d->fontSize = measure; 00143 }
void TextAttributes::setMinimalFontSize | ( | const Measure & | measure | ) |
Set the minimal size of the font used for rendering text.
measure | The measure to use. |
Definition at line 150 of file KDChartTextAttributes.cpp.
References d.
00151 { 00152 d->minimalFontSize = measure; 00153 }
void TextAttributes::setPen | ( | const QPen & | pen | ) |
Set the pen to use for rendering the text.
pen | The pen to use. |
Definition at line 222 of file KDChartTextAttributes.cpp.
References d.
Referenced by TextAttributes().
void TextAttributes::setRotation | ( | int | rotation | ) |
Set the rotation angle to use for the text.
rotation | The rotation angle. |
Definition at line 212 of file KDChartTextAttributes.cpp.
References d.
Referenced by TextAttributes().
void TextAttributes::setVisible | ( | bool | visible | ) |
Set whether the text is to be rendered at all.
visible | Whether the text is visible. |
Definition at line 118 of file KDChartTextAttributes.cpp.
References d.
Referenced by TextAttributes().
00119 { 00120 d->visible = visible; 00121 }