ardour
utils.h
Go to the documentation of this file.
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/cairomm.h>
28 #include <pangomm/fontdescription.h>
29 
30 #include <gtkmm/container.h>
31 #include <gtkmm/treeview.h>
32 #include <gdkmm/window.h> /* for WMDecoration */
33 #include <gdkmm/pixbuf.h>
34 
35 #include "gtkmm2ext/visibility.h"
36 
37 namespace Cairo {
38  class Context;
39 }
40 
41 namespace Gtk {
42  class ComboBoxText;
43  class Widget;
44  class Window;
45  class Paned;
46  class Menu;
47 }
48 
49 namespace Gtkmm2ext {
50  LIBGTKMM2EXT_API void init (const char*);
51 
52  LIBGTKMM2EXT_API bool event_inside_widget_window (Gtk::Widget& widget, GdkEvent* ev);
53 
54  LIBGTKMM2EXT_API std::string fit_to_pixels (const std::string&, int pixel_width, Pango::FontDescription& font, int& actual_width, bool with_ellipses = false);
55  LIBGTKMM2EXT_API std::pair<std::string, double> fit_to_pixels (cairo_t *, std::string, double);
56  LIBGTKMM2EXT_API int pixel_width (const std::string& str, Pango::FontDescription& font);
57 
58  LIBGTKMM2EXT_API void get_ink_pixel_size (Glib::RefPtr<Pango::Layout>,
59  int& width, int& height);
60 
61 
62  LIBGTKMM2EXT_API void get_pixel_size (Glib::RefPtr<Pango::Layout>,
63  int& width, int& height);
64 
66  const gchar *text,
67  gint hpadding,
68  gint vpadding);
69 
71  const gchar* htext,
72  gint hpadding,
73  gint vpadding);
74 
75  LIBGTKMM2EXT_API void set_height_request_to_display_any_text (Gtk::Widget& w, gint vpadding);
76 
78  std::string const & text,
79  gint hpadding,
80  gint vpadding);
82  const std::vector<std::string>&,
83  gint hpadding,
84  gint vpadding);
86  const std::vector<std::string>&,
87  const std::string& hpadding,
88  gint vpadding);
89 
90 
91  LIBGTKMM2EXT_API Glib::RefPtr<Gdk::Pixbuf> pixbuf_from_string (const std::string& name,
92  const Pango::FontDescription& font,
93  int clip_width,
94  int clip_height,
95  Gdk::Color fg);
96 
97  LIBGTKMM2EXT_API void set_popdown_strings (Gtk::ComboBoxText&,
98  const std::vector<std::string>&);
99 
100  LIBGTKMM2EXT_API void get_popdown_strings (Gtk::ComboBoxText&,
101  std::vector<std::string>&);
102 
103  LIBGTKMM2EXT_API bool contains_value (Gtk::ComboBoxText&,
104  const std::string);
105 
106  LIBGTKMM2EXT_API bool set_active_text_if_present (Gtk::ComboBoxText&,
107  const std::string);
108 
109  template<class T> /*LIBGTKMM2EXT_API*/ void deferred_delete (void *ptr) {
110  delete static_cast<T *> (ptr);
111  }
112 
113  LIBGTKMM2EXT_API GdkWindow* get_paned_handle (Gtk::Paned& paned);
114  LIBGTKMM2EXT_API void set_decoration (Gtk::Window* win, Gdk::WMDecoration decor);
115  LIBGTKMM2EXT_API void set_treeview_header_as_default_label(Gtk::TreeViewColumn *c);
116  LIBGTKMM2EXT_API Glib::RefPtr<Gdk::Drawable> get_bogus_drawable();
117  LIBGTKMM2EXT_API void detach_menu (Gtk::Menu&);
118 
119  LIBGTKMM2EXT_API Glib::RefPtr<Gdk::Window> window_to_draw_on (Gtk::Widget& w, Gtk::Widget** parent);
120 
124 
125  LIBGTKMM2EXT_API int physical_screen_height (Glib::RefPtr<Gdk::Window>);
126  LIBGTKMM2EXT_API int physical_screen_width (Glib::RefPtr<Gdk::Window>);
127 
128  LIBGTKMM2EXT_API void container_clear (Gtk::Container&);
129 
130  /* C++ API for rounded rectangles */
131 
132  LIBGTKMM2EXT_API void rounded_rectangle (Cairo::RefPtr<Cairo::Context> context, double x, double y, double w, double h, double r=10);
133  LIBGTKMM2EXT_API void rounded_top_rectangle (Cairo::RefPtr<Cairo::Context> context, double x, double y, double w, double h, double r=10);
134  LIBGTKMM2EXT_API void rounded_top_left_rectangle (Cairo::RefPtr<Cairo::Context> context, double x, double y, double w, double h, double r=10);
135  LIBGTKMM2EXT_API void rounded_top_right_rectangle (Cairo::RefPtr<Cairo::Context> context, double x, double y, double w, double h, double r=10);
136  LIBGTKMM2EXT_API void rounded_top_half_rectangle (Cairo::RefPtr<Cairo::Context>, double x, double y, double w, double h, double r=10);
137  LIBGTKMM2EXT_API void rounded_bottom_half_rectangle (Cairo::RefPtr<Cairo::Context>, double x, double y, double w, double h, double r=10);
138  LIBGTKMM2EXT_API void rounded_right_half_rectangle (Cairo::RefPtr<Cairo::Context>, double x, double y, double w, double h, double r=10);
139  LIBGTKMM2EXT_API void rounded_left_half_rectangle (Cairo::RefPtr<Cairo::Context>, double x, double y, double w, double h, double r=10);
140 
141  /* C API for rounded rectangles */
142 
143  LIBGTKMM2EXT_API void rounded_rectangle (cairo_t*, double x, double y, double w, double h, double r=10);
144  LIBGTKMM2EXT_API void rounded_top_rectangle (cairo_t*, double x, double y, double w, double h, double r=10);
145  LIBGTKMM2EXT_API void rounded_top_left_rectangle (cairo_t*, double x, double y, double w, double h, double r=10);
146  LIBGTKMM2EXT_API void rounded_top_right_rectangle (cairo_t*, double x, double y, double w, double h, double r=10);
147  LIBGTKMM2EXT_API void rounded_top_half_rectangle (cairo_t*, double x, double y, double w, double h, double r=10);
148  LIBGTKMM2EXT_API void rounded_bottom_half_rectangle (cairo_t*, double x, double y, double w, double h, double r=10);
149  LIBGTKMM2EXT_API void rounded_right_half_rectangle (cairo_t*, double x, double y, double w, double h, double r=10);
150  LIBGTKMM2EXT_API void rounded_left_half_rectangle (cairo_t* cr, double x, double y, double w, double h, double r=10);
151 
152  LIBGTKMM2EXT_API Gtk::Label* left_aligned_label (std::string const &);
153 
154  LIBGTKMM2EXT_API void set_no_tooltip_whatsoever (Gtk::Widget &);
157 
158  LIBGTKMM2EXT_API void convert_bgra_to_rgba (guint8 const *, guint8 * dst, int, int);
159  LIBGTKMM2EXT_API const char* event_type_string (int event_type);
160 };
161 
162 #endif /* __gtkmm2ext_utils_h__ */
LIBGTKMM2EXT_API void get_pixel_size(Glib::RefPtr< Pango::Layout >, int &width, int &height)
Definition: utils.cc:62
LIBGTKMM2EXT_API bool event_inside_widget_window(Gtk::Widget &widget, GdkEvent *ev)
Definition: utils.cc:816
LIBGTKMM2EXT_API void set_size_request_to_display_given_text(Gtk::Widget &w, const gchar *text, gint hpadding, gint vpadding)
Definition: utils.cc:70
LIBGTKMM2EXT_API bool possibly_translate_mod_to_make_legal_accelerator(GdkModifierType &mod)
Definition: utils.cc:375
Definition: ardour_ui.h:130
void deferred_delete(void *ptr)
Definition: utils.h:109
LIBGTKMM2EXT_API int physical_screen_width(Glib::RefPtr< Gdk::Window >)
Definition: utils.cc:496
LIBGTKMM2EXT_API void rounded_left_half_rectangle(Cairo::RefPtr< Cairo::Context >, double x, double y, double w, double h, double r=10)
Definition: utils.cc:551
LIBGTKMM2EXT_API bool set_active_text_if_present(Gtk::ComboBoxText &, const std::string)
Definition: utils.cc:334
LIBGTKMM2EXT_API
LIBGTKMM2EXT_API int physical_screen_height(Glib::RefPtr< Gdk::Window >)
Definition: utils.cc:481
LIBGTKMM2EXT_API void rounded_bottom_half_rectangle(Cairo::RefPtr< Cairo::Context >, double x, double y, double w, double h, double r=10)
Definition: utils.cc:545
LIBGTKMM2EXT_API Glib::RefPtr< Gdk::Window > window_to_draw_on(Gtk::Widget &w, Gtk::Widget **parent)
Definition: utils.cc:676
LIBGTKMM2EXT_API bool contains_value(Gtk::ComboBoxText &, const std::string)
Definition: utils.cc:326
LIBGTKMM2EXT_API void set_popdown_strings(Gtk::ComboBoxText &, const std::vector< std::string > &)
LIBGTKMM2EXT_API void set_size_request_to_display_given_text_width(Gtk::Widget &w, const gchar *htext, gint hpadding, gint vpadding)
Definition: utils.cc:83
LIBGTKMM2EXT_API uint32_t possibly_translate_legal_accelerator_to_real_key(uint32_t keyval)
Definition: utils.cc:446
LIBGTKMM2EXT_API void rounded_top_half_rectangle(Cairo::RefPtr< Cairo::Context >, double x, double y, double w, double h, double r=10)
Definition: utils.cc:540
LIBGTKMM2EXT_API std::string fit_to_pixels(const std::string &, int pixel_width, Pango::FontDescription &font, int &actual_width, bool with_ellipses=false)
LIBGTKMM2EXT_API void set_no_tooltip_whatsoever(Gtk::Widget &)
Definition: utils.cc:797
LIBGTKMM2EXT_API void rounded_top_rectangle(Cairo::RefPtr< Cairo::Context > context, double x, double y, double w, double h, double r=10)
Definition: utils.cc:525
LIBGTKMM2EXT_API void disable_tooltips()
Definition: utils.cc:810
LIBGTKMM2EXT_API void set_treeview_header_as_default_label(Gtk::TreeViewColumn *c)
Definition: utils.cc:355
LIBGTKMM2EXT_API Glib::RefPtr< Gdk::Pixbuf > pixbuf_from_string(const std::string &name, const Pango::FontDescription &font, int clip_width, int clip_height, Gdk::Color fg)
LIBGTKMM2EXT_API Gtk::Label * left_aligned_label(std::string const &)
LIBGTKMM2EXT_API GdkWindow * get_paned_handle(Gtk::Paned &paned)
Definition: utils.cc:344
LIBGTKMM2EXT_API void rounded_right_half_rectangle(Cairo::RefPtr< Cairo::Context >, double x, double y, double w, double h, double r=10)
Definition: utils.cc:557
LIBGTKMM2EXT_API void enable_tooltips()
Definition: utils.cc:804
LIBGTKMM2EXT_API bool possibly_translate_keyval_to_make_legal_accelerator(uint32_t &keyval)
Definition: utils.cc:399
LIBGTKMM2EXT_API void convert_bgra_to_rgba(guint8 const *, guint8 *dst, int, int)
Definition: utils.cc:207
LIBGTKMM2EXT_API void get_popdown_strings(Gtk::ComboBoxText &, std::vector< std::string > &)
Definition: utils.cc:311
LIBGTKMM2EXT_API const char * event_type_string(int event_type)
Definition: utils.cc:843
LIBGTKMM2EXT_API void set_decoration(Gtk::Window *win, Gdk::WMDecoration decor)
Definition: utils.cc:350
LIBGTKMM2EXT_API void set_height_request_to_display_any_text(Gtk::Widget &w, gint vpadding)
Definition: utils.cc:102
LIBGTKMM2EXT_API void get_ink_pixel_size(Glib::RefPtr< Pango::Layout >, int &width, int &height)
Definition: utils.cc:51
const char * name
LIBGTKMM2EXT_API void init(const char *)
Definition: utils.cc:42
Definition: utils.h:37
LIBGTKMM2EXT_API void rounded_rectangle(Cairo::RefPtr< Cairo::Context > context, double x, double y, double w, double h, double r=10)
Definition: utils.cc:520
LIBGTKMM2EXT_API int pixel_width(const std::string &str, Pango::FontDescription &font)
LIBGTKMM2EXT_API Glib::RefPtr< Gdk::Drawable > get_bogus_drawable()
LIBGTKMM2EXT_API void detach_menu(Gtk::Menu &)
Definition: utils.cc:361
LIBGTKMM2EXT_API void rounded_top_left_rectangle(Cairo::RefPtr< Cairo::Context > context, double x, double y, double w, double h, double r=10)
Definition: utils.cc:530
LIBGTKMM2EXT_API void rounded_top_right_rectangle(Cairo::RefPtr< Cairo::Context > context, double x, double y, double w, double h, double r=10)
Definition: utils.cc:535
LIBGTKMM2EXT_API void container_clear(Gtk::Container &)
Definition: utils.cc:511