lib Library API Documentation

KoTextFormat Class Reference

Each character (KoTextStringChar) points to a KoTextFormat that defines the formatting of that character (font, bold, italic, underline, misspelled etc.). More...

#include <kotextformat.h>

Collaboration diagram for KoTextFormat:

Collaboration graph
[legend]
List of all members.

Public Types

enum  Flags {
  NoFlags, Bold = 1, Italic = 2, Underline = 4,
  Family = 8, Size = 16, Color = 32, Misspelled = 64,
  VAlign = 128, StrikeOut = 512, TextBackgroundColor = 1024, ExtendUnderLine = 2048,
  Language = 4096, ShadowText = 8192, OffsetFromBaseLine = 16384, WordByWord = 32768,
  Attribute = 65536, Hyphenation = 131072, UnderLineWidth = 262144, Font = Bold | Italic | Underline | Family | Size,
  Format
}
enum  VerticalAlignment { AlignNormal, AlignSubScript, AlignSuperScript }
enum  UnderlineType {
  U_NONE = 0, U_SIMPLE = 1, U_DOUBLE = 2, U_SIMPLE_BOLD = 3,
  U_WAVE = 4
}
enum  StrikeOutType { S_NONE = 0, S_SIMPLE = 1, S_DOUBLE = 2, S_SIMPLE_BOLD = 3 }
enum  UnderlineStyle {
  U_SOLID = 0, U_DASH = 1, U_DOT = 2, U_DASH_DOT = 3,
  U_DASH_DOT_DOT = 4
}
enum  StrikeOutStyle {
  S_SOLID = 0, S_DASH = 1, S_DOT = 2, S_DASH_DOT = 3,
  S_DASH_DOT_DOT = 4
}
enum  AttributeStyle { ATT_NONE = 0, ATT_UPPER = 1, ATT_LOWER = 2, ATT_SMALL_CAPS }

Public Member Functions

 KoTextFormat (const QFont &f, const QColor &c, const QString &_language, bool hyphenation, double ulw, KoTextFormatCollection *parent=0)
 KoTextFormat (const QFont &_font, VerticalAlignment _valign, const QColor &_color, const QColor &_backGroundColor, const QColor &_underlineColor, KoTextFormat::UnderlineType _underlineType, KoTextFormat::UnderlineStyle _underlineStyle, KoTextFormat::StrikeOutType _strikeOutType, KoTextFormat::StrikeOutStyle _strikeOutStyle, KoTextFormat::AttributeStyle _fontAttribute, const QString &_language, double _relativeTextSize, int _offsetFromBaseLine, bool _wordByWord, bool _hyphenation, double _shadowDistanceX, double _shadowDistanceY, const QColor &shadowColor)
 KoTextFormat (const KoTextFormat &fm)
KoTextFormatoperator= (const KoTextFormat &fm)
void copyFormat (const KoTextFormat &fm, int flags)
QColor color () const
QFont font () const
int pointSize () const
bool isMisspelled () const
VerticalAlignment vAlign () const
int width (const QChar &c) const
int width (const QString &str, int pos) const
int height () const
int ascent () const
int descent () const
int offsetX () const
int offsetY () const
void setBold (bool b)
void setItalic (bool b)
void setUnderline (bool b)
void setFamily (const QString &f)
void setPointSize (int s)
void setFont (const QFont &f)
void setColor (const QColor &c)
void setMisspelled (bool b)
void setVAlign (VerticalAlignment a)
bool operator== (const KoTextFormat &f) const
KoTextFormatCollection * parent () const
void setCollection (KoTextFormatCollection *parent)
QString key () const
void addRef ()
void removeRef ()
int compare (const KoTextFormat &format) const
void setStrikeOutType (StrikeOutType _type)
StrikeOutType strikeOutType () const
void setStrikeOutStyle (StrikeOutStyle _type)
StrikeOutStyle strikeOutStyle () const
void setTextBackgroundColor (const QColor &)
QColor textBackgroundColor () const
void setTextUnderlineColor (const QColor &)
QColor textUnderlineColor () const
void setUnderlineType (UnderlineType _type)
UnderlineType underlineType () const
void setUnderlineStyle (UnderlineStyle _type)
UnderlineStyle underlineStyle () const
void setLanguage (const QString &_lang)
QString language () const
void setHyphenation (bool b)
bool hyphenation () const
void setUnderLineWidth (double ulw)
double underLineWidth () const
void setAttributeFont (KoTextFormat::AttributeStyle _att)
KoTextFormat::AttributeStyle attributeFont () const
double shadowDistanceX () const
double shadowDistanceY () const
QColor shadowColor () const
int shadowX (KoZoomHandler *zh) const
int shadowY (KoZoomHandler *zh) const
void setShadow (double shadowDistanceX, double shadowDistanceY, const QColor &shadowColor)
QString shadowAsCss () const
void parseShadowFromCss (const QString &css)
double relativeTextSize () const
void setRelativeTextSize (double _size)
int offsetFromBaseLine () const
void setOffsetFromBaseLine (int _offset)
bool wordByWord () const
void setWordByWord (bool _b)
bool doubleUnderline () const
bool waveUnderline () const
bool underline () const
bool strikeOut () const
bool doubleStrikeOut () const
bool isStrikedOrUnderlined () const
float refPointSize () const
float screenPointSize (const KoZoomHandler *zh) const
const QFontMetricsrefFontMetrics () const
const QFontMetricsscreenFontMetrics (const KoZoomHandler *zh) const
QFont refFont () const
QFont screenFont (const KoZoomHandler *zh) const
QFont smallCapsFont (const KoZoomHandler *zh, bool applyZoom) const
int charWidth (const KoZoomHandler *zh, bool applyZoom, const KoTextStringChar *c, const KoTextParag *parag, int i) const
int charWidthLU (const KoTextStringChar *c, const KoTextParag *parag, int i) const
void applyCharStyle (KoCharStyle *_style)
KoCharStyle * style () const
QString displayedString (const QString &c) const
void printDebug ()

