2 Copyright (C) 1999 Paul Barton-Davis
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __gtkselector_h__
21 #define __gtkselector_h__
30 class TreeView_Selector : public Gtk::TreeView
33 TreeView_Selector() {}
34 virtual ~TreeView_Selector() {}
37 virtual bool on_button_press_event(GdkEventButton *ev);
40 typedef void (SelectorRefillFunction)(Glib::RefPtr<Gtk::ListStore>, void *);
42 class Selector : public Gtk::VBox
44 friend class Gtkmm2ext::TreeView_Selector;
47 Selector (SelectorRefillFunction, void *arg,
48 std::vector<std::string> titles);
51 Glib::RefPtr<Gtk::ListStore> liststore () { return lstore; }
52 void reset (void (*refiller)(Glib::RefPtr<Gtk::ListStore>, void *), void *arg);
53 void set_size (unsigned int w, unsigned int h) {
54 scroll.set_size_request (w, h);
55 tview.columns_autosize ();
58 /* selection is activated via a double click, choice via
61 sigc::signal<void,Gtk::TreeView&, Glib::RefPtr<Gtk::TreeSelection> > selection_made;
62 sigc::signal<void,Gtk::TreeView&, Glib::RefPtr<Gtk::TreeSelection> > choice_made;
63 sigc::signal<void,Gtk::TreeView&, Glib::RefPtr<Gtk::TreeSelection> > shift_made;
64 sigc::signal<void,Gtk::TreeView&, Glib::RefPtr<Gtk::TreeSelection> > control_made;
66 sigc::signal<void> update_contents;
74 virtual void on_map ();
75 virtual void on_show ();
78 Gtk::ScrolledWindow scroll;
79 Gtk::TreeModel::ColumnRecord column_records;
80 Glib::RefPtr<Gtk::ListStore> lstore;
81 Gtkmm2ext::TreeView_Selector tview;
82 void (*refiller)(Glib::RefPtr<Gtk::ListStore>, void *);
91 void shift_clicked ();
92 void control_clicked ();
94 static gint _accept (gpointer);
95 static gint _chosen (gpointer);
96 static gint _shift_clicked (gpointer);
97 static gint _control_clicked (gpointer);
103 #endif // __gtkselector_h__