fix up wscript/build issues in exportvis after merge with master
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / selector.h
1 /*
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.
7
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.
12
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.
16
17 */
18
19 #ifndef __gtkselector_h__
20 #define __gtkselector_h__
21
22 #include <string>
23 #include <vector>
24
25 #include <gtkmm.h>
26
27 #include "gtkmm2ext/visibility.h"
28
29 namespace Gtkmm2ext {
30
31 class LIBGTKMM2EXT_API TreeView_Selector : public Gtk::TreeView
32 {
33 public:
34         TreeView_Selector() {}
35         virtual ~TreeView_Selector() {}
36
37 protected:
38         virtual bool on_button_press_event(GdkEventButton *ev);
39 };
40
41 typedef void (SelectorRefillFunction)(Glib::RefPtr<Gtk::ListStore>, void *);
42
43 class LIBGTKMM2EXT_API Selector : public Gtk::VBox
44 {
45         friend class Gtkmm2ext::TreeView_Selector;
46
47 public:
48         Selector (SelectorRefillFunction, void *arg, 
49                   std::vector<std::string> titles);
50
51         virtual ~Selector ();
52         Glib::RefPtr<Gtk::ListStore> liststore () { return lstore; }
53         void reset (void (*refiller)(Glib::RefPtr<Gtk::ListStore>, void *), void *arg);
54         void set_size (unsigned int w, unsigned int h) {
55                 scroll.set_size_request (w, h);
56                 tview.columns_autosize ();
57         }
58
59         struct Result {
60             Gtk::TreeView& view;
61             Glib::RefPtr<Gtk::TreeSelection> selection;
62
63             Result (Gtk::TreeView& v, Glib::RefPtr<Gtk::TreeSelection> sel)
64                     : view (v), selection (sel) {}
65         };
66
67         /* selection is activated via a double click, choice via
68            a single click.
69         */
70         sigc::signal<void,Result*> selection_made;
71         sigc::signal<void,Result*> choice_made;
72         sigc::signal<void,Result*> shift_made;
73         sigc::signal<void,Result*> control_made;
74
75         sigc::signal<void> update_contents;
76
77         void accept();
78         void cancel();
79         void rescan();
80
81
82   protected:
83         virtual void on_map ();
84         virtual void on_show ();
85
86   private:
87         Gtk::ScrolledWindow scroll;
88         Gtk::TreeModel::ColumnRecord column_records;
89         Glib::RefPtr<Gtk::ListStore> lstore;
90         Gtkmm2ext::TreeView_Selector tview;
91         void (*refiller)(Glib::RefPtr<Gtk::ListStore>, void *);
92         void *refill_arg;
93         gint selected_row;
94         gint selected_column;
95         gint chosen_row;
96         gint chosen_column;
97
98         void refill ();
99         void chosen ();
100         void shift_clicked ();
101         void control_clicked ();
102
103         static gint _accept (gpointer);
104         static gint _chosen (gpointer);
105         static gint _shift_clicked (gpointer);
106         static gint _control_clicked (gpointer);
107
108 };
109
110 } /* namespace */
111
112 #endif // __gtkselector_h__