/* This file is part of cardwords
   (c) 1999 Tobias Peters
   see file COPYING for the copyright terms.
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

// cardwords_gtk_cardlist.hh

#ifndef CARDWORDS_GTK_CARDLIST_HH
#define CARDWORDS_GTK_CARDLIST_HH

#include <gtk--/window.h>
#include "cardwords_cardoccurrencemap.hh"
namespace Gtk {class CList;}

// CardWords_Gtk_CardList is a window displaying the number of occurrences
// of cards.


class CardWords_Gtk_CardList : public Gtk::Window
{
public:
  // This constructor reads the data from a CardWords_CardOccurrenceMap.
  // Two CardWords_CardOccurrenceMap:s are constructed by the
  // CardWords_CommClient: one static map that remains unchanged during the
  // whole game that contains all cards in the game,
  // and another map that contains only cards that could still be contained
  // in the pile at that time.
  // The bool arg tells the constructor which type it should display, because
  // they are displayed differently.
  CardWords_Gtk_CardList(const CardWords_CardOccurrenceMap *,
                         bool static_map = false);
  
  ~CardWords_Gtk_CardList();

  void
  remaining_card_diminished(const CardWords_CardDescription &);
  void
  remaining_card_increased(const CardWords_CardDescription &);

protected:
  // override delete: hide instead of destroy.
  virtual
  gint
  delete_event_impl(GdkEventAny*);

  // overide show: It raises the window if it already there but hidden.
  virtual
  void
  show_impl(void);
  
private:
  Gtk::CList * list;

  struct map_value_type {
    size_t number_of_occurrences;
    size_t position_in_clist;
    map_value_type(size_t n = 0U, size_t p = 0U)
      : number_of_occurrences(n),position_in_clist(p)
      {};
  };

  typedef std::map<CardWords_CardDescription, map_value_type> clist_map_type;

  clist_map_type card_map;
  
#ifdef DEBUG
  bool static_map;
#endif
};

#endif
