-## $Id: Makefile.am 20 2004-06-22 20:46:56Z tilman $
+## $Id: Makefile.am 23 2004-06-26 22:55:31Z tilman $
AM_CFLAGS = $(EVAS_CFLAGS)
INCLUDES = -I$(RUBYDIR)
evas_la_SOURCES = rb_evas_main.c rb_evas_main.h \
rb_evas.c rb_evas.h \
- rb_evas_object.c rb_evas_object.h
+ rb_evas_object.c rb_evas_object.h \
+ rb_rectangle.c rb_rectangle.h \
+ rb_line.c rb_line.h \
+ rb_gradient.c rb_gradient.h \
+ rb_polygon.c rb_polygon.h \
+ rb_image.c rb_image.h \
+ rb_text.c rb_text.h
evas_la_LIBADD = -lruby $(EVAS_LIBS)
evas_la_LDFLAGS = -module -avoid-version
/*
- * $Id: rb_evas.c 20 2004-06-22 20:46:56Z tilman $
+ * $Id: rb_evas.c 23 2004-06-26 22:55:31Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
#include "rb_evas.h"
#include "rb_evas_object.h"
-#define GET_OBJ(obj, type, o, desc) \
- type **(o) = NULL; \
-\
- Data_Get_Struct ((obj), type *, (o)); \
-\
- if (!*(o)) { \
- rb_raise (rb_eException, desc " destroyed already"); \
- return Qnil; \
- }
-
static VALUE parents;
static void c_mark (Evas **e)
VALUE self;
Evas **my_e = NULL;
- if (parent == Qnil || !e)
+ if (NIL_P (parent) || !e)
return Qnil;
self = Data_Make_Struct (cEvas, Evas *,
return self;
}
+static VALUE c_render (VALUE self)
+{
+ GET_OBJ (self, Evas, e, "Evas");
+
+ evas_render (*e);
+
+ return Qnil;
+}
+
static VALUE c_font_path_clear (VALUE self)
{
GET_OBJ (self, Evas, e, "Evas");
/* not publically instantiable yet */
rb_define_private_method (rb_singleton_class (cEvas),
"new", NULL, 0);
+ rb_define_method (cEvas, "render", c_render, 0);
rb_define_method (cEvas, "font_path_clear", c_font_path_clear, 0);
rb_define_method (cEvas, "font_path_append", c_font_path_append, 1);
rb_define_method (cEvas, "font_path_prepend", c_font_path_prepend, 1);
/*
- * $Id: rb_evas_main.c 20 2004-06-22 20:46:56Z tilman $
+ * $Id: rb_evas_main.c 23 2004-06-26 22:55:31Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
#include "rb_evas_main.h"
#include "rb_evas.h"
#include "rb_evas_object.h"
+#include "rb_rectangle.h"
+#include "rb_line.h"
+#include "rb_gradient.h"
+#include "rb_polygon.h"
+#include "rb_image.h"
+#include "rb_text.h"
static VALUE m_shutdown (VALUE self)
{
Init_Evas ();
Init_EvasObject ();
+ Init_Rectangle ();
+ Init_Line ();
+ Init_Gradient ();
+ Init_Polygon ();
+ Init_Image ();
+ Init_Text ();
}
/*
- * $Id: rb_evas_main.h 20 2004-06-22 20:46:56Z tilman $
+ * $Id: rb_evas_main.h 23 2004-06-26 22:55:31Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
#ifndef __RB_EVAS_MAIN_H
#define __RB_EVAS_MAIN_H
+#define GET_OBJ(obj, type, o, desc) \
+ type **(o) = NULL; \
+\
+ Data_Get_Struct ((obj), type *, (o)); \
+\
+ if (!*(o)) { \
+ rb_raise (rb_eException, desc " destroyed already"); \
+ return Qnil; \
+ }
+
+#define CHECK_BOOL(val) \
+ if (TYPE ((val)) != T_TRUE && TYPE ((val)) != T_FALSE) { \
+ rb_raise (rb_eTypeError, \
+ "wrong argument type %s (expected true or false)", \
+ rb_obj_classname ((val))); \
+ return Qnil; \
+ }
+
VALUE mEvas;
#endif
/*
- * $Id: rb_evas_object.c 20 2004-06-22 20:46:56Z tilman $
+ * $Id: rb_evas_object.c 23 2004-06-26 22:55:31Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
#include "rb_evas.h"
#include "rb_evas_object.h"
-#define GET_OBJ(obj, type, o, desc) \
- type **(o) = NULL; \
-\
- Data_Get_Struct ((obj), type *, (o)); \
-\
- if (!*(o)) { \
- rb_raise (rb_eException, desc " destroyed already"); \
- return Qnil; \
- }
-
-#define CHECK_BOOL(val) \
- if (TYPE ((val)) != T_TRUE && TYPE ((val)) != T_FALSE) { \
- rb_raise (rb_eTypeError, \
- "wrong argument type %s (expected true or false)", \
- rb_obj_classname ((val))); \
- return Qnil; \
- }
-
static VALUE parents;
/* called by the child classes */
--- /dev/null
+/*
+ * $Id: rb_gradient.c 23 2004-06-26 22:55:31Z tilman $
+ *
+ * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ *
+ * This library 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.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <ruby.h>
+
+#include <Evas.h>
+
+#include "rb_evas_main.h"
+#include "rb_evas.h"
+#include "rb_evas_object.h"
+
+static VALUE c_new (VALUE klass, VALUE evas)
+{
+ VALUE self, argv[1];
+ Evas_Object **rect;
+
+ if (!rb_obj_is_kind_of (evas, cEvas)) {
+ rb_raise (rb_eTypeError,
+ "wrong argument type %s (expected Evas)",
+ rb_obj_classname (evas));
+ return Qnil;
+ }
+
+ GET_OBJ (evas, Evas, e, "Evas");
+
+ self = Data_Make_Struct (klass, Evas_Object *, c_evas_object_mark,
+ c_evas_object_free, rect);
+ *rect = evas_object_gradient_add (*e);
+
+ argv[0] = evas;
+ rb_obj_call_init (self, 1, argv);
+
+ return self;
+}
+
+static VALUE c_color_add (VALUE self, VALUE r, VALUE g, VALUE b,
+ VALUE a, VALUE distance)
+{
+ GET_OBJ (self, Evas_Object, e, "Gradient");
+
+ Check_Type (r, T_FIXNUM);
+ Check_Type (g, T_FIXNUM);
+ Check_Type (b, T_FIXNUM);
+ Check_Type (a, T_FIXNUM);
+ Check_Type (distance, T_FIXNUM);
+
+ evas_object_gradient_color_add (*e, FIX2INT (r), FIX2INT (g),
+ FIX2INT (b), FIX2INT (a),
+ FIX2INT (distance));
+
+ return Qnil;
+}
+
+static VALUE c_colors_clear (VALUE self)
+{
+ GET_OBJ (self, Evas_Object, e, "Gradient");
+
+ evas_object_gradient_colors_clear (*e);
+
+ return Qnil;
+}
+
+static VALUE c_angle_get (VALUE self)
+{
+ GET_OBJ (self, Evas_Object, e, "Gradient");
+
+ return INT2FIX (evas_object_gradient_angle_get (*e));
+}
+
+static VALUE c_angle_set (VALUE self, VALUE val)
+{
+ GET_OBJ (self, Evas_Object, e, "Gradient");
+
+ Check_Type (val, T_FIXNUM);
+
+ evas_object_gradient_angle_set (*e, FIX2INT (val));
+
+ return Qnil;
+}
+
+void Init_Gradient (void)
+{
+ VALUE cGradient = rb_define_class_under (mEvas, "Gradient",
+ cEvasObject);
+
+ rb_define_singleton_method (cGradient, "new", c_new, 1);
+ rb_define_method (cGradient, "color_add", c_color_add, 5);
+ rb_define_method (cGradient, "colors_clear", c_colors_clear, 0);
+ rb_define_method (cGradient, "angle", c_angle_get, 0);
+ rb_define_method (cGradient, "angle=", c_angle_set, 1);
+}
--- /dev/null
+/*
+ * $Id: rb_gradient.h 23 2004-06-26 22:55:31Z tilman $
+ *
+ * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ *
+ * This library 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.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __RB_GRADIENT_H
+#define __RB_GRADIENT_H
+
+void Init_Gradient (void);
+
+#endif
--- /dev/null
+/*
+ * $Id: rb_image.c 23 2004-06-26 22:55:31Z tilman $
+ *
+ * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ *
+ * This library 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.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <ruby.h>
+
+#include <Evas.h>
+
+#include "rb_evas_main.h"
+#include "rb_evas.h"
+#include "rb_evas_object.h"
+
+static VALUE c_new (VALUE klass, VALUE evas)
+{
+ VALUE self, argv[1];
+ Evas_Object **rect;
+
+ if (!rb_obj_is_kind_of (evas, cEvas)) {
+ rb_raise (rb_eTypeError,
+ "wrong argument type %s (expected Evas)",
+ rb_obj_classname (evas));
+ return Qnil;
+ }
+
+ GET_OBJ (evas, Evas, e, "Evas");
+
+ self = Data_Make_Struct (klass, Evas_Object *, c_evas_object_mark,
+ c_evas_object_free, rect);
+ *rect = evas_object_image_add (*e);
+
+ argv[0] = evas;
+ rb_obj_call_init (self, 1, argv);
+
+ return self;
+}
+
+void Init_Image (void)
+{
+ VALUE cImage = rb_define_class_under (mEvas, "Image", cEvasObject);
+
+ rb_define_singleton_method (cImage, "new", c_new, 1);
+}
--- /dev/null
+/*
+ * $Id: rb_image.h 23 2004-06-26 22:55:31Z tilman $
+ *
+ * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ *
+ * This library 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.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __RB_IMAGE_H
+#define __RB_IMAGE_H
+
+void Init_Image (void);
+
+#endif
--- /dev/null
+/*
+ * $Id: rb_line.c 23 2004-06-26 22:55:31Z tilman $
+ *
+ * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ *
+ * This library 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.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <ruby.h>
+
+#include <Evas.h>
+
+#include "rb_evas_main.h"
+#include "rb_evas.h"
+#include "rb_evas_object.h"
+
+static VALUE c_new (VALUE klass, VALUE evas)
+{
+ VALUE self, argv[1];
+ Evas_Object **rect;
+
+ if (!rb_obj_is_kind_of (evas, cEvas)) {
+ rb_raise (rb_eTypeError,
+ "wrong argument type %s (expected Evas)",
+ rb_obj_classname (evas));
+ return Qnil;
+ }
+
+ GET_OBJ (evas, Evas, e, "Evas");
+
+ self = Data_Make_Struct (klass, Evas_Object *, c_evas_object_mark,
+ c_evas_object_free, rect);
+ *rect = evas_object_line_add (*e);
+
+ argv[0] = evas;
+ rb_obj_call_init (self, 1, argv);
+
+ return self;
+}
+
+static VALUE c_get_xy (VALUE self)
+{
+ int coord[4] = {0, 0, 0, 0};
+
+ GET_OBJ (self, Evas_Object, e, "Line");
+
+ evas_object_line_xy_get (*e, &coord[0], &coord[1],
+ &coord[2], &coord[3]);
+
+ return rb_ary_new3 (4, INT2FIX (coord[0]), INT2FIX (coord[1]),
+ INT2FIX (coord[2]), INT2FIX (coord[3]));
+}
+
+static VALUE c_set_xy (VALUE self, VALUE x1, VALUE y1,
+ VALUE x2, VALUE y2)
+{
+ GET_OBJ (self, Evas_Object, e, "Line");
+
+ Check_Type (x1, T_FIXNUM);
+ Check_Type (y1, T_FIXNUM);
+ Check_Type (x2, T_FIXNUM);
+ Check_Type (y2, T_FIXNUM);
+
+ evas_object_line_xy_set (*e, FIX2INT (x1), FIX2INT (y1),
+ FIX2INT (x2), FIX2INT (y2));
+
+ return Qnil;
+}
+
+void Init_Line (void)
+{
+ VALUE cLine = rb_define_class_under (mEvas, "Line", cEvasObject);
+
+ rb_define_singleton_method (cLine, "new", c_new, 1);
+ rb_define_method (cLine, "get_xy", c_get_xy, 0);
+ rb_define_method (cLine, "set_xy", c_set_xy, 4);
+}
--- /dev/null
+/*
+ * $Id: rb_line.h 23 2004-06-26 22:55:31Z tilman $
+ *
+ * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ *
+ * This library 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.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __RB_LINE_H
+#define __RB_LINE_H
+
+void Init_Line (void);
+
+#endif
--- /dev/null
+/*
+ * $Id: rb_polygon.c 23 2004-06-26 22:55:31Z tilman $
+ *
+ * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ *
+ * This library 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.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <ruby.h>
+
+#include <Evas.h>
+
+#include "rb_evas_main.h"
+#include "rb_evas.h"
+#include "rb_evas_object.h"
+
+static VALUE c_new (VALUE klass, VALUE evas)
+{
+ VALUE self, argv[1];
+ Evas_Object **rect;
+
+ if (!rb_obj_is_kind_of (evas, cEvas)) {
+ rb_raise (rb_eTypeError,
+ "wrong argument type %s (expected Evas)",
+ rb_obj_classname (evas));
+ return Qnil;
+ }
+
+ GET_OBJ (evas, Evas, e, "Evas");
+
+ self = Data_Make_Struct (klass, Evas_Object *, c_evas_object_mark,
+ c_evas_object_free, rect);
+ *rect = evas_object_polygon_add (*e);
+
+ argv[0] = evas;
+ rb_obj_call_init (self, 1, argv);
+
+ return self;
+}
+
+static VALUE c_point_add (VALUE self, VALUE x, VALUE y)
+{
+ GET_OBJ (self, Evas_Object, e, "Polygon");
+
+ Check_Type (x, T_FIXNUM);
+ Check_Type (y, T_FIXNUM);
+
+ evas_object_polygon_point_add (*e, FIX2INT (x), FIX2INT (y));
+
+ return Qnil;
+}
+
+static VALUE c_points_clear (VALUE self)
+{
+ GET_OBJ (self, Evas_Object, e, "Polygon");
+
+ evas_object_polygon_points_clear (*e);
+
+ return Qnil;
+}
+
+void Init_Polygon (void)
+{
+ VALUE cPolygon = rb_define_class_under (mEvas, "Polygon",
+ cEvasObject);
+
+ rb_define_singleton_method (cPolygon, "new", c_new, 1);
+ rb_define_method (cPolygon, "point_add", c_point_add, 2);
+ rb_define_method (cPolygon, "points_clear", c_points_clear, 0);
+}
--- /dev/null
+/*
+ * $Id: rb_polygon.h 23 2004-06-26 22:55:31Z tilman $
+ *
+ * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ *
+ * This library 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.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __RB_POLYGON_H
+#define __RB_POLYGON_H
+
+void Init_Polygon (void);
+
+#endif
--- /dev/null
+/*
+ * $Id: rb_rectangle.c 23 2004-06-26 22:55:31Z tilman $
+ *
+ * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ *
+ * This library 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.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <ruby.h>
+
+#include <Evas.h>
+
+#include "rb_evas_main.h"
+#include "rb_evas.h"
+#include "rb_evas_object.h"
+
+static VALUE c_new (VALUE klass, VALUE evas)
+{
+ VALUE self, argv[1];
+ Evas_Object **rect;
+
+ if (!rb_obj_is_kind_of (evas, cEvas)) {
+ rb_raise (rb_eTypeError,
+ "wrong argument type %s (expected Evas)",
+ rb_obj_classname (evas));
+ return Qnil;
+ }
+
+ GET_OBJ (evas, Evas, e, "Evas");
+
+ self = Data_Make_Struct (klass, Evas_Object *, c_evas_object_mark,
+ c_evas_object_free, rect);
+ *rect = evas_object_rectangle_add (*e);
+
+ argv[0] = evas;
+ rb_obj_call_init (self, 1, argv);
+
+ return self;
+}
+
+void Init_Rectangle (void)
+{
+ VALUE cRect = rb_define_class_under (mEvas, "Rectangle",
+ cEvasObject);
+
+ rb_define_singleton_method (cRect, "new", c_new, 1);
+}
--- /dev/null
+/*
+ * $Id: rb_rectangle.h 23 2004-06-26 22:55:31Z tilman $
+ *
+ * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ *
+ * This library 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.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __RB_RECTANGLE_H
+#define __RB_RECTANGLE_H
+
+void Init_Rectangle (void);
+
+#endif
--- /dev/null
+/*
+ * $Id: rb_text.c 23 2004-06-26 22:55:31Z tilman $
+ *
+ * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ *
+ * This library 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.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <ruby.h>
+
+#include <Evas.h>
+
+#include "rb_evas_main.h"
+#include "rb_evas.h"
+#include "rb_evas_object.h"
+
+static VALUE c_new (VALUE klass, VALUE evas)
+{
+ VALUE self, argv[1];
+ Evas_Object **rect;
+
+ if (!rb_obj_is_kind_of (evas, cEvas)) {
+ rb_raise (rb_eTypeError,
+ "wrong argument type %s (expected Evas)",
+ rb_obj_classname (evas));
+ return Qnil;
+ }
+
+ GET_OBJ (evas, Evas, e, "Evas");
+
+ self = Data_Make_Struct (klass, Evas_Object *, c_evas_object_mark,
+ c_evas_object_free, rect);
+ *rect = evas_object_text_add (*e);
+
+ argv[0] = evas;
+ rb_obj_call_init (self, 1, argv);
+
+ return self;
+}
+
+static VALUE c_font_source_get (VALUE self)
+{
+ const char *tmp;
+
+ GET_OBJ (self, Evas_Object, e, "Text");
+
+ if (!(tmp = evas_object_text_font_source_get (*e)))
+ return Qnil;
+ else
+ return rb_str_new2 (tmp);
+}
+
+static VALUE c_font_source_set (VALUE self, VALUE val)
+{
+ GET_OBJ (self, Evas_Object, e, "Text");
+
+ Check_Type (val, T_STRING);
+
+ evas_object_text_font_source_set (*e, StringValuePtr (val));
+
+ return Qnil;
+}
+
+static VALUE c_get_font (VALUE self)
+{
+ char *font = NULL;
+ Evas_Font_Size size = 0;
+
+ GET_OBJ (self, Evas_Object, e, "Text");
+
+ evas_object_text_font_get (*e, &font, &size);
+
+ return rb_ary_new3 (2, font ? rb_str_new2 (font) : Qnil,
+ INT2FIX (size));
+}
+
+static VALUE c_set_font (VALUE self, VALUE font, VALUE size)
+{
+ GET_OBJ (self, Evas_Object, e, "Text");
+
+ Check_Type (font, T_STRING);
+ Check_Type (font, T_FIXNUM);
+
+ evas_object_text_font_set (*e, StringValuePtr (font),
+ FIX2INT (size));
+
+ return Qnil;
+}
+
+static VALUE c_text_get (VALUE self)
+{
+ const char *tmp;
+
+ GET_OBJ (self, Evas_Object, e, "Text");
+
+ if (!(tmp = evas_object_text_text_get (*e)))
+ return Qnil;
+ else
+ return rb_str_new2 (tmp);
+}
+
+static VALUE c_text_set (VALUE self, VALUE val)
+{
+ GET_OBJ (self, Evas_Object, e, "Text");
+
+ Check_Type (val, T_STRING);
+
+ evas_object_text_text_set (*e, StringValuePtr (val));
+
+ return Qnil;
+}
+
+void Init_Text (void)
+{
+ VALUE cText = rb_define_class_under (mEvas, "Text", cEvasObject);
+
+ rb_define_singleton_method (cText, "new", c_new, 1);
+ rb_define_method (cText, "font_source", c_font_source_get, 0);
+ rb_define_method (cText, "font_source=", c_font_source_set, 1);
+ rb_define_method (cText, "get_font", c_get_font, 0);
+ rb_define_method (cText, "set_font", c_set_font, 2);
+ rb_define_method (cText, "text", c_text_get, 0);
+ rb_define_method (cText, "text=", c_text_set, 1);
+}
--- /dev/null
+/*
+ * $Id: rb_text.h 23 2004-06-26 22:55:31Z tilman $
+ *
+ * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ *
+ * This library 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.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __RB_TEXT_H
+#define __RB_TEXT_H
+
+void Init_Text (void);
+
+#endif