30 class _Internal_QCanvas;
31 class _Internal_QCheckBox;
32 class _Internal_QPushButton;
33 class _Internal_QWidget;
36 typedef std::function<void(GEvent)> GEventListener;
39 typedef std::function<void()> GEventListenerVoid;
46 ACTION_EVENT = 0x0010,
49 WINDOW_EVENT = 0x0080,
53 SERVER_EVENT = 0x0800,
54 CHANGE_EVENT = 0x1000,
55 HYPERLINK_EVENT = 0x2000,
56 SCROLL_EVENT = 0x4000,
57 ANY_EVENT = ACTION_EVENT | KEY_EVENT | TIMER_EVENT | WINDOW_EVENT
58 | MOUSE_EVENT | CLICK_EVENT | TABLE_EVENT | SERVER_EVENT
59 | CHANGE_EVENT | HYPERLINK_EVENT | SCROLL_EVENT
72 WINDOW_CLOSED = WINDOW_EVENT + 1,
73 WINDOW_RESIZED = WINDOW_EVENT + 2,
74 CONSOLE_CLOSED = WINDOW_EVENT + 3,
75 WINDOW_CLOSING = WINDOW_EVENT + 4,
76 WINDOW_MINIMIZED = WINDOW_EVENT + 5,
77 WINDOW_RESTORED = WINDOW_EVENT + 6,
78 WINDOW_MAXIMIZED = WINDOW_EVENT + 7,
80 ACTION_PERFORMED = ACTION_EVENT + 1,
81 ACTION_MENU = ACTION_EVENT + 2,
83 MOUSE_CLICKED = MOUSE_EVENT + 1,
84 MOUSE_PRESSED = MOUSE_EVENT + 2,
85 MOUSE_RELEASED = MOUSE_EVENT + 3,
86 MOUSE_MOVED = MOUSE_EVENT + 4,
87 MOUSE_DRAGGED = MOUSE_EVENT + 5,
88 MOUSE_ENTERED = MOUSE_EVENT + 6,
89 MOUSE_EXITED = MOUSE_EVENT + 7,
90 MOUSE_WHEEL_DOWN = MOUSE_EVENT + 8,
91 MOUSE_WHEEL_UP = MOUSE_EVENT + 9,
92 MOUSE_DOUBLE_CLICKED = MOUSE_EVENT + 10,
94 KEY_PRESSED = KEY_EVENT + 1,
95 KEY_RELEASED = KEY_EVENT + 2,
96 KEY_TYPED = KEY_EVENT + 3,
98 TIMER_TICKED = TIMER_EVENT + 1,
100 TABLE_UPDATED = TABLE_EVENT + 1,
101 TABLE_SELECTED = TABLE_EVENT + 2,
102 TABLE_EDIT_BEGIN = TABLE_EVENT + 3,
103 TABLE_REPLACE_BEGIN = TABLE_EVENT + 4,
104 TABLE_EDIT_CANCEL = TABLE_EVENT + 5,
105 TABLE_CUT = TABLE_EVENT + 6,
106 TABLE_COPY = TABLE_EVENT + 7,
107 TABLE_PASTE = TABLE_EVENT + 8,
109 SERVER_REQUEST = SERVER_EVENT + 1,
111 STATE_CHANGED = CHANGE_EVENT + 1,
113 HYPERLINK_CLICKED = HYPERLINK_EVENT + 1,
115 SCROLL_SCROLLED = SCROLL_EVENT + 1
129 ALT_GRAPH_DOWN = 1 << 4,
130 BUTTON1_DOWN = 1 << 5,
131 BUTTON2_DOWN = 1 << 6,
132 BUTTON3_DOWN = 1 << 7
217 GEvent(EventClass eventClass = NULL_EVENT,
218 EventType eventType = NULL_TYPE,
219 const string& eventName =
"",
232 static string classToString(EventClass eventClass);
251 virtual EventClass
getClass()
const;
265 static long getCurrentTimeMS();
319 virtual string
getName()
const;
331 virtual int getRow()
const;
348 virtual EventType
getType()
const;
355 virtual double getX()
const;
362 virtual double getY()
const;
438 virtual void setActionCommand(
const string& actionCommand);
443 virtual void setButton(
int button);
448 virtual void setInternalEvent(QEvent* event);
453 virtual void setKeyChar(
char keyChar);
458 virtual void setKeyChar(
const string& keyCharString);
463 virtual void setKeyCode(
int keyCode);
468 virtual void setModifiers(Qt::KeyboardModifiers modifiers);
473 virtual void setRequestURL(
const string& requestUrl);
478 virtual void setRowAndColumn(
int row,
int col);
488 virtual void setX(
double x);
493 virtual void setY(
double y);
510 enum EventListenerType {
518 struct EventListenerWrapper {
519 GEventListener handler;
520 GEventListenerVoid handlerVoid;
521 EventListenerType type;
523 void fireEvent(
const GEvent& event) {
524 if (type == HANDLER_EVENT) {
533 string _actionCommand;
548 QEvent* _internalQtEvent;
552 friend class _Internal_QWidget;
558 std::ostream& operator <<(std::ostream& out,
const GEvent& event);
588 GEvent getNextEvent(
int mask = ANY_EVENT) ;
644 GEvent waitForEvent(
int mask = ANY_EVENT) ;
virtual bool isCtrlOrCommandKeyDown() const
Returns true if the Ctrl key, or the Command key (Mac), was held down during this event...
Definition: gevent.cpp:218
virtual int getColumn() const
Returns the column that was interacted with, if this is a table event.
Definition: gevent.cpp:129
virtual GInteractor * getInteractor() const
Returns the source interactor that generated this event.
Definition: gevent.cpp:168
virtual long getTime() const
Returns this event's timestamp, as a number of milliseconds elapsed since the epoch of 1970/01/01 12:...
Definition: gevent.cpp:188
static string typeToString(EventType eventType)
Converts an event type such as MOUSE_EVENT to a string such as "MOUSE_EVENT".
Definition: gevent.cpp:74
virtual GPoint getLocation() const
Returns an (x, y) point representing the mouse position within the interactor when this event occurre...
Definition: gevent.cpp:176
A GEvent represents a user action that has occurred on a graphical interactor.
Definition: gevent.h:153
virtual double getX() const
Returns the x-coordinate of the mouse position within the interactor when this event occurred...
Definition: gevent.cpp:196
virtual int getModifiers() const
Returns the modifiers active during this event.
Definition: gevent.cpp:156
A GObservable object is one that is able to send out events.
Definition: gobservable.h:36
virtual void ignore()
Instructs the GUI system to ignore or cancel this event.
Definition: gevent.cpp:204
virtual int getButton() const
Returns which mouse button was clicked, if this is a mouse event.
Definition: gevent.cpp:121
virtual char getKeyChar() const
Returns the key character that was typed, if this is a key event.
Definition: gevent.cpp:148
virtual double getY() const
Returns the y-coordinate of the mouse position within the interactor when this event occurred...
Definition: gevent.cpp:200
virtual int getKeyCode() const
Returns the integer key code that was typed, if this is a key event.
Definition: gevent.cpp:152
This abstract class is the superclass for all graphical interactors.
Definition: ginteractor.h:48
virtual EventType getEventType() const
Returns the event's type (minor type such as MOUSE_PRESSED).
Definition: gevent.cpp:144
virtual bool isMiddleClick() const
Returns true if the user pressed the middle mouse button.
Definition: gevent.cpp:230
virtual EventClass getEventClass() const
Returns this event's class (major type such as MOUSE_EVENT).
Definition: gevent.cpp:140
GEvent(EventClass eventClass=NULL_EVENT, EventType eventType=NULL_TYPE, string eventName="", GObservable *source=nullptr)
Creates a new event of the given type.
Definition: gevent.cpp:30
KeyCode
Definition: gevent.h:171
virtual EventType getType() const
Returns the event's type (major type such as MOUSE_EVENT).
Definition: gevent.cpp:192
virtual bool isMetaKeyDown() const
Returns true if the Meta/Command key was held down during this event.
Definition: gevent.cpp:238
virtual int getRow() const
Returns the row that was interacted with, if this is a table event.
Definition: gevent.cpp:180
virtual string getName() const
Returns this event's name such as "click" or "keydown" or "actionperformed".
Definition: gevent.cpp:160
virtual string getActionCommand() const
Returns the action command associated with the event.
Definition: gevent.cpp:117
static GEventListener LOG_EVENT
An event listener that just prints the event that occurred.
Definition: gevent.h:164
virtual string toString() const
Returns a text representation of the event for debugging.
Definition: gevent.cpp:484
static string keyCodeToString(int keyCode)
Converts a key code such as 67 into a string such as "A".
Definition: gevent.cpp:246
virtual ~GEvent()
Frees memory allocated internally by the event.
Definition: gevent.cpp:52
static GEventListener EMPTY_EVENT_LISTENER
An empty event handler that can be passed that does nothing.
Definition: gevent.h:158
virtual string getRequestURL() const
Returns this event's request URL, if this is a server URL event.
Definition: gevent.cpp:164
virtual bool isLeftClick() const
Returns true if the user pressed the left mouse button.
Definition: gevent.cpp:226
virtual bool isRightClick() const
Returns true if the user pressed the right mouse button.
Definition: gevent.cpp:234
virtual QEvent * getInternalEvent() const
Returns the Qt event being wrapped by this event, if any.
Definition: gevent.cpp:172
virtual bool isDoubleClick() const
Returns true if the user pressed the mouse button multiple times.
Definition: gevent.cpp:222
virtual GObservable * getSource() const
Returns the source object that generated this event.
Definition: gevent.cpp:184
virtual EventClass getClass() const
Returns this event's class (major type such as MOUSE_EVENT).
Definition: gevent.cpp:125
This struct contains real-valued x and y fields.
Definition: gtypes.h:198
virtual bool isAltKeyDown() const
Returns true if the Alt key was held down during this event.
Definition: gevent.cpp:210
virtual bool isShiftKeyDown() const
Returns true if the Shift key was held down during this event.
Definition: gevent.cpp:242
virtual bool isCtrlKeyDown() const
Returns true if the Ctrl key was held down during this event.
Definition: gevent.cpp:214