kuuko pushed a commit to branch master.

commit 40e76e001a0bb92d4dc641db876c23c761784b5d
Author: Kai Huuhko <[email protected]>
Date:   Sun Apr 14 01:37:08 2013 +0000

    Evas: Add Grid.
---
 doc/evas/class-grid.rst  |   4 ++
 doc/evas/evas.rst        |   1 +
 efl/evas/efl.evas.pyx    |   1 +
 efl/evas/object_grid.pxi | 135 +++++++++++++++++++++++++++++++++++++++++++++++
 include/efl.evas.pxd     |  17 ++++++
 5 files changed, 158 insertions(+)

diff --git a/doc/evas/class-grid.rst b/doc/evas/class-grid.rst
new file mode 100644
index 0000000..03747db
--- /dev/null
+++ b/doc/evas/class-grid.rst
@@ -0,0 +1,4 @@
+:class:`efl.evas.Grid` Class
+============================
+
+.. autoclass:: efl.evas.Grid
diff --git a/doc/evas/evas.rst b/doc/evas/evas.rst
index f1a86d9..1b698a9 100644
--- a/doc/evas/evas.rst
+++ b/doc/evas/evas.rst
@@ -214,6 +214,7 @@ Reference
    class-object-textblock
    class-object-box
    class-object-smart
+   class-grid
    class-table
    class-textgrid
    class-map
diff --git a/efl/evas/efl.evas.pyx b/efl/evas/efl.evas.pyx
index 6a92bc1..4b96ec9 100644
--- a/efl/evas/efl.evas.pyx
+++ b/efl/evas/efl.evas.pyx
@@ -322,6 +322,7 @@ include "efl.evas_object_textblock.pxi"
 include "efl.evas_object_box.pxi"
 include "object_textgrid.pxi"
 include "object_table.pxi"
+include "object_grid.pxi"
 
 
 init()
