Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 112b0974ad288f6cd55bf971ee6026a9 > files > 1752

libqt3-devel-3.0.2-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/src/kernel/qsimplerichtext.cpp:53 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QSimpleRichText Class</title>
<style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QSimpleRichText Class Reference</h1>

<p>The QSimpleRichText class provides a small displayable piece of rich text.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qsimplerichtext-h.html">qsimplerichtext.h</a>&gt;</tt>
<p><a href="qsimplerichtext-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class=fn><a href="#QSimpleRichText"><b>QSimpleRichText</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;text, const&nbsp;QFont&nbsp;&amp;&nbsp;fnt, const&nbsp;QString&nbsp;&amp;&nbsp;context = QString::null, const&nbsp;QStyleSheet&nbsp;*&nbsp;sheet = 0 )</div></li>
<li><div class=fn><a href="#QSimpleRichText-2"><b>QSimpleRichText</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;text, const&nbsp;QFont&nbsp;&amp;&nbsp;fnt, const&nbsp;QString&nbsp;&amp;&nbsp;context, const&nbsp;QStyleSheet&nbsp;*&nbsp;sheet, const&nbsp;QMimeSourceFactory&nbsp;*&nbsp;factory, int&nbsp;pageBreak = -1, const&nbsp;QColor&nbsp;&amp;&nbsp;linkColor = Qt::blue, bool&nbsp;linkUnderline = TRUE )</div></li>
<li><div class=fn><a href="#~QSimpleRichText"><b>~QSimpleRichText</b></a> ()</div></li>
<li><div class=fn>void <a href="#setWidth-2"><b>setWidth</b></a> ( int&nbsp;w )</div></li>
<li><div class=fn>void <a href="#setWidth"><b>setWidth</b></a> ( QPainter&nbsp;*&nbsp;p, int&nbsp;w )</div></li>
<li><div class=fn>void <a href="#setDefaultFont"><b>setDefaultFont</b></a> ( const&nbsp;QFont&nbsp;&amp;&nbsp;f )</div></li>
<li><div class=fn>int <a href="#width"><b>width</b></a> () const</div></li>
<li><div class=fn>int <a href="#widthUsed"><b>widthUsed</b></a> () const</div></li>
<li><div class=fn>int <a href="#height"><b>height</b></a> () const</div></li>
<li><div class=fn>void <a href="#adjustSize"><b>adjustSize</b></a> ()</div></li>
<li><div class=fn>void <a href="#draw"><b>draw</b></a> ( QPainter&nbsp;*&nbsp;p, int&nbsp;x, int&nbsp;y, const&nbsp;QRect&nbsp;&amp;&nbsp;clipRect, const&nbsp;QColorGroup&nbsp;&amp;&nbsp;cg, const&nbsp;QBrush&nbsp;*&nbsp;paper = 0 ) const</div></li>
<li><div class=fn>void draw ( QPainter&nbsp;*&nbsp;p, int&nbsp;x, int&nbsp;y, const&nbsp;QRegion&nbsp;&amp;&nbsp;clipRegion, const&nbsp;QColorGroup&nbsp;&amp;&nbsp;cg, const&nbsp;QBrush&nbsp;*&nbsp;paper = 0 ) const &nbsp;<em>(obsolete)</em></div></li>
<li><div class=fn>QString <a href="#context"><b>context</b></a> () const</div></li>
<li><div class=fn>QString <a href="#anchorAt"><b>anchorAt</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;pos ) const</div></li>
<li><div class=fn>bool <a href="#inText"><b>inText</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;pos ) const</div></li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


The QSimpleRichText class provides a small displayable piece of rich text.
<p> 

<p> 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 <a href="qstylesheet.html">QStyleSheet</a>
is needed actually to understand and format rich text.  Qt provides a
default HTML-like style sheet, but you may define custom style sheets.
<p> Once created, the rich text object can be queried for its <a href="#width">width</a>(),
<a href="#height">height</a>(), and the actual width used (see <a href="#widthUsed">widthUsed</a>()).  Most
importantly, it can be drawn on any given <a href="qpainter.html">QPainter</a> with <a href="#draw">draw</a>().
QSimpleRichText can also be used to implement hypertext or active
text facilities by using <a href="#anchorAt">anchorAt</a>().  A hit test through <a href="#inText">inText</a>()
makes it possible to use simple rich text for text objects in
editable drawing canvases.
<p> 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.
<p> For large documents use <a href="qtextedit.html">QTextEdit</a> or <a href="qtextbrowser.html">QTextBrowser</a>. For very small
items of rich text you can use a <a href="qlabel.html">QLabel</a>.
<p>See also <a href="text.html">Text Related Classes</a>.

