Added wrappers for more functions.
authorTilman Sauerbeck <tilman@code-monkey.de>
Tue, 22 Jun 2004 20:32:57 +0000 (20:32 +0000)
committerTilman Sauerbeck <tilman@code-monkey.de>
Tue, 22 Jun 2004 20:32:57 +0000 (20:32 +0000)
src/ecore_evas/rb_ecore_evas.c

index abf269dd2593921cbe8a48c1e12f2cf5b24b2915..7edb1685b908f90715b5eb45e2aefeb9e5713c53 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rb_ecore_evas.c 14 2004-06-20 10:33:13Z tilman $
+ * $Id: rb_ecore_evas.c 18 2004-06-22 20:32:57Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
                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; \
+       }
+
 /* called by the child classes */
 void c_ecore_evas_free (Ecore_Evas **ee)
 {
@@ -45,17 +53,17 @@ void c_ecore_evas_free (Ecore_Evas **ee)
        free (ee);
 }
 
-#if 0
-static VALUE c_init (int argc, VALUE argv, VALUE self)
+static VALUE c_inspect (VALUE self)
 {
-       rb_iv_set (self, "@title", rb_str_new2 (""));
-       rb_iv_set (self, "@name", rb_str_new2 (""));
-       rb_iv_set (self, "@class", rb_str_new2 (""));
-       rb_iv_set (self, "@name", rb_str_new2 (""));
+       char buf[128];
+
+       GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
+
+       snprintf (buf, sizeof (buf), "#<EcoreEvas:%p ptr=%p>",
+                 (void *) self, *ee);
 
-       return self;
+       return rb_str_new2 (buf);
 }
-#endif
 
 static VALUE c_show (VALUE self)
 {
@@ -75,7 +83,7 @@ static VALUE c_hide (VALUE self)
        return Qnil;
 }
 
-static VALUE c_is_visible (VALUE self)
+static VALUE c_visible_get (VALUE self)
 {
        GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
 
@@ -89,6 +97,52 @@ static VALUE c_evas (VALUE self)
        return TO_EVAS (self, ecore_evas_get (*ee));
 }
 
+static VALUE c_get_size_min (VALUE self)
+{
+       int w = 0, h = 0;
+
+       GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
+
+       ecore_evas_size_min_get (*ee, &w, &h);
+
+       return rb_ary_new3 (2, INT2FIX (w), INT2FIX (h));
+}
+
+static VALUE c_set_size_min (VALUE self, VALUE w, VALUE h)
+{
+       GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
+
+       Check_Type (w, T_FIXNUM);
+       Check_Type (h, T_FIXNUM);
+
+       ecore_evas_size_min_set (*ee, FIX2INT (w), FIX2INT (h));
+
+       return Qnil;
+}
+
+static VALUE c_get_size_max (VALUE self)
+{
+       int w = 0, h = 0;
+
+       GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
+
+       ecore_evas_size_max_get (*ee, &w, &h);
+
+       return rb_ary_new3 (2, INT2FIX (w), INT2FIX (h));
+}
+
+static VALUE c_set_size_max (VALUE self, VALUE w, VALUE h)
+{
+       GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
+
+       Check_Type (w, T_FIXNUM);
+       Check_Type (h, T_FIXNUM);
+
+       ecore_evas_size_max_set (*ee, FIX2INT (w), FIX2INT (h));
+
+       return Qnil;
+}
+
 static VALUE c_resize (VALUE self, VALUE w, VALUE h)
 {
        GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
@@ -135,13 +189,7 @@ static VALUE c_borderless_set (VALUE self, VALUE val)
 {
        GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
 
-       /* make sure we're passed a boolean */
-       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;
-       }
+       CHECK_BOOL (val);
 
        ecore_evas_borderless_set (*ee, val == Qtrue ? 1 : 0);
 
@@ -167,16 +215,19 @@ void Init_EcoreEvas (void)
 
        rb_define_private_method (rb_singleton_class (cEcoreEvas),
                                  "new", NULL, 0);
-       /*rb_define_method (cEcoreEvas, "initialize", c_init, -1);*/
+       rb_define_method (cEcoreEvas, "inspect", c_inspect, 0);
        rb_define_method (cEcoreEvas, "delete", c_delete, 0);
        rb_define_method (cEcoreEvas, "show", c_show, 0);
        rb_define_method (cEcoreEvas, "hide", c_hide, 0);
-       rb_define_method (cEcoreEvas, "visible?", c_is_visible, 0);
+       rb_define_method (cEcoreEvas, "visible?", c_visible_get, 0);
        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, "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_set, 1);
 }
-