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