summaryrefslogtreecommitdiffstats
path: root/doc/html/ntqcursor.html
blob: 5f90ed600cefa2238c0a32084f64c8010614d3d2 (plain)
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<!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/qcursor.cpp:47 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQCursor 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&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>TQCursor Class Reference</h1>

<p>The TQCursor class provides a mouse cursor with an arbitrary
shape.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qcursor-h.html">ntqcursor.h</a>&gt;</tt>
<p>Inherits <a href="ntqt.html">TQt</a>.
<p><a href="qcursor-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQCursor"><b>TQCursor</b></a> ()</li>
<li class=fn><a href="#TQCursor-2"><b>TQCursor</b></a> ( int&nbsp;shape )</li>
<li class=fn><a href="#TQCursor-3"><b>TQCursor</b></a> ( const&nbsp;TQBitmap&nbsp;&amp;&nbsp;bitmap, const&nbsp;TQBitmap&nbsp;&amp;&nbsp;mask, int&nbsp;hotX = -1, int&nbsp;hotY = -1 )</li>
<li class=fn><a href="#TQCursor-4"><b>TQCursor</b></a> ( const&nbsp;TQPixmap&nbsp;&amp;&nbsp;pixmap, int&nbsp;hotX = -1, int&nbsp;hotY = -1 )</li>
<li class=fn><a href="#TQCursor-5"><b>TQCursor</b></a> ( const&nbsp;TQCursor&nbsp;&amp;&nbsp;c )</li>
<li class=fn><a href="#~TQCursor"><b>~TQCursor</b></a> ()</li>
<li class=fn>TQCursor &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;TQCursor&nbsp;&amp;&nbsp;c )</li>
<li class=fn>int <a href="#shape"><b>shape</b></a> () const</li>
<li class=fn>void <a href="#setShape"><b>setShape</b></a> ( int&nbsp;shape )</li>
<li class=fn>const TQBitmap * <a href="#bitmap"><b>bitmap</b></a> () const</li>
<li class=fn>const TQBitmap * <a href="#mask"><b>mask</b></a> () const</li>
<li class=fn>TQPoint <a href="#hotSpot"><b>hotSpot</b></a> () const</li>
<li class=fn>HCURSOR <b>handle</b> () const</li>
<li class=fn><a href="#TQCursor-6"><b>TQCursor</b></a> ( HCURSOR&nbsp;handle )</li>
<li class=fn>HANDLE <a href="#handle"><b>handle</b></a> () const</li>
</ul>
<h2>Static Public Members</h2>
<ul>
<li class=fn>TQPoint <a href="#pos"><b>pos</b></a> ()</li>
<li class=fn>void <a href="#setPos"><b>setPos</b></a> ( int&nbsp;x, int&nbsp;y )</li>
<li class=fn>void <a href="#setPos-2"><b>setPos</b></a> ( const TQPoint &amp; )</li>
<li class=fn>void <a href="#initialize"><b>initialize</b></a> ()</li>
<li class=fn>void <a href="#cleanup"><b>cleanup</b></a> ()</li>
</ul>
<h2>Related Functions</h2>
<ul>
<li class=fn>TQDataStream &amp; <a href="#operator-lt-lt"><b>operator&lt;&lt;</b></a> ( TQDataStream&nbsp;&amp;&nbsp;s, const&nbsp;TQCursor&nbsp;&amp;&nbsp;c )</li>
<li class=fn>TQDataStream &amp; <a href="#operator-gt-gt"><b>operator&gt;&gt;</b></a> ( TQDataStream&nbsp;&amp;&nbsp;s, TQCursor&nbsp;&amp;&nbsp;c )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


<p> The TQCursor class provides a mouse cursor with an arbitrary
shape.
<p> 

