From: Tilman Sauerbeck Date: Sat, 26 Jun 2004 22:55:31 +0000 (+0000) Subject: Added more Evas objects. X-Git-Url: http://git.code-monkey.de/?p=ruby-evas.git;a=commitdiff_plain;h=ba05ccf5a7b503e2d9a58c1de4072312b5abfab7 Added more Evas objects. --- diff --git a/src/Makefile.am b/src/Makefile.am index a2765f6..3ef9ce7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -## $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) @@ -8,7 +8,13 @@ extdir = $(RUBYSITEDIR) 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 diff --git a/src/rb_evas.c b/src/rb_evas.c index dfb949a..3da4ccf 100644 --- a/src/rb_evas.c +++ b/src/rb_evas.c @@ -1,5 +1,5 @@ /* - * $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) * @@ -26,16 +26,6 @@ #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) @@ -52,7 +42,7 @@ VALUE TO_EVAS (VALUE parent, 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 *, @@ -66,6 +56,15 @@ VALUE TO_EVAS (VALUE parent, Evas *e) 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"); @@ -241,6 +240,7 @@ void Init_Evas (void) /* 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); diff --git a/src/rb_evas_main.c b/src/rb_evas_main.c index 719320d..2fbb484 100644 --- a/src/rb_evas_main.c +++ b/src/rb_evas_main.c @@ -1,5 +1,5 @@ /* - * $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) * @@ -25,6 +25,12 @@ #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) { @@ -41,4 +47,10 @@ void Init_evas (void) Init_Evas (); Init_EvasObject (); + Init_Rectangle (); + Init_Line (); + Init_Gradient (); + Init_Polygon (); + Init_Image (); + Init_Text (); } diff --git a/src/rb_evas_main.h b/src/rb_evas_main.h index 214a7a4..2180546 100644 --- a/src/rb_evas_main.h +++ b/src/rb_evas_main.h @@ -1,5 +1,5 @@ /* - * $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) * @@ -21,6 +21,24 @@ #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 diff --git a/src/rb_evas_object.c b/src/rb_evas_object.c index 6492a4e..ee25e1d 100644 --- a/src/rb_evas_object.c +++ b/src/rb_evas_object.c @@ -1,5 +1,5 @@ /* - * $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) * @@ -26,24 +26,6 @@ #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 */ diff --git a/src/rb_gradient.c b/src/rb_gradient.c new file mode 100644 index 0000000..4c745e3 --- /dev/null +++ b/src/rb_gradient.c @@ -0,0 +1,108 @@ +/* + * $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 + +#include + +#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); +} diff --git a/src/rb_gradient.h b/src/rb_gradient.h new file mode 100644 index 0000000..8314e25 --- /dev/null +++ b/src/rb_gradient.h @@ -0,0 +1,26 @@ +/* + * $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 diff --git a/src/rb_image.c b/src/rb_image.c new file mode 100644 index 0000000..1f894dc --- /dev/null +++ b/src/rb_image.c @@ -0,0 +1,58 @@ +/* + * $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 + +#include + +#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); +} diff --git a/src/rb_image.h b/src/rb_image.h new file mode 100644 index 0000000..2c46743 --- /dev/null +++ b/src/rb_image.h @@ -0,0 +1,26 @@ +/* + * $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 diff --git a/src/rb_line.c b/src/rb_line.c new file mode 100644 index 0000000..e75f2bc --- /dev/null +++ b/src/rb_line.c @@ -0,0 +1,89 @@ +/* + * $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 + +#include + +#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); +} diff --git a/src/rb_line.h b/src/rb_line.h new file mode 100644 index 0000000..9593e19 --- /dev/null +++ b/src/rb_line.h @@ -0,0 +1,26 @@ +/* + * $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 diff --git a/src/rb_polygon.c b/src/rb_polygon.c new file mode 100644 index 0000000..d0b918a --- /dev/null +++ b/src/rb_polygon.c @@ -0,0 +1,82 @@ +/* + * $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 + +#include + +#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); +} diff --git a/src/rb_polygon.h b/src/rb_polygon.h new file mode 100644 index 0000000..b60d206 --- /dev/null +++ b/src/rb_polygon.h @@ -0,0 +1,26 @@ +/* + * $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 diff --git a/src/rb_rectangle.c b/src/rb_rectangle.c new file mode 100644 index 0000000..e2e307b --- /dev/null +++ b/src/rb_rectangle.c @@ -0,0 +1,59 @@ +/* + * $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 + +#include + +#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); +} diff --git a/src/rb_rectangle.h b/src/rb_rectangle.h new file mode 100644 index 0000000..ff38842 --- /dev/null +++ b/src/rb_rectangle.h @@ -0,0 +1,26 @@ +/* + * $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 diff --git a/src/rb_text.c b/src/rb_text.c new file mode 100644 index 0000000..c6ffa42 --- /dev/null +++ b/src/rb_text.c @@ -0,0 +1,136 @@ +/* + * $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 + +#include + +#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); +} diff --git a/src/rb_text.h b/src/rb_text.h new file mode 100644 index 0000000..af10920 --- /dev/null +++ b/src/rb_text.h @@ -0,0 +1,26 @@ +/* + * $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