/* * call-seq: * bind(type[, id[, last]]) {|evt| } -> self * * bind the block to the given event type. id and id-range are optional. * ===Arguments * * type Symbol/Integer * * id Symbol/Integer * * last Symbol/Integer * ===Return value * self * === Exceptions * [ArgumentError] * * when the evthander prevent the binding of the given type. */ DLL_LOCAL VALUE _bind(int argc,VALUE *argv,VALUE self) { VALUE type,id,last,proc; rb_scan_args(argc, argv, "12&",&type,&id,&last,&proc); wxEventType ctype = unwrapEventType(type); #if wxUSE_TEXTCTRL if(ctype == wxEVT_TEXT_ENTER && rb_obj_is_kind_of(self, rb_cWXTextCtrl)) { wxTextCtrl* textctrl = unwrap<wxTextCtrl*>(self); if(!textctrl->HasFlag(wxTE_PROCESS_ENTER)) { rb_raise(rb_eArgError, "'%" PRIsVALUE "' for '%" PRIsVALUE "' needs 'process_enter' option.", RB_OBJ_STRING(type), RB_OBJ_STRING(self) ); } } #endif if(NIL_P(proc)) proc = rb_block_proc(); _self->Bind(wxEventTypeTag<wxEvent>(ctype),RubyFunctor(proc),unwrapID(id),unwrapID(last)); return self; }
VALUE _appendNormalItem(int argc,VALUE *argv,VALUE self) { VALUE id,text,help,temp; rb_scan_args(argc, argv, "1*",&id,&temp); if(rb_obj_is_kind_of(id,rb_cString) && rb_block_given_p()){ rb_scan_args(argc, argv, "11",&text,&help); wxMenu *m = new wxMenu; rb_yield(wrap(m)); return wrap(_self->AppendSubMenu(m,wrap<wxString>(text),wrap<wxString>(help))); }else{ rb_scan_args(argc, argv, "12",&id,&text,&help); wxWindowID wid = unwrapID(id); if(!wxIsStockID(wid) && NIL_P(text)) rb_raise(rb_eArgError,"id %d needs an text",wid); wxMenuItem *item = _self->Append(wid,wrap<wxString>(text),wrap<wxString>(help)); if(rb_block_given_p()){ VALUE proc = rb_block_proc(); #ifdef wxHAS_EVENT_BIND _self->Bind(wxEVT_COMMAND_MENU_SELECTED,RubyFunctor(proc),item->GetId()); #else _self->Connect(item->GetId(),wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(RubyFunctor::operator()),NULL,new RubyFunctor(proc)); #endif } return wrap(item); } }
VALUE _appendCheckItem(int argc,VALUE *argv,VALUE self) { VALUE id,text,help; rb_scan_args(argc, argv, "12",&id,&text,&help); wxMenuItem *item = _self->AppendCheckItem(unwrapID(id),wrap<wxString>(text),wrap<wxString>(help)); if(rb_block_given_p()){ VALUE proc = rb_block_proc(); #ifdef wxHAS_EVENT_BIND _self->Bind(wxEVT_COMMAND_MENU_SELECTED,RubyFunctor(proc),item->GetId()); #else _self->Connect(item->GetId(),wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(RubyFunctor::operator()),NULL,new RubyFunctor(proc)); #endif } return wrap(item); }
void connect_v2_ObjectBrush_Point(CL_Signal_v2<ObjectBrush, CL_Point>& sig, VALUE func) { sig = CL_Signal_v2<ObjectBrush, CL_Point>(); new CL_Slot(sig.connect_functor(RubyFunctor(func))); }
void connect_v1_ObjMapObject(CL_Signal_v1<ObjMapObject>& sig, VALUE func) { sig = CL_Signal_v1<ObjMapObject>(); new CL_Slot(sig.connect_functor(RubyFunctor(func))); }
void connect_v1_Color(CL_Signal_v1<CL_Color>& sig, VALUE func) { sig = CL_Signal_v1<CL_Color>(); new CL_Slot(sig.connect_functor(RubyFunctor(func))); }
void connect_v2_graceful(CL_Signal_v2<int, int>& sig, VALUE obj) { new CL_Slot(sig.connect_functor(RubyFunctor(obj))); }
void connect_v2(CL_Signal_v2<int, int>& sig, VALUE obj) { sig = CL_Signal_v2<int, int>(); new CL_Slot(sig.connect_functor(RubyFunctor(obj))); }
void connect_v1_float(CL_Signal_v1<float>& sig, VALUE obj) { sig = CL_Signal_v1<float>(); new CL_Slot(sig.connect_functor(RubyFunctor(obj))); }
void connect(CL_Signal_v0& sig, VALUE obj) { sig = CL_Signal_v0(); new CL_Slot(sig.connect_functor(RubyFunctor(obj))); }