Sha256: 12c119423ee83278fb1f0aa829acd473802a8ad30f24b13b9fd0be976d121619

Contents?: true

Size: 1020 Bytes

Versions: 16

Compression:

Stored size: 1020 Bytes

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

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

16 entries across 16 versions & 1 rubygems

Version Path
wxruby3-1.3.1 lib/wx/core/region_iterator.rb
wxruby3-1.3.0 lib/wx/core/region_iterator.rb
wxruby3-1.2.1 lib/wx/core/region_iterator.rb
wxruby3-1.2.0 lib/wx/core/region_iterator.rb
wxruby3-1.1.2 lib/wx/core/region_iterator.rb
wxruby3-1.1.1 lib/wx/core/region_iterator.rb
wxruby3-1.1.0 lib/wx/core/region_iterator.rb
wxruby3-1.0.1 lib/wx/core/region_iterator.rb
wxruby3-0.9.8 lib/wx/core/region_iterator.rb
wxruby3-0.9.7 lib/wx/core/region_iterator.rb
wxruby3-0.9.5 lib/wx/core/region_iterator.rb
wxruby3-0.9.4 lib/wx/core/region_iterator.rb
wxruby3-0.9.3 lib/wx/core/region_iterator.rb
wxruby3-0.9.2 lib/wx/core/region_iterator.rb
wxruby3-0.9.1 lib/wx/core/region_iterator.rb
wxruby3-0.9.0 lib/wx/core/region_iterator.rb