<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QSimpleRichText"></a>QSimpleRichText::QSimpleRichText ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, const&nbsp;<a href="qfont.html">QFont</a>&nbsp;&amp;&nbsp;fnt, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;context = QString::null, const&nbsp;<a href="qstylesheet.html">QStyleSheet</a>&nbsp;*&nbsp;sheet = 0 )
</h3>
Constructs a QSimpleRichText from the rich text string <em>text</em>
and the font <em>fnt</em>.
<p> The font is used as a basis for the text rendering. When using rich text
rendering on a widget <em>w</em>, you would normally specify the widget's font,
for example:
<p> <pre>
  QSimpleRichText myrichtext( contents, mywidget-&gt;font() );
  </pre>
 
<p> <em>context</em> is the optional context of the document. This becomes
important if <em>text</em> contains relative references, for example
within image tags. QSimpleRichText always uses the default mime
source factory (see <a href="qmimesourcefactory.html#defaultFactory">QMimeSourceFactory::defaultFactory</a>()) to
resolve those references. The context will then be used to calculate
the absolute path. See <a href="qmimesourcefactory.html#makeAbsolute">QMimeSourceFactory::makeAbsolute</a>() for
details.
<p> The <em>sheet</em> is an optional style sheet. If it is 0, the default
style sheet will be used (see <a href="qstylesheet.html#defaultSheet">QStyleSheet::defaultSheet</a>()).

<h3 class=fn><a name="QSimpleRichText-2"></a>QSimpleRichText::QSimpleRichText ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, const&nbsp;<a href="qfont.html">QFont</a>&nbsp;&amp;&nbsp;fnt, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;context, const&nbsp;<a href="qstylesheet.html">QStyleSheet</a>&nbsp;*&nbsp;sheet, const&nbsp;<a href="qmimesourcefactory.html">QMimeSourceFactory</a>&nbsp;*&nbsp;factory, int&nbsp;pageBreak = -1, const&nbsp;<a href="qcolor.html">QColor</a>&nbsp;&amp;&nbsp;linkColor = Qt::blue, bool&nbsp;linkUnderline = TRUE )
</h3>
Constructs a QSimpleRichText from the rich text string <em>text</em>
and the font <em>fnt</em>.
<p> This is a slightly more complex constructor for QSimpleRichText that
takes an additional mime source factory <em>factory</em>, a page break
parameter <em>pageBreak</em> and a bool <em>linkUnderline</em>. <em>linkColor</em> is
only provided for compatibility, but has no effect, as <a href="qcolorgroup.html">QColorGroup</a>'s
<a href="qcolorgroup.html#link">QColorGroup::link</a>() color is used now.
<p> <em>context</em> is the optional context of the document. This becomes
important if <em>text</em> contains relative references, for example
within image tags. QSimpleRichText always uses the default mime
source factory (see <a href="qmimesourcefactory.html#defaultFactory">QMimeSourceFactory::defaultFactory</a>()) to
resolve those references. The context will then be used to calculate
the absolute path. See <a href="qmimesourcefactory.html#makeAbsolute">QMimeSourceFactory::makeAbsolute</a>() for
details.
<p> The <em>sheet</em> is an optional style sheet. If it is 0, the default
style sheet will be used (see <a href="qstylesheet.html#defaultSheet">QStyleSheet::defaultSheet</a>()).
<p> This constructor is useful for creating a QSimpleRichText object
suitable for printing. Set <em>pageBreak</em> to be the height of the
contents area of the pages.

<h3 class=fn><a name="~QSimpleRichText"></a>QSimpleRichText::~QSimpleRichText ()
</h3>
Destroys the document, freeing memory.

<h3 class=fn>void <a name="adjustSize"></a>QSimpleRichText::adjustSize ()
</h3>
Adjusts the richt text document to a reasonable size.
<p> <p>See also <a href="#setWidth">setWidth</a>().

