source: trunk/doc/html/qevent-h.html@ 190

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

reference documentation added

File size: 20.2 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/include/qevent.h:1 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>qevent.h Include File</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>qevent.h</h1>
33
34<p>This is the verbatim text of the qevent.h include file. It is provided only for illustration; the copyright remains with Trolltech.
35<hr>
36<pre>
37/****************************************************************************
38** $Id: qevent-h.html 2051 2007-02-21 10:04:20Z chehrlic $
39**
40** Definition of event classes
41**
42** Created : 931029
43**
44** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
45**
46** This file is part of the kernel module of the Qt GUI Toolkit.
47**
48** This file may be distributed under the terms of the Q Public License
49** as defined by Trolltech ASA of Norway and appearing in the file
50** LICENSE.QPL included in the packaging of this file.
51**
52** This file may be distributed and/or modified under the terms of the
53** GNU General Public License version 2 as published by the Free Software
54** Foundation and appearing in the file LICENSE.GPL included in the
55** packaging of this file.
56**
57** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
58** licenses may use this file in accordance with the Qt Commercial License
59** Agreement provided with the Software.
60**
61** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
62** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
63**
64** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
65** information about Qt Commercial License Agreements.
66** See http://www.trolltech.com/qpl/ for QPL licensing information.
67** See http://www.trolltech.com/gpl/ for GPL licensing information.
68**
69** Contact info@trolltech.com if any conditions of this licensing are
70** not clear to you.
71**
72**********************************************************************/
73
74#ifndef QEVENT_H
75#define QEVENT_H
76
77#ifndef QT_H
78#include "qwindowdefs.h"
79#include "qregion.h"
80#include "qnamespace.h"
81#include "qmime.h"
82#include "qpair.h"
83#endif // QT_H
84
85class Q_EXPORT QEvent: public Qt // event base class
86{
87public:
88 enum Type {
89
90 /*
91 If you get a strange compiler error on the line with None,
92 it's probably because you're also including X11 headers,
93 which #define the symbol None. Put the X11 includes after
94 the Qt includes to solve this problem.
95 */
96
97 None = 0, // invalid event
98
99
100 Timer = 1, // timer event
101 MouseButtonPress = 2, // mouse button pressed
102 MouseButtonRelease = 3, // mouse button released
103 MouseButtonDblClick = 4, // mouse button double click
104 MouseMove = 5, // mouse move
105 KeyPress = 6, // key pressed
106 KeyRelease = 7, // key released
107 FocusIn = 8, // keyboard focus received
108 FocusOut = 9, // keyboard focus lost
109 Enter = 10, // mouse enters widget
110 Leave = 11, // mouse leaves widget
111 Paint = 12, // paint widget
112 Move = 13, // move widget
113 Resize = 14, // resize widget
114 Create = 15, // after object creation
115 Destroy = 16, // during object destruction
116 Show = 17, // widget is shown
117 Hide = 18, // widget is hidden
118 Close = 19, // request to close widget
119 Quit = 20, // request to quit application
120 Reparent = 21, // widget has been reparented
121 ShowMinimized = 22, // widget is shown minimized
122 ShowNormal = 23, // widget is shown normal
123 WindowActivate = 24, // window was activated
124 WindowDeactivate = 25, // window was deactivated
125 ShowToParent = 26, // widget is shown to parent
126 HideToParent = 27, // widget is hidden to parent
127 ShowMaximized = 28, // widget is shown maximized
128 ShowFullScreen = 29, // widget is shown full-screen
129 Accel = 30, // accelerator event
130 Wheel = 31, // wheel event
131 AccelAvailable = 32, // accelerator available event
132 CaptionChange = 33, // caption changed
133 IconChange = 34, // icon changed
134 ParentFontChange = 35, // parent font changed
135 ApplicationFontChange = 36, // application font changed
136 ParentPaletteChange = 37, // parent palette changed
137 ApplicationPaletteChange = 38, // application palette changed
138 PaletteChange = 39, // widget palette changed
139 Clipboard = 40, // internal clipboard event
140 Speech = 42, // reserved for speech input
141 SockAct = 50, // socket activation
142 AccelOverride = 51, // accelerator override event
143 DeferredDelete = 52, // deferred delete event
144 DragEnter = 60, // drag moves into widget
145 DragMove = 61, // drag moves in widget
146 DragLeave = 62, // drag leaves or is cancelled
147 Drop = 63, // actual drop
148 DragResponse = 64, // drag accepted/rejected
149 ChildInserted = 70, // new child widget
150 ChildRemoved = 71, // deleted child widget
151 LayoutHint = 72, // child min/max size changed
152 ShowWindowRequest = 73, // widget's window should be mapped
153 WindowBlocked = 74, // window is about to be blocked modally
154 WindowUnblocked = 75, // windows modal blocking has ended
155 ActivateControl = 80, // ActiveX activation
156 DeactivateControl = 81, // ActiveX deactivation
157 ContextMenu = 82, // context popup menu
158 IMStart = 83, // input method composition start
159 IMCompose = 84, // input method composition
160 IMEnd = 85, // input method composition end
161 Accessibility = 86, // accessibility information is requested
162 TabletMove = 87, // Wacom tablet event
163 LocaleChange = 88, // the system locale changed
164 LanguageChange = 89, // the application language changed
165 LayoutDirectionChange = 90, // the layout direction changed
166 Style = 91, // internal style event
167 TabletPress = 92, // tablet press
168 TabletRelease = 93, // tablet release
169 OkRequest = 94, // CE (Ok) button pressed
170 HelpRequest = 95, // CE (?) button pressed
171 WindowStateChange = 96, // window state has changed
172 IconDrag = 97, // proxy icon dragged
173 User = 1000, // first user event id
174 MaxUser = 65535 // last user event id
175 };
176
177
178 QEvent( Type type ) : t(type), posted(FALSE), spont(FALSE) {}
179 virtual ~QEvent();
180 Type type() const { return t; }
181 bool spontaneous() const { return spont; }
182protected:
183 Type t;
184private:
185 uint posted : 1;
186 uint spont : 1;
187
188
189 friend class QApplication;
190 friend class QAccelManager;
191 friend class QBaseApplication;
192 friend class QETWidget;
193};
194
195
196class Q_EXPORT QTimerEvent : public QEvent
197{
198public:
199 QTimerEvent( int timerId )
200 : QEvent(Timer), id(timerId) {}
201 int timerId() const { return id; }
202protected:
203 int id;
204};
205
206
207class Q_EXPORT QMouseEvent : public QEvent
208{
209public:
210 QMouseEvent( Type type, const QPoint &amp;pos, int button, int state );
211
212 QMouseEvent( Type type, const QPoint &amp;pos, const QPoint&amp;globalPos,
213 int button, int state )
214 : QEvent(type), p(pos), g(globalPos), b((ushort)button),s((ushort)state),accpt(TRUE) {};
215
216 const QPoint &amp;pos() const { return p; }
217 const QPoint &amp;globalPos() const { return g; }
218 int x() const { return p.x(); }
219 int y() const { return p.y(); }
220 int globalX() const { return g.x(); }
221 int globalY() const { return g.y(); }
222 ButtonState button() const { return (ButtonState) b; }
223 ButtonState state() const { return (ButtonState) s; }
224 ButtonState stateAfter() const;
225 bool isAccepted() const { return accpt; }
226 void accept() { accpt = TRUE; }
227 void ignore() { accpt = FALSE; }
228protected:
229 QPoint p;
230 QPoint g;
231 ushort b;
232 ushort s;
233 uint accpt:1;
234};
235
236
237#ifndef QT_NO_WHEELEVENT
238class Q_EXPORT QWheelEvent : public QEvent
239{
240public:
241 QWheelEvent( const QPoint &amp;pos, int delta, int state, Orientation orient = Vertical );
242 QWheelEvent( const QPoint &amp;pos, const QPoint&amp; globalPos, int delta, int state, Orientation orient = Vertical )
243 : QEvent(Wheel), p(pos), g(globalPos), d(delta), s((ushort)state),
244 accpt(TRUE), o(orient) {}
245 int delta() const { return d; }
246 const QPoint &amp;pos() const { return p; }
247 const QPoint &amp;globalPos() const { return g; }
248 int x() const { return p.x(); }
249 int y() const { return p.y(); }
250 int globalX() const { return g.x(); }
251 int globalY() const { return g.y(); }
252 ButtonState state() const { return ButtonState(s); }
253 Orientation orientation() const { return o; }
254 bool isAccepted() const { return accpt; }
255 void accept() { accpt = TRUE; }
256 void ignore() { accpt = FALSE; }
257protected:
258 QPoint p;
259 QPoint g;
260 int d;
261 ushort s;
262 bool accpt;
263 Orientation o;
264};
265#endif
266
267class Q_EXPORT QTabletEvent : public QEvent
268{
269public:
270 enum TabletDevice { NoDevice = -1, Puck, Stylus, Eraser };
271 QTabletEvent( Type t, const QPoint &amp;pos, const QPoint &amp;globalPos, int device,
272 int pressure, int xTilt, int yTilt, const QPair&lt;int,int&gt; &amp;uId );
273 QTabletEvent( const QPoint &amp;pos, const QPoint &amp;globalPos, int device,
274 int pressure, int xTilt, int yTilt, const QPair&lt;int,int&gt; &amp;uId )
275 : QEvent( TabletMove ), mPos( pos ), mGPos( globalPos ), mDev( device ),
276 mPress( pressure ), mXT( xTilt ), mYT( yTilt ), mType( uId.first ),
277 mPhy( uId.second ), mbAcc(TRUE)
278 {}
279 int pressure() const { return mPress; }
280 int xTilt() const { return mXT; }
281 int yTilt() const { return mYT; }
282 const QPoint &amp;pos() const { return mPos; }
283 const QPoint &amp;globalPos() const { return mGPos; }
284 int x() const { return mPos.x(); }
285 int y() const { return mPos.y(); }
286 int globalX() const { return mGPos.x(); }
287 int globalY() const { return mGPos.y(); }
288 TabletDevice device() const { return TabletDevice(mDev); }
289 int isAccepted() const { return mbAcc; }
290 void accept() { mbAcc = TRUE; }
291 void ignore() { mbAcc = FALSE; }
292 QPair&lt;int,int&gt; uniqueId() { return QPair&lt;int,int&gt;( mType, mPhy); }
293protected:
294 QPoint mPos;
295 QPoint mGPos;
296 int mDev,
297 mPress,
298 mXT,
299 mYT,
300 mType,
301 mPhy;
302 bool mbAcc;
303
304};
305
306class Q_EXPORT QKeyEvent : public QEvent
307{
308public:
309 QKeyEvent( Type type, int key, int ascii, int state,
310 const QString&amp; text=QString::null, bool autorep=FALSE, ushort count=1 )
311 : QEvent(type), txt(text), k((ushort)key), s((ushort)state),
312 a((uchar)ascii), accpt(TRUE), autor(autorep), c(count)
313 {
314 if ( key &gt;= Key_Back &amp;&amp; key &lt;= Key_MediaLast )
315 accpt = FALSE;
316 }
317 int key() const { return k; }
318 int ascii() const { return a; }
319 ButtonState state() const { return ButtonState(s); }
320 ButtonState stateAfter() const;
321 bool isAccepted() const { return accpt; }
322 QString text() const { return txt; }
323 bool isAutoRepeat() const { return autor; }
324 int count() const { return int(c); }
325 void accept() { accpt = TRUE; }
326 void ignore() { accpt = FALSE; }
327
328protected:
329 QString txt;
330 ushort k, s;
331 uchar a;
332 uint accpt:1;
333 uint autor:1;
334 ushort c;
335};
336
337
338class Q_EXPORT QFocusEvent : public QEvent
339{
340public:
341
342 QFocusEvent( Type type )
343 : QEvent(type) {}
344
345 bool gotFocus() const { return type() == FocusIn; }
346 bool lostFocus() const { return type() == FocusOut; }
347
348 enum Reason { Mouse, Tab, Backtab, ActiveWindow, Popup, Shortcut, Other };
349 static Reason reason();
350 static void setReason( Reason reason );
351 static void resetReason();
352
353private:
354 static Reason m_reason;
355 static Reason prev_reason;
356};
357
358
359class Q_EXPORT QPaintEvent : public QEvent
360{
361public:
362 QPaintEvent( const QRegion&amp; paintRegion, bool erased = TRUE)
363 : QEvent(Paint),
364 rec(paintRegion.boundingRect()),
365 reg(paintRegion),
366 erase(erased){}
367 QPaintEvent( const QRect &amp;paintRect, bool erased = TRUE )
368 : QEvent(Paint),
369 rec(paintRect),
370 reg(paintRect),
371 erase(erased){}
372 QPaintEvent( const QRegion &amp;paintRegion, const QRect &amp;paintRect, bool erased = TRUE )
373 : QEvent(Paint),
374 rec(paintRect),
375 reg(paintRegion),
376 erase(erased){}
377
378 const QRect &amp;rect() const { return rec; }
379 const QRegion &amp;region() const { return reg; }
380 bool erased() const { return erase; }
381protected:
382 friend class QApplication;
383 friend class QBaseApplication;
384 QRect rec;
385 QRegion reg;
386 bool erase;
387};
388
389
390class Q_EXPORT QMoveEvent : public QEvent
391{
392public:
393 QMoveEvent( const QPoint &amp;pos, const QPoint &amp;oldPos )
394 : QEvent(Move), p(pos), oldp(oldPos) {}
395 const QPoint &amp;pos() const { return p; }
396 const QPoint &amp;oldPos()const { return oldp;}
397protected:
398 QPoint p, oldp;
399 friend class QApplication;
400 friend class QBaseApplication;
401};
402
403
404class Q_EXPORT QResizeEvent : public QEvent
405{
406public:
407 QResizeEvent( const QSize &amp;size, const QSize &amp;oldSize )
408 : QEvent(Resize), s(size), olds(oldSize) {}
409 const QSize &amp;size() const { return s; }
410 const QSize &amp;oldSize()const { return olds;}
411protected:
412 QSize s, olds;
413 friend class QApplication;
414 friend class QBaseApplication;
415};
416
417
418class Q_EXPORT QCloseEvent : public QEvent
419{
420public:
421 QCloseEvent()
422 : QEvent(Close), accpt(FALSE) {}
423 bool isAccepted() const { return accpt; }
424 void accept() { accpt = TRUE; }
425 void ignore() { accpt = FALSE; }
426protected:
427 bool accpt;
428};
429
430
431class Q_EXPORT QIconDragEvent : public QEvent
432{
433public:
434 QIconDragEvent()
435 : QEvent(IconDrag), accpt(FALSE) {}
436
437 bool isAccepted() const { return accpt; }
438 void accept() { accpt = TRUE; }
439 void ignore() { accpt = FALSE; }
440protected:
441 bool accpt;
442};
443
444class Q_EXPORT QShowEvent : public QEvent
445{
446public:
447 QShowEvent()
448 : QEvent(Show) {}
449};
450
451
452class Q_EXPORT QHideEvent : public QEvent
453{
454public:
455 QHideEvent()
456 : QEvent(Hide) {}
457};
458
459class Q_EXPORT QContextMenuEvent : public QEvent
460{
461public:
462 enum Reason { Mouse, Keyboard, Other };
463 QContextMenuEvent( Reason reason, const QPoint &amp;pos, const QPoint &amp;globalPos, int state )
464 : QEvent( ContextMenu ), p( pos ), gp( globalPos ), accpt( TRUE ), consum( TRUE ),
465 reas( reason ), s((ushort)state) {}
466 QContextMenuEvent( Reason reason, const QPoint &amp;pos, int state );
467
468 int x() const { return p.x(); }
469 int y() const { return p.y(); }
470 int globalX() const { return gp.x(); }
471 int globalY() const { return gp.y(); }
472
473 const QPoint&amp; pos() const { return p; }
474 const QPoint&amp; globalPos() const { return gp; }
475
476 ButtonState state() const { return (ButtonState) s; }
477 bool isAccepted() const { return accpt; }
478 bool isConsumed() const { return consum; }
479 void consume() { accpt = FALSE; consum = TRUE; }
480 void accept() { accpt = TRUE; consum = TRUE; }
481 void ignore() { accpt = FALSE; consum = FALSE; }
482
483 Reason reason() const { return Reason( reas ); }
484
485protected:
486 QPoint p;
487 QPoint gp;
488 bool accpt;
489 bool consum;
490 uint reas:8;
491 ushort s;
492};
493
494
495class Q_EXPORT QIMEvent : public QEvent
496{
497public:
498 QIMEvent( Type type, const QString &amp;text, int cursorPosition )
499 : QEvent(type), txt(text), cpos(cursorPosition), a(TRUE) {}
500 const QString &amp;text() const { return txt; }
501 int cursorPos() const { return cpos; }
502 bool isAccepted() const { return a; }
503 void accept() { a = TRUE; }
504 void ignore() { a = FALSE; }
505 int selectionLength() const;
506
507private:
508 QString txt;
509 int cpos;
510 bool a;
511};
512
513class Q_EXPORT QIMComposeEvent : public QIMEvent
514{
515public:
516 QIMComposeEvent( Type type, const QString &amp;text, int cursorPosition,
517 int selLength )
518 : QIMEvent( type, text, cursorPosition ), selLen( selLength ) { }
519
520private:
521 int selLen;
522
523 friend class QIMEvent;
524};
525
526inline int QIMEvent::selectionLength() const
527{
528 if ( type() != IMCompose ) return 0;
529 QIMComposeEvent *that = (QIMComposeEvent *) this;
530 return that-&gt;selLen;
531}
532
533
534#ifndef QT_NO_DRAGANDDROP
535
536// This class is rather closed at the moment. If you need to create your
537// own DND event objects, write to qt-bugs@trolltech.com and we'll try to
538// find a way to extend it so it covers your needs.
539
540class Q_EXPORT QDropEvent : public QEvent, public QMimeSource
541{
542public:
543 QDropEvent( const QPoint&amp; pos, Type typ=Drop )
544 : QEvent(typ), p(pos),
545 act(0), accpt(0), accptact(0), resv(0),
546 d(0)
547 {}
548 const QPoint &amp;pos() const { return p; }
549 bool isAccepted() const { return accpt || accptact; }
550 void accept(bool y=TRUE) { accpt = y; }
551 void ignore() { accpt = FALSE; }
552
553 bool isActionAccepted() const { return accptact; }
554 void acceptAction(bool y=TRUE) { accptact = y; }
555 enum Action { Copy, Link, Move, Private, UserAction=100 };
556 void setAction( Action a ) { act = (uint)a; }
557 Action action() const { return Action(act); }
558
559 QWidget* source() const;
560 const char* format( int n = 0 ) const;
561 QByteArray encodedData( const char* ) const;
562 bool provides( const char* ) const;
563
564 QByteArray data(const char* f) const { return encodedData(f); }
565
566 void setPoint( const QPoint&amp; np ) { p = np; }
567
568protected:
569 QPoint p;
570 uint act:8;
571 uint accpt:1;
572 uint accptact:1;
573 uint resv:5;
574 void * d;
575};
576
577
578
579class Q_EXPORT QDragMoveEvent : public QDropEvent
580{
581public:
582 QDragMoveEvent( const QPoint&amp; pos, Type typ=DragMove )
583 : QDropEvent(pos,typ),
584 rect( pos, QSize( 1, 1 ) ) {}
585 QRect answerRect() const { return rect; }
586 void accept( bool y=TRUE ) { QDropEvent::accept(y); }
587 void accept( const QRect &amp; r) { accpt = TRUE; rect = r; }
588 void ignore( const QRect &amp; r) { accpt =FALSE; rect = r; }
589 void ignore() { QDropEvent::ignore(); }
590
591protected:
592 QRect rect;
593};
594
595
596class Q_EXPORT QDragEnterEvent : public QDragMoveEvent
597{
598public:
599 QDragEnterEvent( const QPoint&amp; pos ) :
600 QDragMoveEvent(pos, DragEnter) { }
601};
602
603
604/* An internal class */
605class Q_EXPORT QDragResponseEvent : public QEvent
606{
607public:
608 QDragResponseEvent( bool accepted )
609 : QEvent(DragResponse), a(accepted) {}
610 bool dragAccepted() const { return a; }
611protected:
612 bool a;
613};
614
615
616class Q_EXPORT QDragLeaveEvent : public QEvent
617{
618public:
619 QDragLeaveEvent()
620 : QEvent(DragLeave) {}
621};
622
623#endif // QT_NO_DRAGANDDROP
624
625class Q_EXPORT QChildEvent : public QEvent
626{
627public:
628 QChildEvent( Type type, QObject *child )
629 : QEvent(type), c(child) {}
630 QObject *child() const { return c; }
631 bool inserted() const { return t == ChildInserted; }
632 bool removed() const { return t == ChildRemoved; }
633protected:
634 QObject *c;
635};
636
637
638class Q_EXPORT QCustomEvent : public QEvent
639{
640public:
641 QCustomEvent( int type );
642 QCustomEvent( Type type, void *data )
643 : QEvent(type), d(data) {};
644 void *data() const { return d; }
645 void setData( void* data ) { d = data; }
646private:
647 void *d;
648};
649
650#endif // QEVENT_H
651</pre>
652<!-- eof -->
653<p><address><hr><div align=center>
654<table width=100% cellspacing=0 border=0><tr>
655<td>Copyright &copy; 2007
656<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
657<td align=right><div align=right>Qt 3.3.8</div>
658</table></div></address></body>
659</html>
Note: See TracBrowser for help on using the repository browser.