class Newt::Widget

Public Instance Methods

==(p1) click to toggle source
static VALUE rb_ext_Widget_equal(VALUE self, VALUE obj)
{
  newtComponent co, cco;
  void *data;

  if (NIL_P(obj)) return Qfalse;
  if (self == obj) return Qtrue;

  if (rb_obj_is_kind_of(obj, cWidget) || rb_obj_is_kind_of(obj, cExitStruct)) {
    Get_Widget_Data(self, data);
    co = ((Widget_data *) data)->co;
    if (rb_obj_is_kind_of(obj, cExitStruct)) {
      Data_Get_Struct(obj, rb_newt_ExitStruct, data);
      if (co == (((rb_newt_ExitStruct *) data)->es.u.co))
        return Qtrue;
    } else {
      Get_Widget_Data(obj, data);
      cco = ((Widget_data *) data)->co;
      if (co == cco) return Qtrue;
    }
  }
  return Qfalse;
}
callback(*args) click to toggle source
static VALUE rb_ext_Widget_callback(int argc, VALUE *argv, VALUE self)
{
  newtComponent co;
  VALUE cb, data = Qnil;

  if (argc < 1 || argc > 2)
    ARG_ERROR(argc, "1 or 2");

  INIT_GUARD();
  if (argc == 2)
    data = argv[1];

  Get_newtComponent(self, co);
  cb = rb_struct_new(rb_ext_sCallback, self, rb_binding_new(), argv[0], data, NULL);
  rb_obj_freeze(cb);
  rb_ivar_set(self, IVAR_WIDGET_CALLBACK, cb);
  newtComponentAddCallback(co, rb_ext_Widget_callback_function, (void *) cb);
  return Qnil;
}
get_position() click to toggle source
static VALUE rb_ext_Widget_GetPosition(VALUE self)
{
  newtComponent co;
  int left, top;

  Get_newtComponent(self, co);
  newtComponentGetPosition(co, &left, &top);
  return rb_ary_new_from_args(2, INT2NUM(left), INT2NUM(top));
}
get_size() click to toggle source
static VALUE rb_ext_Widget_GetSize(VALUE self)
{
  newtComponent co;
  int width, height;

  Get_newtComponent(self, co);
  newtComponentGetSize(co, &width, &height);
  return rb_ary_new_from_args(2, INT2NUM(width), INT2NUM(height));
}
inspect() click to toggle source
static VALUE rb_ext_Widget_inspect(VALUE self)
{
  newtComponent co;
  void *data;

  VALUE classname = rb_class_name(rb_obj_class(self));
  char *class = StringValuePtr(classname);

  Get_Widget_Data(self, data);
  co = ((Widget_data *) data)->co;
  return rb_sprintf("#<%s:%p component=%p>", class, (void *) self, co);
}
takes_focus(p1) click to toggle source
static VALUE rb_ext_Widget_takesFocus(VALUE self, VALUE index)
{
  newtComponent co;

  Get_newtComponent(self, co);
  newtComponentTakesFocus(co, NUM2INT(index));
  return Qnil;
}