class Newt::Grid
Public Class Methods
new(p1, p2)
click to toggle source
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;
}
Public Instance Methods
get_size()
click to toggle source
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(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)
click to toggle source
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)
click to toggle source
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;
}