source: trunk/doc/html/qsimplerichtext.html@ 208

Last change on this file since 208 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 14.9 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qsimplerichtext.cpp:75 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QSimpleRichText Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<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>
33
34<p>The QSimpleRichText class provides a small displayable piece of rich text.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qsimplerichtext-h.html">qsimplerichtext.h</a>&gt;</tt>
37<p><a href="qsimplerichtext-members.html">List of all member functions.</a>
38<h2>Public Members</h2>
39<ul>
40<li 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 )</li>
41<li 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 )</li>
42<li class=fn><a href="#~QSimpleRichText"><b>~QSimpleRichText</b></a> ()</li>
43<li class=fn>void <a href="#setWidth-2"><b>setWidth</b></a> ( int&nbsp;w )</li>
44<li class=fn>void <a href="#setWidth"><b>setWidth</b></a> ( QPainter&nbsp;*&nbsp;p, int&nbsp;w )</li>
45<li class=fn>void <a href="#setDefaultFont"><b>setDefaultFont</b></a> ( const&nbsp;QFont&nbsp;&amp;&nbsp;f )</li>
46<li class=fn>int <a href="#width"><b>width</b></a> () const</li>
47<li class=fn>int <a href="#widthUsed"><b>widthUsed</b></a> () const</li>
48<li class=fn>int <a href="#height"><b>height</b></a> () const</li>
49<li class=fn>void <a href="#adjustSize"><b>adjustSize</b></a> ()</li>
50<li 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</li>
51<li 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></li>
52<li class=fn>QString <a href="#context"><b>context</b></a> () const</li>
53<li class=fn>QString <a href="#anchorAt"><b>anchorAt</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;pos ) const</li>
54<li class=fn>bool <a href="#inText"><b>inText</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;pos ) const</li>
55</ul>
56<hr><a name="details"></a><h2>Detailed Description</h2>
57
58
59The QSimpleRichText class provides a small displayable piece of rich text.
60<p>
61
62<p> This class encapsulates simple rich text usage in which a string
63is interpreted as rich text and can be drawn. This is particularly
64useful if you want to display some rich text in a custom widget. A
65<a href="qstylesheet.html">QStyleSheet</a> is needed to interpret the tags and format the rich
66text. Qt provides a default HTML-like style sheet, but you may
67define custom style sheets.
68<p> Once created, the rich text object can be queried for its <a href="#width">width</a>(),
69<a href="#height">height</a>(), and the actual width used (see <a href="#widthUsed">widthUsed</a>()). Most
70importantly, it can be drawn on any given <a href="qpainter.html">QPainter</a> with <a href="#draw">draw</a>().
71QSimpleRichText can also be used to implement hypertext or active
72text facilities by using <a href="#anchorAt">anchorAt</a>(). A hit test through <a href="#inText">inText</a>()
73makes it possible to use simple rich text for text objects in
74editable drawing canvases.
75<p> Once constructed from a string the contents cannot be changed,
76only resized. If the contents change, just throw the rich text
77object away and make a new one with the new contents.
78<p> For large documents use <a href="qtextedit.html">QTextEdit</a> or <a href="qtextbrowser.html">QTextBrowser</a>. For very small
79items of rich text you can use a <a href="qlabel.html">QLabel</a>.
80<p> If you are using QSimpleRichText to print in high resolution you
81should call <a href="#setWidth">setWidth</a>(QPainter, int) so that the content will be
82laid out properly on the page.
83<p>See also <a href="text.html">Text Related Classes</a>.
84
85<hr><h2>Member Function Documentation</h2>
86<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 )
87</h3>
88Constructs a QSimpleRichText from the rich text string <em>text</em> and
89the font <em>fnt</em>.
90<p> The font is used as a basis for the text rendering. When using
91rich text rendering on a widget <em>w</em>, you would normally specify
92the widget's font, for example:
93<p> <pre>
94 QSimpleRichText myrichtext( contents, mywidget-&gt;font() );
95 </pre>
96
97<p> <em>context</em> is the optional context of the rich text object. This
98becomes important if <em>text</em> contains relative references, for
99example within image tags. QSimpleRichText always uses the default
100mime source factory (see <a href="qmimesourcefactory.html#defaultFactory">QMimeSourceFactory::defaultFactory</a>())
101to resolve those references. The context will then be used to
102calculate the absolute path. See
103<a href="qmimesourcefactory.html#makeAbsolute">QMimeSourceFactory::makeAbsolute</a>() for details.
104<p> The <em>sheet</em> is an optional style sheet. If it is 0, the default
105style sheet will be used (see <a href="qstylesheet.html#defaultSheet">QStyleSheet::defaultSheet</a>()).
106
107<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 )
108</h3>
109Constructs a QSimpleRichText from the rich text string <em>text</em> and
110the font <em>fnt</em>.
111<p> This is a slightly more complex constructor for QSimpleRichText
112that takes an additional mime source factory <em>factory</em>, a page
113break parameter <em>pageBreak</em> and a bool <em>linkUnderline</em>. <em>linkColor</em> is only provided for compatibility, but has no effect,
114as <a href="qcolorgroup.html">QColorGroup</a>'s <a href="qcolorgroup.html#link">QColorGroup::link</a>() color is used now.
115<p> <em>context</em> is the optional context of the rich text object. This
116becomes important if <em>text</em> contains relative references, for
117example within image tags. QSimpleRichText always uses the default
118mime source factory (see <a href="qmimesourcefactory.html#defaultFactory">QMimeSourceFactory::defaultFactory</a>())
119to resolve those references. The context will then be used to
120calculate the absolute path. See
121<a href="qmimesourcefactory.html#makeAbsolute">QMimeSourceFactory::makeAbsolute</a>() for details.
122<p> The <em>sheet</em> is an optional style sheet. If it is 0, the default
123style sheet will be used (see <a href="qstylesheet.html#defaultSheet">QStyleSheet::defaultSheet</a>()).
124<p> This constructor is useful for creating a QSimpleRichText object
125suitable for printing. Set <em>pageBreak</em> to be the height of the
126contents area of the pages.
127
128<h3 class=fn><a name="~QSimpleRichText"></a>QSimpleRichText::~QSimpleRichText ()
129</h3>
130Destroys the rich text object, freeing memory.
131
132<h3 class=fn>void <a name="adjustSize"></a>QSimpleRichText::adjustSize ()
133</h3>
134Adjusts the richt text object to a reasonable size.
135<p> <p>See also <a href="#setWidth">setWidth</a>().
136
137<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
138</h3>
139Returns the anchor at the requested position, <em>pos</em>. An empty
140string is returned if no anchor is specified for this position.
141
142<h3 class=fn><a href="qstring.html">QString</a> <a name="context"></a>QSimpleRichText::context () const
143</h3>
144Returns the context of the rich text object. If no context has
145been specified in the constructor, a null string is returned. The
146context is the path to use to look up relative links, such as
147image tags and anchor references.
148
149<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
150</h3>
151Draws 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
152rich text object's coordinates translated by (<em>x</em>, <em>y</em>). Passing
153an null rectangle results in no clipping. Colors from the color
154group <em>cg</em> are used as needed, and if not 0, <em>*paper</em> is used as
155the background brush.
156<p> Note that the display code is highly optimized to reduce flicker,
157so passing a brush for <em>paper</em> is preferable to simply clearing
158the area to be painted and then calling this without a brush.
159
160<p>Examples: <a href="qaction-application-example.html#x1158">action/application.cpp</a>, <a href="simple-application-example.html#x1576">application/application.cpp</a>, <a href="helpviewer-example.html#x1014">helpviewer/helpwindow.cpp</a>, and <a href="mdi-example.html#x2061">mdi/application.cpp</a>.
161<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
162</h3>
163<p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
164<p> Use the version with clipRect instead. The region version has
165problems with larger documents on some platforms (on X11 regions
166internally are represented with 16bit coordinates).
167
168<h3 class=fn>int <a name="height"></a>QSimpleRichText::height () const
169</h3>
170Returns the height of the rich text object in pixels.
171<p> <p>See also <a href="#setWidth">setWidth</a>().
172
173<p>Examples: <a href="qaction-application-example.html#x1159">action/application.cpp</a>, <a href="simple-application-example.html#x1577">application/application.cpp</a>, <a href="helpviewer-example.html#x1015">helpviewer/helpwindow.cpp</a>, and <a href="mdi-example.html#x2062">mdi/application.cpp</a>.
174<h3 class=fn>bool <a name="inText"></a>QSimpleRichText::inText ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;pos ) const
175</h3>
176Returns TRUE if <em>pos</em> is within a text line of the rich text
177object; otherwise returns FALSE.
178
179<h3 class=fn>void <a name="setDefaultFont"></a>QSimpleRichText::setDefaultFont ( const&nbsp;<a href="qfont.html">QFont</a>&nbsp;&amp;&nbsp;f )
180</h3>
181Sets the default font for the rich text object to <em>f</em>
182
183<h3 class=fn>void <a name="setWidth"></a>QSimpleRichText::setWidth ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;p, int&nbsp;w )
184</h3>
185Sets the width of the rich text object to <em>w</em> pixels,
186recalculating the layout as if it were to be drawn with painter <em>p</em>.
187<p> Passing a painter is useful when you intend drawing on devices
188other than the screen, for example a <a href="qprinter.html">QPrinter</a>.
189<p> <p>See also <a href="#height">height</a>() and <a href="#adjustSize">adjustSize</a>().
190
191<p>Examples: <a href="qaction-application-example.html#x1160">action/application.cpp</a>, <a href="simple-application-example.html#x1578">application/application.cpp</a>, <a href="helpviewer-example.html#x1016">helpviewer/helpwindow.cpp</a>, and <a href="mdi-example.html#x2063">mdi/application.cpp</a>.
192<h3 class=fn>void <a name="setWidth-2"></a>QSimpleRichText::setWidth ( int&nbsp;w )
193</h3>
194This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
195<p> Sets the width of the rich text object to <em>w</em> pixels.
196<p> <p>See also <a href="#height">height</a>() and <a href="#adjustSize">adjustSize</a>().
197
198<h3 class=fn>int <a name="width"></a>QSimpleRichText::width () const
199</h3>
200Returns the set width of the rich text object in pixels.
201<p> <p>See also <a href="#widthUsed">widthUsed</a>().
202
203<h3 class=fn>int <a name="widthUsed"></a>QSimpleRichText::widthUsed () const
204</h3>
205Returns the width in pixels that is actually used by the rich text
206object. This can be smaller or wider than the set width.
207<p> It may be wider, for example, if the text contains images or
208non-breakable words that are already wider than the available
209space. It's smaller when the object only consists of lines that do
210not fill the width completely.
211<p> <p>See also <a href="#width">width</a>().
212
213<!-- eof -->
214<hr><p>
215This file is part of the <a href="index.html">Qt toolkit</a>.
216Copyright &copy; 1995-2007
217<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
218<table width=100% cellspacing=0 border=0><tr>
219<td>Copyright &copy; 2007
220<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
221<td align=right><div align=right>Qt 3.3.8</div>
222</table></div></address></body>
223</html>
Note: See TracBrowser for help on using the repository browser.