2 * $Id: rb_evas.c 23 2004-06-26 22:55:31Z 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_main.h"
27 #include "rb_evas_object.h"
31 static void c_mark (Evas **e)
35 parent = rb_hash_aref (parents, INT2NUM ((long) (e)));
40 VALUE TO_EVAS (VALUE parent, Evas *e)
45 if (NIL_P (parent) || !e)
48 self = Data_Make_Struct (cEvas, Evas *,
52 rb_hash_aset (parents, INT2NUM ((long) my_e), parent);
54 rb_obj_call_init (self, 0, NULL);
59 static VALUE c_render (VALUE self)
61 GET_OBJ (self, Evas, e, "Evas");
68 static VALUE c_font_path_clear (VALUE self)
70 GET_OBJ (self, Evas, e, "Evas");
72 evas_font_path_clear (*e);
77 static VALUE c_font_path_append (VALUE self, VALUE path)
79 GET_OBJ (self, Evas, e, "Evas");
81 Check_Type (path, T_STRING);
83 evas_font_path_append (*e, StringValuePtr (path));
88 static VALUE c_font_path_prepend (VALUE self, VALUE path)
90 GET_OBJ (self, Evas, e, "Evas");
92 Check_Type (path, T_STRING);
94 evas_font_path_append (*e, StringValuePtr (path));
99 static VALUE c_font_path_get (VALUE self)
102 const Evas_List *list, *l;
104 GET_OBJ (self, Evas, e, "Evas");
106 if (!(list = evas_font_path_list (*e)))
107 return rb_ary_new ();
109 ary = rb_ary_new2 (evas_list_count ((Evas_List *) list));
111 for (l = list; l; l = l->next)
112 rb_ary_push (ary, rb_str_new2 (l->data));
117 static VALUE c_font_cache_get (VALUE self)
119 GET_OBJ (self, Evas, e, "Evas");
121 return INT2FIX (evas_font_cache_get (*e));
124 static VALUE c_font_cache_set (VALUE self, VALUE val)
126 GET_OBJ (self, Evas, e, "Evas");
128 Check_Type (val, T_FIXNUM);
130 evas_font_cache_set (*e, FIX2INT (val));
135 static VALUE c_font_cache_flush (VALUE self)
137 GET_OBJ (self, Evas, e, "Evas");
139 evas_font_cache_flush (*e);
144 static VALUE c_image_cache_get (VALUE self)
146 GET_OBJ (self, Evas, e, "Evas");
148 return INT2FIX (evas_image_cache_get (*e));
151 static VALUE c_image_cache_set (VALUE self, VALUE val)
153 GET_OBJ (self, Evas, e, "Evas");
155 Check_Type (val, T_FIXNUM);
157 evas_image_cache_set (*e, FIX2INT (val));
162 static VALUE c_image_cache_reload (VALUE self)
164 GET_OBJ (self, Evas, e, "Evas");
166 evas_image_cache_reload (*e);
171 static VALUE c_image_cache_flush (VALUE self)
173 GET_OBJ (self, Evas, e, "Evas");
175 evas_image_cache_flush (*e);
180 static VALUE c_top_get (VALUE self)
185 GET_OBJ (self, Evas, e, "Evas");
187 if (!(o = evas_object_top_get (*e)))
190 if (!(obj = evas_object_data_get (o, RUBY_EVAS_OBJECT_KEY))) {
191 rb_raise (rb_eException, "EvasObject Ruby object key missing");
198 static VALUE c_bottom_get (VALUE self)
203 GET_OBJ (self, Evas, e, "Evas");
205 if (!(o = evas_object_bottom_get (*e)))
208 if (!(obj = evas_object_data_get (o, RUBY_EVAS_OBJECT_KEY))) {
209 rb_raise (rb_eException, "EvasObject Ruby object key missing");
216 static VALUE c_find_object (VALUE self, VALUE name)
221 GET_OBJ (self, Evas, e, "Evas");
223 Check_Type (name, T_STRING);
225 if (!(o = evas_object_name_find (*e, StringValuePtr (name))))
228 if (!(obj = evas_object_data_get (o, RUBY_EVAS_OBJECT_KEY))) {
229 rb_raise (rb_eException, "EvasObject Ruby object key missing");
236 void Init_Evas (void)
238 cEvas = rb_define_class_under (mEvas, "Evas", rb_cObject);
240 /* not publically instantiable yet */
241 rb_define_private_method (rb_singleton_class (cEvas),
243 rb_define_method (cEvas, "render", c_render, 0);
244 rb_define_method (cEvas, "font_path_clear", c_font_path_clear, 0);
245 rb_define_method (cEvas, "font_path_append", c_font_path_append, 1);
246 rb_define_method (cEvas, "font_path_prepend", c_font_path_prepend, 1);
247 rb_define_method (cEvas, "font_path", c_font_path_get, 0);
248 rb_define_method (cEvas, "font_cache", c_font_cache_get, 0);
249 rb_define_method (cEvas, "font_cache=", c_font_cache_set, 1);
250 rb_define_method (cEvas, "font_cache_flush",
251 c_font_cache_flush, 0);
252 rb_define_method (cEvas, "image_cache", c_image_cache_get, 0);
253 rb_define_method (cEvas, "image_cache=", c_image_cache_set, 1);
254 rb_define_method (cEvas, "image_cache_reload",
255 c_image_cache_reload, 0);
256 rb_define_method (cEvas, "image_cache_flush",
257 c_image_cache_flush, 0);
258 rb_define_method (cEvas, "top", c_top_get, 0);
259 rb_define_method (cEvas, "bottom", c_bottom_get, 0);
260 rb_define_method (cEvas, "find_object", c_find_object, 1);
262 parents = rb_hash_new ();
263 rb_global_variable (&parents);