Class: Newt::Grid
Class Method Summary collapse
Instance Method Summary collapse
- #get_size ⇒ Object
- #set_field(col, row, type, val, padLeft, padTop, padRight, padBottom, anchor, flags) ⇒ Object
- #wrapped_window(*args) ⇒ Object
Methods inherited from Widget
#==, #callback, #get_position, #inspect, #takes_focus
Class Method Details
.new(cols, rows) ⇒ Object
| 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 | # File 'ext/ruby_newt/ruby_newt.c', line 1687
static VALUE rb_ext_Grid_new(VALUE self, VALUE cols, VALUE rows)
{
  newtGrid grid;
  VALUE widget;
  int num_cols, num_rows;
  num_cols = NUM2INT(cols);
  num_rows = NUM2INT(rows);
  if (num_cols <= 0 || num_rows <= 0)
    rb_raise(rb_eRuntimeError, "specified number of columns or rows should be greater than 0");
  INIT_GUARD();
  grid = newtCreateGrid(num_cols, num_rows);
  widget = Data_Wrap_Struct(self, 0, 0, grid);
  rb_ivar_set(widget, IVAR_COLS, cols);
  rb_ivar_set(widget, IVAR_ROWS, rows);
  return widget;
} | 
Instance Method Details
#get_size ⇒ Object
| 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 | # File 'ext/ruby_newt/ruby_newt.c', line 1758
static VALUE rb_ext_Grid_GetSize(VALUE self)
{
  newtGrid grid;
  int width, height;
  INIT_GUARD();
  Data_Get_Struct(self, struct grid_s, grid);
  newtGridGetSize(grid, &width, &height);
  return rb_ary_new_from_args(2, INT2NUM(width), INT2NUM(height));
} | 
#set_field(col, row, type, val, padLeft, padTop, padRight, padBottom, anchor, flags) ⇒ Object
| 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 | # File 'ext/ruby_newt/ruby_newt.c', line 1707
static VALUE rb_ext_Grid_SetField(VALUE self, VALUE col, VALUE row, VALUE type, VALUE val,
    VALUE padLeft, VALUE padTop, VALUE padRight, VALUE padBottom, VALUE anchor, VALUE flags)
{
  newtGrid grid;
  void *co;
  int icol, irow, itype, cols, rows;
  icol = NUM2INT(col);
  irow = NUM2INT(row);
  itype = NUM2INT(type);
  cols = NUM2INT(rb_ivar_get(self, IVAR_COLS));
  rows = NUM2INT(rb_ivar_get(self, IVAR_ROWS));
  if (icol >= cols || irow >= rows)
    rb_raise(rb_eRuntimeError, "attempting to set a field at an invalid position (%d, %d)", icol, irow);
  INIT_GUARD();
  if (itype == NEWT_GRID_SUBGRID) {
    Data_Get_Struct(val, struct grid_s, co);
  } else {
    Get_Widget_Data(val, co);
    co = ((Widget_data *) co)->co;
  }
  Data_Get_Struct(self, struct grid_s, grid);
  newtGridSetField(grid, icol, irow, itype, co, NUM2INT(padLeft),
                   NUM2INT(padTop), NUM2INT(padRight), NUM2INT(padBottom),
                   NUM2INT(anchor), NUM2INT(flags));
  return Qnil;
} | 
#wrapped_window(*args) ⇒ Object
| 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 | # File 'ext/ruby_newt/ruby_newt.c', line 1739
static VALUE rb_ext_Grid_WrappedWindow(int argc, VALUE *argv, VALUE self)
{
  newtGrid grid;
  char *title;
  if (argc != 1 && argc != 3)
    ARG_ERROR(argc, "1 or 3");
  INIT_GUARD();
  title = StringValuePtr(argv[0]);
  Data_Get_Struct(self, struct grid_s, grid);
  if (argc == 1) {
    newtGridWrappedWindow(grid, title);
  } else if (argc == 3) {
    newtGridWrappedWindowAt(grid, title, NUM2INT(argv[1]), NUM2INT(argv[2]));
  }
  return Qnil;
} |