Static Public Member Functions

QString getKey (const QFont &f, const QColor &c, bool misspelled, VerticalAlignment vAlign)
QColor defaultTextColor (QPainter *painter)
QString shadowAsCss (double shadowDistanceX, double shadowDistanceY, const QColor &shadowColor)
QString underlineStyleToString (UnderlineStyle _lineType)
QString strikeOutStyleToString (StrikeOutStyle _lineType)
UnderlineStyle stringToUnderlineStyle (const QString &_str)
StrikeOutStyle stringToStrikeOutStyle (const QString &_str)
QString attributeFontToString (KoTextFormat::AttributeStyle _attr)
AttributeStyle stringToAttributeFont (const QString &_str)
QStringList underlineTypeList ()
QStringList strikeOutTypeList ()
QStringList fontAttributeList ()
QStringList underlineStyleList ()
QStringList strikeOutStyleList ()

Protected Member Functions

QChar displayedChar (QChar c) const
void generateKey ()

Friends

class KoTextFormatCollection

Detailed Description

Each character (KoTextStringChar) points to a KoTextFormat that defines the formatting of that character (font, bold, italic, underline, misspelled etc.).

Formats are stored in KoTextFormatCollection and are shared for all characters with the same format. The API rule is that a const KoTextFormat* is a temporary format (out of collection) and a KoTextFormat* is a format from the collection.

Definition at line 48 of file kotextformat.h.


Constructor & Destructor Documentation

KoTextFormat::KoTextFormat const QFont f,
const QColor c,
const QString _language,
bool  hyphenation,
double  ulw,
KoTextFormatCollection *  parent = 0
 

A simple text format.

Definition at line 76 of file kotextformat.cc.

References QFont::pointSize().

KoTextFormat::KoTextFormat const QFont _font,
VerticalAlignment  _valign,
const QColor _color,
const QColor _backGroundColor,
const QColor _underlineColor,
KoTextFormat::UnderlineType  _underlineType,
KoTextFormat::UnderlineStyle  _underlineStyle,
KoTextFormat::StrikeOutType  _strikeOutType,
KoTextFormat::StrikeOutStyle  _strikeOutStyle,
KoTextFormat::AttributeStyle  _fontAttribute,
const QString _language,
double  _relativeTextSize,
int  _offsetFromBaseLine,
bool  _wordByWord,
bool  _hyphenation,
double  _shadowDistanceX,
double  _shadowDistanceY,
const QColor shadowColor
 

A complete text format (used by KoFontDia).

Definition at line 121 of file kotextformat.cc.


Member Function Documentation

int KoTextFormat::width const QChar c  )  const
 

Return the width of one char (from a string, not necessarily from a paragraph) in LU pixels.

Do not call this for custom items, or for complex glyphs. But this can still be used for ' ' (for parag counters), 'x' (for tabs) etc.

Definition at line 968 of file kotextformat.cc.

References KoTextZoomHandler::ptToLayoutUnitPt(), and refFontMetrics().

int KoTextFormat::compare const KoTextFormat format  )  const
 

Return a set of flags showing the differences between this and 'format'.

