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

Class Method Details

.new(left, top, height, flags) ⇒ Object



495
496
497
498
499
500
501
# File 'ext/ruby_newt/ruby_newt.c', line 495

static VALUE rb_ext_Listbox_new(VALUE self, VALUE left, VALUE top, VALUE height, VALUE flags)
{
  newtComponent co;

  co = newtListbox(NUM2INT(left), NUM2INT(top), NUM2INT(height), NUM2INT(flags));
  return Data_Wrap_Struct(self, 0, 0, co);
}

Instance Method Details

#append(text, data) ⇒ Object



586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
# File 'ext/ruby_newt/ruby_newt.c', line 586

static VALUE rb_ext_Listbox_AppendEntry(VALUE self, VALUE text, VALUE data)
{
  newtComponent co;

  Data_Get_Struct(self, struct newtComponent_struct, co);

  switch(TYPE(data)) {
    case T_STRING:
      newtListboxAppendEntry(co, StringValuePtr(text), (void *)StringValuePtr(data));
      break;
    case T_FIXNUM:
      newtListboxAppendEntry(co, StringValuePtr(text), (void *)NUM2INT(data));
      break;
    default:
      rb_raise(rb_eTypeError, "String or Fixnum expected");
      break;
  }
  return Qnil;
}

#clearObject



665
666
667
668
669
670
671
672
673
# File 'ext/ruby_newt/ruby_newt.c', line 665

static VALUE rb_ext_Listbox_Clear(VALUE self)
{
  newtComponent co;

  Data_Get_Struct(self, struct newtComponent_struct, co);

  newtListboxClear(co);
  return Qnil;
}

#clearSelectionObject



675
676
677
678
679
680
681
682
683
# File 'ext/ruby_newt/ruby_newt.c', line 675

static VALUE rb_ext_Listbox_ClearSelection(VALUE self)
{
  newtComponent co;

  Data_Get_Struct(self, struct newtComponent_struct, co);

  newtListboxClearSelection(co);
  return Qnil;
}

#delete(data) ⇒ Object



645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
# File 'ext/ruby_newt/ruby_newt.c', line 645

static VALUE rb_ext_Listbox_DeleteEntry(VALUE self, VALUE data)
{
  newtComponent co;

  Data_Get_Struct(self, struct newtComponent_struct, co);

  switch(TYPE(data)) {
    case T_STRING:
      newtListboxDeleteEntry(co, (void *)StringValuePtr(data));
      break;
    case T_FIXNUM:
      newtListboxDeleteEntry(co, (void *)NUM2INT(data));
      break;
    default:
      rb_raise(rb_eTypeError, "String or Fixnum expected");
      break;
  }
  return Qnil;
}

#get_currentObject



503
504
505
506
507
508
509
# File 'ext/ruby_newt/ruby_newt.c', line 503

static VALUE rb_ext_Listbox_GetCurrentAsNumber(VALUE self)
{
  newtComponent co;

  Data_Get_Struct(self, struct newtComponent_struct, co);
  return INT2NUM((int *) newtListboxGetCurrent(co));
}

#get_current_as_numberObject



503
504
505
506
507
508
509
# File 'ext/ruby_newt/ruby_newt.c', line 503

static VALUE rb_ext_Listbox_GetCurrentAsNumber(VALUE self)
{
  newtComponent co;

  Data_Get_Struct(self, struct newtComponent_struct, co);
  return INT2NUM((int *) newtListboxGetCurrent(co));
}

#get_current_as_stringObject



511
512
513
514
515
516
517
# File 'ext/ruby_newt/ruby_newt.c', line 511

static VALUE rb_ext_Listbox_GetCurrentAsString(VALUE self)
{
  newtComponent co;

  Data_Get_Struct(self, struct newtComponent_struct, co);
  return rb_str_new2((char *) newtListboxGetCurrent(co));
}

#insert(text, data, key) ⇒ Object



606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
# File 'ext/ruby_newt/ruby_newt.c', line 606

