Exemplo n.º 1
0
/*
 * call-seq:
 *   inspect -> String
 *
 * Human-readable description.
 * ===Return value
 * String
*/
DLL_LOCAL VALUE _inspect(VALUE self)
{
	return rb_sprintf( "%s(%d, %d)",
		rb_obj_classname( self ),
		RB_NUM2INT(_getWidth(self)),
		RB_NUM2INT(_getHeight(self)));
}
Exemplo n.º 2
0
/*
 *  call-seq:
 *     WIN32OLE_VARIANT.new(val, vartype) #=> WIN32OLE_VARIANT object.
 *
 *  Returns Ruby object wrapping OLE variant.
 *  The first argument specifies Ruby object to convert OLE variant variable.
 *  The second argument specifies VARIANT type.
 *  In some situation, you need the WIN32OLE_VARIANT object to pass OLE method
 *
 *     shell = WIN32OLE.new("Shell.Application")
 *     folder = shell.NameSpace("C:\\Windows")
 *     item = folder.ParseName("tmp.txt")
 *     # You can't use Ruby String object to call FolderItem.InvokeVerb.
 *     # Instead, you have to use WIN32OLE_VARIANT object to call the method.
 *     shortcut = WIN32OLE_VARIANT.new("Create Shortcut(\&S)")
 *     item.invokeVerb(shortcut)
 *
 */
static VALUE
folevariant_initialize(VALUE self, VALUE args)
{
    int len = 0;
    VARIANT var;
    VALUE val;
    VALUE vvt;
    VARTYPE vt;
    struct olevariantdata *pvar;

    len = RARRAY_LEN(args);
    rb_check_arity(len, 1, 3);
    VariantInit(&var);
    val = rb_ary_entry(args, 0);

    check_type_val2variant(val);

    TypedData_Get_Struct(self, struct olevariantdata, &olevariant_datatype, pvar);
    if (len == 1) {
        ole_val2variant(val, &(pvar->var));
    } else {
        vvt = rb_ary_entry(args, 1);
        vt = RB_NUM2INT(vvt);
        if ((vt & VT_TYPEMASK) == VT_RECORD) {
            rb_raise(rb_eArgError, "not supported VT_RECORD WIN32OLE_VARIANT object");
        }
        ole_val2olevariantdata(val, vt, pvar);
    }
    return self;
}
Exemplo n.º 3
0
DLL_LOCAL VALUE _class_get(int argc,VALUE *argv,VALUE self)
{

	VALUE size,family,style,weight,underlined;
	rb_scan_args(argc, argv, "41",&size,&family,&style,&weight,&underlined);
	//TODO add refcounting
	wxFont *font = wxTheFontList->FindOrCreateFont(
		RB_NUM2INT(size),
		unwrapenum<wxFontFamily>(family),
		unwrapenum<wxFontStyle>(style),
		unwrapenum<wxFontWeight>(weight),
		RTEST(underlined)
	);

	if(!font || !font->IsOk())
		return Qnil;

	//look in the FontList holder is font was already wrapped
	fontlisttype::iterator it = fontlistholder.find(font);
	if(it != fontlistholder.end()) {
		return it->second;
	} else {
		//wrap wxFont pointer to ruby object
		VALUE result = wrap(font);

		//FontList objects should not be changed
		rb_obj_freeze(result);
		//Prevent FontList objects from been deleted
		rwx_refobject(result);
		//add wrapped font to the FontList holder to find it again
		fontlistholder[font] = result;
		return result;
	}
}
Exemplo n.º 4
0
/*
 * call-seq:
 *   prepend_stretch_spacer([prop])
 *
 * prepends a new stretch spacer WX::Sizer::Item
 * ===Arguments
 * * prop is a Integer
 * ===Return value
 * WX::Sizer::Item
 */
DLL_LOCAL VALUE _prepend_stretch_spacer(int argc,VALUE *argv,VALUE self)
{
	VALUE prop;
	rb_scan_args(argc, argv, "01",&prop);

	return wrap(_self->PrependStretchSpacer(NIL_P(prop) ? 1 : RB_NUM2INT(prop)));
}
Exemplo n.º 5
0
DLL_LOCAL VALUE _getItem(VALUE self,VALUE index)
{
	int cidx = RB_NUM2INT(index);
	if(check_index(cidx,_self->GetItemCount()))
		return wrap(_self->GetItem(cidx));
	return Qnil;
}
Exemplo n.º 6
0
/*
 * call-seq:
 *   insert_stretch_spacer(pos,[prop])
 *
 * inserts a new stretch spacer WX::Sizer::Item
 * ===Arguments
 * * pos is Integer
 * * prop is a Integer
 * ===Return value
 * WX::Sizer::Item
 */
