Finalize Evas::Smart API.
[ruby-evas.git] / src / rb_image.c
index 275dc32423c46dab4e6f3ff8610816bdafb72a59..8e7f5ed797f96d404087d2fb16e0cd21e5ecc567 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rb_image.c 62 2004-08-12 19:35:01Z tilman $
+ * $Id: rb_image.c 354 2006-02-10 18:14:08Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
 #include "rb_evas.h"
 #include "rb_evas_object.h"
 
-static void c_free (RbEvasObject *e)
-{
-       c_evas_object_free (e, true);
-}
-
 /*
  * call-seq:
  *  Evas::Image.new(evas) => img
  *
  * Creates an Evas::Image object.
  */
-static VALUE c_new (VALUE klass, VALUE evas)
+static VALUE c_init (VALUE self, VALUE evas)
 {
-       VALUE self, argv[1];
-       RbEvasObject *img;
-
        CHECK_CLASS (evas, cEvas);
        GET_OBJ (evas, RbEvas, e);
+       GET_OBJ (self, RbEvasObject, img);
 
-       self = Data_Make_Struct (klass, RbEvasObject, c_evas_object_mark,
-                                c_free, img);
        img->real = evas_object_image_add (e->real);
 
-       argv[0] = evas;
-       rb_obj_call_init (self, 1, argv);
+       rb_call_super (1, &evas);
 
        return self;
 }
@@ -223,6 +213,33 @@ static VALUE c_set_fill (VALUE self, VALUE x, VALUE y, VALUE w, VALUE h)
        return Qnil;
 }
 
+static VALUE c_get_border (VALUE self)
+{
+       int x = 0, y = 0, w = 0, h = 0;
+
+       GET_OBJ (self, RbEvasObject, e);
+
+       evas_object_image_border_get (e->real, &x, &y, &w, &h);
+
+       return rb_ary_new3 (4, INT2FIX (x), INT2FIX (y),
+                           INT2FIX (w), INT2FIX (h));
+}
+
+static VALUE c_set_border (VALUE self, VALUE x, VALUE y, VALUE w, VALUE h)
+{
+       GET_OBJ (self, RbEvasObject, e);
+
+       Check_Type (x, T_FIXNUM);
+       Check_Type (y, T_FIXNUM);
+       Check_Type (w, T_FIXNUM);
+       Check_Type (h, T_FIXNUM);
+
+       evas_object_image_border_set (e->real, FIX2INT (x), FIX2INT (y),
+                                     FIX2INT (w), FIX2INT (h));
+
+       return Qnil;
+}
+
 /*
  * call-seq:
  *  img.reload => nil
@@ -242,7 +259,7 @@ void Init_Image (void)
 {
        VALUE c = rb_define_class_under (mEvas, "Image", cEvasObject);
 
-       rb_define_singleton_method (c, "new", c_new, 1);
+       rb_define_method (c, "initialize", c_init, 1);
        rb_define_method (c, "get_file", c_get_file, -1);
        rb_define_method (c, "set_file", c_set_file, -1);
        rb_define_method (c, "has_alpha?", c_has_alpha_get, 0);
@@ -251,5 +268,7 @@ void Init_Image (void)
        rb_define_method (c, "set_size", c_set_size, 2);
        rb_define_method (c, "get_fill", c_get_fill, 0);
        rb_define_method (c, "set_fill", c_set_fill, 4);
+       rb_define_method (c, "get_border", c_get_border, 0);
+       rb_define_method (c, "set_border", c_set_border, 4);
        rb_define_method (c, "reload", c_reload, 0);
 }