static VALUE rb_ext_Listbox_InsertEntry(VALUE self, VALUE text, VALUE data, VALUE key)
{
  newtComponent co;

  Data_Get_Struct(self, struct newtComponent_struct, co);

  switch(TYPE(data)) {
    case T_STRING:
      switch(TYPE(key)) {
        case T_STRING:
          newtListboxInsertEntry(co, StringValuePtr(text), (void *)StringValuePtr(data), (void *)StringValuePtr(key));
          break;
        case T_FIXNUM:
          newtListboxInsertEntry(co, StringValuePtr(text), (void *)StringValuePtr(data), (void *)NUM2INT(key));
          break;
        default:
          rb_raise(rb_eTypeError, "String or Fixnum expected");
          break;
      }
    case T_FIXNUM:
      switch(TYPE(key)) {
        case T_STRING:
          newtListboxInsertEntry(co, StringValuePtr(text), (void *)NUM2INT(data), (void *)StringValuePtr(key));
          break;
        case T_FIXNUM:
          newtListboxInsertEntry(co, StringValuePtr(text), (void *)NUM2INT(data), (void *)NUM2INT(key));
          break;
        default:
          rb_raise(rb_eTypeError, "String or Fixnum expected");
          break;
      }
      break;
    default:
      rb_raise(rb_eTypeError, "String or Fixnum expected");
      break;
  }
  return Qnil;
}

#select(key, sense) ⇒ Object



685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
# File 'ext/ruby_newt/ruby_newt.c', line 685

static VALUE rb_ext_Listbox_SelectItem(VALUE self, VALUE key, VALUE sense)
{
  newtComponent co;

  Data_Get_Struct(self, struct newtComponent_struct, co);

  switch(TYPE(key)) {
    case T_STRING:
      newtListboxSelectItem(co, (void *)StringValuePtr(key), NUM2INT(sense));
      break;
    case T_FIXNUM:
      newtListboxSelectItem(co, (void *)NUM2INT(key), NUM2INT(sense));
      break;
    default:
      rb_raise(rb_eTypeError, "String or Fixnum expected");
      break;
  }
  return Qnil;
}

#set(num, text) ⇒ Object



548
549
550
551
552
553
554
555
# File 'ext/ruby_newt/ruby_newt.c', line 548

static VALUE rb_ext_Listbox_SetEntry(VALUE self, VALUE num, VALUE text)
{
  newtComponent co;

  Data_Get_Struct(self, struct newtComponent_struct, co);
  newtListboxSetEntry(co, NUM2INT(num), StringValuePtr(text));
  return Qnil;
}

#set_current(num) ⇒ Object



519
520
521
522
523
524
525
526
# File 'ext/ruby_newt/ruby_newt.c', line 519

static VALUE rb_ext_Listbox_SetCurrent(VALUE self, VALUE num)
{
  newtComponent co;

  Data_Get_Struct(self, struct newtComponent_struct, co);
  newtListboxSetCurrent(co, NUM2INT(num));
  return Qnil;
}

#set_width(width) ⇒ Object



557
558
559
560
561
562
563
564
# File 'ext/ruby_newt/ruby_newt.c', line 557

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

  Data_Get_Struct(self, struct newtComponent_struct, co);
  newtListboxSetWidth(co, NUM2INT(width));
  return Qnil;
}

#setCurrentByKey(key) ⇒ Object



528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
# File 'ext/ruby_newt/ruby_newt.c', line 528

static VALUE rb_ext_Listbox_SetCurrentByKey(VALUE self, VALUE key)
{
  newtComponent co;

  Data_Get_Struct(self, struct newtComponent_struct, co);

  switch(TYPE(key)) {
    case T_STRING:
      newtListboxSetCurrentByKey(co, (void *)StringValuePtr(key));
      break;
    case T_FIXNUM:
      newtListboxSetCurrentByKey(co, (void *)NUM2INT(key));
      break;
    default:
      rb_raise(rb_eTypeError, "String or Fixnum expected");
      break;
  }
  return Qnil;
}

#setData(num, data) ⇒ Object



566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
# File 'ext/ruby_newt/ruby_newt.c', line 566

static VALUE rb_ext_Listbox_SetData(VALUE self, VALUE num, VALUE data)
{
  newtComponent co;

  Data_Get_Struct(self, struct newtComponent_struct, co);

  switch(TYPE(data)) {
    case T_STRING:
      newtListboxSetData(co, NUM2INT(num), (void *)StringValuePtr(data));
      break;
    case T_FIXNUM:
      newtListboxSetData(co, NUM2INT(num), (void *)NUM2INT(data));
      break;
    default:
      rb_raise(rb_eTypeError, "String or Fixnum expected");
      break;
  }
  return Qnil;
}