<p> This class is mainly used to create mouse cursors that are
associated with particular widgets and to get and set the position
of the mouse cursor.
<p> TQt has a number of standard cursor shapes, but you can also make
custom cursor shapes based on a <a href="ntqbitmap.html">TQBitmap</a>, a mask and a hotspot.
<p> To associate a cursor with a widget, use <a href="ntqwidget.html#setCursor">TQWidget::setCursor</a>(). To
associate a cursor with all widgets (normally for a short period
of time), use <a href="ntqapplication.html#setOverrideCursor">TQApplication::setOverrideCursor</a>().
<p> To set a cursor shape use <a href="#setShape">TQCursor::setShape</a>() or use the TQCursor
constructor which takes the shape as argument, or you can use one
of the predefined cursors defined in the <a href="ntqt.html#CursorShape-enum">CursorShape</a> enum.
<p> If you want to create a cursor with your own bitmap, either use
the TQCursor constructor which takes a bitmap and a mask or the
constructor which takes a pixmap as arguments.
<p> To set or get the position of the mouse cursor use the static
methods <a href="#pos">TQCursor::pos</a>() and <a href="#setPos">TQCursor::setPos</a>().
<p> <center><img src="cursors.png" alt="Cursor Shapes"></center> 
<p> <p>See also <a href="ntqwidget.html">TQWidget</a>, <a href="guibooks.html#fowler">GUI Design Handbook:
 Cursors</a>, <a href="appearance.html">Widget Appearance and Style</a>, and <a href="shared.html">Implicitly and Explicitly Shared Classes</a>.

<p> On X11, TQt supports the <a href="http://www.xfree86.org/4.3.0/Xcursor.3.html">Xcursor</a>
library, which allows for full color icon themes. The table below
shows the cursor name used for each TQt::CursorShape value. If a
cursor cannot be found using the name shown below, a standard X11
cursor will be used instead. Note: X11 does not provide
appropriate cursors for all possible TQt::CursorShape values. It
is possible that some cursors will be taken from the Xcursor
theme, while others will use an internal bitmap cursor.
<p> <center><table cellpadding="4" cellspacing="2" border="0">
<tr bgcolor="#a2c511"> <th valign="top">TQt::CursorShape Values   <th valign="top">Cursor Names
<tr bgcolor="#f0f0f0"> <td valign="top">TQt::ArrowCursor             <td valign="top">left_ptr
<tr bgcolor="#d0d0d0"> <td valign="top">TQt::UpArrowCursor           <td valign="top">up_arrow
<tr bgcolor="#f0f0f0"> <td valign="top">TQt::CrossCursor             <td valign="top">cross
<tr bgcolor="#d0d0d0"> <td valign="top">TQt::WaitCursor              <td valign="top">wait
<tr bgcolor="#f0f0f0"> <td valign="top">TQt::BusyCursor		<td valign="top">left_ptr_watch
<tr bgcolor="#d0d0d0"> <td valign="top">TQt::IbeamCursor             <td valign="top">ibeam
<tr bgcolor="#f0f0f0"> <td valign="top">TQt::SizeVerCursor           <td valign="top">size_ver
<tr bgcolor="#d0d0d0"> <td valign="top">TQt::SizeHorCursor           <td valign="top">size_hor
<tr bgcolor="#f0f0f0"> <td valign="top">TQt::SizeBDiagCursor         <td valign="top">size_bdiag
<tr bgcolor="#d0d0d0"> <td valign="top">TQt::SizeFDiagCursor         <td valign="top">size_fdiag
<tr bgcolor="#f0f0f0"> <td valign="top">TQt::SizeAllCursor           <td valign="top">size_all
<tr bgcolor="#d0d0d0"> <td valign="top">TQt::SplitVCursor            <td valign="top">split_v
<tr bgcolor="#f0f0f0"> <td valign="top">TQt::SplitHCursor            <td valign="top">split_h
<tr bgcolor="#d0d0d0"> <td valign="top">TQt::PointingHandCursor      <td valign="top">pointing_hand
<tr bgcolor="#f0f0f0"> <td valign="top">TQt::ForbiddenCursor         <td valign="top">forbidden
<tr bgcolor="#d0d0d0"> <td valign="top">TQt::WhatsThisCursor         <td valign="top">whats_this
</table></center>

<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="TQCursor"></a>TQCursor::TQCursor ()
</h3>
Constructs a cursor with the default arrow shape.

<h3 class=fn><a name="TQCursor-2"></a>TQCursor::TQCursor ( int&nbsp;shape )
</h3>
Constructs a cursor with the specified <em>shape</em>.
<p> See <a href="ntqt.html#CursorShape-enum">CursorShape</a> for a list of shapes.
<p> <p>See also <a href="#setShape">setShape</a>().

