Class: Newt::Listbox

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

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



1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
# File 'ext/ruby_newt/ruby_newt.c', line 1006

static VALUE rb_ext_Listbox_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 = newtListbox(NUM2INT(argv[0]), NUM2INT(argv[1]), NUM2INT(argv[2]), flags);
  return Make_Widget(self, co);
}

Instance Method Details

#append(text, data) ⇒ Object



1085
1086
1087
1088
1089
1090
1091
1092
1093
# File 'ext/ruby_newt/ruby_newt.c', line 1085

static VALUE rb_ext_Listbox_AppendEntry(VALUE self, VALUE text, VALUE data)
{
  newtComponent co;

  Get_newtComponent(self, co);
  Data_Attach(self, data);
  newtListboxAppendEntry(co, StringValuePtr(text), (void *) data);
  return Qnil;
}

#clearObject



1114
1115
1116
1117
1118
1119
1120
1121
# File 'ext/ruby_newt/ruby_newt.c', line 1114

static VALUE rb_ext_Listbox_Clear(VALUE self)
{
  newtComponent co;

  Get_newtComponent(self, co);
  newtListboxClear(co);
  return Qnil;
}

#clear_selectionObject



1140
1141
1142
1143
1144
1145
1146
1147
# File 'ext/ruby_newt/ruby_newt.c', line 1140

static VALUE rb_ext_Listbox_ClearSelection(VALUE self)
{
  newtComponent co;

  Get_newtComponent(self, co);
  newtListboxClearSelection(co);
  return Qnil;
}

#delete(data) ⇒ Object



1105
1106
1107
1108
1109
1110
1111
1112
# File 'ext/ruby_newt/ruby_newt.c', line 1105

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

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

#get(num) ⇒ Object



1047
1048
1049
1050
1051
1052
1053
1054
1055
# File 'ext/ruby_newt/ruby_newt.c', line 1047

static VALUE rb_ext_Listbox_GetEntry(VALUE self, VALUE num)
{
  char *text; void *data;
  newtComponent co;

  Get_newtComponent(self, co);
  newtListboxGetEntry(co, NUM2INT(num), &text, &data);
  return rb_ary_new_from_args(2, rb_str_new2(text), (VALUE *) data);
}

#get_currentObject



1021
1022
1023
1024
1025
1026
1027
# File 'ext/ruby_newt/ruby_newt.c', line 1021

static VALUE rb_ext_Listbox_GetCurrent(VALUE self)
{
  newtComponent co;

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

#get_selectionObject



1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
# File 'ext/ruby_newt/ruby_newt.c', line 1123

static VALUE rb_ext_Listbox_GetSelection(VALUE self)
{
  newtComponent co;
  VALUE ary, item;
  void **items;
  int i, numitems = 0;

  Get_newtComponent(self, co);
  items = newtListboxGetSelection(co, &numitems);
  ary = rb_ary_new();
  for (i = 0; i < numitems; i++) {
      item = (VALUE) items[i];
      rb_ary_push(ary, item);
  }
  return ary;
}

#insert(text, data, key) ⇒ Object



1095
1096
1097
1098
1099
1100
1101
1102
1103
# File 'ext/ruby_newt/ruby_newt.c', line 1095

static VALUE rb_ext_Listbox_InsertEntry(VALUE self, VALUE text, VALUE data, VALUE key)
{
  newtComponent co;

  Get_newtComponent(self, co);
  Data_Attach(self, data);
  newtListboxInsertEntry(co, StringValuePtr(text), (void *) data, (void *) key);
  return Qnil;
}

#item_countObject



1158
1159
1160
1161
1162
1163
1164
# File 'ext/ruby_newt/ruby_newt.c', line 1158

static VALUE rb_ext_Listbox_ItemCount(VALUE self)
{
  newtComponent co;

  Get_newtComponent(self, co);
  return INT2NUM(newtListboxItemCount(co));
}

#select(key, sense) ⇒ Object



1149
1150
1151
1152
1153
1154
1155
1156
# File 'ext/ruby_newt/ruby_newt.c', line 1149

static VALUE rb_ext_Listbox_SelectItem(VALUE self, VALUE key, VALUE sense)
{
  newtComponent co;

  Get_newtComponent(self, co);
  newtListboxSelectItem(co, (void *) key, NUM2INT(sense));
  return Qnil;
}

#set(num, text) ⇒ Object



1057
1058
1059
1060
1061
1062
1063
1064
# File 'ext/ruby_newt/ruby_newt.c', line 1057

static VALUE rb_ext_Listbox_SetEntry(VALUE self, VALUE num, VALUE text)
{
  newtComponent co;

  Get_newtComponent(self, co);
  newtListboxSetEntry(co, NUM2INT(num), StringValuePtr(text));
  return Qnil;
}

#set_current(num) ⇒ Object



1029
1030
1031
1032
1033
1034
1035
1036
# File 'ext/ruby_newt/ruby_newt.c', line 1029

static VALUE rb_ext_Listbox_SetCurrent(VALUE self, VALUE num)
{
  newtComponent co;

  Get_newtComponent(self, co);
  newtListboxSetCurrent(co, NUM2INT(num));
  return Qnil;
}

#set_current_by_key(key) ⇒ Object



1038
1039
1040
1041
1042
1043
1044
1045
# File 'ext/ruby_newt/ruby_newt.c', line 1038

static VALUE rb_ext_Listbox_SetCurrentByKey(VALUE self, VALUE key)
{
  newtComponent co;

  Get_newtComponent(self, co);
  newtListboxSetCurrentByKey(co, (void *) key);
  return Qnil;
}

#set_data(num, data) ⇒ Object



1075
1076
1077
1078
1079
1080
1081
1082
1083
# File 'ext/ruby_newt/ruby_newt.c', line 1075

static VALUE rb_ext_Listbox_SetData(VALUE self, VALUE num, VALUE data)
{
  newtComponent co;

  Get_newtComponent(self, co);
  Data_Attach(self, data);
  newtListboxSetData(co, NUM2INT(num), (void *) data);
  return Qnil;
}

#set_width(width) ⇒ Object



1066
1067
1068
1069
1070
1071
1072
1073
# File 'ext/ruby_newt/ruby_newt.c', line 1066

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

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