


class GamesList  < IGSList

  include GamesMenu

  Sizes = [30,40,80,35,80,35,40,35,40,40,30,30]
#  Titles= ['','Status','White','Rank','Black','Rank','Move','Size','Handi','Komi','Byo','Obs']

  def initialize(parent)

    super(parent,5,5)

    set_title  GameEntry.new(@titlebar,0,0,nil,Sizes,TkDefaults::Titlebar['Games'])

    @gameinfos = []
    @games =  []
    menu_init
  end

  def del_game(number,line)
    return if @updating or @games[number].nil?
    @games[number].set_disabled(line)
  end

  def add( gameinf)
    @gameinfos.push gameinf
  end

  def  push(gameinf)
    return if gameinf.nil?
    game = GameEntry.new(@canvas,0,@posy,gameinf,Sizes){ |x,y| popup(x,y,gameinf) }
    @games[gameinf.number]= game
    add_entry(game)

  end

  def insert(gameinf)
    return if @updating
    @gameinfos.push gameinf
    push gameinf
  end


  def begin_update
    clear
    @gameinfos = []
    @games =  []

  end

  def end_update

    @updating=true
    @gameinfos.sort.each {|gi|  push gi}
    refresh
    @updating=false


  end

end


