From 711a481223e50d08205648cf67b82d0d8b8ed335 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 10 Nov 2010 13:52:45 +0000 Subject: [PATCH] Use Cairo for wxGraphicsContext in wxX11. Check for Cairo in configure for wxX11 too. Fix compilation of wxCairoContext for non-{GTK,MSW} platforms. Also make wxUSE_CAIRO a "normal" option, i.e. add it to all wx/setup.h files instead of defining it as 1 unconditionally for wxGTK and 0 for everything else. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66094 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- configure | 41 ++++++++++++++++++++++++------------ configure.in | 12 ++++++++++- include/wx/chkconf.h | 16 ++++++-------- include/wx/motif/setup0.h | 13 ++++++++++++ include/wx/msw/setup0.h | 13 ++++++++++++ include/wx/msw/wince/setup.h | 13 ++++++++++++ include/wx/os2/setup0.h | 13 ++++++++++++ include/wx/osx/setup0.h | 13 ++++++++++++ include/wx/palmos/setup0.h | 13 ++++++++++++ include/wx/setup_inc.h | 13 ++++++++++++ include/wx/univ/setup0.h | 13 ++++++++++++ setup.h.in | 3 +++ src/generic/graphicc.cpp | 7 +++--- 13 files changed, 156 insertions(+), 27 deletions(-) diff --git a/configure b/configure index edbaf0892a..fbd626ed31 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Id: configure.in 65489 2010-09-09 20:59:10Z VZ . +# From configure.in Id. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for wxWidgets 2.9.2. # @@ -16958,7 +16958,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | else ac_cv_prog_gcc_traditional=no fi -rm -f -r conftest* +rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then @@ -16975,7 +16975,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "$ac_pattern" >/dev/null 2>&1; then ac_cv_prog_gcc_traditional=yes fi -rm -f -r conftest* +rm -f conftest* fi fi @@ -19598,7 +19598,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | else ac_cv_header_stdc=no fi -rm -f -r conftest* +rm -f conftest* fi @@ -19619,7 +19619,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | else ac_cv_header_stdc=no fi -rm -f -r conftest* +rm -f conftest* fi @@ -24420,11 +24420,13 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include /* for off_t */ + #include int main () { -return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0); +int (*fp) (FILE *, off_t, int) = fseeko; + return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); ; return 0; } @@ -24464,11 +24466,13 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #define _LARGEFILE_SOURCE 1 -#include +#include /* for off_t */ + #include int main () { -return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0); +int (*fp) (FILE *, off_t, int) = fseeko; + return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); ; return 0; } @@ -24515,7 +24519,7 @@ cat >>confdefs.h <<_ACEOF _ACEOF ;; esac -rm -f -r conftest* +rm -f conftest* # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug # in glibc 2.1.3, but that breaks too many other things. @@ -31225,7 +31229,7 @@ _ACEOF eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 's/^$ac_var=//p'\`" done # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. - for ac_extension in a so sl dylib la dll; do + for ac_extension in a so sl; do if test ! -f "$ac_im_usrlibdir/libX11.$ac_extension" && test -f "$ac_im_libdir/libX11.$ac_extension"; then ac_im_usrlibdir=$ac_im_libdir; break @@ -31378,7 +31382,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g` do # Don't even attempt the hair of trying to link an X program! - for ac_extension in a so sl dylib la dll; do + for ac_extension in a so sl; do if test -r "$ac_dir/libX11.$ac_extension"; then ac_x_libraries=$ac_dir break 2 @@ -48143,7 +48147,7 @@ echo "${ECHO_T}$wx_cv_lib_gdiplus" >&6; } if test "$wx_cv_lib_gdiplus" = "yes"; then wx_has_graphics=1 fi - elif test "$wxUSE_GTK" = 1; then + elif test "$wxUSE_GTK" = 1 -o "$wxUSE_X11" = 1; then pkg_failed=no { echo "$as_me:$LINENO: checking for CAIRO" >&5 @@ -48217,6 +48221,17 @@ else echo "${ECHO_T}yes" >&6; } wx_has_graphics=1 fi + if test "$wx_has_graphics" = 1; then + cat >>confdefs.h <<\_ACEOF +#define wxUSE_CAIRO 1 +_ACEOF + + + if test "$wxUSE_GTK" != 1; then + CPPFLAGS="$CAIRO_CFLAGS $CPPFLAGS" + GUI_TK_LIBRARY="$GUI_TK_LIBRARY $CAIRO_LIBS" + fi + fi else wx_has_graphics=1 fi diff --git a/configure.in b/configure.in index 1eae0beda8..9ef9a8d2d3 100644 --- a/configure.in +++ b/configure.in @@ -7498,11 +7498,21 @@ if test "$wxUSE_GRAPHICS_CONTEXT" = "yes"; then if test "$wx_cv_lib_gdiplus" = "yes"; then wx_has_graphics=1 fi - elif test "$wxUSE_GTK" = 1; then + elif test "$wxUSE_GTK" = 1 -o "$wxUSE_X11" = 1; then PKG_CHECK_MODULES(CAIRO, cairo, [wx_has_graphics=1], [AC_MSG_WARN([Cairo library not found])] ) + if test "$wx_has_graphics" = 1; then + AC_DEFINE(wxUSE_CAIRO) + + dnl We don't need to do this for wxGTK as we already get Cairo + dnl flags as part of GTK+ ones. + if test "$wxUSE_GTK" != 1; then + CPPFLAGS="$CAIRO_CFLAGS $CPPFLAGS" + GUI_TK_LIBRARY="$GUI_TK_LIBRARY $CAIRO_LIBS" + fi + fi else dnl assume it's ok, add more checks here if needed wx_has_graphics=1 diff --git a/include/wx/chkconf.h b/include/wx/chkconf.h index e71915d016..e233b4068f 100644 --- a/include/wx/chkconf.h +++ b/include/wx/chkconf.h @@ -439,17 +439,13 @@ # endif #endif /* !defined(wxUSE_BUTTON) */ -/* - This one is special, it's only used under wxGTK currently so don't require - pre-defining it. - */ #ifndef wxUSE_CAIRO -# ifdef __WXGTK210__ -# define wxUSE_CAIRO 1 -# else -# define wxUSE_CAIRO 0 -# endif -#endif +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxUSE_BUTTON must be defined, please read comment near the top of this file." +# else +# define wxUSE_CAIRO 0 +# endif +#endif /* !defined(wxUSE_CAIRO) */ #ifndef wxUSE_CALENDARCTRL # ifdef wxABORT_ON_CONFIG_ERROR diff --git a/include/wx/motif/setup0.h b/include/wx/motif/setup0.h index f5ac2e4af7..594396bb69 100644 --- a/include/wx/motif/setup0.h +++ b/include/wx/motif/setup0.h @@ -689,6 +689,19 @@ # define wxUSE_GRAPHICS_CONTEXT 0 #endif +// Enable wxGraphicsContext implementation using Cairo library. +// +// This is not needed under Windows and detected automatically by configure +// under other systems, however you may set this to 1 manually if you installed +// Cairo under Windows yourself and prefer to use it instead the native GDI+ +// implementation. +// +// Default is 0 +// +// Recommended setting: 0 +#define wxUSE_CAIRO 0 + + // ---------------------------------------------------------------------------- // Individual GUI controls // ---------------------------------------------------------------------------- diff --git a/include/wx/msw/setup0.h b/include/wx/msw/setup0.h index 4a2210c91f..6eb47ced8f 100644 --- a/include/wx/msw/setup0.h +++ b/include/wx/msw/setup0.h @@ -689,6 +689,19 @@ # define wxUSE_GRAPHICS_CONTEXT 0 #endif +// Enable wxGraphicsContext implementation using Cairo library. +// +// This is not needed under Windows and detected automatically by configure +// under other systems, however you may set this to 1 manually if you installed +// Cairo under Windows yourself and prefer to use it instead the native GDI+ +// implementation. +// +// Default is 0 +// +// Recommended setting: 0 +#define wxUSE_CAIRO 0 + + // ---------------------------------------------------------------------------- // Individual GUI controls // ---------------------------------------------------------------------------- diff --git a/include/wx/msw/wince/setup.h b/include/wx/msw/wince/setup.h index b8f731c9c9..64ec15aceb 100644 --- a/include/wx/msw/wince/setup.h +++ b/include/wx/msw/wince/setup.h @@ -689,6 +689,19 @@ # define wxUSE_GRAPHICS_CONTEXT 0 #endif +// Enable wxGraphicsContext implementation using Cairo library. +// +// This is not needed under Windows and detected automatically by configure +// under other systems, however you may set this to 1 manually if you installed +// Cairo under Windows yourself and prefer to use it instead the native GDI+ +// implementation. +// +// Default is 0 +// +// Recommended setting: 0 +#define wxUSE_CAIRO 0 + + // ---------------------------------------------------------------------------- // Individual GUI controls // ---------------------------------------------------------------------------- diff --git a/include/wx/os2/setup0.h b/include/wx/os2/setup0.h index 45ba6ad2af..7656412c7b 100644 --- a/include/wx/os2/setup0.h +++ b/include/wx/os2/setup0.h @@ -689,6 +689,19 @@ # define wxUSE_GRAPHICS_CONTEXT 0 #endif +// Enable wxGraphicsContext implementation using Cairo library. +// +// This is not needed under Windows and detected automatically by configure +// under other systems, however you may set this to 1 manually if you installed +// Cairo under Windows yourself and prefer to use it instead the native GDI+ +// implementation. +// +// Default is 0 +// +// Recommended setting: 0 +#define wxUSE_CAIRO 0 + + // ---------------------------------------------------------------------------- // Individual GUI controls // ---------------------------------------------------------------------------- diff --git a/include/wx/osx/setup0.h b/include/wx/osx/setup0.h index 29ef9e4b43..938a79c502 100644 --- a/include/wx/osx/setup0.h +++ b/include/wx/osx/setup0.h @@ -690,6 +690,19 @@ # define wxUSE_GRAPHICS_CONTEXT 0 #endif +// Enable wxGraphicsContext implementation using Cairo library. +// +// This is not needed under Windows and detected automatically by configure +// under other systems, however you may set this to 1 manually if you installed +// Cairo under Windows yourself and prefer to use it instead the native GDI+ +// implementation. +// +// Default is 0 +// +// Recommended setting: 0 +#define wxUSE_CAIRO 0 + + // ---------------------------------------------------------------------------- // Individual GUI controls // ---------------------------------------------------------------------------- diff --git a/include/wx/palmos/setup0.h b/include/wx/palmos/setup0.h index 7c806a1376..ccfff36d0d 100644 --- a/include/wx/palmos/setup0.h +++ b/include/wx/palmos/setup0.h @@ -689,6 +689,19 @@ # define wxUSE_GRAPHICS_CONTEXT 0 #endif +// Enable wxGraphicsContext implementation using Cairo library. +// +// This is not needed under Windows and detected automatically by configure +// under other systems, however you may set this to 1 manually if you installed +// Cairo under Windows yourself and prefer to use it instead the native GDI+ +// implementation. +// +// Default is 0 +// +// Recommended setting: 0 +#define wxUSE_CAIRO 0 + + // ---------------------------------------------------------------------------- // Individual GUI controls // ---------------------------------------------------------------------------- diff --git a/include/wx/setup_inc.h b/include/wx/setup_inc.h index 0db49ad1bd..84d18783ef 100644 --- a/include/wx/setup_inc.h +++ b/include/wx/setup_inc.h @@ -685,6 +685,19 @@ # define wxUSE_GRAPHICS_CONTEXT 0 #endif +// Enable wxGraphicsContext implementation using Cairo library. +// +// This is not needed under Windows and detected automatically by configure +// under other systems, however you may set this to 1 manually if you installed +// Cairo under Windows yourself and prefer to use it instead the native GDI+ +// implementation. +// +// Default is 0 +// +// Recommended setting: 0 +#define wxUSE_CAIRO 0 + + // ---------------------------------------------------------------------------- // Individual GUI controls // ---------------------------------------------------------------------------- diff --git a/include/wx/univ/setup0.h b/include/wx/univ/setup0.h index a6fc8f7855..2c939907ff 100644 --- a/include/wx/univ/setup0.h +++ b/include/wx/univ/setup0.h @@ -688,6 +688,19 @@ # define wxUSE_GRAPHICS_CONTEXT 0 #endif +// Enable wxGraphicsContext implementation using Cairo library. +// +// This is not needed under Windows and detected automatically by configure +// under other systems, however you may set this to 1 manually if you installed +// Cairo under Windows yourself and prefer to use it instead the native GDI+ +// implementation. +// +// Default is 0 +// +// Recommended setting: 0 +#define wxUSE_CAIRO 0 + + // ---------------------------------------------------------------------------- // Individual GUI controls // ---------------------------------------------------------------------------- diff --git a/setup.h.in b/setup.h.in index b975213e2a..1a7de3353d 100644 --- a/setup.h.in +++ b/setup.h.in @@ -343,6 +343,9 @@ # define wxUSE_GRAPHICS_CONTEXT 0 #endif +#define wxUSE_CAIRO 0 + + #define wxUSE_CONTROLS 0 diff --git a/src/generic/graphicc.cpp b/src/generic/graphicc.cpp index 9b9e88b22f..d2150dfae9 100644 --- a/src/generic/graphicc.cpp +++ b/src/generic/graphicc.cpp @@ -785,7 +785,7 @@ void wxCairoFontData::Apply( wxGraphicsContext* context ) cairo_set_font_face(ctext, m_font); cairo_set_font_size(ctext, m_size ); #else - cairo_select_font_face(ctext, m_fontName, m_slant, m_weights ); + cairo_select_font_face(ctext, m_fontName, m_slant, m_weight ); cairo_set_font_size(ctext, m_size ); #endif } @@ -1071,6 +1071,7 @@ wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitm { wxCHECK_RET( bmp.IsOk(), wxT("Invalid bitmap in wxCairoContext::DrawBitmap")); +#ifdef wxHAS_RAW_BITMAP int bw = m_width = bmp.GetWidth(); int bh = m_height = bmp.GetHeight(); wxBitmap bmpSource = bmp; // we need a non-const instance @@ -1138,6 +1139,7 @@ wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitm } } m_pattern = cairo_pattern_create_for_surface(m_surface); +#endif // wxHAS_RAW_BITMAP } wxCairoBitmapData::~wxCairoBitmapData() @@ -1830,8 +1832,7 @@ wxGraphicsContext * wxCairoRenderer::CreateContextFromNativeContext( void * cont { #ifdef __WXMSW__ return new wxCairoContext(this,(HDC)context); -#endif -#ifdef __WXGTK__ +#else return new wxCairoContext(this,(cairo_t*)context); #endif } -- 2.45.2