Sha256: 1d9bd758ca3f5a1094e8e9da20e0422026353b4f32d47d1a050d2f955c87fc40

Contents?: true

Size: 802 Bytes

Versions: 5

Compression:

Stored size: 802 Bytes

Contents

class Wx::RegionIterator

  alias :have_rects? :have_rects

  # Ruby like enumeration
  def each
    if block_given?
      while have_rects
        yield get_rect
        next_rect
      end
    else
      # The region iterator instance cannot be allowed to exist beyond the outer
      # Wx::RegionIterator.for_region block as it is a temporary instance that
      # will stop to exist when the outer block finishes, so we collect the rectangles
      # here and return an enumerator on that
      arr = []
      while has_rects
        arr << get_rect
        next_rect
      end
      arr.each
    end
  end

  def self.iterate(region, &block)
    return unless block
    for_region(region) do |ri|
      while ri.have_rects
        block.call(ri)
        ri.next_rect
      end
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wxruby3-0.9.0.pre.rc.3 lib/wx/core/region_iterator.rb
wxruby3-0.9.0.pre.rc.2 lib/wx/core/region_iterator.rb
wxruby3-0.9.0.pre.rc.1 lib/wx/core/region_iterator.rb
wxruby3-0.9.0.pre.beta.14 lib/wx/core/region_iterator.rb
wxruby3-0.9.0.pre.beta.13 lib/wx/core/region_iterator.rb