Beispiel #1
0
VALUE _set_choice(wxPGProperty* self,int idx,VALUE hash)
{
    wxPGChoices& choices = const_cast<wxPGChoices&>(self->GetChoices());

    if(!choices.IsOk())
        return Qnil;

    wxPGChoiceEntry& item = choices[idx];

    if(rb_obj_is_kind_of(hash,rb_cHash))
    {
        wxBitmap bitmap;
        wxColour fg,bg;
        wxFont font(wxNullFont);

        if(set_hash_option(hash,"bitmap",bitmap))
            item.SetBitmap(bitmap);

        if(set_hash_option(hash,"bg_col",bg))
            item.SetBgCol(bg);
        if(set_hash_option(hash,"fg_col",fg))
            item.SetFgCol(fg);
        if(set_hash_option(hash,"font",font))
            item.SetFont(font);
    }
    return wrap(&dynamic_cast<wxPGCell&>(item));
}
Beispiel #2
0
/*
 * call-seq:
 *   ComboCtrl.new(parent, name, [options])
 *   ComboCtrl.new(parent, [options])
 *
 * creates a new ComboCtrl widget.
 * ===Arguments
 * * parent of this window or nil
 * * name is a String describing a resource in a loaded xrc
 *
 * *options: Hash with possible options to set:
 *   * items [String]
 *   * select Integer
 *   * value String
*/
DLL_LOCAL VALUE _initialize(int argc,VALUE *argv,VALUE self)
{
	VALUE parent,name,hash;
	rb_scan_args(argc, argv, "11:",&parent,&name,&hash);

	if(!_created  && !rb_obj_is_kind_of(name,rb_cString)) {
		wxWindowID id(wxID_ANY);
		wxString value;
		int style(0);

		if(rb_obj_is_kind_of(hash,rb_cHash)) {
			set_hash_option(hash,"id",id,unwrapID);
			set_hash_option(hash,"value",value);
			set_hash_option(hash,"style",style);

			TextCtrl::set_style_flags(hash,style);
		}
		_self->Create(
			unwrap<wxWindow*>(parent),id,value,
			wxDefaultPosition,wxDefaultSize,style
		);
		
	}

	rb_call_super(argc,argv);

	if(rb_obj_is_kind_of(name,rb_cString) && rb_obj_is_kind_of(hash,rb_cHash)) {
		set_obj_option(hash, "value", &wxComboCtrl::SetValue,_self);
	}

	return self;
}
Beispiel #3
0
/*
 * call-seq:
 *   dir_dialog([parent], [options]) -> String
 *
 * shows an DirDialog.
 * ===Arguments
 * * parent of this window or nil
 *
 * *options: Hash with possible options to set:
 *   * path String default path
 *   * message String
 *   * style Integer
 *   * pos WX::Point

 *   * must_exist Style Flag does set MUST_EXIST
 *   * change_dir Style Flag does set CHANGE_DIR
 * ===Return value
 * selected path
*/
DLL_LOCAL VALUE _getUserDir(int argc,VALUE *argv,VALUE self)
{
	VALUE parent,hash;
	rb_scan_args(argc, argv, "01:",&parent,&hash);

	app_protected();

	wxString message(wxDirSelectorPromptStr);
	wxString defaultPath(wxEmptyString);
	int style(wxDD_DEFAULT_STYLE);
	wxPoint pos(wxDefaultPosition);

	if(rb_obj_is_kind_of(hash,rb_cHash))
	{
		set_default_values(hash,message,defaultPath,style);

		set_hash_option(hash,"pos",pos);

		set_style_flags(hash,style);

	}

	return wrap(wxDirSelector(message,
			defaultPath,style,pos,
			unwrap<wxWindow*>(parent)));
}
Beispiel #4
0
DLL_LOCAL bool set_obj_option(VALUE hash,const char* name,V (C::*set)(const wxString&, const wxString&), C& obj)
{
	wxArrayString val;
	bool result = set_hash_option(hash,name,val);
	if(result) {
		(obj.*set)(val[0], val.size() > 1 ? val[1] : wxString() );
	}
	return result;

}
Beispiel #5
0
DLL_LOCAL bool set_obj_option(VALUE hash,const char* name,V (C::*set)(), C2* obj)
{
	bool val(false);
	bool result = set_hash_option(hash,name,val,unwrap<bool>);
	if(val) {
		(obj->*set)();
	}
	return result;

}
Beispiel #6
0
DLL_LOCAL bool set_obj_option(VALUE hash,const char* name,V (C::*set)(T), C2* obj,T func(const VALUE&) = unwrap<T>)
{
	T val;
	bool result = set_hash_option(hash,name,val,func);
	if(result) {
		(obj->*set)(val);
	}
	return result;

}
Beispiel #7
0
DLL_LOCAL bool set_hash_option(VALUE hash,const char* name,T& val,T2 func(const VALUE&) )
{
	VALUE temp;
	if(set_hash_option(hash,name,temp))
	{
		val = func(temp);
		return true;
	}
	return false;
}
Beispiel #8
0
bool set_ruby_option(VALUE hash,const char* name,VALUE func(VALUE, VALUE), VALUE self)
{
	VALUE temp;
	if(set_hash_option(hash, name, temp))
	{
		func(self, temp);
		return true;
	}
	return false;
}
Beispiel #9
0
bool set_hash_flag_option(VALUE hash,const char* name,const int& flag,int& val)
{
	VALUE temp;
	if(set_hash_option(hash, name, temp))
	{
		if(RTEST(temp))
			val |= flag;
		else
			val &= ~flag;

		return true;
	}
	return false;
}
Beispiel #10
0
/*
 * call-seq:
 *   to_bitmap -> WX::Bitmap
 *
 * convert to WX::Bitmap
 *
 * ===Arguments
 * * opts: Hash with possible options to set:
 *   * depth Integer
 *   * scale Float
 * === Exceptions
 * [ArgumentError]
 * * if scale is negative or zero
 */
DLL_LOCAL VALUE _to_bitmap(int argc,VALUE *argv,VALUE self)
{
	VALUE opts;
	rb_scan_args(argc, argv, "0:",&opts);

	int cdepth(wxBITMAP_SCREEN_DEPTH);
	double cscale(1.0);

	if(rb_obj_is_kind_of(opts, rb_cHash)) {
		set_hash_option(opts, "depth", cdepth);
		if(set_hash_option(opts, "scale", cscale)) {
			if(cscale <= 0.0) {
				rb_raise(rb_eArgError, "scale cant be negative or zero");
				return Qnil;
			}
		}
	}
	return wrap(new wxBitmap(
		*_self, cdepth
#if HAVE_WXBITMAP_WXIMAGE
		, cscale
#endif
		));
}
Beispiel #11
0
DLL_LOCAL bool set_hash_option(VALUE hash,const char* name,T& val)
{
	return set_hash_option(hash, name, val, unwrap<T>);
}