/* * call-seq: * DirDialog.new(parent, name, [options]) * DirDialog.new(parent, [options]) * * creates a new DirDialog 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: * * path String default path * * message String * * * must_exist Style Flag does set MUST_EXIST * * change_dir Style Flag does set CHANGE_DIR * */ 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)) { wxString message(wxDirSelectorPromptStr); wxString path(wxEmptyString); int style(wxDD_DEFAULT_STYLE); if(rb_obj_is_kind_of(hash,rb_cHash)) { set_default_values(hash,message,path,style); TopLevel::set_style_flags(hash,style); set_style_flags(hash,style); } _self->Create(unwrap<wxWindow*>(parent),message,path,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, "message", &wxDirDialog::SetMessage, _self); set_obj_option(hash, "path", &wxDirDialog::SetPath, _self); } return self; }
/* * 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; }
DLL_LOCAL VALUE _busyinfo(int argc,VALUE *argv,VALUE self) { VALUE message, parent, hash; rb_scan_args(argc, argv, "11:",&message, &parent, &hash); app_protected(); #ifdef HAVE_WXBUSYINFOFLAGS wxBusyInfoFlags flags; flags.Label(unwrap<wxString>(message)); flags.Parent(unwrap<wxWindow*>(parent)); if(rb_obj_is_kind_of(hash,rb_cHash)) { set_obj_option(hash,"icon",&wxBusyInfoFlags::Icon, flags); set_obj_option(hash,"title",&wxBusyInfoFlags::Title, flags); set_obj_option(hash,"text",&wxBusyInfoFlags::Text, flags); set_obj_option(hash,"label",&wxBusyInfoFlags::Label, flags); set_obj_option(hash,"parent",&wxBusyInfoFlags::Parent, flags); set_obj_option(hash,"foreground",&wxBusyInfoFlags::Foreground, flags); set_obj_option(hash,"background",&wxBusyInfoFlags::Background, flags); //set_obj_option(hash,"transparency",&wxBusyInfoFlags::Transparency, flags, unwrap<unsigned int>); } wxBusyInfo info(flags); #else wxBusyInfo info(unwrap<wxString>(message),unwrap<wxWindow*>(parent)); #endif rb_yield(Qnil); return self; }
wxSizerFlags unwrap< wxSizerFlags >(const VALUE &hash) { wxSizerFlags result; if(!rb_obj_is_kind_of(hash,rb_cHash)) return result; VALUE val; set_obj_option(hash, "expand", &wxSizerFlags::Expand, result); set_obj_option(hash, "shaped", &wxSizerFlags::Shaped, result); set_obj_option(hash, "border", &wxSizerFlags::Border, result); set_obj_option(hash, "proportion", &wxSizerFlags::Proportion, result); if(!NIL_P(val=rb_hash_aref(hash,RB_ID2SYM(rb_intern("align"))))) { if(RB_SYMBOL_P(val)) { if(RB_SYM2ID(val) == rb_intern("left")) result.Left(); if(RB_SYM2ID(val) == rb_intern("right")) result.Right(); if(RB_SYM2ID(val) == rb_intern("bottom")) result.Bottom(); if(RB_SYM2ID(val) == rb_intern("top")) result.Top(); if(RB_SYM2ID(val) == rb_intern("center")) result.Center(); #ifdef HAVE_CONST_WXALIGN_CENTER_VERTICAL #ifdef HAVE_WXSIZERFLAGS_CENTERVERTICAL if(RB_SYM2ID(val) == rb_intern("center_vertical")) result.CenterVertical(); if(RB_SYM2ID(val) == rb_intern("center_horizontal")) result.CenterHorizontal(); #else if(RB_SYM2ID(val) == rb_intern("center_vertical")) result.Align(wxALIGN_CENTER_VERTICAL); if(RB_SYM2ID(val) == rb_intern("center_horizontal")) result.Align(wxALIGN_CENTER_HORIZONTAL); #endif #endif } } return result; }
DLL_LOCAL bool set_obj_option(VALUE hash,const char* name,V (C::*set)(const T&), C& obj,T func(const VALUE&) = unwrap<T> ) { return set_obj_option(hash, name, set, &obj, func); }
DLL_LOCAL bool set_obj_option(VALUE hash,const char* name,V (C::*set)(), C& obj) { return set_obj_option(hash, name, set, &obj); }
wxAuiPaneInfo unwrap< wxAuiPaneInfo >(const VALUE &vinfo) { if(NIL_P(vinfo)) return wxAuiPaneInfo(); else if(SYMBOL_P(vinfo)) { ID id(SYM2ID(vinfo)); if(id == rb_intern("default")) return wxAuiPaneInfo().DefaultPane(); else if(id == rb_intern("toolbar")) return wxAuiPaneInfo().ToolbarPane(); else if(id == rb_intern("center") || id == rb_intern("centre")) return wxAuiPaneInfo().CenterPane(); else return wxAuiPaneInfo(); } else if(rb_obj_is_kind_of(vinfo,rb_cHash)) { wxAuiPaneInfo info; set_obj_option(vinfo, "default", &wxAuiPaneInfo::DefaultPane, info); set_obj_option(vinfo, "toolbar", &wxAuiPaneInfo::ToolbarPane, info); set_obj_option(vinfo, "caption", &wxAuiPaneInfo::Caption, info); set_obj_option(vinfo, "name", &wxAuiPaneInfo::Caption, info); set_obj_option(vinfo, "icon", &wxAuiPaneInfo::Caption, info); //set_obj_option(vinfo, "direction", &wxAuiPaneInfo::Direction, info, unwrapenum< wxAuiManagerDock >); set_obj_option(vinfo, "layer", &wxAuiPaneInfo::Layer, info); set_obj_option(vinfo, "row", &wxAuiPaneInfo::Row, info); set_obj_option(vinfo, "gripper", &wxAuiPaneInfo::Gripper, info); set_obj_option(vinfo, "gripper_top", &wxAuiPaneInfo::GripperTop, info); set_obj_option(vinfo, "close_button", &wxAuiPaneInfo::CloseButton, info); set_obj_option(vinfo, "maximize_button", &wxAuiPaneInfo::MaximizeButton, info); set_obj_option(vinfo, "minimize_button", &wxAuiPaneInfo::MinimizeButton, info); set_obj_option(vinfo, "pin_button", &wxAuiPaneInfo::PinButton, info); return info; }else return *unwrapTypedPtr<wxAuiPaneInfo>(vinfo, rb_cWXAuiPane); }