2 * $Id: rb_evas_object.c 2 2004-06-19 18:55:39Z tilman $
4 * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "rb_evas_object.h"
27 #define GET_OBJ(obj, type, o, desc) \
30 Data_Get_Struct ((obj), type *, (o)); \
33 rb_raise (rb_eException, desc " destroyed already"); \
39 /* called by the child classes */
40 void c_evas_object_free (Evas_Object **e)
48 void c_evas_object_mark (Evas_Object **e)
52 parent = rb_hash_aref (parents, INT2NUM ((long) (e)));
57 static VALUE c_init (VALUE self, VALUE parent)
59 GET_OBJ (self, Evas_Object, e, "EvasObject");
61 rb_hash_aset (parents, INT2NUM ((long) e), parent);
66 static VALUE c_delete (VALUE self)
68 GET_OBJ (self, Evas_Object, e, "EvasObject");
78 static VALUE c_resize (VALUE self, VALUE w, VALUE h)
80 GET_OBJ (self, Evas_Object, e, "EvasObject");
82 Check_Type (w, T_FIXNUM);
83 Check_Type (h, T_FIXNUM);
85 evas_object_resize (*e, (Evas_Coord) FIX2INT (w),
86 (Evas_Coord) FIX2INT (h));
91 static VALUE c_show (VALUE self)
93 GET_OBJ (self, Evas_Object, e, "EvasObject");
95 evas_object_show (*e);
100 static VALUE c_hide (VALUE self)
102 GET_OBJ (self, Evas_Object, e, "EvasObject");
104 evas_object_hide (*e);
109 static VALUE c_is_visible (VALUE self)
111 GET_OBJ (self, Evas_Object, e, "EvasObject");
113 return evas_object_visible_get (*e) ? Qtrue : Qfalse;
116 void Init_EvasObject (void)
118 cEvasObject = rb_define_class ("EvasObject", rb_cObject);
120 rb_define_private_method (rb_singleton_class (cEvasObject),
123 rb_define_method (cEvasObject, "initialize", c_init, 1);
124 rb_define_method (cEvasObject, "delete", c_delete, 0);
125 rb_define_method (cEvasObject, "resize", c_resize, 2);
126 rb_define_method (cEvasObject, "show", c_show, 0);
127 rb_define_method (cEvasObject, "hide", c_hide, 0);
128 rb_define_method (cEvasObject, "visible?", c_is_visible, 0);
130 parents = rb_hash_new ();
131 rb_global_variable (&parents);