DLL_LOCAL VALUE _insert_stretch_spacer(int argc,VALUE *argv,VALUE self)
{
	VALUE idx,prop;
	rb_scan_args(argc, argv, "11",&idx,&prop);

	return wrap(_self->InsertStretchSpacer(RB_NUM2UINT(idx),NIL_P(prop) ? 1 : RB_NUM2INT(prop)));
}
Exemplo n.º 7
0
/*
 * call-seq:
 *   dec_by(x, y) -> WX::Size
 *   dec_by(i) -> WX::Size
 *   dec_by(size) -> WX::Size
 *   - i -> WX::Size
 *   - size -> WX::Size
 *
 * decrease this size and return new size.
 * ===Arguments
 * * x, y and i are Integer
 * * size is a WX::Size
 * ===Return value
 * WX::Size
 */
DLL_LOCAL VALUE _decBy(int argc,VALUE *argv,VALUE self)
{
	VALUE x, y;
	rb_scan_args(argc, argv, "11", &x, &y);

	wxSize* result = new wxSize(*_self);
	if(NIL_P(y)) {
		if(is_wrapable<wxSize>(x)) {
			result->DecBy(unwrap<wxSize>(x));
		} else {
			result->DecBy(RB_NUM2INT(x));
		}
	} else {
		result->DecBy(RB_NUM2INT(x), RB_NUM2INT(y));
	}
	return wrapTypedPtr(result, rb_class_of(self));
}
Exemplo n.º 8
0
DLL_LOCAL VALUE _remove(VALUE self,VALUE index)
{
	rb_check_frozen(self);
	int cidx = RB_NUM2INT(index);
	if(check_index(cidx,_self->GetItemCount()))
		return wrap(_self->Remove(cidx));
	return Qnil;
}
Exemplo n.º 9
0
/*
 * call-seq:
 *   dec_by!(x, y) -> self
 *   dec_by!(i) -> self
 *   dec_by!(size) -> self
 *
 * decrease this size and return new size.
 * ===Arguments
 * * x, y and i are Integer
 * * size is a WX::Size
 * ===Return value
 * self
 */
DLL_LOCAL VALUE _decBy_self(int argc,VALUE *argv,VALUE self)
{
	VALUE x, y;
	rb_scan_args(argc, argv, "11", &x, &y);

	rb_check_frozen(self);

	if(NIL_P(y)) {
		if(is_wrapable<wxSize>(x)) {
			_self->DecBy(unwrap<wxSize>(x));
		} else {
			_self->DecBy(RB_NUM2INT(x));
		}
	} else {
		_self->DecBy(RB_NUM2INT(x), RB_NUM2INT(y));
	}
	return self;
}
Exemplo n.º 10
0
/*
 * call-seq:
 *   insert(pos, window, [options])
 *   insert(pos, sizer, [options])
 *   insert(pos, size, [options])
 *
 * inserts a new WX::Sizer::Item into the given position.
 * ===Arguments
 * * pos is Integer
 * * window is a WX::Window
 * * sizer is a WX::Sizer
 * * size is a WX::Size
 *
 * *options: Hash with possible options to set:
 *   * expand true/false says if the element should expand to the whole size
 *   * proportion Integer
 * ===Return value
 * WX::Sizer::Item
 */
DLL_LOCAL VALUE _insert(int argc,VALUE *argv,VALUE self)
{
	VALUE index,obj,hash;
	rb_scan_args(argc, argv, "2:",&index,&obj,&hash);

	wxSizerFlags flags(unwrap<wxSizerFlags>(hash));

	if(rb_obj_is_kind_of(obj, rb_cWXWindow)) {
		wxWindow *win = unwrap<wxWindow*>(obj);
		if(check_window(_self, win, hash))
			return wrap(_self->Insert(RB_NUM2INT(index), win, flags));
	} else if(rb_obj_is_kind_of(obj, rb_cWXSizer))
		return wrap(_self->Insert(RB_NUM2INT(index),unwrap<wxSizer*>(obj),flags));
	else {
		const wxSize &size = unwrap<wxSize>(obj);
		return wrap(_self->Insert(RB_NUM2INT(index),size.GetWidth(),size.GetHeight(),flags));
	}
	return Qnil;
}
Exemplo n.º 11
0
wxSize unwrap< wxSize >(const VALUE &vsize)
{
	if(rb_obj_is_kind_of(vsize, rb_cArray) && RARRAY_LEN(vsize) == 2 ){
			wxSize size;
			size.SetWidth(RB_NUM2INT(RARRAY_AREF(vsize,0)));
			size.SetHeight(RB_NUM2INT(RARRAY_AREF(vsize,1)));
			return size;
	}else if(rb_obj_is_kind_of(vsize, rb_cHash)){
		wxSize size;
		size.SetWidth(RB_NUM2INT(rb_hash_aref(vsize,RB_ID2SYM(rwxID_width))));
		size.SetHeight(RB_NUM2INT(rb_hash_aref(vsize,RB_ID2SYM(rwxID_height))));
		return size;
	}else if(rb_obj_is_kind_of(vsize, rb_cWXRect)){
		return unwrapTypedPtr<wxRect>(vsize, rb_cWXRect)->GetSize();
	}else if(!rb_obj_is_kind_of(vsize, rb_cWXSize) &&
		rb_respond_to(vsize,rwxID_width) &&
		rb_respond_to(vsize,rwxID_height)){
		wxSize size;
		size.SetWidth(RB_NUM2INT(rb_funcall(vsize,rwxID_width,0)));
		size.SetHeight(RB_NUM2INT(rb_funcall(vsize,rwxID_height,0)));
		return size;
	}else{
		return *unwrap<wxSize*>(vsize);
	}
}
Exemplo n.º 12
0
static LONG *
ary2safe_array_index(int ary_size, VALUE *ary, SAFEARRAY *psa)
{
    long dim;
    LONG *pid;
    long i;
    dim = SafeArrayGetDim(psa);
    if (dim != ary_size) {
        rb_raise(rb_eArgError, "unmatch number of indices");
    }
    pid = ALLOC_N(LONG, dim);
    if (pid == NULL) {
        rb_raise(rb_eRuntimeError, "failed to allocate memory for indices");
    }
    for (i = 0; i < dim; i++) {
        pid[i] = RB_NUM2INT(ary[i]);
    }
    return pid;
}
Exemplo n.º 13
0
/*
 * call-seq:
 *   marshal_load(array) -> nil
 *
 * Provides marshalling support for use by the Marshal library.
 *
 *
 */