<h3 class=fn><a name="TQCursor-3"></a>TQCursor::TQCursor ( const&nbsp;<a href="ntqbitmap.html">TQBitmap</a>&nbsp;&amp;&nbsp;bitmap, const&nbsp;<a href="ntqbitmap.html">TQBitmap</a>&nbsp;&amp;&nbsp;mask, int&nbsp;hotX = -1, int&nbsp;hotY = -1 )
</h3>
Constructs a custom bitmap cursor.
<p> <em>bitmap</em> and
<em>mask</em> make up the bitmap.
<em>hotX</em> and
<em>hotY</em> define the cursor's hot spot.
<p> If <em>hotX</em> is negative, it is set to the <tt>bitmap().width()/2</tt>.
If <em>hotY</em> is negative, it is set to the <tt>bitmap().height()/2</tt>.
<p> The cursor <em>bitmap</em> (B) and <em>mask</em> (M) bits are combined like this:
<ul>
<li> B=1 and M=1 gives black.
<li> B=0 and M=1 gives white.
<li> B=0 and M=0 gives transparent.
<li> B=1 and M=0 gives an undefined result.
</ul>
<p> Use the global TQt color <tt>color0</tt> to draw 0-pixels and <tt>color1</tt> to
draw 1-pixels in the bitmaps.
<p> Valid cursor sizes depend on the display hardware (or the
underlying window system). We recommend using 32x32 cursors,
because this size is supported on all platforms. Some platforms
also support 16x16, 48x48 and 64x64 cursors.
<p> <p>See also <a href="ntqbitmap.html#TQBitmap">TQBitmap::TQBitmap</a>() and <a href="ntqpixmap.html#setMask">TQBitmap::setMask</a>().

<h3 class=fn><a name="TQCursor-4"></a>TQCursor::TQCursor ( const&nbsp;<a href="ntqpixmap.html">TQPixmap</a>&nbsp;&amp;&nbsp;pixmap, int&nbsp;hotX = -1, int&nbsp;hotY = -1 )
</h3>
Constructs a custom pixmap cursor.
<p> <em>pixmap</em> is the image. It is usual to give it a mask (set using
<a href="ntqpixmap.html#setMask">TQPixmap::setMask</a>()). <em>hotX</em> and <em>hotY</em> define the cursor's hot
spot.
<p> If <em>hotX</em> is negative, it is set to the <tt>pixmap().width()/2</tt>.
If <em>hotY</em> is negative, it is set to the <tt>pixmap().height()/2</tt>.
<p> Valid cursor sizes depend on the display hardware (or the
underlying window system). We recommend using 32x32 cursors,
because this size is supported on all platforms. Some platforms
also support 16x16, 48x48 and 64x64 cursors.
<p> Currently, only black-and-white pixmaps can be used.
<p> <p>See also <a href="ntqpixmap.html#TQPixmap">TQPixmap::TQPixmap</a>() and <a href="ntqpixmap.html#setMask">TQPixmap::setMask</a>().

<h3 class=fn><a name="TQCursor-5"></a>TQCursor::TQCursor ( const&nbsp;<a href="ntqcursor.html">TQCursor</a>&nbsp;&amp;&nbsp;c )
</h3>
Constructs a copy of the cursor <em>c</em>.

<h3 class=fn><a name="TQCursor-6"></a>TQCursor::TQCursor ( HCURSOR&nbsp;handle )
</h3>

<p> Creates a cursor with the specified window system handle <em>handle</em>.
<p> <b>Warning:</b>
Portable in principle, but if you use it you are probably about to
do something non-portable. Be careful.

<h3 class=fn><a name="~TQCursor"></a>TQCursor::~TQCursor ()
</h3>
Destroys the cursor.

<h3 class=fn>const&nbsp;<a href="ntqbitmap.html">TQBitmap</a>&nbsp;* <a name="bitmap"></a>TQCursor::bitmap () const
</h3>
Returns the cursor bitmap, or 0 if it is one of the standard
cursors.

<h3 class=fn>void <a name="cleanup"></a>TQCursor::cleanup ()<tt> [static]</tt>
</h3>
Internal function that deinitializes the predefined cursors.
This function is called from the <a href="ntqapplication.html">TQApplication</a> destructor.
<p> <p>See also <a href="#initialize">initialize</a>().

<h3 class=fn>HANDLE <a name="handle"></a>TQCursor::handle () const
</h3>
Returns the window system cursor handle.
<p> <b>Warning:</b>
Portable in principle, but if you use it you are probably about to
do something non-portable. Be careful.

<h3 class=fn><a href="ntqpoint.html">TQPoint</a> <a name="hotSpot"></a>TQCursor::hotSpot () const
</h3>
Returns the cursor hot spot, or (0, 0) if it is one of the
standard cursors.

<h3 class=fn>void <a name="initialize"></a>TQCursor::initialize ()<tt> [static]</tt>
</h3>
Internal function that initializes the predefined cursors.
This function is called from the <a href="ntqapplication.html">TQApplication</a> constructor.
<p> <p>See also <a href="#cleanup">cleanup</a>().

