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, #get_position, #get_size, #inspect, #takes_focus

Class Method Details

.new(*args) ⇒ Object



1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
# File 'ext/ruby_newt/ruby_newt.c', line 1559

static VALUE rb_ext_Entry_new(int argc, VALUE *argv, VALUE self)
{
  newtComponent co;
  int flags;

  if (argc < 4 || argc > 5)
    ARG_ERROR(argc, "4..5");

  INIT_GUARD();
  flags = (argc == 5) ? NUM2INT(argv[4]) : 0;

  co = newtEntry(NUM2INT(argv[0]), NUM2INT(argv[1]), StringValuePtr(argv[2]),
                 NUM2INT(argv[3]), NULL, flags);

  return Make_Widget(self, co);
}

Instance Method Details

#getObject



1598
1599
1600
1601
1602
1603
1604
# File 'ext/ruby_newt/ruby_newt.c', line 1598

static VALUE rb_ext_Entry_GetValue(VALUE self)
{
  newtComponent co;

  Get_newtComponent(self, co);
  return rb_str_new2(newtEntryGetValue(co));
}

#get_cursor_positionObject



1650
1651
1652
1653
1654
1655
1656
# File 'ext/ruby_newt/ruby_newt.c', line 1650

static VALUE rb_ext_Entry_GetCursorPosition(VALUE self)
{
  newtComponent co;

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

#set(value, cursorAtEnd) ⇒ Object



1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
# File 'ext/ruby_newt/ruby_newt.c', line 1576

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

  Get_newtComponent(self, 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_colors(normal, disabled) ⇒ Object



1641
1642
1643
1644
1645
1646
1647
1648
# File 'ext/ruby_newt/ruby_newt.c', line 1641

static VALUE rb_ext_Entry_SetColors(VALUE self, VALUE normal, VALUE disabled)
{
  newtComponent co;

  Get_newtComponent(self, co);
  newtEntrySetColors(co, NUM2INT(normal), NUM2INT(disabled));
  return Qnil;
}

#set_cursor_position(position) ⇒ Object



1658
1659
1660
1661
1662
1663
1664
1665
# File 'ext/ruby_newt/ruby_newt.c', line 1658

static VALUE rb_ext_Entry_SetCursorPosition(VALUE self, VALUE position)
{
  newtComponent co;

  Get_newtComponent(self, co);
  newtEntrySetCursorPosition(co, NUM2INT(position));
  return Qnil;
}

#set_filter(*args) ⇒ Object



1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
# File 'ext/ruby_newt/ruby_newt.c', line 1606

static VALUE rb_ext_Entry_SetFilter(int argc, VALUE *argv, VALUE self)
{
  newtComponent co;
  VALUE cb, data = Qnil;

  if (argc < 1 || argc > 2)
    ARG_ERROR(argc, "1 or 2");

  if (argc == 2)
    data = argv[1];

  Get_newtComponent(self, co);
  cb = rb_struct_new(rb_ext_sCallback, self, rb_binding_new(), argv[0], data, NULL);
  rb_obj_freeze(cb);
  rb_ivar_set(self, IVAR_FILTER_CALLBACK, cb);
  newtEntrySetFilter(co, rb_ext_Entry_filter_function, (void *) cb);
  return Qnil;
}

#set_flags(*args) ⇒ Object



1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
# File 'ext/ruby_newt/ruby_newt.c', line 1625

static VALUE rb_ext_Entry_SetFlags(int argc, VALUE *argv, VALUE self)
{
  newtComponent co;
  int sense = NEWT_FLAGS_SET;

  if (argc < 1 || argc > 2)
    ARG_ERROR(argc, "1..2");

  if (argc == 2)
    sense = NUM2INT(argv[1]);

  Get_newtComponent(self, co);
  newtEntrySetFlags(co, NUM2INT(argv[0]), sense);
  return Qnil;
}