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