Sha256: 8a45c0e0a8ab7b9f45c1ffc1205fa1bc11c2baebb3da7674ae815e9da56efbbb
Contents?: true
Size: 1.85 KB
Versions: 3
Compression:
Stored size: 1.85 KB
Contents
# Copyright (c) 2023 M.J.N. Corino, The Netherlands # # This software is released under the MIT license. # # Some parts are # Copyright 2004-2007, wxRuby development team # released under the MIT-like wxRuby2 license module Wx # Provide some default implementations of these to make life easier class DataObject def get_preferred_format(direction) get_all_formats(direction).first end def get_format_count(direction) get_all_formats(direction).size end end class DataObjectSimple # implement the overloads which do not require the format arg # using pure Ruby wx_get_data_size = instance_method :get_data_size wx_redefine_method :get_data_size do |format = nil| wx_get_data_size.bind(self).call(format || self.get_format) end wx_get_data_here = instance_method :get_data_here wx_redefine_method :get_data_here do |format = nil| wx_get_data_here.bind(self).call(format || self.get_format) end wx_set_data = instance_method :set_data wx_redefine_method :set_data do |*args| if args.size>1 format, buf = args else format = nil buf = args.first end wx_set_data.bind(self).call(format || self.get_format, buf) end end class DataObjectSimpleBase # implement these in pure Ruby for optimization def get_data_size(*) self._get_data_size end def get_data_here(*) self._get_data end def set_data(*args) if args.size>1 _, buf = args else buf = args.first end self._set_data(buf) end wx_redefine_method :_get_data_size do (_get_data || '').bytesize end protected :_get_data_size end class TextDataObject # override this to loose the extra terminating 0 we otherwise get def get_data_here(*) self.get_text end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
wxruby3-1.4.2 | lib/wx/core/data_object.rb |
wxruby3-1.4.1 | lib/wx/core/data_object.rb |
wxruby3-1.4.0 | lib/wx/core/data_object.rb |