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, #takesFocus

Class Method Details

.new(left, top, height, flags) ⇒ Object



876
877
878
879
880
881
882
# File 'ext/ruby_newt/ruby_newt.c', line 876

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

#addObject

, VALUE index)



884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
# File 'ext/ruby_newt/ruby_newt.c', line 884

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
}