#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 & | r | ) |
Definition at line 73 of file KDChartTextAttributes.cpp.
00074 : _d( new Private( *r.d ) ) 00075 { 00076 00077 }
TextAttributes::~TextAttributes | ( | ) |
bool TextAttributes::autoRotate | ( | ) | const |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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.
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.
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.
font | The font to use. |
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.
measure | The measure to use. |
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.
measure | The measure to use. |
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.
pen | The pen to use. |
Definition at line 232 of file KDChartTextAttributes.cpp.
References d.
Referenced by KDChart::LeveyJenningsAxis::setType(), and TextAttributes().
void TextAttributes::setRotation | ( | int | rotation | ) |
Set the rotation angle to use for the text.
rotation | The rotation angle. |
Definition at line 222 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 123 of file KDChartTextAttributes.cpp.
References d.
Referenced by TextAttributes().
00124 { 00125 d->visible = visible; 00126 }