### # wxRuby3 wxWidgets interface director # Copyright (c) M.J.N. Corino, The Netherlands ### module WXRuby3 class Director class RibbonArtProvider < Director def setup spec.items << 'wxRibbonPageTabInfo' << 'wxRibbonMSWArtProvider' << 'wxRibbonAUIArtProvider' super spec.gc_as_object 'wxRibbonArtProvider' spec.gc_as_untracked 'wxRibbonPageTabInfo' spec.suppress_warning(473, 'wxRibbonArtProvider::Clone', 'wxRibbonMSWArtProvider::Clone', 'wxRibbonAUIArtProvider::Clone') # argout type mappings spec.map_apply 'int *OUTPUT' => ['int *ideal', 'int *small_begin_need_separator', 'int *small_must_have_separator', 'int *minimum'] # wxDirection argout type mapping spec.map 'wxDirection *' => 'Wx::Direction' do map_in ignore: true, temp: 'wxDirection tmp', code: '$1 = &tmp;' map_argout code: <<~__CODE $result = SWIG_Ruby_AppendOutput($result, wxRuby_GetEnumValueObject("wxDirection", static_cast(tmp$argnum))); __CODE map_directorargout code: <<~__CODE if ($1 && !NIL_P($result)) { int eval; wxRuby_GetEnumValue("wxDirection", $result, eval); (*$1) = static_cast (eval); } __CODE end # add method for correctly wrapping RibbonArtProvider references spec.add_header_code <<~__CODE extern VALUE mWxRBN; // declare external module reference extern VALUE wxRuby_WrapWxRibbonArtProviderInRuby(const wxRibbonArtProvider *wx_rap, int own) { // If no object was passed to be wrapped. if ( ! wx_rap ) return Qnil; // check for registered instance VALUE rb_rap = wxRuby_FindTracking(const_cast (wx_rap)); if (rb_rap && !NIL_P(rb_rap)) { return rb_rap; } const void *ptr = 0; wxString class_name; if ((ptr = dynamic_cast (wx_rap))) { class_name = "RibbonAUIArtProvider"; } else if ((ptr = dynamic_cast (wx_rap))) { class_name = "RibbonMSWArtProvider"; } else { class_name = "RibbonArtProvider"; } VALUE r_class = Qnil; if ( ptr && class_name.Len() > 0 ) { wxCharBuffer wx_classname = class_name.mb_str(); VALUE r_class_name = rb_intern(wx_classname.data ()); // wxRuby class name if (rb_const_defined(mWxRBN, r_class_name)) r_class = rb_const_get(mWxRBN, r_class_name); } // If we cannot find the class output a warning and return nil if ( r_class == Qnil ) { rb_warn("Error wrapping object; class `%s' is not (yet) supported in wxRuby", (const char *)class_name.mb_str() ); return Qnil; } // Otherwise, retrieve the swig type info for this class and wrap it // in Ruby. swig_type_info* swig_type = wxRuby_GetSwigTypeForClass(r_class); rb_rap = SWIG_NewPointerObj(const_cast (ptr), swig_type, own); return rb_rap; } __CODE # type mapping for Clone return ref spec.map 'wxRibbonArtProvider*' => 'Wx::RBN::RibbonArtProvider' do # add_header_code 'extern VALUE wxRuby_WrapWxRibbonArtProviderInRuby(const wxRibbonArtProvider *wx_rap, int own);' # wrap AND own in this case map_out code: '$result = wxRuby_WrapWxRibbonArtProviderInRuby($1, 1);' end # type mapping for wxRibbonPageTabInfoArray; no need to expose it to Ruby spec.map 'const wxRibbonPageTabInfoArray &' => 'Array' do map_in temp: 'wxRibbonPageTabInfoArray tmp', code: <<~__CODE if (!NIL_P($input)) { if (TYPE($input) == T_ARRAY) { for (int i=0; i(ptr)); } } else { VALUE msg = rb_inspect($input); rb_raise(rb_eArgError, "$symname : expected array for 3 but got %s", StringValuePtr(msg)); } } $1 = &tmp; __CODE map_directorin code: <<~__CODE $input = rb_ary_new(); for (size_t i = 0; i < $1.GetCount(); i++) { wxRibbonPageTabInfo* wx_rbti = &$1.Item(i); rb_ary_push($input, SWIG_NewPointerObj(SWIG_as_voidptr(wx_rbti), SWIGTYPE_p_wxRibbonPageTabInfo, 0)); } __CODE end end end # class RibbonArtProvider end # class Director end # module WXRuby3