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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qsimplerichtext.cpp:75 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQSimpleRichText Class</title>
<style type="text/css"><!--
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 Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped 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>TQSimpleRichText Class Reference</h1>
<p>The TQSimpleRichText class provides a small displayable piece of rich text.
<a href="#details">More...</a>
<p><tt>#include <<a href="qsimplerichtext-h.html">qsimplerichtext.h</a>></tt>
<p><a href="qsimplerichtext-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQSimpleRichText"><b>TQSimpleRichText</b></a> ( const TQString & text, const TQFont & fnt, const TQString & context = TQString::null, const TQStyleSheet * sheet = 0 )</li>
<li class=fn><a href="#TQSimpleRichText-2"><b>TQSimpleRichText</b></a> ( const TQString & text, const TQFont & fnt, const TQString & context, const TQStyleSheet * sheet, const TQMimeSourceFactory * factory, int pageBreak = -1, const TQColor & linkColor = TQt::blue, bool linkUnderline = TRUE )</li>
<li class=fn><a href="#~TQSimpleRichText"><b>~TQSimpleRichText</b></a> ()</li>
<li class=fn>void <a href="#setWidth-2"><b>setWidth</b></a> ( int w )</li>
<li class=fn>void <a href="#setWidth"><b>setWidth</b></a> ( TQPainter * p, int w )</li>
<li class=fn>void <a href="#setDefaultFont"><b>setDefaultFont</b></a> ( const TQFont & f )</li>
<li class=fn>int <a href="#width"><b>width</b></a> () const</li>
<li class=fn>int <a href="#widthUsed"><b>widthUsed</b></a> () const</li>
<li class=fn>int <a href="#height"><b>height</b></a> () const</li>
<li class=fn>void <a href="#adjustSize"><b>adjustSize</b></a> ()</li>
<li class=fn>void <a href="#draw"><b>draw</b></a> ( TQPainter * p, int x, int y, const TQRect & clipRect, const TQColorGroup & cg, const TQBrush * paper = 0 ) const</li>
<li class=fn>void draw ( TQPainter * p, int x, int y, const TQRegion & clipRegion, const TQColorGroup & cg, const TQBrush * paper = 0 ) const <em>(obsolete)</em></li>
<li class=fn>TQString <a href="#context"><b>context</b></a> () const</li>
<li class=fn>TQString <a href="#anchorAt"><b>anchorAt</b></a> ( const TQPoint & pos ) const</li>
<li class=fn>bool <a href="#inText"><b>inText</b></a> ( const TQPoint & pos ) const</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The TQSimpleRichText 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">TQStyleSheet</a> 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.
<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">TQPainter</a> with <a href="#draw">draw</a>().
TQSimpleRichText 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">TQTextEdit</a> or <a href="qtextbrowser.html">TQTextBrowser</a>. For very small
items of rich text you can use a <a href="qlabel.html">TQLabel</a>.
<p> If you are using TQSimpleRichText to print in high resolution you
should call <a href="#setWidth">setWidth</a>(TQPainter, int) so that the content will be
laid out properly on the page.
<p>See also <a href="text.html">Text Related Classes</a>.
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="TQSimpleRichText"></a>TQSimpleRichText::TQSimpleRichText ( const <a href="qstring.html">TQString</a> & text, const <a href="qfont.html">TQFont</a> & fnt, const <a href="qstring.html">TQString</a> & context = TQString::null, const <a href="qstylesheet.html">TQStyleSheet</a> * sheet = 0 )
</h3>
Constructs a TQSimpleRichText 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>
TQSimpleRichText myrichtext( contents, mywidget->font() );
</pre>
<p> <em>context</em> is the optional context of the rich text object. This
becomes important if <em>text</em> contains relative references, for
example within image tags. TQSimpleRichText always uses the default
mime source factory (see <a href="qmimesourcefactory.html#defaultFactory">TQMimeSourceFactory::defaultFactory</a>())
to resolve those references. The context will then be used to
calculate the absolute path. See
<a href="qmimesourcefactory.html#makeAbsolute">TQMimeSourceFactory::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">TQStyleSheet::defaultSheet</a>()).
<h3 class=fn><a name="TQSimpleRichText-2"></a>TQSimpleRichText::TQSimpleRichText ( const <a href="qstring.html">TQString</a> & text, const <a href="qfont.html">TQFont</a> & fnt, const <a href="qstring.html">TQString</a> & context, const <a href="qstylesheet.html">TQStyleSheet</a> * sheet, const <a href="qmimesourcefactory.html">TQMimeSourceFactory</a> * factory, int pageBreak = -1, const <a href="qcolor.html">TQColor</a> & linkColor = TQt::blue, bool linkUnderline = TRUE )
</h3>
Constructs a TQSimpleRichText from the rich text string <em>text</em> and
the font <em>fnt</em>.
<p> This is a slightly more complex constructor for TQSimpleRichText
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">TQColorGroup</a>'s <a href="qcolorgroup.html#link">TQColorGroup::link</a>() color is used now.
<p> <em>context</em> is the optional context of the rich text object. This
becomes important if <em>text</em> contains relative references, for
example within image tags. TQSimpleRichText always uses the default
mime source factory (see <a href="qmimesourcefactory.html#defaultFactory">TQMimeSourceFactory::defaultFactory</a>())
to resolve those references. The context will then be used to
calculate the absolute path. See
<a href="qmimesourcefactory.html#makeAbsolute">TQMimeSourceFactory::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">TQStyleSheet::defaultSheet</a>()).
<p> This constructor is useful for creating a TQSimpleRichText object
suitable for printing. Set <em>pageBreak</em> to be the height of the
contents area of the pages.
<h3 class=fn><a name="~TQSimpleRichText"></a>TQSimpleRichText::~TQSimpleRichText ()
</h3>
Destroys the rich text object, freeing memory.
<h3 class=fn>void <a name="adjustSize"></a>TQSimpleRichText::adjustSize ()
</h3>
Adjusts the richt text object to a reasonable size.
<p> <p>See also <a href="#setWidth">setWidth</a>().
<h3 class=fn><a href="qstring.html">TQString</a> <a name="anchorAt"></a>TQSimpleRichText::anchorAt ( const <a href="qpoint.html">TQPoint</a> & 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">TQString</a> <a name="context"></a>TQSimpleRichText::context () const
</h3>
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.
<h3 class=fn>void <a name="draw"></a>TQSimpleRichText::draw ( <a href="qpainter.html">TQPainter</a> * p, int x, int y, const <a href="qrect.html">TQRect</a> & clipRect, const <a href="qcolorgroup.html">TQColorGroup</a> & cg, const <a href="qbrush.html">TQBrush</a> * paper = 0 ) const
</h3>
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
rich text object's coordinates translated by (<em>x</em>, <em>y</em>). Passing
an null rectangle results in no clipping. 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>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>.
<h3 class=fn>void <a name="draw-2"></a>TQSimpleRichText::draw ( <a href="qpainter.html">TQPainter</a> * p, int x, int y, const <a href="qregion.html">TQRegion</a> & clipRegion, const <a href="qcolorgroup.html">TQColorGroup</a> & cg, const <a href="qbrush.html">TQBrush</a> * 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>TQSimpleRichText::height () const
</h3>
Returns the height of the rich text object in pixels.
<p> <p>See also <a href="#setWidth">setWidth</a>().
<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>.
<h3 class=fn>bool <a name="inText"></a>TQSimpleRichText::inText ( const <a href="qpoint.html">TQPoint</a> & pos ) const
</h3>
Returns TRUE if <em>pos</em> is within a text line of the rich text
object; otherwise returns FALSE.
<h3 class=fn>void <a name="setDefaultFont"></a>TQSimpleRichText::setDefaultFont ( const <a href="qfont.html">TQFont</a> & f )
</h3>
Sets the default font for the rich text object to <em>f</em>
<h3 class=fn>void <a name="setWidth"></a>TQSimpleRichText::setWidth ( <a href="qpainter.html">TQPainter</a> * p, int w )
</h3>
Sets the width of the rich text object 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 drawing on devices
other than the screen, for example a <a href="qprinter.html">TQPrinter</a>.
<p> <p>See also <a href="#height">height</a>() and <a href="#adjustSize">adjustSize</a>().
<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>.
<h3 class=fn>void <a name="setWidth-2"></a>TQSimpleRichText::setWidth ( int w )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Sets the width of the rich text object 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>TQSimpleRichText::width () const
</h3>
Returns the set width of the rich text object in pixels.
<p> <p>See also <a href="#widthUsed">widthUsed</a>().
<h3 class=fn>int <a name="widthUsed"></a>TQSimpleRichText::widthUsed () const
</h3>
Returns the width in pixels that is actually used by the rich text
object. 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 object 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">TQt toolkit</a>.
Copyright © 1995-2007
<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 © 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>
|