
class ToolBox 

  def initialize(goban)
    @goban=goban
    @canvas= goban.canvas
    @tools=[]
    @widgets=[]
  end

  def add_tool(tool)
    @tools.push(tool)
    @goban.bind_move(tool)
  end

  def add_text(var)
    @tools.push(var)
  end

  def coords(posx, posy, step)
    @posx= posx
    @posy= posy
    @step= step.round
    place_items
  end

  def place_items
    x= @posx*@step
    y= @posy*@step


    @tools.each{ |item|
      item.do_redraw(x, y, @step)
      b=item.bbox
      y+= b[3]-b[1] +5 
    }

  end

  def include?(item)
    @tools.include?(item)
  end

  def replace(oldItem,newItem)
    index = @tools.index(oldItem)
    if index
      @tools[index]=newItem
      @goban.bind_move(newItem)
      place_items
    end
  end
end

