Added Ecore::Evas::EcoreEvas#has_alpha? and #has_alpha=.
[ruby-ecore.git] / src / ecore_evas / rb_fb.c
index 00635defd22d1f6071db46ddd317e814db4a0884..830448d5ca89a3a705bef5527a818eca67d294c4 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * $Id: rb_fb.c 25 2004-06-26 23:07:01Z tilman $
+ * $Id: rb_fb.c 351 2006-02-10 15:25:40Z tilman $
  *
- * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
 
 #include <ruby.h>
 
+#include <Ecore.h>
 #include <Ecore_Evas.h>
 
+#include "../ecore/rb_ecore.h"
 #include "rb_ecore_evas_main.h"
 #include "rb_ecore_evas.h"
 
+static void c_free (RbEcoreEvas *ee)
+{
+       c_ecore_evas_free (ee, true);
+}
+
+static VALUE c_alloc (VALUE klass)
+{
+       RbEcoreEvas *ee = NULL;
+
+       ecore_init ();
+       ecore_evas_init ();
+
+       return Data_Make_Struct (klass, RbEcoreEvas,
+                                c_ecore_evas_mark, c_free, ee);
+}
+
+/*
+ * call-seq:
+ *  Ecore::Evas::Fb.new([display, rotation, w, h]) => fb
+ *
+ * Creates an Ecore::Evas::Fb object.
+ */
 static VALUE c_init (int argc, VALUE *argv, VALUE self)
 {
        VALUE disp, rot, w, h;
-       Ecore_Evas **ee = NULL;
        char *cdisp = NULL;
        int irot = 0, iw = 0, ih = 0;
 
-       Data_Get_Struct (self, Ecore_Evas *, ee);
+       GET_OBJ (self, RbEcoreEvas, ee);
 
        rb_scan_args (argc, argv, "04", &disp, &rot, &w, &h);
 
@@ -43,42 +66,30 @@ static VALUE c_init (int argc, VALUE *argv, VALUE self)
 
        if (!NIL_P (rot)) {
                Check_Type (rot, T_FIXNUM);
-               irot = NUM2INT (rot);
+               irot = FIX2INT (rot);
        }
 
        if (!NIL_P (w)) {
                Check_Type (w, T_FIXNUM);
-               iw = NUM2INT (w);
+               iw = FIX2INT (w);
        }
 
        if (!NIL_P (h)) {
                Check_Type (h, T_FIXNUM);
-               ih = NUM2INT (h);
+               ih = FIX2INT (h);
        }
 
-       *ee = ecore_evas_fb_new (cdisp, irot, iw, ih);
+       ee->real = ecore_evas_fb_new (cdisp, irot, iw, ih);
 
-       return self;
-}
-
-static VALUE c_new (int argc, VALUE *argv, VALUE klass)
-{
-       VALUE self;
-       Ecore_Evas **ee;
-
-       self = Data_Make_Struct (klass, Ecore_Evas *,
-                                NULL, c_ecore_evas_free, ee);
-
-       rb_obj_call_init (self, argc, argv);
+       rb_call_super (argc, argv);
 
        return self;
 }
 
 void Init_Fb (void)
 {
-       VALUE cFb = rb_define_class_under (mEvas, "Fb", cEcoreEvas);
+       VALUE c = rb_define_class_under (mEvas, "Fb", cEcoreEvas);
 
-       rb_define_singleton_method (cFb, "new", c_new, -1);
-       rb_define_method (cFb, "initialize", c_init, -1);
+       rb_define_alloc_func (c, c_alloc);
+       rb_define_method (c, "initialize", c_init, -1);
 }
-