require 'fox'

module Fox
  class FX_ComboBox
    include Enumerable
    def each
      0.upto(numItems - 1) { |i|
        yield getItemText(i), getItemData(i)
      }
      self
    end
  end

  class FX_GLGroup
    include Enumerable
    def each
      0.upto(no - 1) { |i|
        yield child(i)
      }
      self
    end
  end

  class FX_Header
    include Enumerable
    def each
      0.upto(numItems - 1) { |i|
        yield retrieveItem(i)
      }
      self
    end
  end

  class FX_IconList
    include Enumerable
    def each
      0.upto(numItems - 1) { |i|
        yield retrieveItem(i)
      }
      self
    end
  end

  class FX_List
    include Enumerable
    def each
      0.upto(numItems - 1) { |i|
        yield retrieveItem(i)
      }
      self
    end
  end

  class FX_ListBox
    include Enumerable
    def each
      0.upto(numItems - 1) { |i|
        yield getItemText(i), getItemIcon(i), getItemData(i)
      }
      self
    end
  end

  class FX_Table
    include Enumerable
    def each_row
      0.upto(getNumRows - 1) { |i|
        tableRow = []
        0.upto(getNumCols - 1) { |j|
          tableRow.push(getItem(i, j))
        }
        yield tableRow
      }
      self
    end
    def each_column
      0.upto(getNumCols - 1) { |j|
        tableCol = []
        0.upto(getNumRows - 1) { |i|
          tableCol.push(getItem(i, j))
        }
        yield tableCol
      }
      self
    end
    alias each each_row
  end

  class FX_TreeItem
    include Enumerable
    def each
      current = first
      while current != nil
        yield current
        current = current.next
      end
      self
    end
  end

  class FX_TreeList
    include Enumerable
    def each
      current = firstItem
      while current != nil
        yield current
        current = current.next
      end
      self
    end
  end

  class FX_TreeListBox
    include Enumerable
    def each
      current = firstItem
      while current != nil
        yield current
        current = current.next
      end
      self
    end
  end
end
