Enlightenment CVS committal
Author : dj2
Project : e17
Module : docs
Dir : e17/docs/cookbook/xml
Modified Files:
ecore_recipes.xml esmart_recipes.xml
Log Message:
- fix the dates in the ecore_config and esmart_trans examples
- update ecore_config for exit -> shutdown change
- update linkage of esmart examples
- add an esmart_container example
===================================================================
RCS file: /cvsroot/enlightenment/e17/docs/cookbook/xml/ecore_recipes.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ecore_recipes.xml 27 Apr 2004 10:59:32 -0000 1.2
+++ ecore_recipes.xml 6 May 2004 23:34:18 -0000 1.3
@@ -58,7 +58,7 @@
<surname>sinclair</surname>
<email>[EMAIL PROTECTED]</email>
</author>
- <date>25 May 2004</date>
+ <date>25 April 2004</date>
</sectioninfo>
<title>Recipe: Ecore Config Introduction</title>
@@ -101,7 +101,7 @@
free(str);
- ecore_config_exit();
+ ecore_config_shutdown();
return 0;
}
</programlisting>
@@ -127,7 +127,7 @@
</para>
<para>
-ecore_config_exit is then called to shutdown the Ecore_Config system before the
program exits.
+ecore_config_shutdown is then called to shutdown the Ecore_Config system before the
program exits.
</para>
<example>
===================================================================
RCS file: /cvsroot/enlightenment/e17/docs/cookbook/xml/esmart_recipes.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- esmart_recipes.xml 27 Apr 2004 10:59:32 -0000 1.2
+++ esmart_recipes.xml 6 May 2004 23:34:18 -0000 1.3
@@ -57,7 +57,7 @@
<surname>sinclair</surname>
<email>[EMAIL PROTECTED]</email>
</author>
- <date>25 May 2004</date>
+ <date>25 April 2004</date>
</sectioninfo>
<title>Recipe: Esmart Trans Introduction</title>
@@ -299,7 +299,8 @@
<title>Simple makefile</title>
<programlisting>
CFLAGS = `ecore-config --cflags` `evas-config --cflags` `esmart-config --cflags`
-LIBS = `ecore-config --libs` `evas-config --libs` `esmart-config --libs`
+LIBS = `ecore-config --libs` `evas-config --libs` `esmart-config --libs` \
+ -lesmart_trans_x11
all:
gcc -o trans_example trans_example.c $(CFLAGS) $(LIBS)
@@ -311,9 +312,870 @@
library. These -config scripts know where each of the includes and libraries resides
and sets up the appropriate linking and include paths for the compilation.
</para>
+</section>
+
+<!--
+#######################################################
+-->
+
+<!--
+#######################################################
+A simple recipe on using esmart containers
+#######################################################
+-->
+<section>
+<sectioninfo>
+ <author>
+ <firstname>dan</firstname>
+ <surname>sinclair</surname>
+ <email>[EMAIL PROTECTED]</email>
+ </author>
+ <date>30 April 2004</date>
+</sectioninfo>
+
+<title>Recipe: Esmart Container Introduction</title>
+
+<para>
+There is usually a desire while designing an apps UI to group common elements together
+and have their layout depend on one another. To this end the Esmart Container
+libary has been created. It has been designed to handle the hard parts of the
+layout, and in the cases where it does not do what you need, the layout portions of
+the container are extensible and changeable.
+</para>
+
+<para>
+This recipe will give the basics of using an Esmart container. The final product is
+a program that will let you see some of the different layout combinations of the
+default container. The layout will be done by Edje with callbacks to the program
+to change the container layout, and to tell if the user clicked on a container
+element.
+</para>
+
+<example>
+<title>Includes and declarations</title>
+<programlisting>
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+#include <Edje.h>
+#include <Esmart/Esmart_Container.h>
+#include <getopt.h>
+
+static void make_gui(const char *theme);
+static void container_build(int align, int direction, int fill);
+static void _set_text(int align, int direction);
+static void _setup_edje_callbacks(Evas_Object *o);
+static void _right_click_cb(void* data, Evas_Object* o, const char* emmission,
+ const char* source);
+static void _left_click_cb(void* data, Evas_Object* o, const char* emmission,
+ const char* source);
+static void _item_selected(void* data, Evas_Object* o, const char* emmission,
+ const char* source);
+
+static Ecore_Evas *ee;
+static Evas_Object *edje;
+static Evas_Object *container;
+
+char *str_list[] = {"item 1", "item 2",
+ "item 3", "item 4",
+ "item 5"};
+</programlisting>
+</example>
+<para>
+As with other EFL programs we need to include Ecore, Ecore_Evas, Edje and as this is
a
+container example, the Esmart/Esmart_Container header. Getopt will be used to allow
for
+some command line processing.
+</para>
+
+<para>
+Next comes the function prototypes which will be described later when we get to their
+implementations. Then a few global variables to be used throughout the program.
+The str_list array is the content to be stored in the container.
+</para>
+
+<example>
+<title>main</title>
+<programlisting>
+int main(int argc, char ** argv) {
+ int align = 0;
+ int direction = 0;
+ int fill = 0;
+ int ret = 0;
+ int c;
+ char *theme = NULL;
+
+ while((c = getopt(argc, argv, "a:d:f:t:")) != -1) {
+ switch(c) {
+ case 'a':
+ align = atoi(optarg);
+ break;
+
+ case 'd':
+ direction = atoi(optarg);
+ break;
+
+ case 'f':
+ fill = atoi(optarg);
+ break;
+
+ case 't':
+ theme = strdup(optarg);
+ break;
+
+ default:
+ printf("Unknown option string\n");
+ break;
+ }
+ }
+
+ if (theme == NULL) {
+ printf("Need a theme defined\n");
+ exit(-1);
+ }
+</programlisting>
+</example>
+<para>
+The beginning of the main function gets the options out of the
+command line arguments and sets up the default display. As you can
+see, we require a theme to display. This could be made more intelligent,
+searching default install directories and the users application
+directories, but this example takes the easy way out and forces the theme
+to be a command line option.
+</para>
+
+<example>
+<title>Initialization</title>
+<programlisting>
+ if (!ecore_init()) {
+ printf("Can't init ecore, bad\n");
+ ret = 1;
+ goto EXIT;
+ }
+ ecore_app_args_set(argc, (const char **)argv);
+
+ if (!ecore_evas_init()) {
+ printf("Can't init ecore_evas, bad\n");
+ ret = 1;
+ goto EXIT_ECORE;
+ }
+
+ if (!edje_init()) {
+ printf("Can't init edje, bad\n");
+ ret = 1;
+ goto EXIT_ECORE_EVAS;
+ }
+ edje_frametime_set(1.0 / 60.0);
+
+ make_gui(theme);
+ container_build(align, direction, fill);
+
+ ecore_main_loop_begin();
+</programlisting>
+</example>
+<para>
+After receiving the command line arguments, we then proceed to
+initializing the required libraries, Ecore, Ecore_Evas and Edje.
+We take the additional step of setting the Edje frame rate.
+</para>
+
+<para>
+Once the initialization is complete we create the initial GUI for the
+app. I have separated the building of the container out into a
+separate function to make the container code easier to locate in the example.
+</para>
+
+<para>
+Once everything is created we call ecore_main_loop_begin and wait for
+events to occur.
+</para>
+
+<example>
+<title>Shutdown</title>
+<programlisting>
+ edje_shutdown();
+
+EXIT_ECORE_EVAS:
+ ecore_evas_shutdown();
+
+EXIT_ECORE:
+ ecore_shutdown();
+
+EXIT:
+ return ret;
+}
+</programlisting>
+</example>
+<para>
+The usual end routine, be good programmers and shutdown everything we started.
+</para>
+
+<example>
+<title>Window callbacks</title>
+<programlisting>
+static int sig_exit_cb(void *data, int ev_type, void *ev) {
+ ecore_main_loop_quit();
+ return 1;
+}
+
+static void win_del_cb(Ecore_Evas *ee) {
+ ecore_main_loop_quit();
+}
+
+static void win_resize_cb(Ecore_Evas *ee) {
+ int w, h;
+ int minw, minh;
+ int maxw, maxh;
+ Evas_Object *o = NULL;
+
+ if (ee) {
+ ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
+ ecore_evas_size_min_get(ee, &minw, &minh);
+ ecore_evas_size_max_get(ee, &maxw, &maxh);
+
+ if ((w >= minw) && (h >= minh) && (h <= maxh)
&& (w <= maxw)) {
+ if ((o = evas_object_name_find(ecore_evas_get(ee), "edje")))
+ evas_object_resize(o, w, h);
+ }
+ }
+}
+</programlisting>
+</example>
+<para>
+Next we setup some generic callbacks to be used by the UI. This will be the exit,
destroy
+and resize callbacks. Again, the usual EFL style functions.
+</para>
+
+<example>
+<title>make_gui</title>
+<programlisting>
+static void make_gui(const char *theme) {
+ Evas *evas = NULL;
+ Evas_Object *o = NULL;
+ Evas_Coord minw, minh;
+
+ ee = NULL;
+ edje = NULL;
+ container = NULL;
+
+ ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, sig_exit_cb, NULL);
+
+ ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 300, 400);
+ ecore_evas_title_set(ee, "Container Example");
+
+ ecore_evas_callback_delete_request_set(ee, win_del_cb);
+ ecore_evas_callback_resize_set(ee, win_resize_cb);
+ evas = ecore_evas_get(ee);
+
+ // create the edje
+ edje = edje_object_add(evas);
+ evas_object_move(edje, 0, 0);
+
+ if (edje_object_file_set(edje, theme, "container_ex")) {
+ evas_object_name_set(edje, "edje");
+
+ edje_object_size_min_get(edje, &minw, &minh);
+ ecore_evas_size_min_set(ee, (int)minw, (int)minh);
+ evas_object_resize(edje, (int)minw, (int)minh);
+ ecore_evas_resize(ee, (int)minw, (int)minh);
+
+ edje_object_size_max_get(edje, &minw, &minh);
+ ecore_evas_size_max_set(ee, (int)minw, (int)minh);
+ evas_object_show(edje);
+
+ } else {
+ printf("Unable to open (%s) for edje theme\n", theme);
+ exit(-1);
+ }
+ _setup_edje_callbacks(edje);
+ ecore_evas_show(ee);
+}
+</programlisting>
+</example>
+<para>
+The GUI consists of the Ecore_Evas containing the canvas itself, and the Edje that
+we will be using to control our layout. The make_gui function sets up the callbacks
+defined above and creates the Ecore_Evas.
+</para>
+
+<para>
+Once we have the Evas and the callbacks are defined, we create the Edje object that
+will define our layout. The edje_object_add call is used to create the object on the
Evas,
+and once thats done, we take the theme passed in by the user and set our Edje to
+use said theme, the "container_ex" parameter is the name of the group
+inside the EET that we are to use.
+</para>
+
+<para>
+Once the theme file is set to the Edje, we use the values in the theme file to setup
+the size ranges for the app, and show the Edje. We then setup the callbacks on the
+Edje and show the Ecore_Evas.
+</para>
+
+<example>
+<title>Edje Callbacks</title>
+<programlisting>
+static void _setup_edje_callbacks(Evas_Object *o) {
+ edje_object_signal_callback_add(o, "left_click",
+ "left_click", _left_click_cb, NULL);
+ edje_object_signal_callback_add(o, "right_click",
+ "right_click", _right_click_cb, NULL);
+}
+</programlisting>
+</example>
+<para>
+The program will have two main callbacks attached to the Edje, one for the left click
signal and
+one for the right click signal. These will be used to switch the direction/alignment
of the
+container. The second and third parameters of the callbacks need to match the data
emitted with the
+signal from Edje, this will be seen later when we look at the EDC file. The third
parameter is
+the function to call, and the last, any data we wish to be passed into the callback.
+</para>
+
+<example>
+<title>container_build</title>
+<programlisting>
+static void container_build(int align, int direction, int fill_policy) {
+ int len = 0;
+ int i = 0;
+ const char *edjefile = NULL;
+
+ container = esmart_container_new(ecore_evas_get(ee));
+ evas_object_name_set(container, "the_container");
+ esmart_container_direction_set(container, direction);
+ esmart_container_alignment_set(container, align);
+ esmart_container_padding_set(container, 1, 1, 1, 1);
+ esmart_container_spacing_set(container, 1);
+ esmart_container_fill_policy_set(container, fill_policy);
+
+ evas_object_layer_set(container, 0);
+ edje_object_part_swallow(edje, "container", container);
+</programlisting>
+</example>
+<para>
+The container_build function will create the container and set our data elements in
said
+container. The creation is easy enough with a call to esmart_container_new giving
back the
+Evas_Object that is the container. Once the container is created we can set a name on
the
+container to make reference easier.
+</para>
+<para>
+Next, we set the direction, which is either (CONTAINER_DIRECTION_VERTICAL or
+CONTAINER_DIRECTION_HORIZONTAL) [or in this case, an int being passed from the
command
+line as the two directions map to 1 and 0 respectively]. The direction tells the
container
+which way the elements will be drawn.
+</para>
+
+<para>
+After the direction we set the alignment of the container. The alignment tells the
container
+where to draw the elements. The possible values are: CONTAINER_ALIGN_CENTER,
CONTAINER_ALIGN_LEFT,
+CONTAINER_ALIGN_RIGHT, CONTAINER_ALIGN_TOP and CONTAINER_ALIGN_BOTTOM. With the
default
+layout, left and right only apply to a vertical container, and top and bottom only
apply
+to a horizontal container, although center applies to both.
+</para>
+
+<para>
+If we wanted to use a different layout scheme then the default, we could place a call
to
+esmart_container_layout_plugin_set(container, "name") where the name is the name of
+the plugin to use. The default setting is the container named "default".
+</para>
+
+<para>
+Once the directions and alignment are set, the spacing and padding of the container
are
+specified. The padding specifes the space around the outside of the container taking
four
+numeric parameters: left, right, top and bottom. The spacing parameter specifies
+the space between elements in the container.
+</para>
+
+<para>
+We then continue and set the fill policy of the container. This specifies how the
+elements are positioned to fill the space in the container. The possible values are:
+CONTAINER_FILL_POLICY_NONE, CONTAINER_FILL_POLICY_KEEP_ASPECT,
CONTAINER_FILL_POLICY_FILL_X,
+CONTAINER_FILL_POLICY_FILL_Y, CONTAINER_FILL_POLICY_FILL and
CONTAINER_FILL_POLICY_HOMOGENOUS.
+</para>
+
+<para>
+Once the container is fully specified we set the containers layer, and then swallow
the
+container into the edje and the part named "container".
+</para>
+
+<example>
+<title>Adding Elements to the Container</title>
+<programlisting>
+ len = (sizeof(str_list) / sizeof(str_list[0]));
+ for(i = 0; i < len; i++) {
+ Evas_Coord w, h;
+ Evas_Object *t = edje_object_add(ecore_evas_get(ee));
+
+ edje_object_file_get(edje, &edjefile, NULL);
+ if (edje_object_file_set(t, edjefile, "element")) {
+ edje_object_size_min_get(t, &w, &h);
+ evas_object_resize(t, (int)w, (int)h);
+
+ if (edje_object_part_exists(t, "element.value")) {
+ edje_object_part_text_set(t, "element.value", str_list[i]);
+ evas_object_show(t);
+ int *i_ptr = (int *)malloc(sizeof(int));
+ *i_ptr = (i + 1);
+
+ edje_object_signal_callback_add(t, "item_selected",
+ "item_selected", _item_selected, i_ptr);
+
+ esmart_container_element_append(container, t);
+ } else {
+ printf("Missing element.value part\n");
+ evas_object_del(t);
+ }
+ } else {
+ printf("Missing element part\n");
+ evas_object_del(t);
+ }
+ }
+ evas_object_show(container);
+ _set_text(align, direction);
+}
+</programlisting>
+</example>
+<para>
+Now that we have a container, we can add some elements to be displayed. Each of the
+entries in the str_list array defined at the beginning of the program will be added
+into the container as a text part.
+</para>
+
+<para>
+For each element we create a new Edje object on the Evas. We then need to know the
+name of the theme file used to create our main Edje, so we call edje_object_file_get
+which will set edjefile to said value.
+</para>
+
+<para>
+We then try to set the group named "element" onto the newly created
+element. If this fails we print an error and delete the object.
+</para>
+
+<para>
+As long as we have found the group "element" we can attempt to grab the part
+for our element, "element.value". If this part exists, we set the text
+value of the part to our current string and show the part.
+</para>
+
+<para>
+A callback is created through edje_object_signal_callback_add and attached to the
+new element. This will be called if the "item_selected" signal is sent from
the Edje.
+The i_ptr value shows how data can be attached to the element, when the user clicks
+on an element its number will be printed to the console.
+</para>
+
+<para>
+Once the element is created we add it to the container (in this case, appending the
+element).
+</para>
+
+<para>
+To finish, the container is show and we do some extra work to display information
about
+the container in the header through the call _show_text.
+</para>
+
+<example>
+<title>_set_text</title>
+<programlisting>
+static void _set_text(int align, int direction) {
+ Evas_Object *t = edje_object_add(ecore_evas_get(ee));
+ const char *edjefile;
+
+ if (direction == CONTAINER_DIRECTION_VERTICAL)
+ edje_object_part_text_set(edje, "header_text_direction", "vertical");
+ else
+ edje_object_part_text_set(edje, "header_text_direction", "horizontal");
+
+ if (align == CONTAINER_ALIGN_CENTER)
+ edje_object_part_text_set(edje, "header_text_align", "center");
+
+ else if (align == CONTAINER_ALIGN_TOP)
+ edje_object_part_text_set(edje, "header_text_align", "top");
+
+ else if (align == CONTAINER_ALIGN_BOTTOM)
+ edje_object_part_text_set(edje, "header_text_align", "bottom");
+
+ else if (align == CONTAINER_ALIGN_RIGHT)
+ edje_object_part_text_set(edje, "header_text_align", "right");
+
+ else if (align == CONTAINER_ALIGN_LEFT)
+ edje_object_part_text_set(edje, "header_text_align", "left");
+}
+</programlisting>
+</example>
+<para>
+The _set_text routine takes the current direction and alignment of the container and
sets
+some text in the header of the program. This is just a simple communication with the
user
+of the current container settings.
+</para>
+
+<example>
+<title>_left_click_cb</title>
+<programlisting>
+static void _left_click_cb(void* data, Evas_Object* o, const char* emmission,
+ const char* source) {
+ Container_Direction dir = esmart_container_direction_get(container);
+ Container_Direction new_dir = (dir + 1) % 2;
+ Container_Alignment align = esmart_container_alignment_get(container);
+
+ esmart_container_direction_set(container, new_dir);
+
+ if (align != CONTAINER_ALIGN_CENTER) {
+ if (new_dir == CONTAINER_DIRECTION_HORIZONTAL)
+ align = CONTAINER_ALIGN_TOP;
+ else
+ align = CONTAINER_ALIGN_LEFT;
+ }
+ esmart_container_alignment_set(container, align);
+ _set_text(align, new_dir);
+}
+</programlisting>
+</example>
+<para>
+When the user clicks the left mouse button on the screen this callback will be
executed. We take
+the current container direction information and switch to the other direction. (e.g.
horizontal
+becomes vertical and visa versa.) We also reset the alignment if we are not currently
aligned
+center to make sure everything is valid for the new direction. The text in the header
is
+updated to be current.
+</para>
+
+<example>
+<title>_right_click_cb</title>
+<programlisting>
+static void _right_click_cb(void* data, Evas_Object* o, const char* emmission,
+ const char* source) {
+ Container_Direction dir = esmart_container_direction_get(container);
+ Container_Alignment align = esmart_container_alignment_get(container);
+
+ if (dir == CONTAINER_DIRECTION_HORIZONTAL) {
+ if (align == CONTAINER_ALIGN_TOP)
+ align = CONTAINER_ALIGN_CENTER;
+
+ else if (align == CONTAINER_ALIGN_CENTER)
+ align = CONTAINER_ALIGN_BOTTOM;
+
+ else
+ align = CONTAINER_ALIGN_TOP;
+
+ } else {
+ if (align == CONTAINER_ALIGN_LEFT)
+ align = CONTAINER_ALIGN_CENTER;
+
+ else if (align == CONTAINER_ALIGN_CENTER)
+ align = CONTAINER_ALIGN_RIGHT;
+
+ else
+ align = CONTAINER_ALIGN_LEFT;
+ }
+ esmart_container_alignment_set(container, align);
+ _set_text(align, esmart_container_direction_get(container));
+}
+</programlisting>
+</example>
+<para>
+The right click callback will cycle through the available alignments for a given
+direction as the user clicks the right mouse button.
+</para>
+
+<example>
+<title>_item_selected</title>
+<programlisting>
+static void _item_selected(void* data, Evas_Object* o, const char* emmission,
+ const char* source) {
+ printf("You clicked on the item with number %d\n", *((int *)data));
+}
+</programlisting>
+</example>
+<para>
+Finally the _item_selected callback will be executed when the user middle clicks
+on an item in the container. The data will contain the number set for that element
+in the create routine above.
+</para>
+
+<para>
+Thats the end of the code for the app, next comes the required EDC for everything
+to display and function correctly.
+</para>
+
+<example>
+<title>The Edc</title>
+<programlisting>
+fonts {
+ font: "Vera.ttf" "Vera";
+}
+
+collections {
+ group {
+ name, "container_ex";
+ min, 300, 300;
+ max, 800, 800;
+
+ parts {
+ part {
+ name, "bg";
+ type, RECT;
+ mouse_events, 1;
+
+ description {
+ state, "default" 0.0;
+ color, 0 0 0 255;
+
+ rel1 {
+ relative, 0.0 0.1;
+ offset, 0 0;
+ }
+ rel2 {
+ relative, 1.0 1.0;
+ offset, 0 0;
+ }
+ }
+ }
+
+ part {
+ name, "header";
+ type, RECT;
+ mouse_events, 0;
+
+ description {
+ state, "default" 0.0;
+ color, 255 255 255 255;
+
+ rel1 {
+ relative, 0.0 0.0;
+ offset, 0 0;
+ }
+
+ rel2 {
+ relative, 1.0 0.1;
+ offset, 0 0;
+ }
+ }
+ }
+
+ part {
+ name, "header_text_direction";
+ type, TEXT;
+ mouse_events, 0;
+
+ description {
+ state, "default" 0.0;
+ color, 0 0 0 255;
+
+ rel1 {
+ relative, 0.0 0.0;
+ offset, 0 10;
+ to, "header";
+ }
+ rel2 {
+ relative, 1.0 1.0;
+ offset, 0 0;
+ to, "header";
+ }
+ text {
+ text, "direction";
+ font, "Vera";
+ size, 10;
+ }
+ }
+ }
+
+ part {
+ name, "header_text_align";
+ type, TEXT;
+ mouse_events, 0;
+
+ description {
+ state, "default" 0.0;
+ color, 0 0 0 255;
+
+ rel1 {
+ relative, 0.0 0.0;
+ offset, 0 0;
+ to, "header_text_direction";
+ }
+ rel2 {
+ relative, 1.0 1.0;
+ offset, 110 0;
+ to, "header_text_direction";
+ }
+ text {
+ text, "align";
+ font, "Vera";
+ size, 10;
+ }
+ }
+ }
+</programlisting>
+</example>
+<para>
+This EDC file expects to have the Vera font embedded inside it, as defined by the
+font section at the beginning. This means when you compile the edc you either need
+the Vera.ttf file in the current directory or give edje_cc the -fd flag and specify
+the directory to the font.
+</para>
+
+<para>
+After the fonts are defined the main collections are defined. The first collection
+is the main portion of the app itself, the "container_ex" group. This group
+specifes the main window of the app. As such it contains the parts for the
background,
+the header, and the header text. These parts are all fairly standard with some
(minimal)
+alignment done between them.
+</para>
+
+<example>
+<title>The Container Part</title>
+<programlisting>
+ part {
+ name, "container";
+ type, RECT;
+ mouse_events, 1;
+
+ description {
+ state, "default" 0.0;
+ visible, 1;
+
+ rel1 {
+ relative, 0.0 0.0;
+ offset, 0 0;
+ to, bg;
+ }
+ rel2 {
+ relative, 1.0 1.0;
+ offset, 0 0;
+ to, bg;
+ }
+ color, 0 0 0 0;
+ }
+ }
+ }
+ programs {
+ program {
+ name, "left_click";
+ signal, "mouse,clicked,1";
+ source, "container";
+ action, SIGNAL_EMIT "left_click" "left_click";
+ }
+
+ program {
+ name, "right_click";
+ signal, "mouse,clicked,3";
+ source, "container";
+ action, SIGNAL_EMIT "right_click" "right_click";
+ }
+ }
+ }
+</programlisting>
+</example>
+<para>
+The container part is then defined. The part itself is pretty simple, just positioned
+relative to the background and set to receive mouse events. After the parts are
defined
+we specify the programs for this group, of which there are two. The first program
+"left_click" specifies what is to happen on a click event of the first
mouse button.
+</para>
+
+<para>
+The action is to emit a signal, the two parameters after SIGNAL_EMIT match up to the
values
+put in the callback in the application code.
+</para>
+
+<para>
+There is a similar callback for the third mouse button as the first, just emitting a
slightly
+different signal.
+</para>
+
+<example>
+<title>The Element Group</title>
+<programlisting>
+ group {
+ name, "element";
+ min, 80 18;
+ max, 800 18;
+
+ parts {
+ part {
+ name, "element.value";
+ type, TEXT;
+ mouse_events, 1;
+ effect, NONE;
+
+ description {
+ state, "default" 0.0;
+ visible, 1;
+
+ rel1 {
+ relative, 0.0 0.0;
+ offset, 0 0;
+ }
+ rel2 {
+ relative, 1.0 1.0;
+ offset, 0 0;
+ }
+ color, 255 255 255 255;
+
+ text {
+ text, "";
+ font, "Vera";
+ size, 10;
+ }
+ }
+ }
+ }
+ programs {
+ program {
+ name, "center_click";
+ signal, "mouse,clicked,2";
+ source, "element.value";
+ action, SIGNAL_EMIT "item_selected" "item_selected";
+ }
+ }
+ }
+}
+</programlisting>
+</example>
+<para>
+The element group specifies how each element of the container is to be
+displayed. You will notice that the names given here match up to the
+names seached for in the application code itself while creating the elements.
+</para>
+
+<para>
+There is one program in this group which will emit a signal of
"item_selected"
+when the middle mouse button is pressed while hovering over one of the
+elements in the list.
+</para>
+
+<para>
+Thats the end of the EDC code. To compile the app code, a makefile similar to that
below
+could be used.
+</para>
+
+<example>
+<title>Makefile</title>
+<programlisting>
+CFLAGS = `ecore-config --cflags` `evas-config --cflags` `esmart-config --cflags`
+LIBS = `ecore-config --libs` `evas-config --libs` `esmart-config --libs` \
+ -lesmart_container
+
+container_ex: container/container_ex.c
+ gcc -o container/container_ex container/container_ex.c $(CFLAGS) $(LIBS)
+</programlisting>
+</example>
+
+<para>
+And to create the EET file, a simple 'edje_cc default.edc' should suffice as long
+as the Vera.ttf file is in the current directory.
+</para>
+
+<para>
+Thats it, assuming everything goes as planned, you should have a simple app in which
+clicking the right/left mouse buttons moves the container to different portions of
the window.
+While clicking the middle mouse button on elements prints out the number of the
element printed.
+</para>
</section>
+<!--
+#######################################################
+-->
</chapter>
+
-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to
deliver higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs