save tearoff state; restore monitor section state reasonably well; fixup access contr...
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / tearoff.h
1 /*
2     Copyright (C) 2003 Paul Barton-Davis
3  
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (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., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __gtkmm2ext_tearoff_h__
21 #define __gtkmm2ext_tearoff_h__
22
23 #include <gtkmm/window.h>
24 #include <gtkmm/arrow.h>
25 #include <gtkmm/box.h>
26 #include <gtkmm/eventbox.h>
27
28 class XMLNode;
29
30 namespace Gtkmm2ext {
31
32 class TearOff : public Gtk::HBox
33 {
34   public:
35         TearOff (Gtk::Widget& contents, bool allow_resize = false);
36         virtual ~TearOff ();
37
38         void set_visible (bool yn);
39         void set_can_be_torn_off (bool);
40         bool can_be_torn_off () const { return _can_be_torn_off; }
41
42         sigc::signal<void> Detach;
43         sigc::signal<void> Attach;
44         sigc::signal<void> Visible;
45         sigc::signal<void> Hidden;
46
47         Gtk::Window& tearoff_window() { return own_window; }
48         bool torn_off() const;
49         void tear_it_off ();
50         void put_it_back ();
51
52         void set_tornoff_state (const XMLNode&);
53         void add_tornoff_state (XMLNode&) const;
54
55   private:
56         Gtk::Widget&   contents;
57         Gtk::Window    own_window;
58         Gtk::Arrow     tearoff_arrow;
59         Gtk::Arrow     close_arrow;
60         Gtk::HBox      window_box;
61         Gtk::EventBox  tearoff_event_box;
62         Gtk::EventBox  close_event_box;
63         double         drag_x;
64         double         drag_y;
65         bool           dragging;
66         bool          _visible;
67         bool          _can_be_torn_off;
68         int            own_window_width;
69         int            own_window_height;
70         int            own_window_xpos;
71         int            own_window_ypos;
72
73         gint tearoff_click (GdkEventButton*);
74         gint close_click (GdkEventButton*);
75
76         gint window_motion (GdkEventMotion*);
77         gint window_button_press (GdkEventButton*);
78         gint window_button_release (GdkEventButton*);
79         gint window_delete_event (GdkEventAny*);
80
81         void own_window_realized ();
82         bool own_window_configured (GdkEventConfigure*);
83 };
84
85 } /* namespace */
86
87 #endif  // __gtkmm2ext_tearoff_h__