Class: Newt::CheckboxTree
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#add ⇒ Object
, VALUE index).
Methods inherited from Widget
Class Method Details
.new(left, top, height, flags) ⇒ Object
705 706 707 708 709 710 711 |
# File 'ext/ruby_newt/ruby_newt.c', line 705
static VALUE rb_ext_CheckboxTree_new(VALUE self, VALUE left, VALUE top, VALUE height, VALUE flags)
{
newtComponent co;
co = newtCheckboxTree(NUM2INT(left), NUM2INT(top), NUM2INT(height), NUM2INT(flags));
return Data_Wrap_Struct(self, 0, 0, co);
}
|
Instance Method Details
#add ⇒ Object
, VALUE index)
713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 |
# File 'ext/ruby_newt/ruby_newt.c', line 713
static VALUE rb_ext_CheckboxTree_AddItem(VALUE self, VALUE args)
/*rb_ext_CheckboxTree_AddItem(VALUE self, VALUE text, VALUE data, VALUE flags)*/
/*, VALUE index)*/
{
newtComponent co;
#if 1
int i, len;
int *indexes;
len = RARRAY_LEN(args);
if (len < 4) {
rb_raise(rb_eArgError, "4 arguments required");
} else {
Data_Get_Struct(self, struct newtComponent_struct, co);
indexes = ALLOCA_N(int, (len - 4) + 2);
for (i = 0; i < (len - 4) + 1; i++) {
indexes[i] = NUM2INT(RARRAY_PTR(args)[i+3]);
}
indexes[(len - 4) + 1] = NEWT_ARG_LAST;
switch(TYPE(RARRAY_PTR(args)[1])) {
case T_STRING:
newtCheckboxTreeAddArray(co, StringValuePtr(RARRAY_PTR(args)[0]), (void *)StringValuePtr(RARRAY_PTR(args)[1]),
NUM2INT(RARRAY_PTR(args)[2]), indexes);
break;
case T_FIXNUM:
newtCheckboxTreeAddArray(co, StringValuePtr(RARRAY_PTR(args)[0]), (void *)NUM2INT(RARRAY_PTR(args)[1]),
NUM2INT(RARRAY_PTR(args)[2]), indexes);
break;
default:
rb_raise(rb_eTypeError, "String or Fixnum expected");
break;
}
return Qnil;
}
#else
Data_Get_Struct(self, struct newtComponent_struct, co);
switch(TYPE(data)) {
case T_STRING:
newtCheckboxTreeAddItem(co, StringValuePtr(text), (void *)StringValuePtr(data), NUM2INT(flags), NEWT_ARG_APPEND, NEWT_ARG_LAST);
break;
case T_FIXNUM:
newtCheckboxTreeAddItem(co, StringValuePtr(text), (void *)NUM2INT(data), NUM2INT(flags), NEWT_ARG_APPEND, NEWT_ARG_LAST);
break;
default:
rb_raise(rb_eTypeError, "String or Fixnum expected");
break;
}
return Qnil;
#endif
}
|