diff --git a/efl/evas/object_grid.pxi b/efl/evas/object_grid.pxi
new file mode 100644
index 0000000..909d972
--- /dev/null
+++ b/efl/evas/object_grid.pxi
@@ -0,0 +1,135 @@
+# Copyright (C) 2007-2013 various contributors (see AUTHORS)
+#
+# This file is part of Python-EFL.
+#
+# Python-EFL is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# Python-EFL is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this Python-EFL.  If not, see <http://www.gnu.org/licenses/>.
+
+
+cdef class Grid(Object):
+
+    def __init__(self, Canvas canvas not None):
+        self._set_obj(evas_object_grid_add(canvas.obj))
+
+    @classmethod
+    def add_to(cls, Object parent):
+        """Create a grid that is child of a given element @a parent."""
+        Object._set_obj(cls, evas_object_grid_add_to(parent.obj))
+
+    property grid_size:
+        """The virtual resolution for the grid
+
+        :type: (int **w**, int **h**)
+
+        """
+
+    cpdef grid_size_set(self, int w, int h):
+        evas_object_grid_size_set(self.obj, w, h)
+
+    cpdef grid_size_get(self):
+        cdef int w, h
+        evas_object_grid_size_get(self.obj, &w, &h)
+        return (w, h)
+
+    property mirrored:
+        """The mirrored mode of the grid.
+
+        In mirrored mode the grid items go from right to left instead of left 
to
+        right. That is, 0,0 is top right, not top left.
+
+        :type: bool
+
+        """
+
+    cpdef mirrored_set(self, bint mirrored):
+        evas_object_grid_mirrored_set(self.obj, mirrored)
+
+    cpdef bint mirrored_get(self):
+        return bool(evas_object_grid_mirrored_get(self.obj))
+
+    def pack(self, Object child not None, int x, int y, int w, int h):
+        """pack(Object child, int x, int y, int w, int h)
+
+        Add a new child to a grid object.
+
+        :param child: The child object to add.
+        :param x: The virtual x coordinate of the child
+        :param y: The virtual y coordinate of the child
+        :param w: The virtual width of the child
+        :param h: The virtual height of the child
+        :raise RuntimeError: if the child could not be packed to the grid.
+
+        """
+        if not evas_object_grid_pack(self.obj, child.obj, x, y, w, h):
+            raise RuntimeError("Could not pack child to grid.")
+
+    def unpack(self, Object child not None):
+        """unpack(Object child)
+
+        Remove child from grid.
+
+        :param child:
+        :raise RuntimeError: if removing the child fails.
+
+        .. note::
+
+            removing a child will immediately call a walk over children in 
order
+            to recalculate numbers of columns and rows. If you plan to remove
+            all children, use evas_object_grid_clear() instead.
+
+        """
+        if not evas_object_grid_unpack(self.obj, child.obj):
+            raise RuntimeError("Could not remove child from grid.")
+
+    def clear(self, bint clear):
+        """clear(bool clear)
+
+        Faster way to remove all child objects from a grid object.
+
+        :param clear: if True, it will delete just removed children.
+
+        """
+        evas_object_grid_clear(self.obj, clear)
+
+    def pack_get(self, Object child not None):
+        """pack_get(Object child) -> tuple
+
+        Get the pack options for a grid child
+
+        Get the pack x, y, width and height in virtual coordinates set by
+        evas_object_grid_pack()
+
+        :param child: The grid child to query for coordinates
+        :return: (int **x**, int **y**, int **w**, int **h**)
+        :raise RuntimeError: if packing information could not be fetched.
+
+        """
+        cdef int x, y, w, h
+        if not evas_object_grid_pack_get(self.obj, child.obj, &x, &y, &w, &h):
+            raise RuntimeError("Could not get packing information for child.")
+        else:
+            return (x, y, w, h)
+
+    property children:
+        """Get the list of children for the grid.
+
+        :type: list
+
+        """
+
+    cpdef children_get(self):
+        cdef:
+            Eina_List *lst = evas_object_grid_children_get(self.obj)
+            list ret = _object_list_to_python(lst)
+        eina_list_free(lst)
+        return ret
diff --git a/include/efl.evas.pxd b/include/efl.evas.pxd
index 58029b9..436374d 100644
--- a/include/efl.evas.pxd
+++ b/include/efl.evas.pxd
@@ -848,6 +848,23 @@ cdef extern from "Evas.h":
     Eina_List                         
*evas_object_table_children_get(const_Evas_Object *o)
     Evas_Object                       
*evas_object_table_child_get(const_Evas_Object *o, unsigned short col, unsigned 
short row)
 
+    ####################################################################
+    # Grid
+    #
+    Evas_Object   *evas_object_grid_add(Evas *evas)
+    Evas_Object   *evas_object_grid_add_to(Evas_Object *parent)
+    void           evas_object_grid_size_set(Evas_Object *o, int w, int h)
+    void           evas_object_grid_size_get(const_Evas_Object *o, int *w, int 
*h)
+    void           evas_object_grid_mirrored_set(Evas_Object *o, Eina_Bool 
mirrored)
+    Eina_Bool      evas_object_grid_mirrored_get(const_Evas_Object *o)
+    Eina_Bool      evas_object_grid_pack(Evas_Object *o, Evas_Object *child, 
int x, int y, int w, int h)
+    Eina_Bool      evas_object_grid_unpack(Evas_Object *o, Evas_Object *child)
+    void           evas_object_grid_clear(Evas_Object *o, Eina_Bool clear)
+    Eina_Bool      evas_object_grid_pack_get(const_Evas_Object *o, Evas_Object 
*child, int *x, int *y, int *w, int *h)
+    # FIXME: Is this needed? Eina_Iterator 
*evas_object_grid_iterator_new(const_Evas_Object *o)
+    # FIXME: Is this needed? Eina_Accessor 
*evas_object_grid_accessor_new(const_Evas_Object *o)
+    Eina_List     *evas_object_grid_children_get(const_Evas_Object *o)
+
 
 ####################################################################
 # Python classes

-- 

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter

Reply via email to