Evas: evas_object_table documentation.
authorgastal <gastal@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 29 Jul 2011 17:08:25 +0000 (17:08 +0000)
committergastal <gastal@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 29 Jul 2011 17:08:25 +0000 (17:08 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@61906 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

doc/examples.dox
src/examples/evas-table.c [new file with mode: 0644]
src/lib/Evas.h

index c3b56f1..4270c48 100644 (file)
  * @include evas-text.c
  * @example evas-text.c
  */
+
+/**
+ * @page tutorial_table Table Smart Object example
+ *
+ * This example will arrange  rectangles of different sizes(and colors) in a
+ * table. While it's possible to create the same layout we are doing here by
+ * positioning each rectangle independently, using a table makes it a lot
+ * easier, since the table will control layout of all the objects, allowing you
+ * to move, resize or hide the entire table.
+ *
+ * We'll start with creating the table, setting it to
+ * EVAS_OBJECT_TABLE_HOMOGENEOUS_NONE to have maximum flexibility and setting
+ * its padding to 0:
+ * @dontinclude evas-table.c
+ * @skip object_table
+ * @until show
+ *
+ * We then create each rectangle and add it to the table:
+ * @until table_pack
+ * @until table_pack
+ * @until table_pack
+ * @until table_pack
+ * @note Each rectangle has a different minimum size based on how many rows and
+ * columns it will occupy.
+ *
+ * The full source for this example follow:
+ * @include evas-table.c
+ * @example evas-table.c
+ */
diff --git a/src/examples/evas-table.c b/src/examples/evas-table.c
new file mode 100644 (file)
index 0000000..19fb68a
--- /dev/null
@@ -0,0 +1,120 @@
+/**
+ * Simple Evas example illustrating usage of table object.
+ *
+ * You'll need at least one engine built for it (excluding the buffer
+ * one) and the png image loader also built.
+ *
+ * @verbatim
+ * gcc -o evas-table evas-table.c `pkg-config --libs --cflags ecore-evas`
+ * @endverbatim
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#define __UNUSED__
+#endif
+
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+
+#include <stdlib.h>
+
+#define WIDTH  100
+#define HEIGHT 150
+
+struct test_data
+{
+   Ecore_Evas  *ee;
+   Evas        *evas;
+   Evas_Object *bg;
+};
+
+static struct test_data d = {0};
+
+static void
+_on_destroy(Ecore_Evas *ee __UNUSED__)
+{
+   ecore_main_loop_quit();
+}
+
+/* here just to keep our example's window size and background image's
+ * size in synchrony */
+static void
+_canvas_resize_cb(Ecore_Evas *ee)
+{
+   int w, h;
+
+   ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
+   evas_object_resize(d.bg, w, h);
+}
+
+int
+main(void)
+{
+   Evas_Object *table, *rect;
+
+   if (!ecore_evas_init())
+     return EXIT_FAILURE;
+
+   /* this will give you a window with an Evas canvas under the first
+    * engine available */
+   d.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
+   if (!d.ee)
+     goto error;
+
+   ecore_evas_callback_destroy_set(d.ee, _on_destroy);
+   ecore_evas_callback_resize_set(d.ee, _canvas_resize_cb);
+   ecore_evas_show(d.ee);
+
+   /* the canvas pointer, de facto */
+   d.evas = ecore_evas_get(d.ee);
+
+   d.bg = evas_object_rectangle_add(d.evas);
+   evas_object_color_set(d.bg, 255, 255, 255, 255); /* white bg */
+   evas_object_move(d.bg, 0, 0); /* at canvas' origin */
+   evas_object_resize(d.bg, WIDTH, HEIGHT); /* covers full canvas */
+   evas_object_show(d.bg);
+
+   table = evas_object_table_add(d.evas);
+   evas_object_table_homogeneous_set(table, EVAS_OBJECT_TABLE_HOMOGENEOUS_NONE);
+   evas_object_table_padding_set(table, 0, 0);
+   evas_object_resize(table, WIDTH, HEIGHT);
+   evas_object_show(table);
+
+   rect = evas_object_rectangle_add(d.evas);
+   evas_object_color_set(rect, 255, 0, 0, 255);
+   evas_object_size_hint_min_set(rect, 100, 50);
+   evas_object_show(rect);
+   evas_object_table_pack(table, rect, 1, 1, 2, 1);
+
+   rect = evas_object_rectangle_add(d.evas);
+   evas_object_color_set(rect, 0, 255, 0, 255);
+   evas_object_size_hint_min_set(rect, 50, 100);
+   evas_object_show(rect);
+   evas_object_table_pack(table, rect, 1, 2, 1, 2);
+
+   rect = evas_object_rectangle_add(d.evas);
+   evas_object_color_set(rect, 0, 0, 255, 255);
+   evas_object_size_hint_min_set(rect, 50, 50);
+   evas_object_show(rect);
+   evas_object_table_pack(table, rect, 2, 2, 1, 1);
+
+   rect = evas_object_rectangle_add(d.evas);
+   evas_object_color_set(rect, 255, 255, 0, 255);
+   evas_object_size_hint_min_set(rect, 50, 50);
+   evas_object_show(rect);
+   evas_object_table_pack(table, rect, 2, 3, 1, 1);
+
+   ecore_main_loop_begin();
+
+   ecore_evas_free(d.ee);
+   ecore_evas_shutdown();
+   return 0;
+
+error:
+   fprintf(stderr, "you got to have at least one evas engine built and linked"
+                   " up to ecore-evas for this example to run properly.\n");
+   ecore_evas_shutdown();
+   return -1;
+}
index 3e4a14b..d7471e8 100644 (file)
@@ -467,6 +467,9 @@ typedef enum _Evas_Colorspace
 /**
  * How to pack items into cells in a table.
  * @ingroup Evas_Object_Table
+ *
+ * @see evas_object_table_homogeneous_set() for an explanation of the funcion of
+ * each one.
  */
 typedef enum _Evas_Object_Table_Homogeneous_Mode
 {
@@ -10060,28 +10063,31 @@ EAPI Eina_Bool                  evas_object_box_option_property_vget
  * layout using children size hints to define their size and
  * alignment inside their cell space.
  *
+ * @ref tutorial_table shows how to use this Evas_Object.
+ *
  * @see @ref Evas_Object_Group_Size_Hints
  *
  * @ingroup Evas_Smart_Object_Group
+ *
+ * @{
  */
 
 /**
- * Create a new table.
+ * @brief Create a new table.
  *
- * It's set to non-homogeneous by default, add children with
- * evas_object_table_pack().
+ * @param evas Canvas in which table will be added.
  */
 EAPI Evas_Object                        *evas_object_table_add             (Evas *evas) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
 
 /**
- * Create a table that is child of a given element @a parent.
+ * @brief Create a table that is child of a given element @a parent.
  *
  * @see evas_object_table_add()
  */
 EAPI Evas_Object                        *evas_object_table_add_to          (Evas_Object *parent) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
 
 /**
- * Set how this table should layout children.
+ * @brief Set how this table should layout children.
  *
  * @todo consider aspect hint and respect it.
  *
@@ -10089,8 +10095,8 @@ EAPI Evas_Object                        *evas_object_table_add_to          (Evas
  * If table does not use homogeneous mode then columns and rows will
  * be calculated based on hints of individual cells. This operation
  * mode is more flexible, but more complex and heavy to calculate as
- * well. @b Weight properties are handled as a boolean
- * expand. Negative alignment will be considered as 0.5.
+ * well. @b Weight properties are handled as a boolean expand. Negative
+ * alignment will be considered as 0.5. This is the default.
  *
  * @todo @c EVAS_OBJECT_TABLE_HOMOGENEOUS_NONE should balance weight.
  *
@@ -10154,7 +10160,7 @@ EAPI void                                evas_object_table_align_get       (cons
 /**
  * Sets the mirrored mode of the table. In mirrored mode the table items go
  * from right to left instead of left to right. That is, 1,1 is top right, not
- * to left.
+ * top left.
  *
  * @param obj The table object.
  * @param mirrored the mirrored mode to set
@@ -10163,23 +10169,15 @@ EAPI void                                evas_object_table_align_get       (cons
 EAPI void                                evas_object_table_mirrored_set    (Evas_Object *o, Eina_Bool mirrored) EINA_ARG_NONNULL(1);
 
 /**
- * Gets the mirrored mode of the table. In mirrored mode the table items go
- * from right to left instead of left to right. That is, 1,1 is top right, not
- * to left.
+ * Gets the mirrored mode of the table.
  *
  * @param obj The table object.
  * @return EINA_TRUE if it's a mirrored table, EINA_FALSE otherwise.
  * @since 1.1.0
- */
-
-/**
- * Get a child from the table using its coordinates
- *
- * @note This does not take into account col/row spanning
+ * @see evas_object_table_mirrored_set()
  */
 EAPI Eina_Bool                           evas_object_table_mirrored_get    (const Evas_Object *o) EINA_ARG_NONNULL(1);
 
-
 /**
  * Get packing location of a child of table
  *
@@ -10228,7 +10226,6 @@ EAPI Eina_Bool                           evas_object_table_unpack          (Evas
  */
 EAPI void                                evas_object_table_clear           (Evas_Object *o, Eina_Bool clear) EINA_ARG_NONNULL(1);
 
-
 /**
  * Get the number of columns and rows this table takes.
  *
@@ -10262,7 +10259,16 @@ EAPI Eina_Accessor                      *evas_object_table_accessor_new    (cons
  *       list, but these removals won't be reflected on it.
  */
 EAPI Eina_List                          *evas_object_table_children_get    (const Evas_Object *o) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
-   EAPI Evas_Object                        *evas_object_table_child_get       (const Evas_Object *o, unsigned short col, unsigned short row) EINA_ARG_NONNULL(1);
+
+/**
+ * Get the child of the table at the given coordinates
+ *
+ * @note This does not take into account col/row spanning
+ */
+EAPI Evas_Object                        *evas_object_table_child_get       (const Evas_Object *o, unsigned short col, unsigned short row) EINA_ARG_NONNULL(1);
+/**
+ * @}
+ */
 
 /**
  * @defgroup Evas_Object_Grid Grid Smart Object.