54 friend class KoTextFormatCollection;
59class KoTextFormatPrivate
62 KoTextFormatPrivate() : m_screenFont( 0L ), m_screenFontMetrics( 0L ),
63 m_refFont( 0L ), m_refFontMetrics( 0L ),
64 m_refAscent( -1 ), m_refDescent( -1 ), m_refHeight( -1 )
67 memset( m_screenWidths, 0, 256 *
sizeof( ushort ) );
70 ~KoTextFormatPrivate()
77 TQFontMetrics* m_screenFontMetrics;
79 TQFontMetrics* m_refFontMetrics;
83 int m_offsetFromBaseLine;
84 ushort m_screenWidths[ 256 ];
86 double m_relativeTextSize;
87 double m_underLineWidth;
90 double m_shadowDistanceX;
91 double m_shadowDistanceY;
92 TQColor m_shadowColor;
110 TextBackgroundColor = 1024,
111 ExtendUnderLine = 2048,
114 OffsetFromBaseLine = 16384,
117 Hyphenation = 131072,
118 UnderLineWidth = 262144,
120 Font = Bold | Italic | Underline | Family | Size,
122 Format = Font | Color | Misspelled | VAlign | StrikeOut | TextBackgroundColor |
123 ExtendUnderLine | Language | ShadowText | OffsetFromBaseLine |
124 WordByWord | Attribute | Hyphenation | UnderLineWidth
127 enum VerticalAlignment { AlignNormal, AlignSubScript, AlignSuperScript, AlignCustom };
128 enum UnderlineType { U_NONE = 0, U_SIMPLE = 1, U_DOUBLE = 2, U_SIMPLE_BOLD = 3, U_WAVE = 4};
129 enum StrikeOutType { S_NONE = 0, S_SIMPLE = 1, S_DOUBLE = 2, S_SIMPLE_BOLD = 3};
130 enum UnderlineStyle { U_SOLID = 0 , U_DASH = 1, U_DOT = 2, U_DASH_DOT = 3, U_DASH_DOT_DOT = 4};
131 enum StrikeOutStyle { S_SOLID = 0 , S_DASH = 1, S_DOT = 2, S_DASH_DOT = 3, S_DASH_DOT_DOT = 4};
133 enum AttributeStyle { ATT_NONE = 0, ATT_UPPER = 1, ATT_LOWER = 2 , ATT_SMALL_CAPS};
141 KoTextFormat(
const TQFont &f,
const TQColor &c,
const TQString &_language,
142 bool hyphenation, KoTextFormatCollection *parent = 0 );
146 VerticalAlignment _valign,
147 const TQColor & _color,
148 const TQColor & _backGroundColor,
149 const TQColor & _underlineColor,
150 KoTextFormat::UnderlineType _underlineType,
151 KoTextFormat::UnderlineStyle _underlineStyle,
152 KoTextFormat::StrikeOutType _strikeOutType,
153 KoTextFormat::StrikeOutStyle _strikeOutStyle,
154 KoTextFormat::AttributeStyle _fontAttribute,
155 const TQString &_language,
156 double _relativeTextSize,
157 int _offsetFromBaseLine,
160 double _shadowDistanceX,
161 double _shadowDistanceY,
162 const TQColor& shadowColor );
168 TQColor color()
const;
170 int pointSize()
const {
return font().pointSize(); }
171 bool isMisspelled()
const;
172 VerticalAlignment vAlign()
const;
180 int width(
const TQChar &c )
const;
181 int width(
const TQString &str,
int pos )
const;
189 void setBold(
bool b );
190 void setItalic(
bool b );
191 void setUnderline(
bool b );
192 void setFamily(
const TQString &f );
193 void setPointSize(
int s );
194 void setFont(
const TQFont &f );
195 void setColor(
const TQColor &c );
196 void setMisspelled(
bool b );
197 void setVAlign( VerticalAlignment a );
200 KoTextFormatCollection *parent()
const;
201 void setCollection( KoTextFormatCollection *parent ) { collection = parent; }
202 TQString key()
const;
204 static TQString getKey(
const TQFont &f,
const TQColor &c,
bool misspelled, VerticalAlignment vAlign );
214 static TQColor defaultTextColor( TQPainter * painter );
216 void setStrikeOutType (StrikeOutType _type);
217 StrikeOutType strikeOutType()
const {
return m_strikeOutType;}
219 void setStrikeOutStyle( StrikeOutStyle _type );
220 StrikeOutStyle strikeOutStyle()
const {
return m_strikeOutStyle;}
223 void setTextBackgroundColor(
const TQColor &);
224 TQColor textBackgroundColor()
const {
return m_textBackColor;}
226 void setTextUnderlineColor(
const TQColor &);
227 TQColor textUnderlineColor()
const {
return m_textUnderlineColor;}
229 void setUnderlineType (UnderlineType _type);
230 UnderlineType underlineType()
const {
return m_underlineType;}
232 void setUnderlineStyle (UnderlineStyle _type);
233 UnderlineStyle underlineStyle()
const {
return m_underlineStyle;}
235 void setLanguage(
const TQString & _lang);
236 TQString language()
const {
return m_language;}
238 void setHyphenation(
bool b );
239 bool hyphenation()
const {
return d->m_bHyphenation; }
243 void setUnderLineWidth(
double ulw );
244 double underLineWidth()
const {
return d->m_underLineWidth; }
247 void setAttributeFont( KoTextFormat::AttributeStyle _att );
248 KoTextFormat::AttributeStyle attributeFont()
const {
return m_attributeFont;}
251 double shadowDistanceX()
const {
return d->m_shadowDistanceX; }
252 double shadowDistanceY()
const {
return d->m_shadowDistanceY; }
253 TQColor shadowColor()
const;
258 void setShadow(
double shadowDistanceX,
double shadowDistanceY,
const TQColor& shadowColor );
260 TQString shadowAsCss()
const;
261 static TQString shadowAsCss(
double shadowDistanceX,
double shadowDistanceY,
const TQColor& shadowColor );
263 void parseShadowFromCss(
const TQString& css );
265 double relativeTextSize()
const {
return d->m_relativeTextSize;}
266 void setRelativeTextSize(
double _size );
269 int offsetFromBaseLine()
const {
return d->m_offsetFromBaseLine;}
270 void setOffsetFromBaseLine(
int _offset );
272 bool wordByWord()
const {
return d->m_bWordByWord;}
273 void setWordByWord(
bool _b );
275 bool doubleUnderline()
const {
return (m_underlineType==U_DOUBLE ); }
276 bool waveUnderline()
const {
return (m_underlineType==U_WAVE ); }
277 bool underline()
const {
return (m_underlineType==U_SIMPLE ); }
278 bool strikeOut()
const {
return (m_strikeOutType==S_SIMPLE ); }
279 bool doubleStrikeOut()
const {
return (m_strikeOutType==S_DOUBLE ); }
280 bool isStrikedOrUnderlined()
const {
return ((m_underlineType != U_NONE) ||(m_strikeOutType!=S_NONE));}
287 float refPointSize()
const;
300 const TQFontMetrics& refFontMetrics()
const;
313 TQFont refFont()
const;
329 int charWidth(
const KoTextZoomHandler* zh,
bool applyZoom,
const KoTextStringChar* c,
330 const KoTextParag* parag,
int i )
const;
336 int charWidthLU(
const KoTextStringChar* c,
337 const KoTextParag* parag,
int i )
const;
341 static TQString underlineStyleToString( UnderlineStyle _lineType );
342 static TQString strikeOutStyleToString( StrikeOutStyle _lineType );
343 static UnderlineStyle stringToUnderlineStyle(
const TQString & _str );
344 static StrikeOutStyle stringToStrikeOutStyle(
const TQString & _str );
346 static TQString attributeFontToString( KoTextFormat::AttributeStyle _attr );
347 static AttributeStyle stringToAttributeFont(
const TQString & _str );
349 TQString displayedString(
const TQString& c )
const;
350 static TQStringList underlineTypeList();
351 static TQStringList strikeOutTypeList();
352 static TQStringList fontAttributeList();
353 static TQStringList underlineStyleList();
354 static TQStringList strikeOutStyleList();
370 TQChar displayedChar( TQChar c )
const;
376 TQColor m_textBackColor;
377 TQColor m_textUnderlineColor;
378 UnderlineType m_underlineType;
379 StrikeOutType m_strikeOutType;
380 UnderlineStyle m_underlineStyle;
381 StrikeOutStyle m_strikeOutStyle;
383 AttributeStyle m_attributeFont;
384 class KoTextFormatPrivate;
385 KoTextFormatPrivate *d;
391 VerticalAlignment va;
392 KoTextFormatCollection *collection;
Used during loading of Oasis format (and discarded at the end of the loading).
Used during saving to Oasis format (and discarded at the end of the saving).
This class extends KoZoomHandler to add support for WYSIWYG text layouting.