<h3 class=fn>const&nbsp;<a href="ntqbitmap.html">TQBitmap</a>&nbsp;* <a name="mask"></a>TQCursor::mask () const
</h3>
Returns the cursor bitmap mask, or 0 if it is one of the standard
cursors.

<h3 class=fn><a href="ntqcursor.html">TQCursor</a>&nbsp;&amp; <a name="operator-eq"></a>TQCursor::operator= ( const&nbsp;<a href="ntqcursor.html">TQCursor</a>&nbsp;&amp;&nbsp;c )
</h3>
Assigns <em>c</em> to this cursor and returns a reference to this
cursor.

<h3 class=fn><a href="ntqpoint.html">TQPoint</a> <a name="pos"></a>TQCursor::pos ()<tt> [static]</tt>
</h3>
Returns the position of the cursor (hot spot) in global screen
coordinates.
<p> You can call <a href="ntqwidget.html#mapFromGlobal">TQWidget::mapFromGlobal</a>() to translate it to widget
coordinates.
<p> <p>See also <a href="#setPos">setPos</a>(), <a href="ntqwidget.html#mapFromGlobal">TQWidget::mapFromGlobal</a>(), and <a href="ntqwidget.html#mapToGlobal">TQWidget::mapToGlobal</a>().

<p>Examples: <a href="tutorial2-06.html#x2579">chart/canvasview.cpp</a>, <a href="fileiconview-example.html#x809">fileiconview/qfileiconview.cpp</a>, and <a href="menu-example.html#x1859">menu/menu.cpp</a>.
<h3 class=fn>void <a name="setPos"></a>TQCursor::setPos ( int&nbsp;x, int&nbsp;y )<tt> [static]</tt>
</h3>
Moves the cursor (hot spot) to the global screen position (<em>x</em>,
<em>y</em>).
<p> You can call <a href="ntqwidget.html#mapToGlobal">TQWidget::mapToGlobal</a>() to translate widget
coordinates to global screen coordinates.
<p> <p>See also <a href="#pos">pos</a>(), <a href="ntqwidget.html#mapFromGlobal">TQWidget::mapFromGlobal</a>(), and <a href="ntqwidget.html#mapToGlobal">TQWidget::mapToGlobal</a>().

<h3 class=fn>void <a name="setPos-2"></a>TQCursor::setPos ( const&nbsp;<a href="ntqpoint.html">TQPoint</a>&nbsp;&amp; )<tt> [static]</tt>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> 
<h3 class=fn>void <a name="setShape"></a>TQCursor::setShape ( int&nbsp;shape )
</h3>
Sets the cursor to the shape identified by <em>shape</em>.
<p> See <a href="ntqt.html#CursorShape-enum">CursorShape</a> for the list of cursor shapes.
<p> <p>See also <a href="#shape">shape</a>().

<h3 class=fn>int <a name="shape"></a>TQCursor::shape () const
</h3>
Returns the cursor shape identifier. The return value is one of
the <a href="ntqt.html#CursorShape-enum">CursorShape</a> enum values (cast to an int).
<p> <p>See also <a href="#setShape">setShape</a>().

<hr><h2>Related Functions</h2>
<h3 class=fn><a href="ntqdatastream.html">TQDataStream</a>&nbsp;&amp; <a name="operator-lt-lt"></a>operator&lt;&lt; ( <a href="ntqdatastream.html">TQDataStream</a>&nbsp;&amp;&nbsp;s, const&nbsp;<a href="ntqcursor.html">TQCursor</a>&nbsp;&amp;&nbsp;c )
</h3>

Writes the cursor <em>c</em> to the stream <em>s</em>.
<p> <p>See also <a href="datastreamformat.html">Format of the TQDataStream operators</a>.

<h3 class=fn><a href="ntqdatastream.html">TQDataStream</a>&nbsp;&amp; <a name="operator-gt-gt"></a>operator&gt;&gt; ( <a href="ntqdatastream.html">TQDataStream</a>&nbsp;&amp;&nbsp;s, <a href="ntqcursor.html">TQCursor</a>&nbsp;&amp;&nbsp;c )
</h3>

Reads a cursor from the stream <em>s</em> and sets <em>c</em> to the read data.
<p> <p>See also <a href="datastreamformat.html">Format of the TQDataStream operators</a>.

<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright &copy; 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 &copy; 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>