LV2 Toolkit  1.1.1
 All Classes Namespaces Functions Typedefs Enumerations Enumerator Groups Pages
gtkui.hpp
1 /****************************************************************************
2 
3  gtkui.hpp - Wrapper library to make it easier to write LV2 GtkUIs in C++
4 
5  Copyright (C) 2006-2008 Lars Luthman <lars.luthman@gmail.com>
6  Modified by Dave Robillard, 2008 (URI map mixin)
7  Modified by Michael Fisher, 2012 (LV2 rev3)
8 
9  This program is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 3 of the License, or
12  (at your option) any later version.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  Boston, MA 02110-1301 USA
23 
24  ****************************************************************************/
25 
26 #ifndef LVTK_LV2_GTKUI_HPP
27 #define LVTK_LV2_GTKUI_HPP
28 
29 
30 #include <gtkmm.h>
31 #include <lvtk/ui.hpp>
32 
33 
34 namespace lvtk {
35 
36 
44  template <bool Required = true>
45  struct GtkUI
46  {
48  template <class Derived>
49  struct I : Extension<Required>
50  {
51  I() : p_container(NULL)
52  {
53  /* Call before anything else. Prevents glib warnings */
54  Gtk::Main::init_gtkmm_internals();
55 
56  p_container = Gtk::manage (new Gtk::VBox());
57  }
58 
59  ~I()
60  {
62  }
63 
65  static void
67  {
69  }
70 
71 
76  bool
78  {
79  return (p_container != NULL);
80  }
81 
82  protected:
83 
88  Gtk::VBox& container()
89  {
90  return *p_container;
91  }
92 
102  void add (Gtk::Widget& widget)
103  {
104  p_container->pack_start (widget);
105  }
106 
111  LV2UI_Widget*
113  {
114  return widget_cast (p_container->gobj());
115  }
116 
117  private:
119  Gtk::VBox *p_container;
120 
121  };
122  };
123 
124 
125 } /* namespace lvtk */
126 
127 
128 #endif /* LVTK_LV2_GTKUI_HPP */