edje: add example of messages handling (receiving /

sending)

All types!



SVN revision: 79589
This commit is contained in:
Bruno Dilly 2012-11-23 21:28:02 +00:00
parent 74bc2de752
commit af8b2ce2ce
2 changed files with 98 additions and 0 deletions

View File

@ -38,6 +38,7 @@ external_elm_check.edc \
external_elm_panes.edc \
external_emotion_elm.edc \
lua_script.edc \
messages_echo.edc \
perspective.edc \
signalsBubble.edc \
signals-messages.edc \

View File

@ -0,0 +1,97 @@
/* Simple EDC exemplifying how to receive and emit all types of messages */
/* Actually for sets it will send back a message of the same type with the
* first item and N other messages with the remaining items. */
collections {
group {
name: "messages_echo";
parts {
part {
name: "bg";
type: RECT;
description {
state: "default" 0.0;
min: 400 50;
max: 400 50;
color: 0 0 0 255;
}
}
part {
name: "text";
type: TEXT;
description {
state: "default" 0.0;
color: 255 255 255 255;
text {
font: "Sans";
size: 20;
text: "I will echo all your messages ;)";
}
}
}
}
script {
public message(Msg_Type:type, id, ...) {
if (type == MSG_INT)
send_message(type, id, getarg(2));
else if (type == MSG_FLOAT)
send_message(type, id, getfarg(2));
else if (type == MSG_STRING) {
new buf[1024];
getsarg(2, buf, sizeof(buf));
send_message(type, id, buf);
}
else if (type == MSG_STRING_INT) {
new buf[1024];
getsarg(2, buf, sizeof(buf));
send_message(type, id, buf, getarg(3));
}
else if (type == MSG_STRING_FLOAT) {
new buf[1024];
getsarg(2, buf, sizeof(buf));
send_message(type, id, buf, getfarg(3));
}
else if (type == MSG_INT_SET) {
new i, n = numargs();
send_message(type, id, getarg(2));
for (i = 3; i < n; i++)
send_message(MSG_STRING_INT, id, "Extra INT:", getarg(i));
}
else if (type == MSG_FLOAT_SET) {
new i, n = numargs();
send_message(type, id, getfarg(2));
for (i = 3; i < n; i++)
send_message(MSG_STRING_FLOAT, id, "Extra FLOAT:",
getfarg(i));
}
else if (type == MSG_STRING_SET) {
new buf[1024], i, n = numargs();
getsarg(2, buf, sizeof(buf));
send_message(type, id, buf);
for (i = 3; i < n; i++) {
getsarg(i, buf, sizeof(buf));
send_message(MSG_STRING_SET, id, "Extra STRING:", buf);
}
}
else if (type == MSG_STRING_INT_SET) {
new buf[1024], i, n = numargs();
getsarg(2, buf, sizeof(buf));
send_message(type, id, buf, getarg(3));
for (i = 4; i < n; i++)
send_message(MSG_STRING_INT, id, "Extra INT:", getarg(i));
}
else if (type == MSG_STRING_FLOAT_SET) {
new buf[1024], i, n = numargs();
getsarg(2, buf, sizeof(buf));
send_message(type, id, buf, getfarg(3));
for (i = 4; i < n; i++)
send_message(MSG_STRING_INT, id, "Extra FLOAT:", getfarg(i));
}
}
}
}
}