Class: Newt::CheckboxTree

Inherits:
Widget
  • Object
show all
Defined in:
ext/ruby_newt/ruby_newt.c

Direct Known Subclasses

CheckboxTreeMulti

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Widget

#==, #callback, #get_position, #get_size, #inspect, #takes_focus

Class Method Details

.new(*args) ⇒ Object



1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
# File 'ext/ruby_newt/ruby_newt.c', line 1180

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);
}

Instance Method Details

#add(args) ⇒ Object



1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
# File 'ext/ruby_newt/ruby_newt.c', line 1195

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(data) ⇒ Object



1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
# File 'ext/ruby_newt/ruby_newt.c', line 1248

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(data) ⇒ Object



1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
# File 'ext/ruby_newt/ruby_newt.c', line 1284

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_currentObject



1231
1232
1233
1234
1235
1236
1237
# File 'ext/ruby_newt/ruby_newt.c', line 1231

static VALUE rb_ext_CheckboxTree_GetCurrent(VALUE self)
{
  newtComponent co;

  Get_newtComponent(self, co);
  return (VALUE) newtCheckboxTreeGetCurrent(co);
}

#get_selectionObject



1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
# File 'ext/ruby_newt/ruby_newt.c', line 1220

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(data, value) ⇒ Object



1295
1296
1297
1298
1299
1300
1301
# File 'ext/ruby_newt/ruby_newt.c', line 1295

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(data) ⇒ Object



1239
1240
1241
1242
1243
1244
1245
1246
# File 'ext/ruby_newt/ruby_newt.c', line 1239

static VALUE rb_ext_CheckboxTree_SetCurrent(VALUE self, VALUE data)
{
  newtComponent co;

  Get_newtComponent(self, co);
  newtCheckboxTreeSetCurrent(co, (void *) data);
  return Qnil;
}

#set_entry(data, text) ⇒ Object



1266
1267
1268
1269
1270
1271
1272
1273
# File 'ext/ruby_newt/ruby_newt.c', line 1266

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(width) ⇒ Object



1275
1276
1277
1278
1279
1280
1281
1282
# File 'ext/ruby_newt/ruby_newt.c', line 1275

static VALUE rb_ext_CheckboxTree_SetWidth(VALUE self, VALUE width)
{
  newtComponent co;

  Get_newtComponent(self, co);
  newtCheckboxTreeSetWidth(co, NUM2INT(width));
  return Qnil;
}