Sha256: 51627eb67b9ae14acdc02ed498f44c02cc387cb36ca3419dd4521620291e2af2

Contents?: true

Size: 1.59 KB

Versions: 5

Compression:

Stored size: 1.59 KB

Contents

# Copyright (c) 2023 M.J.N. Corino, The Netherlands
#
# This software is released under the MIT license.

# Wx::PG::PGProperty

module Wx::PG

  NullProperty = nil
  PGChoicesEmptyData = nil

  PG_LABEL_STRING = '@!' unless self.const_defined?(:PG_LABEL_STRING) # disappeared >= wxWidgets 3.3.0
  PG_LABEL = Wx::PG::PG_LABEL_STRING

  PG_DEFAULT_IMAGE_SIZE = Wx::DEFAULT_SIZE

  class PGProperty

    wx_each_attribute = instance_method :each_attribute
    define_method :each_attribute do
      if block_given?
        wx_each_attribute.bind(self).call
      else
        ::Enumerator.new { |y| wx_each_attribute.bind(self).call { |variant| y << variant } }
      end
    end

    def get_attributes
      each_attribute.inject({}) { |map, v| map[v.name] = v; map }
    end
    alias :attributes :get_attributes

    def set_attributes(map)
      raise ArgumentError, 'Expected Hash' unless map.is_a?(::Hash)
      map.each_pair { |nm, v| set_attribute(nm, v) }
    end
    alias :attributes= :set_attributes
  end

  class PGChoices

    wx_each_label = instance_method :each_label
    define_method :each_label do
      if block_given?
        wx_each_label.bind(self).call
      else
        ::Enumerator.new { |y| wx_each_label.bind(self).call { |lbl| y << lbl } }
      end
    end

    wx_each_entry = instance_method :each_entry
    define_method :each_entry do
      if block_given?
        wx_each_entry.bind(self).call
      else
        ::Enumerator.new { |y| wx_each_entry.bind(self).call { |entry| y << entry } }
      end
    end
    
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wxruby3-0.9.7-x64-mingw-ucrt lib/wx/pg/pg_property.rb
wxruby3-0.9.5-x64-mingw-ucrt lib/wx/pg/pg_property.rb
wxruby3-0.9.4-x64-mingw-ucrt lib/wx/pg/pg_property.rb
wxruby3-0.9.3-x64-mingw-ucrt lib/wx/pg/pg_property.rb
wxruby3-0.9.2-x64-mingw-ucrt lib/wx/pg/pg_property.rb