You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tqt3/doc/man/man3/tqstylesheet.3qt

225 lines
10 KiB

'\" t
.TH TQStyleSheet 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
TQStyleSheet \- Collection of styles for rich text rendering and a generator of tags
.SH SYNOPSIS
\fC#include <tqstylesheet.h>\fR
.PP
Inherits TQObject.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBTQStyleSheet\fR ( TQObject * parent = 0, const char * name = 0 )"
.br
.ti -1c
.BI "virtual \fB~TQStyleSheet\fR ()"
.br
.ti -1c
.BI "TQStyleSheetItem * \fBitem\fR ( const TQString & name )"
.br
.ti -1c
.BI "const TQStyleSheetItem * \fBitem\fR ( const TQString & name ) const"
.br
.ti -1c
.BI "virtual TQTextCustomItem * \fBtag\fR ( const TQString & name, const TQMap<TQString, TQString> & attr, const TQString & context, const TQMimeSourceFactory & factory, bool emptyTag, TQTextDocument * doc ) const"
.br
.ti -1c
.BI "virtual void \fBscaleFont\fR ( TQFont & font, int logicalSize ) const"
.br
.ti -1c
.BI "virtual void \fBerror\fR ( const TQString & msg ) const"
.br
.in -1c
.SS "Static Public Members"
.in +1c
.ti -1c
.BI "TQStyleSheet * \fBdefaultSheet\fR ()"
.br
.ti -1c
.BI "void \fBsetDefaultSheet\fR ( TQStyleSheet * sheet )"
.br
.ti -1c
.BI "TQString \fBescape\fR ( const TQString & plain )"
.br
.ti -1c
.BI "TQString \fBconvertFromPlainText\fR ( const TQString & plain, TQStyleSheetItem::WhiteSpaceMode mode = TQStyleSheetItem::WhiteSpacePre )"
.br
.ti -1c
.BI "bool \fBmightBeRichText\fR ( const TQString & text )"
.br
.in -1c
.SH DESCRIPTION
The TQStyleSheet class is a collection of styles for rich text rendering and a generator of tags.
.PP
By creating TQStyleSheetItem objects for a style sheet you build a definition of a set of tags. This definition will be used by the internal rich text rendering system to parse and display text documents to which the style sheet applies. Rich text is normally visualized in a TQTextEdit or a TQTextBrowser. However, TQLabel, TQWhatsThis and QMessageBox also support it, and other classes are likely to follow. With TQSimpleRichText it is possible to use the rich text renderer for custom widgets as well.
.PP
The default TQStyleSheet object has the following style bindings, sorted by structuring bindings, anchors, character style bindings (i.e. inline styles), special elements such as horizontal lines or images, and other tags. In addition, rich text supports simple HTML tables.
.PP
The structuring tags are <center>.nf
.TS
l - l. Structuring tags Notes A TQt rich text document. It understands the following attributes:
.TP
A top-level heading.
A sublevel heading.
A sub-sublevel heading.
Headings of lesser importance.
A left-aligned paragraph. Adjust the alignment with the
A centered paragraph.
An indented paragraph that is useful for quotes.
An unordered list. You can also pass a type argument to
define the bullet style. The default is
An ordered list. You can also pass a type argument to
define the enumeration label style. The default is
A list item. This tag can be used only within the context
of
A list of definitions, consisting of terms and descriptions.
A term in a list of definitions. This tag can be used only
in the context of
A description in a list of definitions. This tag can be
used only in the context of
For larger chunks of code. Whitespaces in the contents are
preserved. For small bits of code use the inline-style
.TE
.fi
</center>
.PP
Anchors and links are done with a single tag: <center>.nf
.TS
l - l. Anchor tags Notes An anchor or link.
.TP
A link is created by using an
.TE
.fi
</center>
.PP
The default character style bindings are <center>.nf
.TS
l - l. Style tags Notes Emphasized. By default this is the same as Strong. By default this is the same as Italic font style. Bold font style. Underlined font style. Strike out font style. A larger font size. A smaller font size. Subscripted text Superscripted text Indicates code. By default this is the same as Typewriter font style. Customizes the font size, family and text color. The tag understands the following attributes:
.TP
.TE
.fi
</center>
.PP
Special elements are: <center>.nf
.TS
l
-
l.
Special tags Notes
An image. The image name for the mime source factory is
given in the source attribute, for example
A horizontal line.
A line break.
.TE
.fi
</center>
.PP
In addition, rich text supports simple HTML tables. A table consists of one or more rows each of which contains one or more cells. Cells are either data cells or header cells, depending on their content. Cells which span rows and columns are supported.
.PP
<center>.nf
.TS
l - l. Table tags Notes A table. Tables support the following attributes:
.TP
A table row. This is only valid within a A table header cell. Similar to A table data cell. This is only valid within a
.TE
.fi
</center>
.PP
See also Graphics Classes, Help System, and Text Related Classes.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "TQStyleSheet::TQStyleSheet ( TQObject * parent = 0, const char * name = 0 )"
Creates a style sheet called \fIname\fR, with parent \fIparent\fR. Like any TQObject it will be deleted when its parent is destroyed (if the child still exists).
.PP
By default the style sheet has the tag definitions defined above.
.SH "TQStyleSheet::~TQStyleSheet ()\fC [virtual]\fR"
Destroys the style sheet. All styles inserted into the style sheet will be deleted.
.SH "TQString TQStyleSheet::convertFromPlainText ( const TQString & plain, TQStyleSheetItem::WhiteSpaceMode mode = TQStyleSheetItem::WhiteSpacePre )\fC [static]\fR"
Auxiliary function. Converts the plain text string \fIplain\fR to a rich text formatted paragraph while preserving most of its look.
.PP
\fImode\fR defines the whitespace mode. Possible values are TQStyleSheetItem::WhiteSpacePre (no wrapping, all whitespaces preserved) and TQStyleSheetItem::WhiteSpaceNormal (wrapping, simplified whitespaces).
.PP
See also escape().
.PP
Examples:
.)l action/application.cpp, application/application.cpp, and mdi/application.cpp.
.SH "TQStyleSheet * TQStyleSheet::defaultSheet ()\fC [static]\fR"
Returns the application-wide default style sheet. This style sheet is used by rich text rendering classes such as TQSimpleRichText, TQWhatsThis and QMessageBox to define the rendering style and available tags within rich text documents. It also serves as the initial style sheet for the more complex render widgets, TQTextEdit and TQTextBrowser.
.PP
See also setDefaultSheet().
.SH "void TQStyleSheet::error ( const TQString & msg ) const\fC [virtual]\fR"
This virtual function is called when an error occurs when processing rich text. Reimplement it if you need to catch error messages.
.PP
Errors might occur if some rich text strings contain tags that are not understood by the stylesheet, if some tags are nested incorrectly, or if tags are not closed properly.
.PP
\fImsg\fR is the error message.
.SH "TQString TQStyleSheet::escape ( const TQString & plain )\fC [static]\fR"
Auxiliary function. Converts the plain text string \fIplain\fR to a rich text formatted string with any HTML meta-characters escaped.
.PP
See also convertFromPlainText().
.SH "TQStyleSheetItem * TQStyleSheet::item ( const TQString & name )"
Returns the style called \fIname\fR or 0 if there is no such style.
.SH "const TQStyleSheetItem * TQStyleSheet::item ( const TQString & name ) const"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns the style called \fIname\fR or 0 if there is no such style (const version)
.SH "bool TQStyleSheet::mightBeRichText ( const TQString & text )\fC [static]\fR"
Returns TRUE if the string \fItext\fR is likely to be rich text; otherwise returns FALSE.
.PP
This function uses a fast and therefore simple heuristic. It mainly checks whether there is something that looks like a tag before the first line break. Although the result may be correct for common cases, there is no guarantee.
.SH "void TQStyleSheet::scaleFont ( TQFont & font, int logicalSize ) const\fC [virtual]\fR"
Scales the font \fIfont\fR to the appropriate physical point size corresponding to the logical font size \fIlogicalSize\fR.
.PP
When calling this function, \fIfont\fR has a point size corresponding to the logical font size 3.
.PP
Logical font sizes range from 1 to 7, with 1 being the smallest.
.PP
See also TQStyleSheetItem::logicalFontSize(), TQStyleSheetItem::logicalFontSizeStep(), and TQFont::setPointSize().
.SH "void TQStyleSheet::setDefaultSheet ( TQStyleSheet * sheet )\fC [static]\fR"
Sets the application-wide default style sheet to \fIsheet\fR, deleting any style sheet previously set. The ownership is transferred to TQStyleSheet.
.PP
See also defaultSheet().
.SH "TQTextCustomItem * TQStyleSheet::tag ( const TQString & name, const TQMap<TQString, TQString> & attr, const TQString & context, const TQMimeSourceFactory & factory, bool emptyTag, TQTextDocument * doc ) const\fC [virtual]\fR"
\fBThis function is under development and is subject to change.\fR
.PP
Generates an internal object for the tag called \fIname\fR, given the attributes \fIattr\fR, and using additional information provided by the mime source factory \fIfactory\fR.
.PP
\fIcontext\fR is the optional context of the document, i.e. the path to look for relative links. This becomes important if the text contains relative references, for example within image tags. TQSimpleRichText always uses the default mime source factory (see TQMimeSourceFactory::defaultFactory()) to resolve these references. The context will then be used to calculate the absolute path. See TQMimeSourceFactory::makeAbsolute() for details.
.PP
\fIemptyTag\fR and \fIdoc\fR are for internal use only.
.PP
This function should not be used in application code.
.SH "SEE ALSO"
.BR http://doc.trolltech.com/tqstylesheet.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive TQt documentation is provided in HTML format; it is
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech.
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (tqstylesheet.3qt) and the Qt
version (3.3.8).