X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fesmart_container%2Frb_esmart_container.c;h=93986db68eb57d624e572ad431e2e40d4bf4a57a;hb=1969f6740e354d24f5a05436d0d3ffa63f9dbae9;hp=34c8e260794a15d9d6d8b717cfe58fc7365df8ab;hpb=fb07a428f755a86729628f3aec807c9765383b0b;p=ruby-esmart.git diff --git a/src/esmart_container/rb_esmart_container.c b/src/esmart_container/rb_esmart_container.c index 34c8e26..93986db 100644 --- a/src/esmart_container/rb_esmart_container.c +++ b/src/esmart_container/rb_esmart_container.c @@ -1,6 +1,4 @@ /* - * $Id: rb_esmart_container.c 297 2005-03-18 18:49:46Z tilman $ - * * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de) * * This library is free software; you can redistribute it and/or @@ -45,20 +43,23 @@ static void c_free (RbContainer *e) free (e); } -static VALUE c_new (VALUE klass, VALUE evas) +static VALUE c_alloc (VALUE klass) { - VALUE self, argv[1]; - RbContainer *cont; + RbContainer *cont = NULL; + + return Data_Make_Struct (klass, RbContainer, c_mark, + c_free, cont); +} +static VALUE c_init (VALUE self, VALUE evas) +{ CHECK_CLASS (evas, cEvas); GET_OBJ (evas, RbEvas, e); + GET_OBJ (self, RbContainer, cont); - self = Data_Make_Struct (klass, RbContainer, c_mark, - c_free, cont); cont->real.real = esmart_container_new (e->real); - argv[0] = evas; - rb_obj_call_init (self, 1, argv); + rb_call_super (1, &evas); cont->elements = rb_ary_new (); @@ -250,6 +251,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; @@ -258,7 +281,8 @@ void Init_esmart_container (void) c = rb_define_class_under (mEsmart, "Container", cEvasObject); - rb_define_singleton_method (c, "new", c_new, 1); + rb_define_alloc_func (c, c_alloc); + rb_define_method (c, "initialize", c_init, 1); rb_define_method (c, "direction", c_direction_get, 0); rb_define_method (c, "direction=", c_direction_set, 1); rb_define_method (c, "spacing", c_spacing_get, 0); @@ -277,6 +301,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));