File: qsimplerichtext.html

package info (click to toggle)
qt-embedded 2.3.2-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 68,608 kB
  • ctags: 45,998
  • sloc: cpp: 276,654; ansic: 71,987; makefile: 29,074; sh: 12,305; yacc: 2,465; python: 1,863; perl: 481; lex: 480; xml: 68; lisp: 15
file content (167 lines) | stat: -rw-r--r-- 12,570 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - 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: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">

<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>

<h1 align=center>QSimpleRichText Class Reference</h1><br clear="all">
<p>
A small displayable piece of rich text.
<a href="#details">More...</a>
<p>
<code>#include &lt;<a href="qsimplerichtext-h.html">qsimplerichtext.h</a>&gt;</code>
<p><a href="qsimplerichtext-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn"><a href="#fb3403"><b>QSimpleRichText</b></a>(constQString&amp;text, constQFont&amp;fnt, constQString&amp;context=QString::null, constQStyleSheet*sheet=0)</div>
<li><div class="fn"><a href="#bdb900"><b>QSimpleRichText</b></a>(constQString&amp;text, constQFont&amp;fnt, constQString&amp;context, constQStyleSheet*sheet, constQMimeSourceFactory*factory, intverticalBreak=-1, constQColor&amp;linkColor=Qt::blue, boollinkUnderline=TRUE)</div>
<li><div class="fn"><a href="#7d8194"><b>~QSimpleRichText</b></a>()</div>
<li><div class="fn">void<a href="#6f02c2"><b>setWidth</b></a>(int)</div>
<li><div class="fn">void<a href="#86e351"><b>setWidth</b></a>(QPainter*, int)</div>
<li><div class="fn">int<a href="#612332"><b>width</b></a>()const</div>
<li><div class="fn">int<a href="#59c7f9"><b>widthUsed</b></a>()const</div>
<li><div class="fn">int<a href="#428651"><b>height</b></a>()const</div>
<li><div class="fn">void<a href="#b87475"><b>adjustSize</b></a>()</div>
<li><div class="fn">void<a href="#4e026f"><b>draw</b></a>(QPainter*, intx, inty, constQRegion&amp;clipRegion, constQPalette&amp;pal, constQBrush*paper=0)const</div>
<li><div class="fn">void<a href="#1ec331"><b>draw</b></a>(QPainter*, intx, inty, constQRegion&amp;clipRegion, constQColorGroup&amp;cg, constQBrush*paper=0)const</div>
<li><div class="fn">QString<a href="#1a6efc"><b>context</b></a>()const</div>
<li><div class="fn">QString<a href="#77ea59"><b>anchorAt</b></a>(constQPoint&amp;pos)const</div>
<li><div class="fn">QStringanchor(QPainter*p, constQPoint&amp;pos)<em>(obsolete)</em></div>
<li><div class="fn">bool<a href="#96049b"><b>inText</b></a>(constQPoint&amp;pos)const</div>
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
A small displayable piece of rich text.
<p>
This class encapsulates simple richt text usage where a string is
interpreted as richt text and can be drawn.  This is in particular
useful if you want to display some rich text in a custom widget.
A <a href="qstylesheet.html">QStyleSheet</a> is needed to actually 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="#612332">width</a>(),
<a href="#428651">height</a>() and the actual width used (see <a href="#59c7f9">widthUsed</a>()).  Most
importantly, it can be drawn on any given <a href="qpainter.html">QPainter</a> with <a href="#4e026f">draw</a>().
QSimpleRichText can also be used to implement hypertext or active
text facilities by using <a href="#77ea59">anchorAt</a>().  A hit test through <a href="#96049b">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 should change, just throw the rich text
object away and make a new one with the new contents.
<p>For large documents, see <a href="qtextview.html">QTextView</a> or <a href="qtextbrowser.html">QTextBrowser</a>.