<h3 class=fn><a href="qstring.html">QString</a> <a name="anchorAt"></a>QSimpleRichText::anchorAt ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;pos ) const
</h3> Returns the anchor at the requested position, <em>pos</em>. An empty string is
returned if no anchor is specified for this position.

<h3 class=fn><a href="qstring.html">QString</a> <a name="context"></a>QSimpleRichText::context () const
</h3>
Returns the context of the rich text document. 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.

<h3 class=fn>void <a name="draw"></a>QSimpleRichText::draw ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;p, int&nbsp;x, int&nbsp;y, const&nbsp;<a href="qrect.html">QRect</a>&nbsp;&amp;&nbsp;clipRect, const&nbsp;<a href="qcolorgroup.html">QColorGroup</a>&nbsp;&amp;&nbsp;cg, const&nbsp;<a href="qbrush.html">QBrush</a>&nbsp;*&nbsp;paper = 0 ) const
</h3>
<p> Draws the formatted text with painter <em>p</em>, at position (<em>x</em>, <em>y</em>), clipped to <em>clipRect</em>.  The clipping rectangle is given in the
document's coordinates translated by (<em>x</em>, <em>y</em>). Colors from the
color group <em>cg</em> are used as needed, and if not 0, <em>*paper</em> is
used as the background brush.
<p> Note that the display code is highly optimized to reduce flicker, so
passing a brush for <em>paper</em> is preferable to simply clearing the area
to be painted and then calling this without a brush.

<p>Example: <a href="helpviewer-example.html#x1422">helpviewer/helpwindow.cpp</a>.
<h3 class=fn>void <a name="draw-2"></a>QSimpleRichText::draw ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;p, int&nbsp;x, int&nbsp;y, const&nbsp;<a href="qregion.html">QRegion</a>&nbsp;&amp;&nbsp;clipRegion, const&nbsp;<a href="qcolorgroup.html">QColorGroup</a>&nbsp;&amp;&nbsp;cg, const&nbsp;<a href="qbrush.html">QBrush</a>&nbsp;*&nbsp;paper = 0 ) const
</h3> 
<p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> 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).

<h3 class=fn>int <a name="height"></a>QSimpleRichText::height () const
</h3>
Returns the height of the document in pixels.
<p>See also <a href="#setWidth">setWidth</a>().

<p>Example: <a href="helpviewer-example.html#x1423">helpviewer/helpwindow.cpp</a>.
<h3 class=fn>bool <a name="inText"></a>QSimpleRichText::inText ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;pos ) const
</h3>
Returns TRUE if <em>pos</em> is within a text line of the document;
otherwise returns FALSE.

<h3 class=fn>void <a name="setDefaultFont"></a>QSimpleRichText::setDefaultFont ( const&nbsp;<a href="qfont.html">QFont</a>&nbsp;&amp;&nbsp;f )
</h3> Sets the default font for the document to <em>f</em> 
<h3 class=fn>void <a name="setWidth"></a>QSimpleRichText::setWidth ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;p, int&nbsp;w )
</h3>
Sets the width of the document to <em>w</em> pixels, recalculating the layout
as if it were to be drawn with painter <em>p</em>.
<p> Passing a painter is useful when you intend to draw on devices other
than the screen, for example a <a href="qprinter.html">QPrinter</a>.
<p> <p>See also <a href="#height">height</a>() and <a href="#adjustSize">adjustSize</a>().

<p>Example: <a href="helpviewer-example.html#x1424">helpviewer/helpwindow.cpp</a>.
<h3 class=fn>void <a name="setWidth-2"></a>QSimpleRichText::setWidth ( int&nbsp;w )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Sets the width of the document to <em>w</em> pixels.
<p> <p>See also <a href="#height">height</a>() and <a href="#adjustSize">adjustSize</a>().

<h3 class=fn>int <a name="width"></a>QSimpleRichText::width () const
</h3>
Returns the set width of the document in pixels.
<p> <p>See also <a href="#widthUsed">widthUsed</a>().

<h3 class=fn>int <a name="widthUsed"></a>QSimpleRichText::widthUsed () const
</h3>
Returns the width in pixels that is actually used by the document.
This can be smaller or wider than the set width.
<p> 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 document only consists of lines that do
not fill the width completely.
<p> <p>See also <a href="#width">width</a>().

<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 1995-2001
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2001 
<a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt version 3.0.2</div>
</table></div></address></body>
</html>