save/restore tabbable state
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / tabbable.h
1 /*
2     Copyright (C) 2015 Paul 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_tabbable_h__
21 #define __gtkmm2ext_tabbable_h__
22
23 #include <gtkmm/bin.h>
24
25 #include "gtkmm2ext/window_proxy.h"
26 #include "gtkmm2ext/visibility.h"
27
28 namespace Gtk {
29         class Window;
30         class Notebook;
31 }
32
33 namespace Gtkmm2ext {
34
35 class VisibilityTracker;
36
37 class LIBGTKMM2EXT_API Tabbable : public WindowProxy {
38   public:
39         Tabbable (Gtk::Widget&, const std::string&);
40         ~Tabbable ();
41
42         void add_to_notebook (Gtk::Notebook& notebook, const std::string& tab_title, int position);
43         void show_tab ();
44         
45         Gtk::Widget& contents() const { return _contents; }
46         
47         Gtk::Window* get (bool create = false);
48         Gtk::Window* own_window () { return get (false); } 
49         virtual Gtk::Window* use_own_window (bool and_pack_it);
50
51         bool has_own_window () const;
52         bool is_tabbed () const;
53
54         virtual void show_window ();
55
56         bool window_visible ();
57
58         Gtk::Window* current_toplevel () const;
59
60         Gtk::Notebook* tab_root_drop ();
61
62         int set_state (const XMLNode&, int version);
63         XMLNode& get_state ();
64         
65         static std::string xml_node_name();
66         
67   protected:
68         bool delete_event_handler (GdkEventAny *ev);
69         
70   private:
71         Gtk::Widget&   _contents;
72         Gtk::Notebook  _own_notebook;
73         Gtk::Notebook* _parent_notebook;
74         std::string    _tab_title;
75         int            _notebook_position;
76 };
77
78 }
79
80 #endif