Minor updates for PathList and OptionEditor.
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / barcontroller.h
1 /*
2     Copyright (C) 2004 Paul 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     $Id$
18 */
19
20 #ifndef __gtkmm2ext_bar_controller_h__
21 #define __gtkmm2ext_bar_controller_h__
22
23 #include <gtkmm.h>
24 #include <gtkmm2ext/binding_proxy.h>
25
26 namespace ARDOUR {
27         class Controllable;
28 }
29
30 namespace Gtkmm2ext {
31
32 class BarController : public Gtk::Frame
33 {
34   public:
35         BarController (Gtk::Adjustment& adj, PBD::Controllable&, sigc::slot<void,char*,unsigned int>);
36         virtual ~BarController () {}
37         
38         void set_sensitive (bool yn) {
39                 darea.set_sensitive (yn);
40         }
41         
42         enum Style {
43                 LeftToRight,
44                 RightToLeft,
45                 Line,
46                 CenterOut,
47                 TopToBottom,
48                 BottomToTop
49         };
50
51         Style style() const { return _style; }
52         void set_style (Style);
53         void set_with_text (bool yn);
54         void set_use_parent (bool yn);
55
56         Gtk::SpinButton& get_spin_button() { return spinner; }
57
58         sigc::signal<void> StartGesture;
59         sigc::signal<void> StopGesture;
60
61         /* export this to allow direct connection to button events */
62
63         Gtk::Widget& event_widget() { return darea; }
64
65   protected:
66         Gtk::Adjustment&    adjustment;
67         BindingProxy        binding_proxy;
68         Gtk::DrawingArea    darea;
69         sigc::slot<void,char*,unsigned int> label_callback;
70         Glib::RefPtr<Pango::Layout> layout;
71         Style              _style;
72         bool                grabbed;
73         bool                switching;
74         bool                switch_on_release;
75         bool                with_text;
76         double              initial_value;
77         double              grab_x;
78         GdkWindow*          grab_window;
79         Gtk::SpinButton     spinner;
80         bool                use_parent;
81
82         bool button_press (GdkEventButton *);
83         bool button_release (GdkEventButton *);
84         bool motion (GdkEventMotion *);
85         bool expose (GdkEventExpose *);
86         bool scroll (GdkEventScroll *);
87         bool entry_focus_out (GdkEventFocus*);
88
89         gint mouse_control (double x, GdkWindow* w, double scaling);
90
91         gint switch_to_bar ();
92         gint switch_to_spinner ();
93
94         void entry_activated ();
95 };
96
97
98 }; /* namespace */
99
100 #endif // __gtkmm2ext_bar_controller_h__