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



999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
# File 'ext/ruby_newt/ruby_newt.c', line 999

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



1078
1079
1080
1081
1082
1083
1084
1085
1086
# File 'ext/ruby_newt/ruby_newt.c', line 1078

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



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

static VALUE rb_ext_Listbox_Clear(VALUE self)
{
  newtComponent co;

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

#clear_selectionObject



1133
1134
1135
1136
1137
1138
1139
1140
# File 'ext/ruby_newt/ruby_newt.c', line 1133

static VALUE rb_ext_Listbox_ClearSelection(VALUE self)
{
  newtComponent co;

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

#delete(data) ⇒ Object



1098
1099
1100
1101
1102
1103
1104
1105
# File 'ext/ruby_newt/ruby_newt.c', line 1098

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



1040
1041
1042
1043
1044
1045
1046
1047
1048
# File 'ext/ruby_newt/ruby_newt.c', line 1040

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



1014
1015
1016
1017
1018
1019
1020
# File 'ext/ruby_newt/ruby_newt.c', line 1014

static VALUE rb_ext_Listbox_GetCurrent(VALUE self)
{
  newtComponent co;

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

#get_selectionObject



1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
# File 'ext/ruby_newt/ruby_newt.c', line 1116

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



1088
1089
1090
1091
1092
1093
1094
1095
1096
# File 'ext/ruby_newt/ruby_newt.c', line 1088

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



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

static VALUE rb_ext_Listbox_ItemCount(VALUE self)
{
  newtComponent co;

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

#select(key, sense) ⇒ Object



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

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



1050
1051
1052
1053
1054
1055
1056
1057
# File 'ext/ruby_newt/ruby_newt.c', line 1050

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



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

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



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

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



1068
1069
1070
1071
1072
1073
1074
1075
1076
# File 'ext/ruby_newt/ruby_newt.c', line 1068

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



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

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

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