Added Esmart::Container#alignment.
[ruby-esmart.git] / src / esmart_container / rb_esmart_container.c
index 9eb89b21e897eee221869065ebeeb0810bae0a8e..a4101644b57212994c00e51ec5aed53f3cb237ea 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rb_esmart_container.c 56 2004-08-10 13:28:01Z tilman $
+ * $Id: rb_esmart_container.c 217 2005-02-10 14:24:57Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
@@ -54,9 +54,9 @@ static VALUE c_append_element (VALUE self, VALUE element)
        GET_OBJ (self, RbEvasObject, e);
 
        CHECK_CLASS (element, cEvasObject);
-       GET_OBJ (element, Evas_Object *, o);
+       GET_OBJ (element, RbEvasObject, o);
 
-       esmart_container_element_append (e->real, *o);
+       esmart_container_element_append (e->real, o->real);
 
        return Qnil;
 }
@@ -66,9 +66,9 @@ static VALUE c_prepend_element (VALUE self, VALUE element)
        GET_OBJ (self, RbEvasObject, e);
 
        CHECK_CLASS (element, cEvasObject);
-       GET_OBJ (element, Evas_Object *, o);
+       GET_OBJ (element, RbEvasObject, o);
 
-       esmart_container_element_prepend (e->real, *o);
+       esmart_container_element_prepend (e->real, o->real);
 
        return Qnil;
 }
@@ -78,13 +78,29 @@ static VALUE c_remove_element (VALUE self, VALUE element)
        GET_OBJ (self, RbEvasObject, e);
 
        CHECK_CLASS (element, cEvasObject);
-       GET_OBJ (element, Evas_Object *, o);
+       GET_OBJ (element, RbEvasObject, o);
 
-       esmart_container_element_remove (e->real, *o);
+       esmart_container_element_remove (e->real, o->real);
 
        return Qnil;
 }
 
+static VALUE c_elements_get (VALUE self)
+{
+       VALUE ary;
+       Evas_List *list, *l;
+
+       GET_OBJ (self, RbEvasObject, e);
+
+       list = esmart_container_elements_get (e->real);
+       ary = rb_ary_new ();
+
+       for (l = list; l; l = l->next)
+               rb_ary_push (ary, TO_EVAS_OBJECT (l->data));
+
+       return ary;
+}
+
 static VALUE c_direction_get (VALUE self)
 {
        GET_OBJ (self, RbEvasObject, e);
@@ -139,6 +155,25 @@ static VALUE c_fill_policy_set (VALUE self, VALUE val)
        return Qnil;
 }
 
+static VALUE c_alignment_get (VALUE self)
+{
+       GET_OBJ (self, RbEvasObject, e);
+
+       return INT2FIX (esmart_container_alignment_get (e->real));
+}
+
+static VALUE c_alignment_set (VALUE self, VALUE val)
+{
+       GET_OBJ (self, RbEvasObject, e);
+
+       Check_Type (val, T_FIXNUM);
+
+       esmart_container_alignment_set (e->real, FIX2INT (val));
+
+       return Qnil;
+}
+
+
 static VALUE c_get_padding (VALUE self)
 {
        double l = 0, r = 0, t = 0, b = 0;
@@ -193,11 +228,14 @@ void Init_esmart_container (void)
        rb_define_method (c, "spacing=", c_spacing_set, 1);
        rb_define_method (c, "fill_policy", c_fill_policy_get, 0);
        rb_define_method (c, "fill_policy=", c_fill_policy_set, 1);
+       rb_define_method (c, "alignment", c_alignment_get, 0);
+       rb_define_method (c, "alignment=", c_alignment_set, 1);
        rb_define_method (c, "get_padding", c_get_padding, 0);
        rb_define_method (c, "set_padding", c_set_padding, 4);
        rb_define_method (c, "append_element", c_append_element, 1);
        rb_define_method (c, "prepend_element", c_prepend_element, 1);
        rb_define_method (c, "remove_element", c_remove_element, 1);
+       rb_define_method (c, "elements", c_elements_get, 0);
        rb_define_method (c, "scroll", c_scroll, 1);
 
        rb_define_const (c, "HORIZONTAL",
@@ -215,4 +253,15 @@ void Init_esmart_container (void)
                         INT2FIX (CONTAINER_FILL_POLICY_FILL_Y));
        rb_define_const (c, "HOMOGENOUS",
                         INT2FIX (CONTAINER_FILL_POLICY_HOMOGENOUS));
+
+       rb_define_const (c, "CENTER",
+                        INT2FIX (CONTAINER_ALIGN_CENTER));
+       rb_define_const (c, "LEFT",
+                        INT2FIX (CONTAINER_ALIGN_LEFT));
+       rb_define_const (c, "RIGHT",
+                        INT2FIX (CONTAINER_ALIGN_RIGHT));
+       rb_define_const (c, "BOTTOM",
+                        INT2FIX (CONTAINER_ALIGN_BOTTOM));
+       rb_define_const (c, "TOP",
+                        INT2FIX (CONTAINER_ALIGN_TOP));
 }