From af8b2ce2cec802913618ce47706420ab3af90d54 Mon Sep 17 00:00:00 2001 From: Bruno Dilly Date: Fri, 23 Nov 2012 21:28:02 +0000 Subject: [PATCH] edje: add example of messages handling (receiving / sending) All types! SVN revision: 79589 --- legacy/edje/src/examples/Makefile.am | 1 + legacy/edje/src/examples/messages_echo.edc | 97 ++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 legacy/edje/src/examples/messages_echo.edc diff --git a/legacy/edje/src/examples/Makefile.am b/legacy/edje/src/examples/Makefile.am index f20e6834a9..7ad48bf5aa 100644 --- a/legacy/edje/src/examples/Makefile.am +++ b/legacy/edje/src/examples/Makefile.am @@ -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 \ diff --git a/legacy/edje/src/examples/messages_echo.edc b/legacy/edje/src/examples/messages_echo.edc new file mode 100644 index 0000000000..045ec92d9a --- /dev/null +++ b/legacy/edje/src/examples/messages_echo.edc @@ -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)); + } + } + } + } +}