summaryrefslogtreecommitdiff
path: root/elementary/elementary.c_elementary_table.pxi
blob: c92ea052c95e1bba5bc975a497a6e1ab02077455 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# Copyright (c) 2008-2009 Simon Busch
#
# This file is part of python-elementary.
#
# python-elementary 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 3 of the License, or
# (at your option) any later version.
#
# python-elementary 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 python-elementary.  If not, see <http://www.gnu.org/licenses/>.
#

cdef public class Table(Object) [object PyElementaryTable, type PyElementaryTable_Type]:

    """A container widget to arrange other widgets in a table where items can
    span multiple columns or rows - even overlap (and then be raised or
    lowered accordingly to adjust stacking if they do overlap).

    The row and column count is not fixed. The table widget adjusts itself when
    subobjects are added to it dynamically.

    The most common way to use a table is::
        table = Table(win)
        table.show()
        table.padding_set(table, space_between_columns, space_between_rows)
        table.pack(table_content_object, x_coord, y_coord, colspan, rowspan)
        table.pack(table_content_object, next_x_coord, next_y_coord, colspan, rowspan)
        table.pack(table_content_object, other_x_coord, other_y_coord, colspan, rowspan)

    """

    def __init__(self, evasObject parent):
        Object.__init__(self, parent.evas)
        self._set_obj(elm_table_add(parent.obj))

    def homogeneous_set(self, homogeneous):
        """Set the homogeneous layout in the table

        @param homogeneous: A boolean to set if the layout is homogeneous in
            the table (True = homogeneous,  False = no homogeneous)
        @type homogeneous: bool

        """
        elm_table_homogeneous_set(self.obj, homogeneous)

    def homogeneous_get(self):
        """Get the current table homogeneous mode.

        @return: A boolean to indicating if the layout is homogeneous in the
            table (True = homogeneous,  False = no homogeneous)
        @rtype: bool

        """
        return elm_table_homogeneous_get(self.obj)

    property homogeneous:
        """The homogeneous layout in the table

        @type: bool

        """
        def __get__(self):
            return elm_table_homogeneous_get(self.obj)

        def __set__(self, homogeneous):
            elm_table_homogeneous_set(self.obj, homogeneous)

    def padding_set(self, horizontal, vertical):
        """Set padding between cells.

        Default value is 0.

        @param horizontal: set the horizontal padding.
        @type horizontal: Evas_Coord (int)
        @param vertical: set the vertical padding.
        @type vertical: Evas_Coord (int)

        """
        elm_table_padding_set(self.obj, horizontal, vertical)

    def padding_get(self):
        """Get padding between cells.

        @return: The horizontal and vertical padding
        @rtype: tuple of Evas_Coords (int)

        """
        cdef Evas_Coord horizontal, vertical
        elm_table_padding_get(self.obj, &horizontal, &vertical)
        return (horizontal, vertical)

    property padding:
        """Padding between cells.

        Default value is 0.

        @type: (int, int)

        """
        def __get__(self):
            cdef Evas_Coord horizontal, vertical
            elm_table_padding_get(self.obj, &horizontal, &vertical)
            return (horizontal, vertical)

        def __set__(self, value):
            horizontal, vertical = value
            elm_table_padding_set(self.obj, horizontal, vertical)

    def pack(self, evasObject subobj, x, y, w, h):
        """pack(subobj, x, y, w, h)

        Add a subobject on the table with the coordinates passed

        @note: All positioning inside the table is relative to rows and
            columns, so a value of 0 for x and y, means the top left cell of
            the table, and a value of 1 for w and h means C{subobj} only
            takes that 1 cell.

        @param subobj: The subobject to be added to the table
        @type subobj: L{Object}
        @param x: Row number
        @type x: int
        @param y: Column number
        @type y: int
        @param w: colspan
        @type w: int
        @param h: rowspan
        @type h: int

        """
        elm_table_pack(self.obj, subobj.obj, x, y, w, h)

    def unpack(self, evasObject subobj):
        """unpack(subobj)

        Remove child from table.

        @param subobj: The subobject
        @type subobj: L{Object}

        """
        elm_table_unpack(self.obj, subobj.obj)

    def clear(self, clear):
        """clear(clear)

        Faster way to remove all child objects from a table object.

        @param clear: If True, will delete children, else just remove from table.
        @type clear: bool

        """
        elm_table_clear(self.obj, clear)

    def pack_set(evasObject subobj, x, y, w, h):
        """pack_set(subobj, x, y, w, h)

        Set the packing location of an existing child of the table

        Modifies the position of an object already in the table.

        @note: All positioning inside the table is relative to rows and
            columns, so a value of 0 for x and y, means the top left cell of
            the table, and a value of 1 for w and h means C{subobj} only
            takes that 1 cell.

        @param subobj: The subobject to be modified in the table
        @type subobj: L{Object}
        @param x: Row number
        @type x: int
        @param y: Column number
        @type y: int
        @param w: rowspan
        @type w: int
        @param h: colspan
        @type h: int

        """
        elm_table_pack_set(subobj.obj, x, y, w, h)

    def pack_get(evasObject subobj):
        """pack_get(subobj)

        Get the packing location of an existing child of the table

        @see: L{pack_set()}

        @param subobj: The subobject to be modified in the table
        @type subobj: L{Object}
        @return: Row number, Column number, rowspan, colspan
        @rtype: tuple of ints

        """
        cdef int x, y, w, h
        elm_table_pack_get(subobj.obj, &x, &y, &w, &h)
        return (x, y, w, h)

_elm_widget_type_register("table", Table)

cdef extern from "Elementary.h": # hack to force type to be known
    cdef PyTypeObject PyElementaryTable_Type # hack to install metaclass
_install_metaclass(&PyElementaryTable_Type, ElementaryObjectMeta)