Definition at line 598 of file kotextformat.cc.

References attributeFont(), color(), fn, hyphenation(), QFont::italic(), language(), offsetFromBaseLine(), pointSize(), relativeTextSize(), shadowColor(), shadowDistanceX(), shadowDistanceY(), strikeOutType(), textBackgroundColor(), textUnderlineColor(), underlineStyle(), underlineType(), underLineWidth(), vAlign(), QFont::weight(), and wordByWord().

QColor KoTextFormat::defaultTextColor QPainter painter  )  [static]
 

Call this when a text color is set to 'invalid', meaning 'whatever the default for the color scheme is'.

Definition at line 642 of file kotextformat.cc.

Referenced by KoVariable::drawCustomItemHelper().

int KoTextFormat::shadowX KoZoomHandler zh  )  const
 

Return the amount of pixels for the horizontal shadow distance at a given zoom level.

Definition at line 1053 of file kotextformat.cc.

References KoZoomHandler::zoomItX().

int KoTextFormat::shadowY KoZoomHandler zh  )  const
 

Return the amount of pixels for the vertical shadow distance at a given zoom level.

Definition at line 1058 of file kotextformat.cc.

References KoZoomHandler::zoomItY().

QString KoTextFormat::shadowAsCss  )  const
 

Return css string for the shadow, used when saving.

Definition at line 999 of file kotextformat.cc.

Referenced by KoParagLayout::loadParagLayout().

void KoTextFormat::parseShadowFromCss const QString css  ) 
 

Load shadow attributes from a css string, used when loading.

Definition at line 1004 of file kotextformat.cc.

References KoUnit::parseValue().

float KoTextFormat::refPointSize  )  const
 

Returns:
the reference point size, i.e. the size specified by the user. This is the one used during formatting, independently from the zoom level. This method takes care of superscript and subscript (smaller font).

Definition at line 658 of file kotextformat.cc.

Referenced by refFont().

float KoTextFormat::screenPointSize const KoZoomHandler zh  )  const
 

Returns:
the point size to use on screen, given zh This method takes care of superscript and subscript (smaller font).

Definition at line 649 of file kotextformat.cc.

References KoZoomHandler::layoutUnitToFontSize(), and KoTextZoomHandler::ptToLayoutUnitPt().

Referenced by screenFont().

const QFontMetrics & KoTextFormat::refFontMetrics  )  const
 

Returns:
the metrics for the reference font, i.e. with the size specified by the user. This is the one used during formatting, independently from the zoom level. This method takes care of superscript and subscript (smaller font).

Definition at line 715 of file kotextformat.cc.

References refFont().

Referenced by charWidth(), and width().

const QFontMetrics & KoTextFormat::screenFontMetrics const KoZoomHandler zh  )  const
 

Returns the font metrics for the font used at the zoom & resolution given by 'zh'.

Despite the name, this is probably valid for printing too. This method takes care of superscript and subscript (smaller font).

Definition at line 702 of file kotextformat.cc.

References screenFont().

Referenced by charWidth().

QFont KoTextFormat::refFont  )  const
 

Returns:
the reference font, i.e. with the size specified by the user. This is used at text layout time (e.g. kotextformatter)

Definition at line 666 of file kotextformat.cc.

References refPointSize().

Referenced by refFontMetrics().

QFont KoTextFormat::screenFont const KoZoomHandler zh  )  const
 

Returns the font to be used at the zoom & resolution given by 'zh'.

Despite the name, this is probably valid for printing too. This method takes care of superscript and subscript (smaller font).

Definition at line 681 of file kotextformat.cc.

References screenPointSize().

Referenced by screenFontMetrics().

int KoTextFormat::charWidth const KoZoomHandler zh,
bool  applyZoom,
const KoTextStringChar *  c,
const KoTextParag *  parag,
int  i
const
 

Return the width of one char in one paragraph.

Used by KoTextFormatter twice: once for the 100% zoom pointsize (via charWidthLU), and once for the current zoom pointsize.

Definition at line 737 of file kotextformat.cc.

References refFontMetrics(), screenFontMetrics(), and KoZoomHandler::zoom().

Referenced by charWidthLU().

int KoTextFormat::charWidthLU const KoTextStringChar *  c,
const KoTextParag *  parag,
int  i
const
 

Return the width of one char in LU pixels.

Equivalent to ptToLayoutUnitPt( charWidth( 0L, false, c, parag, i ) )

Definition at line 961 of file kotextformat.cc.

References charWidth(), and KoTextZoomHandler::ptToLayoutUnitPt().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Mar 11 11:50:05 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003