Class: Newt::Entry

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

Class Method Details

.new(left, top, initialValue, width, flags) ⇒ Object



1101
1102
1103
1104
1105
1106
1107
1108
# File 'ext/ruby_newt/ruby_newt.c', line 1101

static VALUE rb_ext_Entry_new(VALUE self, VALUE left, VALUE top, VALUE initialValue, VALUE width, VALUE flags)
{
  newtComponent co;

  co = newtEntry(NUM2INT(left), NUM2INT(top), StringValuePtr(initialValue), NUM2INT(width),
      NULL, NUM2INT(flags));
  return Data_Wrap_Struct(self, 0, 0, co);
}

Instance Method Details

#getObject



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

static VALUE rb_ext_Entry_GetValue(VALUE self)
{
  newtComponent co;

  Data_Get_Struct(self, struct newtComponent_struct, co);
  return rb_str_new2(newtEntryGetValue(co));
}

#set(value, cursorAtEnd) ⇒ Object



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

static VALUE rb_ext_Entry_Set(VALUE self, VALUE value, VALUE cursorAtEnd)
{
  newtComponent co;

  Data_Get_Struct(self, struct newtComponent_struct, co);
  switch(TYPE(cursorAtEnd)) {
    case T_TRUE:
      newtEntrySet(co, StringValuePtr(value), 1);
      break;
    case T_FALSE:
      newtEntrySet(co, StringValuePtr(value), 0);
      break;
    case T_FIXNUM:
      newtEntrySet(co, StringValuePtr(value), NUM2INT(cursorAtEnd));
      break;
    default:
      rb_raise(rb_eTypeError, "Boolean or Fixnum expected");
      break;
  }

  return Qnil;
}

#set_flags(args) ⇒ Object



1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
# File 'ext/ruby_newt/ruby_newt.c', line 1141

static VALUE rb_ext_Entry_SetFlags(VALUE self, VALUE args)
{
  newtComponent co;
  long len;

  len = RARRAY_LEN(args);
  if (len == 1) {
    Data_Get_Struct(self, struct newtComponent_struct, co);
    newtEntrySetFlags(co, NUM2INT(RARRAY_PTR(args)[0]), NEWT_FLAGS_SET);
  } else if (len == 2) {
    Data_Get_Struct(self, struct newtComponent_struct, co);
    newtEntrySetFlags(co, NUM2INT(RARRAY_PTR(args)[0]), NUM2INT(RARRAY_PTR(args)[1]));
  } else {
    rb_raise(rb_eArgError, "1 argument or 2 arguments required");
  }
  return Qnil;
}