Class: Newt::Form
Defined Under Namespace
Classes: ExitStruct
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
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
|
# File 'ext/ruby_newt/ruby_newt.c', line 1402
static VALUE rb_ext_Form_new(int argc, VALUE *argv, VALUE self)
{
newtComponent co;
VALUE helpTag;
int flags = 0;
if (argc > 3)
ARG_ERROR(argc, "0..3");
INIT_GUARD();
helpTag = (argc >= 2) ? argv[1] : Qnil;
flags = (argc == 3) ? NUM2INT(argv[2]) : 0;
/* Can't determine how Form scrollbars work, so just pass NULL. */
co = newtForm(NULL, (void *) helpTag, flags);
return Make_Widget(self, co);
}
|
Instance Method Details
#add(components) ⇒ Object
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
|
# File 'ext/ruby_newt/ruby_newt.c', line 1429
static VALUE rb_ext_Form_AddComponents(VALUE self, VALUE components)
{
Widget_data *form, *co;
VALUE str;
int i;
INIT_GUARD();
Get_Widget_Data(self, form);
if (RARRAY_LEN(components) > 0 && form->components == Qnil) {
form->components = rb_hash_new();
rb_gc_register_address(&form->components);
}
for (i = 0; i < RARRAY_LEN(components); i++) {
Get_Widget_Data(RARRAY_PTR(components)[i], co);
if (co->flags & FLAG_ADDED_TO_FORM) {
str = rb_inspect(RARRAY_PTR(components)[i]);
rb_raise(rb_eRuntimeError, "%s is already added to a Form",
StringValuePtr(str));
}
co->flags ^= FLAG_GC_FREE;
co->flags |= FLAG_ADDED_TO_FORM;
rb_hash_aset(form->components, PTR2NUM(co->co), RARRAY_PTR(components)[i]);
newtFormAddComponent(form->co, co->co);
}
return Qnil;
}
|
#add_hotkey(key) ⇒ Object
1527
1528
1529
1530
1531
1532
1533
1534
|
# File 'ext/ruby_newt/ruby_newt.c', line 1527
static VALUE rb_ext_Form_AddHotKey(VALUE self, VALUE key)
{
newtComponent form;
Get_newtComponent(self, form);
newtFormAddHotKey(form, NUM2INT(key));
return Qnil;
}
|
#draw ⇒ Object
1518
1519
1520
1521
1522
1523
1524
1525
|
# File 'ext/ruby_newt/ruby_newt.c', line 1518
static VALUE rb_ext_Form_DrawForm(VALUE self)
{
newtComponent form;
Get_newtComponent(self, form);
newtDrawForm(form);
return Qnil;
}
|
#get_current ⇒ Object
1477
1478
1479
1480
1481
1482
1483
1484
|
# File 'ext/ruby_newt/ruby_newt.c', line 1477
static VALUE rb_ext_Form_GetCurrent(VALUE self)
{
newtComponent form, co;
Get_newtComponent(self, form);
co = newtFormGetCurrent(form);
return Make_Widget_Ref(cWidget, co);
}
|
#run ⇒ Object
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
|
# File 'ext/ruby_newt/ruby_newt.c', line 1504
static VALUE rb_ext_Form_Run(VALUE self)
{
Widget_data *data;
rb_newt_ExitStruct *rb_es;
INIT_GUARD();
Get_Widget_Data(self, data);
rb_es = ALLOC(rb_newt_ExitStruct);
newtFormRun(data->co, &rb_es->es);
rb_es->components = data->components;
rb_gc_register_address(&rb_es->components);
return Data_Wrap_Struct(cExitStruct, 0, rb_newt_es_free, rb_es);
}
|
#set_background(color) ⇒ Object
1420
1421
1422
1423
1424
1425
1426
1427
|
# File 'ext/ruby_newt/ruby_newt.c', line 1420
static VALUE rb_ext_Form_SetBackground(VALUE self, VALUE color)
{
newtComponent form;
Get_newtComponent(self, form);
newtFormSetBackground(form, NUM2INT(color));
return Qnil;
}
|
#set_current(obj) ⇒ Object
1467
1468
1469
1470
1471
1472
1473
1474
1475
|
# File 'ext/ruby_newt/ruby_newt.c', line 1467
static VALUE rb_ext_Form_SetCurrent(VALUE self, VALUE obj)
{
newtComponent form, co;
Get_newtComponent(self, form);
Get_newtComponent(obj, co);
newtFormSetCurrent(form, co);
return Qnil;
}
|
#set_height(height) ⇒ Object
1486
1487
1488
1489
1490
1491
1492
1493
|
# File 'ext/ruby_newt/ruby_newt.c', line 1486
static VALUE rb_ext_Form_SetHeight(VALUE self, VALUE height)
{
newtComponent form;
Get_newtComponent(self, form);
newtFormSetHeight(form, NUM2INT(height));
return Qnil;
}
|
#set_size ⇒ Object
1458
1459
1460
1461
1462
1463
1464
1465
|
# File 'ext/ruby_newt/ruby_newt.c', line 1458
static VALUE rb_ext_Form_SetSize(VALUE self)
{
newtComponent form;
Get_newtComponent(self, form);
newtFormSetSize(form);
return Qnil;
}
|
#set_timer(millisecs) ⇒ Object
1536
1537
1538
1539
1540
1541
1542
1543
|
# File 'ext/ruby_newt/ruby_newt.c', line 1536
static VALUE rb_ext_Form_SetTimer(VALUE self, VALUE millisecs)
{
newtComponent form;
Get_newtComponent(self, form);
newtFormSetTimer(form, NUM2INT(millisecs));
return Qnil;
}
|
#set_width(width) ⇒ Object
1495
1496
1497
1498
1499
1500
1501
1502
|
# File 'ext/ruby_newt/ruby_newt.c', line 1495
static VALUE rb_ext_Form_SetWidth(VALUE self, VALUE width)
{
newtComponent form;
Get_newtComponent(self, form);
newtFormSetWidth(form, NUM2INT(width));
return Qnil;
}
|
#watch_fd(io, flags) ⇒ Object
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
|
# File 'ext/ruby_newt/ruby_newt.c', line 1545
static VALUE rb_ext_Form_WatchFd(VALUE self, VALUE io, VALUE flags)
{
newtComponent form;
int fd;
if (!rb_obj_is_kind_of(io, rb_cIO) && TYPE(io) != T_FIXNUM)
rb_raise(rb_eTypeError, "neither IO nor file descriptor");
Get_newtComponent(self, form);
fd = NUM2INT(rb_funcall(io, rb_intern("fileno"), 0));
newtFormWatchFd(form, fd, NUM2INT(flags));
return Qnil;
}
|