/*
- * $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)
{
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)
{
return Qnil;
}
-static VALUE c_is_visible (VALUE self)
+static VALUE c_visible_get (VALUE self)
{
GET_OBJ (self, Ecore_Evas, ee, "EcoreEvas");
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");
{
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);
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);
}
-