summaryrefslogtreecommitdiff
path: root/common/message.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/message.h')
-rw-r--r--common/message.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/common/message.h b/common/message.h
new file mode 100644
index 0000000..f97cff2
--- /dev/null
+++ b/common/message.h
@@ -0,0 +1,40 @@
+#ifndef _MESSAGE_H_
+#define _MESSAGE_H_
+
+#include "array.h"
+
+typedef void (*LC_MSG_CALLBACK) (int message, void *data, void *user);
+
+typedef enum
+{
+ LC_MSG_FOCUS_CHANGED,
+ // LC_MSG_SELECTION_CHANGED,
+ LC_MSG_COUNT
+} LC_MESSAGES;
+
+typedef struct
+{
+ LC_MSG_CALLBACK func;
+ void *user;
+} LC_MSG_STRUCT;
+
+class Messenger
+{
+ public:
+ Messenger ();
+ ~Messenger ();
+
+ void AddRef ()
+ { m_nRef++; };
+ void DecRef ()
+ { m_nRef--; if (m_nRef == 0) delete this; };
+
+ void Dispatch (int message, void *data);
+ void Listen (LC_MSG_CALLBACK func, void *user);
+
+ protected:
+ int m_nRef;
+ PtrArray<LC_MSG_STRUCT> m_Listeners;
+};
+
+#endif // _MESSAGE_H_