DLL_LOCAL VALUE _marshal_load(VALUE self,VALUE data)
{
	data = rb_Array(data);

	_self->Create(
		RB_NUM2INT(RARRAY_AREF(data,0)),
		unwrapenum<wxFontFamily>(RARRAY_AREF(data,1)),
		unwrapenum<wxFontStyle>(RARRAY_AREF(data,2)),
		unwrapenum<wxFontWeight>(RARRAY_AREF(data,3)),
		RTEST(RARRAY_AREF(data,4)),
		unwrap<wxString>(RARRAY_AREF(data,6)),
#ifdef HAVE_RUBY_ENCODING_H
		unwrapenum<wxFontEncoding>(RARRAY_AREF(data,7))
#else
		wxFONTENCODING_DEFAULT
#endif
	);

	_setStrikethrough(self,RARRAY_AREF(data,5));

	return self;
}
Exemplo n.º 14
0
/*
 * call-seq:
 *   image.blur_vertical(radius) -> WX::Image
 *
 * blur the image according to the specified pixel radius
 * ===Arguments
 * * radius Integer
 * ===Return value
 * WX::Image
*/
DLL_LOCAL VALUE _BlurVertical(VALUE self, VALUE radius)
{
	return wrap(_self->BlurVertical(RB_NUM2INT(radius)));
}
Exemplo n.º 15
0
/*
 * call-seq:
 *   prepend_spacer(size)
 *
 * prepend a new spacer WX::Sizer::Item
 * ===Arguments
 * * size is a Integer
 * ===Return value
 * WX::Sizer::Item
 */
DLL_LOCAL VALUE _prepend_spacer(VALUE self,VALUE size)
{
	return wrap(_self->PrependSpacer(RB_NUM2INT(size)));
}
Exemplo n.º 16
0
/*
 * call-seq:
 *   insert_spacer(pos, size)
 *
 * inserts a new spacer WX::Sizer::Item into the given position.
 * ===Arguments
 * * pos is Integer
 * * size is a Integer
 * ===Return value
 * WX::Sizer::Item
 */
DLL_LOCAL VALUE _insert_spacer(VALUE self,VALUE idx,VALUE size)
{
	return wrap(_self->InsertSpacer(RB_NUM2UINT(idx),RB_NUM2INT(size)));
}
Exemplo n.º 17
0
/*
 * call-seq:
 *   add_spacer(size)
 *
 * adds a new spacer WX::Sizer::Item
 * ===Arguments
 * * size is a Integer
 * ===Return value
 * WX::Sizer::Item
 */
DLL_LOCAL VALUE _add_spacer(VALUE self,VALUE size)
{
	return wrap(_self->AddSpacer(RB_NUM2INT(size)));
}
Exemplo n.º 18
0
/*
 * call-seq:
 *   image.blur_vertical(radius) -> WX::Image
 *
 * blur the image according to the specified pixel radius
 * ===Arguments
 * * radius Integer
 * ===Return value
 * WX::Image
*/
DLL_LOCAL VALUE _BlurVertical_self(VALUE self, VALUE radius)
{
	rb_check_frozen(self);
	_self->Paste(_self->BlurVertical(RB_NUM2INT(radius)), 0, 0);
	return self;
}
Exemplo n.º 19
0
/*
 * call-seq:
 *   image.blur_horizontal(radius) -> WX::Image
 *
 * blur the image according to the specified pixel radius
 * ===Arguments
 * * radius Integer
 * ===Return value
 * WX::Image
*/
DLL_LOCAL VALUE _BlurHorizontal(VALUE self, VALUE radius)
{
	return wrap(_self->BlurHorizontal(RB_NUM2INT(radius)));
}