Diffstat (limited to 'noncore/apps/opie-write/qstylesheet.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-write/qstylesheet.cpp | 1230 |
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 | |||
@@ -54,6 +54,7 @@ public: | |||
54 | QStyleSheetItem::DisplayMode disp; | 54 | QStyleSheetItem::DisplayMode disp; |
55 | int fontitalic; | 55 | int fontitalic; |
56 | int fontunderline; | 56 | int fontunderline; |
57 | int fontstrikeout; | ||
57 | int fontweight; | 58 | int fontweight; |
58 | int fontsize; | 59 | int fontsize; |
59 | int fontsizelog; | 60 | int fontsizelog; |
@@ -78,66 +79,74 @@ public: | |||
78 | } | 79 | } |
79 | 80 | ||
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 | */ |
102 | 106 | ||
103 | /*! \enum QStyleSheetItem::AdditionalStyleValues | 107 | /*! \enum QStyleSheetItem::AdditionalStyleValues |
104 | \internal | 108 | \internal |
105 | */ | 109 | */ |
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 | ||
121 | */ | 127 | */ |
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 | */ |
134 | 142 | ||
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 | */ |
142 | QStyleSheetItem::QStyleSheetItem( QStyleSheet* parent, const QString& name ) | 151 | QStyleSheetItem::QStyleSheetItem( QStyleSheet* parent, const QString& name ) |
143 | { | 152 | { |
@@ -150,9 +159,9 @@ QStyleSheetItem::QStyleSheetItem( QStyleSheet* parent, const QString& name ) | |||
150 | } | 159 | } |
151 | 160 | ||
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 | */ |
156 | QStyleSheetItem::QStyleSheetItem( const QStyleSheetItem & other ) | 165 | QStyleSheetItem::QStyleSheetItem( const QStyleSheetItem & other ) |
157 | { | 166 | { |
158 | d = new QStyleSheetItemData; | 167 | d = new QStyleSheetItemData; |
@@ -161,9 +170,9 @@ QStyleSheetItem::QStyleSheetItem( const QStyleSheetItem & other ) | |||
161 | 170 | ||
162 | 171 | ||
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 | */ |
167 | QStyleSheetItem::~QStyleSheetItem() | 176 | QStyleSheetItem::~QStyleSheetItem() |
168 | { | 177 | { |
169 | delete d; | 178 | delete d; |
@@ -172,8 +181,8 @@ QStyleSheetItem::~QStyleSheetItem() | |||
172 | 181 | ||
173 | 182 | ||
174 | /*! | 183 | /*! |
175 | Returns the style sheet this item is in. | 184 | Returns the style sheet this item is in. |
176 | */ | 185 | */ |
177 | QStyleSheet* QStyleSheetItem::styleSheet() | 186 | QStyleSheet* QStyleSheetItem::styleSheet() |
178 | { | 187 | { |
179 | return d->sheet; | 188 | return d->sheet; |
@@ -181,8 +190,9 @@ QStyleSheet* QStyleSheetItem::styleSheet() | |||
181 | 190 | ||
182 | /*! | 191 | /*! |
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 | */ | ||
186 | const QStyleSheet* QStyleSheetItem::styleSheet() const | 196 | const QStyleSheet* QStyleSheetItem::styleSheet() const |
187 | { | 197 | { |
188 | return d->sheet; | 198 | return d->sheet; |
@@ -198,6 +208,7 @@ void QStyleSheetItem::init() | |||
198 | 208 | ||
199 | d->fontitalic = Undefined; | 209 | d->fontitalic = Undefined; |
200 | d->fontunderline = Undefined; | 210 | d->fontunderline = Undefined; |
211 | d->fontstrikeout = Undefined; | ||
201 | d->fontweight = Undefined; | 212 | d->fontweight = Undefined; |
202 | d->fontsize = Undefined; | 213 | d->fontsize = Undefined; |
203 | d->fontsizelog = Undefined; | 214 | d->fontsizelog = Undefined; |
@@ -212,14 +223,14 @@ void QStyleSheetItem::init() | |||
212 | d->margin[2] = Undefined; | 223 | d->margin[2] = Undefined; |
213 | d->margin[3] = Undefined; | 224 | d->margin[3] = Undefined; |
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; |
218 | d->lineSpacing = Undefined; | 229 | d->lineSpacing = Undefined; |
219 | } | 230 | } |
220 | 231 | ||
221 | /*! | 232 | /*! |
222 | Returns the name of the style item. | 233 | Returns the name of the style item. |
223 | */ | 234 | */ |
224 | QString QStyleSheetItem::name() const | 235 | QString QStyleSheetItem::name() const |
225 | { | 236 | { |
@@ -227,36 +238,37 @@ QString QStyleSheetItem::name() const | |||
227 | } | 238 | } |
228 | 239 | ||
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 | */ |
235 | QStyleSheetItem::DisplayMode QStyleSheetItem::displayMode() const | 246 | QStyleSheetItem::DisplayMode QStyleSheetItem::displayMode() const |
236 | { | 247 | { |
237 | return d->disp; | 248 | return d->disp; |
238 | } | 249 | } |
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 | */ |
255 | 267 | ||
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 | */ |
261 | void QStyleSheetItem::setDisplayMode(DisplayMode m) | 273 | void QStyleSheetItem::setDisplayMode(DisplayMode m) |
262 | { | 274 | { |
@@ -265,24 +277,25 @@ void QStyleSheetItem::setDisplayMode(DisplayMode m) | |||
265 | 277 | ||
266 | 278 | ||
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 | */ |
273 | int QStyleSheetItem::alignment() const | 286 | int QStyleSheetItem::alignment() const |
274 | { | 287 | { |
275 | return d->align; | 288 | return d->align; |
276 | } | 289 | } |
277 | 290 | ||
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 | */ |
286 | void QStyleSheetItem::setAlignment( int f ) | 299 | void QStyleSheetItem::setAlignment( int f ) |
287 | { | 300 | { |
288 | d->align = f; | 301 | d->align = f; |
@@ -290,40 +303,41 @@ void QStyleSheetItem::setAlignment( int f ) | |||
290 | 303 | ||
291 | 304 | ||
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 | */ |
298 | QStyleSheetItem::VerticalAlignment QStyleSheetItem::verticalAlignment() const | 311 | QStyleSheetItem::VerticalAlignment QStyleSheetItem::verticalAlignment() const |
299 | { | 312 | { |
300 | return d->valign; | 313 | return d->valign; |
301 | } | 314 | } |
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 | ||
316 | */ | 330 | */ |
317 | 331 | ||
318 | 332 | ||
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 | */ |
327 | void QStyleSheetItem::setVerticalAlignment( VerticalAlignment valign ) | 341 | void QStyleSheetItem::setVerticalAlignment( VerticalAlignment valign ) |
328 | { | 342 | { |
329 | d->valign = valign; | 343 | d->valign = valign; |
@@ -331,10 +345,11 @@ void QStyleSheetItem::setVerticalAlignment( VerticalAlignment valign ) | |||
331 | 345 | ||
332 | 346 | ||
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 | */ |
338 | bool QStyleSheetItem::fontItalic() const | 353 | bool QStyleSheetItem::fontItalic() const |
339 | { | 354 | { |
340 | return d->fontitalic > 0; | 355 | return d->fontitalic > 0; |
@@ -344,51 +359,54 @@ bool QStyleSheetItem::fontItalic() const | |||
344 | If \a italic is TRUE sets italic for the style; otherwise sets | 359 | If \a italic is TRUE sets italic for the style; otherwise sets |
345 | upright. | 360 | upright. |
346 | 361 | ||
347 | \sa fontItalic(), definesFontItalic() | 362 | \sa fontItalic(), definesFontItalic() |
348 | */ | 363 | */ |
349 | void QStyleSheetItem::setFontItalic(bool italic) | 364 | void QStyleSheetItem::setFontItalic(bool italic) |
350 | { | 365 | { |
351 | d->fontitalic = italic?1:0; | 366 | d->fontitalic = italic?1:0; |
352 | } | 367 | } |
353 | 368 | ||
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 | */ |
360 | bool QStyleSheetItem::definesFontItalic() const | 376 | bool QStyleSheetItem::definesFontItalic() const |
361 | { | 377 | { |
362 | return d->fontitalic != Undefined; | 378 | return d->fontitalic != Undefined; |
363 | } | 379 | } |
364 | 380 | ||
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 | */ |
370 | bool QStyleSheetItem::fontUnderline() const | 387 | bool QStyleSheetItem::fontUnderline() const |
371 | { | 388 | { |
372 | return d->fontunderline > 0; | 389 | return d->fontunderline > 0; |
373 | } | 390 | } |
374 | 391 | ||
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 | */ |
381 | void QStyleSheetItem::setFontUnderline(bool underline) | 398 | void QStyleSheetItem::setFontUnderline(bool underline) |
382 | { | 399 | { |
383 | d->fontunderline = underline?1:0; | 400 | d->fontunderline = underline?1:0; |
384 | } | 401 | } |
385 | 402 | ||
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 | */ | ||
392 | bool QStyleSheetItem::definesFontUnderline() const | 410 | bool QStyleSheetItem::definesFontUnderline() const |
393 | { | 411 | { |
394 | return d->fontunderline != Undefined; | 412 | return d->fontunderline != Undefined; |
@@ -396,33 +414,68 @@ bool QStyleSheetItem::definesFontUnderline() const | |||
396 | 414 | ||
397 | 415 | ||
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 | */ |
422 | bool 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 | */ | ||
433 | void 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 | */ | ||
445 | bool 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 | */ | ||
404 | int QStyleSheetItem::fontWeight() const | 457 | int QStyleSheetItem::fontWeight() const |
405 | { | 458 | { |
406 | return d->fontweight; | 459 | return d->fontweight; |
407 | } | 460 | } |
408 | 461 | ||
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 | */ |
415 | void QStyleSheetItem::setFontWeight(int w) | 468 | void QStyleSheetItem::setFontWeight(int w) |
416 | { | 469 | { |
417 | d->fontweight = w; | 470 | d->fontweight = w; |
418 | } | 471 | } |
419 | 472 | ||
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 | */ |
426 | int QStyleSheetItem::logicalFontSize() const | 479 | int QStyleSheetItem::logicalFontSize() const |
427 | { | 480 | { |
428 | return d->fontsizelog; | 481 | return d->fontsizelog; |
@@ -430,34 +483,34 @@ int QStyleSheetItem::logicalFontSize() const | |||
430 | 483 | ||
431 | 484 | ||
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 | */ |
438 | void QStyleSheetItem::setLogicalFontSize(int s) | 491 | void QStyleSheetItem::setLogicalFontSize(int s) |
439 | { | 492 | { |
440 | d->fontsizelog = s; | 493 | d->fontsizelog = s; |
441 | } | 494 | } |
442 | 495 | ||
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 | */ |
451 | int QStyleSheetItem::logicalFontSizeStep() const | 504 | int QStyleSheetItem::logicalFontSizeStep() const |
452 | { | 505 | { |
453 | return d->fontsizestep; | 506 | return d->fontsizestep; |
454 | } | 507 | } |
455 | 508 | ||
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 | */ |
461 | void QStyleSheetItem::setLogicalFontSizeStep( int s ) | 514 | void QStyleSheetItem::setLogicalFontSizeStep( int s ) |
462 | { | 515 | { |
463 | d->fontsizestep = s; | 516 | d->fontsizestep = s; |
@@ -466,21 +519,21 @@ void QStyleSheetItem::setLogicalFontSizeStep( int s ) | |||
466 | 519 | ||
467 | 520 | ||
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 | */ |
473 | void QStyleSheetItem::setFontSize(int s) | 526 | void QStyleSheetItem::setFontSize(int s) |
474 | { | 527 | { |
475 | d->fontsize = s; | 528 | d->fontsize = s; |
476 | } | 529 | } |
477 | 530 | ||
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 | */ |
484 | int QStyleSheetItem::fontSize() const | 537 | int QStyleSheetItem::fontSize() const |
485 | { | 538 | { |
486 | return d->fontsize; | 539 | return d->fontsize; |
@@ -488,21 +541,21 @@ int QStyleSheetItem::fontSize() const | |||
488 | 541 | ||
489 | 542 | ||
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 | */ |
496 | QString QStyleSheetItem::fontFamily() const | 549 | QString QStyleSheetItem::fontFamily() const |
497 | { | 550 | { |
498 | return d->fontfamily; | 551 | return d->fontfamily; |
499 | } | 552 | } |
500 | 553 | ||
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 | */ |
506 | void QStyleSheetItem::setFontFamily( const QString& fam) | 559 | void QStyleSheetItem::setFontFamily( const QString& fam) |
507 | { | 560 | { |
508 | d->fontfamily = fam; | 561 | d->fontfamily = fam; |
@@ -522,7 +575,7 @@ int QStyleSheetItem::numberOfColumns() const | |||
522 | 575 | ||
523 | 576 | ||
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. |
527 | 580 | ||
528 | This makes sense only if the style uses a block display mode | 581 | This makes sense only if the style uses a block display mode |
@@ -538,43 +591,43 @@ void QStyleSheetItem::setNumberOfColumns(int ncols) | |||
538 | 591 | ||
539 | 592 | ||
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 | */ |
546 | QColor QStyleSheetItem::color() const | 599 | QColor QStyleSheetItem::color() const |
547 | { | 600 | { |
548 | return d->col; | 601 | return d->col; |
549 | } | 602 | } |
550 | 603 | ||
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 | */ |
556 | void QStyleSheetItem::setColor( const QColor &c) | 609 | void QStyleSheetItem::setColor( const QColor &c) |
557 | { | 610 | { |
558 | d->col = c; | 611 | d->col = c; |
559 | } | 612 | } |
560 | 613 | ||
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 | */ |
566 | bool QStyleSheetItem::isAnchor() const | 619 | bool QStyleSheetItem::isAnchor() const |
567 | { | 620 | { |
568 | return d->anchor; | 621 | return d->anchor; |
569 | } | 622 | } |
570 | 623 | ||
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 | */ |
578 | void QStyleSheetItem::setAnchor(bool anc) | 631 | void QStyleSheetItem::setAnchor(bool anc) |
579 | { | 632 | { |
580 | d->anchor = anc; | 633 | d->anchor = anc; |
@@ -582,19 +635,20 @@ void QStyleSheetItem::setAnchor(bool anc) | |||
582 | 635 | ||
583 | 636 | ||
584 | /*! | 637 | /*! |
585 | Returns the whitespace mode. | 638 | Returns the whitespace mode. |
586 | 639 | ||
587 | \sa setWhiteSpaceMode() WhiteSpaceMode | 640 | \sa setWhiteSpaceMode() WhiteSpaceMode |
588 | */ | 641 | */ |
589 | QStyleSheetItem::WhiteSpaceMode QStyleSheetItem::whiteSpaceMode() const | 642 | QStyleSheetItem::WhiteSpaceMode QStyleSheetItem::whiteSpaceMode() const |
590 | { | 643 | { |
591 | return d->whitespacemode; | 644 | return d->whitespacemode; |
592 | } | 645 | } |
593 | 646 | ||
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 | */ | ||
598 | void QStyleSheetItem::setWhiteSpaceMode(WhiteSpaceMode m) | 652 | void QStyleSheetItem::setWhiteSpaceMode(WhiteSpaceMode m) |
599 | { | 653 | { |
600 | d->whitespacemode = m; | 654 | d->whitespacemode = m; |
@@ -602,14 +656,14 @@ void QStyleSheetItem::setWhiteSpaceMode(WhiteSpaceMode m) | |||
602 | 656 | ||
603 | 657 | ||
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 | */ |
613 | int QStyleSheetItem::margin(Margin m) const | 667 | int QStyleSheetItem::margin(Margin m) const |
614 | { | 668 | { |
615 | return d->margin[m]; | 669 | return d->margin[m]; |
@@ -617,14 +671,14 @@ int QStyleSheetItem::margin(Margin m) const | |||
617 | 671 | ||
618 | 672 | ||
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 | */ |
628 | void QStyleSheetItem::setMargin(Margin m, int v) | 682 | void QStyleSheetItem::setMargin(Margin m, int v) |
629 | { | 683 | { |
630 | if (m == MarginAll ) { | 684 | if (m == MarginAll ) { |
@@ -646,71 +700,74 @@ void QStyleSheetItem::setMargin(Margin m, int v) | |||
646 | 700 | ||
647 | 701 | ||
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 | */ |
653 | QStyleSheetItem::ListStyle QStyleSheetItem::listStyle() const | 707 | QStyleSheetItem::ListStyle QStyleSheetItem::listStyle() const |
654 | { | 708 | { |
655 | return d->list; | 709 | return d->list; |
656 | } | 710 | } |
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 | */ |
678 | void QStyleSheetItem::setListStyle(ListStyle s) | 734 | void QStyleSheetItem::setListStyle(ListStyle s) |
679 | { | 735 | { |
680 | d->list=s; | 736 | d->list=s; |
681 | } | 737 | } |
682 | 738 | ||
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 | */ |
691 | QString QStyleSheetItem::contexts() const | 748 | QString QStyleSheetItem::contexts() const |
692 | { | 749 | { |
693 | return d->contxt; | 750 | return d->contxt; |
694 | } | 751 | } |
695 | 752 | ||
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 | */ |
703 | void QStyleSheetItem::setContexts( const QString& c) | 760 | void QStyleSheetItem::setContexts( const QString& c) |
704 | { | 761 | { |
705 | d->contxt = QChar(' ') + c + QChar(' '); | 762 | d->contxt = QChar(' ') + c + QChar(' '); |
706 | } | 763 | } |
707 | 764 | ||
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 | */ |
714 | bool QStyleSheetItem::allowedInContext( const QStyleSheetItem* s) const | 771 | bool QStyleSheetItem::allowedInContext( const QStyleSheetItem* s) const |
715 | { | 772 | { |
716 | if ( d->contxt.isEmpty() ) | 773 | if ( d->contxt.isEmpty() ) |
@@ -720,38 +777,50 @@ bool QStyleSheetItem::allowedInContext( const QStyleSheetItem* s) const | |||
720 | 777 | ||
721 | 778 | ||
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 | */ |
728 | bool QStyleSheetItem::selfNesting() const | 785 | bool QStyleSheetItem::selfNesting() const |
729 | { | 786 | { |
730 | return d->selfnest; | 787 | return d->selfnest; |
731 | } | 788 | } |
732 | 789 | ||
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 | */ |
742 | void QStyleSheetItem::setSelfNesting( bool nesting ) | 799 | void QStyleSheetItem::setSelfNesting( bool nesting ) |
743 | { | 800 | { |
744 | d->selfnest = nesting; | 801 | d->selfnest = nesting; |
745 | } | 802 | } |
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 | ||
749 | void QStyleSheetItem::setLineSpacing( int ls ) | 814 | void QStyleSheetItem::setLineSpacing( int ls ) |
750 | { | 815 | { |
751 | d->lineSpacing = ls; | 816 | d->lineSpacing = ls; |
752 | } | 817 | } |
753 | 818 | ||
754 | /*! Returns the linespacing */ | 819 | /*! |
820 | \obsolete | ||
821 | |||
822 | Returns the linespacing | ||
823 | */ | ||
755 | 824 | ||
756 | int QStyleSheetItem::lineSpacing() const | 825 | int QStyleSheetItem::lineSpacing() const |
757 | { | 826 | { |
@@ -767,224 +836,222 @@ int QStyleSheetItem::lineSpacing() const | |||
767 | 836 | ||
768 | 837 | ||
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><li></tt>...<tt></li></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 | */ |
989 | QStyleSheet::QStyleSheet( QObject *parent, const char *name ) | 1056 | QStyleSheet::QStyleSheet( QObject *parent, const char *name ) |
990 | : QObject( parent, name ) | 1057 | : QObject( parent, name ) |
@@ -993,8 +1060,8 @@ QStyleSheet::QStyleSheet( QObject *parent, const char *name ) | |||
993 | } | 1060 | } |
994 | 1061 | ||
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 | */ |
999 | QStyleSheet::~QStyleSheet() | 1066 | QStyleSheet::~QStyleSheet() |
1000 | { | 1067 | { |
@@ -1018,7 +1085,6 @@ void QStyleSheet::init() | |||
1018 | 1085 | ||
1019 | style = new QStyleSheetItem( this, QString::fromLatin1("qt") ); | 1086 | style = new QStyleSheetItem( this, QString::fromLatin1("qt") ); |
1020 | style->setDisplayMode( QStyleSheetItem::DisplayBlock ); | 1087 | style->setDisplayMode( QStyleSheetItem::DisplayBlock ); |
1021 | //style->setMargin( QStyleSheetItem::MarginAll, 4 ); | ||
1022 | 1088 | ||
1023 | style = new QStyleSheetItem( this, QString::fromLatin1("a") ); | 1089 | style = new QStyleSheetItem( this, QString::fromLatin1("a") ); |
1024 | style->setAnchor( TRUE ); | 1090 | style->setAnchor( TRUE ); |
@@ -1047,40 +1113,39 @@ void QStyleSheet::init() | |||
1047 | style->setFontWeight( QFont::Bold); | 1113 | style->setFontWeight( QFont::Bold); |
1048 | style->setLogicalFontSize(6); | 1114 | style->setLogicalFontSize(6); |
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 | ||
1053 | style = new QStyleSheetItem( this, QString::fromLatin1("h2") ); | 1119 | style = new QStyleSheetItem( this, QString::fromLatin1("h2") ); |
1054 | style->setFontWeight( QFont::Bold); | 1120 | style->setFontWeight( QFont::Bold); |
1055 | style->setLogicalFontSize(5); | 1121 | style->setLogicalFontSize(5); |
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 | ||
1060 | style = new QStyleSheetItem( this, QString::fromLatin1("h3") ); | 1126 | style = new QStyleSheetItem( this, QString::fromLatin1("h3") ); |
1061 | style->setFontWeight( QFont::Bold); | 1127 | style->setFontWeight( QFont::Bold); |
1062 | style->setLogicalFontSize(4); | 1128 | style->setLogicalFontSize(4); |
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 | ||
1067 | style = new QStyleSheetItem( this, QString::fromLatin1("h4") ); | 1133 | style = new QStyleSheetItem( this, QString::fromLatin1("h4") ); |
1068 | style->setFontWeight( QFont::Bold); | 1134 | style->setFontWeight( QFont::Bold); |
1069 | style->setLogicalFontSize(3); | 1135 | style->setLogicalFontSize(3); |
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 | ||
1074 | style = new QStyleSheetItem( this, QString::fromLatin1("h5") ); | 1139 | style = new QStyleSheetItem( this, QString::fromLatin1("h5") ); |
1075 | style->setFontWeight( QFont::Bold); | 1140 | style->setFontWeight( QFont::Bold); |
1076 | style->setLogicalFontSize(2); | 1141 | style->setLogicalFontSize(2); |
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); |
1080 | 1145 | ||
1081 | style = new QStyleSheetItem( this, QString::fromLatin1("p") ); | 1146 | style = new QStyleSheetItem( this, QString::fromLatin1("p") ); |
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 ); |
1085 | 1150 | ||
1086 | style = new QStyleSheetItem( this, QString::fromLatin1("center") ); | 1151 | style = new QStyleSheetItem( this, QString::fromLatin1("center") ); |
@@ -1097,18 +1162,19 @@ void QStyleSheet::init() | |||
1097 | 1162 | ||
1098 | style = new QStyleSheetItem( this, QString::fromLatin1("ul") ); | 1163 | style = new QStyleSheetItem( this, QString::fromLatin1("ul") ); |
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 | ||
1102 | style = new QStyleSheetItem( this, QString::fromLatin1("ol") ); | 1169 | style = new QStyleSheetItem( this, QString::fromLatin1("ol") ); |
1103 | style->setDisplayMode(QStyleSheetItem::DisplayBlock); | 1170 | style->setDisplayMode(QStyleSheetItem::DisplayBlock); |
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 | ||
1107 | style = new QStyleSheetItem( this, QString::fromLatin1("li") ); | 1175 | style = new QStyleSheetItem( this, QString::fromLatin1("li") ); |
1108 | style->setDisplayMode(QStyleSheetItem::DisplayListItem); | 1176 | style->setDisplayMode(QStyleSheetItem::DisplayListItem); |
1109 | style->setSelfNesting( FALSE ); | 1177 | style->setSelfNesting( FALSE ); |
1110 | style->setContexts(QString::fromLatin1("ol ul")); | ||
1111 | style-> setMargin(QStyleSheetItem::MarginVertical, 4); | ||
1112 | 1178 | ||
1113 | style = new QStyleSheetItem( this, QString::fromLatin1("code") ); | 1179 | style = new QStyleSheetItem( this, QString::fromLatin1("code") ); |
1114 | style->setFontFamily( QString::fromLatin1("courier") ); | 1180 | style->setFontFamily( QString::fromLatin1("courier") ); |
@@ -1119,6 +1185,7 @@ void QStyleSheet::init() | |||
1119 | new QStyleSheetItem(this, QString::fromLatin1("img")); | 1185 | new QStyleSheetItem(this, QString::fromLatin1("img")); |
1120 | new QStyleSheetItem(this, QString::fromLatin1("br")); | 1186 | new QStyleSheetItem(this, QString::fromLatin1("br")); |
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")); |
1123 | style->setVerticalAlignment( QStyleSheetItem::VAlignSub ); | 1190 | style->setVerticalAlignment( QStyleSheetItem::VAlignSub ); |
1124 | style = new QStyleSheetItem(this, QString::fromLatin1("sup")); | 1191 | style = new QStyleSheetItem(this, QString::fromLatin1("sup")); |
@@ -1135,9 +1202,13 @@ void QStyleSheet::init() | |||
1135 | 1202 | ||
1136 | style = new QStyleSheetItem( this, QString::fromLatin1("head") ); | 1203 | style = new QStyleSheetItem( this, QString::fromLatin1("head") ); |
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); |
1142 | style = new QStyleSheetItem( this, QString::fromLatin1("dt") ); | 1213 | style = new QStyleSheetItem( this, QString::fromLatin1("dt") ); |
1143 | style->setDisplayMode(QStyleSheetItem::DisplayBlock); | 1214 | style->setDisplayMode(QStyleSheetItem::DisplayBlock); |
@@ -1148,10 +1219,15 @@ void QStyleSheet::init() | |||
1148 | style->setContexts(QString::fromLatin1("dt dl") ); | 1219 | style->setContexts(QString::fromLatin1("dt dl") ); |
1149 | style = new QStyleSheetItem( this, QString::fromLatin1("u") ); | 1220 | style = new QStyleSheetItem( this, QString::fromLatin1("u") ); |
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 | ||
1156 | // tables | 1232 | // tables |
1157 | style = new QStyleSheetItem( this, QString::fromLatin1("table") ); | 1233 | style = new QStyleSheetItem( this, QString::fromLatin1("table") ); |
@@ -1173,14 +1249,14 @@ static QStyleSheet* defaultsheet = 0; | |||
1173 | static QSingleCleanupHandler<QStyleSheet> qt_cleanup_stylesheet; | 1249 | static QSingleCleanupHandler<QStyleSheet> qt_cleanup_stylesheet; |
1174 | 1250 | ||
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 | */ |
1185 | QStyleSheet* QStyleSheet::defaultSheet() | 1261 | QStyleSheet* QStyleSheet::defaultSheet() |
1186 | { | 1262 | { |
@@ -1192,11 +1268,11 @@ QStyleSheet* QStyleSheet::defaultSheet() | |||
1192 | } | 1268 | } |
1193 | 1269 | ||
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 | */ |
1201 | void QStyleSheet::setDefaultSheet( QStyleSheet* sheet) | 1277 | void QStyleSheet::setDefaultSheet( QStyleSheet* sheet) |
1202 | { | 1278 | { |
@@ -1211,8 +1287,8 @@ void QStyleSheet::setDefaultSheet( QStyleSheet* sheet) | |||
1211 | } | 1287 | } |
1212 | 1288 | ||
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. |
1217 | */ | 1293 | */ |
1218 | void QStyleSheet::insert( QStyleSheetItem* style ) | 1294 | void QStyleSheet::insert( QStyleSheetItem* style ) |
@@ -1222,8 +1298,8 @@ void QStyleSheet::insert( QStyleSheetItem* style ) | |||
1222 | 1298 | ||
1223 | 1299 | ||
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 | */ |
1227 | QStyleSheetItem* QStyleSheet::item( const QString& name) | 1303 | QStyleSheetItem* QStyleSheet::item( const QString& name) |
1228 | { | 1304 | { |
1229 | if ( name.isNull() ) | 1305 | if ( name.isNull() ) |
@@ -1233,8 +1309,10 @@ QStyleSheetItem* QStyleSheet::item( const QString& name) | |||
1233 | 1309 | ||
1234 | /*! | 1310 | /*! |
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 | */ | ||
1238 | const QStyleSheetItem* QStyleSheet::item( const QString& name) const | 1316 | const QStyleSheetItem* QStyleSheet::item( const QString& name) const |
1239 | { | 1317 | { |
1240 | if ( name.isNull() ) | 1318 | if ( name.isNull() ) |
@@ -1245,21 +1323,22 @@ const QStyleSheetItem* QStyleSheet::item( const QString& name) const | |||
1245 | 1323 | ||
1246 | /*! | 1324 | /*! |
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 | */ |
1264 | QTextCustomItem* QStyleSheet::tag( const QString& name, | 1343 | QTextCustomItem* QStyleSheet::tag( const QString& name, |
1265 | const QMap<QString, QString> &attr, | 1344 | const QMap<QString, QString> &attr, |
@@ -1267,32 +1346,28 @@ QTextCustomItem* QStyleSheet::tag( const QString& name, | |||
1267 | const QMimeSourceFactory& factory, | 1346 | const QMimeSourceFactory& factory, |
1268 | bool /*emptyTag */, QTextDocument *doc ) const | 1347 | bool /*emptyTag */, QTextDocument *doc ) const |
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 ); |
1274 | // first some known tags | 1350 | // first some known tags |
1275 | if ( !style ) | 1351 | if ( !style ) |
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 ); |
1281 | return 0; | 1357 | return 0; |
1282 | } | 1358 | } |
1283 | 1359 | ||
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 | */ |
1296 | QString QStyleSheet::convertFromPlainText( const QString& plain, QStyleSheetItem::WhiteSpaceMode mode ) | 1371 | QString QStyleSheet::convertFromPlainText( const QString& plain, QStyleSheetItem::WhiteSpaceMode mode ) |
1297 | { | 1372 | { |
1298 | int col = 0; | 1373 | int col = 0; |
@@ -1300,41 +1375,53 @@ QString QStyleSheet::convertFromPlainText( const QString& plain, QStyleSheetItem | |||
1300 | rich += "<p>"; | 1375 | rich += "<p>"; |
1301 | for ( int i = 0; i < int(plain.length()); ++i ) { | 1376 | for ( int i = 0; i < int(plain.length()); ++i ) { |
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 +="<"; | ||
1405 | else if ( plain[i] == '>' ) | ||
1406 | rich +=">"; | ||
1407 | else if ( plain[i] == '&' ) | ||
1408 | rich +="&"; | ||
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 +="<"; | ||
1320 | else if ( plain[i] == '>' ) | ||
1321 | rich +=">"; | ||
1322 | else if ( plain[i] == '&' ) | ||
1323 | rich +="&"; | ||
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; |
1330 | } | 1417 | } |
1331 | 1418 | ||
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 | */ |
1338 | QString QStyleSheet::escape( const QString& plain) | 1425 | QString QStyleSheet::escape( const QString& plain) |
1339 | { | 1426 | { |
1340 | QString rich; | 1427 | QString rich; |
@@ -1354,32 +1441,33 @@ QString QStyleSheet::escape( const QString& plain) | |||
1354 | // Must doc this enum somewhere, and it is logically related to QStyleSheet | 1441 | // Must doc this enum somewhere, and it is logically related to QStyleSheet |
1355 | 1442 | ||
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 | */ |
1374 | 1462 | ||
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 | */ |
1384 | bool QStyleSheet::mightBeRichText( const QString& text) | 1472 | bool QStyleSheet::mightBeRichText( const QString& text) |
1385 | { | 1473 | { |
@@ -1413,17 +1501,18 @@ bool QStyleSheet::mightBeRichText( const QString& text) | |||
1413 | } | 1501 | } |
1414 | 1502 | ||
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 | */ |
1428 | void QStyleSheet::error( const QString& ) const | 1517 | void QStyleSheet::error( const QString& ) const |
1429 | { | 1518 | { |
@@ -1431,16 +1520,15 @@ void QStyleSheet::error( const QString& ) const | |||
1431 | 1520 | ||
1432 | 1521 | ||
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 | */ |
1445 | void QStyleSheet::scaleFont( QFont& font, int logicalSize ) const | 1533 | void QStyleSheet::scaleFont( QFont& font, int logicalSize ) const |
1446 | { | 1534 | { |