<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="fb3403"></a>QSimpleRichText::QSimpleRichText(const<a href="qstring.html">QString</a>&amp;text, const<a href="qfont.html">QFont</a>&amp;fnt, const<a href="qstring.html">QString</a>&amp;context=QString::null, const<a href="qstylesheet.html">QStyleSheet</a>*sheet=0)</h3>
<p>Constructs a QSimpleRichText from the rich text string <em>text</em>
and the font <em>fnt.</em>
<p>The font is used as basis for the text rendering. When using rich
text rendering on a certain widget <em>w,</em> you would regularly
specify the widget's font as shown in the following code example:
<p><pre>  <a href="qsimplerichtext.html">QSimpleRichText</a> 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#5c7072">QMimeSourceFactory::defaultFactory</a>() ) to
resolve those references. The context will then be used to calculate
the absolute path. See <a href="qmimesourcefactory.html#83807a">QMimeSourceFactory::makeAbsolute</a>() for
details.
<p>Finally <em>s</em> is an optional style sheet. If it is 0, the default
style sheet will be used (see <a href="qstylesheet.html#50ded7">QStyleSheet::defaultSheet</a>() ).
<h3 class="fn"><a name="bdb900"></a>QSimpleRichText::QSimpleRichText(const<a href="qstring.html">QString</a>&amp;text, const<a href="qfont.html">QFont</a>&amp;fnt, const<a href="qstring.html">QString</a>&amp;context, const<a href="qstylesheet.html">QStyleSheet</a>*sheet, const<a href="qmimesourcefactory.html">QMimeSourceFactory</a>*factory, intverticalBreak=-1, const<a href="qcolor.html">QColor</a>&amp;linkColor=Qt::blue, boollinkUnderline=TRUE)</h3>
<p>Another, more complex constructor for QSimpleRichText that takes
an additional mime source factory <em>factory,</em> a vertical break
parameter <em>verticalBreak,</em> a link color <em>linkColor</em> and a bool <em>linkUnderline.</em>
<p>The constructor is useful to create a QSimpleRichText object
suitable for printing. Set <em>verticalBreak</em> to be the height of the
contents area of the pages.
<h3 class="fn"><a name="7d8194"></a>QSimpleRichText::~QSimpleRichText()</h3>
<p>Destructs the document, freeing memory.
<h3 class="fn">void<a name="b87475"></a>QSimpleRichText::adjustSize()</h3>
<p>Adjusts the richt text document to a reasonable size.
<p>See also  <a href="#6f02c2">setWidth</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="e45f6c"></a>QSimpleRichText::anchor(<a href="qpainter.html">QPainter</a>*, const<a href="qpoint.html">QPoint</a>&amp;pos)</h3>
<p><b>This function is obsolete.</b> It is provided to keep old source working, and will probably be removed in a future version of Qt.  We strongly advise against using it in new code.<p>
Returns the anchor at the requested position. The <a href="qpainter.html">QPainter</a> is needed for font size
calculations. An empty string is returned if no anchor is specified for this certain
position.
<p>This function will be removed in 3.0.
<h3 class="fn"><a href="qstring.html">QString</a><a name="77ea59"></a>QSimpleRichText::anchorAt(const<a href="qpoint.html">QPoint</a>&amp;pos)const</h3>
<p>Returns the anchor at the requested position. An empty string is
returned if no anchor is specified for this certain position.
<h3 class="fn"><a href="qstring.html">QString</a><a name="1a6efc"></a>QSimpleRichText::context()const</h3>
<p>Returns the context of the rich text document. If no context has been specified
in the constructor, a null string is returned.
<h3 class="fn">void<a name="4e026f"></a>QSimpleRichText::draw(<a href="qpainter.html">QPainter</a>*p, intx, inty, const<a href="qregion.html">QRegion</a>&amp;clipRegion, const<a href="qpalette.html">QPalette</a>&amp;pal, const<a href="qbrush.html">QBrush</a>*paper=0)const</h3>
<p>Draws the formatted text with <em>p,</em> at position (<em>x, y),</em> clipped
to <em>clipRegion.</em>  Colors from the palette <em>pal</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.
<h3 class="fn">void<a name="1ec331"></a>QSimpleRichText::draw(<a href="qpainter.html">QPainter</a>*p, intx, inty, const<a href="qregion.html">QRegion</a>&amp;clipRegion, const<a href="qcolorgroup.html">QColorGroup</a>&amp;cg, const<a href="qbrush.html">QBrush</a>*paper=0)const</h3>
<p>This is an overloaded member function, provided for convenience.  It differs from the above function only in what argument(s) it accepts.
<p>Draws the formatted text with <em>p,</em> at position (<em>x, y),</em> clipped
to <em>clipRegion.</em>  Colors from the <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>This is a convenience function if there's no palette but just a
color group available. If you have a palette, pass this instead of <em>cg.</em>
<h3 class="fn">int<a name="428651"></a>QSimpleRichText::height()const</h3>
<p>Returns the height of the document, in pixels.
<p>See also  <a href="#6f02c2">setWidth</a>().
<h3 class="fn">bool<a name="96049b"></a>QSimpleRichText::inText(const<a href="qpoint.html">QPoint</a>&amp;pos)const</h3>
<p>Returns whether <em>pos</em> is within a text line of the document or not.
<h3 class="fn">void<a name="86e351"></a>QSimpleRichText::setWidth(<a href="qpainter.html">QPainter</a>*p, intw)</h3>
<p>Sets the width of the document to <em>w</em> pixels, recalculating the layout
as if it were to be drawn with <em>p.</em>
<p>Passing a painter is useful when you intend to draw on devices other
than the screen, like for example a <a href="qprinter.html">QPrinter</a>.
<p>See also  <a href="#428651">height</a>() and <a href="#b87475">adjustSize</a>().
<h3 class="fn">void<a name="6f02c2"></a>QSimpleRichText::setWidth(intw)</h3>
<p>Sets the width of the document to <em>w</em> pixels.
<p>See also  <a href="#428651">height</a>() and <a href="#b87475">adjustSize</a>().
<h3 class="fn">int<a name="612332"></a>QSimpleRichText::width()const</h3>
<p>Returns the set width of the document, in pixels.
<p>See also  <a href="#59c7f9">widthUsed</a>().
<h3 class="fn">int<a name="59c7f9"></a>QSimpleRichText::widthUsed()const</h3>
<p>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>See also  <a href="#612332">width</a>().
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><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  2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>