From cf509a9038c95c541f4080f2592924e82577af3f Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Thu, 6 Sep 2007 17:56:09 +0000 Subject: [PATCH 1/1] Removed run-time dependency on libpangocairo git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48593 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/cairo.h | 90 +++++++++++++++++++++++--------------------- src/common/cairo.cpp | 11 +++++- src/gtk/print.cpp | 16 ++++---- 3 files changed, 66 insertions(+), 51 deletions(-) diff --git a/include/wx/cairo.h b/include/wx/cairo.h index 5cdf39e598..4c9b725072 100644 --- a/include/wx/cairo.h +++ b/include/wx/cairo.h @@ -37,56 +37,57 @@ public: private: bool m_ok; wxDynamicLibrary *m_cairo_lib; + wxDynamicLibrary *m_pango_cairo_lib; static wxCairoLibrary *s_lib; public: - wxDL_METHOD_DEFINE( void, cairo_arc, - (cairo_t *cr, double xc, double yc, double radius, double angle1, double angle2), (cr, xc, yc, radius, angle1, angle2), /**/) - wxDL_METHOD_DEFINE( void, cairo_arc_negative, - (cairo_t *cr, double xc, double yc, double radius, double angle1, double angle2), (cr, xc, yc, radius, angle1, angle2), /**/) - wxDL_METHOD_DEFINE( void, cairo_clip, - (cairo_t *cr), (cr), /**/) - wxDL_METHOD_DEFINE( void, cairo_close_path, - (cairo_t *cr), (cr), /**/) + wxDL_VOIDMETHOD_DEFINE( cairo_arc, + (cairo_t *cr, double xc, double yc, double radius, double angle1, double angle2), (cr, xc, yc, radius, angle1, angle2) ) + wxDL_VOIDMETHOD_DEFINE( cairo_arc_negative, + (cairo_t *cr, double xc, double yc, double radius, double angle1, double angle2), (cr, xc, yc, radius, angle1, angle2) ) + wxDL_VOIDMETHOD_DEFINE( cairo_clip, + (cairo_t *cr), (cr) ) + wxDL_VOIDMETHOD_DEFINE( cairo_close_path, + (cairo_t *cr), (cr) ) wxDL_METHOD_DEFINE( cairo_t*, cairo_create, (cairo_surface_t *target), (target), NULL) - wxDL_METHOD_DEFINE( void, cairo_curve_to, - (cairo_t *cr, double x1, double y1, double x2, double y2, double x3, double y3), (cr, x1, y1, x2, y2, x3, y3), /**/) - wxDL_METHOD_DEFINE( void, cairo_destroy, - (cairo_t *cr), (cr), /**/) - wxDL_METHOD_DEFINE( void, cairo_fill, - (cairo_t *cr), (cr), /**/) - wxDL_METHOD_DEFINE( void, cairo_fill_preserve, - (cairo_t *cr), (cr), /**/) + wxDL_VOIDMETHOD_DEFINE( cairo_curve_to, + (cairo_t *cr, double x1, double y1, double x2, double y2, double x3, double y3), (cr, x1, y1, x2, y2, x3, y3) ) + wxDL_VOIDMETHOD_DEFINE( cairo_destroy, + (cairo_t *cr), (cr) ) + wxDL_VOIDMETHOD_DEFINE( cairo_fill, + (cairo_t *cr), (cr) ) + wxDL_VOIDMETHOD_DEFINE( cairo_fill_preserve, + (cairo_t *cr), (cr) ) wxDL_METHOD_DEFINE( cairo_surface_t*, cairo_get_target, (cairo_t *cr), (cr), NULL) wxDL_METHOD_DEFINE( cairo_surface_t*, cairo_image_surface_create_for_data, (unsigned char *data, cairo_format_t format, int width, int height, int stride), (data, format, width, height, stride), NULL) - wxDL_METHOD_DEFINE( void, cairo_line_to, - (cairo_t *cr, double x, double y), (cr, x, y), /**/) - wxDL_METHOD_DEFINE( void, cairo_move_to, - (cairo_t *cr, double x, double y), (cr, x, y), /**/) - wxDL_METHOD_DEFINE( void, cairo_new_path, - (cairo_t *cr), (cr), /**/) - wxDL_METHOD_DEFINE( void, cairo_paint, - (cairo_t *cr), (cr), /**/) - wxDL_METHOD_DEFINE( void, cairo_pattern_add_color_stop_rgba, - (cairo_pattern_t *pattern, double offset, double red, double green, double blue, double alpha), (pattern, offset, red, green, blue, alpha), /**/) + wxDL_VOIDMETHOD_DEFINE( cairo_line_to, + (cairo_t *cr, double x, double y), (cr, x, y) ) + wxDL_VOIDMETHOD_DEFINE( cairo_move_to, + (cairo_t *cr, double x, double y), (cr, x, y) ) + wxDL_VOIDMETHOD_DEFINE( cairo_new_path, + (cairo_t *cr), (cr) ) + wxDL_VOIDMETHOD_DEFINE( cairo_paint, + (cairo_t *cr), (cr) ) + wxDL_VOIDMETHOD_DEFINE( cairo_pattern_add_color_stop_rgba, + (cairo_pattern_t *pattern, double offset, double red, double green, double blue, double alpha), (pattern, offset, red, green, blue, alpha) ) wxDL_METHOD_DEFINE( cairo_pattern_t*, cairo_pattern_create_for_surface, (cairo_surface_t *surface), (surface), NULL) wxDL_METHOD_DEFINE( cairo_pattern_t*, cairo_pattern_create_linear, (double x0, double y0, double x1, double y1), (x0, y0, x1, y1), NULL) wxDL_METHOD_DEFINE( cairo_pattern_t*, cairo_pattern_create_radial, (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1), (cx0, cy0, radius0, cx1, cy1, radius1), NULL) - wxDL_METHOD_DEFINE( void, cairo_pattern_destroy, - (cairo_pattern_t *pattern), (pattern), /**/) - wxDL_METHOD_DEFINE( void, cairo_pattern_set_extend, - (cairo_pattern_t *pattern, cairo_extend_t extend), (pattern, extend), /**/) - wxDL_METHOD_DEFINE( void, cairo_pattern_set_filter, - (cairo_pattern_t *pattern, cairo_filter_t filter), (pattern, filter), /**/) - wxDL_METHOD_DEFINE( void, cairo_rectangle, - (cairo_t *cr, double x, double y, double width, double height), (cr, x, y, width, height), /**/) + wxDL_VOIDMETHOD_DEFINE( cairo_pattern_destroy, + (cairo_pattern_t *pattern), (pattern) ) + wxDL_VOIDMETHOD_DEFINE( cairo_pattern_set_extend, + (cairo_pattern_t *pattern, cairo_extend_t extend), (pattern, extend) ) + wxDL_VOIDMETHOD_DEFINE( cairo_pattern_set_filter, + (cairo_pattern_t *pattern, cairo_filter_t filter), (pattern, filter) ) + wxDL_VOIDMETHOD_DEFINE( cairo_rectangle, + (cairo_t *cr, double x, double y, double width, double height), (cr, x, y, width, height) ) wxDL_METHOD_DEFINE( void, cairo_reset_clip, (cairo_t *cr), (cr), /**/) wxDL_METHOD_DEFINE( void, cairo_restore, @@ -113,16 +114,21 @@ public: (cairo_t *cr, cairo_pattern_t *source), (cr, source), /**/) wxDL_METHOD_DEFINE( void, cairo_set_source_rgba, (cairo_t *cr, double red, double green, double blue, double alpha), (cr, red, green, blue, alpha), /**/) - wxDL_METHOD_DEFINE( void, cairo_stroke, - (cairo_t *cr), (cr), /**/) - wxDL_METHOD_DEFINE( void, cairo_stroke_preserve, - (cairo_t *cr), (cr), /**/) + wxDL_VOIDMETHOD_DEFINE( cairo_stroke, + (cairo_t *cr), (cr) ) + wxDL_VOIDMETHOD_DEFINE( cairo_stroke_preserve, + (cairo_t *cr), (cr) ) wxDL_METHOD_DEFINE( cairo_surface_t*, cairo_surface_create_similar, (cairo_surface_t *other, cairo_content_t content, int width, int height), (other, content, width, height), NULL) - wxDL_METHOD_DEFINE( void, cairo_surface_destroy, - (cairo_surface_t *surface), (surface), /**/) - wxDL_METHOD_DEFINE( void, cairo_translate, - (cairo_t *cr, double tx, double ty), (cr, tx, ty), /**/) + wxDL_VOIDMETHOD_DEFINE( cairo_surface_destroy, + (cairo_surface_t *surface), (surface) ) + wxDL_VOIDMETHOD_DEFINE( cairo_translate, + (cairo_t *cr, double tx, double ty), (cr, tx, ty) ) + + wxDL_VOIDMETHOD_DEFINE( pango_cairo_update_layout, + (cairo_t *cr, PangoLayout *layout), (cr, layout) ) + wxDL_VOIDMETHOD_DEFINE( pango_cairo_show_layout, + (cairo_t *cr, PangoLayout *layout), (cr, layout) ) DECLARE_NO_COPY_CLASS(wxCairoLibrary) }; diff --git a/src/common/cairo.cpp b/src/common/cairo.cpp index c6bb12b3fb..a9328718d0 100644 --- a/src/common/cairo.cpp +++ b/src/common/cairo.cpp @@ -35,9 +35,15 @@ wxCairoLibrary *wxCairoLibrary::s_lib = NULL; wxCairoLibrary::wxCairoLibrary() { m_cairo_lib = NULL; + m_pango_cairo_lib = NULL; wxLogNull log; - m_cairo_lib = new wxDynamicLibrary( wxT("libcairo.so") ); + + m_cairo_lib = new wxDynamicLibrary( wxT("libcairo.so.2") ); + m_ok = m_cairo_lib->IsLoaded(); + if (!m_ok) return; + + m_pango_cairo_lib = new wxDynamicLibrary( wxT("libpangocairo-1.0.so.0") ); m_ok = m_cairo_lib->IsLoaded(); if (!m_ok) return; @@ -126,6 +132,9 @@ void wxCairoLibrary::InitializeMethods() wxDL_METHOD_LOAD( m_cairo_lib, cairo_surface_destroy, success ) wxDL_METHOD_LOAD( m_cairo_lib, cairo_translate, success ) + wxDL_METHOD_LOAD( m_pango_cairo_lib, pango_cairo_update_layout, success ) + wxDL_METHOD_LOAD( m_pango_cairo_lib, pango_cairo_show_layout, success ) + m_ok = true; } diff --git a/src/gtk/print.cpp b/src/gtk/print.cpp index b5eabec535..d52518e89e 100644 --- a/src/gtk/print.cpp +++ b/src/gtk/print.cpp @@ -1870,14 +1870,14 @@ void wxGtkPrintDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, { gs_cairo->cairo_save( m_cairo ); gs_cairo->cairo_rotate( m_cairo, angle*DEG2RAD ); - // pango_cairo_update_layout (m_cairo, m_layout); - // pango_cairo_show_layout (m_cairo, m_layout); + gs_cairo->pango_cairo_update_layout (m_cairo, m_layout); + gs_cairo->pango_cairo_show_layout (m_cairo, m_layout); gs_cairo->cairo_restore( m_cairo ); } else { - // pango_cairo_update_layout (m_cairo, m_layout); - // pango_cairo_show_layout (m_cairo, m_layout); + gs_cairo->pango_cairo_update_layout (m_cairo, m_layout); + gs_cairo->pango_cairo_show_layout (m_cairo, m_layout); } // Reset unscaled size. @@ -1917,14 +1917,14 @@ void wxGtkPrintDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, { gs_cairo->cairo_save( m_cairo ); gs_cairo->cairo_rotate( m_cairo, angle*DEG2RAD ); - // pango_cairo_update_layout (m_cairo, m_layout); - // pango_cairo_show_layout (m_cairo, m_layout); + gs_cairo->pango_cairo_update_layout (m_cairo, m_layout); + gs_cairo->pango_cairo_show_layout (m_cairo, m_layout); gs_cairo->cairo_restore( m_cairo ); } else { - // pango_cairo_update_layout (m_cairo, m_layout); - // pango_cairo_show_layout (m_cairo, m_layout); + gs_cairo->pango_cairo_update_layout (m_cairo, m_layout); + gs_cairo->pango_cairo_show_layout (m_cairo, m_layout); } } -- 2.45.2