Added Esmart::Container#scroll_percent and scroll_percent=.
[ruby-esmart.git] / src / esmart_container / rb_esmart_container.c
index 3269c37091bbc8105b5013027a3feca5af5d3211..45e13f8958173a7ba5a93518cef1dedb8e7b936f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rb_esmart_container.c 286 2005-03-15 18:05:42Z tilman $
+ * $Id: rb_esmart_container.c 317 2005-04-25 21:48:10Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
@@ -60,7 +60,7 @@ static VALUE c_new (VALUE klass, VALUE evas)
        argv[0] = evas;
        rb_obj_call_init (self, 1, argv);
 
-       rb_iv_set (self, "@elements", rb_ary_new ());
+       cont->elements = rb_ary_new ();
 
        return self;
 }
@@ -250,6 +250,28 @@ static VALUE c_scroll (VALUE self, VALUE val)
        return Qnil;
 }
 
+static VALUE c_scroll_percent_get (VALUE self)
+{
+       double val;
+
+       GET_OBJ (self, RbContainer, e);
+
+       val = esmart_container_scroll_percent_get (e->real.real);
+
+       return rb_float_new (val);
+}
+
+static VALUE c_scroll_percent_set (VALUE self, VALUE val)
+{
+       GET_OBJ (self, RbContainer, e);
+
+       Check_Type (val, T_FLOAT);
+
+       esmart_container_scroll_percent_set (e->real.real, NUM2DBL (val));
+
+       return Qnil;
+}
+
 void Init_esmart_container (void)
 {
        VALUE c;
@@ -277,6 +299,8 @@ void Init_esmart_container (void)
        rb_define_method (c, "elements_orig_length",
                          c_elements_orig_length_get, 0);
        rb_define_method (c, "scroll", c_scroll, 1);
+       rb_define_method (c, "scroll_percent", c_scroll_percent_get, 0);
+       rb_define_method (c, "scroll_percent=", c_scroll_percent_set, 1);
 
        rb_define_const (c, "HORIZONTAL",
                         INT2FIX (CONTAINER_DIRECTION_HORIZONTAL));