1 /* Hexxagon board game.
2  * Copyright (C) 2001 Erik Jonsson.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  *
18  * Email hexxagon@nesqi.se
19  *
20  */
21 
22 
23 #ifndef INC_GTKBOARDLIST_H
24 #define INC_GTKBOARDLIST_H
25 
26 #include <gtkmm.h>
27 #include <libhexx/libhexx.h>
28 
29 #include <map>
30 
31 class GtkBoardList : public Gtk::TreeView
32 {
33     public:
34         GtkBoardList();
35 
36         void init_default_list();
37         bool read_list_from_file();
38         bool write_list_to_file();
39 
40         Glib::ustring getSelected();
41         bool addBoard(const Glib::ustring &name, const libhexx::Layout &l);
42         bool removeBoard(const Glib::ustring &name);
43         void selectFirst();
44 
45         void on_selection_changed();
46 
47         sigc::signal<void, const Glib::ustring&, const libhexx::Layout&> callback;
48 
49     private:
50         class ModelColumns : public Gtk::TreeModel::ColumnRecord
51         {
52             public:
53 
ModelColumns()54                 ModelColumns()
55                 {
56                     add(col_name);
57                 };
58 
59                 Gtk::TreeModelColumn<Glib::ustring> col_name;
60         };
61 
62         Glib::RefPtr<Gtk::ListStore> lstore;
63         ModelColumns colRec;
64 
65         Glib::RefPtr<Gtk::TreeSelection> selection;
66 
67         std::map<Glib::ustring, libhexx::Layout> data;
68 };
69 
70 #endif //_GTKBOARDLIST_H
71 
72