summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-write/qstylesheet.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-write/qstylesheet.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-write/qstylesheet.cpp1230
1 files changed, 659 insertions, 571 deletions
diff --git a/noncore/apps/opie-write/qstylesheet.cpp b/noncore/apps/opie-write/qstylesheet.cpp
index 7ab9ec6..67cd828 100644
--- a/noncore/apps/opie-write/qstylesheet.cpp
+++ b/noncore/apps/opie-write/qstylesheet.cpp
@@ -56,2 +56,3 @@ public:
56 int fontunderline; 56 int fontunderline;
57 int fontstrikeout;
57 int fontweight; 58 int fontweight;
@@ -80,22 +81,25 @@ public:
80/*! 81/*!
81 \class QStyleSheetItem qstylesheet.h 82 \class QStyleSheetItem qstylesheet.h
82 \ingroup text 83 \brief The QStyleSheetItem class provides an encapsulation of a set of text styles.
83 \brief The QStyleSheetItem class provides an encapsulation of a set of text styles. 84
84 85 \ingroup text
85 A style sheet item consists of a name and a set of attributes that 86
86 specifiy its font, color, etc. When used in a \link QStyleSheet 87 A style sheet item consists of a name and a set of attributes that
87 style sheet\endlink (see styleSheet()), items define the name() of a 88 specifiy its font, color, etc. When used in a \link QStyleSheet
88 rich text tag and the display property changes associated with it. 89 style sheet\endlink (see styleSheet()), items define the name() of
89 90 a rich text tag and the display property changes associated with
90 The \link QStyleSheetItem::DisplayMode display mode\endlink 91 it.
91 attribute indicates whether the item is a block, an inline element 92
92 or a list element; see setDisplayMode(). The treatment of whitespace 93 The \link QStyleSheetItem::DisplayMode display mode\endlink
93 is controlled by the \link QStyleSheetItem::WhiteSpaceMode white 94 attribute indicates whether the item is a block, an inline element
94 space mode\endlink; see setWhiteSpaceMode(). An item's margins are 95 or a list element; see setDisplayMode(). The treatment of
95 set with setMargin(), and line spacing is set with setLineSpacing(). 96 whitespace is controlled by the \link
96 In the case of list items, the list style is set with 97 QStyleSheetItem::WhiteSpaceMode white space mode\endlink; see
97 setListStyle(). An item may be a hypertext link anchor; see 98 setWhiteSpaceMode(). An item's margins are set with setMargin(),
98 setAnchor(). Other attributes are set with setAlignment(), 99 In the case of list items, the list style is set with
99 setVerticalAlignment(), setFontFamily(), setFontSize(), 100 setListStyle(). An item may be a hypertext link anchor; see
100 setFontWeight(), setFontItalic(), setFontUnderline() and setColor(). 101 setAnchor(). Other attributes are set with setAlignment(),
102 setVerticalAlignment(), setFontFamily(), setFontSize(),
103 setFontWeight(), setFontItalic(), setFontUnderline(),
104 setFontStrikeOut and setColor().
101*/ 105*/
@@ -106,15 +110,17 @@ public:
106 110
107/*! \enum QStyleSheetItem::WhiteSpaceMode 111/*!
112 \enum QStyleSheetItem::WhiteSpaceMode
108 113
109 This enum defines the ways in which QStyleSheet can treat whitespace. There are three values at present: 114 This enum defines the ways in which QStyleSheet can treat
115 whitespace.
110 116
111 \value WhiteSpaceNormal any sequence of whitespace (including 117 \value WhiteSpaceNormal any sequence of whitespace (including
112 line-breaks) is equivalent to a single space. 118 line-breaks) is equivalent to a single space.
113 119
114 \value WhiteSpacePre whitespace must be output exactly as given 120 \value WhiteSpacePre whitespace must be output exactly as given
115 in the input. 121 in the input.
116 122
117 \value WhiteSpaceNoWrap multiple spaces are collapsed as with 123 \value WhiteSpaceNoWrap multiple spaces are collapsed as with
118 WhiteSpaceNormal, but no automatic line-breaks occur. To break lines manually, 124 WhiteSpaceNormal, but no automatic line-breaks occur. To break
119 use the \c{<br>} tag. 125 lines manually, use the \c{<br>} tag.
120 126
@@ -122,12 +128,14 @@ public:
122 128
123/*! \enum QStyleSheetItem::Margin 129/*!
124 130 \enum QStyleSheetItem::Margin
125 \value MarginLeft left margin 131
126 \value MarginRight right margin 132 \value MarginLeft left margin
127 \value MarginTop top margin 133 \value MarginRight right margin
128 \value MarginBottom bottom margin 134 \value MarginTop top margin
129 \value MarginAll all margins (left, right, top and bottom) 135 \value MarginBottom bottom margin
130 \value MarginVertical top and bottom margins 136 \value MarginAll all margins (left, right, top and bottom)
131 \value MarginHorizontal left and right margins 137 \value MarginVertical top and bottom margins
132 \value MarginFirstLine margin (indentation) of the first line of a paragarph (in addition to the MarginLeft of the paragraph) 138 \value MarginHorizontal left and right margins
139 \value MarginFirstLine margin (indentation) of the first line of
140 a paragarph (in addition to the MarginLeft of the paragraph)
133*/ 141*/
@@ -135,7 +143,8 @@ public:
135/*! 143/*!
136 Constructs a new style named \a name for the stylesheet \a parent. 144 Constructs a new style called \a name for the stylesheet \a
145 parent.
137 146
138 All properties in QStyleSheetItem are initially in the "do not change" state, 147 All properties in QStyleSheetItem are initially in the "do not
139 except \link QStyleSheetItem::DisplayMode display mode\endlink, which defaults 148 change" state, except \link QStyleSheetItem::DisplayMode display
140 to \c DisplayInline. 149 mode\endlink, which defaults to \c DisplayInline.
141*/ 150*/
@@ -152,5 +161,5 @@ QStyleSheetItem::QStyleSheetItem( QStyleSheet* parent, const QString& name )
152/*! 161/*!
153 Copy constructor. Constructs a copy of \a other that is 162 Copy constructor. Constructs a copy of \a other that is not bound
154 not bound to any style sheet. 163 to any style sheet.
155 */ 164*/
156QStyleSheetItem::QStyleSheetItem( const QStyleSheetItem & other ) 165QStyleSheetItem::QStyleSheetItem( const QStyleSheetItem & other )
@@ -163,5 +172,5 @@ QStyleSheetItem::QStyleSheetItem( const QStyleSheetItem & other )
163/*! 172/*!
164 Destroys the style. Note that QStyleSheetItem objects become owned 173 Destroys the style. Note that QStyleSheetItem objects become
165 by QStyleSheet when they are created. 174 owned by QStyleSheet when they are created.
166 */ 175*/
167QStyleSheetItem::~QStyleSheetItem() 176QStyleSheetItem::~QStyleSheetItem()
@@ -174,4 +183,4 @@ QStyleSheetItem::~QStyleSheetItem()
174/*! 183/*!
175 Returns the style sheet this item is in. 184 Returns the style sheet this item is in.
176 */ 185*/
177QStyleSheet* QStyleSheetItem::styleSheet() 186QStyleSheet* QStyleSheetItem::styleSheet()
@@ -183,4 +192,5 @@ QStyleSheet* QStyleSheetItem::styleSheet()
183 \overload 192 \overload
184 Returns the style sheet this item is in. 193
185 */ 194 Returns the style sheet this item is in.
195*/
186const QStyleSheet* QStyleSheetItem::styleSheet() const 196const QStyleSheet* QStyleSheetItem::styleSheet() const
@@ -200,2 +210,3 @@ void QStyleSheetItem::init()
200 d->fontunderline = Undefined; 210 d->fontunderline = Undefined;
211 d->fontstrikeout = Undefined;
201 d->fontweight = Undefined; 212 d->fontweight = Undefined;
@@ -214,4 +225,4 @@ void QStyleSheetItem::init()
214 d->margin[4] = Undefined; 225 d->margin[4] = Undefined;
215 d->list = QStyleSheetItem::ListDisc; 226 d->list = (ListStyle) Undefined;
216 d->whitespacemode = QStyleSheetItem::WhiteSpaceNormal; 227 d->whitespacemode = (WhiteSpaceMode) Undefined;
217 d->selfnest = TRUE; 228 d->selfnest = TRUE;
@@ -221,3 +232,3 @@ void QStyleSheetItem::init()
221/*! 232/*!
222 Returns the name of the style item. 233 Returns the name of the style item.
223*/ 234*/
@@ -229,7 +240,7 @@ QString QStyleSheetItem::name() const
229/*! 240/*!
230 Returns the \link QStyleSheetItem::DisplayMode display mode\endlink 241 Returns the \link QStyleSheetItem::DisplayMode display
231 of the style. 242 mode\endlink of the style.
232 243
233 \sa setDisplayMode() 244 \sa setDisplayMode()
234 */ 245*/
235QStyleSheetItem::DisplayMode QStyleSheetItem::displayMode() const 246QStyleSheetItem::DisplayMode QStyleSheetItem::displayMode() const
@@ -239,16 +250,17 @@ QStyleSheetItem::DisplayMode QStyleSheetItem::displayMode() const
239 250
240/*! \enum QStyleSheetItem::DisplayMode 251/*!
252 \enum QStyleSheetItem::DisplayMode
241 253
242 This enum type defines the way adjacent elements are displayed. The possible values are: 254 This enum type defines the way adjacent elements are displayed.
243 255
244 \value DisplayBlock elements are displayed as a rectangular block 256 \value DisplayBlock elements are displayed as a rectangular block
245 (e.g. \c{<p>...</p>}). 257 (e.g. \c{<p>...</p>}).
246 258
247 \value DisplayInline elements are displayed in a horizontally flowing 259 \value DisplayInline elements are displayed in a horizontally
248 sequence (e.g. \c{<em>...</em>}). 260 flowing sequence (e.g. \c{<em>...</em>}).
249 261
250 \value DisplayListItem elements are displayed in a vertical sequence 262 \value DisplayListItem elements are displayed in a vertical
251 (e.g. \c{<li>...</li>}). 263 sequence (e.g. \c{<li>...</li>}).
252 264
253 \value DisplayNone elements are not displayed at all. 265 \value DisplayNone elements are not displayed at all.
254*/ 266*/
@@ -256,5 +268,5 @@ QStyleSheetItem::DisplayMode QStyleSheetItem::displayMode() const
256/*! 268/*!
257 Sets the display mode of the style to \a m. 269 Sets the display mode of the style to \a m.
258 270
259 \sa displayMode() 271 \sa displayMode()
260 */ 272 */
@@ -267,7 +279,8 @@ void QStyleSheetItem::setDisplayMode(DisplayMode m)
267/*! 279/*!
268 Returns the alignment of this style. Possible values are AlignAuto, AlignLeft, 280 Returns the alignment of this style. Possible values are \c
269 AlignRight, AlignCenter and AlignJustify. 281 AlignAuto, \c AlignLeft, \c AlignRight, \c AlignCenter or \c
282 AlignJustify.
270 283
271 \sa setAlignment(), Qt::AlignmentFlags 284 \sa setAlignment(), Qt::AlignmentFlags
272 */ 285*/
273int QStyleSheetItem::alignment() const 286int QStyleSheetItem::alignment() const
@@ -278,9 +291,9 @@ int QStyleSheetItem::alignment() const
278/*! 291/*!
279 Sets the alignment to \a f. This only makes sense for styles with a 292 Sets the alignment to \a f. This only makes sense for styles with
280 \link QStyleSheetItem::DisplayMode display mode\endlink of 293 a \link QStyleSheetItem::DisplayMode display mode\endlink of
281 DisplayBlock. Possible values are AlignAuto, AlignLeft, AlignRight, 294 DisplayBlock. Possible values are \c AlignAuto, \c AlignLeft,
282 AlignCenter and AlignJustify. 295 \c AlignRight, \c AlignCenter or \c AlignJustify.
283 296
284 \sa alignment(), displayMode(), Qt::AlignmentFlags 297 \sa alignment(), displayMode(), Qt::AlignmentFlags
285 */ 298*/
286void QStyleSheetItem::setAlignment( int f ) 299void QStyleSheetItem::setAlignment( int f )
@@ -292,7 +305,7 @@ void QStyleSheetItem::setAlignment( int f )
292/*! 305/*!
293 Returns the vertical alignment of the style. Possible values are 306 Returns the vertical alignment of the style. Possible values are
294 VAlignBaseline, VAlignSub and VAlignSuper. 307 \c VAlignBaseline, \c VAlignSub or \c VAlignSuper.
295 308
296 psa setVerticalAlignment() 309 \sa setVerticalAlignment()
297 */ 310*/
298QStyleSheetItem::VerticalAlignment QStyleSheetItem::verticalAlignment() const 311QStyleSheetItem::VerticalAlignment QStyleSheetItem::verticalAlignment() const
@@ -302,14 +315,15 @@ QStyleSheetItem::VerticalAlignment QStyleSheetItem::verticalAlignment() const
302 315
303/*! \enum QStyleSheetItem::VerticalAlignment 316/*!
317 \enum QStyleSheetItem::VerticalAlignment
304 318
305 This enum type defines the way elements are aligned vertically. This 319 This enum type defines the way elements are aligned vertically.
306 is supported for text elements only. The possible values are: 320 This is only supported for text elements.
307 321
308 \value VAlignBaseline align the baseline of the element (or the 322 \value VAlignBaseline align the baseline of the element (or the
309 bottom, if the element doesn't have a baseline) with the baseline of 323 bottom, if the element doesn't have a baseline) with the
310 the parent 324 baseline of the parent
311 325
312 \value VAlignSub subscript the element 326 \value VAlignSub subscript the element
313 327
314 \value VAlignSuper superscript the element 328 \value VAlignSuper superscript the element
315 329
@@ -319,9 +333,9 @@ QStyleSheetItem::VerticalAlignment QStyleSheetItem::verticalAlignment() const
319/*! 333/*!
320 Sets the vertical alignment to \a valign. Possible values are 334 Sets the vertical alignment to \a valign. Possible values are
321 VAlignBaseline, VAlignSub and VAlignSuper. 335 \c VAlignBaseline, \c VAlignSub or \c VAlignSuper.
322 336
323 The vertical alignment property is not inherited. 337 The vertical alignment property is not inherited.
324 338
325 \sa verticalAlignment() 339 \sa verticalAlignment()
326 */ 340*/
327void QStyleSheetItem::setVerticalAlignment( VerticalAlignment valign ) 341void QStyleSheetItem::setVerticalAlignment( VerticalAlignment valign )
@@ -333,6 +347,7 @@ void QStyleSheetItem::setVerticalAlignment( VerticalAlignment valign )
333/*! 347/*!
334 Returns TRUE if the style sets an italic font; otherwise returns FALSE. 348 Returns TRUE if the style sets an italic font; otherwise returns
349 FALSE.
335 350
336 \sa setFontItalic(), definesFontItalic() 351 \sa setFontItalic(), definesFontItalic()
337 */ 352*/
338bool QStyleSheetItem::fontItalic() const 353bool QStyleSheetItem::fontItalic() const
@@ -346,4 +361,4 @@ bool QStyleSheetItem::fontItalic() const
346 361
347 \sa fontItalic(), definesFontItalic() 362 \sa fontItalic(), definesFontItalic()
348 */ 363*/
349void QStyleSheetItem::setFontItalic(bool italic) 364void QStyleSheetItem::setFontItalic(bool italic)
@@ -354,7 +369,8 @@ void QStyleSheetItem::setFontItalic(bool italic)
354/*! 369/*!
355 Returns whether the style defines a font shape. A style 370 Returns TRUE if the style defines a font shape; otherwise returns
356 does not define any shape until setFontItalic() is called. 371 FALSE. A style does not define any shape until setFontItalic() is
372 called.
357 373
358 \sa setFontItalic(), fontItalic() 374 \sa setFontItalic(), fontItalic()
359 */ 375*/
360bool QStyleSheetItem::definesFontItalic() const 376bool QStyleSheetItem::definesFontItalic() const
@@ -365,6 +381,7 @@ bool QStyleSheetItem::definesFontItalic() const
365/*! 381/*!
366 Returns TRUE if the style sets an underlined font; otherwise returns FALSE. 382 Returns TRUE if the style sets an underlined font; otherwise
383 returns FALSE.
367 384
368 \sa setFontUnderline(), definesFontUnderline() 385 \sa setFontUnderline(), definesFontUnderline()
369 */ 386*/
370bool QStyleSheetItem::fontUnderline() const 387bool QStyleSheetItem::fontUnderline() const
@@ -375,7 +392,7 @@ bool QStyleSheetItem::fontUnderline() const
375/*! 392/*!
376 If \a underline is TRUE sets underline for the style; otherwise sets 393 If \a underline is TRUE, sets underline for the style; otherwise
377 no underline. 394 sets no underline.
378 395
379 \sa fontUnderline(), definesFontUnderline() 396 \sa fontUnderline(), definesFontUnderline()
380 */ 397*/
381void QStyleSheetItem::setFontUnderline(bool underline) 398void QStyleSheetItem::setFontUnderline(bool underline)
@@ -386,7 +403,8 @@ void QStyleSheetItem::setFontUnderline(bool underline)
386/*! 403/*!
387 Returns whether the style defines a setting for the underline 404 Returns TRUE if the style defines a setting for the underline
388 property of the font. A style does not define this until 405 property of the font; otherwise returns FALSE. A style does not
389 setFontUnderline() is called. 406 define this until setFontUnderline() is called.
390 407
391 \sa setFontUnderline(), fontUnderline() */ 408 \sa setFontUnderline(), fontUnderline()
409*/
392bool QStyleSheetItem::definesFontUnderline() const 410bool QStyleSheetItem::definesFontUnderline() const
@@ -398,7 +416,42 @@ bool QStyleSheetItem::definesFontUnderline() const
398/*! 416/*!
399 Returns the font weight setting of the style. This is either a 417 Returns TRUE if the style sets a strike out font; otherwise
400 valid QFont::Weight or the value QStyleSheetItem::Undefined. 418 returns FALSE.
401 419
402 \sa setFontWeight(), QFont 420 \sa setFontStrikeOut(), definesFontStrikeOut()
403 */ 421*/
422bool QStyleSheetItem::fontStrikeOut() const
423{
424 return d->fontstrikeout > 0;
425}
426
427/*!
428 If \a strikeOut is TRUE, sets strike out for the style; otherwise
429 sets no strike out.
430
431 \sa fontStrikeOut(), definesFontStrikeOut()
432*/
433void QStyleSheetItem::setFontStrikeOut(bool strikeOut)
434{
435 d->fontstrikeout = strikeOut?1:0;
436}
437
438/*!
439 Returns TRUE if the style defines a setting for the strikeOut
440 property of the font; otherwise returns FALSE. A style does not
441 define this until setFontStrikeOut() is called.
442
443 \sa setFontStrikeOut(), fontStrikeOut()
444*/
445bool QStyleSheetItem::definesFontStrikeOut() const
446{
447 return d->fontstrikeout != Undefined;
448}
449
450
451/*!
452 Returns the font weight setting of the style. This is either a
453 valid \c QFont::Weight or the value \c QStyleSheetItem::Undefined.
454
455 \sa setFontWeight(), QFont
456*/
404int QStyleSheetItem::fontWeight() const 457int QStyleSheetItem::fontWeight() const
@@ -409,7 +462,7 @@ int QStyleSheetItem::fontWeight() const
409/*! 462/*!
410 Sets the font weight setting of the style to \a w. Valid values are 463 Sets the font weight setting of the style to \a w. Valid values
411 those defined by QFont::Weight. 464 are those defined by \c QFont::Weight.
412 465
413 \sa QFont, fontWeight() 466 \sa QFont, fontWeight()
414 */ 467*/
415void QStyleSheetItem::setFontWeight(int w) 468void QStyleSheetItem::setFontWeight(int w)
@@ -420,7 +473,7 @@ void QStyleSheetItem::setFontWeight(int w)
420/*! 473/*!
421 Returns the logical font size setting of the style. This is either a valid 474 Returns the logical font size setting of the style. This is either
422 size between 1 and 7 or QStyleSheetItem::Undefined. 475 a valid size between 1 and 7 or \c QStyleSheetItem::Undefined.
423 476
424 \sa setLogicalFontSize(), setLogicalFontSizeStep(), QFont::pointSize(), QFont::setPointSize() 477 \sa setLogicalFontSize(), setLogicalFontSizeStep(), QFont::pointSize(), QFont::setPointSize()
425 */ 478*/
426int QStyleSheetItem::logicalFontSize() const 479int QStyleSheetItem::logicalFontSize() const
@@ -432,7 +485,7 @@ int QStyleSheetItem::logicalFontSize() const
432/*! 485/*!
433 Sets the logical font size setting of the style to \a s. 486 Sets the logical font size setting of the style to \a s. Valid
434 Valid logical sizes are 1 to 7. 487 logical sizes are 1 to 7.
435 488
436 \sa logicalFontSize(), QFont::pointSize(), QFont::setPointSize() 489 \sa logicalFontSize(), QFont::pointSize(), QFont::setPointSize()
437 */ 490*/
438void QStyleSheetItem::setLogicalFontSize(int s) 491void QStyleSheetItem::setLogicalFontSize(int s)
@@ -443,9 +496,9 @@ void QStyleSheetItem::setLogicalFontSize(int s)
443/*! 496/*!
444 Returns the logical font size step of this style. 497 Returns the logical font size step of this style.
445 498
446 The default is 0. Tags such as \c big define \c +1; \c small defines 499 The default is 0. Tags such as \c big define \c +1; \c small
447 \c -1. 500 defines \c -1.
448 501
449 \sa setLogicalFontSizeStep() 502 \sa setLogicalFontSizeStep()
450 */ 503*/
451int QStyleSheetItem::logicalFontSizeStep() const 504int QStyleSheetItem::logicalFontSizeStep() const
@@ -456,6 +509,6 @@ int QStyleSheetItem::logicalFontSizeStep() const
456/*! 509/*!
457 Sets the logical font size step of this style to \a s. 510 Sets the logical font size step of this style to \a s.
458 511
459 \sa logicalFontSizeStep() 512 \sa logicalFontSizeStep()
460 */ 513*/
461void QStyleSheetItem::setLogicalFontSizeStep( int s ) 514void QStyleSheetItem::setLogicalFontSizeStep( int s )
@@ -468,6 +521,6 @@ void QStyleSheetItem::setLogicalFontSizeStep( int s )
468/*! 521/*!
469 Sets the font size setting of the style to \a s points. 522 Sets the font size setting of the style to \a s points.
470 523
471 \sa fontSize(), QFont::pointSize(), QFont::setPointSize() 524 \sa fontSize(), QFont::pointSize(), QFont::setPointSize()
472 */ 525*/
473void QStyleSheetItem::setFontSize(int s) 526void QStyleSheetItem::setFontSize(int s)
@@ -478,7 +531,7 @@ void QStyleSheetItem::setFontSize(int s)
478/*! 531/*!
479 Returns the font size setting of the style. This is either a valid 532 Returns the font size setting of the style. This is either a valid
480 point size or QStyleSheetItem::Undefined. 533 point size or \c QStyleSheetItem::Undefined.
481 534
482 \sa setFontSize(), QFont::pointSize(), QFont::setPointSize() 535 \sa setFontSize(), QFont::pointSize(), QFont::setPointSize()
483 */ 536*/
484int QStyleSheetItem::fontSize() const 537int QStyleSheetItem::fontSize() const
@@ -490,7 +543,7 @@ int QStyleSheetItem::fontSize() const
490/*! 543/*!
491 Returns the font family setting of the style. This is either a valid 544 Returns the font family setting of the style. This is either a
492 font family or QString::null if no family has been set. 545 valid font family or QString::null if no family has been set.
493 546
494 \sa setFontFamily(), QFont::family(), QFont::setFamily() 547 \sa setFontFamily(), QFont::family(), QFont::setFamily()
495 */ 548*/
496QString QStyleSheetItem::fontFamily() const 549QString QStyleSheetItem::fontFamily() const
@@ -501,6 +554,6 @@ QString QStyleSheetItem::fontFamily() const
501/*! 554/*!
502 Sets the font family setting of the style to \a fam. 555 Sets the font family setting of the style to \a fam.
503 556
504 \sa fontFamily(), QFont::family(), QFont::setFamily() 557 \sa fontFamily(), QFont::family(), QFont::setFamily()
505 */ 558*/
506void QStyleSheetItem::setFontFamily( const QString& fam) 559void QStyleSheetItem::setFontFamily( const QString& fam)
@@ -524,3 +577,3 @@ int QStyleSheetItem::numberOfColumns() const
524/*!\obsolete 577/*!\obsolete
525 Sets the number of columns for this style. Elements in the style 578 Sets the number of columns for this style. Elements in the style
526 are divided into columns. 579 are divided into columns.
@@ -540,7 +593,7 @@ void QStyleSheetItem::setNumberOfColumns(int ncols)
540/*! 593/*!
541 Returns the text color of this style or an invalid color 594 Returns the text color of this style or an invalid color if no
542 if no color has been set. 595 color has been set.
543 596
544 \sa setColor() QColor::isValid() 597 \sa setColor() QColor::isValid()
545 */ 598*/
546QColor QStyleSheetItem::color() const 599QColor QStyleSheetItem::color() const
@@ -551,6 +604,6 @@ QColor QStyleSheetItem::color() const
551/*! 604/*!
552 Sets the text color of this style to \a c. 605 Sets the text color of this style to \a c.
553 606
554 \sa color() 607 \sa color()
555 */ 608*/
556void QStyleSheetItem::setColor( const QColor &c) 609void QStyleSheetItem::setColor( const QColor &c)
@@ -561,6 +614,6 @@ void QStyleSheetItem::setColor( const QColor &c)
561/*! 614/*!
562 Returns whether this style is an anchor. 615 Returns whether this style is an anchor.
563 616
564 \sa setAnchor() 617 \sa setAnchor()
565 */ 618*/
566bool QStyleSheetItem::isAnchor() const 619bool QStyleSheetItem::isAnchor() const
@@ -571,8 +624,8 @@ bool QStyleSheetItem::isAnchor() const
571/*! 624/*!
572 If \a anc is TRUE sets this style to be an anchor (hypertext link); 625 If \a anc is TRUE, sets this style to be an anchor (hypertext
573 otherwise sets it to not be an anchor. Elements in this style have 626 link); otherwise sets it to not be an anchor. Elements in this
574 connections to other documents or anchors. 627 style link to other documents or anchors.
575 628
576 \sa isAnchor() 629 \sa isAnchor()
577 */ 630*/
578void QStyleSheetItem::setAnchor(bool anc) 631void QStyleSheetItem::setAnchor(bool anc)
@@ -584,6 +637,6 @@ void QStyleSheetItem::setAnchor(bool anc)
584/*! 637/*!
585 Returns the whitespace mode. 638 Returns the whitespace mode.
586 639
587 \sa setWhiteSpaceMode() WhiteSpaceMode 640 \sa setWhiteSpaceMode() WhiteSpaceMode
588 */ 641*/
589QStyleSheetItem::WhiteSpaceMode QStyleSheetItem::whiteSpaceMode() const 642QStyleSheetItem::WhiteSpaceMode QStyleSheetItem::whiteSpaceMode() const
@@ -594,5 +647,6 @@ QStyleSheetItem::WhiteSpaceMode QStyleSheetItem::whiteSpaceMode() const
594/*! 647/*!
595 Sets the whitespace mode to \a m. 648 Sets the whitespace mode to \a m.
596 \sa WhiteSpaceMode 649
597 */ 650 \sa WhiteSpaceMode
651*/
598void QStyleSheetItem::setWhiteSpaceMode(WhiteSpaceMode m) 652void QStyleSheetItem::setWhiteSpaceMode(WhiteSpaceMode m)
@@ -604,10 +658,10 @@ void QStyleSheetItem::setWhiteSpaceMode(WhiteSpaceMode m)
604/*! 658/*!
605 Returns the width of margin \a m in pixels. 659 Returns the width of margin \a m in pixels.
606 660
607 The margin, \a m, can be \c MarginLeft, \c MarginRight, 661 The margin, \a m, can be \c MarginLeft, \c MarginRight, \c
608 \c MarginTop, \c MarginBottom, \c MarginAll, \c MarginVertical or \c 662 MarginTop, \c MarginBottom, \c MarginAll, \c MarginVertical or \c
609 MarginHorizontal. 663 MarginHorizontal.
610 664
611 \sa setMargin() Margin 665 \sa setMargin() Margin
612 */ 666*/
613int QStyleSheetItem::margin(Margin m) const 667int QStyleSheetItem::margin(Margin m) const
@@ -619,10 +673,10 @@ int QStyleSheetItem::margin(Margin m) const
619/*! 673/*!
620 Sets the width of margin \a m to \a v pixels. 674 Sets the width of margin \a m to \a v pixels.
621 675
622 The margin, \a m, can be \c MarginLeft, \c MarginRight, 676 The margin, \a m, can be \c MarginLeft, \c MarginRight, \c
623 \c MarginTop, \c MarginBottom, \c MarginAll, \c MarginVertical or \c 677 MarginTop, \c MarginBottom, \c MarginAll, \c MarginVertical or \c
624 MarginHorizontal. The value \a v must be >= 0. 678 MarginHorizontal. The value \a v must be >= 0.
625 679
626 \sa margin() 680 \sa margin()
627 */ 681*/
628void QStyleSheetItem::setMargin(Margin m, int v) 682void QStyleSheetItem::setMargin(Margin m, int v)
@@ -648,5 +702,5 @@ void QStyleSheetItem::setMargin(Margin m, int v)
648/*! 702/*!
649 Returns the list style of the style. 703 Returns the list style of the style.
650 704
651 \sa setListStyle() ListStyle 705 \sa setListStyle() ListStyle
652 */ 706 */
@@ -657,22 +711,24 @@ QStyleSheetItem::ListStyle QStyleSheetItem::listStyle() const
657 711
658/*! \enum QStyleSheetItem::ListStyle 712/*!
713 \enum QStyleSheetItem::ListStyle
659 714
660 This enum type defines how the items in a list are prefixed when 715 This enum type defines how the items in a list are prefixed when
661 displayed. The currently defined values are: 716 displayed.
662 717
663 \value ListDisc a filled circle (i.e. a bullet) 718 \value ListDisc a filled circle (i.e. a bullet)
664 \value ListCircle an unfilled circle 719 \value ListCircle an unfilled circle
665 \value ListSquare a filled square 720 \value ListSquare a filled square
666 \value ListDecimal an integer in base 10: \e 1, \e 2, \e 3, ... 721 \value ListDecimal an integer in base 10: \e 1, \e 2, \e 3, ...
667 \value ListLowerAlpha a lowercase letter: \e a, \e b, \e c, ... 722 \value ListLowerAlpha a lowercase letter: \e a, \e b, \e c, ...
668 \value ListUpperAlpha an uppercase letter: \e A, \e B, \e C, ... 723 \value ListUpperAlpha an uppercase letter: \e A, \e B, \e C, ...
669*/ 724*/
725
670/*! 726/*!
671 Sets the list style of the style to \a s. 727 Sets the list style of the style to \a s.
672 728
673 This is used by nested elements that have a display mode of 729 This is used by nested elements that have a display mode of \c
674 \c DisplayListItem. 730 DisplayListItem.
675 731
676 \sa listStyle() DisplayMode ListStyle 732 \sa listStyle() DisplayMode ListStyle
677 */ 733*/
678void QStyleSheetItem::setListStyle(ListStyle s) 734void QStyleSheetItem::setListStyle(ListStyle s)
@@ -683,9 +739,10 @@ void QStyleSheetItem::setListStyle(ListStyle s)
683 739
684/*! Returns a space-separated list of names of styles that may 740/*!
685 contain elements of this style. If nothing has been set, contexts() 741 Returns a space-separated list of names of styles that may contain
686 returns an empty string, which indicates that this style can be 742 elements of this style. If nothing has been set, contexts()
687 nested everywhere. 743 returns an empty string, which indicates that this style can be
744 nested everywhere.
688 745
689 \sa setContexts() 746 \sa setContexts()
690 */ 747*/
691QString QStyleSheetItem::contexts() const 748QString QStyleSheetItem::contexts() const
@@ -696,8 +753,8 @@ QString QStyleSheetItem::contexts() const
696/*! 753/*!
697 Sets a space-separated list of names of styles that may contain 754 Sets a space-separated list of names of styles that may contain
698 elements of this style. If \a c is empty, the style can be nested 755 elements of this style. If \a c is empty, the style can be nested
699 everywhere. 756 everywhere.
700 757
701 \sa contexts() 758 \sa contexts()
702 */ 759*/
703void QStyleSheetItem::setContexts( const QString& c) 760void QStyleSheetItem::setContexts( const QString& c)
@@ -708,7 +765,7 @@ void QStyleSheetItem::setContexts( const QString& c)
708/*! 765/*!
709 Returns TRUE if this style can be nested into an element 766 Returns TRUE if this style can be nested into an element of style
710 of style \a s; otherwise returns FALSE. 767 \a s; otherwise returns FALSE.
711 768
712 \sa contexts(), setContexts() 769 \sa contexts(), setContexts()
713 */ 770*/
714bool QStyleSheetItem::allowedInContext( const QStyleSheetItem* s) const 771bool QStyleSheetItem::allowedInContext( const QStyleSheetItem* s) const
@@ -722,7 +779,7 @@ bool QStyleSheetItem::allowedInContext( const QStyleSheetItem* s) const
722/*! 779/*!
723 Returns TRUE if this style has self-nesting enabled; otherwise 780 Returns TRUE if this style has self-nesting enabled; otherwise
724 returns FALSE. 781 returns FALSE.
725 782
726 \sa setSelfNesting() 783 \sa setSelfNesting()
727 */ 784*/
728bool QStyleSheetItem::selfNesting() const 785bool QStyleSheetItem::selfNesting() const
@@ -733,10 +790,10 @@ bool QStyleSheetItem::selfNesting() const
733/*! 790/*!
734 Sets the self-nesting property for this style to \a nesting. 791 Sets the self-nesting property for this style to \a nesting.
735 792
736 In order to support "dirty" HTML, paragraphs \c{<p>} and list items 793 In order to support "dirty" HTML, paragraphs \c{<p>} and list
737 \c{<li>} are not self-nesting. This means that starting a new 794 items \c{<li>} are not self-nesting. This means that starting a
738 paragraph or list item automatically closes the previous one. 795 new paragraph or list item automatically closes the previous one.
739 796
740 \sa selfNesting() 797 \sa selfNesting()
741 */ 798*/
742void QStyleSheetItem::setSelfNesting( bool nesting ) 799void QStyleSheetItem::setSelfNesting( bool nesting )
@@ -746,3 +803,11 @@ void QStyleSheetItem::setSelfNesting( bool nesting )
746 803
747/*! Sets the linespacing to be \a ls pixels */ 804/*
805 Sets the linespacing to be at least \a ls pixels.
806
807 For compatibility with previous Qt releases, small values get
808 treated differently: If \a ls is smaller than the default font
809 line spacing in pixels at parse time, the resulting line spacing
810 is the sum of the default line spacing plus \a ls. We recommend
811 not relying on this behavior.
812*/
748 813
@@ -753,3 +818,7 @@ void QStyleSheetItem::setLineSpacing( int ls )
753 818
754/*! Returns the linespacing */ 819/*!
820 \obsolete
821
822 Returns the linespacing
823*/
755 824
@@ -769,220 +838,218 @@ int QStyleSheetItem::lineSpacing() const
769/*! 838/*!
770 \class QStyleSheet qstylesheet.h 839 \class QStyleSheet qstylesheet.h
771 \ingroup text 840 \ingroup text
772 \brief The QStyleSheet class is a collection of styles for rich text 841 \brief The QStyleSheet class is a collection of styles for rich text
773 rendering and a generator of tags. 842 rendering and a generator of tags.
774 843
775 \ingroup graphics 844 \ingroup graphics
776 \ingroup helpsystem 845 \ingroup helpsystem
777 846
778 By creating QStyleSheetItem objects for a style sheet you build a 847 By creating QStyleSheetItem objects for a style sheet you build a
779 definition of a set of tags. This definition will be used by the 848 definition of a set of tags. This definition will be used by the
780 internal rich text rendering system to parse and display text 849 internal rich text rendering system to parse and display text
781 documents to which the style sheet applies. Rich text is normally 850 documents to which the style sheet applies. Rich text is normally
782 visualized in a QTextView or a QTextBrowser. However, QLabel, 851 visualized in a QTextView or a QTextBrowser. However, QLabel,
783 QWhatsThis and QMessageBox also support it, and other classes are 852 QWhatsThis and QMessageBox also support it, and other classes are
784 likely to follow. With QSimpleRichText it is possible to use the 853 likely to follow. With QSimpleRichText it is possible to use the
785 rich text renderer for custom widgets as well. 854 rich text renderer for custom widgets as well.
786 855
787 The default QStyleSheet object has the following style bindings, 856 The default QStyleSheet object has the following style bindings,
788 sorted by structuring bindings, anchors, character style bindings 857 sorted by structuring bindings, anchors, character style bindings
789 (i.e. inline styles), special elements such as horizontal lines or 858 (i.e. inline styles), special elements such as horizontal lines or
790 images, and other tags. In addition, rich text supports simple HTML 859 images, and other tags. In addition, rich text supports simple
791 tables. 860 HTML tables.
792 861
793 The structuring tags are 862 The structuring tags are
794 \list 863 \table
795 \i \c{<qt>}...\c{</qt>} 864 \header \i Structuring tags \i Notes
796 - A Qt rich text document. It understands the following attributes: 865 \row \i \c{<qt>}...\c{</qt>}
797 \list 866 \i A Qt rich text document. It understands the following
798 \i title 867 attributes:
799 - The caption of the document. This attribute is easily accessible with 868 \list
800 QTextView::documentTitle(). 869 \i \c title -- The caption of the document. This attribute is
801 \i type 870 easily accessible with QTextView::documentTitle().
802 - The type of the document. The default type is \c page . It 871 \i \c type -- The type of the document. The default type is \c
803 indicates that the document is displayed in a page of its 872 page. It indicates that the document is displayed in a
804 own. Another style is \c detail, which can be used to 873 page of its own. Another style is \c detail, which can be
805 explain certain expressions in more detail in a few 874 used to explain certain expressions in more detail in a
806 sentences. The QTextBrowser will then keep the current page 875 few sentences. For \c detail, QTextBrowser will then keep
807 and display the new document in a small popup similar to 876 the current page and display the new document in a small
808 QWhatsThis. Note that links will not work in documents with 877 popup similar to QWhatsThis. Note that links will not work
809 \c{<qt type="detail">...</qt>}. 878 in documents with \c{<qt type="detail">...</qt>}.
810 \i bgcolor 879 \i \c bgcolor -- The background color, for example \c
811 - The background color, for example \c bgcolor="yellow" or \c 880 bgcolor="yellow" or \c bgcolor="#0000FF".
812 bgcolor="#0000FF". 881 \i \c background -- The background pixmap, for example \c
813 \i background 882 background="granite.xpm". The pixmap name will be resolved
814 - The background pixmap, for example \c 883 by a QMimeSourceFactory().
815 background="granit.xpm". The pixmap name will be resolved by 884 \i \c text -- The default text color, for example \c text="red".
816 a QMimeSourceFactory(). 885 \i \c link -- The link color, for example \c link="green".
817 \i text 886 \endlist
818 - The default text color, for example \c text="red". 887 \row \i \c{<h1>...</h1>}
819 \i link 888 \i A top-level heading.
820 - The link color, for example \c link="green". 889 \row \i \c{<h2>...</h2>}
821 \endlist 890 \i A sublevel heading.
822 \i \c{<h1>...</h1>} 891 \row \i \c{<h3>...</h3>}
823 - A top-level heading. 892 \i A sub-sublevel heading.
824 \i \c{<h2>...</h2>} 893 \row \i \c{<p>...</p>}
825 - A sublevel heading. 894 \i A left-aligned paragraph. Adjust the alignment with the \c
826 \i \c{<h3>...</h3>} 895 align attribute. Possible values are \c left, \c right and
827 - A sub-sublevel heading. 896 \c center.
828 \i \c{<p>...</p>} 897 \row \i \c{<center>...}<br>\c{</center>}
829 - A left-aligned paragraph. Adjust the alignment with 898 \i A centered paragraph.
830 the \c align attribute. Possible values are 899 \row \i \c{<blockquote>...}<br>\c{</blockquote>}
831 \c left, \c right and \c center. 900 \i An indented paragraph that is useful for quotes.
832 \i \c{<center>...</center>} 901 \row \i \c{<ul>...</ul>}
833 - A centered paragraph. 902 \i An unordered list. You can also pass a type argument to
834 \i \c{<blockquote>...</blockquote>} 903 define the bullet style. The default is \c type=disc;
835 - An indented paragraph that is useful for quotes. 904 other types are \c circle and \c square.
836 \i \c{<ul>...</ul>} 905 \row \i \c{<ol>...</ol>}
837 - An unordered list. You can also pass a type argument to 906 \i An ordered list. You can also pass a type argument to
838 define the bullet style. The default is \c type=disc; other 907 define the enumeration label style. The default is \c
839 types are \c circle and \c square. 908 type="1"; other types are \c "a" and \c "A".
840 \i \c{<ol>...</ol>} 909 \row \i \c{<li>...</li>}
841 - An ordered list. You can also pass a type argument to define 910 \i A list item. This tag can be used only within the context
842 the enumeration label style. The default is \c type="1"; other 911 of \c{<ol>} or \c{<ul>}.
843 types are \c "a" and \c "A". 912 \row \i \c{<pre>...</pre>}
844 \i <tt>&lt;li&gt;</tt>...<tt>&lt;/li&gt;</tt> 913 \i For larger chunks of code. Whitespaces in the contents are
845 - A list item. This tag can be used only within the context of 914 preserved. For small bits of code use the inline-style \c
846 \c ol or \c ul. 915 code.
847 \i \c{<pre>...</pre>} 916 \endtable
848 - For larger chunks of code. Whitespaces in the contents are preserved. 917
849 For small bits of code use the inline-style \c code. 918 Anchors and links are done with a single tag:
850 \endlist 919 \table
851 920 \header \i Anchor tags \i Notes
852 Anchors and links are done with a single tag: 921 \row \i \c{<a>...</a>}
853 \list 922 \i An anchor or link.
854 \i \c{<a>...</a>} 923 \list
855 - An anchor or link. The reference target is defined in the \c 924 \i A link is created by using an \c href
856 href attribute of the tag as in \c{<a 925 attribute, for example
857 href="target.qml">...</a>}. You can also specify an 926 <br>\c{<a href="target.qml">Link Text</a>}. Links to
858 additional anchor within the specified target document, for 927 targets within a document are achieved in the same way
859 example \c{<a href="target.qml#123">...</a>}. If \c a is 928 as for HTML, e.g.
860 meant to be an anchor, the reference source is given in the 929 <br>\c{<a href="target.qml#subtitle">Link Text</a>}.
861 \c name attribute. 930 \i A target is created by using a \c name
862 \endlist 931 attribute, for example
863 932 <br>\c{<a name="subtitle"><h2>Sub Title</h2></a>}.
864 The default character style bindings are 933 \endlist
865 \list 934 \endtable
866 \i \c{<em>...</em>} 935
867 - Emphasized. By default this is the same as 936 The default character style bindings are
868 \c{<i>...</i>} (italic). 937 \table
869 \i \c{<strong>...</strong>} 938 \header \i Style tags \i Notes
870 - Strong. By default this is the same as 939 \row \i \c{<em>...</em>}
871 \c{<b>...</b>} (bold). 940 \i Emphasized. By default this is the same as \c{<i>...</i>}
872 \i \c{<i>...</i>} 941 (italic).
873 - Italic font style. 942 \row \i \c{<strong>...</strong>}
874 \i \c{<b>...</b>} 943 \i Strong. By default this is the same as \c{<b>...</b>}
875 - Bold font style. 944 (bold).
876 \i \c{<u>...</u>} 945 \row \i \c{<i>...</i>}
877 - Underlined font style. 946 \i Italic font style.
878 \i \c{<big>...</big>} 947 \row \i \c{<b>...</b>}
879 - A larger font size. 948 \i Bold font style.
880 \i \c{<small>...</small>} 949 \row \i \c{<u>...</u>}
881 - A smaller font size. 950 \i Underlined font style.
882 \i \c{<code>...</code>} 951 \row \i \c{<s>...</s>}
883 - Indicates code. By default this is the same as 952 \i Strike out font style.
884 \c{<tt>...</tt>} (typewriter). For 953 \row \i \c{<big>...</big>}
885 larger junks of code use the block-tag \c pre. 954 \i A larger font size.
886 \i \c{<tt>...</tt>} 955 \row \i \c{<small>...</small>}
887 - Typewriter font style. 956 \i A smaller font size.
888 \i \c{<font>...</font>} 957 \row \i \c{<code>...</code>}
889 - Customizes the font size, family and text color. The tag understands 958 \i Indicates code. By default this is the same as
890 the following attributes: 959 \c{<tt>...</tt>} (typewriter). For larger junks of code
891 \list 960 use the block-tag \c{<}\c{pre>}.
892 \i color 961 \row \i \c{<tt>...</tt>}
893 - The text color, for example \c color="red" or \c color="#FF0000". 962 \i Typewriter font style.
894 \i size 963 \row \i \c{<font>...</font>}
895 - The logical size of the font. Logical sizes 1 to 7 are supported. 964 \i Customizes the font size, family and text color. The tag
896 The value may either be absolute (for example, 965 understands the following attributes:
897 \c size=3) or relative (\c size=-2). In the latter case the sizes 966 \list
898 are simply added. 967 \i \c color -- The text color, for example \c color="red" or
899 \i face 968 \c color="#FF0000".
900 - The family of the font, for example \c face=times. 969 \i \c size -- The logical size of the font. Logical sizes 1
901 \endlist 970 to 7 are supported. The value may either be absolute
902 \endlist 971 (for example, \c size=3) or relative (\c size=-2). In
903 972 the latter case the sizes are simply added.
904 Special elements are: 973 \i \c face -- The family of the font, for example \c face=times.
905 \list 974 \endlist
906 \i \c{<img>} 975 \endtable
907 - An image. The image name for the mime source 976
908 factory is given in the source attribute, for example 977 Special elements are:
909 \c{<img src="qt.xpm">} 978 \table
910 The image tag also understands the attributes \c width and \c 979 \header \i Special tags \i Notes
911 height that determine the size of the image. If the pixmap 980 \row \i \c{<img>}
912 does not fit the specified size it will be scaled 981 \i An image. The image name for the mime source factory is
913 automatically (by using QImage::smoothScale()). 982 given in the source attribute, for example
914 983 \c{<img src="qt.xpm">} The image tag also understands the
915 The \c align attribute determines where the image is 984 attributes \c width and \c height that determine the size
916 placed. By default, an image is placed inline just like a 985 of the image. If the pixmap does not fit the specified
917 normal character. Specify \c left or \c right to place the 986 size it will be scaled automatically (by using
918 image at the respective side. 987 QImage::smoothScale()).
919 \i \c{<hr>} 988 <br>
920 - A horizonal line. 989 The \c align attribute determines where the image is
921 \i \c{<br>} 990 placed. By default, an image is placed inline just like a
922 - A line break. 991 normal character. Specify \c left or \c right to place the
923 \endlist 992 image at the respective side.
924 993 \row \i \c{<hr>}
925 Another tag not in any of the above cathegories is 994 \i A horizonal line.
926 \list 995 \row \i \c{<br>}
927 \i \c{<nobr>...</nobr>} 996 \i A line break.
928 - No break. Prevents word wrap. 997 \row \i \c{<nobr>...</nobr>}
929 \endlist 998 \i No break. Prevents word wrap.
930 999 \endtable
931 In addition, rich text supports simple HTML tables. A table consists 1000
932 of one or more rows each of which contains one or more cells. Cells 1001 In addition, rich text supports simple HTML tables. A table
933 are either data cells or header cells, depending on their 1002 consists of one or more rows each of which contains one or more
934 content. Cells which span rows and columns are supported. 1003 cells. Cells are either data cells or header cells, depending on
935 1004 their content. Cells which span rows and columns are supported.
936 \list 1005
937 \i \c{<table>...</table>} 1006 \table
938 - A table. Tables support the following attributes: 1007 \header \i Table tags \i Notes
939 \list 1008 \row \i \c{<table>...</table>}
940 \i bgcolor 1009 \i A table. Tables support the following attributes:
941 - The background color. 1010 \list
942 \i width 1011 \i \c bgcolor -- The background color.
943 - The table width. This is either an absolute pixel width or a relative 1012 \i \c width -- The table width. This is either an absolute
944 percentage of the table's width, for example \c width=80%. 1013 pixel width or a relative percentage of the table's
945 \i border 1014 width, for example \c width=80%.
946 - The width of the table border. The default is 0 (= no border). 1015 \i \c border -- The width of the table border. The default is
947 \i cellspacing 1016 0 (= no border).
948 - Additional space around the table cells. The default is 2. 1017 \i \c cellspacing -- Additional space around the table cells.
949 \i cellpadding 1018 The default is 2.
950 - Additional space around the contents of table cells. The default is 1. 1019 \i \c cellpadding -- Additional space around the contents of
951 \endlist 1020 table cells. The default is 1.
952 \i \c{<tr>...</tr>} 1021 \endlist
953 - A table row. This is only valid within a \c table. Rows support 1022 \row \i \c{<tr>...</tr>}
954 the following attribute: 1023 \i A table row. This is only valid within a \c table. Rows
955 \list 1024 support the following attribute:
956 \i bgcolor 1025 \list
957 - The background color. 1026 \i \c bgcolor -- The background color.
958 \endlist 1027 \endlist
959 \i \c{<th>...</th>} 1028 \row \i \c{<th>...</th>}
960 - A table header cell. Similar to \c td, but defaults to center alignment 1029 \i A table header cell. Similar to \c td, but defaults to
961 and a bold font. 1030 center alignment and a bold font.
962 \i \c{<td>...</td>} 1031 \row \i \c{<td>...</td>}
963 - A table data cell. This is only valid within a \c tr. Cells 1032 \i A table data cell. This is only valid within a \c tr.
964 support the following attributes: 1033 Cells support the following attributes:
965 \list 1034 \list
966 \i bgcolor 1035 \i \c bgcolor -- The background color.
967 - The background color. 1036 \i \c width -- The cell width. This is either an absolute
968 \i width 1037 pixel width or a relative percentage of table's width,
969 - The cell width. This is either an absolute pixel width or a relative 1038 for example \c width=50%.
970 percentage of table's width, for example \c width=50%. 1039 \i \c colspan -- Specifies how many columns this cell spans.
971 \i colspan 1040 The default is 1.
972 - Specifies how many columns this cell spans. The default is 1. 1041 \i \c rowspan -- Specifies how many rows this cell spans. The
973 \i rowspan 1042 default is 1.
974 - Specifies how many rows this cell spans. The default is 1. 1043 \i \c align -- Alignment; possible values are \c left, \c
975 \i align 1044 right, and \c center. The default is left.
976 - Alignment; possible values are \c left, \c right, and \c center. The 1045 \endlist
977 default is left. 1046 \endtable
978 \endlist 1047*/
979 \endlist 1048
980*/ 1049/*!
981 1050 Creates a style sheet called \a name, with parent \a parent. Like
982/*! 1051 any QObject it will be deleted when its parent is destroyed (if
983 Creates a style sheet with parent \a parent and name \a name. Like 1052 the child still exists).
984 any QObject it will be deleted when its parent is 1053
985 destroyed (if the child still exists). 1054 By default the style sheet has the tag definitions defined above.
986
987 By default the style sheet has the tag definitions defined above.
988*/ 1055*/
@@ -995,4 +1062,4 @@ QStyleSheet::QStyleSheet( QObject *parent, const char *name )
995/*! 1062/*!
996 Destroys the style sheet. All styles inserted into the style sheet 1063 Destroys the style sheet. All styles inserted into the style sheet
997 will be deleted. 1064 will be deleted.
998*/ 1065*/
@@ -1020,3 +1087,2 @@ void QStyleSheet::init()
1020 style->setDisplayMode( QStyleSheetItem::DisplayBlock ); 1087 style->setDisplayMode( QStyleSheetItem::DisplayBlock );
1021 //style->setMargin( QStyleSheetItem::MarginAll, 4 );
1022 1088
@@ -1049,4 +1115,4 @@ void QStyleSheet::init()
1049 style->setDisplayMode(QStyleSheetItem::DisplayBlock); 1115 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
1050 style-> setMargin(QStyleSheetItem::MarginTop, 12); 1116 style-> setMargin(QStyleSheetItem::MarginTop, 18);
1051 style-> setMargin(QStyleSheetItem::MarginBottom, 6); 1117 style-> setMargin(QStyleSheetItem::MarginBottom, 12);
1052 1118
@@ -1056,4 +1122,4 @@ void QStyleSheet::init()
1056 style->setDisplayMode(QStyleSheetItem::DisplayBlock); 1122 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
1057 style-> setMargin(QStyleSheetItem::MarginTop, 10); 1123 style-> setMargin(QStyleSheetItem::MarginTop, 16);
1058 style-> setMargin(QStyleSheetItem::MarginBottom, 5); 1124 style-> setMargin(QStyleSheetItem::MarginBottom, 12);
1059 1125
@@ -1063,4 +1129,4 @@ void QStyleSheet::init()
1063 style->setDisplayMode(QStyleSheetItem::DisplayBlock); 1129 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
1064 style-> setMargin(QStyleSheetItem::MarginTop, 8); 1130 style-> setMargin(QStyleSheetItem::MarginTop, 14);
1065 style-> setMargin(QStyleSheetItem::MarginBottom, 4); 1131 style-> setMargin(QStyleSheetItem::MarginBottom, 12);
1066 1132
@@ -1070,4 +1136,3 @@ void QStyleSheet::init()
1070 style->setDisplayMode(QStyleSheetItem::DisplayBlock); 1136 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
1071 style-> setMargin(QStyleSheetItem::MarginTop, 8); 1137 style-> setMargin(QStyleSheetItem::MarginVertical, 12);
1072 style-> setMargin(QStyleSheetItem::MarginBottom, 4);
1073 1138
@@ -1077,3 +1142,3 @@ void QStyleSheet::init()
1077 style->setDisplayMode(QStyleSheetItem::DisplayBlock); 1142 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
1078 style-> setMargin(QStyleSheetItem::MarginTop, 8); 1143 style-> setMargin(QStyleSheetItem::MarginTop, 12);
1079 style-> setMargin(QStyleSheetItem::MarginBottom, 4); 1144 style-> setMargin(QStyleSheetItem::MarginBottom, 4);
@@ -1082,3 +1147,3 @@ void QStyleSheet::init()
1082 style->setDisplayMode(QStyleSheetItem::DisplayBlock); 1147 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
1083 style-> setMargin(QStyleSheetItem::MarginVertical, 8); 1148 style-> setMargin(QStyleSheetItem::MarginVertical, 12);
1084 style->setSelfNesting( FALSE ); 1149 style->setSelfNesting( FALSE );
@@ -1099,3 +1164,5 @@ void QStyleSheet::init()
1099 style->setDisplayMode(QStyleSheetItem::DisplayBlock); 1164 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
1100 style-> setMargin(QStyleSheetItem::MarginVertical, 4); 1165 style->setListStyle( QStyleSheetItem::ListDisc );
1166 style-> setMargin(QStyleSheetItem::MarginVertical, 12);
1167 style->setMargin( QStyleSheetItem::MarginLeft, 40 );
1101 1168
@@ -1104,3 +1171,4 @@ void QStyleSheet::init()
1104 style->setListStyle( QStyleSheetItem::ListDecimal ); 1171 style->setListStyle( QStyleSheetItem::ListDecimal );
1105 style-> setMargin(QStyleSheetItem::MarginVertical, 4); 1172 style-> setMargin(QStyleSheetItem::MarginVertical, 12);
1173 style->setMargin( QStyleSheetItem::MarginLeft, 40 );
1106 1174
@@ -1109,4 +1177,2 @@ void QStyleSheet::init()
1109 style->setSelfNesting( FALSE ); 1177 style->setSelfNesting( FALSE );
1110 style->setContexts(QString::fromLatin1("ol ul"));
1111 style-> setMargin(QStyleSheetItem::MarginVertical, 4);
1112 1178
@@ -1121,2 +1187,3 @@ void QStyleSheet::init()
1121 new QStyleSheetItem(this, QString::fromLatin1("hr")); 1187 new QStyleSheetItem(this, QString::fromLatin1("hr"));
1188
1122 style = new QStyleSheetItem(this, QString::fromLatin1("sub")); 1189 style = new QStyleSheetItem(this, QString::fromLatin1("sub"));
@@ -1137,5 +1204,9 @@ void QStyleSheet::init()
1137 style->setDisplayMode(QStyleSheetItem::DisplayNone); 1204 style->setDisplayMode(QStyleSheetItem::DisplayNone);
1205 style = new QStyleSheetItem( this, QString::fromLatin1("body") );
1206 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
1138 style = new QStyleSheetItem( this, QString::fromLatin1("div") ); 1207 style = new QStyleSheetItem( this, QString::fromLatin1("div") );
1139 style->setDisplayMode(QStyleSheetItem::DisplayBlock) ; 1208 style->setDisplayMode(QStyleSheetItem::DisplayBlock) ;
1209 style = new QStyleSheetItem( this, QString::fromLatin1("span") );
1140 style = new QStyleSheetItem( this, QString::fromLatin1("dl") ); 1210 style = new QStyleSheetItem( this, QString::fromLatin1("dl") );
1211 style-> setMargin(QStyleSheetItem::MarginVertical, 8);
1141 style->setDisplayMode(QStyleSheetItem::DisplayBlock); 1212 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
@@ -1150,6 +1221,11 @@ void QStyleSheet::init()
1150 style->setFontUnderline( TRUE); 1221 style->setFontUnderline( TRUE);
1222 style = new QStyleSheetItem( this, QString::fromLatin1("s") );
1223 style->setFontStrikeOut( TRUE);
1151 style = new QStyleSheetItem( this, QString::fromLatin1("nobr") ); 1224 style = new QStyleSheetItem( this, QString::fromLatin1("nobr") );
1152 style->setWhiteSpaceMode( QStyleSheetItem::WhiteSpaceNoWrap ); 1225 style->setWhiteSpaceMode( QStyleSheetItem::WhiteSpaceNoWrap );
1153 style = new QStyleSheetItem( this, QString::fromLatin1("wsp") ); // qt extension for QTextEdit 1226
1154 style->setWhiteSpaceMode( (QStyleSheetItem::WhiteSpaceMode) 3 ); // WhiteSpaceModeNoCompression 1227 // compatibily with some minor 3.0.x Qt versions that had an
1228 // undocumented <wsp> tag. ### Remove 3.1
1229 style = new QStyleSheetItem( this, QString::fromLatin1("wsp") );
1230 style->setWhiteSpaceMode( QStyleSheetItem::WhiteSpacePre );
1155 1231
@@ -1175,10 +1251,10 @@ static QSingleCleanupHandler<QStyleSheet> qt_cleanup_stylesheet;
1175/*! 1251/*!
1176 Returns the application-wide default style sheet. This style sheet is 1252 Returns the application-wide default style sheet. This style sheet
1177 used by rich text rendering classes such as QSimpleRichText, 1253 is used by rich text rendering classes such as QSimpleRichText,
1178 QWhatsThis and QMessageBox to define the rendering style and 1254 QWhatsThis and QMessageBox to define the rendering style and
1179 available tags within rich text documents. It serves also as initial 1255 available tags within rich text documents. It also serves as the
1180 style sheet for the more complex render widgets QTextEdit and 1256 initial style sheet for the more complex render widgets, QTextEdit
1181 QTextBrowser. 1257 and QTextBrowser.
1182 1258
1183 \sa setDefaultSheet() 1259 \sa setDefaultSheet()
1184*/ 1260*/
@@ -1194,7 +1270,7 @@ QStyleSheet* QStyleSheet::defaultSheet()
1194/*! 1270/*!
1195 Sets the application-wide default style sheet to \a sheet, deleting 1271 Sets the application-wide default style sheet to \a sheet,
1196 any style sheet previously set. The ownership is transferred to 1272 deleting any style sheet previously set. The ownership is
1197 QStyleSheet. 1273 transferred to QStyleSheet.
1198 1274
1199 \sa defaultSheet() 1275 \sa defaultSheet()
1200*/ 1276*/
@@ -1213,4 +1289,4 @@ void QStyleSheet::setDefaultSheet( QStyleSheet* sheet)
1213/*!\internal 1289/*!\internal
1214 Inserts \a style. Any tags generated after this time will be 1290 Inserts \a style. Any tags generated after this time will be
1215 bound to this style. Note that \a style becomes owned by the 1291 bound to this style. Note that \a style becomes owned by the
1216 style sheet and will be deleted when the style sheet is destroyed. 1292 style sheet and will be deleted when the style sheet is destroyed.
@@ -1224,4 +1300,4 @@ void QStyleSheet::insert( QStyleSheetItem* style )
1224/*! 1300/*!
1225 Returns the style with name \a name or 0 if there is no such style. 1301 Returns the style called \a name or 0 if there is no such style.
1226 */ 1302*/
1227QStyleSheetItem* QStyleSheet::item( const QString& name) 1303QStyleSheetItem* QStyleSheet::item( const QString& name)
@@ -1235,4 +1311,6 @@ QStyleSheetItem* QStyleSheet::item( const QString& name)
1235 \overload 1311 \overload
1236 Returns the style with name \a name or 0 if there is no such style (const version) 1312
1237 */ 1313 Returns the style called \a name or 0 if there is no such style
1314 (const version)
1315*/
1238const QStyleSheetItem* QStyleSheet::item( const QString& name) const 1316const QStyleSheetItem* QStyleSheet::item( const QString& name) const
@@ -1247,17 +1325,18 @@ const QStyleSheetItem* QStyleSheet::item( const QString& name) const
1247 \preliminary 1325 \preliminary
1248 Generates an internal object for the tag called \a name, given the
1249 attributes \a attr, and using additional information provided
1250 by the mime source factory \a factory.
1251 1326
1252 \a context is the optional context of the document, i.e. the path to 1327 Generates an internal object for the tag called \a name, given the
1253 look for relative links. This becomes important if the text contains 1328 attributes \a attr, and using additional information provided by
1254 relative references, for example within image tags. QSimpleRichText 1329 the mime source factory \a factory.
1255 always uses the default mime source factory (see
1256 \l{QMimeSourceFactory::defaultFactory()}) to resolve these references.
1257 The context will then be used to calculate the absolute path. See
1258 QMimeSourceFactory::makeAbsolute() for details.
1259 1330
1260 \a emptyTag and \a doc are for internal use only. 1331 \a context is the optional context of the document, i.e. the path
1332 to look for relative links. This becomes important if the text
1333 contains relative references, for example within image tags.
1334 QSimpleRichText always uses the default mime source factory (see
1335 \l{QMimeSourceFactory::defaultFactory()}) to resolve these
1336 references. The context will then be used to calculate the
1337 absolute path. See QMimeSourceFactory::makeAbsolute() for details.
1261 1338
1262 This function should not (yet) be used in application code. 1339 \a emptyTag and \a doc are for internal use only.
1340
1341 This function should not be used in application code.
1263*/ 1342*/
@@ -1269,5 +1348,2 @@ QTextCustomItem* QStyleSheet::tag( const QString& name,
1269{ 1348{
1270 static QString s_img = QString::fromLatin1("img");
1271 static QString s_hr = QString::fromLatin1("hr");
1272
1273 const QStyleSheetItem* style = item( name ); 1349 const QStyleSheetItem* style = item( name );
@@ -1276,5 +1352,5 @@ QTextCustomItem* QStyleSheet::tag( const QString& name,
1276 return 0; 1352 return 0;
1277 if ( style->name() == s_img ) 1353 if ( style->name() == "img" )
1278 return new QTextImage( doc, attr, context, (QMimeSourceFactory&)factory ); 1354 return new QTextImage( doc, attr, context, (QMimeSourceFactory&)factory );
1279 if ( style->name() == s_hr ) 1355 if ( style->name() == "hr" )
1280 return new QTextHorizontalLine( doc, attr, context, (QMimeSourceFactory&)factory ); 1356 return new QTextHorizontalLine( doc, attr, context, (QMimeSourceFactory&)factory );
@@ -1284,13 +1360,12 @@ QTextCustomItem* QStyleSheet::tag( const QString& name,
1284 1360
1285/*! 1361/*! Auxiliary function. Converts the plain text string \a plain to a
1286 Auxiliary function. Converts the plain text string \a plain to a 1362 rich text formatted paragraph while preserving most of its look.
1287 rich text formatted paragraph while preserving its look.
1288 1363
1289 \a mode defines the whitespace mode. Possible values are \c 1364 \a mode defines the whitespace mode. Possible values are \c
1290 QStyleSheetItem::WhiteSpacePre (no wrapping, all whitespaces 1365 QStyleSheetItem::WhiteSpacePre (no wrapping, all whitespaces
1291 preserved) and \c QStyleSheetItem::WhiteSpaceNormal (wrapping, 1366 preserved) and \c QStyleSheetItem::WhiteSpaceNormal (wrapping,
1292 simplified whitespaces). 1367 simplified whitespaces).
1293 1368
1294 \sa escape() 1369 \sa escape()
1295 */ 1370*/
1296QString QStyleSheet::convertFromPlainText( const QString& plain, QStyleSheetItem::WhiteSpaceMode mode ) 1371QString QStyleSheet::convertFromPlainText( const QString& plain, QStyleSheetItem::WhiteSpaceMode mode )
@@ -1302,28 +1377,40 @@ QString QStyleSheet::convertFromPlainText( const QString& plain, QStyleSheetItem
1302 if ( plain[i] == '\n' ){ 1377 if ( plain[i] == '\n' ){
1303 if ( col == 1 ) 1378 int c = 1;
1304 rich += "<p></p>"; 1379 while ( i+1 < int(plain.length()) && plain[i+1] == '\n' ) {
1305 else 1380 i++;
1306 rich += "<br>"; 1381 c++;
1382 }
1383 if ( c == 1)
1384 rich += "<br>\n";
1385 else {
1386 rich += "</p>\n";
1387 while ( --c > 1 )
1388 rich += "<br>\n";
1389 rich += "<p>";
1390 }
1307 col = 0; 1391 col = 0;
1308 } 1392 } else {
1309 else if ( mode == QStyleSheetItem::WhiteSpacePre && plain[i] == '\t' ){ 1393 if ( mode == QStyleSheetItem::WhiteSpacePre && plain[i] == '\t' ){
1310 rich += 0x00a0U;
1311 while ( col % 4 ) {
1312 rich += 0x00a0U; 1394 rich += 0x00a0U;
1313 ++col; 1395 ++col;
1396 while ( col % 8 ) {
1397 rich += 0x00a0U;
1398 ++col;
1399 }
1314 } 1400 }
1401 else if ( mode == QStyleSheetItem::WhiteSpacePre && plain[i].isSpace() )
1402 rich += 0x00a0U;
1403 else if ( plain[i] == '<' )
1404 rich +="&lt;";
1405 else if ( plain[i] == '>' )
1406 rich +="&gt;";
1407 else if ( plain[i] == '&' )
1408 rich +="&amp;";
1409 else
1410 rich += plain[i];
1411 ++col;
1315 } 1412 }
1316 else if ( mode == QStyleSheetItem::WhiteSpacePre && plain[i].isSpace() )
1317 rich += 0x00a0U;
1318 else if ( plain[i] == '<' )
1319 rich +="&lt;";
1320 else if ( plain[i] == '>' )
1321 rich +="&gt;";
1322 else if ( plain[i] == '&' )
1323 rich +="&amp;";
1324 else
1325 rich += plain[i];
1326 ++col;
1327 } 1413 }
1328 rich += "</p>"; 1414 if ( col != 0 )
1415 rich += "</p>";
1329 return rich; 1416 return rich;
@@ -1332,7 +1419,7 @@ QString QStyleSheet::convertFromPlainText( const QString& plain, QStyleSheetItem
1332/*! 1419/*!
1333 Auxiliary function. Converts the plain text string \a plain to a 1420 Auxiliary function. Converts the plain text string \a plain to a
1334 rich text formatted string with any HTML meta-characters escaped. 1421 rich text formatted string with any HTML meta-characters escaped.
1335 1422
1336 \sa convertFromPlainText() 1423 \sa convertFromPlainText()
1337 */ 1424*/
1338QString QStyleSheet::escape( const QString& plain) 1425QString QStyleSheet::escape( const QString& plain)
@@ -1356,18 +1443,19 @@ QString QStyleSheet::escape( const QString& plain)
1356/*! 1443/*!
1357 \enum Qt::TextFormat 1444 \enum Qt::TextFormat
1358 1445
1359 This enum is used in widgets that can display both plain text and 1446 This enum is used in widgets that can display both plain text and
1360 rich text, e.g. QLabel. It is used for deciding whether a text 1447 rich text, e.g. QLabel. It is used for deciding whether a text
1361 string should be interpreted as one or the other. This is 1448 string should be interpreted as one or the other. This is normally
1362 normally done by passing one of the enum values to a setTextFormat() 1449 done by passing one of the enum values to a setTextFormat()
1363 function. 1450 function.
1364 1451
1365 \value PlainText The text string is interpreted as a plain text string. 1452 \value PlainText The text string is interpreted as a plain text
1453 string.
1366 1454
1367 \value RichText The text string is interpreted as a rich text string 1455 \value RichText The text string is interpreted as a rich text
1368 using the current QStyleSheet::defaultSheet(). 1456 string using the current QStyleSheet::defaultSheet().
1369 1457
1370 \value AutoText The text string is interpreted as for \c RichText if 1458 \value AutoText The text string is interpreted as for \c RichText
1371 QStyleSheet::mightBeRichText() returns TRUE, otherwise as for \c 1459 if QStyleSheet::mightBeRichText() returns TRUE, otherwise as
1372 PlainText. 1460 \c PlainText.
1373*/ 1461*/
@@ -1375,9 +1463,9 @@ QString QStyleSheet::escape( const QString& plain)
1375/*! 1463/*!
1376 Returns TRUE if the string \a text is likely to be rich text; 1464 Returns TRUE if the string \a text is likely to be rich text;
1377 otherwise returns FALSE. 1465 otherwise returns FALSE.
1378 1466
1379 Note: The function uses a fast and therefore simple heuristic. It 1467 This function uses a fast and therefore simple heuristic. It
1380 mainly checks whether there is something that looks like a tag 1468 mainly checks whether there is something that looks like a tag
1381 before the first line break. Although the result may be correct for 1469 before the first line break. Although the result may be correct
1382 most common cases, there is no guarantee. 1470 for common cases, there is no guarantee.
1383*/ 1471*/
@@ -1415,13 +1503,14 @@ bool QStyleSheet::mightBeRichText( const QString& text)
1415 1503
1416/*! \fn void QStyleSheet::error( const QString& msg) const 1504/*!
1505 \fn void QStyleSheet::error( const QString& msg) const
1417 1506
1418 This virtual function is called when an error occurs when 1507 This virtual function is called when an error occurs when
1419 processing rich text. Reimplement it if you need to catch 1508 processing rich text. Reimplement it if you need to catch error
1420 error messages. 1509 messages.
1421 1510
1422 Errors might occur if some rich text strings contain tags that are 1511 Errors might occur if some rich text strings contain tags that are
1423 not understood by the stylesheet, if some tags are nested incorrectly, or 1512 not understood by the stylesheet, if some tags are nested
1424 if tags are not closed properly. 1513 incorrectly, or if tags are not closed properly.
1425 1514
1426 \a msg is the error message. 1515 \a msg is the error message.
1427*/ 1516*/
@@ -1433,12 +1522,11 @@ void QStyleSheet::error( const QString& ) const
1433/*! 1522/*!
1434 Scales the font \a font to the appropriate physical point size 1523 Scales the font \a font to the appropriate physical point size
1435 corresponding to the logical font size \a logicalSize. 1524 corresponding to the logical font size \a logicalSize.
1436 1525
1437 When calling this function, \a font has a point size corresponding to 1526 When calling this function, \a font has a point size corresponding
1438 the logical font size 3. 1527 to the logical font size 3.
1439 1528
1440 Logical font sizes range from 1 to 7, with 1 being the smallest. 1529 Logical font sizes range from 1 to 7, with 1 being the smallest.
1441 1530
1442 \sa QStyleSheetItem::logicalFontSize(), 1531 \sa QStyleSheetItem::logicalFontSize(), QStyleSheetItem::logicalFontSizeStep(), QFont::setPointSize()
1443 QStyleSheetItem::logicalFontSizeStep(), QFont::setPointSize()
1444 */ 1532 */