2 * $Id: rb_ecore_evas.c 9 2004-06-19 19:53:47Z 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
23 #include <Ecore_Evas.h>
26 #include "rb_ecore_evas_main.h"
27 #include "rb_ecore_evas.h"
29 #define GET_OBJ(obj, ee) \
30 Ecore_Evas **(ee) = NULL; \
32 Data_Get_Struct ((obj), Ecore_Evas *, (ee)); \
35 rb_raise (rb_eException, "EcoreEvas destroyed already"); \
39 /* called by the child classes */
40 void c_ecore_evas_free (Ecore_Evas **ee)
43 ecore_evas_free (*ee);
49 static VALUE c_init (int argc, VALUE argv, VALUE self)
51 rb_iv_set (self, "@title", rb_str_new2 (""));
52 rb_iv_set (self, "@name", rb_str_new2 (""));
53 rb_iv_set (self, "@class", rb_str_new2 (""));
54 rb_iv_set (self, "@name", rb_str_new2 (""));
60 static VALUE c_show (VALUE self)
64 ecore_evas_show (*ee);
69 static VALUE c_hide (VALUE self)
73 ecore_evas_hide (*ee);
78 static VALUE c_is_visible (VALUE self)
82 return ecore_evas_visibility_get (*ee) ? Qtrue : Qfalse;
85 static VALUE c_evas (VALUE self)
89 return TO_EVAS (self, ecore_evas_get (*ee));
92 static VALUE c_resize (VALUE self, VALUE w, VALUE h)
96 Check_Type (w, T_FIXNUM);
97 Check_Type (h, T_FIXNUM);
99 ecore_evas_resize (*ee, FIX2INT (w), FIX2INT (h));
104 static VALUE c_title_get (VALUE self)
110 if (!(tmp = ecore_evas_title_get (*ee)))
113 return rb_str_new2 (tmp);
116 static VALUE c_title_set (VALUE self, VALUE val)
120 Check_Type (val, T_STRING);
122 ecore_evas_title_set (*ee, STR2CSTR (val));
127 static VALUE c_borderless_get (VALUE self)
131 return ecore_evas_borderless_get (*ee) ? Qtrue : Qfalse;
134 static VALUE c_borderless_set (VALUE self, VALUE val)
138 /* make sure we're passed a boolean */
139 if (TYPE (val) != T_TRUE && TYPE (val) != T_FALSE) {
140 rb_raise (rb_eTypeError,
141 "wrong argument type %s (expected true or false)",
142 rb_obj_classname (val));
146 ecore_evas_borderless_set (*ee, val == Qtrue ? 1 : 0);
151 static VALUE c_delete (VALUE self)
155 /* reap our children */
158 ecore_evas_free (*ee);
164 void Init_EcoreEvas (void)
166 cEcoreEvas = rb_define_class_under (mEvas, "EcoreEvas", rb_cObject);
168 rb_define_private_method (rb_singleton_class (cEcoreEvas),
170 /*rb_define_method (cEcoreEvas, "initialize", c_init, -1);*/
171 rb_define_method (cEcoreEvas, "delete", c_delete, 0);
172 rb_define_method (cEcoreEvas, "show", c_show, 0);
173 rb_define_method (cEcoreEvas, "hide", c_hide, 0);
174 rb_define_method (cEcoreEvas, "visible?", c_is_visible, 0);
175 rb_define_method (cEcoreEvas, "evas", c_evas, 0);
176 rb_define_method (cEcoreEvas, "resize", c_resize, 2);
177 rb_define_method (cEcoreEvas, "title", c_title_get, 0);
178 rb_define_method (cEcoreEvas, "title=", c_title_set, 1);
179 rb_define_method (cEcoreEvas, "borderless", c_borderless_get, 0);
180 rb_define_method (cEcoreEvas, "borderless=", c_borderless_set, 1);