ecore_init and ecore_shutdown aren't exported anymore.
[ruby-ecore.git] / src / ecore_evas / rb_ecore_evas.c
index 7edb1685b908f90715b5eb45e2aefeb9e5713c53..b508339bf44cb1bf988ac743c9df18e5af197e95 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rb_ecore_evas.c 18 2004-06-22 20:32:57Z tilman $
+ * $Id: rb_ecore_evas.c 27 2004-07-08 18:25:05Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
@@ -20,6 +20,7 @@
 
 #include <ruby.h>
 
+#include <Ecore.h>
 #include <Ecore_Evas.h>
 #include <rb_evas.h>
 
                return Qnil; \
        }
 
+static VALUE evases;
+
 /* called by the child classes */
 void c_ecore_evas_free (Ecore_Evas **ee)
 {
        if (*ee)
                ecore_evas_free (*ee);
 
+       rb_hash_aset (evases, INT2NUM ((long) ee), Qnil);
+
+       ecore_evas_shutdown ();
+       ecore_shutdown ();
+
        free (ee);
 }
 
@@ -59,7 +67,7 @@ static VALUE c_inspect (VALUE self)
 
        GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
 
-       snprintf (buf, sizeof (buf), "#<EcoreEvas:%p ptr=%p>",
+       snprintf (buf, sizeof (buf), "#<Ecore::Evas::EcoreEvas:%p ptr=%p>",
                  (void *) self, *ee);
 
        return rb_str_new2 (buf);
@@ -90,11 +98,54 @@ static VALUE c_visible_get (VALUE self)
        return ecore_evas_visibility_get (*ee) ? Qtrue : Qfalse;
 }
 
+static VALUE c_raise (VALUE self)
+{
+       GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
+
+       ecore_evas_raise (*ee);
+
+       return Qnil;
+}
+
+static VALUE c_lower (VALUE self)
+{
+       GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
+
+       ecore_evas_lower (*ee);
+
+       return Qnil;
+}
+
+static VALUE c_layer_get (VALUE self)
+{
+       GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
+
+       return INT2FIX (ecore_evas_layer_get (*ee));
+}
+
+static VALUE c_layer_set (VALUE self, VALUE val)
+{
+       GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
+
+       Check_Type (val, T_FIXNUM);
+
+       ecore_evas_layer_set (*ee, FIX2INT (val));
+
+       return Qnil;
+}
+
 static VALUE c_evas (VALUE self)
 {
+       VALUE evas;
+
        GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
 
-       return TO_EVAS (self, ecore_evas_get (*ee));
+       if (NIL_P (evas = rb_hash_aref (evases, INT2NUM ((long) (ee))))) {
+               evas = TO_EVAS (self, ecore_evas_get (*ee));
+               rb_hash_aset (evases, INT2NUM ((long) ee), evas);
+       }
+
+       return evas;
 }
 
 static VALUE c_get_size_min (VALUE self)
@@ -143,6 +194,18 @@ static VALUE c_set_size_max (VALUE self, VALUE w, VALUE h)
        return Qnil;
 }
 
+static VALUE c_move (VALUE self, VALUE x, VALUE y)
+{
+       GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
+
+       Check_Type (x, T_FIXNUM);
+       Check_Type (y, T_FIXNUM);
+
+       ecore_evas_move (*ee, FIX2INT (x), FIX2INT (y));
+
+       return Qnil;
+}
+
 static VALUE c_resize (VALUE self, VALUE w, VALUE h)
 {
        GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
@@ -196,6 +259,60 @@ static VALUE c_borderless_set (VALUE self, VALUE val)
        return Qnil;
 }
 
+static VALUE c_shaped_get (VALUE self)
+{
+       GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
+
+       return ecore_evas_shaped_get (*ee) ? Qtrue : Qfalse;
+}
+
+static VALUE c_shaped_set (VALUE self, VALUE val)
+{
+       GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
+
+       CHECK_BOOL (val);
+
+       ecore_evas_shaped_set (*ee, val == Qtrue ? 1 : 0);
+
+       return Qnil;
+}
+
+static VALUE c_sticky_get (VALUE self)
+{
+       GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
+
+       return ecore_evas_sticky_get (*ee) ? Qtrue : Qfalse;
+}
+
+static VALUE c_sticky_set (VALUE self, VALUE val)
+{
+       GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
+
+       CHECK_BOOL (val);
+
+       ecore_evas_sticky_set (*ee, val == Qtrue ? 1 : 0);
+
+       return Qnil;
+}
+
+static VALUE c_rotation_get (VALUE self)
+{
+       GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
+
+       return INT2FIX (ecore_evas_rotation_get (*ee));
+}
+
+static VALUE c_rotation_set (VALUE self, VALUE val)
+{
+       GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
+
+       Check_Type (val, T_FIXNUM);
+
+       ecore_evas_rotation_set (*ee, FIX2INT (val));
+
+       return Qnil;
+}
+
 static VALUE c_delete (VALUE self)
 {
        GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
@@ -220,14 +337,28 @@ void Init_EcoreEvas (void)
        rb_define_method (cEcoreEvas, "show", c_show, 0);
        rb_define_method (cEcoreEvas, "hide", c_hide, 0);
        rb_define_method (cEcoreEvas, "visible?", c_visible_get, 0);
+       rb_define_method (cEcoreEvas, "raise", c_raise, 0);
+       rb_define_method (cEcoreEvas, "lower", c_lower, 0);
+       rb_define_method (cEcoreEvas, "layer", c_layer_get, 0);
+       rb_define_method (cEcoreEvas, "layer=", c_layer_set, 1);
        rb_define_method (cEcoreEvas, "evas", c_evas, 0);
        rb_define_method (cEcoreEvas, "get_size_min", c_get_size_min, 0);
        rb_define_method (cEcoreEvas, "set_size_min", c_set_size_min, 2);
        rb_define_method (cEcoreEvas, "get_size_max", c_get_size_max, 0);
        rb_define_method (cEcoreEvas, "set_size_max", c_set_size_max, 2);
+       rb_define_method (cEcoreEvas, "move", c_move, 2);
        rb_define_method (cEcoreEvas, "resize", c_resize, 2);
        rb_define_method (cEcoreEvas, "title", c_title_get, 0);
        rb_define_method (cEcoreEvas, "title=", c_title_set, 1);
-       rb_define_method (cEcoreEvas, "borderless", c_borderless_get, 0);
+       rb_define_method (cEcoreEvas, "borderless?", c_borderless_get, 0);
        rb_define_method (cEcoreEvas, "borderless=", c_borderless_set, 1);
+       rb_define_method (cEcoreEvas, "shaped?", c_shaped_get, 0);
+       rb_define_method (cEcoreEvas, "shaped=", c_shaped_set, 1);
+       rb_define_method (cEcoreEvas, "sticky?", c_sticky_get, 0);
+       rb_define_method (cEcoreEvas, "sticky=", c_sticky_set, 1);
+       rb_define_method (cEcoreEvas, "rotation", c_rotation_get, 0);
+       rb_define_method (cEcoreEvas, "rotation=", c_rotation_set, 1);
+
+       evases = rb_hash_new ();
+       rb_global_variable (&evases);
 }