Class: Newt::Checkbox

Inherits:
Widget
  • Object
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, text, defValue, seq) ⇒ Object



423
424
425
426
427
428
429
430
431
432
433
434
435
436
# File 'ext/ruby_newt/ruby_newt.c', line 423

static VALUE rb_ext_Checkbox_new(VALUE self, VALUE left, VALUE top, VALUE text,
    VALUE defValue, VALUE seq)
{
  newtComponent co;

  if (NIL_P(seq)) {
    co = newtCheckbox(NUM2INT(left), NUM2INT(top), StringValuePtr(text),
        StringValuePtr(defValue)[0], NULL, NULL);
  } else {
    co = newtCheckbox(NUM2INT(left), NUM2INT(top), StringValuePtr(text),
        StringValuePtr(defValue)[0], StringValuePtr(seq), NULL);
  }
  return Data_Wrap_Struct(self, 0, 0, co);
}

Instance Method Details

#getObject



438
439
440
441
442
443
444
445
446
447
# File 'ext/ruby_newt/ruby_newt.c', line 438

static VALUE rb_ext_Checkbox_GetValue(VALUE self)
{
  newtComponent co;
  char value[10];

  Data_Get_Struct(self, struct newtComponent_struct, co);
  value[0] = newtCheckboxGetValue(co);
  value[1] = '\0';
  return rb_str_new2(value);
}

#set(value) ⇒ Object



449
450
451
452
453
454
455
456
457
458
# File 'ext/ruby_newt/ruby_newt.c', line 449

static VALUE rb_ext_Checkbox_SetValue(VALUE self, VALUE value)
{
  newtComponent co;

  Data_Get_Struct(self, struct newtComponent_struct, co);
  if (RSTRING_LEN(value) > 0) {
    newtCheckboxSetValue(co, StringValuePtr(value)[0]);
  }
  return Qnil;
}

#set_flags(args) ⇒ Object



460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
# File 'ext/ruby_newt/ruby_newt.c', line 460

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

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

  return Qnil;
}