/*
- * $Id: rb_ecore_evas.c 50 2004-08-01 10:18:39Z tilman $
+ * $Id: rb_ecore_evas.c 60 2004-08-10 14:12:36Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
#include "rb_ecore_evas_main.h"
#include "rb_ecore_evas.h"
-#define CALLBACK_ADD_HANDLER(name) \
+#define CALLBACK_DEFINE_HANDLER(name) \
static void on_##name (Ecore_Evas *real) \
{ \
VALUE self = rb_hash_aref (objects, INT2NUM ((long) real)); \
cb = rb_hash_aref (ee->callbacks, rb_str_new2 (#name)); \
rb_funcall (cb, rb_intern ("call"), 0); \
} \
-\
- static VALUE c_on_##name (VALUE self) \
- { \
+
+#define CALLBACK_REG_HANDLER(name) \
GET_OBJ (self, RbEcoreEvas, ee); \
\
if (!rb_block_given_p ()) \
\
ecore_evas_callback_##name##_set (ee->real, on_##name); \
\
- return Qnil; \
- }
-
-#define CALLBACK_ADD(mod, name) \
- rb_define_method ((mod), "on_"#name, c_on_##name, 0);
+ return Qnil;
VALUE cEcoreEvas;
static VALUE objects;
free (ee);
}
+/* :nodoc: */
static VALUE c_init (int argc, VALUE *argv, VALUE self)
{
GET_OBJ (self, RbEcoreEvas, ee);
return Qnil;
}
+/* :nodoc: */
static VALUE c_inspect (VALUE self)
{
INSPECT (self, RbEcoreEvas);
}
+/*
+ * call-seq:
+ * ee.show => nil
+ *
+ * Shows <i>ee</i>.
+ */
static VALUE c_show (VALUE self)
{
GET_OBJ (self, RbEcoreEvas, ee);
return Qnil;
}
+/*
+ * call-seq:
+ * ee.hide => nil
+ *
+ * Hides <i>ee</i>.
+ */
static VALUE c_hide (VALUE self)
{
GET_OBJ (self, RbEcoreEvas, ee);
return Qnil;
}
+/*
+ * call-seq:
+ * ee.visible? => true or false
+ *
+ * Returns true if <i>ee</i> is visible, else false.
+ */
static VALUE c_visible_get (VALUE self)
{
GET_OBJ (self, RbEcoreEvas, ee);
return ecore_evas_visibility_get (ee->real) ? Qtrue : Qfalse;
}
+/*
+ * call-seq:
+ * ee.raise => nil
+ *
+ * Raises <i>ee</i>.
+ */
static VALUE c_raise (VALUE self)
{
GET_OBJ (self, RbEcoreEvas, ee);
return Qnil;
}
+/*
+ * call-seq:
+ * ee.lower => nil
+ *
+ * Lowers <i>ee</i>.
+ */
static VALUE c_lower (VALUE self)
{
GET_OBJ (self, RbEcoreEvas, ee);
return Qnil;
}
+/*
+ * call-seq:
+ * ee.layer => fixnum
+ *
+ * Returns the layer of <i>ee</i>.
+ */
static VALUE c_layer_get (VALUE self)
{
GET_OBJ (self, RbEcoreEvas, ee);
return INT2FIX (ecore_evas_layer_get (ee->real));
}
+/*
+ * call-seq:
+ * ee.layer(fixnum) => fixnum
+ *
+ * Sets the layer of <i>ee</i>.
+ */
static VALUE c_layer_set (VALUE self, VALUE val)
{
GET_OBJ (self, RbEcoreEvas, ee);
return Qnil;
}
+/*
+ * call-seq:
+ * ee.evas => evas
+ *
+ * Returns the <code>Evas::Evas</code> object for <i>ee</i>.
+ */
static VALUE c_evas_get (VALUE self)
{
GET_OBJ (self, RbEcoreEvas, ee);
return ee->evas;
}
+/*
+ * call-seq:
+ * ee.geometry => array
+ *
+ * Returns an array containing the geometry of <i>ee</i>.
+ *
+ * ee.move(150, 300) #=> nil
+ * ee.resize(200, 200) #=> nil
+ * ee.geometry #=> [150, 300, 200, 200]
+ */
static VALUE c_geometry_get (VALUE self)
{
int x = 0, y = 0, w = 0, h = 0;
INT2FIX (w), INT2FIX (h));
}
+/*
+ * call-seq:
+ * ee.get_size_min => array
+ *
+ * Returns an array containing the minimum size of <i>ee</i>.
+ *
+ * ee.set_size_min(100, 200) #=> nil
+ * ee.get_size_min #=> [100, 200]
+ */
static VALUE c_get_size_min (VALUE self)
{
int w = 0, h = 0;
return rb_ary_new3 (2, INT2FIX (w), INT2FIX (h));
}
+/*
+ * call-seq:
+ * ee.set_size_min(width, height) => nil
+ *
+ * Sets the minimum size of <i>ee</i>.
+ *
+ * ee.set_size_min(100, 200) #=> nil
+ */
static VALUE c_set_size_min (VALUE self, VALUE w, VALUE h)
{
GET_OBJ (self, RbEcoreEvas, ee);
return Qnil;
}
+/*
+ * call-seq:
+ * ee.get_size_max => array
+ *
+ * Returns an array containing the maximum size of <i>ee</i>.
+ *
+ * ee.set_size_max(100, 200) #=> nil
+ * ee.get_size_max #=> [100, 200]
+ */
static VALUE c_get_size_max (VALUE self)
{
int w = 0, h = 0;
return rb_ary_new3 (2, INT2FIX (w), INT2FIX (h));
}
+/*
+ * call-seq:
+ * ee.set_size_max(width, height) => nil
+ *
+ * Sets the maximum size of <i>ee</i>.
+ *
+ * ee.set_size_max(100, 200) #=> nil
+ */
static VALUE c_set_size_max (VALUE self, VALUE w, VALUE h)
{
GET_OBJ (self, RbEcoreEvas, ee);
return Qnil;
}
+/*
+ * call-seq:
+ * ee.move(x, y) => nil
+ *
+ * Moves <i>ee</i> to the coordinates specified in
+ * <i>x</i> and <i>y</i>.
+ *
+ * ee.move(100, 200) #=> nil
+ */
static VALUE c_move (VALUE self, VALUE x, VALUE y)
{
GET_OBJ (self, RbEcoreEvas, ee);
return Qnil;
}
+/*
+ * call-seq:
+ * ee.resize(width, height) => nil
+ *
+ * Resizes <i>ee</i> to width x height.
+ *
+ * ee.resize(100, 200) #=> nil
+ */
static VALUE c_resize (VALUE self, VALUE w, VALUE h)
{
GET_OBJ (self, RbEcoreEvas, ee);
return Qnil;
}
+/*
+ * call-seq:
+ * ee.title => string
+ *
+ * Returns the title of <i>ee</i>.
+ */
static VALUE c_title_get (VALUE self)
{
const char *tmp;
return rb_str_new2 (tmp);
}
+/*
+ * call-seq:
+ * ee.title(string)
+ *
+ * Sets the title of <i>ee</i>.
+ */
static VALUE c_title_set (VALUE self, VALUE val)
{
GET_OBJ (self, RbEcoreEvas, ee);
return Qnil;
}
+/*
+ * call-seq:
+ * ee.borderless? => true or false
+ *
+ * Returns true if <i>ee</i> is borderless, else false.
+ */
static VALUE c_borderless_get (VALUE self)
{
GET_OBJ (self, RbEcoreEvas, ee);
return ecore_evas_borderless_get (ee->real) ? Qtrue : Qfalse;
}
+/*
+ * call-seq:
+ * ee.borderless(true or false)
+ *
+ * Sets whether <i>ee</i> is borderless or not.
+ */
static VALUE c_borderless_set (VALUE self, VALUE val)
{
GET_OBJ (self, RbEcoreEvas, ee);
return Qnil;
}
+/*
+ * call-seq:
+ * ee.shaped? => true or false
+ *
+ * Returns true if <i>ee</i> is shaped, else false.
+ */
static VALUE c_shaped_get (VALUE self)
{
GET_OBJ (self, RbEcoreEvas, ee);
return ecore_evas_shaped_get (ee->real) ? Qtrue : Qfalse;
}
+/*
+ * call-seq:
+ * ee.shaped(true or false)
+ *
+ * Sets whether <i>ee</i> is shaped or not.
+ */
static VALUE c_shaped_set (VALUE self, VALUE val)
{
GET_OBJ (self, RbEcoreEvas, ee);
return Qnil;
}
+/*
+ * call-seq:
+ * ee.sticky? => true or false
+ *
+ * Returns true if <i>ee</i> is sticky, else false.
+ */
static VALUE c_sticky_get (VALUE self)
{
GET_OBJ (self, RbEcoreEvas, ee);
return ecore_evas_sticky_get (ee->real) ? Qtrue : Qfalse;
}
+/*
+ * call-seq:
+ * ee.sticky(true or false)
+ *
+ * Sets whether <i>ee</i> is sticky or not.
+ */
static VALUE c_sticky_set (VALUE self, VALUE val)
{
GET_OBJ (self, RbEcoreEvas, ee);
return Qnil;
}
+/*
+ * call-seq:
+ * ee.rotation => fixnum
+ *
+ * Returns the rotation of <i>ee</i>.
+ */
static VALUE c_rotation_get (VALUE self)
{
GET_OBJ (self, RbEcoreEvas, ee);
return INT2FIX (ecore_evas_rotation_get (ee->real));
}
+/*
+ * call-seq:
+ * ee.rotation(fixnum)
+ *
+ * Sets the rotation of <i>ee</i>.
+ */
static VALUE c_rotation_set (VALUE self, VALUE val)
{
GET_OBJ (self, RbEcoreEvas, ee);
return Qnil;
}
-/* FIXME: this is unsafe! */
+/* FIXME: this is unsafe!
+ * :nodoc:
+ */
static VALUE c_delete (VALUE self)
{
GET_OBJ (self, RbEcoreEvas, ee);
return Qnil;
}
-CALLBACK_ADD_HANDLER (resize);
-CALLBACK_ADD_HANDLER (move);
-CALLBACK_ADD_HANDLER (show);
-CALLBACK_ADD_HANDLER (hide);
-CALLBACK_ADD_HANDLER (delete_request);
-CALLBACK_ADD_HANDLER (destroy);
-CALLBACK_ADD_HANDLER (focus_in);
-CALLBACK_ADD_HANDLER (focus_out);
-CALLBACK_ADD_HANDLER (mouse_in);
-CALLBACK_ADD_HANDLER (mouse_out);
-CALLBACK_ADD_HANDLER (pre_render);
-CALLBACK_ADD_HANDLER (post_render);
+CALLBACK_DEFINE_HANDLER (resize);
+CALLBACK_DEFINE_HANDLER (move);
+CALLBACK_DEFINE_HANDLER (show);
+CALLBACK_DEFINE_HANDLER (hide);
+CALLBACK_DEFINE_HANDLER (delete_request);
+CALLBACK_DEFINE_HANDLER (destroy);
+CALLBACK_DEFINE_HANDLER (focus_in);
+CALLBACK_DEFINE_HANDLER (focus_out);
+CALLBACK_DEFINE_HANDLER (mouse_in);
+CALLBACK_DEFINE_HANDLER (mouse_out);
+CALLBACK_DEFINE_HANDLER (pre_render);
+CALLBACK_DEFINE_HANDLER (post_render);
+
+/*
+ * call-seq:
+ * ee.on_resize { block } => nil
+ *
+ * Sets the handler for the resize event.
+ */
+static VALUE c_on_resize (VALUE self)
+{
+ CALLBACK_REG_HANDLER (resize);
+}
+
+/*
+ * call-seq:
+ * ee.on_move { block } => nil
+ *
+ * Sets the handler for the move event.
+ */
+static VALUE c_on_move (VALUE self)
+{
+ CALLBACK_REG_HANDLER (move);
+}
+
+/*
+ * call-seq:
+ * ee.on_show { block } => nil
+ *
+ * Sets the handler for the show event.
+ */
+static VALUE c_on_show (VALUE self)
+{
+ CALLBACK_REG_HANDLER (show);
+}
+
+/*
+ * call-seq:
+ * ee.on_hide { block } => nil
+ *
+ * Sets the handler for the hide event.
+ */
+static VALUE c_on_hide (VALUE self)
+{
+ CALLBACK_REG_HANDLER (hide);
+}
+
+/*
+ * call-seq:
+ * ee.on_delete_request { block } => nil
+ *
+ * Sets the handler for the delete request event.
+ */
+static VALUE c_on_delete_request (VALUE self)
+{
+ CALLBACK_REG_HANDLER (delete_request);
+}
+
+/*
+ * call-seq:
+ * ee.on_destroy { block } => nil
+ *
+ * Sets the handler for the destroy event.
+ */
+static VALUE c_on_destroy (VALUE self)
+{
+ CALLBACK_REG_HANDLER (destroy);
+}
+
+/*
+ * call-seq:
+ * ee.on_focus_in { block } => nil
+ *
+ * Sets the handler for the focus in event.
+ */
+static VALUE c_on_focus_in (VALUE self)
+{
+ CALLBACK_REG_HANDLER (focus_in);
+}
+
+/*
+ * call-seq:
+ * ee.on_focus_out { block } => nil
+ *
+ * Sets the handler for the focus out event.
+ */
+static VALUE c_on_focus_out (VALUE self)
+{
+ CALLBACK_REG_HANDLER (focus_out);
+}
+
+/*
+ * call-seq:
+ * ee.on_mouse_in { block } => nil
+ *
+ * Sets the handler for the mouse in event.
+ */
+static VALUE c_on_mouse_in (VALUE self)
+{
+ CALLBACK_REG_HANDLER (mouse_in);
+}
+
+/*
+ * call-seq:
+ * ee.on_mouse_out { block } => nil
+ *
+ * Sets the handler for the mouse out event.
+ */
+static VALUE c_on_mouse_out (VALUE self)
+{
+ CALLBACK_REG_HANDLER (mouse_out);
+}
+
+/*
+ * call-seq:
+ * ee.on_pre_render { block } => nil
+ *
+ * Sets the handler for the pre render event.
+ */
+static VALUE c_on_pre_render (VALUE self)
+{
+ CALLBACK_REG_HANDLER (pre_render);
+}
+
+/*
+ * call-seq:
+ * ee.on_post_render { block } => nil
+ *
+ * Sets the handler for the post render event.
+ */
+static VALUE c_on_post_render (VALUE self)
+{
+ CALLBACK_REG_HANDLER (post_render);
+}
void Init_EcoreEvas (void)
{
rb_define_method (cEcoreEvas, "rotation", c_rotation_get, 0);
rb_define_method (cEcoreEvas, "rotation=", c_rotation_set, 1);
- CALLBACK_ADD (cEcoreEvas, resize);
- CALLBACK_ADD (cEcoreEvas, move);
- CALLBACK_ADD (cEcoreEvas, show);
- CALLBACK_ADD (cEcoreEvas, hide);
- CALLBACK_ADD (cEcoreEvas, delete_request);
- CALLBACK_ADD (cEcoreEvas, destroy);
- CALLBACK_ADD (cEcoreEvas, focus_in);
- CALLBACK_ADD (cEcoreEvas, focus_out);
- CALLBACK_ADD (cEcoreEvas, mouse_in);
- CALLBACK_ADD (cEcoreEvas, mouse_out);
- CALLBACK_ADD (cEcoreEvas, pre_render);
- CALLBACK_ADD (cEcoreEvas, post_render);
+ rb_define_method (cEcoreEvas, "on_resize", c_on_resize, 0);
+ rb_define_method (cEcoreEvas, "on_move", c_on_move, 0);
+ rb_define_method (cEcoreEvas, "on_show", c_on_show, 0);
+ rb_define_method (cEcoreEvas, "on_hide", c_on_hide, 0);
+ rb_define_method (cEcoreEvas, "on_delete_request", c_on_delete_request, 0);
+ rb_define_method (cEcoreEvas, "on_destroy", c_on_destroy, 0);
+ rb_define_method (cEcoreEvas, "on_focus_in", c_on_focus_in, 0);
+ rb_define_method (cEcoreEvas, "on_focus_out", c_on_focus_out, 0);
+ rb_define_method (cEcoreEvas, "on_mouse_in", c_on_mouse_in, 0);
+ rb_define_method (cEcoreEvas, "on_mouse_out", c_on_mouse_out, 0);
+ rb_define_method (cEcoreEvas, "on_pre_render", c_on_pre_render, 0);
+ rb_define_method (cEcoreEvas, "on_post_render", c_on_post_render, 0);
objects = rb_hash_new ();
rb_global_variable (&objects);