Eneboo - Documentación para desarrolladores
src/qt/src/kernel/qevent.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qevent.h   3.3.8   edited Jan 11 14:38 $
00003 **
00004 ** Definition of event classes
00005 **
00006 ** Created : 931029
00007 **
00008 ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
00009 **
00010 ** This file is part of the kernel module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed under the terms of the Q Public License
00013 ** as defined by Trolltech ASA of Norway and appearing in the file
00014 ** LICENSE.QPL included in the packaging of this file.
00015 **
00016 ** This file may be distributed and/or modified under the terms of the
00017 ** GNU General Public License version 2 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.GPL included in the
00019 ** packaging of this file.
00020 **
00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00022 ** licenses may use this file in accordance with the Qt Commercial License
00023 ** Agreement provided with the Software.
00024 **
00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00027 **
00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00029 **   information about Qt Commercial License Agreements.
00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00032 **
00033 ** Contact info@trolltech.com if any conditions of this licensing are
00034 ** not clear to you.
00035 **
00036 **********************************************************************/
00037 
00038 #ifndef QEVENT_H
00039 #define QEVENT_H
00040 
00041 #ifndef QT_H
00042 #include "qwindowdefs.h"
00043 #include "qregion.h"
00044 #include "qnamespace.h"
00045 #include "qmime.h"
00046 #include "qpair.h"
00047 #endif // QT_H
00048 
00049 class Q_EXPORT QEvent: public Qt                // event base class
00050 {
00051 public:
00052     enum Type {
00053 
00054         /*
00055           If you get a strange compiler error on the line with None,
00056           it's probably because you're also including X11 headers,
00057           which #define the symbol None. Put the X11 includes after
00058           the Qt includes to solve this problem.
00059         */
00060 
00061         None = 0,                               // invalid event
00062 
00063 
00064         Timer = 1,                              // timer event
00065         MouseButtonPress = 2,                   // mouse button pressed
00066         MouseButtonRelease = 3,                 // mouse button released
00067         MouseButtonDblClick = 4,                // mouse button double click
00068         MouseMove = 5,                          // mouse move
00069         KeyPress = 6,                           // key pressed
00070         KeyRelease = 7,                         // key released
00071         FocusIn = 8,                            // keyboard focus received
00072         FocusOut = 9,                           // keyboard focus lost
00073         Enter = 10,                             // mouse enters widget
00074         Leave = 11,                             // mouse leaves widget
00075         Paint = 12,                             // paint widget
00076         Move = 13,                              // move widget
00077         Resize = 14,                            // resize widget
00078         Create = 15,                            // after object creation
00079         Destroy = 16,                           // during object destruction
00080         Show = 17,                              // widget is shown
00081         Hide = 18,                              // widget is hidden
00082         Close = 19,                             // request to close widget
00083         Quit = 20,                              // request to quit application
00084         Reparent = 21,                          // widget has been reparented
00085         ShowMinimized = 22,                     // widget is shown minimized
00086         ShowNormal = 23,                        // widget is shown normal
00087         WindowActivate = 24,                    // window was activated
00088         WindowDeactivate = 25,                  // window was deactivated
00089         ShowToParent = 26,                      // widget is shown to parent
00090         HideToParent = 27,                      // widget is hidden to parent
00091         ShowMaximized = 28,                     // widget is shown maximized
00092         ShowFullScreen = 29,                    // widget is shown full-screen
00093         Accel = 30,                             // accelerator event
00094         Wheel = 31,                             // wheel event
00095         AccelAvailable = 32,                    // accelerator available event
00096         CaptionChange = 33,                     // caption changed
00097         IconChange = 34,                        // icon changed
00098         ParentFontChange = 35,                  // parent font changed
00099         ApplicationFontChange = 36,             // application font changed
00100         ParentPaletteChange = 37,               // parent palette changed
00101         ApplicationPaletteChange = 38,          // application palette changed
00102         PaletteChange = 39,                     // widget palette changed
00103         Clipboard = 40,                         // internal clipboard event
00104         Speech = 42,                            // reserved for speech input
00105         SockAct = 50,                           // socket activation
00106         AccelOverride = 51,                     // accelerator override event
00107         DeferredDelete = 52,                    // deferred delete event
00108         DragEnter = 60,                         // drag moves into widget
00109         DragMove = 61,                          // drag moves in widget
00110         DragLeave = 62,                         // drag leaves or is cancelled
00111         Drop = 63,                              // actual drop
00112         DragResponse = 64,                      // drag accepted/rejected
00113         ChildInserted = 70,                     // new child widget
00114         ChildRemoved = 71,                      // deleted child widget
00115         LayoutHint = 72,                        // child min/max size changed
00116         ShowWindowRequest = 73,                 // widget's window should be mapped
00117         WindowBlocked = 74,                     // window is about to be blocked modally
00118         WindowUnblocked = 75,                   // windows modal blocking has ended
00119         ActivateControl = 80,                   // ActiveX activation
00120         DeactivateControl = 81,                 // ActiveX deactivation
00121         ContextMenu = 82,                       // context popup menu
00122         IMStart = 83,                           // input method composition start
00123         IMCompose = 84,                         // input method composition
00124         IMEnd = 85,                             // input method composition end
00125         Accessibility = 86,                     // accessibility information is requested
00126         TabletMove = 87,                        // Wacom tablet event
00127         LocaleChange = 88,                      // the system locale changed
00128         LanguageChange = 89,                    // the application language changed
00129         LayoutDirectionChange = 90,             // the layout direction changed
00130         Style = 91,                             // internal style event
00131         TabletPress = 92,                       // tablet press
00132         TabletRelease = 93,                     // tablet release
00133         OkRequest = 94,                         // CE (Ok) button pressed
00134         HelpRequest = 95,                       // CE (?)  button pressed
00135         WindowStateChange = 96,                 // window state has changed
00136         IconDrag = 97,                          // proxy icon dragged
00137         User = 1000,                            // first user event id
00138         MaxUser = 65535                         // last user event id
00139     };
00140 
00141 
00142     QEvent( Type type ) : t(type), posted(FALSE), spont(FALSE) {}
00143     virtual ~QEvent();
00144     Type  type() const  { return t; }
00145     bool spontaneous() const    { return spont; }
00146 protected:
00147     Type  t;
00148 private:
00149     uint posted : 1;
00150     uint spont : 1;
00151 
00152 
00153     friend class QApplication;
00154     friend class QAccelManager;
00155     friend class QBaseApplication;
00156     friend class QETWidget;
00157 };
00158 
00159 
00160 class Q_EXPORT QTimerEvent : public QEvent
00161 {
00162 public:
00163     QTimerEvent( int timerId )
00164         : QEvent(Timer), id(timerId) {}
00165     int   timerId()     const   { return id; }
00166 protected:
00167     int   id;
00168 };
00169 
00170 
00171 class Q_EXPORT QMouseEvent : public QEvent
00172 {
00173 public:
00174     QMouseEvent( Type type, const QPoint &pos, int button, int state );
00175 
00176     QMouseEvent( Type type, const QPoint &pos, const QPoint&globalPos,
00177                  int button, int state )
00178         : QEvent(type), p(pos), g(globalPos), b((ushort)button),s((ushort)state),accpt(TRUE) {};
00179 
00180     const QPoint &pos() const   { return p; }
00181     const QPoint &globalPos() const { return g; }
00182     int    x()          const   { return p.x(); }
00183     int    y()          const   { return p.y(); }
00184     int    globalX()    const   { return g.x(); }
00185     int    globalY()    const   { return g.y(); }
00186     ButtonState button() const  { return (ButtonState) b; }
00187     ButtonState state() const   { return (ButtonState) s; }
00188     ButtonState stateAfter() const;
00189     bool   isAccepted() const   { return accpt; }
00190     void   accept()             { accpt = TRUE; }
00191     void   ignore()             { accpt = FALSE; }
00192 protected:
00193     QPoint p;
00194     QPoint g;
00195     ushort b;
00196     ushort s;
00197     uint   accpt:1;
00198 };
00199 
00200 
00201 #ifndef QT_NO_WHEELEVENT
00202 class Q_EXPORT QWheelEvent : public QEvent
00203 {
00204 public:
00205     QWheelEvent( const QPoint &pos, int delta, int state, Orientation orient = Vertical );
00206     QWheelEvent( const QPoint &pos, const QPoint& globalPos, int delta, int state, Orientation orient = Vertical  )
00207         : QEvent(Wheel), p(pos), g(globalPos), d(delta), s((ushort)state),
00208           accpt(TRUE), o(orient) {}
00209     int    delta()      const   { return d; }
00210     const QPoint &pos() const   { return p; }
00211     const QPoint &globalPos() const     { return g; }
00212     int    x()          const   { return p.x(); }
00213     int    y()          const   { return p.y(); }
00214     int    globalX()    const   { return g.x(); }
00215     int    globalY()    const   { return g.y(); }
00216     ButtonState state() const   { return ButtonState(s); }
00217     Orientation orientation()   const   { return o; }
00218     bool   isAccepted() const   { return accpt; }
00219     void   accept()             { accpt = TRUE; }
00220     void   ignore()             { accpt = FALSE; }
00221 protected:
00222     QPoint p;
00223     QPoint g;
00224     int d;
00225     ushort s;
00226     bool   accpt;
00227     Orientation o;
00228 };
00229 #endif
00230 
00231 class Q_EXPORT QTabletEvent : public QEvent
00232 {
00233 public:
00234     enum TabletDevice { NoDevice = -1, Puck, Stylus, Eraser };
00235     QTabletEvent( Type t, const QPoint &pos, const QPoint &globalPos, int device,
00236                   int pressure, int xTilt, int yTilt, const QPair<int,int> &uId );
00237     QTabletEvent( const QPoint &pos, const QPoint &globalPos, int device,
00238                   int pressure, int xTilt, int yTilt, const QPair<int,int> &uId )
00239         : QEvent( TabletMove ), mPos( pos ), mGPos( globalPos ), mDev( device ),
00240           mPress( pressure ), mXT( xTilt ), mYT( yTilt ), mType( uId.first ),
00241           mPhy( uId.second ), mbAcc(TRUE)
00242     {}
00243     int pressure()      const { return mPress; }
00244     int xTilt()         const { return mXT; }
00245     int yTilt()         const { return mYT; }
00246     const QPoint &pos() const { return mPos; }
00247     const QPoint &globalPos() const { return mGPos; }
00248     int x()             const { return mPos.x(); }
00249     int y()             const { return mPos.y(); }
00250     int globalX()       const { return mGPos.x(); }
00251     int globalY()       const { return mGPos.y(); }
00252     TabletDevice device()       const { return TabletDevice(mDev); }
00253     int isAccepted() const { return mbAcc; }
00254     void accept() { mbAcc = TRUE; }
00255     void ignore() { mbAcc = FALSE; }
00256     QPair<int,int> uniqueId() { return QPair<int,int>( mType, mPhy); }
00257 protected:
00258     QPoint mPos;
00259     QPoint mGPos;
00260     int mDev,
00261         mPress,
00262         mXT,
00263         mYT,
00264         mType,
00265         mPhy;
00266     bool mbAcc;
00267 
00268 };
00269 
00270 class Q_EXPORT QKeyEvent : public QEvent
00271 {
00272 public:
00273     QKeyEvent( Type type, int key, int ascii, int state,
00274                 const QString& text=QString::null, bool autorep=FALSE, ushort count=1 )
00275         : QEvent(type), txt(text), k((ushort)key), s((ushort)state),
00276             a((uchar)ascii), accpt(TRUE), autor(autorep), c(count)
00277     {
00278         if ( key >= Key_Back && key <= Key_MediaLast )
00279             accpt = FALSE;
00280     }
00281     int    key()        const   { return k; }
00282     int    ascii()      const   { return a; }
00283     ButtonState state() const   { return ButtonState(s); }
00284     ButtonState stateAfter() const;
00285     bool   isAccepted() const   { return accpt; }
00286     QString text()      const   { return txt; }
00287     bool   isAutoRepeat() const { return autor; }
00288     int   count() const { return int(c); }
00289     void   accept()             { accpt = TRUE; }
00290     void   ignore()             { accpt = FALSE; }
00291 
00292 protected:
00293     QString txt;
00294     ushort k, s;
00295     uchar  a;
00296     uint   accpt:1;
00297     uint   autor:1;
00298     ushort c;
00299 };
00300 
00301 
00302 class Q_EXPORT QFocusEvent : public QEvent
00303 {
00304 public:
00305 
00306     QFocusEvent( Type type )
00307         : QEvent(type) {}
00308 
00309     bool   gotFocus()   const { return type() == FocusIn; }
00310     bool   lostFocus()  const { return type() == FocusOut; }
00311 
00312     enum Reason { Mouse, Tab, Backtab, ActiveWindow, Popup, Shortcut, Other };
00313     static Reason reason();
00314     static void setReason( Reason reason );
00315     static void resetReason();
00316 
00317 private:
00318     static Reason m_reason;
00319     static Reason prev_reason;
00320 };
00321 
00322 
00323 class Q_EXPORT QPaintEvent : public QEvent
00324 {
00325 public:
00326     QPaintEvent( const QRegion& paintRegion, bool erased = TRUE)
00327         : QEvent(Paint),
00328           rec(paintRegion.boundingRect()),
00329           reg(paintRegion),
00330           erase(erased){}
00331     QPaintEvent( const QRect &paintRect, bool erased = TRUE )
00332         : QEvent(Paint),
00333           rec(paintRect),
00334           reg(paintRect),
00335           erase(erased){}
00336     QPaintEvent( const QRegion &paintRegion, const QRect &paintRect, bool erased = TRUE )
00337         : QEvent(Paint),
00338           rec(paintRect),
00339           reg(paintRegion),
00340           erase(erased){}
00341 
00342     const QRect &rect() const     { return rec; }
00343     const QRegion &region() const { return reg; }
00344     bool erased() const { return erase; }
00345 protected:
00346     friend class QApplication;
00347     friend class QBaseApplication;
00348     QRect rec;
00349     QRegion reg;
00350     bool erase;
00351 };
00352 
00353 
00354 class Q_EXPORT QMoveEvent : public QEvent
00355 {
00356 public:
00357     QMoveEvent( const QPoint &pos, const QPoint &oldPos )
00358         : QEvent(Move), p(pos), oldp(oldPos) {}
00359     const QPoint &pos()   const { return p; }
00360     const QPoint &oldPos()const { return oldp;}
00361 protected:
00362     QPoint p, oldp;
00363     friend class QApplication;
00364     friend class QBaseApplication;
00365 };
00366 
00367 
00368 class Q_EXPORT QResizeEvent : public QEvent
00369 {
00370 public:
00371     QResizeEvent( const QSize &size, const QSize &oldSize )
00372         : QEvent(Resize), s(size), olds(oldSize) {}
00373     const QSize &size()   const { return s; }
00374     const QSize &oldSize()const { return olds;}
00375 protected:
00376     QSize s, olds;
00377     friend class QApplication;
00378     friend class QBaseApplication;
00379 };
00380 
00381 
00382 class Q_EXPORT QCloseEvent : public QEvent
00383 {
00384 public:
00385     QCloseEvent()
00386         : QEvent(Close), accpt(FALSE) {}
00387     bool   isAccepted() const   { return accpt; }
00388     void   accept()             { accpt = TRUE; }
00389     void   ignore()             { accpt = FALSE; }
00390 protected:
00391     bool   accpt;
00392 };
00393 
00394 
00395 class Q_EXPORT QIconDragEvent : public QEvent
00396 {
00397 public:
00398     QIconDragEvent() 
00399         : QEvent(IconDrag), accpt(FALSE) {}
00400 
00401     bool   isAccepted() const   { return accpt; }
00402     void   accept()             { accpt = TRUE; }
00403     void   ignore()             { accpt = FALSE; }
00404 protected:
00405     bool   accpt;
00406 };
00407 
00408 class Q_EXPORT QShowEvent : public QEvent
00409 {
00410 public:
00411     QShowEvent()
00412         : QEvent(Show) {}
00413 };
00414 
00415 
00416 class Q_EXPORT QHideEvent : public QEvent
00417 {
00418 public:
00419     QHideEvent()
00420         : QEvent(Hide) {}
00421 };
00422 
00423 class Q_EXPORT QContextMenuEvent : public QEvent
00424 {
00425 public:
00426     enum Reason { Mouse, Keyboard, Other };
00427     QContextMenuEvent( Reason reason, const QPoint &pos, const QPoint &globalPos, int state )
00428         : QEvent( ContextMenu ), p( pos ), gp( globalPos ), accpt( TRUE ), consum( TRUE ),
00429         reas( reason ), s((ushort)state) {}
00430     QContextMenuEvent( Reason reason, const QPoint &pos, int state );
00431 
00432     int     x() const { return p.x(); }
00433     int     y() const { return p.y(); }
00434     int     globalX() const { return gp.x(); }
00435     int     globalY() const { return gp.y(); }
00436 
00437     const QPoint&   pos() const { return p; }
00438     const QPoint&   globalPos() const { return gp; }
00439 
00440     ButtonState state() const   { return (ButtonState) s; }
00441     bool    isAccepted() const  { return accpt; }
00442     bool    isConsumed() const  { return consum; }
00443     void    consume()           { accpt = FALSE; consum = TRUE; }
00444     void    accept()            { accpt = TRUE; consum = TRUE; }
00445     void    ignore()            { accpt = FALSE; consum = FALSE; }
00446 
00447     Reason  reason() const { return Reason( reas ); }
00448 
00449 protected:
00450     QPoint  p;
00451     QPoint  gp;
00452     bool    accpt;
00453     bool    consum;
00454     uint    reas:8;
00455     ushort s;
00456 };
00457 
00458 
00459 class Q_EXPORT QIMEvent : public QEvent
00460 {
00461 public:
00462     QIMEvent( Type type, const QString &text, int cursorPosition )
00463         : QEvent(type), txt(text), cpos(cursorPosition), a(TRUE) {}
00464     const QString &text() const { return txt; }
00465     int cursorPos() const { return cpos; }
00466     bool isAccepted() const { return a; }
00467     void accept() { a = TRUE; }
00468     void ignore() { a = FALSE; }
00469     int selectionLength() const;
00470 
00471 private:
00472     QString txt;
00473     int cpos;
00474     bool a;
00475 };
00476 
00477 class Q_EXPORT QIMComposeEvent : public QIMEvent
00478 {
00479 public:
00480     QIMComposeEvent( Type type, const QString &text, int cursorPosition,
00481                      int selLength )
00482         : QIMEvent( type, text, cursorPosition ), selLen( selLength ) { }
00483 
00484 private:
00485     int selLen;
00486 
00487     friend class QIMEvent;
00488 };
00489 
00490 inline int QIMEvent::selectionLength() const
00491 {
00492     if ( type() != IMCompose ) return 0;
00493     QIMComposeEvent *that = (QIMComposeEvent *) this;
00494     return that->selLen;
00495 }
00496 
00497 
00498 #ifndef QT_NO_DRAGANDDROP
00499 
00500 // This class is rather closed at the moment.  If you need to create your
00501 // own DND event objects, write to qt-bugs@trolltech.com and we'll try to
00502 // find a way to extend it so it covers your needs.
00503 
00504 class Q_EXPORT QDropEvent : public QEvent, public QMimeSource
00505 {
00506 public:
00507     QDropEvent( const QPoint& pos, Type typ=Drop )
00508         : QEvent(typ), p(pos),
00509           act(0), accpt(0), accptact(0), resv(0),
00510           d(0)
00511         {}
00512     const QPoint &pos() const   { return p; }
00513     bool isAccepted() const     { return accpt || accptact; }
00514     void accept(bool y=TRUE)    { accpt = y; }
00515     void ignore()               { accpt = FALSE; }
00516 
00517     bool isActionAccepted() const { return accptact; }
00518     void acceptAction(bool y=TRUE) { accptact = y; }
00519     enum Action { Copy, Link, Move, Private, UserAction=100 };
00520     void setAction( Action a ) { act = (uint)a; }
00521     Action action() const { return Action(act); }
00522 
00523     QWidget* source() const;
00524     const char* format( int n = 0 ) const;
00525     QByteArray encodedData( const char* ) const;
00526     bool provides( const char* ) const;
00527 
00528     QByteArray data(const char* f) const { return encodedData(f); }
00529 
00530     void setPoint( const QPoint& np ) { p = np; }
00531 
00532 protected:
00533     QPoint p;
00534     uint act:8;
00535     uint accpt:1;
00536     uint accptact:1;
00537     uint resv:5;
00538     void * d;
00539 };
00540 
00541 
00542 
00543 class Q_EXPORT QDragMoveEvent : public QDropEvent
00544 {
00545 public:
00546     QDragMoveEvent( const QPoint& pos, Type typ=DragMove )
00547         : QDropEvent(pos,typ),
00548           rect( pos, QSize( 1, 1 ) ) {}
00549     QRect answerRect() const { return rect; }
00550     void accept( bool y=TRUE ) { QDropEvent::accept(y); }
00551     void accept( const QRect & r) { accpt = TRUE; rect = r; }
00552     void ignore( const QRect & r) { accpt =FALSE; rect = r; }
00553     void ignore()               { QDropEvent::ignore(); }
00554 
00555 protected:
00556     QRect rect;
00557 };
00558 
00559 
00560 class Q_EXPORT QDragEnterEvent : public QDragMoveEvent
00561 {
00562 public:
00563     QDragEnterEvent( const QPoint& pos ) :
00564         QDragMoveEvent(pos, DragEnter) { }
00565 };
00566 
00567 
00568 /* An internal class */
00569 class Q_EXPORT QDragResponseEvent : public QEvent
00570 {
00571 public:
00572     QDragResponseEvent( bool accepted )
00573         : QEvent(DragResponse), a(accepted) {}
00574     bool   dragAccepted() const { return a; }
00575 protected:
00576     bool a;
00577 };
00578 
00579 
00580 class Q_EXPORT QDragLeaveEvent : public QEvent
00581 {
00582 public:
00583     QDragLeaveEvent()
00584         : QEvent(DragLeave) {}
00585 };
00586 
00587 #endif // QT_NO_DRAGANDDROP
00588 
00589 class Q_EXPORT QChildEvent : public QEvent
00590 {
00591 public:
00592     QChildEvent( Type type, QObject *child )
00593         : QEvent(type), c(child) {}
00594     QObject *child() const      { return c; }
00595     bool inserted() const { return t == ChildInserted; }
00596     bool removed() const { return t == ChildRemoved; }
00597 protected:
00598     QObject *c;
00599 };
00600 
00601 
00602 class Q_EXPORT QCustomEvent : public QEvent
00603 {
00604 public:
00605     QCustomEvent( int type );
00606     QCustomEvent( Type type, void *data )
00607         : QEvent(type), d(data) {};
00608     void       *data()  const   { return d; }
00609     void        setData( void* data )   { d = data; }
00610 private:
00611     void       *d;
00612 };
00613 
00614 #endif // QEVENT_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'