This class encapsulates simple rich text usage in which a string is interpreted as rich text and can be drawn. This is particularly useful if you want to display some rich text in a custom widget. A TQStyleSheet is needed to interpret the tags and format the rich text. TQt provides a default HTML-like style sheet, but you may define custom style sheets.
Once created, the rich text object can be queried for its width(), height(), and the actual width used (see widthUsed()). Most importantly, it can be drawn on any given TQPainter with draw(). QSimpleRichText can also be used to implement hypertext or active text facilities by using anchorAt(). A hit test through inText() makes it possible to use simple rich text for text objects in editable drawing canvases.
Once constructed from a string the contents cannot be changed, only resized. If the contents change, just throw the rich text object away and make a new one with the new contents.
If you are using QSimpleRichText to print in high resolution you should call setWidth(TQPainter, int) so that the content will be laid out properly on the page.
Constructs a QSimpleRichText from the rich text string \fItext\fR and the font \fIfnt\fR.
.PP
The font is used as a basis for the text rendering. When using rich text rendering on a widget \fIw\fR, you would normally specify the widget's font, for example:
\fIcontext\fR is the optional context of the rich text object. This becomes important if \fItext\fR contains relative references, for example within image tags. QSimpleRichText always uses the default mime source factory (see TQMimeSourceFactory::defaultFactory()) to resolve those references. The context will then be used to calculate the absolute path. See TQMimeSourceFactory::makeAbsolute() for details.
This is a slightly more complex constructor for QSimpleRichText that takes an additional mime source factory \fIfactory\fR, a page break parameter \fIpageBreak\fR and a bool \fIlinkUnderline\fR. \fIlinkColor\fR is only provided for compatibility, but has no effect, as TQColorGroup's TQColorGroup::link() color is used now.
\fIcontext\fR is the optional context of the rich text object. This becomes important if \fItext\fR contains relative references, for example within image tags. QSimpleRichText always uses the default mime source factory (see TQMimeSourceFactory::defaultFactory()) to resolve those references. The context will then be used to calculate the absolute path. See TQMimeSourceFactory::makeAbsolute() for details.
This constructor is useful for creating a QSimpleRichText object suitable for printing. Set \fIpageBreak\fR to be the height of the contents area of the pages.
.SH "QSimpleRichText::~QSimpleRichText ()"
Destroys the rich text object, freeing memory.
.SH "void QSimpleRichText::adjustSize ()"
Adjusts the richt text object to a reasonable size.
Returns the context of the rich text object. If no context has been specified in the constructor, a null string is returned. The context is the path to use to look up relative links, such as image tags and anchor references.
Draws the formatted text with painter \fIp\fR, at position (\fIx\fR, \fIy\fR), clipped to \fIclipRect\fR. The clipping rectangle is given in the rich text object's coordinates translated by (\fIx\fR, \fIy\fR). Passing an null rectangle results in no clipping. Colors from the color group \fIcg\fR are used as needed, and if not 0, \fI*paper\fR is used as the background brush.
.PP
Note that the display code is highly optimized to reduce flicker, so passing a brush for \fIpaper\fR is preferable to simply clearing the area to be painted and then calling this without a brush.
.PP
Examples:
.)l action/application.cpp, application/application.cpp, helpviewer/helpwindow.cpp, and mdi/application.cpp.
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
Use the version with clipRect instead. The region version has problems with larger documents on some platforms (on X11 regions internally are represented with 16bit coordinates).
.SH "int QSimpleRichText::height () const"
Returns the height of the rich text object in pixels.
.PP
See also setWidth().
.PP
Examples:
.)l action/application.cpp, application/application.cpp, helpviewer/helpwindow.cpp, and mdi/application.cpp.
.)l action/application.cpp, application/application.cpp, helpviewer/helpwindow.cpp, and mdi/application.cpp.
.SH "void QSimpleRichText::setWidth ( int w )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Sets the width of the rich text object to \fIw\fR pixels.
.PP
See also height() and adjustSize().
.SH "int QSimpleRichText::width () const"
Returns the set width of the rich text object in pixels.
.PP
See also widthUsed().
.SH "int QSimpleRichText::widthUsed () const"
Returns the width in pixels that is actually used by the rich text object. This can be smaller or wider than the set width.
.PP
It may be wider, for example, if the text contains images or non-breakable words that are already wider than the available space. It's smaller when the object only consists of lines that do not fill the width completely.