summaryrefslogtreecommitdiff
path: root/efl/edje/efl.edje_edit_part.pxi
blob: 8332cfbecc1186cf6bdce9ea767e51395a11a4cc (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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# 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 Part(object):
    cdef EdjeEdit edje
    cdef object name

    def __init__(self, EdjeEdit e, name):
        if isinstance(name, unicode): name = name.encode("UTF-8")
        self.edje = e
        self.name = name

    property name:
        def __get__(self):
            return self.name.decode('UTF-8', 'strict')
        def __set__(self, name):
            self.rename(name)

    def rename(self, newname):
        cdef Eina_Bool ret
        if isinstance(newname, unicode): newname = newname.encode("UTF-8")
        ret = edje_edit_part_name_set(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL,
                    <const_char *>newname if newname is not None else NULL)
        if ret == 0:
            return False
        self.name = newname
        return True

    def above_get(self):
        cdef:
            const_char *part
            object ret
        part = edje_edit_part_above_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL)
        ret = _ctouni(part)
        edje_edit_string_free(part)
        return ret

    def below_get(self):
        cdef:
            const_char *part
            object ret
        part = edje_edit_part_below_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL)
        ret = _ctouni(part)
        edje_edit_string_free(part)
        return ret

    def restack_below(self):
        return bool(edje_edit_part_restack_below(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL))

    def restack_above(self):
        return bool(edje_edit_part_restack_above(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL))

    property type:
        def __get__(self):
            return edje_edit_part_type_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL)


    property states:
        def __get__(self):
            cdef Eina_List *lst
            lst = edje_edit_part_states_list_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL)
            ret = convert_eina_list_strings_to_python_list(lst)
            edje_edit_string_list_free(lst)
            return ret

    def state_get(self, sname, double value=0.0):
        if self.state_exist(sname, value):
            return State(self, sname, value)

    def state_add(self, sname, double value=0.0):
        if isinstance(sname, unicode): sname = sname.encode("UTF-8")
        return bool(edje_edit_state_add(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL,
                    <const_char *>sname if sname is not None else NULL,
                    value))

    def state_del(self, sname, double value=0.0):
        if isinstance(sname, unicode): sname = sname.encode("UTF-8")
        return bool(edje_edit_state_del(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL,
                    <const_char *>sname if sname is not None else NULL,
                    value))

    def state_exist(self, sname, double value=0.0):
        if isinstance(sname, unicode): sname = sname.encode("UTF-8")
        return bool(edje_edit_state_exist(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL,
                    <const_char *>sname if sname is not None else NULL,
                    value))

    def state_copy(self, sfrom, double vfrom, sto, double vto):
        if isinstance(sfrom, unicode): sfrom = sfrom.encode("UTF-8")
        if isinstance(sto, unicode): sto = sto.encode("UTF-8")
        return bool(edje_edit_state_copy(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL,
                    <const_char *>sfrom if sfrom is not None else NULL, vfrom,
                    <const_char *>sto if sto is not None else NULL, vto))

    def state_selected_get(self):
        cdef const_char *sel
        cdef double val
        sel = edje_edit_part_selected_state_get(self.edje.obj,
               <const_char *>self.name if self.name is not None else NULL, &val)
        if sel == NULL: return None
        r = _ctouni(sel)
        v = val
        edje_edit_string_free(sel)
        return (r, v)

    def state_selected_set(self, state, double value=0.0):
        if isinstance(state, unicode): state = state.encode("UTF-8")
        edje_edit_part_selected_state_set(self.edje.obj,
                <const_char *>self.name if self.name is not None else NULL,
                <const_char *>state if state is not None else NULL,
                value)

    property clip_to:
        def __get__(self):
            cdef const_char *clipper
            clipper = edje_edit_part_clip_to_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL)
            ret = _ctouni(clipper)
            edje_edit_string_free(clipper)
            return ret

        def __set__(self, clipper):
            if isinstance(clipper, unicode): clipper = clipper.encode("UTF-8")
            edje_edit_part_clip_to_set(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL,
                    <const_char *>clipper if clipper is not None else NULL)

        def __del__(self):
            edje_edit_part_clip_to_set(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL,
                    NULL)

    property source:
        def __get__(self):
            cdef const_char *source
            source = edje_edit_part_source_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL)
            ret = _ctouni(source)
            edje_edit_string_free(source)
            return ret

        def __set__(self, source):
            if isinstance(source, unicode): source = source.encode("UTF-8")
            edje_edit_part_source_set(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL,
                    <const_char *>source if source is not None else NULL)

        def __del__(self):
            edje_edit_part_source_set(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL,
                    NULL)

    property mouse_events:
        def __get__(self):
            return bool(edje_edit_part_mouse_events_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL))

        def __set__(self, me):
            edje_edit_part_mouse_events_set(self.edje.obj,
                <const_char *>self.name if self.name is not None else NULL,
                1 if me else 0)

    property repeat_events:
        def __get__(self):
            return bool(edje_edit_part_repeat_events_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL))

        def __set__(self, re):
            edje_edit_part_repeat_events_set(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL,
                    1 if re else 0)

    property effect:
        def __get__(self):
            return edje_edit_part_effect_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL)

        def __set__(self, effect):
            edje_edit_part_effect_set(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL,
                    effect)

    property ignore_flags:
        def __get__(self):
            return edje_edit_part_ignore_flags_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL)

        def __set__(self, flags):
            edje_edit_part_ignore_flags_set(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL,
                    flags)

    property scale:
        def __get__(self):
            return bool(edje_edit_part_scale_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL))

        def __set__(self, scale):
            edje_edit_part_scale_set(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL,
                    1 if scale else 0)

    property drag:
        def __get__(self):
            cdef int x, y
            x = edje_edit_part_drag_x_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL)
            y = edje_edit_part_drag_y_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL)
            return (x, y)

        def __set__(self, val):
            x, y = val
            edje_edit_part_drag_x_set(self.edje.obj,
                <const_char *>self.name if self.name is not None else NULL, x)
            edje_edit_part_drag_y_set(self.edje.obj,
                <const_char *>self.name if self.name is not None else NULL, y)

    property drag_step:
        def __get__(self):
            cdef int x, y
            x = edje_edit_part_drag_step_x_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL)
            y = edje_edit_part_drag_step_y_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL)
            return (x, y)

        def __set__(self, val):
            x, y = val
            edje_edit_part_drag_step_x_set(self.edje.obj,
                <const_char *>self.name if self.name is not None else NULL, x)
            edje_edit_part_drag_step_y_set(self.edje.obj,
                <const_char *>self.name if self.name is not None else NULL, y)

    property drag_count:
        def __get__(self):
            cdef int x, y
            x = edje_edit_part_drag_count_x_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL)
            y = edje_edit_part_drag_count_y_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL)
            return (x, y)

        def __set__(self, val):
            x, y = val
            edje_edit_part_drag_count_x_set(self.edje.obj,
                <const_char *>self.name if self.name is not None else NULL, x)
            edje_edit_part_drag_count_y_set(self.edje.obj,
                <const_char *>self.name if self.name is not None else NULL, y)

    property drag_confine:
        def __get__(self):
            cdef const_char *confine
            confine = edje_edit_part_drag_confine_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL)
            ret = _ctouni(confine)
            edje_edit_string_free(confine)
            return ret

        def __set__(self, confine):
            if isinstance(confine, unicode): confine = confine.encode("UTF-8")
            edje_edit_part_drag_confine_set(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL,
                    <const_char *>confine if confine is not None else NULL)

    property drag_event:
        def __get__(self):
            cdef const_char *event
            event = edje_edit_part_drag_event_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL)
            ret = _ctouni(event)
            edje_edit_string_free(event)
            return ret

        def __set__(self, event):
            if isinstance(event, unicode): event = event.encode("UTF-8")
            edje_edit_part_drag_event_set(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL,
                    <const_char *>event if event is not None else NULL)

    property api:
        def __get__(self):
            cdef:
                const_char *name
                const_char *description
            name = edje_edit_part_api_name_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL)
            description = edje_edit_part_api_description_get(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL)
            n, d = _ctouni(name), _ctouni(description)
            edje_edit_string_free(name)
            edje_edit_string_free(description)
            return (n, d)

        def __set__(self, value):
            cdef object name, desc
            name, desc = value
            if isinstance(name, unicode): name = name.encode("UTF-8")
            if isinstance(desc, unicode): desc = desc.encode("UTF-8")
            edje_edit_part_api_name_set(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL,
                    <const_char *>name if name is not None else NULL)
            edje_edit_part_api_description_set(self.edje.obj,
                    <const_char *>self.name if self.name is not None else NULL,
                    <const_char *>desc if desc is not None else NULL)