3528435ed1889f71449dbabfb400f384dc968946
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / utils.h
1 /*
2     Copyright (C) 1999 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_utils_h__
21 #define __gtkmm2ext_utils_h__
22
23 #include <vector>
24 #include <string>
25 #include <stdint.h>
26
27 #include <gtkmm/container.h>
28 #include <gtkmm/treeview.h>
29 #include <gdkmm/window.h> /* for WMDecoration */
30 #include <gdkmm/pixbuf.h>
31 #include <pangomm/fontdescription.h>
32
33 namespace Gtk {
34         class ComboBoxText;
35         class Widget;
36         class Window;
37         class Paned;
38         class Menu;
39 }
40
41 namespace Gtkmm2ext {
42         void init ();
43
44         void get_ink_pixel_size (Glib::RefPtr<Pango::Layout>, 
45                                  int& width, int& height);
46
47         void set_size_request_to_display_given_text (Gtk::Widget &w,
48                                                      const gchar *text,
49                                                      gint hpadding,
50                                                      gint vpadding);
51
52         void set_size_request_to_display_given_text (Gtk::Widget &w,
53                                                      const std::vector<std::string>&,
54                                                      gint hpadding,
55                                                      gint vpadding);
56
57         Glib::RefPtr<Gdk::Pixbuf> pixbuf_from_string (const std::string& name, 
58                                                       Pango::FontDescription* font, 
59                                                       int clip_width, 
60                                                       int clip_height, 
61                                                       Gdk::Color fg);
62
63         void set_popdown_strings (Gtk::ComboBoxText&, 
64                                   const std::vector<std::string>&, 
65                                   bool set_size = false,
66                                   gint hpadding = 0, gint vpadding = 0);
67
68         // Combo's are stupid - they steal space from the entry for the button
69 #ifdef GTKOSX
70         static const guint32 COMBO_FUDGE = 38; 
71 #else
72         static const guint32 COMBO_FUDGE = 24; 
73 #endif
74
75         template<class T> void deferred_delete (void *ptr) {
76                 delete static_cast<T *> (ptr);
77         }
78
79         GdkWindow* get_paned_handle (Gtk::Paned& paned);
80         void set_decoration (Gtk::Window* win, Gdk::WMDecoration decor);
81         void set_treeview_header_as_default_label(Gtk::TreeViewColumn *c);
82         Glib::RefPtr<Gdk::Drawable> get_bogus_drawable();
83         void detach_menu (Gtk::Menu&);
84
85         bool possibly_translate_keyval_to_make_legal_accelerator (uint32_t& keyval);
86         uint32_t possibly_translate_legal_accelerator_to_real_key (uint32_t keyval);
87
88         int physical_screen_height (Glib::RefPtr<Gdk::Window>);
89         int physical_screen_width (Glib::RefPtr<Gdk::Window>);
90
91         void container_clear (Gtk::Container&);
92 };
93
94 #endif /*  __gtkmm2ext_utils_h__ */