class Newt::CheckboxTree
Public Class Methods
new(*args)
click to toggle source
static VALUE rb_ext_CheckboxTree_new(int argc, VALUE *argv, VALUE self)
{
newtComponent co;
int flags;
if (argc < 3 || argc > 4)
ARG_ERROR(argc, "3..4");
INIT_GUARD();
flags = (argc == 4) ? NUM2INT(argv[3]) : 0;
co = newtCheckboxTree(NUM2INT(argv[0]), NUM2INT(argv[1]), NUM2INT(argv[2]), flags);
return Make_Widget(self, co);
}
Public Instance Methods
add(*args)
click to toggle source
static VALUE rb_ext_CheckboxTree_AddItem(VALUE self, VALUE args)
{
newtComponent co;
int *indexes;
char *text; VALUE data;
int i, len, flags;
len = RARRAY_LENINT(args);
if (len < 4)
ARG_ERROR(len, "4+");
Get_newtComponent(self, 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;
text = StringValuePtr(RARRAY_PTR(args)[0]);
data = RARRAY_PTR(args)[1];
flags = NUM2INT(RARRAY_PTR(args)[2]);
Data_Attach(self, data);
newtCheckboxTreeAddArray(co, text, (void *) data, flags, indexes);
return Qnil;
}
find(p1)
click to toggle source
static VALUE rb_ext_CheckboxTree_FindItem(VALUE self, VALUE data)
{
newtComponent co;
int *path;
VALUE ary;
int i;
ary = Qnil;
Get_newtComponent(self, co);
path = newtCheckboxTreeFindItem(co, (void *) data);
if (path != NULL) {
ary = rb_ary_new();
for (i = 0; path[i] != NEWT_ARG_LAST; i++)
rb_ary_push(ary, INT2NUM(path[i]));
}
return ary;
}
get(p1)
click to toggle source
static VALUE rb_ext_CheckboxTree_GetEntryValue(VALUE self, VALUE data)
{
newtComponent co;
char value[2];
Get_newtComponent(self, co);
value[0] = newtCheckboxTreeGetEntryValue(co, (void *) data);
value[1] = '\0';
return (value[0] == -1) ? Qnil : rb_str_new_cstr(value);
}
get_current()
click to toggle source
static VALUE rb_ext_CheckboxTree_GetCurrent(VALUE self)
{
newtComponent co;
Get_newtComponent(self, co);
return (VALUE) newtCheckboxTreeGetCurrent(co);
}
get_selection()
click to toggle source
static VALUE rb_ext_CheckboxTree_GetSelection(VALUE self)
{
newtComponent co;
VALUE *data;
int numitems;
Get_newtComponent(self, co);
data = (VALUE *) newtCheckboxTreeGetSelection(co, &numitems);
return checkboxtree_collect_selection(numitems, data);
}
set(p1, p2)
click to toggle source
static VALUE rb_ext_CheckboxTree_SetEntryValue(VALUE self, VALUE data, VALUE value) {
newtComponent co;
Get_newtComponent(self, co);
newtCheckboxTreeSetEntryValue(co, (void *) data, StringValueCStr(value)[0]);
return Qnil;
}
set_current(p1)
click to toggle source
static VALUE rb_ext_CheckboxTree_SetCurrent(VALUE self, VALUE data)
{
newtComponent co;
Get_newtComponent(self, co);
newtCheckboxTreeSetCurrent(co, (void *) data);
return Qnil;
}
set_entry(p1, p2)
click to toggle source
static VALUE rb_ext_CheckboxTree_SetEntry(VALUE self, VALUE data, VALUE text)
{
newtComponent co;
Get_newtComponent(self, co);
newtCheckboxTreeSetEntry(co, (void *) data, StringValuePtr(text));
return Qnil;
}
set_width(p1)
click to toggle source
static VALUE rb_ext_CheckboxTree_SetWidth(VALUE self, VALUE width)
{
newtComponent co;
Get_newtComponent(self, co);
newtCheckboxTreeSetWidth(co, NUM2INT(width));
return Qnil;
}