2 * $Id: rb_evas.c 49 2004-08-01 10:17: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
26 #include "rb_evas_main.h"
28 #include "rb_evas_object.h"
32 static void c_mark (RbEvas *e)
34 rb_gc_mark (e->parent);
37 VALUE TO_EVAS (VALUE parent, Evas *e)
42 if (NIL_P (parent) || !e)
45 self = Data_Make_Struct (cEvas, RbEvas,
48 evas->parent = parent;
50 rb_obj_call_init (self, 0, NULL);
55 static VALUE c_inspect (VALUE self)
57 INSPECT (self, RbEvas);
60 static VALUE c_render (VALUE self)
62 GET_OBJ (self, RbEvas, e);
64 evas_render (e->real);
69 static VALUE c_font_path_clear (VALUE self)
71 GET_OBJ (self, RbEvas, e);
73 evas_font_path_clear (e->real);
78 static VALUE c_font_path_append (VALUE self, VALUE path)
80 GET_OBJ (self, RbEvas, e);
82 Check_Type (path, T_STRING);
84 evas_font_path_append (e->real, StringValuePtr (path));
89 static VALUE c_font_path_prepend (VALUE self, VALUE path)
91 GET_OBJ (self, RbEvas, e);
93 Check_Type (path, T_STRING);
95 evas_font_path_append (e->real, StringValuePtr (path));
100 static VALUE c_font_path_get (VALUE self)
103 const Evas_List *list, *l;
105 GET_OBJ (self, RbEvas, e);
107 if (!(list = evas_font_path_list (e->real)))
108 return rb_ary_new ();
110 ary = rb_ary_new2 (evas_list_count ((Evas_List *) list));
112 for (l = list; l; l = l->next)
113 rb_ary_push (ary, rb_str_new2 (l->data));
118 static VALUE c_font_cache_get (VALUE self)
120 GET_OBJ (self, RbEvas, e);
122 return INT2FIX (evas_font_cache_get (e->real));
125 static VALUE c_font_cache_set (VALUE self, VALUE val)
127 GET_OBJ (self, RbEvas, e);
129 Check_Type (val, T_FIXNUM);
131 evas_font_cache_set (e->real, FIX2INT (val));
136 static VALUE c_font_cache_flush (VALUE self)
138 GET_OBJ (self, RbEvas, e);
140 evas_font_cache_flush (e->real);
145 static VALUE c_image_cache_get (VALUE self)
147 GET_OBJ (self, RbEvas, e);
149 return INT2FIX (evas_image_cache_get (e->real));
152 static VALUE c_image_cache_set (VALUE self, VALUE val)
154 GET_OBJ (self, RbEvas, e);
156 Check_Type (val, T_FIXNUM);
158 evas_image_cache_set (e->real, FIX2INT (val));
163 static VALUE c_image_cache_reload (VALUE self)
165 GET_OBJ (self, RbEvas, e);
167 evas_image_cache_reload (e->real);
172 static VALUE c_image_cache_flush (VALUE self)
174 GET_OBJ (self, RbEvas, e);
176 evas_image_cache_flush (e->real);
181 static VALUE c_top_get (VALUE self)
186 GET_OBJ (self, RbEvas, e);
188 if (!(o = evas_object_top_get (e->real)))
191 if (!(obj = evas_object_data_get (o, RUBY_EVAS_OBJECT_KEY))) {
192 rb_raise (rb_eException, "EvasObject Ruby object key missing");
199 static VALUE c_bottom_get (VALUE self)
204 GET_OBJ (self, RbEvas, e);
206 if (!(o = evas_object_bottom_get (e->real)))
209 if (!(obj = evas_object_data_get (o, RUBY_EVAS_OBJECT_KEY))) {
210 rb_raise (rb_eException, "EvasObject Ruby object key missing");
217 static VALUE c_find_object (VALUE self, VALUE name)
222 GET_OBJ (self, RbEvas, e);
224 Check_Type (name, T_STRING);
226 if (!(o = evas_object_name_find (e->real, StringValuePtr (name))))
229 if (!(obj = evas_object_data_get (o, RUBY_EVAS_OBJECT_KEY))) {
230 rb_raise (rb_eException, "EvasObject Ruby object key missing");
237 void Init_Evas (void)
239 cEvas = rb_define_class_under (mEvas, "Evas", rb_cObject);
241 /* not publically instantiable yet */
242 rb_define_private_method (rb_singleton_class (cEvas),
244 rb_define_method (cEvas, "inspect", c_inspect, 0);
245 rb_define_method (cEvas, "render", c_render, 0);
246 rb_define_method (cEvas, "font_path_clear", c_font_path_clear, 0);
247 rb_define_method (cEvas, "font_path_append", c_font_path_append, 1);
248 rb_define_method (cEvas, "font_path_prepend", c_font_path_prepend, 1);
249 rb_define_method (cEvas, "font_path", c_font_path_get, 0);
250 rb_define_method (cEvas, "font_cache", c_font_cache_get, 0);
251 rb_define_method (cEvas, "font_cache=", c_font_cache_set, 1);
252 rb_define_method (cEvas, "font_cache_flush",
253 c_font_cache_flush, 0);
254 rb_define_method (cEvas, "image_cache", c_image_cache_get, 0);
255 rb_define_method (cEvas, "image_cache=", c_image_cache_set, 1);
256 rb_define_method (cEvas, "image_cache_reload",
257 c_image_cache_reload, 0);
258 rb_define_method (cEvas, "image_cache_flush",
259 c_image_cache_flush, 0);
260 rb_define_method (cEvas, "top", c_top_get, 0);
261 rb_define_method (cEvas, "bottom", c_bottom_get, 0);
262 rb_define_method (cEvas, "find_object", c_find_object, 1);