1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/**
* dispatch_ifc.m
*
* defines a function interface for dispatchable messaging
* define DISPATCH before loading if you are a message reciever
*
* @author mpdeimos
* @date 2008/10/25
* @version 0.1
*/
#ifndef included
#error This script can only be compiled as a #include
#endif
Function initDispatcher(); // Call this function on startup to set the parent layout as dispatcher
Function setDispatcher(GuiObject dispatcher); // Call this function instead if you want to define a custom
#ifndef DISPATCH
// Sends a message to the parent layout
Function int sendMessage(int message, int i0, int i1, int i2, String s0, String s1, GuiObject obj);
Function int sendMessageI(int message, int i0);
Function int sendMessageI2(int message, int i0, int i1);
Function int sendMessageS(int message, String s0);
Function int sendMessageO(int message, GuiObject obj);
Function int sendMessageV(int message);
#endif
#ifdef DISPATCH
// Recieves Messages
Function int onMessage(int message, int i0, int i1, int i2, String s0, String s1, GuiObject obj);
int onMessage(int message, int i0, int i1, int i2, String s0, String s1, GuiObject obj) {} // STUB! Implement this in your code
#endif
///
/// IMPLEMENTATION
///
Global GuiObject dispatcher;
initDispatcher()
{
dispatcher = getScriptGroup().getParentLayout();
}
setDispatcher(GuiObject go)
{
dispatcher = go;
}
#ifndef DISPATCH
int sendMessage(int message, int i0, int i1, int i2, String s0, String s1, GuiObject obj)
{
return dispatcher.onAction (s0, s1, message, i0, i1, i2, obj);
}
int sendMessageI(int message, int i0)
{
GuiObject obj = NULL;
return sendMessage(message, i0, i1, 0, "", "", obj);
}
int sendMessageI2(int message, int i0, int i1)
{
GuiObject obj = NULL;
return sendMessage(message, i0, 0, 0, "", "", obj);
}
int sendMessageS(int message, String s0)
{
GuiObject obj = NULL;
return sendMessage(message, 0, 0, 0, s0, "", obj);
}
int sendMessageO(int message, GuiObject obj)
{
return sendMessage(message, 0, 0, 0, "", "", obj);
}
int sendMessageV(int messagej)
{
GuiObject obj = NULL;
return sendMessage(message, 0, 0, 0, "", "", obj);
}
#endif
#ifdef DISPATCH
dispatcher.onAction(String action, String param, Int message, int y, int p1, int p2, GuiObject source)
{
return onMessage(message, y, p1, p2, action, param, source);
}
#endif
|