HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UI_Event.h
Go to the documentation of this file.
1 #ifndef __UI_Event__
2 #define __UI_Event__
3 
4 #include "UI_API.h"
5 #include <string.h>
6 #ifdef DEBUG_TRIGGER
7 #include "UI_Global.h" // Need debug macros for inline function...
8 #endif
9 #include "UI_DeviceEvent.h"
10 #include "UI_EventType.h"
11 #include "UI_Object.h"
12 #include "UI_Value.h"
13 #include <iosfwd>
14 
15 template<typename T> class UT_Array;
16 
18 public:
19  UI_Event();
20  ~UI_Event();
21 
22  UI_Event(const UI_Event &e);
23 
24  UI_Event &operator=(const UI_Event &e);
25 
26  UI_Event(
28  UI_Object *to,
29  UI_Object *from = (UI_Object *)0,
31  );
32 
33  UI_Event(
34  UI_Value *v,
35  UI_Object *to,
36  UI_Object *from = (UI_Object *)0,
38  );
39 
40  UI_Event(
41  UI_Value *v,
42  UI_Object *to,
43  UI_EventMethod callback,
44  UI_Object *from = (UI_Object *)0,
46  );
47 
48  UI_Event(
49  UI_EventType t,
50  UI_Object *to,
51  UI_EventMethod callback,
52  UI_Object *from = (UI_Object *)0
53  );
54 
60 
62 
64 
65  // history of collapsed events, 0 if no events were collapsed.
66  // Because of how we merge, this is a STACK.
67  // Ie, event->state is the most recent event and
68  // (*event->myStateHistory)[0] is the oldest, with
69  // *event->myStateHistory->last() the event just before event->state.
70  // This lets the usual process of merging events to just
71  // append to the list rather than prepend.
73 
74  void trigger()
75  {
76 #ifdef DEBUG_TRIGGER
77  UI_DEBUG(DBG_EVENTS,
78  UI_debug("Trigger %s, source: %s, target: %s\n",
79  name(),
80  source ? source->className() : "NULL",
81  target ? target->className() : "NULL"));
82 #endif
83  if( target )
84  (target->*method)(this);
85  }
86 
87  const char *name() const;
88  const char *className() const { return "UI_Event"; }
89  void display() const;
90  static const char *type_name(UI_EventType type);
91  static const char *reason_name(UI_Reason reason);
92 
93  // Contents of prevevent are somehow merged into this.
94  // Used to consolidate mouse moves into the UI_DeviceEvent history.
95  void mergeEvent(const UI_Event *prevevent);
96 
97  void display(std::ostream &os) const;
98 };
99 
100 UI_API size_t format(char *buffer, size_t buffer_size, const UI_EventType &v);
101 UI_API size_t format(char *buffer, size_t buffer_size, const UI_Event &v);
102 
103 
104 #endif
GLuint const GLchar * name
Definition: glew.h:1814
GLenum target
Definition: glew.h:2865
UI_API size_t format(char *buffer, size_t buffer_size, const UI_EventType &v)
GLsizei GLsizei GLchar * source
Definition: glew.h:1832
const GLdouble * v
Definition: glew.h:1391
const char * className() const
Definition: UI_Event.h:88
UI_Object * target
Definition: UI_Event.h:56
GLuint buffer
Definition: glew.h:1680
UI_EventType
Definition: UI_EventType.h:20
UI_Value * value
Definition: UI_Event.h:58
UI_DeviceEvent state
Definition: UI_Event.h:61
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
void trigger()
Definition: UI_Event.h:74
UI_Reason
Definition: UI_Value.h:29
UI_Object * source
Definition: UI_Event.h:55
GLdouble GLdouble GLdouble r
Definition: glew.h:1406
void(UI_Object::* UI_EventMethod)(UI_Event *)
Definition: UI_Object.h:35
#define UI_API
Definition: UI_API.h:10
UI_EventMethod method
Definition: UI_Event.h:57
UI_Reason reason
Definition: UI_Event.h:63
UI_EventType type
Definition: UI_Event.h:59
UT_Array< UI_DeviceEvent > * myStateHistory
Definition: UI_Event.h:72
GLdouble GLdouble t
Definition: glew.h:1398