class GoWindow < TkToplevel

  @@windows=[]

  def GoWindow.raise_all

    @@windows.each { |w| w.deiconify }
  end

  def GoWindow.withdraw_all
    @@windows.each { |w| w.withdraw }
  end

  attr_reader :menubar, :help_menu

  def initialize(call)
    @call = call
    super()
    TkDefaults.set_top_options(@call,self)
    self.protocol('WM_DELETE_WINDOW', proc{ destroy })
    @@windows.push(self)
    self
  end

  def destroy
    TkDefaults.save_top_options(@call,self)
    @@windows.delete(self)
    super
  end

  def withdraw
    TkDefaults.save_top_options(@call,self)
    super
  end

  def make_menubar
    unless @menubar
      @menubar=Menu.new


      if $platform == 'windows'
        @help_menu= Menu.new
        @menubar.add('cascade','menu' => @help_menu, 'label' => 'Help')
      else
        @help_menu= TkSysMenu_Help.new(@menubar)
        @menubar.add('cascade','menu' => @help_menu, 'label' => 'Help')
      end

      self.configure('menu'=> @menubar)
    end

  end

  def help_add(*args)
    make_menubar
    @help_menu.add(*args)
  end

  def cursor(name)
#    super(name) doesn't work (super doesn't use method_missing)
    configure('cursor',name)
    Tk.update
  end


end
