support for GTK3

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71894 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett
2012-06-30 20:39:06 +00:00
parent 6f41c10973
commit 9dc44eff02
89 changed files with 6885 additions and 1923 deletions

File diff suppressed because it is too large Load Diff

1
aclocal.m4 vendored
View File

@@ -22,6 +22,7 @@ m4_include([build/aclocal/bakefile-lang.m4])
m4_include([build/aclocal/bakefile.m4])
m4_include([build/aclocal/cppunit.m4])
m4_include([build/aclocal/gtk-2.0.m4])
m4_include([build/aclocal/gtk-3.0.m4])
m4_include([build/aclocal/gtk.m4])
m4_include([build/aclocal/pkg.m4])
m4_include([build/aclocal/sdl.m4])

View File

@@ -560,6 +560,18 @@ dnl ### begin block 20_COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GU
COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1=""
fi
AC_SUBST(COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1)
dnl ### begin block 20_COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_3[wx.bkl] ###
COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_3="#"
if test "x$PLATFORM_UNIX" = "x1" -a "x$TOOLKIT" = "xGTK" -a "x$TOOLKIT_VERSION" = "x3" ; then
COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_3=""
fi
AC_SUBST(COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_3)
dnl ### begin block 20_COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1[wx.bkl] ###
COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1="#"
if test "x$PLATFORM_UNIX" = "x1" -a "x$TOOLKIT" = "xGTK" -a "x$TOOLKIT_VERSION" = "x3" -a "x$USE_GUI" = "x1" ; then
COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1=""
fi
AC_SUBST(COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1)
dnl ### begin block 20_COND_PLATFORM_UNIX_1_USE_GUI_1[wx.bkl] ###
COND_PLATFORM_UNIX_1_USE_GUI_1="#"
if test "x$PLATFORM_UNIX" = "x1" -a "x$USE_GUI" = "x1" ; then
@@ -740,6 +752,36 @@ dnl ### begin block 20_COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1_WXUNIV_0[wx.
COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1_WXUNIV_0=""
fi
AC_SUBST(COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1_WXUNIV_0)
dnl ### begin block 20_COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_WXUNIV_0[wx.bkl] ###
COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_WXUNIV_0="#"
if test "x$TOOLKIT" = "xGTK" -a "x$TOOLKIT_VERSION" = "x2" -a "x$WXUNIV" = "x0" ; then
COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_WXUNIV_0=""
fi
AC_SUBST(COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_WXUNIV_0)
dnl ### begin block 20_COND_TOOLKIT_GTK_TOOLKIT_VERSION_3[wx.bkl] ###
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3="#"
if test "x$TOOLKIT" = "xGTK" -a "x$TOOLKIT_VERSION" = "x3" ; then
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3=""
fi
AC_SUBST(COND_TOOLKIT_GTK_TOOLKIT_VERSION_3)
dnl ### begin block 20_COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1[wx.bkl] ###
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1="#"
if test "x$TOOLKIT" = "xGTK" -a "x$TOOLKIT_VERSION" = "x3" -a "x$USE_GUI" = "x1" ; then
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1=""
fi
AC_SUBST(COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1)
dnl ### begin block 20_COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1_WXUNIV_0[wx.bkl] ###
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1_WXUNIV_0="#"
if test "x$TOOLKIT" = "xGTK" -a "x$TOOLKIT_VERSION" = "x3" -a "x$USE_GUI" = "x1" -a "x$WXUNIV" = "x0" ; then
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1_WXUNIV_0=""
fi
AC_SUBST(COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1_WXUNIV_0)
dnl ### begin block 20_COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_WXUNIV_0[wx.bkl] ###
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_WXUNIV_0="#"
if test "x$TOOLKIT" = "xGTK" -a "x$TOOLKIT_VERSION" = "x3" -a "x$WXUNIV" = "x0" ; then
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_WXUNIV_0=""
fi
AC_SUBST(COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_WXUNIV_0)
dnl ### begin block 20_COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1[wx.bkl] ###
COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1="#"
if test "x$TOOLKIT" = "xGTK" -a "x$TOOLKIT_VERSION" = "x" -a "x$USE_GUI" = "x1" ; then

219
build/aclocal/gtk-3.0.m4 Normal file
View File

@@ -0,0 +1,219 @@
# Configure paths for GTK+
# Owen Taylor 1997-2001
dnl AM_PATH_GTK_3_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
dnl Test for GTK+, and define GTK_CFLAGS and GTK_LIBS, if gthread is specified in MODULES,
dnl pass to pkg-config
dnl
AC_DEFUN([AM_PATH_GTK_3_0],
[dnl
dnl Get the cflags and libraries from pkg-config
dnl
AC_ARG_ENABLE(gtktest, [ --disable-gtktest do not try to compile and run a test GTK+ program],
, enable_gtktest=yes)
pkg_config_args=gtk+-3.0
for module in . $4
do
case "$module" in
gthread)
pkg_config_args="$pkg_config_args gthread-2.0"
;;
esac
done
no_gtk=""
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test x$PKG_CONFIG != xno ; then
if $PKG_CONFIG --atleast-pkgconfig-version 0.7 ; then
:
else
echo "*** pkg-config too old; version 0.7 or better required."
no_gtk=yes
PKG_CONFIG=no
fi
else
no_gtk=yes
fi
min_gtk_version=ifelse([$1], ,3.0.0,$1)
AC_MSG_CHECKING(for GTK+ - version >= $min_gtk_version)
if test x$PKG_CONFIG != xno ; then
## don't try to run the test against uninstalled libtool libs
if $PKG_CONFIG --uninstalled $pkg_config_args; then
echo "Will use uninstalled version of GTK+ found in PKG_CONFIG_PATH"
enable_gtktest=no
fi
if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args; then
:
else
no_gtk=yes
fi
fi
if test x"$no_gtk" = x ; then
GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
if test "x$enable_gtktest" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $GTK_CFLAGS"
LIBS="$GTK_LIBS $LIBS"
dnl
dnl Now check if the installed GTK+ is sufficiently new. (Also sanity
dnl checks the results of pkg-config to some extent)
dnl
rm -f conf.gtktest
AC_TRY_RUN([
#include <gtk/gtk.h>
#include <stdio.h>
#include <stdlib.h>
int
main ()
{
int major, minor, micro;
char *tmp_version;
fclose (fopen ("conf.gtktest", "w"));
/* HP/UX 9 (%@#!) writes to sscanf strings */
tmp_version = g_strdup("$min_gtk_version");
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
printf("%s, bad version string\n", "$min_gtk_version");
exit(1);
}
if ((gtk_major_version != $gtk_config_major_version) ||
(gtk_minor_version != $gtk_config_minor_version) ||
(gtk_micro_version != $gtk_config_micro_version))
{
printf("\n*** 'pkg-config --modversion gtk+-3.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
$gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
gtk_major_version, gtk_minor_version, gtk_micro_version);
printf ("*** was found! If pkg-config was correct, then it is best\n");
printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
printf("*** required on your system.\n");
printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
printf("*** to point to the correct configuration files\n");
}
else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
(gtk_minor_version != GTK_MINOR_VERSION) ||
(gtk_micro_version != GTK_MICRO_VERSION))
{
printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
printf("*** library (version %d.%d.%d)\n",
gtk_major_version, gtk_minor_version, gtk_micro_version);
}
else
{
if ((gtk_major_version > major) ||
((gtk_major_version == major) && (gtk_minor_version > minor)) ||
((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
{
return 0;
}
else
{
printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
gtk_major_version, gtk_minor_version, gtk_micro_version);
printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
major, minor, micro);
printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
printf("***\n");
printf("*** If you have already installed a sufficiently new version, this error\n");
printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
printf("*** being found. The easiest way to fix this is to remove the old version\n");
printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n");
printf("*** correct copy of pkg-config. (In this case, you will have to\n");
printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
printf("*** so that the correct libraries are found at run-time))\n");
}
}
return 1;
}
],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
if test "x$no_gtk" = x ; then
AC_MSG_RESULT(yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version))
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
if test "$PKG_CONFIG" = "no" ; then
echo "*** A new enough version of pkg-config was not found."
echo "*** See http://pkgconfig.sourceforge.net"
else
if test -f conf.gtktest ; then
:
else
echo "*** Could not run GTK+ test program, checking why..."
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $GTK_CFLAGS"
LIBS="$LIBS $GTK_LIBS"
AC_TRY_LINK([
#include <gtk/gtk.h>
#include <stdio.h>
], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
[ echo "*** The test program compiled, but did not run. This usually means"
echo "*** that the run-time linker is not finding GTK+ or finding the wrong"
echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your"
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
echo "*** to the installed location Also, make sure you have run ldconfig if that"
echo "*** is required on your system"
echo "***"
echo "*** If you have an old version installed, it is best to remove it, although"
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
[ echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means GTK+ is incorrectly installed."])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
GTK_CFLAGS=""
GTK_LIBS=""
ifelse([$3], , :, [$3])
fi
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
rm -f conf.gtktest
])
dnl GTK_CHECK_BACKEND(BACKEND-NAME [, MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
dnl Tests for BACKEND-NAME in the GTK targets list
dnl
AC_DEFUN([GTK_CHECK_BACKEND],
[
pkg_config_args=ifelse([$1],,gtk+-3.0, gtk+-$1-3.0)
min_gtk_version=ifelse([$2],,3.0.0,$2)
AC_PATH_PROG(PKG_CONFIG, [pkg-config], [AC_MSG_ERROR([No pkg-config found])])
if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args ; then
target_found=yes
else
target_found=no
fi
if test "x$target_found" = "xno"; then
ifelse([$4],,[AC_MSG_ERROR([Backend $backend not found.])],[$4])
else
ifelse([$3],,[:],[$3])
fi
])

View File

@@ -1063,9 +1063,6 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
src/gtk/cursor.cpp
src/gtk/dataobj.cpp
src/gtk/dc.cpp
src/gtk/dcclient.cpp
src/gtk/dcmemory.cpp
src/gtk/dcscreen.cpp
src/gtk/dnd.cpp
src/gtk/evtloop.cpp
src/gtk/filectrl.cpp
@@ -1087,6 +1084,12 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
src/gtk/win_gtk.cpp
src/gtk/window.cpp
</set>
<set var="GTK2_LOWLEVEL_SRC" hints="files">
$(GTK_LOWLEVEL_SRC)
src/gtk/dcclient.cpp
src/gtk/dcmemory.cpp
src/gtk/dcscreen.cpp
</set>
<set var="GTK_LOWLEVEL_HDR" hints="files">
$(GTK_PLATFORM_HDR)
wx/generic/icon.h
@@ -1101,10 +1104,6 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
wx/gtk/dataform.h
wx/gtk/dataobj.h
wx/gtk/dataobj2.h
wx/gtk/dc.h
wx/gtk/dcclient.h
wx/gtk/dcmemory.h
wx/gtk/dcscreen.h
wx/gtk/dnd.h
wx/gtk/evtloop.h
wx/gtk/evtloopsrc.h
@@ -3119,14 +3118,20 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<set var="ADVANCED_GTK_SRC" hints="files">
$(ADVANCED_GTK_PLATFORM_SRC)
src/gtk/taskbar.cpp
</set>
<set var="ADVANCED_GTK2_SRC" hints="files">
$(ADVANCED_GTK_SRC)
src/gtk/eggtrayicon.c
src/gtk/hildon/notifmsg.cpp
</set>
<set var="ADVANCED_GTK_HDR" hints="files">
$(ADVANCED_GTK_PLATFORM_HDR)
wx/gtk/hildon/notifmsg.h
wx/gtk/taskbar.h
</set>
<set var="ADVANCED_GTK2_HDR" hints="files">
$(ADVANCED_GTK_HDR)
wx/gtk/hildon/notifmsg.h
</set>
<set var="ADVANCED_GTK_NATIVE_SRC" hints="files">
src/gtk/aboutdlg.cpp
@@ -3500,6 +3505,10 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<if cond="TOOLKIT=='OSX_COCOA'">src/osx/cocoa/glcanvas.mm src/osx/glcanvas_osx.cpp</if>
<if cond="TOOLKIT=='OSX_IPHONE'">src/osx/iphone/glcanvas.mm src/osx/glcanvas_osx.cpp</if>
<if cond="TOOLKIT=='COCOA'">src/cocoa/glcanvas.mm</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='3'">
src/unix/glx11.cpp
src/gtk/glcanvas.cpp
</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='2'">
src/gtk/glcanvas.cpp
src/unix/glx11.cpp
@@ -3524,6 +3533,10 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<if cond="TOOLKIT=='OSX_CARBON'">wx/osx/glcanvas.h</if>
<if cond="TOOLKIT=='OSX_COCOA'">wx/osx/glcanvas.h</if>
<if cond="TOOLKIT=='COCOA'">wx/cocoa/glcanvas.h</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='3'">
wx/gtk/glcanvas.h
wx/unix/glx11.h
</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='2'">
wx/gtk/glcanvas.h
wx/unix/glx11.h
@@ -3788,7 +3801,8 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<!-- GUI sources: -->
<set var="LOWLEVEL_SRC" hints="files">
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='2'">$(GTK_LOWLEVEL_SRC)</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='3'">$(GTK_LOWLEVEL_SRC)</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='2'">$(GTK2_LOWLEVEL_SRC)</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION==''">$(GTK1_LOWLEVEL_SRC)</if>
<if cond="TOOLKIT=='MOTIF'">$(MOTIF_LOWLEVEL_SRC)</if>
<if cond="TOOLKIT=='MSW'">$(MSW_LOWLEVEL_SRC) $(MSW_DESKTOP_LOWLEVEL_SRC)</if>
@@ -3802,6 +3816,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<if cond="TOOLKIT=='DFB'">$(DFB_LOWLEVEL_SRC)</if>
</set>
<set var="LOWLEVEL_HDR" hints="files">
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='3'">$(GTK_LOWLEVEL_HDR)</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='2'">$(GTK_LOWLEVEL_HDR)</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION==''">$(GTK1_LOWLEVEL_HDR)</if>
<if cond="TOOLKIT=='MOTIF'">$(MOTIF_LOWLEVEL_HDR)</if>
@@ -3822,6 +3837,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
</set>
<set var="GUI_SRC" hints="files">
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='3'">$(GTK_SRC)</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='2'">$(GTK_SRC)</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION==''">$(GTK1_SRC)</if>
<if cond="TOOLKIT=='MOTIF'">$(MOTIF_SRC)</if>
@@ -3834,6 +3850,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<if cond="TOOLKIT=='PM'">$(OS2_SRC)</if>
</set>
<set var="GUI_HDR" hints="files">
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='3'">$(GTK_HDR)</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='2'">$(GTK_HDR)</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION==''">$(GTK1_HDR)</if>
<if cond="TOOLKIT=='MOTIF'">$(MOTIF_HDR)</if>
@@ -3864,7 +3881,8 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<if cond="TOOLKIT=='OSX_IPHONE'">$(ADVANCED_OSX_IPHONE_SRC)</if>
<if cond="TOOLKIT=='COCOA'">$(ADVANCED_COCOA_SRC)</if>
<if cond="TOOLKIT=='MOTIF'">$(ADVANCED_UNIX_SRC) $(ADVANCED_MOTIF_SRC)</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='2'">$(ADVANCED_GTK_SRC)</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='3'">$(ADVANCED_GTK_SRC)</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='2'">$(ADVANCED_GTK2_SRC)</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION==''">$(ADVANCED_UNIX_SRC) $(ADVANCED_GTK1_SRC)</if>
<if cond="TOOLKIT=='X11'">$(ADVANCED_UNIX_SRC)</if>
<if cond="TOOLKIT=='PM'">$(ADVANCED_OS2_SRC)</if>
@@ -3877,7 +3895,8 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<if cond="TOOLKIT=='OSX_IPHONE'">$(ADVANCED_OSX_IPHONE_HDR)</if>
<if cond="TOOLKIT=='COCOA'">$(ADVANCED_COCOA_HDR)</if>
<if cond="TOOLKIT=='MOTIF'">$(ADVANCED_UNIX_HDR) $(ADVANCED_MOTIF_HDR)</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='2'">$(ADVANCED_GTK_HDR)</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='3'">$(ADVANCED_GTK_HDR)</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='2'">$(ADVANCED_GTK2_HDR)</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION==''">$(ADVANCED_UNIX_HDR) $(ADVANCED_GTK1_HDR)</if>
<if cond="TOOLKIT=='X11'">$(ADVANCED_UNIX_HDR)</if>
<if cond="TOOLKIT=='PM'">$(ADVANCED_OS2_HDR)</if>
@@ -3885,11 +3904,13 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
<!-- wxAdv files not used by wxUniv -->
<set var="ADVANCED_PLATFORM_NATIVE_SRC" hints="files">
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='3'">$(ADVANCED_GTK_NATIVE_SRC)</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='2'">$(ADVANCED_GTK_NATIVE_SRC)</if>
<if cond="TOOLKIT=='MSW'">$(ADVANCED_MSW_NATIVE_SRC)</if>
<if cond="TOOLKIT=='WINCE'">$(ADVANCED_MSW_NATIVE_SRC)</if>
</set>
<set var="ADVANCED_PLATFORM_NATIVE_HDR" hints="files">
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='3'">$(ADVANCED_GTK_NATIVE_HDR)</if>
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='2'">$(ADVANCED_GTK_NATIVE_HDR)</if>
<if cond="TOOLKIT=='MSW'">$(ADVANCED_MSW_NATIVE_HDR)</if>
<if cond="TOOLKIT=='WINCE'">$(ADVANCED_MSW_NATIVE_HDR)</if>

480
configure vendored
View File

@@ -714,6 +714,11 @@ COND_TOOLKIT_MAC
COND_TOOLKIT_GTK_USE_GUI_1
COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1_WXUNIV_0
COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_WXUNIV_0
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1_WXUNIV_0
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3
COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_WXUNIV_0
COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1_WXUNIV_0
COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1
COND_TOOLKIT_GTK_TOOLKIT_VERSION_2
@@ -744,6 +749,8 @@ COND_PLATFORM_WIN32_1
COND_PLATFORM_WIN32_0
COND_PLATFORM_UNIX_1_USE_PLUGINS_0
COND_PLATFORM_UNIX_1_USE_GUI_1
COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1
COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_3
COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1
COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_2
COND_PLATFORM_UNIX_1
@@ -1082,7 +1089,6 @@ with_directfb
with_microwin
with_x11
enable_nanox
enable_gtk2
enable_gpe
with_libpng
with_libjpeg
@@ -2034,7 +2040,6 @@ Optional Features:
--disable-all-features disable all optional features to build minimal library
--enable-universal use wxWidgets GUI controls instead of native ones
--enable-nanox use NanoX
--disable-gtk2 use GTK+ 1.2 instead of 2.0
--enable-gpe use GNOME PDA Environment features if possible
--enable-debug build library for debugging
--disable-debug_flag disable all debugging support
@@ -2293,7 +2298,7 @@ Optional Packages:
--without-subdirs don't generate makefiles for samples/demos/...
--with-flavour=NAME specify a name to identify this build
--with-themes=all|list use only the specified comma-separated list of wxUniversal themes
--with-gtk[=VERSION] use GTK+, VERSION can be 2 (default), 1 or "any"
--with-gtk[=VERSION] use GTK+, VERSION can be 3, 2 (default), 1 or "any"
--with-motif use Motif/Lesstif
--with-osx_carbon use Mac OS X (Carbon)
--with-osx_cocoa use Mac OS X (Cocoa)
@@ -3585,7 +3590,7 @@ $as_echo "$as_me: loading site script $ac_site_file" >&6;}
|| { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "failed to load site script $ac_site_file
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
fi
done
@@ -3728,7 +3733,7 @@ fi
$as_echo "$ac_cv_build" >&6; }
case $ac_cv_build in
*-*-*) ;;
*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;;
*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
esac
build=$ac_cv_build
ac_save_IFS=$IFS; IFS='-'
@@ -3761,7 +3766,7 @@ fi
$as_echo "$ac_cv_host" >&6; }
case $ac_cv_host in
*-*-*) ;;
*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;;
*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
esac
host=$ac_cv_host
ac_save_IFS=$IFS; IFS='-'
@@ -4122,8 +4127,6 @@ DEFAULT_wxUSE_MAC_ARCH=no
DEFAULT_wxUSE_OFFICIAL_BUILD=no
DEFAULT_wxUSE_GTK2=yes
DEFAULT_wxUSE_OBJC_UNIQUIFYING=no
@@ -4617,12 +4620,6 @@ fi
$as_echo "$result" >&6; }
# Check whether --enable-gtk2 was given.
if test "${enable_gtk2+set}" = set; then :
enableval=$enable_gtk2; wxUSE_GTK2="$enableval"
fi
enablestring=
defaultval=
if test -z "$defaultval"; then
@@ -4730,15 +4727,6 @@ if test "$wxUSE_GUI" = "yes"; then
as_fn_error $? "Please specify at most one toolkit" "$LINENO" 5
esac
# to be removed when --disable-gtk2 isn't needed
if test "x$wxUSE_GTK2" = "xyes"; then
wxGTK_VERSION=2
wxUSE_GTK1=0
elif test "x$wxUSE_GTK2" = "xno"; then
wxGTK_VERSION=1
wxUSE_GTK1=1
fi
for toolkit in $ALL_TOOLKITS; do
var=wxUSE_$toolkit
eval "value=\$${var}"
@@ -16493,7 +16481,7 @@ fi
test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "no acceptable C compiler found in \$PATH
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
# Provide some information about the compiler.
$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
@@ -16608,7 +16596,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "C compiler cannot create executables
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
@@ -16651,7 +16639,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot compute suffix of executables: cannot compile and link
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f conftest conftest$ac_cv_exeext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
@@ -16710,7 +16698,7 @@ $as_echo "$ac_try_echo"; } >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot run C compiled programs.
If you meant to cross compile, use \`--host'.
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
fi
fi
fi
@@ -16762,7 +16750,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot compute suffix of object files: cannot compile
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f conftest.$ac_cv_objext conftest.$ac_ext
fi
@@ -17187,7 +17175,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot figure out if compiler needs -ext o: cannot compile
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f conftest.$ac_ext.o conftest.$ac_objext conftest.$ac_ext
@@ -17871,7 +17859,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
fi
ac_ext=c
@@ -18517,7 +18505,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot figure out if compiler needs -ext o: cannot compile
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f conftest.$ac_ext.o conftest.$ac_objext conftest.$ac_ext
@@ -19237,7 +19225,7 @@ $as_echo_n "checking for SDK directory $wxUSE_MACOSX_SDK... " >&6; }
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "not found
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: exists" >&5
$as_echo "exists" >&6; }
@@ -19416,7 +19404,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "no. Try a different SDK
See \`config.log' for more details" "$LINENO" 5 ; }; exit 1
See \`config.log' for more details" "$LINENO" 5; }; exit 1
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
@@ -19453,7 +19441,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "no. Try a different SDK
See \`config.log' for more details" "$LINENO" 5 ; }; exit 1
See \`config.log' for more details" "$LINENO" 5; }; exit 1
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
@@ -19570,7 +19558,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "no. CoreFoundation not available.
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
@@ -20191,7 +20179,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (short)
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_short=0
fi
@@ -20224,7 +20212,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (void *)
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_void_p=0
fi
@@ -20257,7 +20245,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (int)
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_int=0
fi
@@ -20290,7 +20278,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (long)
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_long=0
fi
@@ -20323,7 +20311,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (size_t)
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_size_t=0
fi
@@ -20359,7 +20347,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (long long)
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_long_long=0
fi
@@ -20394,7 +20382,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (long long)
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_long_long=0
fi
@@ -20432,7 +20420,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (long long)
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_long_long=0
fi
@@ -20484,7 +20472,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (wchar_t)
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_wchar_t=0
fi
@@ -21773,7 +21761,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
fi
ac_ext=cpp
@@ -22703,7 +22691,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (boolean)
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_boolean=0
fi
@@ -23063,8 +23051,10 @@ if test "$wxUSE_GUI" = "yes"; then
GUI_TK_LIBRARY=
WXGTK1=
WXGTK127=
WXGTK2=
WXGTK3=
WXGPE=
if test "$wxUSE_OLD_COCOA" = 1 ; then
@@ -23113,6 +23103,10 @@ $as_echo "" >&6; }
GTK_MODULES=gthread
fi
if test -z "$wxGTK_VERSION"; then
wxGTK_VERSION=any
fi
wx_cv_lib_gtk=
if test "x$wxGTK_VERSION" != "x1"
then
@@ -23123,7 +23117,8 @@ $as_echo "" >&6; }
fi
esac
# Check whether --enable-gtktest was given.
if test "$wxGTK_VERSION" != 3; then
# Check whether --enable-gtktest was given.
if test "${enable_gtktest+set}" = set; then :
enableval=$enable_gtktest;
else
@@ -23382,6 +23377,270 @@ rm -f core conftest.err conftest.$ac_objext \
rm -f conf.gtktest
fi
if test -z "$wx_cv_lib_gtk"; then
if test "$wxGTK_VERSION" = 3 -o "$wxGTK_VERSION" = any; then
# Check whether --enable-gtktest was given.
if test "${enable_gtktest+set}" = set; then :
enableval=$enable_gtktest;
else
enable_gtktest=yes
fi
pkg_config_args=gtk+-3.0
for module in . $GTK_MODULES
do
case "$module" in
gthread)
pkg_config_args="$pkg_config_args gthread-2.0"
;;
esac
done
no_gtk=""
# Extract the first word of "pkg-config", so it can be a program name with args.
set dummy pkg-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
$as_echo_n "(cached) " >&6
else
case $PKG_CONFIG in
[\\/]* | ?:[\\/]*)
ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
;;
esac
fi
PKG_CONFIG=$ac_cv_path_PKG_CONFIG
if test -n "$PKG_CONFIG"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
$as_echo "$PKG_CONFIG" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test x$PKG_CONFIG != xno ; then
if $PKG_CONFIG --atleast-pkgconfig-version 0.7 ; then
:
else
echo "*** pkg-config too old; version 0.7 or better required."
no_gtk=yes
PKG_CONFIG=no
fi
else
no_gtk=yes
fi
min_gtk_version=3.0.0
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GTK+ - version >= $min_gtk_version" >&5
$as_echo_n "checking for GTK+ - version >= $min_gtk_version... " >&6; }
if test x$PKG_CONFIG != xno ; then
## don't try to run the test against uninstalled libtool libs
if $PKG_CONFIG --uninstalled $pkg_config_args; then
echo "Will use uninstalled version of GTK+ found in PKG_CONFIG_PATH"
enable_gtktest=no
fi
if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args; then
:
else
no_gtk=yes
fi
fi
if test x"$no_gtk" = x ; then
GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'`
gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'`
gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'`
if test "x$enable_gtktest" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $GTK_CFLAGS"
LIBS="$GTK_LIBS $LIBS"
rm -f conf.gtktest
if test "$cross_compiling" = yes; then :
echo $ac_n "cross compiling; assumed OK... $ac_c"
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <gtk/gtk.h>
#include <stdio.h>
#include <stdlib.h>
int
main ()
{
int major, minor, micro;
char *tmp_version;
fclose (fopen ("conf.gtktest", "w"));
/* HP/UX 9 (%@#!) writes to sscanf strings */
tmp_version = g_strdup("$min_gtk_version");
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
printf("%s, bad version string\n", "$min_gtk_version");
exit(1);
}
if ((gtk_major_version != $gtk_config_major_version) ||
(gtk_minor_version != $gtk_config_minor_version) ||
(gtk_micro_version != $gtk_config_micro_version))
{
printf("\n*** 'pkg-config --modversion gtk+-3.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
$gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
gtk_major_version, gtk_minor_version, gtk_micro_version);
printf ("*** was found! If pkg-config was correct, then it is best\n");
printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
printf("*** required on your system.\n");
printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
printf("*** to point to the correct configuration files\n");
}
else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
(gtk_minor_version != GTK_MINOR_VERSION) ||
(gtk_micro_version != GTK_MICRO_VERSION))
{
printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
printf("*** library (version %d.%d.%d)\n",
gtk_major_version, gtk_minor_version, gtk_micro_version);
}
else
{
if ((gtk_major_version > major) ||
((gtk_major_version == major) && (gtk_minor_version > minor)) ||
((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
{
return 0;
}
else
{
printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
gtk_major_version, gtk_minor_version, gtk_micro_version);
printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
major, minor, micro);
printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
printf("***\n");
printf("*** If you have already installed a sufficiently new version, this error\n");
printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
printf("*** being found. The easiest way to fix this is to remove the old version\n");
printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n");
printf("*** correct copy of pkg-config. (In this case, you will have to\n");
printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
printf("*** so that the correct libraries are found at run-time))\n");
}
}
return 1;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
else
no_gtk=yes
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
if test "x$no_gtk" = x ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version)" >&5
$as_echo "yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version)" >&6; }
wx_cv_lib_gtk=3
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
if test "$PKG_CONFIG" = "no" ; then
echo "*** A new enough version of pkg-config was not found."
echo "*** See http://pkgconfig.sourceforge.net"
else
if test -f conf.gtktest ; then
:
else
echo "*** Could not run GTK+ test program, checking why..."
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $GTK_CFLAGS"
LIBS="$LIBS $GTK_LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <gtk/gtk.h>
#include <stdio.h>
int
main ()
{
return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version));
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
echo "*** The test program compiled, but did not run. This usually means"
echo "*** that the run-time linker is not finding GTK+ or finding the wrong"
echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your"
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
echo "*** to the installed location Also, make sure you have run ldconfig if that"
echo "*** is required on your system"
echo "***"
echo "*** If you have an old version installed, it is best to remove it, although"
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
else
echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means GTK+ is incorrectly installed."
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
GTK_CFLAGS=""
GTK_LIBS=""
:
fi
rm -f conf.gtktest
fi
fi
fi
if test -z "$wx_cv_lib_gtk"; then
@@ -23951,12 +24210,16 @@ $as_echo "$wx_cv_lib_gtk" >&6; }
fi
case "$wx_cv_lib_gtk" in
3) WXGTK3=1
TOOLKIT_VERSION=3
;;
2.0) WXGTK2=1
TOOLKIT_VERSION=2
;;
1.2.7) WXGTK127=1
WXGTK1=1
;;
1.2*) ;;
1.2*) WXGTK1=1 ;;
*) as_fn_error $? "
The development files for GTK+ were not found. For GTK+ 2, please
ensure that pkg-config is in the path and that gtk+-2.0.pc is
@@ -23968,7 +24231,14 @@ libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
;;
esac
if test "$WXGTK2" = 1; then
if test "$WXGTK3" = 1; then
$as_echo "#define __WXGTK218__ 1" >>confdefs.h
$as_echo "#define __WXGTK210__ 1" >>confdefs.h
$as_echo "#define __WXGTK26__ 1" >>confdefs.h
elif test "$WXGTK2" = 1; then
save_CFLAGS="$CFLAGS"
save_LIBS="$LIBS"
CFLAGS="$wx_cv_cflags_gtk $CFLAGS"
@@ -24453,7 +24723,7 @@ if test "x$with_x" = xno; then
have_x=disabled
else
case $x_includes,$x_libraries in #(
*\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5 ;; #(
*\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #(
*,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then :
$as_echo_n "(cached) " >&6
else
@@ -26205,7 +26475,7 @@ fi
USE_XINERAMA=0
if test "$wxUSE_DISPLAY" = "yes"; then
if test "$wxUSE_MOTIF" = 1 -o "$wxUSE_X11" = 1 -o "$wxUSE_GTK1" = 1; then
if test "$wxUSE_MOTIF" = 1 -o "$wxUSE_X11" = 1 -o "$WXGTK1" = 1; then
ac_find_libraries=
@@ -27331,7 +27601,7 @@ if test "$wxUSE_OPENGL" = "yes" -o "$wxUSE_OPENGL" = "auto"; then
OPENGL_LIBS="-framework OpenGL -framework AGL"
elif test "$wxUSE_MSW" = 1; then
OPENGL_LIBS="-lopengl32 -lglu32"
elif test "$wxUSE_MOTIF" = 1 -o "$wxUSE_X11" = 1 -o "$wxUSE_GTK2" = 1 -o "$wxUSE_GTK" = 1; then
elif test "$wxUSE_MOTIF" = 1 -o "$wxUSE_X11" = 1 -o "$wxUSE_GTK" = 1; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL headers" >&5
$as_echo_n "checking for OpenGL headers... " >&6; }
@@ -29028,7 +29298,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "no
See \`config.log' for more details" "$LINENO" 5 ; }
See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
@@ -32532,6 +32802,13 @@ $as_echo "no" >&6; }
fi
fi
if test "$WXGTK3" = 1 ; then
cat >>confdefs.h <<_ACEOF
#define __WXGTK3__ 1
_ACEOF
WXGTK2=1
fi
if test "$WXGTK2" = 1 ; then
cat >>confdefs.h <<_ACEOF
#define __WXGTK20__ $WXGTK2
@@ -32572,10 +32849,10 @@ if test "$wxUSE_DEBUG_FLAG" = "no" ; then
WXCONFIG_CPPFLAGS="$WXCONFIG_CPPFLAGS -DwxDEBUG_LEVEL=0"
if test "$wxUSE_GTK" = 1 ; then
if test "x$wxGTK_VERSION" = "x1" ; then
CPPFLAGS="-DGTK_NO_CHECK_CASTS $CPPFLAGS"
else
if test "$WXGTK2" = 1 ; then
CPPFLAGS="$CPPFLAGS -DG_DISABLE_CAST_CHECKS"
else
CPPFLAGS="-DGTK_NO_CHECK_CASTS $CPPFLAGS"
fi
fi
fi
@@ -33479,7 +33756,11 @@ fi
if test "$wxUSE_PRINTING_ARCHITECTURE" = "yes" ; then
if test "$wxUSE_GTKPRINT" = "yes" ; then
if test "$WXGTK3" = 1; then
gtk_unix_print="gtk+-unix-print-3.0"
else
gtk_unix_print="gtk+-unix-print-2.0 >= 2.10"
fi
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GTKPRINT" >&5
@@ -33490,12 +33771,12 @@ if test -n "$PKG_CONFIG"; then
pkg_cv_GTKPRINT_CFLAGS="$GTKPRINT_CFLAGS"
else
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gtk+-unix-print-2.0 >= 2.10\""; } >&5
($PKG_CONFIG --exists --print-errors "gtk+-unix-print-2.0 >= 2.10") 2>&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$gtk_unix_print\""; } >&5
($PKG_CONFIG --exists --print-errors "$gtk_unix_print") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_GTKPRINT_CFLAGS=`$PKG_CONFIG --cflags "gtk+-unix-print-2.0 >= 2.10" 2>/dev/null`
pkg_cv_GTKPRINT_CFLAGS=`$PKG_CONFIG --cflags "$gtk_unix_print" 2>/dev/null`
else
pkg_failed=yes
fi
@@ -33508,12 +33789,12 @@ if test -n "$PKG_CONFIG"; then
pkg_cv_GTKPRINT_LIBS="$GTKPRINT_LIBS"
else
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gtk+-unix-print-2.0 >= 2.10\""; } >&5
($PKG_CONFIG --exists --print-errors "gtk+-unix-print-2.0 >= 2.10") 2>&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$gtk_unix_print\""; } >&5
($PKG_CONFIG --exists --print-errors "$gtk_unix_print") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_GTKPRINT_LIBS=`$PKG_CONFIG --libs "gtk+-unix-print-2.0 >= 2.10" 2>/dev/null`
pkg_cv_GTKPRINT_LIBS=`$PKG_CONFIG --libs "$gtk_unix_print" 2>/dev/null`
else
pkg_failed=yes
fi
@@ -33532,9 +33813,9 @@ else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
GTKPRINT_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "gtk+-unix-print-2.0 >= 2.10"`
GTKPRINT_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$gtk_unix_print"`
else
GTKPRINT_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "gtk+-unix-print-2.0 >= 2.10"`
GTKPRINT_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$gtk_unix_print"`
fi
# Put the nasty error message in config.log where it belongs
echo "$GTKPRINT_PKG_ERRORS" >&5
@@ -36024,6 +36305,10 @@ if test "$wxUSE_WEBVIEW" = "yes"; then
USE_WEBVIEW_WEBKIT=0
if test "$wxUSE_WEBVIEW_WEBKIT" = "yes"; then
if test "$wxUSE_GTK" = 1; then
webkitgtk=webkit-1.0
if test "$WXGTK3" = 1; then
webkitgtk=webkitgtk-3.0
fi
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for WEBKIT" >&5
@@ -36034,12 +36319,12 @@ if test -n "$PKG_CONFIG"; then
pkg_cv_WEBKIT_CFLAGS="$WEBKIT_CFLAGS"
else
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"webkit-1.0 >= 1.3.1\""; } >&5
($PKG_CONFIG --exists --print-errors "webkit-1.0 >= 1.3.1") 2>&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$webkitgtk >= 1.3.1\""; } >&5
($PKG_CONFIG --exists --print-errors "$webkitgtk >= 1.3.1") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_WEBKIT_CFLAGS=`$PKG_CONFIG --cflags "webkit-1.0 >= 1.3.1" 2>/dev/null`
pkg_cv_WEBKIT_CFLAGS=`$PKG_CONFIG --cflags "$webkitgtk >= 1.3.1" 2>/dev/null`
else
pkg_failed=yes
fi
@@ -36052,12 +36337,12 @@ if test -n "$PKG_CONFIG"; then
pkg_cv_WEBKIT_LIBS="$WEBKIT_LIBS"
else
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"webkit-1.0 >= 1.3.1\""; } >&5
($PKG_CONFIG --exists --print-errors "webkit-1.0 >= 1.3.1") 2>&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$webkitgtk >= 1.3.1\""; } >&5
($PKG_CONFIG --exists --print-errors "$webkitgtk >= 1.3.1") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_WEBKIT_LIBS=`$PKG_CONFIG --libs "webkit-1.0 >= 1.3.1" 2>/dev/null`
pkg_cv_WEBKIT_LIBS=`$PKG_CONFIG --libs "$webkitgtk >= 1.3.1" 2>/dev/null`
else
pkg_failed=yes
fi
@@ -36076,9 +36361,9 @@ else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
WEBKIT_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "webkit-1.0 >= 1.3.1"`
WEBKIT_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$webkitgtk >= 1.3.1"`
else
WEBKIT_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "webkit-1.0 >= 1.3.1"`
WEBKIT_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$webkitgtk >= 1.3.1"`
fi
# Put the nasty error message in config.log where it belongs
echo "$WEBKIT_PKG_ERRORS" >&5
@@ -37118,7 +37403,11 @@ case "$TOOLKIT" in
GTK)
TOOLKIT_DESC="GTK+"
if test "$WXGTK2" = 1; then
TOOLKIT_DESC="$TOOLKIT_DESC 2"
if test "$WXGTK3" = 1; then
TOOLKIT_DESC="$TOOLKIT_DESC 3"
else
TOOLKIT_DESC="$TOOLKIT_DESC 2"
fi
if test "$wxUSE_GTKPRINT" = "yes" ; then
TOOLKIT_EXTRA="$TOOLKIT_EXTRA GTK+ printing";
fi
@@ -39795,6 +40084,16 @@ EOF
COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1=""
fi
COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_3="#"
if test "x$PLATFORM_UNIX" = "x1" -a "x$TOOLKIT" = "xGTK" -a "x$TOOLKIT_VERSION" = "x3" ; then
COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_3=""
fi
COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1="#"
if test "x$PLATFORM_UNIX" = "x1" -a "x$TOOLKIT" = "xGTK" -a "x$TOOLKIT_VERSION" = "x3" -a "x$USE_GUI" = "x1" ; then
COND_PLATFORM_UNIX_1_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1=""
fi
COND_PLATFORM_UNIX_1_USE_GUI_1="#"
if test "x$PLATFORM_UNIX" = "x1" -a "x$USE_GUI" = "x1" ; then
COND_PLATFORM_UNIX_1_USE_GUI_1=""
@@ -39945,6 +40244,31 @@ EOF
COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_USE_GUI_1_WXUNIV_0=""
fi
COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_WXUNIV_0="#"
if test "x$TOOLKIT" = "xGTK" -a "x$TOOLKIT_VERSION" = "x2" -a "x$WXUNIV" = "x0" ; then
COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_WXUNIV_0=""
fi
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3="#"
if test "x$TOOLKIT" = "xGTK" -a "x$TOOLKIT_VERSION" = "x3" ; then
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3=""
fi
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1="#"
if test "x$TOOLKIT" = "xGTK" -a "x$TOOLKIT_VERSION" = "x3" -a "x$USE_GUI" = "x1" ; then
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1=""
fi
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1_WXUNIV_0="#"
if test "x$TOOLKIT" = "xGTK" -a "x$TOOLKIT_VERSION" = "x3" -a "x$USE_GUI" = "x1" -a "x$WXUNIV" = "x0" ; then
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_USE_GUI_1_WXUNIV_0=""
fi
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_WXUNIV_0="#"
if test "x$TOOLKIT" = "xGTK" -a "x$TOOLKIT_VERSION" = "x3" -a "x$WXUNIV" = "x0" ; then
COND_TOOLKIT_GTK_TOOLKIT_VERSION_3_WXUNIV_0=""
fi
COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1="#"
if test "x$TOOLKIT" = "xGTK" -a "x$TOOLKIT_VERSION" = "x" -a "x$USE_GUI" = "x1" ; then
COND_TOOLKIT_GTK_TOOLKIT_VERSION__USE_GUI_1=""
@@ -41509,7 +41833,7 @@ do
"wx-config") CONFIG_COMMANDS="$CONFIG_COMMANDS wx-config" ;;
"$mk") CONFIG_FILES="$CONFIG_FILES $mk" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
done
@@ -41825,7 +42149,7 @@ do
esac
case $ac_mode$ac_tag in
:[FHL]*:*);;
:L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;;
:L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
:[FH]-) ac_tag=-:-;;
:[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
esac
@@ -41853,7 +42177,7 @@ do
[\\/$]*) false;;
*) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
esac ||
as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;;
as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
esac
case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
as_fn_append ac_file_inputs " '$ac_f'"
@@ -41880,7 +42204,7 @@ $as_echo "$as_me: creating $ac_file" >&6;}
case $ac_tag in
*:-:* | *:-) cat >"$tmp/stdin" \
|| as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
|| as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
esac
;;
esac

View File

@@ -402,9 +402,6 @@ DEFAULT_wxUSE_MAC_ARCH=no
DEFAULT_wxUSE_OFFICIAL_BUILD=no
dnl Applicable only when --with-gtk was used:
DEFAULT_wxUSE_GTK2=yes
dnl Always default to no. Only special cases require this.
DEFAULT_wxUSE_OBJC_UNIQUIFYING=no
@@ -469,7 +466,7 @@ fi
dnl we use AC_ARG_WITH and not WX_ARG_WITH for the toolkit options as they
dnl shouldn't default to wxUSE_ALL_FEATURES
AC_ARG_WITH(gtk, [[ --with-gtk[=VERSION] use GTK+, VERSION can be 2 (default), 1 or "any"]], [wxUSE_GTK="$withval" CACHE_GTK=1 TOOLKIT_GIVEN=1])
AC_ARG_WITH(gtk, [[ --with-gtk[=VERSION] use GTK+, VERSION can be 3, 2 (default), 1 or "any"]], [wxUSE_GTK="$withval" CACHE_GTK=1 TOOLKIT_GIVEN=1])
AC_ARG_WITH(motif, [ --with-motif use Motif/Lesstif], [wxUSE_MOTIF="$withval" CACHE_MOTIF=1 TOOLKIT_GIVEN=1])
AC_ARG_WITH(osx_carbon, [ --with-osx_carbon use Mac OS X (Carbon)], [wxUSE_OSX_CARBON="$withval" CACHE_OSX_CARBON=1 TOOLKIT_GIVEN=1])
AC_ARG_WITH(osx_cocoa, [ --with-osx_cocoa use Mac OS X (Cocoa)], [wxUSE_OSX_COCOA="$withval" CACHE_OSX_COCOA=1 TOOLKIT_GIVEN=1])
@@ -487,8 +484,6 @@ AC_ARG_WITH(directfb, [ --with-directfb use DirectFB], [wxUSE_DFB=
AC_ARG_WITH(microwin, [ --with-microwin use MicroWindows], [wxUSE_MICROWIN="$withval" CACHE_MICROWIN=1 TOOLKIT_GIVEN=1])
AC_ARG_WITH(x11, [ --with-x11 use X11], [wxUSE_X11="$withval" wxUSE_UNIVERSAL="yes" CACHE_X11=1 TOOLKIT_GIVEN=1])
WX_ARG_ENABLE(nanox, [ --enable-nanox use NanoX], wxUSE_NANOX)
AC_ARG_ENABLE(gtk2, [ --disable-gtk2 use GTK+ 1.2 instead of 2.0], [wxUSE_GTK2="$enableval"])
WX_ARG_ENABLE(gpe, [ --enable-gpe use GNOME PDA Environment features if possible], wxUSE_GPE)
dnl check that no more than one toolkit is given and that if none are given that
@@ -560,15 +555,6 @@ if test "$wxUSE_GUI" = "yes"; then
AC_MSG_ERROR(Please specify at most one toolkit)
esac
# to be removed when --disable-gtk2 isn't needed
if test "x$wxUSE_GTK2" = "xyes"; then
wxGTK_VERSION=2
wxUSE_GTK1=0
elif test "x$wxUSE_GTK2" = "xno"; then
wxGTK_VERSION=1
wxUSE_GTK1=1
fi
for toolkit in $ALL_TOOLKITS; do
var=wxUSE_$toolkit
eval "value=\$${var}"
@@ -2881,8 +2867,10 @@ if test "$wxUSE_GUI" = "yes"; then
GUI_TK_LIBRARY=
WXGTK1=
WXGTK127=
WXGTK2=
WXGTK3=
WXGPE=
if test "$wxUSE_OLD_COCOA" = 1 ; then
@@ -2930,6 +2918,10 @@ if test "$wxUSE_GUI" = "yes"; then
GTK_MODULES=gthread
fi
if test -z "$wxGTK_VERSION"; then
wxGTK_VERSION=any
fi
dnl detect GTK2
wx_cv_lib_gtk=
if test "x$wxGTK_VERSION" != "x1"
@@ -2944,7 +2936,14 @@ if test "$wxUSE_GUI" = "yes"; then
fi
esac
AM_PATH_GTK_2_0(2.4.0, wx_cv_lib_gtk=2.0, , $GTK_MODULES)
if test "$wxGTK_VERSION" != 3; then
AM_PATH_GTK_2_0(2.4.0, wx_cv_lib_gtk=2.0, , $GTK_MODULES)
fi
if test -z "$wx_cv_lib_gtk"; then
if test "$wxGTK_VERSION" = 3 -o "$wxGTK_VERSION" = any; then
AM_PATH_GTK_3_0(, wx_cv_lib_gtk=3, , $GTK_MODULES)
fi
fi
fi
dnl detect GTK1.x
@@ -2980,12 +2979,16 @@ if test "$wxUSE_GUI" = "yes"; then
fi
case "$wx_cv_lib_gtk" in
3) WXGTK3=1
TOOLKIT_VERSION=3
;;
2.0) WXGTK2=1
TOOLKIT_VERSION=2
;;
1.2.7) WXGTK127=1
WXGTK1=1
;;
1.2*) ;;
1.2*) WXGTK1=1 ;;
*) AC_MSG_ERROR([
The development files for GTK+ were not found. For GTK+ 2, please
ensure that pkg-config is in the path and that gtk+-2.0.pc is
@@ -2997,7 +3000,11 @@ libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
;;
esac
if test "$WXGTK2" = 1; then
if test "$WXGTK3" = 1; then
AC_DEFINE(__WXGTK218__)
AC_DEFINE(__WXGTK210__)
AC_DEFINE(__WXGTK26__)
elif test "$WXGTK2" = 1; then
save_CFLAGS="$CFLAGS"
save_LIBS="$LIBS"
CFLAGS="$wx_cv_cflags_gtk $CFLAGS"
@@ -3635,7 +3642,7 @@ dnl ---------------------------------------------------------------------------
USE_XINERAMA=0
if test "$wxUSE_DISPLAY" = "yes"; then
dnl Xinerama is used for wxGTK1/wxX11/wxMotif only
if test "$wxUSE_MOTIF" = 1 -o "$wxUSE_X11" = 1 -o "$wxUSE_GTK1" = 1; then
if test "$wxUSE_MOTIF" = 1 -o "$wxUSE_X11" = 1 -o "$WXGTK1" = 1; then
WX_FIND_LIB(Xinerama, XineramaQueryScreens)
if test "$ac_find_libraries" != "" ; then
if test "$ac_find_libraries" != "std" ; then
@@ -3712,7 +3719,7 @@ if test "$wxUSE_OPENGL" = "yes" -o "$wxUSE_OPENGL" = "auto"; then
OPENGL_LIBS="-framework OpenGL -framework AGL"
elif test "$wxUSE_MSW" = 1; then
OPENGL_LIBS="-lopengl32 -lglu32"
elif test "$wxUSE_MOTIF" = 1 -o "$wxUSE_X11" = 1 -o "$wxUSE_GTK2" = 1 -o "$wxUSE_GTK" = 1; then
elif test "$wxUSE_MOTIF" = 1 -o "$wxUSE_X11" = 1 -o "$wxUSE_GTK" = 1; then
dnl adjust CPPFLAGS to include GL/gl.h location if necessary
dnl (/opt/graphics/OpenGL is for HP-UX systems, bug 925307)
@@ -5248,6 +5255,10 @@ else
fi
fi
if test "$WXGTK3" = 1 ; then
AC_DEFINE_UNQUOTED(__WXGTK3__, 1)
WXGTK2=1
fi
if test "$WXGTK2" = 1 ; then
AC_DEFINE_UNQUOTED(__WXGTK20__,$WXGTK2)
fi
@@ -5284,10 +5295,10 @@ if test "$wxUSE_DEBUG_FLAG" = "no" ; then
WXCONFIG_CPPFLAGS="$WXCONFIG_CPPFLAGS -DwxDEBUG_LEVEL=0"
if test "$wxUSE_GTK" = 1 ; then
if test "x$wxGTK_VERSION" = "x1" ; then
CPPFLAGS="-DGTK_NO_CHECK_CASTS $CPPFLAGS"
else
if test "$WXGTK2" = 1 ; then
CPPFLAGS="$CPPFLAGS -DG_DISABLE_CAST_CHECKS"
else
CPPFLAGS="-DGTK_NO_CHECK_CASTS $CPPFLAGS"
fi
fi
fi
@@ -5660,9 +5671,13 @@ if test "$WXGTK2" = 1; then
if test "$wxUSE_PRINTING_ARCHITECTURE" = "yes" ; then
if test "$wxUSE_GTKPRINT" = "yes" ; then
if test "$WXGTK3" = 1; then
gtk_unix_print="gtk+-unix-print-3.0"
else
gtk_unix_print="gtk+-unix-print-2.0 >= 2.10"
fi
PKG_CHECK_MODULES(GTKPRINT,
[gtk+-unix-print-2.0 >= 2.10],
[$gtk_unix_print],
[
CFLAGS="$GTKPRINT_CFLAGS $CFLAGS"
CXXFLAGS="$GTKPRINT_CFLAGS $CXXFLAGS"
@@ -7245,8 +7260,12 @@ if test "$wxUSE_WEBVIEW" = "yes"; then
USE_WEBVIEW_WEBKIT=0
if test "$wxUSE_WEBVIEW_WEBKIT" = "yes"; then
if test "$wxUSE_GTK" = 1; then
webkitgtk=webkit-1.0
if test "$WXGTK3" = 1; then
webkitgtk=webkitgtk-3.0
fi
PKG_CHECK_MODULES([WEBKIT],
[webkit-1.0 >= 1.3.1],
[$webkitgtk >= 1.3.1],
[
USE_WEBVIEW_WEBKIT=1
CPPFLAGS="$CPPFLAGS $WEBKIT_CFLAGS"
@@ -8016,7 +8035,11 @@ case "$TOOLKIT" in
GTK)
TOOLKIT_DESC="GTK+"
if test "$WXGTK2" = 1; then
TOOLKIT_DESC="$TOOLKIT_DESC 2"
if test "$WXGTK3" = 1; then
TOOLKIT_DESC="$TOOLKIT_DESC 3"
else
TOOLKIT_DESC="$TOOLKIT_DESC 2"
fi
if test "$wxUSE_GTKPRINT" = "yes" ; then
TOOLKIT_EXTRA="$TOOLKIT_EXTRA GTK+ printing";
fi

View File

@@ -568,6 +568,7 @@ All (GUI):
GTK:
- Added support for GTK+ 3 (John Chain and Paul Cornett)
- Implement support for wxBG_STYLE_TRANSPARENT (Armel Asselin).
- Fix wxNotebook best size calculation.
- Implement wxDirDialog::Create() and wxFileDialog::Create() (vinayakgarg).

View File

@@ -4,7 +4,7 @@
// Author: Benjamin I. Williams
// Modified by: Jens Lody (extracted from wx/aui/auibook.h)
// Created: 2012-03-21
// RCS-ID: $Id:$
// RCS-ID: $Id$
// Copyright: (C) Copyright 2006, Kirix Corporation, All Rights Reserved.
// Licence: wxWindows Library Licence, Version 3.1
///////////////////////////////////////////////////////////////////////////////
@@ -276,7 +276,7 @@ protected:
};
#ifndef __WXUNIVERSAL__
#if defined(__WXGTK20__)
#if defined(__WXGTK20__) && !defined(__WXGTK3__)
#define wxHAS_NATIVE_TABART
#include "wx/aui/tabartgtk.h"
#define wxAuiDefaultTabArt wxAuiGtkTabArt

View File

@@ -3193,14 +3193,14 @@ typedef struct _GdkDragContext GdkDragContext;
typedef unsigned long GdkAtom;
#endif
#if !defined(__WXGTK30__)
#if !defined(__WXGTK3__)
typedef struct _GdkColormap GdkColormap;
typedef struct _GdkFont GdkFont;
typedef struct _GdkGC GdkGC;
typedef struct _GdkRegion GdkRegion;
#endif
#if defined(__WXGTK30__)
#if defined(__WXGTK3__)
typedef struct _GdkWindow GdkWindow;
#elif defined(__WXGTK20__)
typedef struct _GdkDrawable GdkWindow;

View File

@@ -10,6 +10,10 @@
#ifndef _WX_GTK_BITMAP_H_
#define _WX_GTK_BITMAP_H_
#ifdef __WXGTK3__
typedef struct _cairo cairo_t;
typedef struct _cairo_surface cairo_surface_t;
#endif
typedef struct _GdkPixbuf GdkPixbuf;
class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
@@ -30,8 +34,13 @@ public:
virtual ~wxMask();
// implementation
#ifdef __WXGTK3__
wxMask(cairo_surface_t*);
cairo_surface_t* GetBitmap() const;
#else
wxMask(GdkPixmap*);
GdkPixmap* GetBitmap() const;
#endif
protected:
virtual void FreeData();
@@ -39,7 +48,11 @@ protected:
virtual bool InitFromMonoBitmap(const wxBitmap& bitmap);
private:
#ifdef __WXGTK3__
cairo_surface_t* m_bitmap;
#else
GdkPixmap* m_bitmap;
#endif
DECLARE_DYNAMIC_CLASS(wxMask)
};
@@ -65,8 +78,7 @@ public:
#endif
wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE );
#if wxUSE_IMAGE
wxBitmap( const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH )
{ (void)CreateFromImage(image, depth); }
wxBitmap(const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH);
#endif // wxUSE_IMAGE
wxBitmap(GdkPixbuf* pixbuf);
virtual ~wxBitmap();
@@ -88,6 +100,7 @@ public:
wxMask *GetMask() const;
void SetMask( wxMask *mask );
wxBitmap GetMaskBitmap() const;
wxBitmap GetSubBitmap( const wxRect& rect ) const;
@@ -110,9 +123,16 @@ public:
void SetWidth( int width );
void SetDepth( int depth );
#ifdef __WXGTK3__
GdkPixbuf* GetPixbufNoMask() const;
cairo_t* CairoCreate() const;
void Draw(cairo_t* cr, int x, int y, bool useMask = true, const wxColour* fg = NULL, const wxColour* bg = NULL) const;
void SetSourceSurface(cairo_t* cr, int x, int y, const wxColour* fg = NULL, const wxColour* bg = NULL) const;
#else
GdkPixmap *GetPixmap() const;
bool HasPixmap() const;
bool HasPixbuf() const;
#endif
GdkPixbuf *GetPixbuf() const;
// raw bitmap access support functions
@@ -122,14 +142,17 @@ public:
bool HasAlpha() const;
protected:
#ifndef __WXGTK3__
#if wxUSE_IMAGE
bool CreateFromImage(const wxImage& image, int depth);
#endif // wxUSE_IMAGE
#endif
virtual wxGDIRefData* CreateGDIRefData() const;
virtual wxGDIRefData* CloneGDIRefData(const wxGDIRefData* data) const;
private:
#ifndef __WXGTK3__
void SetPixmap(GdkPixmap* pixmap);
#if wxUSE_IMAGE
// to be called from CreateFromImage only!
@@ -147,6 +170,7 @@ public:
// removes other representations from memory, keeping only 'keep'
// (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
void PurgeOtherRepresentations(Representation keep);
#endif
DECLARE_DYNAMIC_CLASS(wxBitmap)
};

View File

@@ -81,3 +81,14 @@
#endif
#endif /* __WINDOWS__ */
#ifdef __WXGTK3__
#if !wxUSE_GRAPHICS_CONTEXT
#ifdef wxABORT_ON_CONFIG_ERROR
#error "GTK+ 3 support requires wxGraphicsContext"
#else
#undef wxUSE_GRAPHICS_CONTEXT
#define wxUSE_GRAPHICS_CONTEXT 1
#endif
#endif
#endif

View File

@@ -52,8 +52,8 @@ protected:
public: // used by the GTK callback only
void SetGdkColor(const GdkColor& gdkColor)
{ m_colour = wxColor(gdkColor); }
void GTKSetColour(const wxColour& colour)
{ m_colour = colour; }
wxWindow *m_topParent;

View File

@@ -10,6 +10,10 @@
#ifndef _WX_GTK_COLOUR_H_
#define _WX_GTK_COLOUR_H_
#ifdef __WXGTK3__
typedef struct _GdkRGBA GdkRGBA;
#endif
//-----------------------------------------------------------------------------
// wxColour
//-----------------------------------------------------------------------------
@@ -21,6 +25,9 @@ public:
// ------------
DEFINE_STD_WXCOLOUR_CONSTRUCTORS
wxColour(const GdkColor& gdkColor);
#ifdef __WXGTK3__
wxColour(const GdkRGBA& gdkRGBA);
#endif
virtual ~wxColour();
@@ -33,8 +40,12 @@ public:
unsigned char Alpha() const;
// Implementation part
#ifdef __WXGTK3__
operator const GdkRGBA*() const;
#else
void CalcPixel( GdkColormap *cmap );
int GetPixel() const;
#endif
const GdkColor *GetColor() const;
protected:
@@ -43,7 +54,6 @@ protected:
virtual bool FromString(const wxString& str);
private:
DECLARE_DYNAMIC_CLASS(wxColour)
};

View File

@@ -26,6 +26,7 @@ extern "C" {
class WXDLLIMPEXP_CORE wxControl : public wxControlBase
{
typedef wxControlBase base_type;
public:
wxControl();
wxControl(wxWindow *parent, wxWindowID id,
@@ -43,8 +44,10 @@ public:
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxControlNameStr);
virtual wxVisualAttributes GetDefaultAttributes() const;
#ifdef __WXGTK3__
virtual bool SetFont(const wxFont& font);
#endif
protected:
virtual wxSize DoGetBestSize() const;

View File

@@ -10,6 +10,105 @@
#ifndef _WX_GTKDC_H_
#define _WX_GTKDC_H_
#ifdef __WXGTK3__
#include "wx/dcgraph.h"
class wxGTKCairoDCImpl: public wxGCDCImpl
{
typedef wxGCDCImpl base_type;
public:
wxGTKCairoDCImpl(wxDC* owner);
wxGTKCairoDCImpl(wxDC* owner, wxWindow* window);
virtual void DoDrawBitmap(const wxBitmap& bitmap, int x, int y, bool useMask);
virtual void DoDrawIcon(const wxIcon& icon, int x, int y);
#if wxUSE_IMAGE
virtual bool DoFloodFill(int x, int y, const wxColour& col, wxFloodFillStyle style);
#endif
virtual wxBitmap DoGetAsBitmap(const wxRect* subrect) const;
virtual bool DoGetPixel(int x, int y, wxColour* col) const;
virtual void DoGetSize(int* width, int* height) const;
virtual bool DoStretchBlit(int xdest, int ydest, int dstWidth, int dstHeight, wxDC* source, int xsrc, int ysrc, int srcWidth, int srcHeight, wxRasterOperationMode rop, bool useMask, int xsrcMask, int ysrcMask);
virtual void* GetCairoContext() const;
protected:
int m_width, m_height;
wxDECLARE_NO_COPY_CLASS(wxGTKCairoDCImpl);
};
//-----------------------------------------------------------------------------
class wxWindowDCImpl: public wxGTKCairoDCImpl
{
typedef wxGTKCairoDCImpl base_type;
public:
wxWindowDCImpl(wxWindowDC* owner, wxWindow* window);
wxDECLARE_NO_COPY_CLASS(wxWindowDCImpl);
};
//-----------------------------------------------------------------------------
class wxClientDCImpl: public wxGTKCairoDCImpl
{
typedef wxGTKCairoDCImpl base_type;
public:
wxClientDCImpl(wxClientDC* owner, wxWindow* window);
wxDECLARE_NO_COPY_CLASS(wxClientDCImpl);
};
//-----------------------------------------------------------------------------
class wxPaintDCImpl: public wxGTKCairoDCImpl
{
typedef wxGTKCairoDCImpl base_type;
public:
wxPaintDCImpl(wxPaintDC* owner, wxWindow* window);
wxDECLARE_NO_COPY_CLASS(wxPaintDCImpl);
};
//-----------------------------------------------------------------------------
class wxScreenDCImpl: public wxGTKCairoDCImpl
{
typedef wxGTKCairoDCImpl base_type;
public:
wxScreenDCImpl(wxScreenDC* owner);
wxDECLARE_NO_COPY_CLASS(wxScreenDCImpl);
};
//-----------------------------------------------------------------------------
class wxMemoryDCImpl: public wxGTKCairoDCImpl
{
typedef wxGTKCairoDCImpl base_type;
public:
wxMemoryDCImpl(wxMemoryDC* owner);
wxMemoryDCImpl(wxMemoryDC* owner, wxBitmap& bitmap);
wxMemoryDCImpl(wxMemoryDC* owner, wxDC* dc);
virtual wxBitmap DoGetAsBitmap(const wxRect* subrect) const;
virtual void DoSelect(const wxBitmap& bitmap);
virtual const wxBitmap& GetSelectedBitmap() const;
virtual wxBitmap& GetSelectedBitmap();
private:
void Setup();
wxBitmap m_bitmap;
wxDECLARE_NO_COPY_CLASS(wxMemoryDCImpl);
};
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGTKCairoDC: public wxDC
{
typedef wxDC base_type;
public:
wxGTKCairoDC(cairo_t* cr);
wxDECLARE_NO_COPY_CLASS(wxGTKCairoDC);
};
#else
#include "wx/dc.h"
//-----------------------------------------------------------------------------
@@ -50,4 +149,5 @@ public:
#define wxHAS_WORKING_GTK_DC_BLIT
#endif
#endif
#endif // _WX_GTKDC_H_

View File

@@ -12,7 +12,12 @@
#ifndef _WX_GTK_DVRENDERERS_H_
#define _WX_GTK_DVRENDERERS_H_
typedef struct _GdkRectangle GdkRectangle;
#ifdef __WXGTK3__
typedef struct _cairo_rectangle_int cairo_rectangle_int_t;
typedef cairo_rectangle_int_t GdkRectangle;
#else
typedef struct _GdkRectangle GdkRectangle;
#endif
// ---------------------------------------------------------
// wxDataViewTextRenderer

View File

@@ -39,6 +39,7 @@ public:
const int *attribList = NULL,
const wxPalette& palette = wxNullPalette);
virtual bool SetBackgroundStyle(wxBackgroundStyle style);
// implement wxGLCanvasX11 methods
// --------------------------------
@@ -93,6 +94,9 @@ public:
void OnInternalIdle();
bool m_exposed;
#ifdef __WXGTK3__
cairo_t* m_cairoPaintContext;
#endif
#if WXWIN_COMPATIBILITY_2_8
wxGLContext *m_sharedContext;

View File

@@ -119,7 +119,7 @@ WXDLLIMPEXP_CORE GtkWidget *GetHeaderButtonWidgetLast();
WXDLLIMPEXP_CORE GtkWidget *GetHeaderButtonWidget();
WXDLLIMPEXP_CORE GtkWidget *GetNotebookWidget();
WXDLLIMPEXP_CORE GtkWidget *GetRadioButtonWidget();
WXDLLIMPEXP_CORE GtkWidget *GetSplitterWidget();
WXDLLIMPEXP_CORE GtkWidget *GetSplitterWidget(wxOrientation orient = wxHORIZONTAL);
WXDLLIMPEXP_CORE GtkWidget *GetTextEntryWidget();
WXDLLIMPEXP_CORE GtkWidget *GetTreeWidget();

View File

@@ -26,7 +26,7 @@
// functions even if GTK_CHECK_VERSION would indicate the function is
// already available in GTK+.
#if !GTK_CHECK_VERSION(3,0,0) && !(defined(GTK_DISABLE_DEPRECATED) || defined(GSEAL_ENABLE))
#ifndef __WXGTK3__
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 2.8
@@ -342,9 +342,60 @@ static inline GdkWindow* wx_gtk_entry_get_text_window(GtkEntry* entry)
}
#define gtk_entry_get_text_window wx_gtk_entry_get_text_window
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 2.22
static inline GdkWindow* wx_gtk_button_get_event_window(GtkButton* button)
{
return button->event_window;
}
#define gtk_button_get_event_window wx_gtk_button_get_event_window
static inline GdkDragAction wx_gdk_drag_context_get_actions(GdkDragContext* context)
{
return context->actions;
}
#define gdk_drag_context_get_actions wx_gdk_drag_context_get_actions
static inline GdkDragAction wx_gdk_drag_context_get_selected_action(GdkDragContext* context)
{
return context->action;
}
#define gdk_drag_context_get_selected_action wx_gdk_drag_context_get_selected_action
static inline GdkDragAction wx_gdk_drag_context_get_suggested_action(GdkDragContext* context)
{
return context->suggested_action;
}
#define gdk_drag_context_get_suggested_action wx_gdk_drag_context_get_suggested_action
static inline GList* wx_gdk_drag_context_list_targets(GdkDragContext* context)
{
return context->targets;
}
#define gdk_drag_context_list_targets wx_gdk_drag_context_list_targets
static inline gint wx_gdk_visual_get_depth(GdkVisual* visual)
{
return visual->depth;
}
#define gdk_visual_get_depth wx_gdk_visual_get_depth
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 2.24
static inline GdkDisplay* wx_gdk_window_get_display(GdkWindow* window)
{
return gdk_drawable_get_display(window);
}
#define gdk_window_get_display wx_gdk_window_get_display
static inline GdkScreen* wx_gdk_window_get_screen(GdkWindow* window)
{
return gdk_drawable_get_screen(window);
}
#define gdk_window_get_screen wx_gdk_window_get_screen
static inline gint wx_gdk_window_get_height(GdkWindow* window)
{
int h;
@@ -369,8 +420,20 @@ static inline void wx_gdk_cairo_set_source_window(cairo_t* cr, GdkWindow* window
#define gdk_cairo_set_source_window wx_gdk_cairo_set_source_window
#endif
#endif // !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
// ----------------------------------------------------------------------------
// the following were introduced in GTK+ 3.0
static inline void wx_gdk_window_get_geometry(GdkWindow* window, gint* x, gint* y, gint* width, gint* height)
{
gdk_window_get_geometry(window, x, y, width, height, NULL);
}
#define gdk_window_get_geometry wx_gdk_window_get_geometry
static inline GtkWidget* wx_gtk_tree_view_column_get_button(GtkTreeViewColumn* tree_column)
{
return tree_column->button;
}
#define gtk_tree_view_column_get_button wx_gtk_tree_view_column_get_button
#endif // !__WXGTK3__
#endif // _WX_GTK_PRIVATE_COMPAT_H_

View File

@@ -10,8 +10,6 @@
#ifndef _WX_GTK_PIZZA_H_
#define _WX_GTK_PIZZA_H_
#include <gtk/gtk.h>
#define WX_PIZZA(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, wxPizza::type(), wxPizza)
#define WX_IS_PIZZA(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, wxPizza::type())
@@ -26,14 +24,13 @@ struct WXDLLIMPEXP_CORE wxPizza
void move(GtkWidget* widget, int x, int y, int width, int height);
void put(GtkWidget* widget, int x, int y, int width, int height);
void scroll(int dx, int dy);
void get_border_widths(int& x, int& y);
void get_border(GtkBorder& border);
GtkFixed m_fixed;
GList* m_children;
int m_scroll_x;
int m_scroll_y;
int m_border_style;
bool m_is_scrollable;
int m_windowStyle;
};
#endif // _WX_GTK_PIZZA_H_

View File

@@ -10,6 +10,10 @@
#ifndef _WX_GTK_REGION_H_
#define _WX_GTK_REGION_H_
#ifdef __WXGTK3__
typedef struct _cairo_region cairo_region_t;
#endif
// ----------------------------------------------------------------------------
// wxRegion
// ----------------------------------------------------------------------------
@@ -56,12 +60,12 @@ public:
virtual void Clear();
virtual bool IsEmpty() const;
public:
// Init with GdkRegion, set ref count to 2 so that
// the C++ class will not destroy the region!
wxRegion( GdkRegion *region );
#ifdef __WXGTK3__
cairo_region_t* GetRegion() const;
#else
wxRegion(const GdkRegion* region);
GdkRegion *GetRegion() const;
#endif
protected:
virtual wxGDIRefData *CreateGDIRefData() const;

View File

@@ -1652,9 +1652,6 @@
#define __WXGTK26__
#define __WXGTK210__
#define __WXGTK218__
// Alternatively, all the above symbols could be commented and this one
// uncommented if using GTK+ 3.
//#define __WXGTK30__
//#define __WXGTK3__
#endif // _WX_SETUP_H_

View File

@@ -12,6 +12,13 @@
#include "wx/dynarray.h"
#ifdef __WXGTK3__
typedef struct _cairo cairo_t;
#define WXUNUSED_IN_GTK3(x)
#else
#define WXUNUSED_IN_GTK3(x) x
#endif
// helper structure that holds class that holds GtkIMContext object and
// some additional data needed for key events processing
struct wxGtkIMData;
@@ -140,12 +147,13 @@ public:
// Internal addition of child windows
void DoAddChild(wxWindowGTK *child);
// This methods sends wxPaintEvents to the window. It reads the
// update region, breaks it up into rects and sends an event
// for each rect. It is also responsible for background erase
// events and NC paint events. It is called from "draw" and
// "expose" handlers as well as from ::Update()
void GtkSendPaintEvents();
// This method sends wxPaintEvents to the window.
// It is also responsible for background erase events.
#ifdef __WXGTK3__
void GTKSendPaintEvents(cairo_t* cr);
#else
void GTKSendPaintEvents(const GdkRegion* region);
#endif
// The methods below are required because many native widgets
// are composed of several subwidgets and setting a style for
@@ -267,7 +275,6 @@ public:
wxGtkIMData *m_imData;
// indices for the arrays below
enum ScrollDir { ScrollDir_Horz, ScrollDir_Vert, ScrollDir_Max };
@@ -359,20 +366,23 @@ protected:
// Copies m_children tab order to GTK focus chain:
void RealizeTabOrder();
#ifndef __WXGTK3__
// Called by ApplyWidgetStyle (which is called by SetFont() and
// SetXXXColour etc to apply style changed to native widgets) to create
// modified GTK style with non-standard attributes. If forceStyle=true,
// creates empty GtkRcStyle if there are no modifications, otherwise
// returns NULL in such case.
GtkRcStyle *GTKCreateWidgetStyle(bool forceStyle = false);
#endif
// Overridden in many GTK widgets who have to handle subwidgets
virtual void GTKApplyWidgetStyle(bool forceStyle = false);
void GTKApplyWidgetStyle(bool forceStyle = false);
// helper function to ease native widgets wrapping, called by
// ApplyWidgetStyle -- override this, not ApplyWidgetStyle
virtual void DoApplyWidgetStyle(GtkRcStyle *style);
void GTKApplyStyle(GtkWidget* widget, GtkRcStyle* style);
// sets the border of a given GtkScrolledWindow from a wx style
static void GTKScrolledWindowSetBorder(GtkWidget* w, int style);
@@ -395,6 +405,17 @@ private:
bool DoScrollByUnits(ScrollDir dir, ScrollUnit unit, int units);
virtual void AddChildGTK(wxWindowGTK* child);
#ifdef __WXGTK3__
// paint context is stashed here so wxPaintDC can use it
cairo_t* m_paintContext;
public:
cairo_t* GTKPaintContext() const
{
return m_paintContext;
}
#endif
DECLARE_DYNAMIC_CLASS(wxWindowGTK)
wxDECLARE_NO_COPY_CLASS(wxWindowGTK);
};

View File

@@ -39,9 +39,7 @@
typedef HWND wxNativeContainerWindowId;
typedef HWND wxNativeContainerWindowHandle;
#elif defined(__WXGTK__)
#include <gdk/gdk.h>
typedef GdkNativeWindow wxNativeContainerWindowId;
typedef unsigned long wxNativeContainerWindowId;
typedef GdkWindow *wxNativeContainerWindowHandle;
#else
// no support for using native windows under this platform yet

View File

@@ -68,6 +68,9 @@
/* Define this if your version of GTK+ is greater than 2.18 */
#undef __WXGTK218__
/* Define this if your version of GTK+ is >= 3.0 */
#undef __WXGTK3__
/* Define this if you want to use GPE features */
#undef __WXGPE__

View File

@@ -43,11 +43,14 @@
#ifdef __WXGTK__
#include <gtk/gtk.h>
#include "wx/renderer.h"
#if GTK_CHECK_VERSION(2,0,0)
#ifdef __WXGTK20__
#include "wx/gtk/private/gtk2-compat.h"
#else
#define gtk_widget_is_drawable GTK_WIDGET_DRAWABLE
#endif
#ifdef __WXGTK3__
#include "wx/graphics.h"
#endif
#endif
@@ -420,11 +423,17 @@ void wxAuiDefaultDockArt::DrawSash(wxDC& dc, wxWindow *window, int orientation,
gtk_paint_handle
(
gtk_widget_get_style(window->m_wxwindow),
#ifdef __WXGTK3__
static_cast<cairo_t*>(dc.GetGraphicsContext()->GetNativeContext()),
#else
window->GTKGetDrawingWindow(),
#endif
// flags & wxCONTROL_CURRENT ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL,
GTK_STATE_NORMAL,
GTK_SHADOW_NONE,
#ifndef __WXGTK3__
NULL /* no clipping */,
#endif
window->m_wxwindow,
"paned",
rect.x,

View File

@@ -44,7 +44,9 @@
#include "wx/msw/dcscreen.h"
#endif
#ifdef __WXGTK20__
#ifdef __WXGTK3__
#include "wx/gtk/dc.h"
#elif defined __WXGTK20__
#include "wx/gtk/dcclient.h"
#include "wx/gtk/dcmemory.h"
#include "wx/gtk/dcscreen.h"

View File

@@ -80,8 +80,10 @@ using namespace std;
#ifdef __WXGTK__
#include <gtk/gtk.h>
#include "wx/fontutil.h"
#ifndef __WXGTK3__
#include "wx/gtk/dc.h"
#endif
#endif
#ifdef __WXMAC__
#include "wx/osx/private.h"
@@ -367,7 +369,7 @@ public:
wxCairoContext( wxGraphicsRenderer* renderer, const wxMemoryDC& dc );
wxCairoContext( wxGraphicsRenderer* renderer, const wxPrinterDC& dc );
#ifdef __WXGTK__
wxCairoContext( wxGraphicsRenderer* renderer, GdkDrawable *drawable );
wxCairoContext( wxGraphicsRenderer* renderer, GdkWindow *window );
#endif
#ifdef __WXMSW__
wxCairoContext( wxGraphicsRenderer* renderer, HDC context );
@@ -1264,7 +1266,7 @@ wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitm
// image has alpha (or a mask represented as alpha) then we'll use a
// different format and iterator than if it doesn't...
cairo_format_t bufferFormat = bmp.GetDepth() == 32
#ifdef __WXGTK__
#if defined(__WXGTK__) && !defined(__WXGTK3__)
|| bmp.GetMask()
#endif
? CAIRO_FORMAT_ARGB32
@@ -1337,7 +1339,7 @@ wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitm
p.OffsetY(pixData, 1);
}
}
#ifdef __WXMSW__
#if defined(__WXMSW__) || defined(__WXGTK3__)
// if there is a mask, set the alpha bytes in the target buffer to
// fully transparent or fully opaque
if (bmpSource.GetMask())
@@ -1636,7 +1638,11 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxWindowDC&
Init( cairo_create(m_mswSurface) );
#endif
#ifdef __WXGTK20__
#ifdef __WXGTK3__
cairo_t* cr = static_cast<cairo_t*>(dc.GetImpl()->GetCairoContext());
if (cr)
Init(cr);
#elif defined __WXGTK20__
wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
Init( gdk_cairo_create( impldc->GetGDKWindow() ) );
@@ -1707,7 +1713,11 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxMemoryDC&
}
#endif
#ifdef __WXGTK20__
#ifdef __WXGTK3__
cairo_t* cr = static_cast<cairo_t*>(dc.GetImpl()->GetCairoContext());
if (cr)
Init(cr);
#elif defined __WXGTK20__
wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
Init( gdk_cairo_create( impldc->GetGDKWindow() ) );
@@ -1737,15 +1747,20 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxMemoryDC&
}
#ifdef __WXGTK20__
wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, GdkDrawable *drawable )
wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, GdkWindow *window )
: wxGraphicsContext(renderer)
{
Init( gdk_cairo_create( drawable ) );
Init( gdk_cairo_create( window ) );
#ifdef __WXGTK3__
m_width = gdk_window_get_width(window);
m_height = gdk_window_get_height(window);
#else
int width, height;
gdk_drawable_get_size( drawable, &width, &height );
gdk_drawable_get_size(window, &width, &height);
m_width = width;
m_height = height;
#endif
}
#endif
@@ -2410,7 +2425,7 @@ wxGraphicsContext * wxCairoRenderer::CreateContextFromNativeWindow( void * windo
{
ENSURE_LOADED_OR_RETURN(NULL);
#ifdef __WXGTK__
return new wxCairoContext(this,(GdkDrawable*)window);
return new wxCairoContext(this, static_cast<GdkWindow*>(window));
#else
wxUnusedVar(window);
return NULL;

View File

@@ -30,6 +30,7 @@
#ifdef __WXGTK20__
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/gtk2-compat.h"
#endif
// we only have to do it here when we use wxStatusBarGeneric in addition to the
@@ -90,8 +91,10 @@ gboolean statusbar_query_tooltip(GtkWidget* WXUNUSED(widget),
BEGIN_EVENT_TABLE(wxStatusBarGeneric, wxWindow)
EVT_PAINT(wxStatusBarGeneric::OnPaint)
EVT_SIZE(wxStatusBarGeneric::OnSize)
#ifdef __WXGTK20__
EVT_LEFT_DOWN(wxStatusBarGeneric::OnLeftDown)
EVT_RIGHT_DOWN(wxStatusBarGeneric::OnRightDown)
#endif
EVT_SYS_COLOUR_CHANGED(wxStatusBarGeneric::OnSysColourChanged)
END_EVENT_TABLE()
@@ -132,7 +135,11 @@ bool wxStatusBarGeneric::Create(wxWindow *parent,
#if defined( __WXGTK20__ )
#if GTK_CHECK_VERSION(2,12,0)
if (HasFlag(wxSTB_SHOW_TIPS) && !gtk_check_version(2,12,0))
if (HasFlag(wxSTB_SHOW_TIPS)
#ifndef __WXGTK3__
&& gtk_check_version(2,12,0) == NULL
#endif
)
{
g_object_set(m_widget, "has-tooltip", TRUE, NULL);
g_signal_connect(m_widget, "query-tooltip",
@@ -427,6 +434,23 @@ void wxStatusBarGeneric::OnPaint(wxPaintEvent& WXUNUSED(event) )
if ( ShowsSizeGrip() )
{
const wxRect& rc = GetSizeGripRect();
#ifdef __WXGTK3__
GtkWidget* toplevel = gtk_widget_get_toplevel(m_widget);
if (toplevel && !gtk_window_get_has_resize_grip(GTK_WINDOW(toplevel)))
{
GtkStyleContext* sc = gtk_widget_get_style_context(toplevel);
gtk_style_context_save(sc);
gtk_style_context_add_class(sc, GTK_STYLE_CLASS_GRIP);
GtkJunctionSides sides = GTK_JUNCTION_CORNER_BOTTOMRIGHT;
if (GetLayoutDirection() == wxLayout_RightToLeft)
sides = GTK_JUNCTION_CORNER_BOTTOMLEFT;
gtk_style_context_set_junction_sides(sc, sides);
gtk_render_handle(sc,
static_cast<cairo_t*>(dc.GetImpl()->GetCairoContext()),
rc.x, rc.y, rc.width, rc.height);
gtk_style_context_restore(sc);
}
#else
GdkWindowEdge edge =
GetLayoutDirection() == wxLayout_RightToLeft ? GDK_WINDOW_EDGE_SOUTH_WEST :
GDK_WINDOW_EDGE_SOUTH_EAST;
@@ -438,6 +462,7 @@ void wxStatusBarGeneric::OnPaint(wxPaintEvent& WXUNUSED(event) )
"statusbar",
edge,
rc.x, rc.y, rc.width, rc.height );
#endif
}
#endif // __WXGTK20__
@@ -460,19 +485,20 @@ void wxStatusBarGeneric::OnSysColourChanged(wxSysColourChangedEvent& event)
wxWindow::OnSysColourChanged(event);
}
#ifdef __WXGTK20__
void wxStatusBarGeneric::OnLeftDown(wxMouseEvent& event)
{
#ifdef __WXGTK20__
int width, height;
GetClientSize(&width, &height);
if ( ShowsSizeGrip() && (event.GetX() > width-height) )
GtkWidget* ancestor = gtk_widget_get_toplevel(m_widget);
#ifdef __WXGTK3__
if (ancestor && gtk_window_get_has_resize_grip(GTK_WINDOW(ancestor)))
ancestor = NULL;
#endif
if (ancestor && ShowsSizeGrip() && event.GetX() > width - height)
{
GtkWidget *ancestor = gtk_widget_get_toplevel( m_widget );
if (!GTK_IS_WINDOW (ancestor))
return;
GdkWindow *source = GTKGetDrawingWindow();
int org_x = 0;
@@ -502,24 +528,21 @@ void wxStatusBarGeneric::OnLeftDown(wxMouseEvent& event)
{
event.Skip( true );
}
#else
event.Skip( true );
#endif
}
void wxStatusBarGeneric::OnRightDown(wxMouseEvent& event)
{
#ifdef __WXGTK20__
int width, height;
GetClientSize(&width, &height);
if ( ShowsSizeGrip() && (event.GetX() > width-height) )
GtkWidget* ancestor = gtk_widget_get_toplevel(m_widget);
#ifdef __WXGTK3__
if (ancestor && gtk_window_get_has_resize_grip(GTK_WINDOW(ancestor)))
ancestor = NULL;
#endif
if (ancestor && ShowsSizeGrip() && event.GetX() > width - height)
{
GtkWidget *ancestor = gtk_widget_get_toplevel( m_widget );
if (!GTK_IS_WINDOW (ancestor))
return;
GdkWindow *source = GTKGetDrawingWindow();
int org_x = 0;
@@ -536,10 +559,8 @@ void wxStatusBarGeneric::OnRightDown(wxMouseEvent& event)
{
event.Skip( true );
}
#else
event.Skip( true );
#endif
}
#endif // __WXGTK20__
void wxStatusBarGeneric::OnSize(wxSizeEvent& event)
{

View File

@@ -21,14 +21,19 @@
#if wxUSE_ABOUTDLG && defined(__WXGTK26__)
#include "wx/aboutdlg.h"
#ifndef WX_PRECOMP
#include "wx/utils.h" // for wxLaunchDefaultBrowser()
#endif //WX_PRECOMP
#include "wx/aboutdlg.h"
#ifndef __WXGTK3__
#include "wx/generic/aboutdlgg.h"
#endif
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/gtk2-compat.h"
// ----------------------------------------------------------------------------
// GtkArray: temporary array of GTK strings
@@ -101,25 +106,41 @@ private:
// GTK+ about dialog is modeless, keep track of it in this variable
static GtkAboutDialog *gs_aboutDialog = NULL;
extern "C" void
wxGtkAboutDialogOnClose(GtkAboutDialog *about)
extern "C" {
static void wxGtkAboutDialogOnClose(GtkAboutDialog *about)
{
gtk_widget_destroy(GTK_WIDGET(about));
if ( about == gs_aboutDialog )
gs_aboutDialog = NULL;
}
}
extern "C" void
wxGtkAboutDialogOnLink(GtkAboutDialog * WXUNUSED(about),
const gchar *link,
gpointer WXUNUSED(data))
#ifdef __WXGTK3__
extern "C" {
static gboolean activate_link(GtkAboutDialog*, const char* link, void* dontIgnore)
{
if (dontIgnore)
{
wxLaunchDefaultBrowser(wxGTK_CONV_BACK_SYS(link));
return true;
}
return false;
}
}
#else
extern "C" {
static void wxGtkAboutDialogOnLink(GtkAboutDialog*, const char* link, void*)
{
wxLaunchDefaultBrowser(wxGTK_CONV_BACK_SYS(link));
}
}
#endif
void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* WXUNUSED(parent))
{
#ifndef __WXGTK3__
if ( !gtk_check_version(2,6,0) )
#endif
{
// don't create another dialog if one is already present
if ( !gs_aboutDialog )
@@ -150,10 +171,14 @@ void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* WXUNUSED(parent))
if ( info.HasWebSite() )
{
#ifdef __WXGTK3__
g_signal_connect(dlg, "activate-link", G_CALLBACK(activate_link), dlg);
#else
// NB: must be called before gtk_about_dialog_set_website() as
// otherwise it has no effect (although GTK+ docs don't mention
// this...)
gtk_about_dialog_set_url_hook(wxGtkAboutDialogOnLink, NULL, NULL);
#endif
gtk_about_dialog_set_website(dlg, wxGTK_CONV_SYS(info.GetWebSiteURL()));
gtk_about_dialog_set_website_label
@@ -166,7 +191,11 @@ void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* WXUNUSED(parent))
{
gtk_about_dialog_set_website(dlg, NULL);
gtk_about_dialog_set_website_label(dlg, NULL);
#ifdef __WXGTK3__
g_signal_connect(dlg, "activate-link", G_CALLBACK(activate_link), NULL);
#else
gtk_about_dialog_set_url_hook(NULL, NULL, NULL);
#endif
}
if ( info.HasDevelopers() )
@@ -216,11 +245,12 @@ void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* WXUNUSED(parent))
G_CALLBACK(wxGtkAboutDialogOnClose), NULL);
gtk_window_present(GTK_WINDOW(dlg));
return;
}
// native about dialog not available, fall back to the generic one
wxGenericAboutBox(info);
#ifndef __WXGTK3__
else
// native about dialog not available, fall back to the generic one
wxGenericAboutBox(info);
#endif
}
#endif // wxUSE_ABOUTDLG && GTK+ 2.6+

View File

@@ -363,20 +363,8 @@ void wxAnimationCtrl::DisplayStaticImage()
if (m_bmpStaticReal.IsOk())
{
// show inactive bitmap
GdkBitmap *mask = NULL;
if (m_bmpStaticReal.GetMask())
mask = m_bmpStaticReal.GetMask()->GetBitmap();
if (m_bmpStaticReal.HasPixbuf())
{
gtk_image_set_from_pixbuf(GTK_IMAGE(m_widget),
gtk_image_set_from_pixbuf(GTK_IMAGE(m_widget),
m_bmpStaticReal.GetPixbuf());
}
else
{
gtk_image_set_from_pixmap(GTK_IMAGE(m_widget),
m_bmpStaticReal.GetPixmap(), mask);
}
}
else
{

View File

@@ -19,7 +19,8 @@
#include "wx/stockitem.h"
#include "wx/gtk/private.h"
#include <gtk/gtk.h>
#include "wx/gtk/private/gtk2-compat.h"
// ----------------------------------------------------------------------------
// GTK callbacks
@@ -87,7 +88,7 @@ bool wxAnyButton::Enable( bool enable )
GdkWindow *wxAnyButton::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{
return GTK_BUTTON(m_widget)->event_window;
return gtk_button_get_event_window(GTK_BUTTON(m_widget));
}
// static

View File

@@ -26,7 +26,6 @@
#include <gpe/init.h>
#endif
#include "wx/gtk/private.h"
#include "wx/apptrait.h"
#include "wx/fontmap.h"
@@ -38,9 +37,8 @@
#include <hildon/hildon.h>
#endif // wxUSE_LIBHILDON2
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// link GnomeVFS
@@ -231,6 +229,7 @@ bool wxApp::OnInitGui()
if ( !wxAppBase::OnInitGui() )
return false;
#ifndef __WXGTK3__
// if this is a wxGLApp (derived from wxApp), and we've already
// chosen a specific visual, then derive the GdkVisual from that
if ( GetXVisualInfo() )
@@ -268,6 +267,7 @@ bool wxApp::OnInitGui()
}
}
}
#endif
#if wxUSE_LIBHILDON || wxUSE_LIBHILDON2
if ( !GetHildonProgram() )

View File

@@ -21,6 +21,8 @@
#endif
#include "wx/artprov.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
// compatibility with older GTK+ versions:
@@ -303,6 +305,7 @@ wxIconBundle
wxGTK2ArtProvider::CreateIconBundle(const wxArtID& id,
const wxArtClient& WXUNUSED(client))
{
wxIconBundle bundle;
const wxString stockid = wxArtIDToStock(id);
// try to load the bundle as stock icon first
@@ -313,7 +316,7 @@ wxGTK2ArtProvider::CreateIconBundle(const wxArtID& id,
GtkIconSize *sizes;
gint n_sizes;
gtk_icon_set_get_sizes(iconset, &sizes, &n_sizes);
wxIconBundle bundle = DoCreateIconBundle
bundle = DoCreateIconBundle
(
stockid.utf8_str(),
sizes, sizes + n_sizes,
@@ -325,7 +328,9 @@ wxGTK2ArtProvider::CreateIconBundle(const wxArtID& id,
// otherwise try icon themes
#ifdef __WXGTK26__
#ifndef __WXGTK3__
if ( !gtk_check_version(2,6,0) )
#endif
{
gint *sizes = gtk_icon_theme_get_icon_sizes
(
@@ -333,24 +338,23 @@ wxGTK2ArtProvider::CreateIconBundle(const wxArtID& id,
stockid.utf8_str()
);
if ( !sizes )
return wxNullIconBundle;
return bundle;
gint *last = sizes;
while ( *last )
last++;
wxIconBundle bundle = DoCreateIconBundle
bundle = DoCreateIconBundle
(
stockid.utf8_str(),
sizes, last,
&CreateThemeIcon
);
g_free(sizes);
return bundle;
}
#endif // __WXGTK26__
return wxNullIconBundle;
return bundle;
}
// ----------------------------------------------------------------------------

View File

@@ -27,6 +27,7 @@
extern GtkWidget *wxGetRootWindow();
#ifndef __WXGTK3__
static void PixmapToPixbuf(GdkPixmap* pixmap, GdkPixbuf* pixbuf, int w, int h)
{
gdk_pixbuf_get_from_drawable(pixbuf, pixmap, NULL, 0, 0, 0, 0, w, h);
@@ -68,6 +69,7 @@ static void MaskToAlpha(GdkPixmap* mask, GdkPixbuf* pixbuf, int w, int h)
}
g_object_unref(mask_pixbuf);
}
#endif
//-----------------------------------------------------------------------------
// wxMask
@@ -82,6 +84,21 @@ wxMask::wxMask()
wxMask::wxMask(const wxMask& mask)
{
#ifdef __WXGTK3__
m_bitmap = NULL;
if (mask.m_bitmap)
{
const int w = cairo_image_surface_get_width(mask.m_bitmap);
const int h = cairo_image_surface_get_height(mask.m_bitmap);
m_bitmap = cairo_image_surface_create(CAIRO_FORMAT_A8, w, h);
const guchar* src = cairo_image_surface_get_data(mask.m_bitmap);
guchar* dst = cairo_image_surface_get_data(m_bitmap);
const int stride = cairo_image_surface_get_stride(m_bitmap);
wxASSERT(stride == cairo_image_surface_get_stride(mask.m_bitmap));
memcpy(dst, src, stride * h);
cairo_surface_mark_dirty(m_bitmap);
}
#else
if ( !mask.m_bitmap )
{
m_bitmap = NULL;
@@ -95,6 +112,7 @@ wxMask::wxMask(const wxMask& mask)
wxGtkObject<GdkGC> gc(gdk_gc_new(m_bitmap));
gdk_draw_drawable(m_bitmap, gc, mask.m_bitmap, 0, 0, 0, 0, -1, -1);
#endif
}
wxMask::wxMask( const wxBitmap& bitmap, const wxColour& colour )
@@ -117,7 +135,11 @@ wxMask::wxMask( const wxBitmap& bitmap )
InitFromMonoBitmap(bitmap);
}
#ifdef __WXGTK3__
wxMask::wxMask(cairo_surface_t* bitmap)
#else
wxMask::wxMask(GdkPixmap* bitmap)
#endif
{
m_bitmap = bitmap;
}
@@ -125,14 +147,24 @@ wxMask::wxMask(GdkPixmap* bitmap)
wxMask::~wxMask()
{
if (m_bitmap)
{
#ifdef __WXGTK3__
cairo_surface_destroy(m_bitmap);
#else
g_object_unref (m_bitmap);
#endif
}
}
void wxMask::FreeData()
{
if (m_bitmap)
{
#ifdef __WXGTK3__
cairo_surface_destroy(m_bitmap);
#else
g_object_unref (m_bitmap);
#endif
m_bitmap = NULL;
}
}
@@ -142,6 +174,29 @@ bool wxMask::InitFromColour(const wxBitmap& bitmap, const wxColour& colour)
const int w = bitmap.GetWidth();
const int h = bitmap.GetHeight();
#ifdef __WXGTK3__
m_bitmap = cairo_image_surface_create(CAIRO_FORMAT_A8, w, h);
GdkPixbuf* pixbuf = bitmap.GetPixbufNoMask();
const guchar* src = gdk_pixbuf_get_pixels(pixbuf);
guchar* dst = cairo_image_surface_get_data(m_bitmap);
const int stride_src = gdk_pixbuf_get_rowstride(pixbuf);
const int stride_dst = cairo_image_surface_get_stride(m_bitmap);
const int src_inc = gdk_pixbuf_get_n_channels(pixbuf);
const guchar r = colour.Red();
const guchar g = colour.Green();
const guchar b = colour.Blue();
for (int j = 0; j < h; j++, src += stride_src, dst += stride_dst)
{
const guchar* s = src;
for (int i = 0; i < w; i++, s += src_inc)
{
dst[i] = 0xff;
if (s[0] == r && s[1] == g && s[2] == b)
dst[i] = 0;
}
}
cairo_surface_mark_dirty(m_bitmap);
#else
// create mask as XBM format bitmap
// one bit per pixel, each row starts on a byte boundary
@@ -193,6 +248,7 @@ bool wxMask::InitFromColour(const wxBitmap& bitmap, const wxColour& colour)
}
m_bitmap = gdk_bitmap_create_from_data(wxGetRootWindow()->window, (char*)out, w, h);
delete[] out;
#endif
return true;
}
@@ -202,6 +258,9 @@ bool wxMask::InitFromMonoBitmap(const wxBitmap& bitmap)
wxCHECK_MSG( bitmap.GetDepth() == 1, false, wxT("Cannot create mask from colour bitmap") );
#ifdef __WXGTK3__
InitFromColour(bitmap, *wxBLACK);
#else
m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, bitmap.GetWidth(), bitmap.GetHeight(), 1 );
if (!m_bitmap) return false;
@@ -209,11 +268,16 @@ bool wxMask::InitFromMonoBitmap(const wxBitmap& bitmap)
wxGtkObject<GdkGC> gc(gdk_gc_new( m_bitmap ));
gdk_gc_set_function(gc, GDK_COPY_INVERT);
gdk_draw_drawable(m_bitmap, gc, bitmap.GetPixmap(), 0, 0, 0, 0, bitmap.GetWidth(), bitmap.GetHeight());
#endif
return true;
}
#ifdef __WXGTK3__
cairo_surface_t* wxMask::GetBitmap() const
#else
GdkPixmap* wxMask::GetBitmap() const
#endif
{
return m_bitmap;
}
@@ -230,15 +294,22 @@ public:
virtual bool IsOk() const;
#ifdef __WXGTK3__
GdkPixbuf* m_pixbufMask;
GdkPixbuf* m_pixbufNoMask;
cairo_surface_t* m_surface;
#else
GdkPixmap *m_pixmap;
GdkPixbuf *m_pixbuf;
#endif
wxMask *m_mask;
int m_width;
int m_height;
int m_bpp;
#ifndef __WXGTK3__
bool m_alphaRequested;
#endif
private:
// We don't provide a copy ctor as copying m_pixmap and m_pixbuf properly
// is expensive and we don't want to do it implicitly (and possibly
// accidentally). wxBitmap::CloneGDIRefData() which does need to do it does
@@ -248,23 +319,43 @@ private:
wxBitmapRefData::wxBitmapRefData(int width, int height, int depth)
{
#ifdef __WXGTK3__
m_pixbufMask = NULL;
m_pixbufNoMask = NULL;
m_surface = NULL;
#else
m_pixmap = NULL;
m_pixbuf = NULL;
#endif
m_mask = NULL;
m_width = width;
m_height = height;
m_bpp = depth;
#ifdef __WXGTK3__
if (m_bpp != 1 && m_bpp != 32)
m_bpp = 24;
#else
if (m_bpp < 0)
m_bpp = gdk_drawable_get_depth(wxGetRootWindow()->window);
m_alphaRequested = depth == 32;
#endif
}
wxBitmapRefData::~wxBitmapRefData()
{
#ifdef __WXGTK3__
if (m_pixbufMask)
g_object_unref(m_pixbufMask);
if (m_pixbufNoMask)
g_object_unref(m_pixbufNoMask);
if (m_surface)
cairo_surface_destroy(m_surface);
#else
if (m_pixmap)
g_object_unref (m_pixmap);
if (m_pixbuf)
g_object_unref (m_pixbuf);
#endif
delete m_mask;
}
@@ -291,7 +382,30 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
wxASSERT(depth == 1);
if (width > 0 && height > 0 && depth == 1)
{
SetPixmap(gdk_bitmap_create_from_data(wxGetRootWindow()->window, bits, width, height));
m_refData = new wxBitmapRefData(width, height, 1);
#ifdef __WXGTK3__
GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, width, height);
M_BMPDATA->m_pixbufNoMask = pixbuf;
const char* src = bits;
guchar* dst = gdk_pixbuf_get_pixels(pixbuf);
const int stride_src = (width + 7) / 8;
const int rowinc_dst = gdk_pixbuf_get_rowstride(pixbuf) - 3 * width;
for (int j = 0; j < width; j++, src += stride_src, dst += rowinc_dst)
{
for (int i = 0; i < height; i++)
{
guchar c = 0xff;
if (src[i >> 3] & (1 << (i & 7)))
c = 0;
*dst++ = c;
*dst++ = c;
*dst++ = c;
}
}
#else
M_BMPDATA->m_pixmap = gdk_bitmap_create_from_data(
wxGetRootWindow()->window, bits, width, height);
#endif
}
}
@@ -299,15 +413,33 @@ wxBitmap::wxBitmap(const char* const* bits)
{
wxCHECK2_MSG(bits != NULL, return, wxT("invalid bitmap data"));
GdkBitmap* mask = NULL;
SetPixmap(gdk_pixmap_create_from_xpm_d(wxGetRootWindow()->window, &mask, NULL, const_cast<char**>(bits)));
if (!M_BMPDATA)
return;
if (M_BMPDATA->m_pixmap != NULL && mask != NULL)
#if wxUSE_IMAGE
*this = wxBitmap(wxImage(bits));
#elif defined __WXGTK3__
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_xpm_data(const_cast<const char**>(bits));
if (pixbuf)
{
M_BMPDATA->m_mask = new wxMask(mask);
m_refData = new wxBitmapRefData(
gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf),
gdk_pixbuf_get_n_channels(pixbuf) * 8);
M_BMPDATA->m_pixbufNoMask = pixbuf;
wxASSERT(M_BMPDATA->m_bpp == 32 || !gdk_pixbuf_get_has_alpha(M_BMPDATA->m_pixbufNoMask));
}
#else
GdkBitmap* mask = NULL;
GdkPixmap* pixmap = gdk_pixmap_create_from_xpm_d(wxGetRootWindow()->window, &mask, NULL, const_cast<char**>(bits));
if (pixmap)
{
int width, height;
gdk_drawable_get_size(pixmap, &width, &height);
m_refData = new wxBitmapRefData(width, height, -1);
M_BMPDATA->m_pixmap = pixmap;
if (mask)
{
M_BMPDATA->m_mask = new wxMask(mask);
}
}
#endif
}
wxBitmap::wxBitmap(GdkPixbuf* pixbuf)
@@ -318,7 +450,11 @@ wxBitmap::wxBitmap(GdkPixbuf* pixbuf)
gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf),
gdk_pixbuf_get_n_channels(pixbuf) * 8);
m_refData = bmpData;
#ifdef __WXGTK3__
bmpData->m_pixbufNoMask = pixbuf;
#else
bmpData->m_pixbuf = pixbuf;
#endif
}
}
@@ -334,22 +470,110 @@ bool wxBitmap::Create( int width, int height, int depth )
return true;
}
#if wxUSE_IMAGE
bool wxBitmap::CreateFromImage(const wxImage& image, int depth)
#ifdef __WXGTK3__
static void CopyImageData(
guchar* dst, int dstChannels, int dstStride,
const guchar* src, int srcChannels, int srcStride,
int w, int h)
{
UnRef();
if (dstChannels == srcChannels)
{
if (dstStride == srcStride)
memcpy(dst, src, size_t(dstStride) * h);
else
{
const int stride = dstStride < srcStride ? dstStride : srcStride;
for (int j = 0; j < h; j++, src += srcStride, dst += dstStride)
memcpy(dst, src, stride);
}
}
else
{
for (int j = 0; j < h; j++, src += srcStride, dst += dstStride)
{
guchar* d = dst;
const guchar* s = src;
if (dstChannels == 4)
{
for (int i = 0; i < w; i++, d += 4, s += 3)
{
d[0] = s[0];
d[1] = s[1];
d[2] = s[2];
d[3] = 0xff;
}
}
else
{
for (int i = 0; i < w; i++, d += 3, s += 4)
{
d[0] = s[0];
d[1] = s[1];
d[2] = s[2];
}
}
}
}
}
#endif
wxCHECK_MSG( image.IsOk(), false, wxT("invalid image") );
#if wxUSE_IMAGE
#ifdef __WXGTK3__
wxBitmap::wxBitmap(const wxImage& image, int depth)
{
wxCHECK_RET(image.IsOk(), "invalid image");
if (image.GetWidth() <= 0 || image.GetHeight() <= 0)
return false;
const int w = image.GetWidth();
const int h = image.GetHeight();
const guchar* alpha = image.GetAlpha();
if (depth < 0)
depth = alpha ? 32 : 24;
else if (depth != 1 && depth != 32)
depth = 24;
wxBitmapRefData* bmpData = new wxBitmapRefData(w, h, depth);
m_refData = bmpData;
GdkPixbuf* pixbuf_dst = gdk_pixbuf_new(GDK_COLORSPACE_RGB, depth == 32, 8, w, h);
bmpData->m_pixbufNoMask = pixbuf_dst;
wxASSERT(bmpData->m_bpp == 32 || !gdk_pixbuf_get_has_alpha(bmpData->m_pixbufNoMask));
const guchar* src = image.GetData();
guchar* dst = gdk_pixbuf_get_pixels(pixbuf_dst);
const int dstStride = gdk_pixbuf_get_rowstride(pixbuf_dst);
CopyImageData(dst, gdk_pixbuf_get_n_channels(pixbuf_dst), dstStride, src, 3, 3 * w, w, h);
if (depth == 32 && alpha)
{
for (int j = 0; j < h; j++, dst += dstStride)
for (int i = 0; i < w; i++)
dst[i * 4 + 3] = *alpha++;
}
if (image.HasMask())
{
const guchar r = image.GetMaskRed();
const guchar g = image.GetMaskGreen();
const guchar b = image.GetMaskBlue();
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_A8, w, h);
const int stride = cairo_image_surface_get_stride(surface);
dst = cairo_image_surface_get_data(surface);
memset(dst, 0xff, stride * h);
for (int j = 0; j < h; j++, dst += stride)
for (int i = 0; i < w; i++, src += 3)
if (src[0] == r && src[1] == g && src[2] == b)
dst[i] = 0;
cairo_surface_mark_dirty(surface);
bmpData->m_mask = new wxMask(surface);
}
}
#else
wxBitmap::wxBitmap(const wxImage& image, int depth)
{
wxCHECK_RET(image.IsOk(), "invalid image");
if (depth == 32 || (depth == -1 && image.HasAlpha()))
return CreateFromImageAsPixbuf(image);
// otherwise create pixmap, if alpha is present it will be converted to mask
return CreateFromImageAsPixmap(image, depth);
CreateFromImageAsPixbuf(image);
else
// otherwise create pixmap, if alpha is present it will be converted to mask
CreateFromImageAsPixmap(image, depth);
}
bool wxBitmap::CreateFromImageAsPixmap(const wxImage& image, int depth)
@@ -464,9 +688,72 @@ bool wxBitmap::CreateFromImageAsPixbuf(const wxImage& image)
return true;
}
#endif
wxImage wxBitmap::ConvertToImage() const
{
#ifdef __WXGTK3__
wxImage image;
wxCHECK_MSG(IsOk(), image, "invalid bitmap");
wxBitmapRefData* bmpData = M_BMPDATA;
const int w = bmpData->m_width;
const int h = bmpData->m_height;
image.Create(w, h, false);
guchar* dst = image.GetData();
GdkPixbuf* pixbuf_src = NULL;
if (bmpData->m_pixbufNoMask)
pixbuf_src = bmpData->m_pixbufNoMask;
else if (bmpData->m_surface)
{
pixbuf_src = gdk_pixbuf_get_from_surface(bmpData->m_surface, 0, 0, w, h);
bmpData->m_pixbufNoMask = pixbuf_src;
wxASSERT(bmpData->m_bpp == 32 || !gdk_pixbuf_get_has_alpha(bmpData->m_pixbufNoMask));
}
if (pixbuf_src)
{
const guchar* src = gdk_pixbuf_get_pixels(pixbuf_src);
const int srcStride = gdk_pixbuf_get_rowstride(pixbuf_src);
const int srcChannels = gdk_pixbuf_get_n_channels(pixbuf_src);
CopyImageData(dst, 3, 3 * w, src, srcChannels, srcStride, w, h);
if (srcChannels == 4)
{
image.SetAlpha();
guchar* alpha = image.GetAlpha();
for (int j = 0; j < h; j++, src += srcStride)
{
const guchar* s = src;
for (int i = 0; i < w; i++, s += 4)
*alpha++ = s[3];
}
}
}
cairo_surface_t* maskSurf = NULL;
if (bmpData->m_mask)
maskSurf = bmpData->m_mask->GetBitmap();
if (maskSurf)
{
const guchar r = 1;
const guchar g = 2;
const guchar b = 3;
image.SetMaskColour(r, g, b);
wxASSERT(cairo_image_surface_get_format(maskSurf) == CAIRO_FORMAT_A8);
const int stride = cairo_image_surface_get_stride(maskSurf);
const guchar* src = cairo_image_surface_get_data(maskSurf);
for (int j = 0; j < h; j++, src += stride)
{
for (int i = 0; i < w; i++, dst += 3)
if (src[i] == 0)
{
dst[0] = r;
dst[1] = g;
dst[2] = b;
}
else if (dst[0] == r && dst[1] == g && dst[2] == b)
dst[2]--;
}
}
#else
wxCHECK_MSG( IsOk(), wxNullImage, wxT("invalid bitmap") );
const int w = GetWidth();
@@ -561,6 +848,7 @@ wxImage wxBitmap::ConvertToImage() const
}
g_object_unref(image_mask);
}
#endif
return image;
}
@@ -604,12 +892,77 @@ void wxBitmap::SetMask( wxMask *mask )
M_BMPDATA->m_mask = mask;
}
wxBitmap wxBitmap::GetMaskBitmap() const
{
wxBitmap bitmap;
wxBitmapRefData* bmpData = M_BMPDATA;
#ifdef __WXGTK3__
cairo_surface_t* mask = NULL;
if (bmpData && bmpData->m_mask)
mask = bmpData->m_mask->GetBitmap();
if (mask)
{
const int w = cairo_image_surface_get_width(mask);
const int h = cairo_image_surface_get_height(mask);
GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, w, h);
const guchar* src = cairo_image_surface_get_data(mask);
guchar* dst = gdk_pixbuf_get_pixels(pixbuf);
const int stride_src = cairo_image_surface_get_stride(mask);
const int stride_dst = gdk_pixbuf_get_rowstride(pixbuf);
for (int j = 0; j < h; j++, src += stride_src, dst += stride_dst)
{
guchar* d = dst;
for (int i = 0; i < w; i++, d += 3)
{
d[0] = src[i];
d[1] = src[i];
d[2] = src[i];
}
}
bitmap = wxBitmap(pixbuf);
}
#else
GdkPixmap* mask = NULL;
if (bmpData && bmpData->m_mask)
mask = bmpData->m_mask->GetBitmap();
if (mask)
{
int w, h;
gdk_drawable_get_size(mask, &w, &h);
GdkPixbuf* pixbuf = gdk_pixbuf_get_from_drawable(
NULL, mask, NULL, 0, 0, 0, 0, w, h);
bitmap = wxBitmap(pixbuf);
}
#endif
return bitmap;
}
bool wxBitmap::CopyFromIcon(const wxIcon& icon)
{
*this = icon;
return IsOk();
}
#ifdef __WXGTK3__
static cairo_surface_t* GetSubSurface(cairo_surface_t* surface, const wxRect& rect)
{
cairo_surface_flush(surface);
const cairo_format_t format = cairo_image_surface_get_format(surface);
int x = rect.x;
if (format != CAIRO_FORMAT_A8)
x *= 4;
cairo_surface_t* subSurface = cairo_image_surface_create(format, rect.width, rect.height);
const int srcStride = cairo_image_surface_get_stride(surface);
const int dstStride = cairo_image_surface_get_stride(subSurface);
const guchar* src = cairo_image_surface_get_data(surface) + rect.y * srcStride + x;
guchar* dst = cairo_image_surface_get_data(subSurface);
for (int j = 0; j < rect.height; j++, src += srcStride, dst += dstStride)
memcpy(dst, src, dstStride);
cairo_surface_mark_dirty(subSurface);
return subSurface;
}
#endif
wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
{
wxBitmap ret;
@@ -628,6 +981,25 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
wxBitmapRefData * const newRef = new wxBitmapRefData(w, h, bmpData->m_bpp);
ret.m_refData = newRef;
#ifdef __WXGTK3__
if (bmpData->m_pixbufNoMask)
{
GdkPixbuf* pixbuf = gdk_pixbuf_new_subpixbuf(bmpData->m_pixbufNoMask, rect.x, rect.y, w, h);
newRef->m_pixbufNoMask = gdk_pixbuf_copy(pixbuf);
wxASSERT(newRef->m_bpp == 32 || !gdk_pixbuf_get_has_alpha(newRef->m_pixbufNoMask));
g_object_unref(pixbuf);
}
else if (bmpData->m_surface)
newRef->m_surface = GetSubSurface(bmpData->m_surface, rect);
cairo_surface_t* maskSurf = NULL;
if (bmpData->m_mask)
maskSurf = bmpData->m_mask->GetBitmap();
if (maskSurf)
{
newRef->m_mask = new wxMask(GetSubSurface(maskSurf, rect));
}
#else
if (bmpData->m_pixbuf)
{
GdkPixbuf* pixbuf =
@@ -655,6 +1027,7 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
sub_mask, gc, mask, rect.x, rect.y, 0, 0, w, h);
g_object_unref(gc);
}
#endif
return ret;
}
@@ -728,6 +1101,7 @@ void wxBitmap::SetDepth( int depth )
M_BMPDATA->m_bpp = depth;
}
#ifndef __WXGTK3__
void wxBitmap::SetPixmap( GdkPixmap *pixmap )
{
UnRef();
@@ -782,12 +1156,185 @@ bool wxBitmap::HasPixmap() const
return M_BMPDATA->m_pixmap != NULL;
}
#endif
#ifdef __WXGTK3__
GdkPixbuf* wxBitmap::GetPixbufNoMask() const
{
wxCHECK_MSG(IsOk(), NULL, "invalid bitmap");
wxBitmapRefData* bmpData = M_BMPDATA;
GdkPixbuf* pixbuf = bmpData->m_pixbufNoMask;
if (pixbuf)
return pixbuf;
const int w = bmpData->m_width;
const int h = bmpData->m_height;
if (bmpData->m_surface)
pixbuf = gdk_pixbuf_get_from_surface(bmpData->m_surface, 0, 0, w, h);
else
pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, bmpData->m_bpp == 32, 8, w, h);
bmpData->m_pixbufNoMask = pixbuf;
wxASSERT(bmpData->m_bpp == 32 || !gdk_pixbuf_get_has_alpha(bmpData->m_pixbufNoMask));
return pixbuf;
}
// helper to set up a simulated depth 1 surface
static void SetSourceSurface1(const wxBitmapRefData* bmpData, cairo_t* cr, int x, int y, const wxColour* fg, const wxColour* bg)
{
GdkPixbuf* pixbuf = gdk_pixbuf_copy(bmpData->m_pixbufNoMask);
const int w = bmpData->m_width;
const int h = bmpData->m_height;
const int stride = gdk_pixbuf_get_rowstride(pixbuf);
const int channels = gdk_pixbuf_get_n_channels(pixbuf);
guchar* dst = gdk_pixbuf_get_pixels(pixbuf);
guchar fg_r = 0, fg_g = 0, fg_b = 0;
if (fg && fg->IsOk())
{
fg_r = fg->Red();
fg_g = fg->Green();
fg_b = fg->Blue();
}
guchar bg_r = 255, bg_g = 255, bg_b = 255;
if (bg && bg->IsOk())
{
bg_r = bg->Red();
bg_g = bg->Green();
bg_b = bg->Blue();
}
for (int j = 0; j < h; j++, dst += stride)
{
guchar* d = dst;
for (int i = 0; i < w; i++, d += channels)
if (d[0])
{
d[0] = bg_r;
d[1] = bg_g;
d[2] = bg_b;
}
else
{
d[0] = fg_r;
d[1] = fg_g;
d[2] = fg_b;
}
}
gdk_cairo_set_source_pixbuf(cr, pixbuf, x, y);
g_object_unref(pixbuf);
}
void wxBitmap::SetSourceSurface(cairo_t* cr, int x, int y, const wxColour* fg, const wxColour* bg) const
{
wxBitmapRefData* bmpData = M_BMPDATA;
if (bmpData->m_surface)
{
cairo_set_source_surface(cr, bmpData->m_surface, x, y);
return;
}
wxCHECK_RET(bmpData->m_pixbufNoMask, "no bitmap data");
if (bmpData->m_bpp == 1)
SetSourceSurface1(bmpData, cr, x, y, fg, bg);
else
{
gdk_cairo_set_source_pixbuf(cr, bmpData->m_pixbufNoMask, x, y);
cairo_pattern_get_surface(cairo_get_source(cr), &bmpData->m_surface);
cairo_surface_reference(bmpData->m_surface);
}
}
cairo_t* wxBitmap::CairoCreate() const
{
wxCHECK_MSG(IsOk(), NULL, "invalid bitmap");
wxBitmapRefData* bmpData = M_BMPDATA;
cairo_t* cr;
if (bmpData->m_surface)
cr = cairo_create(bmpData->m_surface);
else
{
GdkPixbuf* pixbuf = bmpData->m_pixbufNoMask;
const bool useAlpha = bmpData->m_bpp == 32 || (pixbuf && gdk_pixbuf_get_has_alpha(pixbuf));
bmpData->m_surface = cairo_image_surface_create(
useAlpha ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24,
bmpData->m_width, bmpData->m_height);
cr = cairo_create(bmpData->m_surface);
if (pixbuf)
{
gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
cairo_paint(cr);
cairo_set_source_rgb(cr, 0, 0, 0);
}
}
if (bmpData->m_pixbufNoMask)
{
g_object_unref(bmpData->m_pixbufNoMask);
bmpData->m_pixbufNoMask = NULL;
}
if (bmpData->m_pixbufMask)
{
g_object_unref(bmpData->m_pixbufMask);
bmpData->m_pixbufMask = NULL;
}
wxASSERT(cr && cairo_status(cr) == 0);
return cr;
}
void wxBitmap::Draw(cairo_t* cr, int x, int y, bool useMask, const wxColour* fg, const wxColour* bg) const
{
wxCHECK_RET(IsOk(), "invalid bitmap");
wxBitmapRefData* bmpData = M_BMPDATA;
SetSourceSurface(cr, x, y, fg, bg);
cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_NEAREST);
cairo_surface_t* mask = NULL;
if (useMask && bmpData->m_mask)
mask = bmpData->m_mask->GetBitmap();
if (mask)
cairo_mask_surface(cr, mask, x, y);
else
cairo_paint(cr);
}
#endif
GdkPixbuf *wxBitmap::GetPixbuf() const
{
wxCHECK_MSG( IsOk(), NULL, wxT("invalid bitmap") );
wxBitmapRefData* bmpData = M_BMPDATA;
#ifdef __WXGTK3__
if (bmpData->m_pixbufMask)
return bmpData->m_pixbufMask;
if (bmpData->m_pixbufNoMask == NULL)
GetPixbufNoMask();
cairo_surface_t* mask = NULL;
if (bmpData->m_mask)
mask = bmpData->m_mask->GetBitmap();
if (mask == NULL)
return bmpData->m_pixbufNoMask;
const int w = bmpData->m_width;
const int h = bmpData->m_height;
bmpData->m_pixbufMask = gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, w, h);
guchar* dst = gdk_pixbuf_get_pixels(bmpData->m_pixbufMask);
const int dstStride = gdk_pixbuf_get_rowstride(bmpData->m_pixbufMask);
CopyImageData(dst, 4, dstStride,
gdk_pixbuf_get_pixels(bmpData->m_pixbufNoMask),
gdk_pixbuf_get_n_channels(bmpData->m_pixbufNoMask),
gdk_pixbuf_get_rowstride(bmpData->m_pixbufNoMask),
w, h);
const guchar* src = cairo_image_surface_get_data(mask);
const int srcStride = cairo_image_surface_get_stride(mask);
for (int j = 0; j < h; j++, src += srcStride, dst += dstStride)
for (int i = 0; i < w; i++)
if (src[i] == 0)
dst[i * 4 + 3] = 0;
return bmpData->m_pixbufMask;
#else
if (bmpData->m_pixbuf)
return bmpData->m_pixbuf;
@@ -803,8 +1350,10 @@ GdkPixbuf *wxBitmap::GetPixbuf() const
if (mask)
MaskToAlpha(mask, bmpData->m_pixbuf, w, h);
return bmpData->m_pixbuf;
#endif
}
#ifndef __WXGTK3__
bool wxBitmap::HasPixbuf() const
{
wxCHECK_MSG( IsOk(), false, wxT("invalid bitmap") );
@@ -825,11 +1374,33 @@ void wxBitmap::PurgeOtherRepresentations(wxBitmap::Representation keep)
M_BMPDATA->m_pixmap = NULL;
}
}
#endif
#ifdef wxHAS_RAW_BITMAP
void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp)
{
void* bits = NULL;
#ifdef __WXGTK3__
GdkPixbuf* pixbuf = GetPixbufNoMask();
if ((bpp == 32) == (gdk_pixbuf_get_has_alpha(pixbuf) != 0))
{
bits = gdk_pixbuf_get_pixels(pixbuf);
wxBitmapRefData* bmpData = M_BMPDATA;
data.m_width = bmpData->m_width;
data.m_height = bmpData->m_height;
data.m_stride = gdk_pixbuf_get_rowstride(pixbuf);
if (bmpData->m_pixbufMask)
{
g_object_unref(bmpData->m_pixbufMask);
bmpData->m_pixbufMask = NULL;
}
if (bmpData->m_surface)
{
cairo_surface_destroy(bmpData->m_surface);
bmpData->m_surface = NULL;
}
}
#else
GdkPixbuf *pixbuf = GetPixbuf();
const bool hasAlpha = HasAlpha();
@@ -841,6 +1412,7 @@ void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp)
data.m_stride = gdk_pixbuf_get_rowstride( pixbuf );
bits = gdk_pixbuf_get_pixels(pixbuf);
}
#endif
return bits;
}
@@ -852,8 +1424,12 @@ void wxBitmap::UngetRawData(wxPixelDataBase& WXUNUSED(data))
bool wxBitmap::HasAlpha() const
{
const wxBitmapRefData* bmpData = M_BMPDATA;
#ifdef __WXGTK3__
return bmpData && bmpData->m_bpp == 32;
#else
return bmpData && (bmpData->m_alphaRequested ||
(bmpData->m_pixbuf && gdk_pixbuf_get_has_alpha(bmpData->m_pixbuf)));
#endif
}
wxGDIRefData* wxBitmap::CreateGDIRefData() const
@@ -867,6 +1443,25 @@ wxGDIRefData* wxBitmap::CloneGDIRefData(const wxGDIRefData* data) const
wxBitmapRefData * const newRef = new wxBitmapRefData(oldRef->m_width,
oldRef->m_height,
oldRef->m_bpp);
#ifdef __WXGTK3__
if (oldRef->m_pixbufNoMask)
newRef->m_pixbufNoMask = gdk_pixbuf_copy(oldRef->m_pixbufNoMask);
if (oldRef->m_surface)
{
const int w = oldRef->m_width;
const int h = oldRef->m_height;
cairo_surface_t* surface = cairo_image_surface_create(
cairo_image_surface_get_format(oldRef->m_surface), w, h);
newRef->m_surface = surface;
cairo_surface_flush(oldRef->m_surface);
const guchar* src = cairo_image_surface_get_data(oldRef->m_surface);
guchar* dst = cairo_image_surface_get_data(surface);
const int stride = cairo_image_surface_get_stride(surface);
wxASSERT(stride == cairo_image_surface_get_stride(oldRef->m_surface));
memcpy(dst, src, stride * h);
cairo_surface_mark_dirty(surface);
}
#else
if (oldRef->m_pixmap != NULL)
{
newRef->m_pixmap = gdk_pixmap_new(
@@ -881,6 +1476,7 @@ wxGDIRefData* wxBitmap::CloneGDIRefData(const wxGDIRefData* data) const
{
newRef->m_pixbuf = gdk_pixbuf_copy(oldRef->m_pixbuf);
}
#endif
if (oldRef->m_mask != NULL)
{
newRef->m_mask = new wxMask(*oldRef->m_mask);

View File

@@ -30,6 +30,7 @@
#include "wx/log.h"
#endif
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
// ============================================================================
@@ -121,7 +122,11 @@ void wxBitmapComboBox::GTKCreateComboBoxWidget()
}
else
{
#ifdef __WXGTK3__
m_widget = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(store));
#else
m_widget = gtk_combo_box_entry_new_with_model( GTK_TREE_MODEL(store), m_stringCellIndex );
#endif
m_entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(m_widget)));
gtk_editable_set_editable(GTK_EDITABLE(m_entry), true);
}

View File

@@ -18,7 +18,9 @@
#include "wx/stockitem.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/gtk2-compat.h"
#include "wx/gtk/private/list.h"
// ----------------------------------------------------------------------------
@@ -174,7 +176,12 @@ wxSize wxButtonBase::GetDefaultSize()
gtk_container_add(GTK_CONTAINER(box), btn);
gtk_container_add(GTK_CONTAINER(wnd), box);
GtkRequisition req;
#ifdef __WXGTK3__
gtk_widget_get_preferred_height(btn, NULL, &req.height);
gtk_widget_get_preferred_width_for_height(btn, req.height, NULL, &req.width);
#else
gtk_widget_size_request(btn, &req);
#endif
gint minwidth, minheight;
gtk_widget_style_get(box,
@@ -269,9 +276,9 @@ GtkLabel *wxButton::GTKGetLabel() const
void wxButton::DoApplyWidgetStyle(GtkRcStyle *style)
{
gtk_widget_modify_style(m_widget, style);
GTKApplyStyle(m_widget, style);
GtkWidget* child = gtk_bin_get_child(GTK_BIN(m_widget));
gtk_widget_modify_style(child, style);
GTKApplyStyle(child, style);
// for buttons with images, the path to the label is (at least in 2.12)
// GtkButton -> GtkAlignment -> GtkHBox -> GtkLabel
@@ -283,7 +290,7 @@ void wxButton::DoApplyWidgetStyle(GtkRcStyle *style)
wxGtkList list(gtk_container_get_children(GTK_CONTAINER(box)));
for (GList* item = list; item; item = item->next)
{
gtk_widget_modify_style(GTK_WIDGET(item->data), style);
GTKApplyStyle(GTK_WIDGET(item->data), style);
}
}
}

View File

@@ -15,6 +15,7 @@
#include "wx/checkbox.h"
#include <gtk/gtk.h>
#include "wx/gtk/private/gtk2-compat.h"
//-----------------------------------------------------------------------------
// data
@@ -224,13 +225,13 @@ bool wxCheckBox::Enable( bool enable )
void wxCheckBox::DoApplyWidgetStyle(GtkRcStyle *style)
{
gtk_widget_modify_style(m_widgetCheckbox, style);
gtk_widget_modify_style(m_widgetLabel, style);
GTKApplyStyle(m_widgetCheckbox, style);
GTKApplyStyle(m_widgetLabel, style);
}
GdkWindow *wxCheckBox::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{
return GTK_BUTTON(m_widgetCheckbox)->event_window;
return gtk_button_get_event_window(GTK_BUTTON(m_widgetCheckbox));
}
// static

View File

@@ -17,8 +17,9 @@
#include "wx/arrstr.h"
#endif
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/gtk2-compat.h"
// ----------------------------------------------------------------------------
// GTK callbacks
@@ -76,7 +77,11 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
m_strings = new wxGtkCollatedArrayString;
}
#ifdef __WXGTK3__
m_widget = gtk_combo_box_text_new();
#else
m_widget = gtk_combo_box_new_text();
#endif
g_object_ref(m_widget);
Append(n, choices);
@@ -117,7 +122,11 @@ void wxChoice::SendSelectionChangedEvent(wxEventType evt_type)
void wxChoice::GTKInsertComboBoxTextItem( unsigned int n, const wxString& text )
{
#ifdef __WXGTK3__
gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(m_widget), n, wxGTK_CONV(text));
#else
gtk_combo_box_insert_text( GTK_COMBO_BOX( m_widget ), n, wxGTK_CONV( text ) );
#endif
}
int wxChoice::DoInsertItems(const wxArrayStringsAdapter & items,
@@ -370,8 +379,8 @@ wxSize wxChoice::DoGetBestSize() const
void wxChoice::DoApplyWidgetStyle(GtkRcStyle *style)
{
gtk_widget_modify_style(m_widget, style);
gtk_widget_modify_style(gtk_bin_get_child(GTK_BIN(m_widget)), style);
GTKApplyStyle(m_widget, style);
GTKApplyStyle(gtk_bin_get_child(GTK_BIN(m_widget)), style);
}

View File

@@ -37,9 +37,14 @@ static void gtk_clrbutton_setcolor_callback(GtkColorButton *widget,
{
// update the m_colour member of the wxColourButton
wxASSERT(p);
#ifdef __WXGTK3__
GdkRGBA gdkColor;
gtk_color_button_get_rgba(widget, &gdkColor);
#else
GdkColor gdkColor;
gtk_color_button_get_color(widget, &gdkColor);
p->SetGdkColor(gdkColor);
#endif
p->GTKSetColour(gdkColor);
// fire the colour-changed event
wxColourPickerEvent event(p, p->GetId(), p->GetColour());
@@ -67,7 +72,11 @@ bool wxColourButton::Create( wxWindow *parent, wxWindowID id,
}
m_colour = col;
#ifdef __WXGTK3__
m_widget = gtk_color_button_new_with_rgba(m_colour);
#else
m_widget = gtk_color_button_new_with_color( m_colour.GetColor() );
#endif
g_object_ref(m_widget);
// GtkColourButton signals
@@ -89,7 +98,11 @@ wxColourButton::~wxColourButton()
void wxColourButton::UpdateColour()
{
#ifdef __WXGTK3__
gtk_color_button_set_rgba(GTK_COLOR_BUTTON(m_widget), m_colour);
#else
gtk_color_button_set_color(GTK_COLOR_BUTTON(m_widget), m_colour.GetColor());
#endif
}
#endif // wxUSE_COLOURPICKERCTRL

View File

@@ -24,7 +24,9 @@
#include "wx/sizer.h"
#include "wx/panel.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/gtk2-compat.h"
// the lines below duplicate the same definitions in collpaneg.cpp, if we have
// another implementation of this class we should extract them to a common file
@@ -220,10 +222,12 @@ wxSize wxCollapsiblePane::DoGetBestSize() const
wxASSERT_MSG( m_widget, wxT("DoGetBestSize called before creation") );
GtkRequisition req;
req.width = 2;
req.height = 2;
(* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request )
(m_widget, &req );
#ifdef __WXGTK3__
gtk_widget_get_preferred_width(m_widget, NULL, &req.width);
gtk_widget_get_preferred_height_for_width(m_widget, req.width, NULL, &req.height);
#else
GTK_WIDGET_GET_CLASS(m_widget)->size_request(m_widget, &req);
#endif
// notice that we do not cache our best size here as it changes
// all times the user expands/hide our pane

View File

@@ -24,7 +24,9 @@
#include "wx/intl.h"
#endif
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/gtk2-compat.h"
#if wxUSE_LIBHILDON
#include <hildon-widgets/hildon-color-selector.h>
@@ -104,10 +106,11 @@ int wxColourDialog::ShowModal()
void wxColourDialog::ColourDataToDialog()
{
#if wxUSE_LIBHILDON || wxUSE_LIBHILDON2
const GdkColor * const
col = m_data.GetColour().IsOk() ? m_data.GetColour().GetColor()
: NULL;
#endif
#if wxUSE_LIBHILDON
HildonColorSelector * const sel = HILDON_COLOR_SELECTOR(m_widget);
hildon_color_selector_set_color(sel, const_cast<GdkColor *>(col));
@@ -128,14 +131,21 @@ void wxColourDialog::ColourDataToDialog()
gtk_color_selection_dialog_get_color_selection(
GTK_COLOR_SELECTION_DIALOG(m_widget)));
if ( col )
gtk_color_selection_set_current_color(sel, col);
const wxColour& c = m_data.GetColour();
if (c.IsOk())
{
#ifdef __WXGTK3__
gtk_color_selection_set_current_rgba(sel, c);
#else
gtk_color_selection_set_current_color(sel, c.GetColor());
#endif
}
// setup the palette:
GdkColor colors[16];
GdkColor colors[wxColourData::NUM_CUSTOM];
gint n_colors = 0;
for (unsigned i = 0; i < 16; i++)
for (unsigned i = 0; i < WXSIZEOF(colors); i++)
{
wxColour c = m_data.GetCustomColour(i);
if (c.IsOk())
@@ -182,8 +192,13 @@ void wxColourDialog::DialogToColourData()
gtk_color_selection_dialog_get_color_selection(
GTK_COLOR_SELECTION_DIALOG(m_widget)));
#ifdef __WXGTK3__
GdkRGBA clr;
gtk_color_selection_get_current_rgba(sel, &clr);
#else
GdkColor clr;
gtk_color_selection_get_current_color(sel, &clr);
#endif
m_data.SetColour(clr);
// Extract custom palette:
@@ -196,7 +211,7 @@ void wxColourDialog::DialogToColourData()
gint n_colors;
if (gtk_color_selection_palette_from_string(pal, &colors, &n_colors))
{
for (int i = 0; i < wxMin(n_colors, 16); i++)
for (int i = 0; i < n_colors && i < wxColourData::NUM_CUSTOM; i++)
{
m_data.SetCustomColour(i, wxColour(colors[i]));
}

View File

@@ -12,9 +12,8 @@
#include "wx/colour.h"
#include "wx/gtk/private.h"
#include <gdk/gdk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// wxColour
@@ -23,6 +22,38 @@
class wxColourRefData : public wxGDIRefData
{
public:
#ifdef __WXGTK3__
wxColourRefData(const GdkRGBA& gdkRGBA)
: m_gdkRGBA(gdkRGBA)
{
m_gdkColor.red = guint16(gdkRGBA.red * 65535);
m_gdkColor.green = guint16(gdkRGBA.green * 65535);
m_gdkColor.blue = guint16(gdkRGBA.blue * 65535);
m_alpha = wxByte(gdkRGBA.alpha * 255 + 0.5);
}
wxColourRefData(const GdkColor& gdkColor)
: m_gdkColor(gdkColor)
{
m_gdkRGBA.red = gdkColor.red / 65535.0;
m_gdkRGBA.green = gdkColor.green / 65535.0;
m_gdkRGBA.blue = gdkColor.blue / 65535.0;
m_gdkRGBA.alpha = 1;
m_alpha = 255;
}
wxColourRefData(guchar red, guchar green, guchar blue, guchar alpha)
{
m_gdkRGBA.red = red / 255.0;
m_gdkRGBA.green = green / 255.0;
m_gdkRGBA.blue = blue / 255.0;
m_gdkRGBA.alpha = alpha / 255.0;
m_gdkColor.red = (guint16(red) << 8) + red;
m_gdkColor.green = (guint16(green) << 8) + green;
m_gdkColor.blue = (guint16(blue) << 8) + blue;
m_alpha = alpha;
}
GdkRGBA m_gdkRGBA;
GdkColor m_gdkColor;
#else
wxColourRefData(guint16 red, guint16 green, guint16 blue, wxByte alpha = 0xff)
{
m_color.red =
@@ -50,11 +81,13 @@ public:
guint16 m_red;
guint16 m_green;
guint16 m_blue;
#endif
wxByte m_alpha;
wxDECLARE_NO_COPY_CLASS(wxColourRefData);
};
#ifndef __WXGTK3__
void wxColourRefData::FreeColour()
{
if (m_colormap)
@@ -80,6 +113,7 @@ void wxColourRefData::AllocColour( GdkColormap *cmap )
}
}
}
#endif
//-----------------------------------------------------------------------------
@@ -88,10 +122,22 @@ void wxColourRefData::AllocColour( GdkColormap *cmap )
// GDK's values are in 0..65535 range, ours are in 0..255
#define SHIFT 8
#ifdef __WXGTK3__
wxColour::wxColour(const GdkRGBA& gdkRGBA)
{
m_refData = new wxColourRefData(gdkRGBA);
}
wxColour::wxColour(const GdkColor& gdkColor)
{
m_refData = new wxColourRefData(gdkColor);
}
#else
wxColour::wxColour(const GdkColor& gdkColor)
{
m_refData = new wxColourRefData(gdkColor.red, gdkColor.green, gdkColor.blue);
}
#endif
wxColour::~wxColour()
{
@@ -107,9 +153,15 @@ bool wxColour::operator == ( const wxColour& col ) const
wxColourRefData* refData = M_COLDATA;
wxColourRefData* that_refData = static_cast<wxColourRefData*>(col.m_refData);
#ifdef __WXGTK3__
return refData->m_gdkColor.red == that_refData->m_gdkColor.red &&
refData->m_gdkColor.green == that_refData->m_gdkColor.green &&
refData->m_gdkColor.blue == that_refData->m_gdkColor.blue &&
#else
return refData->m_red == that_refData->m_red &&
refData->m_green == that_refData->m_green &&
refData->m_blue == that_refData->m_blue &&
#endif
refData->m_alpha == that_refData->m_alpha;
}
@@ -118,32 +170,48 @@ void wxColour::InitRGBA(unsigned char red, unsigned char green, unsigned char bl
{
UnRef();
#ifdef __WXGTK3__
m_refData = new wxColourRefData(red, green, blue, alpha);
#else
m_refData = new wxColourRefData(
(guint16(red) << SHIFT) + red,
(guint16(green) << SHIFT) + green,
(guint16(blue) << SHIFT) + blue,
alpha);
#endif
}
unsigned char wxColour::Red() const
{
wxCHECK_MSG( IsOk(), 0, wxT("invalid colour") );
#ifdef __WXGTK3__
return wxByte(M_COLDATA->m_gdkColor.red >> 8);
#else
return wxByte(M_COLDATA->m_red >> SHIFT);
#endif
}
unsigned char wxColour::Green() const
{
wxCHECK_MSG( IsOk(), 0, wxT("invalid colour") );
#ifdef __WXGTK3__
return wxByte(M_COLDATA->m_gdkColor.green >> 8);
#else
return wxByte(M_COLDATA->m_green >> SHIFT);
#endif
}
unsigned char wxColour::Blue() const
{
wxCHECK_MSG( IsOk(), 0, wxT("invalid colour") );
#ifdef __WXGTK3__
return wxByte(M_COLDATA->m_gdkColor.blue >> 8);
#else
return wxByte(M_COLDATA->m_blue >> SHIFT);
#endif
}
unsigned char wxColour::Alpha() const
@@ -153,6 +221,7 @@ unsigned char wxColour::Alpha() const
return M_COLDATA->m_alpha;
}
#ifndef __WXGTK3__
void wxColour::CalcPixel( GdkColormap *cmap )
{
if (!IsOk()) return;
@@ -166,22 +235,46 @@ int wxColour::GetPixel() const
return M_COLDATA->m_color.pixel;
}
#endif
const GdkColor *wxColour::GetColor() const
{
wxCHECK_MSG( IsOk(), NULL, wxT("invalid colour") );
#ifdef __WXGTK3__
return &M_COLDATA->m_gdkColor;
#else
return &M_COLDATA->m_color;
#endif
}
#ifdef __WXGTK3__
wxColour::operator const GdkRGBA*() const
{
const GdkRGBA* c = NULL;
if (IsOk())
c = &M_COLDATA->m_gdkRGBA;
return c;
}
#endif
bool wxColour::FromString(const wxString& str)
{
#ifdef __WXGTK3__
GdkRGBA gdkRGBA;
if (gdk_rgba_parse(&gdkRGBA, wxGTK_CONV_SYS(str)))
{
*this = wxColour(gdkRGBA);
return true;
}
#else
GdkColor colGDK;
if ( gdk_color_parse( wxGTK_CONV_SYS( str ), &colGDK ) )
{
*this = wxColour(colGDK);
return true;
}
#endif
return wxColourBase::FromString(str);
}

View File

@@ -21,7 +21,9 @@
#include "wx/arrstr.h"
#endif
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/gtk2-compat.h"
// ----------------------------------------------------------------------------
// GTK callbacks
@@ -170,7 +172,9 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
g_signal_connect_after (m_widget, "changed",
G_CALLBACK (gtkcombobox_changed_callback), this);
#ifndef __WXGTK3__
if ( !gtk_check_version(2,10,0) )
#endif
{
g_signal_connect (m_widget, "notify::popup-shown",
G_CALLBACK (gtkcombobox_popupshown_callback), this);
@@ -183,7 +187,11 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
void wxComboBox::GTKCreateComboBoxWidget()
{
#ifdef __WXGTK3__
m_widget = gtk_combo_box_text_new_with_entry();
#else
m_widget = gtk_combo_box_entry_new_text();
#endif
g_object_ref(m_widget);
m_entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(m_widget)));
@@ -264,14 +272,23 @@ GtkWidget* wxComboBox::GetConnectWidget()
GdkWindow* wxComboBox::GTKGetWindow(wxArrayGdkWindows& /* windows */) const
{
#ifdef __WXGTK3__
// no access to internal GdkWindows
return NULL;
#else
return gtk_entry_get_text_window(GetEntry());
#endif
}
// static
wxVisualAttributes
wxComboBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
{
#ifdef __WXGTK3__
return GetDefaultAttributesFromGTKWidget(gtk_combo_box_new_with_entry, true);
#else
return GetDefaultAttributesFromGTKWidget(gtk_combo_box_entry_new, true);
#endif
}
void wxComboBox::SetValue(const wxString& value)

View File

@@ -20,10 +20,11 @@
#endif
#include "wx/fontutil.h"
#include "wx/gtk/private.h"
#include "wx/utils.h"
#include "wx/sysopt.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/mnemonics.h"
// ============================================================================
@@ -57,6 +58,21 @@ bool wxControl::Create( wxWindow *parent,
return ret;
}
#ifdef __WXGTK3__
bool wxControl::SetFont(const wxFont& font)
{
const bool changed = base_type::SetFont(font);
if (changed && !gtk_widget_get_realized(m_widget))
{
// GTK defers sending "style-updated" until widget is realized, but
// GetBestSize() won't compute correct result until the signal is sent,
// so we have to do it now
g_signal_emit_by_name(m_widget, "style-updated");
}
return changed;
}
#endif
wxSize wxControl::DoGetBestSize() const
{
// Do not return any arbitrary default value...
@@ -71,7 +87,20 @@ wxSize wxControl::DoGetBestSize() const
else
{
GtkRequisition req;
#ifdef __WXGTK3__
if (gtk_widget_get_request_mode(m_widget) != GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
{
gtk_widget_get_preferred_height(m_widget, NULL, &req.height);
gtk_widget_get_preferred_width_for_height(m_widget, req.height, NULL, &req.width);
}
else
{
gtk_widget_get_preferred_width(m_widget, NULL, &req.width);
gtk_widget_get_preferred_height_for_width(m_widget, req.width, NULL, &req.height);
}
#else
GTK_WIDGET_GET_CLASS(m_widget)->size_request(m_widget, &req);
#endif
best.Set(req.width, req.height);
}
CacheBestSize(best);
@@ -82,12 +111,14 @@ void wxControl::PostCreation(const wxSize& size)
{
wxWindow::PostCreation();
#ifndef __WXGTK3__
// NB: GetBestSize needs to know the style, otherwise it will assume
// default font and if the user uses a different font, determined
// best size will be different (typically, smaller) than the desired
// size. This call ensure that a style is available at the time
// GetBestSize is called.
gtk_widget_ensure_style(m_widget);
#endif
GTKApplyWidgetStyle();
SetInitialSize(size);
@@ -99,8 +130,9 @@ void wxControl::PostCreation(const wxSize& size)
// ----------------------------------------------------------------------------
// Fix sensitivity due to bug in GTK+ < 2.14
void wxControl::GTKFixSensitivity(bool onlyIfUnderMouse)
void wxControl::GTKFixSensitivity(bool WXUNUSED_IN_GTK3(onlyIfUnderMouse))
{
#ifndef __WXGTK3__
if (gtk_check_version(2,14,0)
#if wxUSE_SYSTEM_OPTIONS
&& (wxSystemOptions::GetOptionInt(wxT("gtk.control.disable-sensitivity-fix")) != 1)
@@ -115,6 +147,7 @@ void wxControl::GTKFixSensitivity(bool onlyIfUnderMouse)
Show();
}
}
#endif
}
// ----------------------------------------------------------------------------
@@ -168,8 +201,8 @@ void wxControl::GTKSetLabelForFrame(GtkFrame *w, const wxString& label)
void wxControl::GTKFrameApplyWidgetStyle(GtkFrame* w, GtkRcStyle* style)
{
gtk_widget_modify_style(GTK_WIDGET(w), style);
gtk_widget_modify_style(gtk_frame_get_label_widget (w), style);
GTKApplyStyle(GTK_WIDGET(w), style);
GTKApplyStyle(gtk_frame_get_label_widget(w), style);
}
void wxControl::GTKFrameSetMnemonicWidget(GtkFrame* w, GtkWidget* widget)
@@ -214,11 +247,29 @@ wxVisualAttributes wxControl::GetDefaultAttributes() const
// static
wxVisualAttributes
wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
bool useBase,
bool WXUNUSED_IN_GTK3(useBase),
int state)
{
GtkStyle* style;
wxVisualAttributes attr;
#ifdef __WXGTK3__
GtkStateFlags stateFlag = GTK_STATE_FLAG_NORMAL;
if (state)
{
wxASSERT(state == GTK_STATE_ACTIVE);
stateFlag = GTK_STATE_FLAG_ACTIVE;
}
GtkStyleContext* sc = gtk_widget_get_style_context(widget);
GdkRGBA c;
gtk_style_context_get_color(sc, stateFlag, &c);
attr.colFg = wxColour(c);
gtk_style_context_get_background_color(sc, stateFlag, &c);
attr.colBg = wxColour(c);
wxNativeFontInfo info;
info.description = const_cast<PangoFontDescription*>(gtk_style_context_get_font(sc, stateFlag));
attr.font = wxFont(info);
info.description = NULL;
#else
GtkStyle* style;
style = gtk_rc_get_style(widget);
if (!style)
@@ -246,7 +297,8 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
attr.font = wxFont(info);
info.description = NULL;
}
else
#endif
if (!attr.font.IsOk())
{
GtkSettings *settings = gtk_settings_get_default();
gchar *font_name = NULL;

View File

@@ -99,29 +99,68 @@ wxCursor::wxCursor(const char bits[], int width, int height,
int hotSpotX, int hotSpotY,
const char maskBits[], const wxColour *fg, const wxColour *bg)
{
m_refData = new wxCursorRefData;
if (hotSpotX < 0 || hotSpotX >= width)
hotSpotX = 0;
if (hotSpotY < 0 || hotSpotY >= height)
hotSpotY = 0;
#ifdef __WXGTK3__
wxBitmap bitmap(bits, width, height);
if (maskBits)
bitmap.SetMask(new wxMask(wxBitmap(maskBits, width, height)));
GdkPixbuf* pixbuf = bitmap.GetPixbuf();
if (fg || bg)
{
const int stride = gdk_pixbuf_get_rowstride(pixbuf);
const int n_channels = gdk_pixbuf_get_n_channels(pixbuf);
guchar* data = gdk_pixbuf_get_pixels(pixbuf);
for (int j = 0; j < height; j++, data += stride)
{
guchar* p = data;
for (int i = 0; i < width; i++, p += n_channels)
{
if (p[0])
{
if (fg)
{
p[0] = fg->Red();
p[1] = fg->Green();
p[2] = fg->Blue();
}
}
else
{
if (bg)
{
p[0] = bg->Red();
p[1] = bg->Green();
p[2] = bg->Blue();
}
}
}
}
}
M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixbuf(gtk_widget_get_display(wxGetRootWindow()), pixbuf, hotSpotX, hotSpotY);
#else
if (!maskBits)
maskBits = bits;
if (!fg)
fg = wxBLACK;
if (!bg)
bg = wxWHITE;
if (hotSpotX < 0 || hotSpotX >= width)
hotSpotX = 0;
if (hotSpotY < 0 || hotSpotY >= height)
hotSpotY = 0;
GdkBitmap* data = gdk_bitmap_create_from_data(
gtk_widget_get_window(wxGetRootWindow()), const_cast<char*>(bits), width, height);
GdkBitmap* mask = gdk_bitmap_create_from_data(
gtk_widget_get_window(wxGetRootWindow()), const_cast<char*>(maskBits), width, height);
m_refData = new wxCursorRefData;
M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixmap(
data, mask, fg->GetColor(), bg->GetColor(),
hotSpotX, hotSpotY );
g_object_unref (data);
g_object_unref (mask);
#endif
}
wxCursor::~wxCursor()
@@ -135,6 +174,9 @@ void wxCursor::InitFromStock( wxStockCursor cursorId )
GdkCursorType gdk_cur = GDK_LEFT_PTR;
switch (cursorId)
{
#ifdef __WXGTK3__
case wxCURSOR_BLANK: gdk_cur = GDK_BLANK_CURSOR; break;
#else
case wxCURSOR_BLANK:
{
const char bits[] = { 0 };
@@ -149,7 +191,7 @@ void wxCursor::InitFromStock( wxStockCursor cursorId )
g_object_unref(pixmap);
}
return;
#endif
case wxCURSOR_ARROW: // fall through to default
case wxCURSOR_DEFAULT: gdk_cur = GDK_LEFT_PTR; break;
case wxCURSOR_RIGHT_ARROW: gdk_cur = GDK_RIGHT_PTR; break;
@@ -196,152 +238,42 @@ void wxCursor::InitFromStock( wxStockCursor cursorId )
#if wxUSE_IMAGE
static void GetHotSpot(const wxImage& image, int& x, int& y)
{
if (image.HasOption(wxIMAGE_OPTION_CUR_HOTSPOT_X))
x = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
else
x = 0;
if (image.HasOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y))
y = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
else
y = 0;
if (x < 0 || x >= image.GetWidth())
x = 0;
if (y < 0 || y >= image.GetHeight())
y = 0;
}
void wxCursor::InitFromImage( const wxImage & image )
{
int w = image.GetWidth() ;
int h = image.GetHeight();
bool bHasMask = image.HasMask();
int hotSpotX, hotSpotY;
GetHotSpot(image, hotSpotX, hotSpotY);
const int w = image.GetWidth();
const int h = image.GetHeight();
const guchar* alpha = image.GetAlpha();
const bool hasMask = image.HasMask();
int hotSpotX = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
int hotSpotY = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
if (hotSpotX < 0 || hotSpotX > w) hotSpotX = 0;
if (hotSpotY < 0 || hotSpotY > h) hotSpotY = 0;
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(image.GetData(), GDK_COLORSPACE_RGB, false, 8, w, h, w * 3, NULL, NULL);
if (alpha || hasMask)
{
guchar r = 0, g = 0, b = 0;
if (hasMask)
{
r = image.GetMaskRed();
g = image.GetMaskGreen();
b = image.GetMaskBlue();
}
GdkPixbuf* pixbuf0 = pixbuf;
pixbuf = gdk_pixbuf_add_alpha(pixbuf, hasMask, r, g, b);
g_object_unref(pixbuf0);
if (alpha)
{
guchar* d = gdk_pixbuf_get_pixels(pixbuf);
const int stride = gdk_pixbuf_get_rowstride(pixbuf);
for (int j = 0; j < h; j++, d += stride)
for (int i = 0; i < w; i++, alpha++)
if (d[4 * i + 3])
d[4 * i + 3] = *alpha;
}
}
m_refData = new wxCursorRefData;
wxImage image_copy(image);
GdkDisplay* display = gdk_drawable_get_display(gtk_widget_get_window(wxGetRootWindow()));
if (gdk_display_supports_cursor_color(display))
{
if (!image.HasAlpha())
{
// add alpha, so wxBitmap will convert to pixbuf format
image_copy.InitAlpha();
}
wxBitmap bitmap(image_copy);
wxASSERT(bitmap.HasPixbuf());
M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixbuf
(
display,
bitmap.GetPixbuf(),
hotSpotX, hotSpotY
);
}
else // no colour cursor support
{
unsigned long keyMaskColor = 0;
GdkPixmap *maskRaw;
if (bHasMask)
{
keyMaskColor = wxImageHistogram::MakeKey(
image.GetMaskRed(), image.GetMaskGreen(), image.GetMaskBlue());
// get mask before image is modified
wxBitmap bitmap(image, 1);
maskRaw = bitmap.GetMask()->GetBitmap();
g_object_ref(maskRaw);
}
else
{
const int size = ((w + 7) / 8) * h;
char* bits = new char[size];
memset(bits, 0xff, size);
maskRaw = gdk_bitmap_create_from_data(
gtk_widget_get_window(wxGetRootWindow()), bits, w, h);
delete[] bits;
}
// assign the raw pointer to wxGtkObject to ensure it is unref'd later
wxGtkObject<GdkPixmap> mask(maskRaw);
// modify image so wxBitmap can be used to convert to pixmap
image_copy.SetMask(false);
wxByte* data = image_copy.GetData();
for (int j = 0; j < h; j++)
{
for (int i = 0; i < w; i++, data += 3)
{
// if average value of the pixel is > mid grey, convert it to
// background (0), otherwise to foreground (255, using wxBitmap
// convention)
data[0] =
data[1] =
data[2] = int(data[0]) + data[1] + data[2] >= 3 * 128 ? 0 : 255;
}
}
wxBitmap bitmap(image_copy, 1);
// find the most frequent color(s)
wxImageHistogram histogram;
image.ComputeHistogram(histogram);
long colMostFreq = 0;
unsigned long nMost = 0;
long colNextMostFreq = 0;
unsigned long nNext = 0;
for ( wxImageHistogram::iterator entry = histogram.begin();
entry != histogram.end();
++entry )
{
unsigned long key = entry->first;
if ( !bHasMask || (key != keyMaskColor) )
{
unsigned long value = entry->second.value;
if (value > nMost)
{
nNext = nMost;
colNextMostFreq = colMostFreq;
nMost = value;
colMostFreq = key;
}
else if (value > nNext)
{
nNext = value;
colNextMostFreq = key;
}
}
}
wxColour fg = wxColour ( (unsigned char)(colMostFreq >> 16),
(unsigned char)(colMostFreq >> 8),
(unsigned char)(colMostFreq) );
wxColour bg = wxColour ( (unsigned char)(colNextMostFreq >> 16),
(unsigned char)(colNextMostFreq >> 8),
(unsigned char)(colNextMostFreq) );
int fg_intensity = fg.Red() + fg.Green() + fg.Blue();
int bg_intensity = bg.Red() + bg.Green() + bg.Blue();
if (bg_intensity > fg_intensity)
{
//swap fg and bg
wxColour tmp = fg;
fg = bg;
bg = tmp;
}
M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixmap
(
bitmap.GetPixmap(),
mask,
fg.GetColor(), bg.GetColor(),
hotSpotX, hotSpotY
);
}
M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixbuf(gtk_widget_get_display(wxGetRootWindow()), pixbuf, hotSpotX, hotSpotY);
g_object_unref(pixbuf);
}
#endif // wxUSE_IMAGE

View File

@@ -28,17 +28,27 @@
#include "wx/popupwin.h"
#include "wx/listimpl.cpp"
#include "wx/gtk/private.h"
#include "wx/gtk/dc.h"
#ifndef __WXGTK3__
#include "wx/gtk/dcclient.h"
#endif
#include "wx/gtk/private/gdkconv.h"
#include "wx/gtk/private/list.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/event.h"
#include "wx/gtk/private/gdkconv.h"
#include "wx/gtk/private/gtk2-compat.h"
#include "wx/gtk/private/list.h"
using namespace wxGTKImpl;
class wxGtkDataViewModelNotifier;
#ifdef __WXGTK3__
#define wxConstGdkRect const GdkRectangle
#else
#define wxConstGdkRect GdkRectangle
#endif
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
@@ -137,7 +147,8 @@ public:
// any given moment. It's just simpler like this and we don't need anything
// more for now.
extern "C"
extern "C" {
static
gboolean wxdataview_selection_func(GtkTreeSelection * WXUNUSED(selection),
GtkTreeModel * WXUNUSED(model),
GtkTreePath * WXUNUSED(path),
@@ -146,6 +157,7 @@ gboolean wxdataview_selection_func(GtkTreeSelection * WXUNUSED(selection),
{
return data == NULL;
}
}
class wxGtkTreeSelectionLock
{
@@ -185,8 +197,10 @@ private:
// We can only use gtk_tree_selection_get_select_function() with 2.14+
// so check for its availability both during compile- and run-time.
#if GTK_CHECK_VERSION(2, 14, 0)
#ifndef __WXGTK3__
if ( gtk_check_version(2, 14, 0) != NULL )
return;
#endif
// If this assert is triggered, it means the code elsewhere has called
// gtk_tree_selection_set_select_function() but currently doing this
@@ -1074,8 +1088,8 @@ static GtkCellEditable *gtk_wx_cell_renderer_text_start_editing(
GdkEvent *event,
GtkWidget *widget,
const gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
wxConstGdkRect *background_area,
wxConstGdkRect *cell_area,
GtkCellRendererState flags );
@@ -1138,8 +1152,8 @@ static GtkCellEditable *gtk_wx_cell_renderer_text_start_editing(
GdkEvent *gdk_event,
GtkWidget *widget,
const gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
wxConstGdkRect *background_area,
wxConstGdkRect *cell_area,
GtkCellRendererState flags )
{
GtkWxCellRendererText *wxgtk_renderer = (GtkWxCellRendererText *) gtk_renderer;
@@ -1195,34 +1209,40 @@ static void gtk_wx_cell_renderer_class_init(
static void gtk_wx_cell_renderer_get_size (
GtkCellRenderer *cell,
GtkWidget *widget,
GdkRectangle *rectangle,
wxConstGdkRect *rectangle,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height );
static void gtk_wx_cell_renderer_render (
GtkCellRenderer *cell,
#ifdef __WXGTK3__
cairo_t* cr,
#else
GdkWindow *window,
#endif
GtkWidget *widget,
GdkRectangle *background_area,
GdkRectangle *cell_area,
wxConstGdkRect *background_area,
wxConstGdkRect *cell_area,
#ifndef __WXGTK3__
GdkRectangle *expose_area,
#endif
GtkCellRendererState flags );
static gboolean gtk_wx_cell_renderer_activate(
GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
const gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
wxConstGdkRect *background_area,
wxConstGdkRect *cell_area,
GtkCellRendererState flags );
static GtkCellEditable *gtk_wx_cell_renderer_start_editing(
GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
const gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
wxConstGdkRect *background_area,
wxConstGdkRect *cell_area,
GtkCellRendererState flags );
} // extern "C"
@@ -1283,8 +1303,8 @@ static GtkCellEditable *gtk_wx_cell_renderer_start_editing(
GdkEvent *WXUNUSED(event),
GtkWidget *widget,
const gchar *path,
GdkRectangle *WXUNUSED(background_area),
GdkRectangle *cell_area,
wxConstGdkRect *WXUNUSED(background_area),
wxConstGdkRect *cell_area,
GtkCellRendererState WXUNUSED(flags) )
{
GtkWxCellRenderer *wxrenderer = (GtkWxCellRenderer *) renderer;
@@ -1324,7 +1344,7 @@ static GtkCellEditable *gtk_wx_cell_renderer_start_editing(
static void
gtk_wx_cell_renderer_get_size (GtkCellRenderer *renderer,
GtkWidget *WXUNUSED(widget),
GdkRectangle *cell_area,
wxConstGdkRect *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
@@ -1381,20 +1401,30 @@ gtk_wx_cell_renderer_get_size (GtkCellRenderer *renderer,
struct wxDataViewCustomRenderer::GTKRenderParams
{
#ifdef __WXGTK3__
cairo_t* cr;
#else
GdkWindow* window;
GdkRectangle* expose_area;
#endif
GtkWidget* widget;
GdkRectangle* background_area;
wxConstGdkRect* background_area;
int flags;
};
static void
gtk_wx_cell_renderer_render (GtkCellRenderer *renderer,
#ifdef __WXGTK3__
cairo_t* cr,
#else
GdkWindow *window,
#endif
GtkWidget *widget,
GdkRectangle *background_area,
GdkRectangle *cell_area,
wxConstGdkRect *background_area,
wxConstGdkRect *cell_area,
#ifndef __WXGTK3__
GdkRectangle *expose_area,
#endif
GtkCellRendererState flags)
{
@@ -1402,8 +1432,12 @@ gtk_wx_cell_renderer_render (GtkCellRenderer *renderer,
wxDataViewCustomRenderer *cell = wxrenderer->cell;
wxDataViewCustomRenderer::GTKRenderParams renderParams;
#ifdef __WXGTK3__
renderParams.cr = cr;
#else
renderParams.window = window;
renderParams.expose_area = expose_area;
#endif
renderParams.widget = widget;
renderParams.background_area = background_area;
renderParams.flags = flags;
@@ -1414,7 +1448,18 @@ gtk_wx_cell_renderer_render (GtkCellRenderer *renderer,
gtk_cell_renderer_get_padding(renderer, &xpad, &ypad);
rect = rect.Deflate(xpad, ypad);
wxWindowDC* dc = (wxWindowDC*) cell->GetDC();
wxDC* dc = cell->GetDC();
#ifdef __WXGTK3__
wxGraphicsContext* context = dc->GetGraphicsContext();
void* nativeContext = NULL;
if (context)
nativeContext = context->GetNativeContext();
if (cr != nativeContext)
{
cairo_reference(cr);
dc->SetGraphicsContext(wxGraphicsContext::CreateFromNative(cr));
}
#else
wxWindowDCImpl *impl = (wxWindowDCImpl *) dc->GetImpl();
// Reinitialize wxWindowDC's GDK window if drawing occurs into a different
@@ -1425,6 +1470,7 @@ gtk_wx_cell_renderer_render (GtkCellRenderer *renderer,
impl->m_gdkwindow = window;
impl->SetUpDC();
}
#endif
int state = 0;
if (flags & GTK_CELL_RENDERER_SELECTED)
@@ -1440,6 +1486,9 @@ gtk_wx_cell_renderer_render (GtkCellRenderer *renderer,
cell->WXCallRender( rect, dc, state );
cell->GTKSetRenderParams(NULL);
#ifdef __WXGTK3__
dc->SetGraphicsContext(NULL);
#endif
}
static gboolean
@@ -1448,8 +1497,8 @@ gtk_wx_cell_renderer_activate(
GdkEvent *event,
GtkWidget *widget,
const gchar *path,
GdkRectangle *WXUNUSED(background_area),
GdkRectangle *cell_area,
wxConstGdkRect *WXUNUSED(background_area),
wxConstGdkRect *cell_area,
GtkCellRendererState WXUNUSED(flags) )
{
GtkWxCellRenderer *wxrenderer = (GtkWxCellRenderer *) renderer;
@@ -1661,7 +1710,9 @@ bool wxGtkDataViewModelNotifier::ValueChanged( const wxDataViewItem &item, unsig
double d = gtk_adjustment_get_value( hadjust );
int xdiff = (int) d;
int ydiff = gcolumn->button->allocation.height;
GtkAllocation a;
gtk_widget_get_allocation(GTK_WIDGET(gtk_tree_view_column_get_button(gcolumn)), &a);
int ydiff = a.height;
// Redraw
gtk_widget_queue_draw_area( GTK_WIDGET(widget),
cell_area.x - xdiff, ydiff + cell_area.y, cell_area.width, cell_area.height );
@@ -1790,7 +1841,9 @@ void wxDataViewRenderer::GtkPackIntoColumn(GtkTreeViewColumn *column)
void wxDataViewRenderer::GtkInitHandlers()
{
#ifndef __WXGTK3__
if (!gtk_check_version(2,6,0))
#endif
{
g_signal_connect (GTK_CELL_RENDERER(m_renderer), "editing_started",
G_CALLBACK (wxgtk_renderer_editing_started),
@@ -1919,8 +1972,10 @@ int wxDataViewRenderer::GetAlignment() const
void wxDataViewRenderer::EnableEllipsize(wxEllipsizeMode mode)
{
#ifdef __WXGTK26__
#ifndef __WXGTK3__
if ( gtk_check_version(2, 6, 0) != NULL )
return;
#endif
GtkCellRendererText * const rend = GtkGetTextRenderer();
if ( !rend )
@@ -1941,8 +1996,10 @@ void wxDataViewRenderer::EnableEllipsize(wxEllipsizeMode mode)
wxEllipsizeMode wxDataViewRenderer::GetEllipsizeMode() const
{
#ifdef __WXGTK26__
#ifndef __WXGTK3__
if ( gtk_check_version(2, 6, 0) != NULL )
return wxELLIPSIZE_NONE;
#endif
GtkCellRendererText * const rend = GtkGetTextRenderer();
if ( !rend )
@@ -2150,8 +2207,10 @@ void wxDataViewTextRenderer::SetAlignment( int align )
{
wxDataViewRenderer::SetAlignment(align);
#ifndef __WXGTK3__
if (gtk_check_version(2,10,0))
return;
#endif
// horizontal alignment:
PangoAlignment pangoAlign = PANGO_ALIGN_LEFT;
@@ -2328,6 +2387,7 @@ bool wxDataViewToggleRenderer::GetValue( wxVariant &value ) const
// wxDataViewCustomRenderer
// ---------------------------------------------------------
#ifndef __WXGTK3__
class wxDataViewCtrlDCImpl: public wxWindowDCImpl
{
public:
@@ -2358,7 +2418,7 @@ public:
wxWindowDC( new wxDataViewCtrlDCImpl( this, window ) )
{ }
};
#endif
// ---------------------------------------------------------
// wxDataViewCustomRenderer
@@ -2424,11 +2484,17 @@ void wxDataViewCustomRenderer::RenderText( const wxString &text,
cell_area.width -= xoffset;
gtk_cell_renderer_render( GTK_CELL_RENDERER(textRenderer),
#ifdef __WXGTK3__
m_renderParams->cr,
#else
m_renderParams->window,
#endif
m_renderParams->widget,
m_renderParams->background_area,
&cell_area,
#ifndef __WXGTK3__
m_renderParams->expose_area,
#endif
GtkCellRendererState(m_renderParams->flags));
}
@@ -2460,11 +2526,18 @@ wxDC *wxDataViewCustomRenderer::GetDC()
{
if (m_dc == NULL)
{
#ifdef __WXGTK3__
wxASSERT(m_renderParams);
cairo_t* cr = m_renderParams->cr;
wxASSERT(cr && cairo_status(cr) == 0);
m_dc = new wxGTKCairoDC(cr);
#else
if (GetOwner() == NULL)
return NULL;
if (GetOwner()->GetOwner() == NULL)
return NULL;
m_dc = new wxDataViewCtrlDC( GetOwner()->GetOwner() );
#endif
}
return m_dc;
@@ -2484,7 +2557,7 @@ wxDataViewProgressRenderer::wxDataViewProgressRenderer( const wxString &label,
m_value = 0;
#ifdef __WXGTK26__
if (!gtk_check_version(2,6,0))
if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,6,0) == NULL)
{
m_renderer = (GtkCellRenderer*) gtk_cell_renderer_progress_new();
@@ -2540,7 +2613,7 @@ void wxDataViewProgressRenderer::GTKSetLabel()
bool wxDataViewProgressRenderer::SetValue( const wxVariant &value )
{
#ifdef __WXGTK26__
if (!gtk_check_version(2,6,0))
if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,6,0) == NULL)
{
#if !wxUSE_UNICODE
if ( m_needsToSetLabel )
@@ -2603,7 +2676,7 @@ wxDataViewChoiceRenderer::wxDataViewChoiceRenderer( const wxArrayString &choices
m_choices = choices;
#ifdef __WXGTK26__
if (!gtk_check_version(2,6,0))
if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,6,0) == NULL)
{
m_renderer = (GtkCellRenderer*) gtk_cell_renderer_combo_new();
@@ -2653,7 +2726,7 @@ bool wxDataViewChoiceRenderer::SetValue( const wxVariant &value )
{
#ifdef __WXGTK26__
if (!gtk_check_version(2,6,0))
if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,6,0) == NULL)
{
GValue gvalue = { 0, };
g_value_init( &gvalue, G_TYPE_STRING );
@@ -2673,7 +2746,7 @@ bool wxDataViewChoiceRenderer::SetValue( const wxVariant &value )
bool wxDataViewChoiceRenderer::GetValue( wxVariant &value ) const
{
#ifdef __WXGTK26__
if (!gtk_check_version(2,6,0))
if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,6,0) == NULL)
{
GValue gvalue = { 0, };
g_value_init( &gvalue, G_TYPE_STRING );
@@ -2697,8 +2770,10 @@ void wxDataViewChoiceRenderer::SetAlignment( int align )
{
wxDataViewCustomRenderer::SetAlignment(align);
#ifndef __WXGTK3__
if (gtk_check_version(2,10,0))
return;
#endif
// horizontal alignment:
PangoAlignment pangoAlign = PANGO_ALIGN_LEFT;
@@ -3010,9 +3085,10 @@ void wxDataViewColumn::OnInternalIdle()
if (gtk_widget_get_realized(GetOwner()->m_treeview))
{
GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(m_column);
if (column->button)
GtkWidget* button = gtk_tree_view_column_get_button(column);
if (button)
{
g_signal_connect(column->button, "button_press_event",
g_signal_connect(button, "button_press_event",
G_CALLBACK (gtk_dataview_header_button_press_callback), this);
// otherwise the event will be blocked by GTK+
@@ -3059,20 +3135,7 @@ void wxDataViewColumn::SetBitmap( const wxBitmap &bitmap )
{
GtkImage *gtk_image = GTK_IMAGE(m_image);
GdkBitmap *mask = NULL;
if (bitmap.GetMask())
mask = bitmap.GetMask()->GetBitmap();
if (bitmap.HasPixbuf())
{
gtk_image_set_from_pixbuf(GTK_IMAGE(gtk_image),
bitmap.GetPixbuf());
}
else
{
gtk_image_set_from_pixmap(GTK_IMAGE(gtk_image),
bitmap.GetPixmap(), mask);
}
gtk_image_set_from_pixbuf(GTK_IMAGE(gtk_image), bitmap.GetPixbuf());
gtk_widget_show( m_image );
}
else
@@ -4517,7 +4580,9 @@ bool wxDataViewCtrl::Create(wxWindow *parent,
G_CALLBACK (gtk_dataviewctrl_size_callback), this);
#ifdef __WXGTK26__
#ifndef __WXGTK3__
if (!gtk_check_version(2,6,0))
#endif
{
bool fixed = (style & wxDV_VARIABLE_LINE_HEIGHT) == 0;
gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), fixed );
@@ -4533,7 +4598,9 @@ bool wxDataViewCtrl::Create(wxWindow *parent,
gtk_tree_view_set_headers_visible( GTK_TREE_VIEW(m_treeview), (style & wxDV_NO_HEADER) == 0 );
#ifdef __WXGTK210__
#ifndef __WXGTK3__
if (!gtk_check_version(2,10,0))
#endif
{
GtkTreeViewGridLines grid = GTK_TREE_VIEW_GRID_LINES_NONE;
@@ -4627,7 +4694,9 @@ bool wxDataViewCtrl::AssociateModel( wxDataViewModel *model )
return false;
#ifdef __WXGTK26__
#ifndef __WXGTK3__
if (!gtk_check_version(2,6,0))
#endif
{
bool fixed = (((GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) == 0) || (model->IsVirtualListModel()));
gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), fixed );
@@ -4657,7 +4726,9 @@ bool wxDataViewCtrl::AppendColumn( wxDataViewColumn *col )
m_cols.Append( col );
#ifdef __WXGTK26__
#ifndef __WXGTK3__
if (!gtk_check_version(2,6,0))
#endif
{
if (gtk_tree_view_column_get_sizing( GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()) ) !=
GTK_TREE_VIEW_COLUMN_FIXED)
@@ -4679,7 +4750,9 @@ bool wxDataViewCtrl::PrependColumn( wxDataViewColumn *col )
m_cols.Insert( col );
#ifdef __WXGTK26__
#ifndef __WXGTK3__
if (!gtk_check_version(2,6,0))
#endif
{
if (gtk_tree_view_column_get_sizing( GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()) ) !=
GTK_TREE_VIEW_COLUMN_FIXED)
@@ -4701,7 +4774,9 @@ bool wxDataViewCtrl::InsertColumn( unsigned int pos, wxDataViewColumn *col )
m_cols.Insert( pos, col );
#ifdef __WXGTK26__
#ifndef __WXGTK3__
if (!gtk_check_version(2,6,0))
#endif
{
if (gtk_tree_view_column_get_sizing( GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()) ) !=
GTK_TREE_VIEW_COLUMN_FIXED)
@@ -5131,7 +5206,7 @@ wxDataViewCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
void wxDataViewCtrl::DoApplyWidgetStyle(GtkRcStyle *style)
{
wxDataViewCtrlBase::DoApplyWidgetStyle(style);
gtk_widget_modify_style(m_treeview, style);
GTKApplyStyle(m_treeview, style);
}
#endif // !wxUSE_GENERICDATAVIEWCTRL

View File

@@ -10,6 +10,349 @@
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __WXGTK3__
#include "wx/window.h"
#include "wx/dcclient.h"
#include "wx/dcmemory.h"
#include "wx/dcscreen.h"
#include "wx/icon.h"
#include "wx/gtk/dc.h"
#include <gtk/gtk.h>
wxGTKCairoDCImpl::wxGTKCairoDCImpl(wxDC* owner)
: base_type(owner)
{
m_width = 0;
m_height = 0;
}
wxGTKCairoDCImpl::wxGTKCairoDCImpl(wxDC* owner, wxWindow* window)
: base_type(owner)
{
m_window = window;
m_font = window->GetFont();
m_textForegroundColour = window->GetForegroundColour();
m_textBackgroundColour = window->GetBackgroundColour();
m_width = 0;
m_height = 0;
}
void wxGTKCairoDCImpl::DoDrawBitmap(const wxBitmap& bitmap, int x, int y, bool useMask)
{
wxCHECK_RET(IsOk(), "invalid DC");
cairo_t* cr = NULL;
if (m_graphicContext)
cr = static_cast<cairo_t*>(m_graphicContext->GetNativeContext());
if (cr)
{
cairo_save(cr);
bitmap.Draw(cr, x, y, useMask, &m_textForegroundColour, &m_textBackgroundColour);
cairo_restore(cr);
}
}
void wxGTKCairoDCImpl::DoDrawIcon(const wxIcon& icon, int x, int y)
{
DoDrawBitmap(icon, x, y, true);
}
#if wxUSE_IMAGE
bool wxDoFloodFill(wxDC* dc, int x, int y, const wxColour& col, wxFloodFillStyle style);
bool wxGTKCairoDCImpl::DoFloodFill(int x, int y, const wxColour& col, wxFloodFillStyle style)
{
return wxDoFloodFill(GetOwner(), x, y, col, style);
}
#endif
wxBitmap wxGTKCairoDCImpl::DoGetAsBitmap(const wxRect* /*subrect*/) const
{
wxFAIL_MSG("DoGetAsBitmap not implemented");
return wxBitmap();
}
bool wxGTKCairoDCImpl::DoGetPixel(int x, int y, wxColour* col) const
{
if (col)
{
cairo_t* cr = NULL;
if (m_graphicContext)
cr = static_cast<cairo_t*>(m_graphicContext->GetNativeContext());
if (cr)
{
cairo_surface_t* surface = cairo_get_target(cr);
x = LogicalToDeviceX(x);
y = LogicalToDeviceY(y);
GdkPixbuf* pixbuf = gdk_pixbuf_get_from_surface(surface, x, y, 1, 1);
if (pixbuf)
{
const guchar* src = gdk_pixbuf_get_pixels(pixbuf);
col->Set(src[0], src[1], src[2]);
g_object_unref(pixbuf);
return true;
}
*col = wxColour();
}
}
return false;
}
void wxGTKCairoDCImpl::DoGetSize(int* width, int* height) const
{
if (width)
*width = m_width;
if (height)
*height = m_height;
}
bool wxGTKCairoDCImpl::DoStretchBlit(int xdest, int ydest, int dstWidth, int dstHeight, wxDC* source, int xsrc, int ysrc, int srcWidth, int srcHeight, wxRasterOperationMode rop, bool useMask, int xsrcMask, int ysrcMask)
{
wxCHECK_MSG(IsOk(), false, "invalid DC");
wxCHECK_MSG(source && source->IsOk(), false, "invalid source DC");
cairo_t* cr = NULL;
if (m_graphicContext)
cr = static_cast<cairo_t*>(m_graphicContext->GetNativeContext());
cairo_t* cr_src = NULL;
wxGraphicsContext* gc_src = source->GetGraphicsContext();
if (gc_src)
cr_src = static_cast<cairo_t*>(gc_src->GetNativeContext());
if (cr == NULL || cr_src == NULL)
return false;
const int xsrc_dev = source->LogicalToDeviceX(xsrc);
const int ysrc_dev = source->LogicalToDeviceY(ysrc);
cairo_surface_t* surface = cairo_get_target(cr_src);
cairo_surface_flush(surface);
cairo_save(cr);
cairo_translate(cr, xdest, ydest);
cairo_rectangle(cr, 0, 0, dstWidth, dstHeight);
double sx, sy;
source->GetUserScale(&sx, &sy);
cairo_scale(cr, dstWidth / (sx * srcWidth), dstHeight / (sy * srcHeight));
cairo_set_source_surface(cr, surface, -xsrc_dev, -ysrc_dev);
const wxRasterOperationMode rop_save = m_logicalFunction;
SetLogicalFunction(rop);
cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_NEAREST);
cairo_surface_t* maskSurf = NULL;
if (useMask)
{
const wxBitmap& bitmap = source->GetImpl()->GetSelectedBitmap();
if (bitmap.IsOk())
{
wxMask* mask = bitmap.GetMask();
if (mask)
maskSurf = mask->GetBitmap();
}
}
if (maskSurf)
{
int xsrcMask_dev = xsrc_dev;
int ysrcMask_dev = ysrc_dev;
if (xsrcMask != -1)
xsrcMask_dev = source->LogicalToDeviceX(xsrcMask);
if (ysrcMask != -1)
ysrcMask_dev = source->LogicalToDeviceY(ysrcMask);
cairo_clip(cr);
cairo_mask_surface(cr, maskSurf, -xsrcMask_dev, -ysrcMask_dev);
}
else
{
cairo_fill(cr);
}
cairo_restore(cr);
m_logicalFunction = rop_save;
return true;
}
void* wxGTKCairoDCImpl::GetCairoContext() const
{
cairo_t* cr = NULL;
if (m_graphicContext)
cr = static_cast<cairo_t*>(m_graphicContext->GetNativeContext());
if (cr)
cairo_reference(cr);
return cr;
}
//-----------------------------------------------------------------------------
wxWindowDCImpl::wxWindowDCImpl(wxWindowDC* owner, wxWindow* window)
: base_type(owner, window)
{
GtkWidget* widget = window->m_wxwindow;
if (widget == NULL)
widget = window->m_widget;
GdkWindow* gdkWindow = NULL;
if (widget)
{
gdkWindow = gtk_widget_get_window(widget);
m_ok = true;
}
if (gdkWindow)
{
cairo_t* cr = gdk_cairo_create(gdkWindow);
SetGraphicsContext(wxGraphicsContext::CreateFromNative(cr));
GtkAllocation a;
gtk_widget_get_allocation(widget, &a);
int x, y;
if (gtk_widget_get_has_window(widget))
{
m_width = gdk_window_get_width(gdkWindow);
m_height = gdk_window_get_height(gdkWindow);
x = m_width - a.width;
y = m_height - a.height;
}
else
{
m_width = a.width;
m_height = a.height;
x = a.x;
y = a.y;
cairo_rectangle(cr, a.x, a.y, a.width, a.height);
cairo_clip(cr);
}
if (x || y)
SetDeviceLocalOrigin(x, y);
}
}
//-----------------------------------------------------------------------------
wxClientDCImpl::wxClientDCImpl(wxClientDC* owner, wxWindow* window)
: base_type(owner, window)
{
GtkWidget* widget = window->m_wxwindow;
if (widget == NULL)
widget = window->m_widget;
GdkWindow* gdkWindow = NULL;
if (widget)
{
gdkWindow = gtk_widget_get_window(widget);
m_ok = true;
}
if (gdkWindow)
{
cairo_t* cr = gdk_cairo_create(gdkWindow);
SetGraphicsContext(wxGraphicsContext::CreateFromNative(cr));
if (gtk_widget_get_has_window(widget))
{
m_width = gdk_window_get_width(gdkWindow);
m_height = gdk_window_get_height(gdkWindow);
}
else
{
GtkAllocation a;
gtk_widget_get_allocation(widget, &a);
m_width = a.width;
m_height = a.height;
cairo_rectangle(cr, a.x, a.y, a.width, a.height);
cairo_clip(cr);
SetDeviceLocalOrigin(a.x, a.y);
}
}
else
{
// create something that can be used for measuring, but not drawing
cairo_t* cr = gdk_cairo_create(gdk_get_default_root_window());
cairo_rectangle(cr, 0, 0, 0, 0);
cairo_clip(cr);
SetGraphicsContext(wxGraphicsContext::CreateFromNative(cr));
}
}
//-----------------------------------------------------------------------------
wxPaintDCImpl::wxPaintDCImpl(wxPaintDC* owner, wxWindow* window)
: base_type(owner, window)
{
cairo_t* cr = window->GTKPaintContext();
wxCHECK_RET(cr, "using wxPaintDC without being in a native paint event");
GdkWindow* gdkWindow = gtk_widget_get_window(window->m_wxwindow);
m_width = gdk_window_get_width(gdkWindow);
m_height = gdk_window_get_height(gdkWindow);
cairo_reference(cr);
SetGraphicsContext(wxGraphicsContext::CreateFromNative(cr));
}
//-----------------------------------------------------------------------------
wxScreenDCImpl::wxScreenDCImpl(wxScreenDC* owner)
: base_type(owner)
{
GdkWindow* window = gdk_get_default_root_window();
m_width = gdk_window_get_width(window);
m_height = gdk_window_get_height(window);
cairo_t* cr = gdk_cairo_create(window);
SetGraphicsContext(wxGraphicsContext::CreateFromNative(cr));
}
//-----------------------------------------------------------------------------
wxMemoryDCImpl::wxMemoryDCImpl(wxMemoryDC* owner)
: base_type(owner)
{
m_ok = false;
}
wxMemoryDCImpl::wxMemoryDCImpl(wxMemoryDC* owner, wxBitmap& bitmap)
: base_type(owner)
, m_bitmap(bitmap)
{
Setup();
}
wxMemoryDCImpl::wxMemoryDCImpl(wxMemoryDC* owner, wxDC*)
: base_type(owner)
{
m_ok = false;
}
wxBitmap wxMemoryDCImpl::DoGetAsBitmap(const wxRect* subrect) const
{
return subrect ? m_bitmap.GetSubBitmap(*subrect) : m_bitmap;
}
void wxMemoryDCImpl::DoSelect(const wxBitmap& bitmap)
{
m_bitmap = bitmap;
Setup();
}
const wxBitmap& wxMemoryDCImpl::GetSelectedBitmap() const
{
return m_bitmap;
}
wxBitmap& wxMemoryDCImpl::GetSelectedBitmap()
{
return m_bitmap;
}
void wxMemoryDCImpl::Setup()
{
wxGraphicsContext* gc = NULL;
m_ok = m_bitmap.IsOk();
if (m_ok)
{
m_width = m_bitmap.GetWidth();
m_height = m_bitmap.GetHeight();
cairo_t* cr = m_bitmap.CairoCreate();
gc = wxGraphicsContext::CreateFromNative(cr);
}
SetGraphicsContext(gc);
}
//-----------------------------------------------------------------------------
wxGTKCairoDC::wxGTKCairoDC(cairo_t* cr)
: base_type(new wxGTKCairoDCImpl(this))
{
cairo_reference(cr);
SetGraphicsContext(wxGraphicsContext::CreateFromNative(cr));
}
#else
#include "wx/gtk/dc.h"
//-----------------------------------------------------------------------------
@@ -60,3 +403,4 @@ wxSize wxGTKDCImpl::GetPPI() const
// TODO (should probably be pure virtual)
return wxSize(0, 0);
}
#endif

View File

@@ -240,8 +240,8 @@ static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget),
result_action = GDK_ACTION_MOVE;
// is result action actually supported
bool ret ((result_action != GDK_ACTION_DEFAULT) &&
(context->actions & result_action));
bool ret = (result_action != GDK_ACTION_DEFAULT) &&
(gdk_drag_context_get_actions(context) & result_action);
if (ret)
gdk_drag_status( context, result_action, time );
@@ -379,7 +379,7 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
this is only valid for the duration of this call */
drop_target->GTKSetDragData( data );
wxDragResult result = ConvertFromGTK(context->action);
wxDragResult result = ConvertFromGTK(gdk_drag_context_get_selected_action(context));
if ( wxIsDragResultOk( drop_target->OnData( x, y, result ) ) )
{
@@ -443,11 +443,12 @@ wxDragResult wxDropTarget::GTKFigureOutSuggestedAction()
// only good if we don't have our own preferences - but also the actions
// field
wxDragResult suggested_action = wxDragNone;
const GdkDragAction actions = gdk_drag_context_get_actions(m_dragContext);
if (GetDefaultAction() == wxDragNone)
{
// use default action set by wxDropSource::DoDragDrop()
if ( (gs_flagsForDrag & wxDrag_DefaultMove) == wxDrag_DefaultMove &&
(m_dragContext->actions & GDK_ACTION_MOVE ) )
(actions & GDK_ACTION_MOVE))
{
// move is requested by the program and allowed by GTK+ - do it, even
// though suggested_action may be currently wxDragCopy
@@ -455,7 +456,7 @@ wxDragResult wxDropTarget::GTKFigureOutSuggestedAction()
}
else // use whatever GTK+ says we should
{
suggested_action = ConvertFromGTK(m_dragContext->suggested_action);
suggested_action = ConvertFromGTK(gdk_drag_context_get_suggested_action(m_dragContext));
#if 0
// RR: I don't understand the code below: if the drag comes from
@@ -472,18 +473,18 @@ wxDragResult wxDropTarget::GTKFigureOutSuggestedAction()
}
}
else if (GetDefaultAction() == wxDragMove &&
(m_dragContext->actions & GDK_ACTION_MOVE))
(actions & GDK_ACTION_MOVE))
{
suggested_action = wxDragMove;
}
else
{
if (m_dragContext->actions & GDK_ACTION_COPY)
if (actions & GDK_ACTION_COPY)
suggested_action = wxDragCopy;
else if (m_dragContext->actions & GDK_ACTION_MOVE)
else if (actions & GDK_ACTION_MOVE)
suggested_action = wxDragMove;
else if (m_dragContext->actions & GDK_ACTION_LINK)
else if (actions & GDK_ACTION_LINK)
suggested_action = wxDragLink;
else
suggested_action = wxDragNone;
@@ -505,7 +506,7 @@ GdkAtom wxDropTarget::GTKGetMatchingPair(bool quiet)
if (!m_dragContext)
return (GdkAtom) 0;
GList *child = m_dragContext->targets;
const GList* child = gdk_drag_context_list_targets(m_dragContext);
while (child)
{
GdkAtom formatAtom = (GdkAtom)(child->data);
@@ -647,7 +648,7 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget),
return;
}
drop_source->m_retValue = ConvertFromGTK( context->action );
drop_source->m_retValue = ConvertFromGTK(gdk_drag_context_get_selected_action(context));
gtk_selection_data_set( selection_data,
gtk_selection_data_get_target(selection_data),
@@ -680,7 +681,7 @@ extern "C" {
static gint
gtk_dnd_window_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxDropSource *source )
{
source->GiveFeedback( ConvertFromGTK(source->m_dragContext->action) );
source->GiveFeedback(ConvertFromGTK(gdk_drag_context_get_selected_action(source->m_dragContext)));
return 0;
}
@@ -760,6 +761,7 @@ void wxDropSource::PrepareIcon( int action, GdkDragContext *context )
else
icon = &m_iconNone;
#ifndef __WXGTK3__
GdkBitmap *mask;
if ( icon->GetMask() )
mask = icon->GetMask()->GetBitmap();
@@ -768,28 +770,45 @@ void wxDropSource::PrepareIcon( int action, GdkDragContext *context )
GdkPixmap *pixmap = icon->GetPixmap();
gint width,height;
gdk_drawable_get_size (pixmap, &width, &height);
GdkColormap *colormap = gtk_widget_get_colormap( m_widget );
gtk_widget_push_colormap (colormap);
#endif
m_iconWindow = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_events (m_iconWindow, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
gtk_widget_set_app_paintable (m_iconWindow, TRUE);
#ifdef __WXGTK3__
gtk_widget_set_visual(m_iconWindow, gtk_widget_get_visual(m_widget));
#else
gtk_widget_pop_colormap ();
#endif
gtk_widget_set_size_request (m_iconWindow, width, height);
gtk_widget_set_size_request (m_iconWindow, icon->GetWidth(), icon->GetHeight());
gtk_widget_realize (m_iconWindow);
g_signal_connect (m_iconWindow, "configure_event",
G_CALLBACK (gtk_dnd_window_configure_callback), this);
#ifdef __WXGTK3__
cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(m_iconWindow));
icon->SetSourceSurface(cr, 0, 0);
cairo_pattern_t* pattern = cairo_get_source(cr);
gdk_window_set_background_pattern(gtk_widget_get_window(m_iconWindow), pattern);
cairo_destroy(cr);
cairo_surface_t* mask = icon->GetMask()->GetBitmap();
if (mask)
{
cairo_region_t* region = gdk_cairo_region_create_from_surface(mask);
gtk_widget_shape_combine_region(m_iconWindow, region);
cairo_region_destroy(region);
}
#else
gdk_window_set_back_pixmap(gtk_widget_get_window(m_iconWindow), pixmap, false);
if (mask)
gtk_widget_shape_combine_mask (m_iconWindow, mask, 0, 0);
#endif
gtk_drag_set_icon_widget( context, m_iconWindow, 0, 0 );
}

View File

@@ -280,7 +280,9 @@ static void wxgtk_main_do_event(GdkEvent* event, void* data)
case GDK_DESTROY:
case GDK_EXPOSE:
#ifndef __WXGTK3__
case GDK_NO_EXPOSE:
#endif
case GDK_MAP:
case GDK_UNMAP:

View File

@@ -41,6 +41,7 @@ static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog)
wxGtkString filename(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)));
// gtk version numbers must be identical with the one in ctor (that calls set_do_overwrite_confirmation)
#ifndef __WXGTK3__
#if GTK_CHECK_VERSION(2,7,3)
if (gtk_check_version(2, 7, 3) != NULL)
#endif
@@ -62,6 +63,7 @@ static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog)
}
}
}
#endif
if (style & wxFD_FILE_MUST_EXIST)
{
@@ -290,8 +292,14 @@ bool wxFileDialog::Create(wxWindow *parent, const wxString& message,
}
#if GTK_CHECK_VERSION(2,7,3)
if ((style & wxFD_OVERWRITE_PROMPT) && !gtk_check_version(2,7,3))
if ((style & wxFD_OVERWRITE_PROMPT)
#ifndef __WXGTK3__
&& gtk_check_version(2,7,3) == NULL
#endif
)
{
gtk_file_chooser_set_do_overwrite_confirmation(file_chooser, true);
}
#endif
}
else // wxFD_OPEN

View File

@@ -44,7 +44,9 @@ void wxFileHistory::AddFileToHistory(const wxString& file)
#ifdef __WXGTK210__
const wxString fullPath = wxFileName(file).GetFullPath();
#ifndef __WXGTK3__
if ( !gtk_check_version(2,10,0) )
#endif
{
wxGtkString uri(g_filename_to_uri(wxGTK_CONV_FN(fullPath), NULL, NULL));

View File

@@ -22,6 +22,7 @@
#include "wx/filepicker.h"
#include "wx/tooltip.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
// ============================================================================
@@ -43,7 +44,11 @@ bool wxFileButton::Create( wxWindow *parent, wxWindowID id,
{
// we can't use the native button for wxFLP_SAVE pickers as it can only
// open existing files and there is no way to create a new file using it
if ( !(style & wxFLP_SAVE) && !(style & wxFLP_USE_TEXTCTRL) && !gtk_check_version(2,6,0) )
if (!(style & wxFLP_SAVE) && !(style & wxFLP_USE_TEXTCTRL)
#ifndef __WXGTK3__
&& gtk_check_version(2,6,0) == NULL
#endif
)
{
// VERY IMPORTANT: this code is identical to relative code in wxDirButton;
// if you find a problem here, fix it also in wxDirButton !
@@ -196,7 +201,11 @@ bool wxDirButton::Create( wxWindow *parent, wxWindowID id,
long style, const wxValidator& validator,
const wxString &name )
{
if ( !(style & wxDIRP_USE_TEXTCTRL) && !gtk_check_version(2,6,0) )
if (!(style & wxDIRP_USE_TEXTCTRL)
#ifndef __WXGTK3__
&& gtk_check_version(2,6,0) == NULL
#endif
)
{
// VERY IMPORTANT: this code is identic to relative code in wxFileButton;
// if you find a problem here, fix it also in wxFileButton !

View File

@@ -42,8 +42,13 @@ bool wxGauge::Create( wxWindow *parent,
g_object_ref(m_widget);
if ( style & wxGA_VERTICAL )
{
#ifdef __WXGTK3__
gtk_orientable_set_orientation(GTK_ORIENTABLE(m_widget), GTK_ORIENTATION_VERTICAL);
gtk_progress_bar_set_inverted(GTK_PROGRESS_BAR(m_widget), true);
#else
gtk_progress_bar_set_orientation( GTK_PROGRESS_BAR(m_widget),
GTK_PROGRESS_BOTTOM_TO_TOP );
#endif
}
// when using the gauge in indeterminate mode, we need this:

View File

@@ -40,6 +40,7 @@ gtk_glwindow_realized_callback( GtkWidget *WXUNUSED(widget), wxGLCanvas *win )
// "map" from m_wxwindow
//-----------------------------------------------------------------------------
#ifndef __WXGTK3__
extern "C" {
static void
gtk_glwindow_map_callback( GtkWidget * WXUNUSED(widget), wxGLCanvas *win )
@@ -52,12 +53,28 @@ gtk_glwindow_map_callback( GtkWidget * WXUNUSED(widget), wxGLCanvas *win )
win->GetUpdateRegion().Clear();
}
}
#endif
//-----------------------------------------------------------------------------
// "expose_event" of m_wxwindow
//-----------------------------------------------------------------------------
extern "C" {
#ifdef __WXGTK3__
static gboolean draw(GtkWidget*, cairo_t* cr, wxGLCanvas* win)
{
win->m_exposed = true;
if (win->m_cairoPaintContext == NULL)
{
win->m_cairoPaintContext = cr;
cairo_reference(cr);
}
double x1, y1, x2, y2;
cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
win->GetUpdateRegion().Union(int(x1), int(y1), int(x2 - x1), int(y2 - y1));
return false;
}
#else
static gboolean
gtk_glwindow_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxGLCanvas *win )
{
@@ -69,6 +86,7 @@ gtk_glwindow_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_e
gdk_event->area.height );
return false;
}
#endif
}
//-----------------------------------------------------------------------------
@@ -107,9 +125,13 @@ parent_set_hook(GSignalInvocationHint*, guint, const GValue* param_values, void*
{
GdkScreen* screen = gtk_widget_get_screen(win->m_wxwindow);
visual = gdk_x11_screen_lookup_visual(screen, xvi->visualid);
#ifdef __WXGTK3__
gtk_widget_set_visual(win->m_wxwindow, visual);
#else
GdkColormap* colormap = gdk_colormap_new(visual, false);
gtk_widget_set_colormap(win->m_wxwindow, colormap);
g_object_unref(colormap);
#endif
}
// remove hook
return false;
@@ -207,6 +229,10 @@ bool wxGLCanvas::Create(wxWindow *parent,
m_exposed = false;
m_noExpose = true;
m_nativeSizeEvent = true;
#ifdef __WXGTK3__
m_cairoPaintContext = NULL;
m_backgroundStyle = wxBG_STYLE_PAINT;
#endif
if ( !InitVisual(attribList) )
return false;
@@ -224,8 +250,12 @@ bool wxGLCanvas::Create(wxWindow *parent,
#if WXWIN_COMPATIBILITY_2_8
g_signal_connect(m_wxwindow, "realize", G_CALLBACK(gtk_glwindow_realized_callback), this);
#endif // WXWIN_COMPATIBILITY_2_8
#ifdef __WXGTK3__
g_signal_connect(m_wxwindow, "draw", G_CALLBACK(draw), this);
#else
g_signal_connect(m_wxwindow, "map", G_CALLBACK(gtk_glwindow_map_callback), this);
g_signal_connect(m_wxwindow, "expose_event", G_CALLBACK(gtk_glwindow_expose_callback), this);
#endif
g_signal_connect(m_widget, "size_allocate", G_CALLBACK(gtk_glcanvas_size_callback), this);
#if WXWIN_COMPATIBILITY_2_8
@@ -236,25 +266,38 @@ bool wxGLCanvas::Create(wxWindow *parent,
gtk_glwindow_realized_callback( m_wxwindow, this );
#endif // WXWIN_COMPATIBILITY_2_8
#ifndef __WXGTK3__
if (gtk_widget_get_mapped(m_wxwindow))
gtk_glwindow_map_callback( m_wxwindow, this );
#endif
return true;
}
bool wxGLCanvas::SetBackgroundStyle(wxBackgroundStyle /* style */)
{
return false;
}
Window wxGLCanvas::GetXWindow() const
{
GdkWindow* window = GTKGetDrawingWindow();
return window ? GDK_WINDOW_XWINDOW(window) : 0;
return window ? GDK_WINDOW_XID(window) : 0;
}
void wxGLCanvas::OnInternalIdle()
{
if (m_exposed)
{
#ifdef __WXGTK3__
GTKSendPaintEvents(m_cairoPaintContext);
cairo_destroy(m_cairoPaintContext);
m_cairoPaintContext = NULL;
#else
wxPaintEvent event( GetId() );
event.SetEventObject( this );
HandleWindowEvent( event );
#endif
m_exposed = false;
GetUpdateRegion().Clear();

View File

@@ -40,7 +40,11 @@
static inline bool UseNative()
{
// native gtk_link_button widget is only available in GTK+ 2.10 and later
#ifdef __WXGTK3__
return true;
#else
return !gtk_check_version(2, 10, 0);
#endif
}
// ============================================================================
@@ -241,7 +245,7 @@ wxColour wxHyperlinkCtrl::GetHoverColour() const
GdkWindow *wxHyperlinkCtrl::GTKGetWindow(wxArrayGdkWindows& windows) const
{
return UseNative() ? GTK_BUTTON(m_widget)->event_window
return UseNative() ? gtk_button_get_event_window(GTK_BUTTON(m_widget))
: wxGenericHyperlinkCtrl::GTKGetWindow(windows);
}

View File

@@ -82,8 +82,12 @@ namespace
inline bool UseNative()
{
#ifdef __WXGTK3__
return true;
#else
// native GtkInfoBar widget is only available in GTK+ 2.18 and later
return gtk_check_version(2, 18, 0) == 0;
#endif
}
} // anonymous namespace
@@ -275,7 +279,7 @@ void wxInfoBar::DoApplyWidgetStyle(GtkRcStyle *style)
wxInfoBarGeneric::DoApplyWidgetStyle(style);
if ( UseNative() )
gtk_widget_modify_style(m_impl->m_label, style);
GTKApplyStyle(m_impl->m_label, style);
}
#endif // wxUSE_INFOBAR

View File

@@ -25,15 +25,15 @@
#include "wx/arrstr.h"
#endif
#include "wx/gtk/private.h"
#include "wx/gtk/private/object.h"
#include "wx/gtk/treeentry_gtk.h"
#if wxUSE_TOOLTIPS
#include "wx/tooltip.h"
#endif
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/gtk2-compat.h"
#include "wx/gtk/private/object.h"
#include "wx/gtk/treeentry_gtk.h"
#include <gdk/gdkkeysyms.h>
#if GTK_CHECK_VERSION(3,0,0)
@@ -816,7 +816,7 @@ int wxListBox::DoListHitTest(const wxPoint& point) const
// need to translate from master window since it is in client coords
gint binx, biny;
gdk_window_get_geometry(gtk_tree_view_get_bin_window(m_treeview),
&binx, &biny, NULL, NULL, NULL);
&binx, &biny, NULL, NULL);
GtkTreePath* path;
if ( !gtk_tree_view_get_path_at_pos
@@ -857,6 +857,9 @@ GdkWindow *wxListBox::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
void wxListBox::DoApplyWidgetStyle(GtkRcStyle *style)
{
#ifdef __WXGTK3__
// don't know if this is even necessary, or how to do it
#else
if (m_hasBgCol && m_backgroundColour.IsOk())
{
GdkWindow *window = gtk_tree_view_get_bin_window(m_treeview);
@@ -867,8 +870,9 @@ void wxListBox::DoApplyWidgetStyle(GtkRcStyle *style)
gdk_window_clear( window );
}
}
#endif
gtk_widget_modify_style( GTK_WIDGET(m_treeview), style );
GTKApplyStyle(GTK_WIDGET(m_treeview), style);
}
wxSize wxListBox::DoGetBestSize() const

View File

@@ -24,7 +24,10 @@
#include "wx/accel.h"
#include "wx/stockitem.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/gtk2-compat.h"
#include "wx/gtk/private/mnemonics.h"
// we use normal item but with a special id for the menu title
@@ -138,7 +141,7 @@ DetachFromFrame(wxMenu* menu, wxFrame* frame)
// Note that wxGetTopLevelParent() is really needed because this frame
// can be an MDI child frame which is a fake frame and not a TLW at all
GtkWindow * const tlw = GTK_WINDOW(wxGetTopLevelParent(frame)->m_widget);
if (g_slist_find(menu->m_accel->acceleratables, tlw))
if (g_slist_find(gtk_accel_groups_from_object(G_OBJECT(tlw)), menu->m_accel))
gtk_window_remove_accel_group(tlw, menu->m_accel);
}
@@ -159,7 +162,7 @@ AttachToFrame(wxMenu* menu, wxFrame* frame)
if (menu->m_accel)
{
GtkWindow * const tlw = GTK_WINDOW(wxGetTopLevelParent(frame)->m_widget);
if (!g_slist_find(menu->m_accel->acceleratables, tlw))
if (!g_slist_find(gtk_accel_groups_from_object(G_OBJECT(tlw)), menu->m_accel))
gtk_window_add_accel_group(tlw, menu->m_accel);
}
@@ -899,6 +902,9 @@ wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
return NULL;
GtkWidget * const mitem = item->GetMenuItem();
#ifdef __WXGTK3__
gtk_menu_item_set_submenu(GTK_MENU_ITEM(mitem), NULL);
#else
if (!gtk_check_version(2,12,0))
{
// gtk_menu_item_remove_submenu() is deprecated since 2.12, but
@@ -913,6 +919,7 @@ wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
// instead.
gtk_menu_item_remove_submenu(GTK_MENU_ITEM(mitem));
}
#endif
gtk_widget_destroy(mitem);
item->SetMenuItem(NULL);

View File

@@ -20,7 +20,11 @@
#include "wx/image.h"
#endif
#ifdef __WXGTK3__
#include "wx/gtk/dc.h"
#else
#include "wx/gtk/dcclient.h"
#endif
#include <gtk/gtk.h>
#include "wx/gtk/private/gtk2-compat.h"
@@ -59,8 +63,24 @@ static wxColor LightContrastColour(const wxColour& c)
}
extern "C" {
static gboolean gtk_window_own_expose_callback(GtkWidget* widget, GdkEventExpose* gdk_event, wxMiniFrame* win)
#ifdef __WXGTK3__
static gboolean draw(GtkWidget* widget, cairo_t* cr, wxMiniFrame* win)
#else
static gboolean expose_event(GtkWidget* widget, GdkEventExpose* gdk_event, wxMiniFrame* win)
#endif
{
#ifdef __WXGTK3__
if (!gtk_cairo_should_draw_window(cr, gtk_widget_get_window(widget)))
return false;
GtkStyleContext* sc = gtk_widget_get_style_context(widget);
gtk_style_context_save(sc);
gtk_style_context_add_class(sc, GTK_STYLE_CLASS_BUTTON);
gtk_render_frame(sc, cr, 0, 0, win->m_width, win->m_height);
gtk_style_context_restore(sc);
wxGTKCairoDC dc(cr);
#else
if (!win->m_hasVMT || gdk_event->count > 0 ||
gdk_event->window != gtk_widget_get_window(widget))
{
@@ -75,20 +95,23 @@ static gboolean gtk_window_own_expose_callback(GtkWidget* widget, GdkEventExpose
0, 0,
win->m_width, win->m_height);
int style = win->GetWindowStyle();
wxClientDC dc(win);
wxDCImpl *impl = dc.GetImpl();
wxClientDCImpl *gtk_impl = wxDynamicCast( impl, wxClientDCImpl );
gtk_impl->m_gdkwindow = gtk_widget_get_window(widget); // Hack alert
#endif
int style = win->GetWindowStyle();
#ifndef __WXGTK3__
if (style & wxRESIZE_BORDER)
{
dc.SetBrush( *wxGREY_BRUSH );
dc.SetPen( *wxTRANSPARENT_PEN );
dc.DrawRectangle( win->m_width - 14, win->m_height-14, 14, 14 );
}
#endif
if (win->m_miniTitle && !win->GetTitle().empty())
{
@@ -133,6 +156,7 @@ gtk_window_button_press_callback(GtkWidget* widget, GdkEventButton* gdk_event, w
int y = (int)gdk_event->y;
int x = (int)gdk_event->x;
#ifndef __WXGTK3__
if ((style & wxRESIZE_BORDER) &&
(x > win->m_width-14) && (y > win->m_height-14))
{
@@ -153,6 +177,7 @@ gtk_window_button_press_callback(GtkWidget* widget, GdkEventButton* gdk_event, w
return TRUE;
}
#endif
if (win->m_miniTitle && (style & wxCLOSE_BOX))
{
@@ -269,14 +294,13 @@ gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event,
gdk_event->state = state;
}
int style = win->GetWindowStyle();
int x = (int)gdk_event->x;
int y = (int)gdk_event->y;
if (!win->m_isDragging)
{
if (style & wxRESIZE_BORDER)
#ifndef __WXGTK3__
if (win->GetWindowStyle() & wxRESIZE_BORDER)
{
if ((x > win->m_width-14) && (y > win->m_height-14))
gdk_window_set_cursor(gtk_widget_get_window(widget), gdk_cursor_new(GDK_BOTTOM_RIGHT_CORNER));
@@ -284,6 +308,7 @@ gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event,
gdk_window_set_cursor(gtk_widget_get_window(widget), NULL);
win->GTKUpdateCursor(false);
}
#endif
return TRUE;
}
@@ -382,8 +407,11 @@ bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title
}
/* these are called when the borders are drawn */
g_signal_connect_after(eventbox, "expose_event",
G_CALLBACK (gtk_window_own_expose_callback), this );
#ifdef __WXGTK3__
g_signal_connect_after(eventbox, "draw", G_CALLBACK(draw), this);
#else
g_signal_connect_after(eventbox, "expose_event", G_CALLBACK(expose_event), this);
#endif
/* these are required for dragging the mini frame around */
g_signal_connect (eventbox, "button_press_event",

View File

@@ -24,10 +24,10 @@
#include "wx/intl.h"
#endif
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/messagetype.h"
#include "wx/gtk/private/mnemonics.h"
#include <gtk/gtk.h>
#if wxUSE_LIBHILDON
#include <hildon-widgets/hildon-note.h>
@@ -168,7 +168,11 @@ void wxMessageDialog::GTKCreateMsgDialog()
wxString message;
#if GTK_CHECK_VERSION(2, 6, 0)
bool needsExtMessage = false;
if ( gtk_check_version(2, 6, 0) == NULL && !m_extendedMessage.empty() )
if (!m_extendedMessage.empty()
#ifndef __WXGTK3__
&& gtk_check_version(2, 6, 0) == NULL
#endif
)
{
message = m_message;
needsExtMessage = true;

View File

@@ -32,7 +32,7 @@
#include "wx/gtk/private/gtk2-compat.h"
#ifdef GDK_WINDOWING_X11
#include <X11/Xlib.h>
#include <gdk/gdkx.h>
#endif
// ============================================================================
@@ -95,7 +95,11 @@ bool wxNativeContainerWindow::Create(wxNativeContainerWindowHandle win)
bool wxNativeContainerWindow::Create(wxNativeContainerWindowId anid)
{
bool rc;
#ifdef __WXGTK3__
GdkWindow * const win = gdk_x11_window_foreign_new_for_display(gdk_display_get_default(), anid);
#else
GdkWindow * const win = gdk_window_foreign_new(anid);
#endif
if ( win )
{
rc = Create(win);

View File

@@ -24,18 +24,17 @@
#endif
#ifndef WX_PRECOMP
#include "wx/nonownedwnd.h"
#include "wx/dcclient.h"
#include "wx/dcmemory.h"
#include "wx/nonownedwnd.h"
#include "wx/region.h"
#endif // WX_PRECOMP
#include "wx/gtk/private.h"
#include <gdk/gdk.h>
#include "wx/graphics.h"
#include <gtk/gtk.h>
#include "wx/gtk/private/gtk2-compat.h"
// ----------------------------------------------------------------------------
// wxNonOwnedWindowShapeImpl: base class for region and path-based classes.
// ----------------------------------------------------------------------------
@@ -96,7 +95,7 @@ public:
private:
virtual bool DoSetShape(GdkWindow* window)
{
gdk_window_shape_combine_mask(window, NULL, 0, 0);
gdk_window_shape_combine_region(window, NULL, 0, 0);
return true;
}
@@ -176,7 +175,11 @@ private:
dc.SetBackground(*wxBLACK);
dc.Clear();
#ifdef __WXGTK3__
wxGraphicsContext* context = dc.GetGraphicsContext();
#else
wxScopedPtr<wxGraphicsContext> context(wxGraphicsContext::Create(dc));
#endif
context->SetBrush(*wxWHITE);
context->FillPath(path);
@@ -185,11 +188,16 @@ private:
virtual bool DoSetShape(GdkWindow *window)
{
GdkBitmap* bitmap = m_mask.GetBitmap();
if ( !bitmap )
if (m_mask.GetBitmap() == NULL)
return false;
gdk_window_shape_combine_mask(window, bitmap, 0, 0);
#ifdef __WXGTK3__
cairo_region_t* region = gdk_cairo_region_create_from_surface(m_mask.GetBitmap());
gdk_window_shape_combine_region(window, region, 0, 0);
cairo_region_destroy(region);
#else
gdk_window_shape_combine_mask(window, m_mask.GetBitmap(), 0, 0);
#endif
return true;
}
@@ -200,7 +208,11 @@ private:
event.Skip();
wxPaintDC dc(m_win);
#ifdef __WXGTK3__
wxGraphicsContext* context = dc.GetGraphicsContext();
#else
wxScopedPtr<wxGraphicsContext> context(wxGraphicsContext::Create(dc));
#endif
context->SetPen(wxPen(*wxLIGHT_GREY, 2));
context->StrokePath(m_path);
}

View File

@@ -25,7 +25,9 @@
#include "wx/imaglist.h"
#include "wx/fontutil.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/gtk2-compat.h"
//-----------------------------------------------------------------------------
// wxGtkNotebookPage
@@ -455,12 +457,16 @@ bool wxNotebook::InsertPage( size_t position,
gtk_notebook_insert_page(notebook, win->m_widget, pageData->m_box, position);
/* apply current style */
#ifdef __WXGTK3__
GTKApplyStyle(pageData->m_label, NULL);
#else
GtkRcStyle *style = GTKCreateWidgetStyle();
if ( style )
{
gtk_widget_modify_style(pageData->m_label, style);
g_object_unref(style);
}
#endif
if (select && GetPageCount() > 1)
{
@@ -580,15 +586,19 @@ bool wxNotebook::DoPhase( int WXUNUSED(nPhase) )
void wxNotebook::DoApplyWidgetStyle(GtkRcStyle *style)
{
gtk_widget_modify_style(m_widget, style);
GTKApplyStyle(m_widget, style);
for (size_t i = GetPageCount(); i--;)
gtk_widget_modify_style(GetNotebookPage(i)->m_label, style);
GTKApplyStyle(GetNotebookPage(i)->m_label, style);
}
GdkWindow *wxNotebook::GTKGetWindow(wxArrayGdkWindows& windows) const
{
windows.push_back(gtk_widget_get_window(m_widget));
#ifdef __WXGTK3__
// no access to internal GdkWindows
#else
windows.push_back(GTK_NOTEBOOK(m_widget)->event_window);
#endif
return NULL;
}

View File

@@ -113,10 +113,13 @@ bool wxPopupWindow::Create( wxWindow *parent, int style )
if (GTK_IS_WINDOW (toplevel))
{
#if GTK_CHECK_VERSION(2,10,0)
#ifndef __WXGTK3__
if (!gtk_check_version(2,10,0))
gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)), GTK_WINDOW (m_widget));
#endif
{
gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)), GTK_WINDOW (m_widget));
}
#endif
gtk_window_set_transient_for (GTK_WINDOW (m_widget), GTK_WINDOW (toplevel));
}
gtk_window_set_resizable (GTK_WINDOW (m_widget), FALSE);
@@ -125,7 +128,7 @@ bool wxPopupWindow::Create( wxWindow *parent, int style )
g_signal_connect (m_widget, "delete_event",
G_CALLBACK (gtk_dialog_delete_callback), this);
m_wxwindow = wxPizza::New(m_windowStyle);
m_wxwindow = wxPizza::New();
gtk_widget_show( m_wxwindow );
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );

View File

@@ -86,8 +86,12 @@ private:
bool wxGtkPrintModule::OnInit()
{
#ifndef __WXGTK3__
if (gtk_check_version(2,10,0) == NULL)
#endif
{
wxPrintFactory::SetPrintFactory( new wxGtkPrintFactory );
}
return true;
}
@@ -1705,9 +1709,11 @@ void wxGtkPrinterDCImpl::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoor
y = wxCoord(YLOG2DEV(y));
int bw = bitmap.GetWidth();
int bh = bitmap.GetHeight();
#ifndef __WXGTK3__
wxBitmap bmpSource = bitmap; // we need a non-const instance.
if (!useMask && !bitmap.HasPixbuf() && bitmap.GetMask())
bmpSource.SetMask(NULL);
#endif
cairo_save(m_cairo);
@@ -1719,12 +1725,16 @@ void wxGtkPrinterDCImpl::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoor
wxDouble scaleY = (wxDouble) YLOG2DEVREL(bh) / (wxDouble) bh;
cairo_scale(m_cairo, scaleX, scaleY);
#ifdef __WXGTK3__
bitmap.Draw(m_cairo, 0, 0, useMask, &m_textForegroundColour, &m_textBackgroundColour);
#else
gdk_cairo_set_source_pixbuf(m_cairo, bmpSource.GetPixbuf(), 0, 0);
cairo_pattern_set_filter(cairo_get_source(m_cairo), CAIRO_FILTER_NEAREST);
// Use the original size here since the context is scaled already.
cairo_rectangle(m_cairo, 0, 0, bw, bh);
// Fill the rectangle using the pattern.
cairo_fill(m_cairo);
#endif
CalcBoundingBox(0,0);
CalcBoundingBox(bw,bh);

View File

@@ -28,6 +28,7 @@
#include "wx/module.h"
#endif
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
// ----------------------------------------------------------------------------
@@ -139,15 +140,28 @@ static void CreateHeaderButtons()
GtkTreeViewColumn *column = gtk_tree_view_column_new();
gtk_tree_view_append_column(GTK_TREE_VIEW(treewidget), column);
#ifdef __WXGTK3__
s_first_button = gtk_tree_view_column_get_button(column);
#else
s_first_button = column->button;
#endif
wxASSERT(s_first_button);
column = gtk_tree_view_column_new();
gtk_tree_view_append_column(GTK_TREE_VIEW(treewidget), column);
#ifdef __WXGTK3__
s_other_button = gtk_tree_view_column_get_button(column);
#else
s_other_button = column->button;
#endif
column = gtk_tree_view_column_new();
gtk_tree_view_append_column(GTK_TREE_VIEW(treewidget), column);
#ifdef __WXGTK3__
s_last_button = gtk_tree_view_column_get_button(column);
#else
s_last_button = column->button;
#endif
}
GtkWidget *GetHeaderButtonWidgetFirst()
@@ -191,13 +205,22 @@ GtkWidget * GetRadioButtonWidget()
return s_button;
}
GtkWidget* GetSplitterWidget()
GtkWidget* GetSplitterWidget(wxOrientation orient)
{
static GtkWidget* widget;
static GtkWidget* widgets[2];
const GtkOrientation gtkOrient =
orient == wxHORIZONTAL ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL;
GtkWidget*& widget = widgets[gtkOrient];
if (widget == NULL)
{
widget = gtk_vpaned_new();
#ifdef __WXGTK3__
widget = gtk_paned_new(gtkOrient);
#else
if (orient == wxHORIZONTAL)
widget = gtk_hpaned_new();
else
widget = gtk_vpaned_new();
#endif
gtk_container_add(GetContainer(), widget);
gtk_widget_realize(widget);
}
@@ -236,7 +259,6 @@ GtkWidget *GetTreeWidget()
return s_tree;
}
// Module for destroying created widgets
class WidgetsCleanupModule : public wxModule
{

View File

@@ -18,7 +18,9 @@
#include "wx/tooltip.h"
#endif
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/gtk2-compat.h"
#include <gdk/gdkkeysyms.h>
#if GTK_CHECK_VERSION(3,0,0)
@@ -547,8 +549,8 @@ void wxRadioBox::DoApplyWidgetStyle(GtkRcStyle *style)
{
GtkWidget *widget = GTK_WIDGET( node->GetData()->button );
gtk_widget_modify_style( widget, style );
gtk_widget_modify_style(gtk_bin_get_child(GTK_BIN(widget)), style);
GTKApplyStyle(widget, style);
GTKApplyStyle(gtk_bin_get_child(GTK_BIN(widget)), style);
node = node->GetNext();
}

View File

@@ -14,7 +14,9 @@
#include "wx/radiobut.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/gtk2-compat.h"
//-----------------------------------------------------------------------------
// data
@@ -167,14 +169,14 @@ bool wxRadioButton::Enable( bool enable )
void wxRadioButton::DoApplyWidgetStyle(GtkRcStyle *style)
{
gtk_widget_modify_style(m_widget, style);
gtk_widget_modify_style(gtk_bin_get_child(GTK_BIN(m_widget)), style);
GTKApplyStyle(m_widget, style);
GTKApplyStyle(gtk_bin_get_child(GTK_BIN(m_widget)), style);
}
GdkWindow *
wxRadioButton::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{
return GTK_BUTTON(m_widget)->event_window;
return gtk_button_get_event_window(GTK_BUTTON(m_widget));
}
// static

View File

@@ -21,12 +21,7 @@
#include "wx/region.h"
#ifndef WX_PRECOMP
#include "wx/log.h"
#endif
#include "wx/gtk/private.h"
#include <gdk/gdk.h>
// ----------------------------------------------------------------------------
// wxRegionRefData: private class containing the information about the region
@@ -43,24 +38,38 @@ public:
wxRegionRefData(const wxRegionRefData& refData)
: wxGDIRefData()
{
#ifdef __WXGTK3__
m_region = cairo_region_copy(refData.m_region);
#else
m_region = gdk_region_copy(refData.m_region);
#endif
}
virtual ~wxRegionRefData()
{
if (m_region)
{
#ifdef __WXGTK3__
cairo_region_destroy(m_region);
#else
gdk_region_destroy( m_region );
#endif
}
}
#ifdef __WXGTK3__
cairo_region_t* m_region;
#else
GdkRegion *m_region;
#endif
};
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
#define M_REGIONDATA ((wxRegionRefData *)m_refData)
#define M_REGIONDATA_OF(rgn) ((wxRegionRefData *)(rgn.m_refData))
#define M_REGIONDATA static_cast<wxRegionRefData*>(m_refData)
#define M_REGIONDATA_OF(r) static_cast<wxRegionRefData*>(r.m_refData)
IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject)
IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator,wxObject)
@@ -69,8 +78,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator,wxObject)
// wxRegion construction
// ----------------------------------------------------------------------------
#define M_REGIONDATA ((wxRegionRefData *)m_refData)
void wxRegion::InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
{
GdkRectangle rect;
@@ -81,18 +88,74 @@ void wxRegion::InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
m_refData = new wxRegionRefData();
#ifdef __WXGTK3__
M_REGIONDATA->m_region = cairo_region_create_rectangle(&rect);
#else
M_REGIONDATA->m_region = gdk_region_rectangle( &rect );
#endif
}
wxRegion::wxRegion( GdkRegion *region )
#ifndef __WXGTK3__
wxRegion::wxRegion(const GdkRegion* region)
{
m_refData = new wxRegionRefData();
M_REGIONDATA->m_region = gdk_region_copy( region );
M_REGIONDATA->m_region = gdk_region_copy(const_cast<GdkRegion*>(region));
}
#endif
wxRegion::wxRegion( size_t n, const wxPoint *points,
wxPolygonFillMode fillStyle )
{
#ifdef __WXGTK3__
// Make a cairo path from the points, draw it onto an image surface, use
// gdk_cairo_region_create_from_surface() to get a cairo region
// need at least 3 points to make a useful polygon
if (n < 3)
return;
// get bounding rect
int min_x = points[0].x;
int max_x = min_x;
int min_y = points[0].y;
int max_y = min_y;
size_t i;
for (i = 1; i < n; i++)
{
const int x = points[i].x;
if (min_x > x)
min_x = x;
else if (max_x < x)
max_x = x;
const int y = points[i].y;
if (min_y > y)
min_y = y;
else if (max_y < y)
max_y = y;
}
const int w = max_x - min_x + 1;
const int h = max_y - min_y + 1;
// make surface just big enough to contain polygon (A1 is native format
// for gdk_cairo_region_create_from_surface)
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_A1, w, h);
memset(cairo_image_surface_get_data(surface), 0, cairo_image_surface_get_stride(surface) * h);
cairo_surface_mark_dirty(surface);
cairo_surface_set_device_offset(surface, -min_x, -min_y);
cairo_t* cr = cairo_create(surface);
cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
if (fillStyle == wxODDEVEN_RULE)
cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
// make path
cairo_move_to(cr, points[0].x, points[0].y);
for (i = 1; i < n; i++)
cairo_line_to(cr, points[i].x, points[i].y);
cairo_close_path(cr);
cairo_fill(cr);
cairo_destroy(cr);
cairo_surface_flush(surface);
m_refData = new wxRegionRefData;
M_REGIONDATA->m_region = gdk_cairo_region_create_from_surface(surface);
cairo_surface_destroy(surface);
#else
GdkPoint *gdkpoints = new GdkPoint[n];
for ( size_t i = 0 ; i < n ; i++ )
{
@@ -113,6 +176,7 @@ wxRegion::wxRegion( size_t n, const wxPoint *points,
M_REGIONDATA->m_region = reg;
delete [] gdkpoints;
#endif
}
wxRegion::~wxRegion()
@@ -122,12 +186,14 @@ wxRegion::~wxRegion()
wxGDIRefData *wxRegion::CreateGDIRefData() const
{
return new wxRegionRefData;
// should never be called
wxFAIL;
return NULL;
}
wxGDIRefData *wxRegion::CloneGDIRefData(const wxGDIRefData *data) const
{
return new wxRegionRefData(*(wxRegionRefData *)data);
return new wxRegionRefData(*static_cast<const wxRegionRefData*>(data));
}
// ----------------------------------------------------------------------------
@@ -136,8 +202,13 @@ wxGDIRefData *wxRegion::CloneGDIRefData(const wxGDIRefData *data) const
bool wxRegion::DoIsEqual(const wxRegion& region) const
{
#ifdef __WXGTK3__
return cairo_region_equal(
M_REGIONDATA->m_region, M_REGIONDATA_OF(region)->m_region);
#else
return gdk_region_equal(M_REGIONDATA->m_region,
M_REGIONDATA_OF(region)->m_region) != 0;
#endif
}
// ----------------------------------------------------------------------------
@@ -171,7 +242,11 @@ bool wxRegion::DoUnionWithRect(const wxRect& r)
rect.width = r.width;
rect.height = r.height;
#ifdef __WXGTK3__
cairo_region_union_rectangle(M_REGIONDATA->m_region, &rect);
#else
gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect );
#endif
}
return true;
@@ -179,16 +254,20 @@ bool wxRegion::DoUnionWithRect(const wxRect& r)
bool wxRegion::DoUnionWithRegion( const wxRegion& region )
{
wxCHECK_MSG( region.IsOk(), false, wxT("invalid region") );
if (!m_refData)
if (region.m_refData == NULL)
{ }
else if (m_refData == NULL)
{
m_refData = new wxRegionRefData(*M_REGIONDATA_OF(region));
}
else
{
AllocExclusive();
#ifdef __WXGTK3__
cairo_region_union(M_REGIONDATA->m_region, M_REGIONDATA_OF(region)->m_region);
#else
gdk_region_union( M_REGIONDATA->m_region, region.GetRegion() );
#endif
}
return true;
@@ -196,43 +275,41 @@ bool wxRegion::DoUnionWithRegion( const wxRegion& region )
bool wxRegion::DoIntersect( const wxRegion& region )
{
wxCHECK_MSG( region.IsOk(), false, wxT("invalid region") );
if (!m_refData)
{
// intersecting with invalid region doesn't make sense
if (region.m_refData == NULL || m_refData == NULL)
return false;
}
AllocExclusive();
#ifdef __WXGTK3__
cairo_region_intersect(M_REGIONDATA->m_region, M_REGIONDATA_OF(region)->m_region);
#else
gdk_region_intersect( M_REGIONDATA->m_region, region.GetRegion() );
#endif
return true;
}
bool wxRegion::DoSubtract( const wxRegion& region )
{
wxCHECK_MSG( region.IsOk(), false, wxT("invalid region") );
if (!m_refData)
{
// subtracting from an invalid region doesn't make sense
if (region.m_refData == NULL || m_refData == NULL)
return false;
}
AllocExclusive();
#ifdef __WXGTK3__
cairo_region_subtract(M_REGIONDATA->m_region, M_REGIONDATA_OF(region)->m_region);
#else
gdk_region_subtract( M_REGIONDATA->m_region, region.GetRegion() );
#endif
return true;
}
bool wxRegion::DoXor( const wxRegion& region )
{
wxCHECK_MSG( region.IsOk(), false, wxT("invalid region") );
if (!m_refData)
if (region.m_refData == NULL)
{ }
else if (m_refData == NULL)
{
// XOR-ing with an invalid region is the same as XOR-ing with an empty
// one, i.e. it is simply a copy.
@@ -242,7 +319,11 @@ bool wxRegion::DoXor( const wxRegion& region )
{
AllocExclusive();
#ifdef __WXGTK3__
cairo_region_xor(M_REGIONDATA->m_region, M_REGIONDATA_OF(region)->m_region);
#else
gdk_region_xor( M_REGIONDATA->m_region, region.GetRegion() );
#endif
}
return true;
@@ -254,7 +335,11 @@ bool wxRegion::DoOffset( wxCoord x, wxCoord y )
AllocExclusive();
#ifdef __WXGTK3__
cairo_region_translate(M_REGIONDATA->m_region, x, y);
#else
gdk_region_offset( M_REGIONDATA->m_region, x, y );
#endif
return true;
}
@@ -268,7 +353,11 @@ bool wxRegion::DoGetBox( wxCoord &x, wxCoord &y, wxCoord &w, wxCoord &h ) const
if ( m_refData )
{
GdkRectangle rect;
#ifdef __WXGTK3__
cairo_region_get_extents(M_REGIONDATA->m_region, &rect);
#else
gdk_region_get_clipbox( M_REGIONDATA->m_region, &rect );
#endif
x = rect.x;
y = rect.y;
w = rect.width;
@@ -289,21 +378,23 @@ bool wxRegion::DoGetBox( wxCoord &x, wxCoord &y, wxCoord &w, wxCoord &h ) const
bool wxRegion::IsEmpty() const
{
if (!m_refData)
return true;
return gdk_region_empty( M_REGIONDATA->m_region ) != 0;
#ifdef __WXGTK3__
return m_refData == NULL || cairo_region_is_empty(M_REGIONDATA->m_region);
#else
return m_refData == NULL || gdk_region_empty(M_REGIONDATA->m_region);
#endif
}
wxRegionContain wxRegion::DoContainsPoint( wxCoord x, wxCoord y ) const
{
if (!m_refData)
#ifdef __WXGTK3__
if (m_refData == NULL || !cairo_region_contains_point(M_REGIONDATA->m_region, x, y))
#else
if (m_refData == NULL || !gdk_region_point_in(M_REGIONDATA->m_region, x, y))
#endif
return wxOutRegion;
if (gdk_region_point_in( M_REGIONDATA->m_region, x, y ))
return wxInRegion;
else
return wxOutRegion;
return wxInRegion;
}
wxRegionContain wxRegion::DoContainsRect(const wxRect& r) const
@@ -316,6 +407,14 @@ wxRegionContain wxRegion::DoContainsRect(const wxRect& r) const
rect.y = r.y;
rect.width = r.width;
rect.height = r.height;
#ifdef __WXGTK3__
switch (cairo_region_contains_rectangle(M_REGIONDATA->m_region, &rect))
{
case CAIRO_REGION_OVERLAP_IN: return wxInRegion;
case CAIRO_REGION_OVERLAP_PART: return wxPartRegion;
default: break;
}
#else
GdkOverlapType res = gdk_region_rect_in( M_REGIONDATA->m_region, &rect );
switch (res)
{
@@ -323,10 +422,15 @@ wxRegionContain wxRegion::DoContainsRect(const wxRect& r) const
case GDK_OVERLAP_RECTANGLE_OUT: return wxOutRegion;
case GDK_OVERLAP_RECTANGLE_PART: return wxPartRegion;
}
#endif
return wxOutRegion;
}
#ifdef __WXGTK3__
cairo_region_t* wxRegion::GetRegion() const
#else
GdkRegion *wxRegion::GetRegion() const
#endif
{
if (!m_refData)
return NULL;
@@ -366,6 +470,27 @@ void wxRegionIterator::CreateRects( const wxRegion& region )
wxDELETEA(m_rects);
m_numRects = 0;
#ifdef __WXGTK3__
cairo_region_t* cairoRegion = region.GetRegion();
if (cairoRegion == NULL)
return;
m_numRects = cairo_region_num_rectangles(cairoRegion);
if (m_numRects)
{
m_rects = new wxRect[m_numRects];
for (int i = 0; i < m_numRects; i++)
{
GdkRectangle gr;
cairo_region_get_rectangle(cairoRegion, i, &gr);
wxRect &wr = m_rects[i];
wr.x = gr.x;
wr.y = gr.y;
wr.width = gr.width;
wr.height = gr.height;
}
}
#else
GdkRegion *gdkregion = region.GetRegion();
if (!gdkregion)
return;
@@ -387,6 +512,7 @@ void wxRegionIterator::CreateRects( const wxRegion& region )
}
}
g_free( gdkrects );
#endif
}
void wxRegionIterator::Reset( const wxRegion& region )

View File

@@ -34,10 +34,13 @@
#endif
#include "wx/dcgraph.h"
#ifndef __WXGTK3__
#include "wx/gtk/dc.h"
#include "wx/gtk/private.h"
#endif
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/gtk2-compat.h"
// ----------------------------------------------------------------------------
// wxRendererGTK: our wxRendererNative implementation
@@ -140,7 +143,28 @@ wxRendererNative& wxRendererNative::GetDefault()
return s_rendererGTK;
}
static GdkWindow* wxGetGdkWindowForDC(wxWindow* win, wxDC& dc)
#ifdef __WXGTK3__
#define NULL_RECT
typedef cairo_t wxGTKDrawable;
static cairo_t* wxGetGTKDrawable(wxWindow*, const wxDC& dc)
{
wxGraphicsContext* gc = dc.GetGraphicsContext();
wxCHECK_MSG(gc, NULL, "cannot use wxRendererNative on wxDC of this type");
return static_cast<cairo_t*>(gc->GetNativeContext());
}
static const GtkStateFlags stateTypeToFlags[] = {
GTK_STATE_FLAG_NORMAL, GTK_STATE_FLAG_ACTIVE, GTK_STATE_FLAG_PRELIGHT,
GTK_STATE_FLAG_SELECTED, GTK_STATE_FLAG_INSENSITIVE, GTK_STATE_FLAG_INCONSISTENT,
GTK_STATE_FLAG_FOCUSED
};
#else
#define NULL_RECT NULL,
typedef GdkWindow wxGTKDrawable;
static GdkWindow* wxGetGTKDrawable(wxWindow* win, wxDC& dc)
{
GdkWindow* gdk_window = NULL;
@@ -150,14 +174,12 @@ static GdkWindow* wxGetGdkWindowForDC(wxWindow* win, wxDC& dc)
else
#endif
{
#if wxUSE_NEW_DC
wxDCImpl *impl = dc.GetImpl();
wxGTKDCImpl *gtk_impl = wxDynamicCast( impl, wxGTKDCImpl );
if (gtk_impl)
gdk_window = gtk_impl->GetGDKWindow();
#else
gdk_window = dc.GetGDKWindow();
#endif
else
wxFAIL_MSG("cannot use wxRendererNative on wxDC of this type");
}
#if !wxUSE_GRAPHICS_CONTEXT
@@ -166,6 +188,7 @@ static GdkWindow* wxGetGdkWindowForDC(wxWindow* win, wxDC& dc)
return gdk_window;
}
#endif
// ----------------------------------------------------------------------------
// list/tree controls drawing
@@ -179,17 +202,12 @@ wxRendererGTK::DrawHeaderButton(wxWindow *win,
wxHeaderSortIconType sortArrow,
wxHeaderButtonParams* params)
{
GtkWidget *button = wxGTKPrivate::GetHeaderButtonWidget();
if (flags & wxCONTROL_SPECIAL)
button = wxGTKPrivate::GetHeaderButtonWidgetFirst();
if (flags & wxCONTROL_DIRTY)
button = wxGTKPrivate::GetHeaderButtonWidgetLast();
GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
wxASSERT_MSG( gdk_window,
wxT("cannot use wxRendererNative on wxDC of this type") );
int x_diff = 0;
if (win->GetLayoutDirection() == wxLayout_RightToLeft)
x_diff = rect.width;
@@ -203,6 +221,19 @@ wxRendererGTK::DrawHeaderButton(wxWindow *win,
state = GTK_STATE_PRELIGHT;
}
#ifdef __WXGTK3__
cairo_t* cr = wxGetGTKDrawable(win, dc);
if (cr)
{
GtkStyleContext* sc = gtk_widget_get_style_context(button);
gtk_style_context_save(sc);
gtk_style_context_set_state(sc, stateTypeToFlags[state]);
gtk_render_background(sc, cr, rect.x - x_diff+4, rect.y+4, rect.width-8, rect.height-8);
gtk_render_frame(sc, cr, rect.x - x_diff+4, rect.y+4, rect.width-8, rect.height-8);
gtk_style_context_restore(sc);
}
#else
GdkWindow* gdk_window = wxGetGTKDrawable(win, dc);
gtk_paint_box
(
gtk_widget_get_style(button),
@@ -214,6 +245,7 @@ wxRendererGTK::DrawHeaderButton(wxWindow *win,
"button",
dc.LogicalToDeviceX(rect.x) - x_diff, rect.y, rect.width, rect.height
);
#endif
return DrawHeaderButtonContents(win, dc, rect, flags, sortArrow, params);
}
@@ -223,7 +255,11 @@ int wxRendererGTK::GetHeaderButtonHeight(wxWindow *WXUNUSED(win))
GtkWidget *button = wxGTKPrivate::GetHeaderButtonWidget();
GtkRequisition req;
#ifdef __WXGTK3__
gtk_widget_get_preferred_height(button, NULL, &req.height);
#else
GTK_WIDGET_GET_CLASS(button)->size_request(button, &req);
#endif
return req.height;
}
@@ -242,10 +278,6 @@ wxRendererGTK::DrawTreeItemButton(wxWindow* win,
{
GtkWidget *tree = wxGTKPrivate::GetTreeWidget();
GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
wxASSERT_MSG( gdk_window,
wxT("cannot use wxRendererNative on wxDC of this type") );
GtkStateType state;
if ( flags & wxCONTROL_CURRENT )
state = GTK_STATE_PRELIGHT;
@@ -256,7 +288,19 @@ wxRendererGTK::DrawTreeItemButton(wxWindow* win,
if (win->GetLayoutDirection() == wxLayout_RightToLeft)
x_diff = rect.width;
#ifdef __WXGTK3__
cairo_t* cr = wxGetGTKDrawable(win, dc);
if (cr)
{
gtk_widget_set_state_flags(tree, stateTypeToFlags[state], true);
GtkStyleContext* sc = gtk_widget_get_style_context(tree);
gtk_render_expander(sc, cr, rect.x - x_diff, rect.y, rect.width, rect.height);
}
#else
// x and y parameters specify the center of the expander
GdkWindow* gdk_window = wxGetGTKDrawable(win, dc);
if (gdk_window == NULL)
return;
gtk_paint_expander
(
gtk_widget_get_style(tree),
@@ -270,6 +314,7 @@ wxRendererGTK::DrawTreeItemButton(wxWindow* win,
flags & wxCONTROL_EXPANDED ? GTK_EXPANDER_EXPANDED
: GTK_EXPANDER_COLLAPSED
);
#endif
}
@@ -320,15 +365,16 @@ wxRendererGTK::DrawSplitterSash(wxWindow* win,
return;
}
GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
wxASSERT_MSG( gdk_window,
wxT("cannot use wxRendererNative on wxDC of this type") );
wxCoord full_size = GetGtkSplitterFullSize(wxGTKPrivate::GetSplitterWidget());
wxGTKDrawable* drawable = wxGetGTKDrawable(win, dc);
if (drawable == NULL)
return;
// are we drawing vertical or horizontal splitter?
const bool isVert = orient == wxVERTICAL;
GtkWidget* widget = wxGTKPrivate::GetSplitterWidget(orient);
const int full_size = GetGtkSplitterFullSize(widget);
GdkRectangle rect;
if ( isVert )
@@ -350,6 +396,18 @@ wxRendererGTK::DrawSplitterSash(wxWindow* win,
if (win->GetLayoutDirection() == wxLayout_RightToLeft)
x_diff = rect.width;
#ifdef __WXGTK3__
cairo_t* cr = wxGetGTKDrawable(win, dc);
if (cr)
{
gtk_widget_set_state_flags(widget, stateTypeToFlags[flags & wxCONTROL_CURRENT ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL], true);
GtkStyleContext* sc = gtk_widget_get_style_context(widget);
gtk_render_handle(sc, cr, rect.x - x_diff, rect.y, rect.width, rect.height);
}
#else
GdkWindow* gdk_window = wxGetGTKDrawable(win, dc);
if (gdk_window == NULL)
return;
gtk_paint_handle
(
gtk_widget_get_style(win->m_wxwindow),
@@ -365,6 +423,7 @@ wxRendererGTK::DrawSplitterSash(wxWindow* win,
rect.height,
isVert ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL
);
#endif
}
void
@@ -380,19 +439,12 @@ wxRendererGTK::DrawDropArrow(wxWindow* win,
// work for wxMemoryDC. So that is why we assume wxDC
// is wxWindowDC (wxClientDC, wxMemoryDC and wxPaintDC
// are derived from it) and use its m_window.
GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
wxASSERT_MSG( gdk_window,
wxT("cannot use wxRendererNative on wxDC of this type") );
// draw arrow so that there is even space horizontally
// on both sides
int arrowX = rect.width/4 + 1;
int arrowWidth = rect.width - (arrowX*2);
// scale arrow's height accoording to the width
int arrowHeight = rect.width/3;
int arrowY = (rect.height-arrowHeight)/2 +
((rect.height-arrowHeight) & 1);
const int size = rect.width / 2;
const int x = rect.x + (size + 1) / 2;
const int y = rect.y + (rect.height - size + 1) / 2;
GtkStateType state;
@@ -405,6 +457,18 @@ wxRendererGTK::DrawDropArrow(wxWindow* win,
else
state = GTK_STATE_NORMAL;
#ifdef __WXGTK3__
cairo_t* cr = wxGetGTKDrawable(win, dc);
if (cr)
{
gtk_widget_set_state_flags(button, stateTypeToFlags[state], true);
GtkStyleContext* sc = gtk_widget_get_style_context(button);
gtk_render_arrow(sc, cr, G_PI, x, y, size);
}
#else
GdkWindow* gdk_window = wxGetGTKDrawable(win, dc);
if (gdk_window == NULL)
return;
// draw arrow on button
gtk_paint_arrow
(
@@ -417,11 +481,10 @@ wxRendererGTK::DrawDropArrow(wxWindow* win,
"arrow",
GTK_ARROW_DOWN,
FALSE,
rect.x + arrowX,
rect.y + arrowY,
arrowWidth,
arrowHeight
x, y,
size, size
);
#endif
}
void
@@ -455,16 +518,13 @@ wxRendererGTK::DrawCheckBox(wxWindow* win,
{
GtkWidget *button = wxGTKPrivate::GetCheckButtonWidget();
GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
wxASSERT_MSG( gdk_window,
wxT("cannot use wxRendererNative on wxDC of this type") );
gint indicator_size, indicator_spacing;
gtk_widget_style_get(button,
"indicator_size", &indicator_size,
"indicator_spacing", &indicator_spacing,
NULL);
#ifndef __WXGTK3__
GtkStateType state;
if ( flags & wxCONTROL_PRESSED )
@@ -484,6 +544,35 @@ wxRendererGTK::DrawCheckBox(wxWindow* win,
shadow_type = GTK_SHADOW_IN;
else
shadow_type = GTK_SHADOW_OUT;
#endif
#ifdef __WXGTK3__
cairo_t* cr = wxGetGTKDrawable(win, dc);
if (cr)
{
int stateFlags = GTK_STATE_FLAG_NORMAL;
if (flags & wxCONTROL_CHECKED)
stateFlags = GTK_STATE_FLAG_ACTIVE;
if (flags & wxCONTROL_DISABLED)
stateFlags |= GTK_STATE_FLAG_INSENSITIVE;
if (flags & wxCONTROL_UNDETERMINED)
stateFlags |= GTK_STATE_FLAG_INCONSISTENT;
if (flags & wxCONTROL_CURRENT)
stateFlags |= GTK_STATE_FLAG_PRELIGHT;
GtkStyleContext* sc = gtk_widget_get_style_context(button);
gtk_style_context_save(sc);
gtk_style_context_set_state(sc, GtkStateFlags(stateFlags));
gtk_style_context_add_class(sc, GTK_STYLE_CLASS_CHECK);
gtk_render_check(sc, cr,
rect.x + (rect.width - indicator_size) / 2,
rect.y + (rect.height - indicator_size) / 2,
indicator_size, indicator_size);
gtk_style_context_restore(sc);
}
#else
GdkWindow* gdk_window = wxGetGTKDrawable(win, dc);
if (gdk_window == NULL)
return;
gtk_paint_check
(
@@ -498,6 +587,7 @@ wxRendererGTK::DrawCheckBox(wxWindow* win,
dc.LogicalToDeviceY(rect.y) + indicator_spacing,
indicator_size, indicator_size
);
#endif
}
void
@@ -508,10 +598,6 @@ wxRendererGTK::DrawPushButton(wxWindow* win,
{
GtkWidget *button = wxGTKPrivate::GetButtonWidget();
GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
wxASSERT_MSG( gdk_window,
wxT("cannot use wxRendererNative on wxDC of this type") );
// draw button
GtkStateType state;
@@ -524,6 +610,22 @@ wxRendererGTK::DrawPushButton(wxWindow* win,
else
state = GTK_STATE_NORMAL;
#ifdef __WXGTK3__
cairo_t* cr = wxGetGTKDrawable(win, dc);
if (cr)
{
GtkStyleContext* sc = gtk_widget_get_style_context(button);
gtk_style_context_save(sc);
gtk_style_context_set_state(sc, stateTypeToFlags[state]);
gtk_render_background(sc, cr, rect.x, rect.y, rect.width, rect.height);
gtk_render_frame(sc, cr, rect.x, rect.y, rect.width, rect.height);
gtk_style_context_restore(sc);
}
#else
GdkWindow* gdk_window = wxGetGTKDrawable(win, dc);
if (gdk_window == NULL)
return;
gtk_paint_box
(
gtk_widget_get_style(button),
@@ -538,6 +640,7 @@ wxRendererGTK::DrawPushButton(wxWindow* win,
rect.width,
rect.height
);
#endif
}
void
@@ -546,11 +649,9 @@ wxRendererGTK::DrawItemSelectionRect(wxWindow* win,
const wxRect& rect,
int flags )
{
GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
wxASSERT_MSG( gdk_window,
wxT("cannot use wxRendererNative on wxDC of this type") );
wxGTKDrawable* drawable = wxGetGTKDrawable(win, dc);
if (flags & wxCONTROL_SELECTED)
if (drawable && (flags & wxCONTROL_SELECTED))
{
int x_diff = 0;
if (win->GetLayoutDirection() == wxLayout_RightToLeft)
@@ -559,10 +660,10 @@ wxRendererGTK::DrawItemSelectionRect(wxWindow* win,
// the wxCONTROL_FOCUSED state is deduced
// directly from the m_wxwindow by GTK+
gtk_paint_flat_box(gtk_widget_get_style(wxGTKPrivate::GetTreeWidget()),
gdk_window,
drawable,
GTK_STATE_SELECTED,
GTK_SHADOW_NONE,
NULL,
NULL_RECT
win->m_wxwindow,
"cell_even",
dc.LogicalToDeviceX(rect.x) - x_diff,
@@ -577,9 +678,9 @@ wxRendererGTK::DrawItemSelectionRect(wxWindow* win,
void wxRendererGTK::DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)
{
GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
wxASSERT_MSG( gdk_window,
wxT("cannot use wxRendererNative on wxDC of this type") );
wxGTKDrawable* drawable = wxGetGTKDrawable(win, dc);
if (drawable == NULL)
return;
GtkStateType state;
if (flags & wxCONTROL_SELECTED)
@@ -587,24 +688,36 @@ void wxRendererGTK::DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, i
else
state = GTK_STATE_NORMAL;
#ifdef __WXGTK3__
GtkStyleContext* sc = gtk_widget_get_style_context(win->m_widget);
gtk_style_context_save(sc);
gtk_style_context_set_state(sc, stateTypeToFlags[state]);
gtk_render_focus(sc, drawable, rect.x, rect.y, rect.width, rect.height);
gtk_style_context_restore(sc);
#else
gtk_paint_focus( gtk_widget_get_style(win->m_widget),
gdk_window,
drawable,
state,
NULL,
NULL_RECT
win->m_wxwindow,
NULL,
dc.LogicalToDeviceX(rect.x),
dc.LogicalToDeviceY(rect.y),
rect.width,
rect.height );
#endif
}
//TODO: GTK3 implementations for the remaining functions below
// Uses the theme to draw the border and fill for something like a wxTextCtrl
void wxRendererGTK::DrawTextCtrl(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)
{
GtkWidget *entry = wxGTKPrivate::GetTextEntryWidget();
GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
wxGTKDrawable* drawable = wxGetGTKDrawable(win, dc);
if (drawable == NULL)
return;
GtkStateType state = GTK_STATE_NORMAL;
if ( flags & wxCONTROL_DISABLED )
@@ -615,10 +728,10 @@ void wxRendererGTK::DrawTextCtrl(wxWindow* win, wxDC& dc, const wxRect& rect, in
gtk_paint_shadow
(
gtk_widget_get_style(entry),
gdk_window,
drawable,
state,
GTK_SHADOW_OUT,
NULL,
NULL_RECT
entry,
"entry",
dc.LogicalToDeviceX(rect.x),
@@ -633,7 +746,7 @@ void wxRendererGTK::DrawComboBox(wxWindow* win, wxDC& dc, const wxRect& rect, in
{
GtkWidget *combo = wxGTKPrivate::GetComboBoxWidget();
GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
wxGTKDrawable* drawable = wxGetGTKDrawable(win, dc);
GtkStateType state = GTK_STATE_NORMAL;
if ( flags & wxCONTROL_DISABLED )
@@ -641,13 +754,16 @@ void wxRendererGTK::DrawComboBox(wxWindow* win, wxDC& dc, const wxRect& rect, in
gtk_widget_set_can_focus(combo, (flags & wxCONTROL_CURRENT) != 0);
if (drawable == NULL)
return;
gtk_paint_shadow
(
gtk_widget_get_style(combo),
gdk_window,
drawable,
state,
GTK_SHADOW_OUT,
NULL,
NULL_RECT
combo,
"combobox",
dc.LogicalToDeviceX(rect.x),
@@ -666,10 +782,10 @@ void wxRendererGTK::DrawComboBox(wxWindow* win, wxDC& dc, const wxRect& rect, in
gtk_paint_arrow
(
gtk_widget_get_style(combo),
gdk_window,
drawable,
state,
GTK_SHADOW_OUT,
NULL,
NULL_RECT
combo,
"arrow",
GTK_ARROW_DOWN,
@@ -687,10 +803,10 @@ void wxRendererGTK::DrawComboBox(wxWindow* win, wxDC& dc, const wxRect& rect, in
gtk_paint_box
(
gtk_widget_get_style(combo),
gdk_window,
drawable,
state,
GTK_SHADOW_ETCHED_OUT,
NULL,
NULL_RECT
combo,
"vseparator",
dc.LogicalToDeviceX(r.x),
@@ -713,7 +829,9 @@ void wxRendererGTK::DrawRadioBitmap(wxWindow* win, wxDC& dc, const wxRect& rect,
{
GtkWidget *button = wxGTKPrivate::GetRadioButtonWidget();
GdkWindow* gdk_window = wxGetGdkWindowForDC(win, dc);
wxGTKDrawable* drawable = wxGetGTKDrawable(win, dc);
if (drawable == NULL)
return;
GtkShadowType shadow_type = GTK_SHADOW_OUT;
if ( flags & wxCONTROL_CHECKED )
@@ -734,10 +852,10 @@ void wxRendererGTK::DrawRadioBitmap(wxWindow* win, wxDC& dc, const wxRect& rect,
gtk_paint_option
(
gtk_widget_get_style(button),
gdk_window,
drawable,
state,
shadow_type,
NULL,
NULL_RECT
button,
"radiobutton",
dc.LogicalToDeviceX(rect.x),

View File

@@ -45,26 +45,34 @@ static GtkContainer* ContainerWidget()
}
extern "C" {
#ifdef __WXGTK3__
static void style_updated(GtkWidget*, void*)
#else
static void style_set(GtkWidget*, GtkStyle*, void*)
#endif
{
gs_fontSystem = wxNullFont;
}
}
static const GtkStyle* ButtonStyle()
static GtkWidget* ButtonWidget()
{
static GtkWidget* s_widget;
if (s_widget == NULL)
{
s_widget = gtk_button_new();
gtk_container_add(ContainerWidget(), s_widget);
#ifdef __WXGTK3__
g_signal_connect(s_widget, "style_updated", G_CALLBACK(style_updated), NULL);
#else
gtk_widget_ensure_style(s_widget);
g_signal_connect(s_widget, "style_set", G_CALLBACK(style_set), NULL);
#endif
}
return gtk_widget_get_style(s_widget);
return s_widget;
}
static const GtkStyle* ListStyle()
static GtkWidget* ListWidget()
{
static GtkWidget* s_widget;
if (s_widget == NULL)
@@ -72,60 +80,213 @@ static const GtkStyle* ListStyle()
s_widget = gtk_tree_view_new_with_model(
GTK_TREE_MODEL(gtk_list_store_new(1, G_TYPE_INT)));
gtk_container_add(ContainerWidget(), s_widget);
#ifndef __WXGTK3__
gtk_widget_ensure_style(s_widget);
#endif
}
return gtk_widget_get_style(s_widget);
return s_widget;
}
static const GtkStyle* TextCtrlStyle()
static GtkWidget* TextCtrlWidget()
{
static GtkWidget* s_widget;
if (s_widget == NULL)
{
s_widget = gtk_text_view_new();
gtk_container_add(ContainerWidget(), s_widget);
#ifndef __WXGTK3__
gtk_widget_ensure_style(s_widget);
#endif
}
return gtk_widget_get_style(s_widget);
return s_widget;
}
static const GtkStyle* MenuItemStyle()
static GtkWidget* MenuItemWidget()
{
static GtkWidget* s_widget;
if (s_widget == NULL)
{
s_widget = gtk_menu_item_new();
gtk_container_add(ContainerWidget(), s_widget);
#ifndef __WXGTK3__
gtk_widget_ensure_style(s_widget);
#endif
}
return gtk_widget_get_style(s_widget);
return s_widget;
}
static const GtkStyle* MenuBarStyle()
static GtkWidget* MenuBarWidget()
{
static GtkWidget* s_widget;
if (s_widget == NULL)
{
s_widget = gtk_menu_bar_new();
gtk_container_add(ContainerWidget(), s_widget);
#ifndef __WXGTK3__
gtk_widget_ensure_style(s_widget);
#endif
}
return gtk_widget_get_style(s_widget);
return s_widget;
}
static const GtkStyle* ToolTipStyle()
static GtkWidget* ToolTipWidget()
{
static GtkWidget* s_widget;
if (s_widget == NULL)
{
s_widget = gtk_window_new(GTK_WINDOW_POPUP);
const char* name = "gtk-tooltip";
#ifndef __WXGTK3__
if (gtk_check_version(2, 11, 0))
name = "gtk-tooltips";
#endif
gtk_widget_set_name(s_widget, name);
#ifndef __WXGTK3__
gtk_widget_ensure_style(s_widget);
#endif
}
return gtk_widget_get_style(s_widget);
return s_widget;
}
#ifdef __WXGTK3__
static void bg(GtkWidget* widget, GtkStateFlags state, GdkRGBA& gdkRGBA)
{
GtkStyleContext* sc = gtk_widget_get_style_context(widget);
gtk_style_context_get_background_color(sc, state, &gdkRGBA);
}
static void fg(GtkWidget* widget, GtkStateFlags state, GdkRGBA& gdkRGBA)
{
GtkStyleContext* sc = gtk_widget_get_style_context(widget);
gtk_style_context_get_color(sc, state, &gdkRGBA);
}
static void border(GtkWidget* widget, GtkStateFlags state, GdkRGBA& gdkRGBA)
{
GtkStyleContext* sc = gtk_widget_get_style_context(widget);
gtk_style_context_get_border_color(sc, state, &gdkRGBA);
}
wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
{
GdkRGBA gdkRGBA = { 0, 0, 0, 1 };
switch (index)
{
case wxSYS_COLOUR_3DLIGHT:
case wxSYS_COLOUR_ACTIVEBORDER:
case wxSYS_COLOUR_BTNFACE:
case wxSYS_COLOUR_DESKTOP:
case wxSYS_COLOUR_INACTIVEBORDER:
case wxSYS_COLOUR_INACTIVECAPTION:
case wxSYS_COLOUR_SCROLLBAR:
case wxSYS_COLOUR_WINDOWFRAME:
bg(ButtonWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
break;
case wxSYS_COLOUR_BTNHIGHLIGHT:
case wxSYS_COLOUR_HIGHLIGHT:
bg(ButtonWidget(), GTK_STATE_FLAG_SELECTED, gdkRGBA);
break;
case wxSYS_COLOUR_BTNSHADOW:
border(ButtonWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
break;
case wxSYS_COLOUR_BTNTEXT:
case wxSYS_COLOUR_WINDOWTEXT:
fg(ButtonWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
break;
case wxSYS_COLOUR_GRAYTEXT:
case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
fg(ButtonWidget(), GTK_STATE_FLAG_INSENSITIVE, gdkRGBA);
break;
case wxSYS_COLOUR_HIGHLIGHTTEXT:
fg(ButtonWidget(), GTK_STATE_FLAG_SELECTED, gdkRGBA);
break;
case wxSYS_COLOUR_HOTLIGHT:
{
static GtkWidget* s_widget;
if (s_widget == NULL)
{
s_widget = gtk_link_button_new("");
gtk_container_add(ContainerWidget(), s_widget);
}
fg(s_widget, GTK_STATE_FLAG_NORMAL, gdkRGBA);
}
break;
case wxSYS_COLOUR_INFOBK:
bg(ToolTipWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
break;
case wxSYS_COLOUR_INFOTEXT:
fg(ToolTipWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
break;
case wxSYS_COLOUR_LISTBOX:
bg(ListWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
break;
case wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT:
fg(ListWidget(), GTK_STATE_FLAG_SELECTED, gdkRGBA);
break;
case wxSYS_COLOUR_LISTBOXTEXT:
fg(ListWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
break;
case wxSYS_COLOUR_MENU:
bg(MenuItemWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
break;
case wxSYS_COLOUR_MENUBAR:
bg(MenuBarWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
break;
case wxSYS_COLOUR_ACTIVECAPTION:
case wxSYS_COLOUR_MENUHILIGHT:
bg(MenuItemWidget(), GTK_STATE_FLAG_SELECTED, gdkRGBA);
break;
case wxSYS_COLOUR_MENUTEXT:
fg(MenuItemWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
break;
case wxSYS_COLOUR_APPWORKSPACE:
case wxSYS_COLOUR_WINDOW:
bg(TextCtrlWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
break;
case wxSYS_COLOUR_CAPTIONTEXT:
{
GdkRGBA c = { 1, 1, 1, 1 };
gdkRGBA = c;
}
break;
default:
wxFAIL_MSG("unknown system colour index");
// fallthrough
case wxSYS_COLOUR_3DDKSHADOW:
case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
// black
break;
}
return wxColour(gdkRGBA);
}
#else
static const GtkStyle* ButtonStyle()
{
return gtk_widget_get_style(ButtonWidget());
}
static const GtkStyle* ListStyle()
{
return gtk_widget_get_style(ListWidget());
}
static const GtkStyle* TextCtrlStyle()
{
return gtk_widget_get_style(TextCtrlWidget());
}
static const GtkStyle* MenuItemStyle()
{
return gtk_widget_get_style(MenuItemWidget());
}
static const GtkStyle* MenuBarStyle()
{
return gtk_widget_get_style(MenuBarWidget());
}
static const GtkStyle* ToolTipStyle()
{
return gtk_widget_get_style(ToolTipWidget());
}
wxColour wxSystemSettingsNative::GetColour( wxSystemColour index )
@@ -242,6 +403,7 @@ wxColour wxSystemSettingsNative::GetColour( wxSystemColour index )
wxASSERT(color.IsOk());
return color;
}
#endif
wxFont wxSystemSettingsNative::GetFont( wxSystemFont index )
{
@@ -261,7 +423,13 @@ wxFont wxSystemSettingsNative::GetFont( wxSystemFont index )
if (!gs_fontSystem.IsOk())
{
wxNativeFontInfo info;
#ifdef __WXGTK3__
GtkStyleContext* sc = gtk_widget_get_style_context(ButtonWidget());
info.description = const_cast<PangoFontDescription*>(
gtk_style_context_get_font(sc, GTK_STATE_FLAG_NORMAL));
#else
info.description = ButtonStyle()->font_desc;
#endif
gs_fontSystem = wxFont(info);
#if wxUSE_FONTENUM
@@ -290,7 +458,7 @@ wxFont wxSystemSettingsNative::GetFont( wxSystemFont index )
// on or for the default screen if window is NULL
static GtkSettings *GetSettingsForWindowScreen(GdkWindow *window)
{
return window ? gtk_settings_get_for_screen(gdk_drawable_get_screen(window))
return window ? gtk_settings_get_for_screen(gdk_window_get_screen(window))
: gtk_settings_get_default();
}
@@ -299,16 +467,16 @@ static int GetBorderWidth(wxSystemMetric index, wxWindow* win)
if (win->m_wxwindow)
{
wxPizza* pizza = WX_PIZZA(win->m_wxwindow);
int x, y;
pizza->get_border_widths(x, y);
GtkBorder border;
pizza->get_border(border);
switch (index)
{
case wxSYS_BORDER_X:
case wxSYS_EDGE_X:
case wxSYS_FRAMESIZE_X:
return x;
return border.left;
default:
return y;
return border.top;
}
}
return -1;
@@ -359,7 +527,7 @@ int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win )
case wxSYS_CURSOR_X:
case wxSYS_CURSOR_Y:
return gdk_display_get_default_cursor_size(
window ? gdk_drawable_get_display(window)
window ? gdk_window_get_display(window)
: gdk_display_get_default());
case wxSYS_DCLICK_X:
@@ -396,13 +564,13 @@ int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win )
case wxSYS_SCREEN_X:
if (window)
return gdk_screen_get_width(gdk_drawable_get_screen(window));
return gdk_screen_get_width(gdk_window_get_screen(window));
else
return gdk_screen_width();
case wxSYS_SCREEN_Y:
if (window)
return gdk_screen_get_height(gdk_drawable_get_screen(window));
return gdk_screen_get_height(gdk_window_get_screen(window));
else
return gdk_screen_height();

View File

@@ -521,7 +521,12 @@ int wxSlider::GetLineSize() const
GdkWindow *wxSlider::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{
#ifdef __WXGTK3__
// no access to internal GdkWindows
return NULL;
#else
return GTK_RANGE(m_scale)->event_window;
#endif
}
// static

View File

@@ -198,7 +198,12 @@ void wxSpinButton::GtkEnableEvents() const
GdkWindow *wxSpinButton::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{
#ifdef __WXGTK3__
// no access to internal GdkWindows
return NULL;
#else
return GTK_SPIN_BUTTON(m_widget)->panel;
#endif
}
wxSize wxSpinButton::DoGetBestSize() const

View File

@@ -21,7 +21,9 @@
#include "wx/wxcrtvararg.h"
#endif
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/gtk2-compat.h"
//-----------------------------------------------------------------------------
// data
@@ -325,10 +327,15 @@ void wxSpinCtrlGTKBase::OnChar( wxKeyEvent &event )
GdkWindow *wxSpinCtrlGTKBase::GTKGetWindow(wxArrayGdkWindows& windows) const
{
#ifdef __WXGTK3__
// no access to internal GdkWindows
wxUnusedVar(windows);
#else
GtkSpinButton* spinbutton = GTK_SPIN_BUTTON(m_widget);
windows.push_back(spinbutton->entry.text_area);
windows.push_back(spinbutton->panel);
#endif
return NULL;
}

View File

@@ -13,10 +13,10 @@
#if wxUSE_STATBOX
#include "wx/statbox.h"
#include "wx/gtk/private/win_gtk.h" // for wxPizza
#include <gtk/gtk.h>
#include "wx/gtk/private/gtk2-compat.h"
#include "wx/gtk/private/win_gtk.h"
// constants taken from GTK sources
#define LABEL_PAD 1
@@ -26,6 +26,7 @@
// "size_allocate" from m_widget
//-----------------------------------------------------------------------------
#ifndef __WXGTK3__
extern "C" {
static void size_allocate(GtkWidget* widget, GtkAllocation* alloc, void*)
{
@@ -45,6 +46,7 @@ static void size_allocate(GtkWidget* widget, GtkAllocation* alloc, void*)
}
}
}
#endif
//-----------------------------------------------------------------------------
// wxStaticBox
@@ -99,11 +101,13 @@ bool wxStaticBox::Create( wxWindow *parent,
gtk_frame_set_label_align(GTK_FRAME(m_widget), xalign, 0.5);
#ifndef __WXGTK3__
if (gtk_check_version(2, 12, 0))
{
// we connect this signal to perform label-clipping as GTK >= 2.12 does
g_signal_connect(m_widget, "size_allocate", G_CALLBACK(size_allocate), NULL);
}
#endif
return true;
}

View File

@@ -13,6 +13,8 @@
#if wxUSE_STATTEXT
#include "wx/stattext.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
@@ -71,7 +73,9 @@ bool wxStaticText::Create(wxWindow *parent,
gtk_label_set_justify(GTK_LABEL(m_widget), justify);
#ifdef __WXGTK26__
#ifndef __WXGTK3__
if (!gtk_check_version(2,6,0))
#endif
{
// set ellipsize mode
PangoEllipsizeMode ellipsizeMode = PANGO_ELLIPSIZE_NONE;
@@ -107,6 +111,7 @@ void wxStaticText::GTKDoSetLabel(GTKLabelSetter setter, const wxString& label)
InvalidateBestSize();
#ifndef __WXGTK3__
if (gtk_check_version(2,6,0) && IsEllipsized())
{
// GTK+ < 2.6 does not support ellipsization so we need to do it
@@ -116,6 +121,7 @@ void wxStaticText::GTKDoSetLabel(GTKLabelSetter setter, const wxString& label)
GTKSetLabelForLabel(GTK_LABEL(m_widget), GetEllipsizedLabel());
}
else // Ellipsization not needed or supported by GTK+.
#endif
{
(this->*setter)(GTK_LABEL(m_widget), label);
}
@@ -211,12 +217,14 @@ void wxStaticText::DoSetSize(int x, int y,
{
wxStaticTextBase::DoSetSize(x, y, width, height, sizeFlags);
#ifndef __WXGTK3__
if (gtk_check_version(2,6,0))
{
// GTK+ < 2.6 does not support ellipsization - we need to run our
// generic code (actually it will be run only if IsEllipsized() == true)
UpdateLabel();
}
#endif
}
wxSize wxStaticText::DoGetBestSize() const
@@ -228,11 +236,19 @@ wxSize wxStaticText::DoGetBestSize() const
// gtk_label_set_line_wrap() from here is a bad idea as it queues another
// size request by calling gtk_widget_queue_resize() and we end up in
// infinite loop sometimes (notably when the control is in a toolbar)
// With GTK3 however, there is no simple alternative, and the sizing loop
// no longer seems to occur.
#ifdef __WXGTK3__
gtk_label_set_line_wrap(GTK_LABEL(m_widget), false);
#else
GTK_LABEL(m_widget)->wrap = FALSE;
#endif
wxSize size = wxStaticTextBase::DoGetBestSize();
#ifdef __WXGTK3__
gtk_label_set_line_wrap(GTK_LABEL(m_widget), true);
#else
GTK_LABEL(m_widget)->wrap = TRUE; // restore old value
#endif
// Adding 1 to width to workaround GTK sometimes wrapping the text needlessly
size.x++;

View File

@@ -22,8 +22,13 @@
#include "wx/icon.h"
#endif
#include "eggtrayicon.h"
#include <gtk/gtk.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
#ifndef __WXGTK3__
#include "eggtrayicon.h"
#endif
#if !GTK_CHECK_VERSION(2,10,0)
typedef struct _GtkStatusIcon GtkStatusIcon;
@@ -41,20 +46,23 @@ public:
wxTaskBarIcon* m_taskBarIcon;
// used when GTK+ >= 2.10
GtkStatusIcon* m_statusIcon;
// used when GTK+ < 2.10
GtkWidget* m_eggTrayIcon;
// for PopupMenu
wxWindow* m_win;
// for tooltip when GTK+ < 2.10
GtkTooltips* m_tooltips;
wxBitmap m_bitmap;
wxString m_tipText;
#ifndef __WXGTK3__
// used when GTK+ < 2.10
GtkWidget* m_eggTrayIcon;
// for tooltip when GTK+ < 2.10
GtkTooltips* m_tooltips;
// width and height of available space, only used when GTK+ < 2.10
int m_size;
#endif
};
//-----------------------------------------------------------------------------
extern "C" {
#ifndef __WXGTK3__
static void
icon_size_allocate(GtkWidget*, GtkAllocation* alloc, wxTaskBarIcon::Private* priv)
{
@@ -69,6 +77,7 @@ icon_destroy(GtkWidget*, wxTaskBarIcon::Private* priv)
priv->m_eggTrayIcon = NULL;
priv->SetIcon();
}
#endif
static void
icon_activate(void*, wxTaskBarIcon* taskBarIcon)
@@ -91,6 +100,7 @@ icon_popup_menu(GtkWidget*, wxTaskBarIcon* taskBarIcon)
return true;
}
#ifndef __WXGTK3__
static gboolean
icon_button_press_event(GtkWidget*, GdkEventButton* event, wxTaskBarIcon* taskBarIcon)
{
@@ -103,6 +113,7 @@ icon_button_press_event(GtkWidget*, GdkEventButton* event, wxTaskBarIcon* taskBa
}
return false;
}
#endif
#if GTK_CHECK_VERSION(2,10,0)
static void
@@ -135,37 +146,43 @@ wxTaskBarIcon::Private::Private(wxTaskBarIcon* taskBarIcon)
{
m_taskBarIcon = taskBarIcon;
m_statusIcon = NULL;
m_eggTrayIcon = NULL;
m_win = NULL;
#ifndef __WXGTK3__
m_eggTrayIcon = NULL;
m_tooltips = NULL;
m_size = 0;
#endif
}
wxTaskBarIcon::Private::~Private()
{
if (m_statusIcon)
g_object_unref(m_statusIcon);
#ifndef __WXGTK3__
else if (m_eggTrayIcon)
{
g_signal_handlers_disconnect_by_func(m_eggTrayIcon, (void*)icon_destroy, this);
gtk_widget_destroy(m_eggTrayIcon);
}
#endif
if (m_win)
{
m_win->PopEventHandler();
m_win->Destroy();
}
#ifndef __WXGTK3__
if (m_tooltips)
{
gtk_object_destroy(GTK_OBJECT(m_tooltips));
g_object_unref(m_tooltips);
}
#endif
}
void wxTaskBarIcon::Private::SetIcon()
{
#if GTK_CHECK_VERSION(2,10,0)
if (gtk_check_version(2,10,0) == NULL)
if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,10,0) == NULL)
{
if (m_statusIcon)
gtk_status_icon_set_from_pixbuf(m_statusIcon, m_bitmap.GetPixbuf());
@@ -181,6 +198,7 @@ void wxTaskBarIcon::Private::SetIcon()
else
#endif
{
#ifndef __WXGTK3__
m_size = 0;
if (m_eggTrayIcon)
{
@@ -203,6 +221,7 @@ void wxTaskBarIcon::Private::SetIcon()
gtk_container_add(GTK_CONTAINER(m_eggTrayIcon), image);
gtk_widget_show_all(m_eggTrayIcon);
}
#endif
}
#if wxUSE_TOOLTIPS
const char *tip_text = NULL;
@@ -218,7 +237,7 @@ void wxTaskBarIcon::Private::SetIcon()
else
#endif
{
#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
#ifndef __WXGTK3__
gtk_status_icon_set_tooltip(m_statusIcon, tip_text);
#endif
}
@@ -226,7 +245,7 @@ void wxTaskBarIcon::Private::SetIcon()
else
#endif // GTK_CHECK_VERSION(2,10,0)
{
#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
#ifndef __WXGTK3__
if (tip_text && m_tooltips == NULL)
{
m_tooltips = gtk_tooltips_new();
@@ -240,6 +259,7 @@ void wxTaskBarIcon::Private::SetIcon()
#endif // wxUSE_TOOLTIPS
}
#ifndef __WXGTK3__
void wxTaskBarIcon::Private::size_allocate(int width, int height)
{
int size = height;
@@ -262,6 +282,7 @@ void wxTaskBarIcon::Private::size_allocate(int width, int height)
g_object_unref(pixbuf);
}
}
#endif
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxTaskBarIcon, wxEvtHandler)
@@ -293,7 +314,11 @@ bool wxTaskBarIcon::RemoveIcon()
bool wxTaskBarIcon::IsIconInstalled() const
{
#ifdef __WXGTK3__
return m_priv->m_statusIcon != NULL;
#else
return m_priv->m_statusIcon || m_priv->m_eggTrayIcon;
#endif
}
bool wxTaskBarIcon::PopupMenu(wxMenu* menu)

View File

@@ -30,7 +30,9 @@
#include <sys/stat.h>
#include <ctype.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/gtk2-compat.h"
// ----------------------------------------------------------------------------
// helpers
@@ -167,25 +169,29 @@ static void wxGtkTextApplyTagsFromAttr(GtkWidget *text,
GtkJustification align;
switch (attr.GetAlignment())
{
default:
align = GTK_JUSTIFY_LEFT;
break;
case wxTEXT_ALIGNMENT_RIGHT:
align = GTK_JUSTIFY_RIGHT;
break;
case wxTEXT_ALIGNMENT_CENTER:
align = GTK_JUSTIFY_CENTER;
break;
case wxTEXT_ALIGNMENT_JUSTIFIED:
#ifdef __WXGTK3__
align = GTK_JUSTIFY_FILL;
break;
#elif GTK_CHECK_VERSION(2,11,0)
// gtk+ doesn't support justify before gtk+-2.11.0 with pango-1.17 being available
// (but if new enough pango isn't available it's a mere gtk warning)
#if GTK_CHECK_VERSION(2,11,0)
case wxTEXT_ALIGNMENT_JUSTIFIED:
if (!gtk_check_version(2,11,0))
{
align = GTK_JUSTIFY_FILL;
else
align = GTK_JUSTIFY_LEFT;
break;
break;
}
// fallthrough
#endif
default:
align = GTK_JUSTIFY_LEFT;
break;
}
g_snprintf(buf, sizeof(buf), "WXALIGNMENT %d", align);
@@ -1645,7 +1651,12 @@ GdkWindow *wxTextCtrl::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
}
else
{
#ifdef __WXGTK3__
// no access to internal GdkWindows
return NULL;
#else
return gtk_entry_get_text_window(GTK_ENTRY(m_text));
#endif
}
}
@@ -1792,7 +1803,7 @@ bool wxTextCtrl::GetStyle(long position, wxTextAttr& style)
void wxTextCtrl::DoApplyWidgetStyle(GtkRcStyle *style)
{
gtk_widget_modify_style(m_text, style);
GTKApplyStyle(m_text, style);
}
void wxTextCtrl::OnCut(wxCommandEvent& WXUNUSED(event))

View File

@@ -26,13 +26,14 @@
#if wxUSE_TEXTCTRL || wxUSE_COMBOBOX
#ifndef WX_PRECOMP
#include "wx/textentry.h"
#include "wx/window.h"
#include "wx/textctrl.h"
#endif //WX_PRECOMP
#include "wx/textentry.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/gtk2-compat.h"
// ============================================================================
// signal handlers implementation
@@ -205,6 +206,7 @@ void wxTextEntry::SetSelection(long from, long to)
// GTK+ does by default
gtk_editable_select_region(GetEditable(), to, from);
#ifndef __WXGTK3__
// avoid reported problem with RHEL 5 GTK+ 2.10 where selection is reset by
// a clipboard callback, see #13277
if (gtk_check_version(2,12,0))
@@ -214,6 +216,7 @@ void wxTextEntry::SetSelection(long from, long to)
to = entry->text_length;
entry->selection_bound = to;
}
#endif
}
void wxTextEntry::GetSelection(long *from, long *to) const

View File

@@ -21,6 +21,7 @@
#include "wx/button.h"
#endif
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
extern bool g_blockEventsOnDrag;
@@ -212,8 +213,8 @@ GtkLabel *wxToggleButton::GTKGetLabel() const
void wxToggleButton::DoApplyWidgetStyle(GtkRcStyle *style)
{
gtk_widget_modify_style(m_widget, style);
gtk_widget_modify_style(gtk_bin_get_child(GTK_BIN(m_widget)), style);
GTKApplyStyle(m_widget, style);
GTKApplyStyle(gtk_bin_get_child(GTK_BIN(m_widget)), style);
}
// Get the "best" size for this control.

View File

@@ -15,7 +15,9 @@
#include "wx/toolbar.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/gtk2-compat.h"
// ----------------------------------------------------------------------------
// globals
@@ -174,7 +176,11 @@ enter_notify_event(GtkWidget*, GdkEventCrossing* event, wxToolBarTool* tool)
extern "C" {
static gboolean
#ifdef __WXGTK3__
image_draw(GtkWidget* widget, cairo_t* cr, wxToolBarTool* tool)
#else
image_expose_event(GtkWidget* widget, GdkEventExpose*, wxToolBarTool* tool)
#endif
{
const wxBitmap& bitmap = tool->GetDisabledBitmap();
if (tool->IsEnabled() || !bitmap.IsOk())
@@ -185,12 +191,16 @@ image_expose_event(GtkWidget* widget, GdkEventExpose*, wxToolBarTool* tool)
gtk_widget_get_allocation(widget, &alloc);
GtkRequisition req;
gtk_widget_get_requisition(widget, &req);
const int x = alloc.x + (alloc.width - req.width) / 2;
const int y = alloc.y + (alloc.height - req.height) / 2;
#ifdef __WXGTK3__
bitmap.Draw(cr, x, y);
#else
gdk_draw_pixbuf(
gtk_widget_get_window(widget), gtk_widget_get_style(widget)->black_gc, bitmap.GetPixbuf(),
0, 0,
alloc.x + (alloc.width - req.width) / 2,
alloc.y + (alloc.height - req.height) / 2,
0, 0, x, y,
-1, -1, GDK_RGB_DITHER_NORMAL, 0, 0);
#endif
return true;
}
}
@@ -341,11 +351,13 @@ void wxToolBar::Init()
wxToolBar::~wxToolBar()
{
#ifndef __WXGTK3__
if (m_tooltips) // always NULL if GTK >= 2.12
{
gtk_object_destroy(GTK_OBJECT(m_tooltips));
g_object_unref(m_tooltips);
}
#endif
}
bool wxToolBar::Create( wxWindow *parent,
@@ -366,7 +378,7 @@ bool wxToolBar::Create( wxWindow *parent,
FixupStyle();
m_toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
#ifndef __WXGTK3__
if (gtk_check_version(2, 12, 0))
{
m_tooltips = gtk_tooltips_new();
@@ -425,7 +437,7 @@ void wxToolBar::GtkSetStyle()
style = GTK_TOOLBAR_BOTH_HORIZ;
}
#if GTK_CHECK_VERSION(3,0,0) || defined(GTK_DISABLE_DEPRECATED)
#ifdef __WXGTK3__
gtk_orientable_set_orientation(GTK_ORIENTABLE(m_toolbar), orient);
#else
gtk_toolbar_set_orientation(m_toolbar, orient);
@@ -513,8 +525,13 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
GTK_TOOL_BUTTON(tool->m_item), image);
tool->SetImage();
gtk_widget_show(image);
#ifdef __WXGTK3__
g_signal_connect(image, "draw",
G_CALLBACK(image_draw), tool);
#else
g_signal_connect(image, "expose_event",
G_CALLBACK(image_expose_event), tool);
#endif
}
if (!tool->GetLabel().empty())
{
@@ -534,7 +551,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
else
#endif
{
#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
#ifndef __WXGTK3__
gtk_tool_item_set_tooltip(tool->m_item,
m_tooltips, wxGTK_CONV(tool->GetShortHelp()), "");
#endif
@@ -602,7 +619,7 @@ bool wxToolBar::DoDeleteTool(size_t /* pos */, wxToolBarToolBase* toolBase)
GtkWidget* widget = tool->GetControl()->m_widget;
gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(widget)), widget);
}
gtk_object_destroy(GTK_OBJECT(tool->m_item));
gtk_widget_destroy(GTK_WIDGET(tool->m_item));
tool->m_item = NULL;
InvalidateBestSize();
@@ -708,7 +725,7 @@ void wxToolBar::SetToolShortHelp( int id, const wxString& helpString )
else
#endif
{
#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
#ifndef __WXGTK3__
gtk_tool_item_set_tooltip(tool->m_item,
m_tooltips, wxGTK_CONV(helpString), "");
#endif

View File

@@ -31,26 +31,20 @@
#include "wx/app.h"
#endif
#include "wx/gtk/private.h"
#include "wx/evtloop.h"
#include "wx/sysopt.h"
#include <gtk/gtk.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#include <gdk/gdkx.h>
#include <X11/Xatom.h> // XA_CARDINAL
#include "wx/unix/utilsx11.h"
#endif
#include "wx/gtk/private.h"
#include "wx/gtk/private/gtk2-compat.h"
#include "wx/gtk/private/win_gtk.h"
#ifdef GDK_WINDOWING_X11
#include "wx/unix/utilsx11.h"
// XA_CARDINAL
#include <X11/Xatom.h>
#endif // GDK_WINDOWING_X11
#if wxUSE_LIBHILDON
#include <hildon-widgets/hildon-program.h>
#include <hildon-widgets/hildon-window.h>
@@ -86,7 +80,7 @@ static int gs_requestFrameExtentsStatus;
// RequestUserAttention related functions
//-----------------------------------------------------------------------------
#ifndef __WXGTK30__
#ifndef __WXGTK3__
static void wxgtk_window_set_urgency_hint (GtkWindow *win,
gboolean setting)
{
@@ -310,7 +304,7 @@ void wxTopLevelWindowGTK::GTKHandleRealized()
// GTK's shrinking/growing policy
if ( !(m_gdkFunc & GDK_FUNC_RESIZE) )
gtk_window_set_resizable(GTK_WINDOW(m_widget), FALSE);
#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
#ifndef __WXGTK3__
else
gtk_window_set_policy(GTK_WINDOW(m_widget), 1, 1, 1);
#endif
@@ -318,6 +312,16 @@ void wxTopLevelWindowGTK::GTKHandleRealized()
const wxIconBundle& icons = GetIcons();
if (icons.GetIconCount())
SetIcons(icons);
#ifdef __WXGTK3__
if (gtk_window_get_has_resize_grip(GTK_WINDOW(m_widget)))
{
// Grip window can end up obscured, probably due to deferred show.
// Reset grip to ensure it is visible.
gtk_window_set_has_resize_grip(GTK_WINDOW(m_widget), false);
gtk_window_set_has_resize_grip(GTK_WINDOW(m_widget), true);
}
#endif
}
//-----------------------------------------------------------------------------
@@ -351,7 +355,9 @@ gtk_frame_map_callback( GtkWidget*,
}
#if GTK_CHECK_VERSION(2,6,0)
#ifndef __WXGTK3__
if (!gtk_check_version(2,6,0))
#endif
{
// restore focus-on-map setting in case ShowWithoutActivating() was called
gtk_window_set_focus_on_map(GTK_WINDOW(win->m_widget), true);
@@ -393,15 +399,15 @@ bool wxGetFrameExtents(GdkWindow* window, int* left, int* right, int* top, int*
{
#ifdef GDK_WINDOWING_X11
static GdkAtom property = gdk_atom_intern("_NET_FRAME_EXTENTS", false);
Atom xproperty = gdk_x11_atom_to_xatom_for_display(
gdk_drawable_get_display(window), property);
GdkDisplay* display = gdk_window_get_display(window);
Atom xproperty = gdk_x11_atom_to_xatom_for_display(display, property);
Atom type;
int format;
gulong nitems, bytes_after;
guchar* data;
Status status = XGetWindowProperty(
gdk_x11_drawable_get_xdisplay(window),
gdk_x11_drawable_get_xid(window),
GDK_DISPLAY_XDISPLAY(display),
GDK_WINDOW_XID(window),
xproperty,
0, 4, false, XA_CARDINAL,
&type, &format, &nitems, &bytes_after, &data);
@@ -615,7 +621,7 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
PostCreation();
#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
#ifndef __WXGTK3__
if ((m_x != -1) || (m_y != -1))
gtk_widget_set_uposition( m_widget, m_x, m_y );
#endif
@@ -757,9 +763,9 @@ bool wxTopLevelWindowGTK::ShowFullScreen(bool show, long)
m_fsIsShowing = show;
#ifdef GDK_WINDOWING_X11
wxX11FullScreenMethod method =
wxGetFullScreenMethodX11((WXDisplay*)GDK_DISPLAY(),
(WXWindow)GDK_ROOT_WINDOW());
Display* xdpy = GDK_DISPLAY_XDISPLAY(gtk_widget_get_display(m_widget));
Window xroot = GDK_WINDOW_XID(gtk_widget_get_root_window(m_widget));
wxX11FullScreenMethod method = wxGetFullScreenMethodX11(xdpy, (WXWindow)xroot);
// NB: gtk_window_fullscreen() uses freedesktop.org's WMspec extensions
// to switch to fullscreen, which is not always available. We must
@@ -777,14 +783,16 @@ bool wxTopLevelWindowGTK::ShowFullScreen(bool show, long)
else
{
GdkWindow* window = gtk_widget_get_window(m_widget);
Window xid = GDK_WINDOW_XID(window);
if (show)
{
GetPosition( &m_fsSaveFrame.x, &m_fsSaveFrame.y );
GetSize( &m_fsSaveFrame.width, &m_fsSaveFrame.height );
int screen_width,screen_height;
wxDisplaySize( &screen_width, &screen_height );
GdkScreen* screen = gtk_widget_get_screen(m_widget);
const int screen_width = gdk_screen_get_width(screen);
const int screen_height = gdk_screen_get_height(screen);
gint client_x, client_y, root_x, root_y;
gint width, height;
@@ -796,14 +804,14 @@ bool wxTopLevelWindowGTK::ShowFullScreen(bool show, long)
gdk_window_set_functions(window, (GdkWMFunction)0);
gdk_window_get_origin(window, &root_x, &root_y);
gdk_window_get_geometry(window, &client_x, &client_y, &width, &height, NULL);
gdk_window_get_geometry(window, &client_x, &client_y, &width, &height);
gdk_window_move_resize(
window, -client_x, -client_y, screen_width + 1, screen_height + 1);
wxSetFullScreenStateX11((WXDisplay*)GDK_DISPLAY(),
(WXWindow)GDK_ROOT_WINDOW(),
(WXWindow)GDK_WINDOW_XWINDOW(window),
wxSetFullScreenStateX11(xdpy,
(WXWindow)xroot,
(WXWindow)xid,
show, &m_fsSaveFrame, method);
}
else // hide
@@ -813,9 +821,9 @@ bool wxTopLevelWindowGTK::ShowFullScreen(bool show, long)
gdk_window_set_decorations(window, (GdkWMDecoration)m_gdkDecor);
gdk_window_set_functions(window, (GdkWMFunction)m_gdkFunc);
wxSetFullScreenStateX11((WXDisplay*)GDK_DISPLAY(),
(WXWindow)GDK_ROOT_WINDOW(),
(WXWindow)GDK_WINDOW_XWINDOW(window),
wxSetFullScreenStateX11(xdpy,
(WXWindow)xroot,
(WXWindow)xid,
show, &m_fsSaveFrame, method);
SetSize(m_fsSaveFrame.x, m_fsSaveFrame.y,
@@ -918,12 +926,12 @@ bool wxTopLevelWindowGTK::Show( bool show )
memset(&xevent, 0, sizeof(xevent));
xevent.type = ClientMessage;
GdkWindow* window = gtk_widget_get_window(m_widget);
xevent.window = gdk_x11_drawable_get_xid(window);
xevent.window = GDK_WINDOW_XID(window);
xevent.message_type = gdk_x11_atom_to_xatom_for_display(
gdk_drawable_get_display(window),
gdk_window_get_display(window),
gdk_atom_intern("_NET_REQUEST_FRAME_EXTENTS", false));
xevent.format = 32;
Display* display = gdk_x11_drawable_get_xdisplay(window);
Display* display = GDK_DISPLAY_XDISPLAY(gdk_window_get_display(window));
XSendEvent(display, DefaultRootWindow(display), false,
SubstructureNotifyMask | SubstructureRedirectMask,
(XEvent*)&xevent);
@@ -970,7 +978,9 @@ void wxTopLevelWindowGTK::ShowWithoutActivating()
if (!m_isShown)
{
#if GTK_CHECK_VERSION(2,6,0)
#ifndef __WXGTK3__
if (!gtk_check_version(2,6,0))
#endif
gtk_window_set_focus_on_map(GTK_WINDOW(m_widget), false);
#endif // GTK+ 2.6+
@@ -1054,6 +1064,8 @@ void wxTopLevelWindowGTK::DoSetSize( int x, int y, int width, int height, int si
if (height >= 0)
m_height = height;
ConstrainSize();
if (m_width < 1) m_width = 1;
if (m_height < 1) m_height = 1;
if (m_width != oldSize.x || m_height != oldSize.y)
{
int w, h;
@@ -1171,8 +1183,8 @@ void wxTopLevelWindowGTK::GTKUpdateDecorSize(const wxSize& decorSize)
// adjust overall size to match change in frame extents
m_width += diff.x;
m_height += diff.y;
if (m_width < 0) m_width = 0;
if (m_height < 0) m_height = 0;
if (m_width < 1) m_width = 1;
if (m_height < 1) m_height = 1;
m_oldClientWidth = 0;
gtk_widget_queue_resize(m_wxwindow);
}
@@ -1433,6 +1445,9 @@ bool wxTopLevelWindowGTK::CanSetTransparent()
return wxSystemOptions::GetOptionInt(SYSOPT_TRANSPARENT) != 0;
}
#ifdef __WXGTK3__
return gtk_widget_is_composited(m_widget) != 0;
#else
#if GTK_CHECK_VERSION(2,10,0)
if (!gtk_check_version(2,10,0))
{
@@ -1443,6 +1458,7 @@ bool wxTopLevelWindowGTK::CanSetTransparent()
{
return false;
}
#endif // !__WXGTK3__
#if 0 // Don't be optimistic here for the sake of wxAUI
int opcode, event, error;

View File

@@ -57,6 +57,8 @@
#include "wx/unix/utilsx11.h"
#endif
#include "wx/gtk/private/gtk2-compat.h"
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
@@ -73,13 +75,15 @@ void wxBell()
}
// ----------------------------------------------------------------------------
// display characterstics
// display characteristics
// ----------------------------------------------------------------------------
#ifdef GDK_WINDOWING_X11
void *wxGetDisplay()
{
return GDK_DISPLAY();
return GDK_DISPLAY_XDISPLAY(gtk_widget_get_display(wxGetRootWindow()));
}
#endif
void wxDisplaySize( int *width, int *height )
{
@@ -105,7 +109,7 @@ bool wxColourDisplay()
int wxDisplayDepth()
{
return gtk_widget_get_visual(wxGetRootWindow())->depth;
return gdk_visual_get_depth(gtk_widget_get_visual(wxGetRootWindow()));
}
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
@@ -166,7 +170,9 @@ const gchar *wx_pango_version_check (int major, int minor, int micro)
// added in pango-1.4 or earlier since GTK 2.4 (our minimum requirement
// for GTK lib) required pango 1.4...
#ifdef PANGO_VERSION_MAJOR
#ifdef __WXGTK3__
return pango_version_check(major, minor, micro);
#elif defined(PANGO_VERSION_MAJOR)
if (!gtk_check_version (2,11,0))
{
// GTK+ 2.11 requires Pango >= 1.15.3 and pango_version_check
@@ -185,7 +191,6 @@ const gchar *wx_pango_version_check (int major, int minor, int micro)
#endif
}
// ----------------------------------------------------------------------------
// subprocess routines
// ----------------------------------------------------------------------------
@@ -288,7 +293,11 @@ wxEventLoopBase *wxGUIAppTraits::CreateEventLoop()
#if wxUSE_INTL && defined(__UNIX__)
void wxGUIAppTraits::SetLocale()
{
#ifdef __WXGTK3__
setlocale(LC_ALL, "");
#else
gtk_set_locale();
#endif
wxUpdateLocaleIsUtf8();
}
#endif
@@ -465,7 +474,9 @@ wxGUIAppTraits::GetStandardCmdLineOptions(wxArrayString& names,
wxString usage;
#ifdef __WXGTK26__
#ifndef __WXGTK3__
if (!gtk_check_version(2,6,0))
#endif
{
// since GTK>=2.6, we can use the glib_check_version() symbol...

View File

@@ -452,7 +452,7 @@ bool wxWebViewWebKit::Enable( bool enable )
if (!wxControl::Enable(enable))
return false;
gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable);
gtk_widget_set_sensitive(gtk_bin_get_child(GTK_BIN(m_widget)), enable);
//if (enable)
// GTKFixSensitivity();

View File

@@ -10,9 +10,13 @@
#include "wx/wxprec.h"
#include "wx/defs.h"
#include "wx/gtk/private.h"
#include <gtk/gtk.h>
#include "wx/gtk/private/win_gtk.h"
#include "wx/gtk/private.h"
#include "wx/gtk/private/gtk2-compat.h"
/*
wxPizza is a custom GTK+ widget derived from GtkFixed. A custom widget
is needed to adapt GTK+ to wxWidgets needs in 3 areas: scrolling, window
@@ -37,28 +41,40 @@ struct wxPizzaChild
static GtkWidgetClass* parent_class;
#ifdef __WXGTK3__
enum {
PROP_0,
PROP_HADJUSTMENT,
PROP_VADJUSTMENT,
PROP_HSCROLL_POLICY,
PROP_VSCROLL_POLICY
};
#endif
extern "C" {
struct wxPizzaClass
{
GtkFixedClass parent;
#ifndef __WXGTK3__
void (*set_scroll_adjustments)(GtkWidget*, GtkAdjustment*, GtkAdjustment*);
#endif
};
static void size_allocate(GtkWidget* widget, GtkAllocation* alloc)
static void pizza_size_allocate(GtkWidget* widget, GtkAllocation* alloc)
{
wxPizza* pizza = WX_PIZZA(widget);
int border_x, border_y;
pizza->get_border_widths(border_x, border_y);
int w = alloc->width - 2 * border_x;
GtkBorder border;
pizza->get_border(border);
int w = alloc->width - border.left - border.right;
if (w < 0) w = 0;
if (gtk_widget_get_realized(widget))
{
int h = alloc->height - 2 * border_y;
int h = alloc->height - border.top - border.bottom;
if (h < 0) h = 0;
const int x = alloc->x + border_x;
const int y = alloc->y + border_y;
const int x = alloc->x + border.left;
const int y = alloc->y + border.top;
GdkWindow* window = gtk_widget_get_window(widget);
int old_x, old_y;
@@ -69,18 +85,20 @@ static void size_allocate(GtkWidget* widget, GtkAllocation* alloc)
{
gdk_window_move_resize(window, x, y, w, h);
if (border_x + border_y)
if (border.left + border.right + border.top + border.bottom)
{
// old and new border areas need to be invalidated,
// otherwise they will not be erased/redrawn properly
GtkAllocation old_alloc;
gtk_widget_get_allocation(widget, &old_alloc);
GdkWindow* parent = gtk_widget_get_parent_window(widget);
gdk_window_invalidate_rect(parent, &widget->allocation, false);
gdk_window_invalidate_rect(parent, &old_alloc, false);
gdk_window_invalidate_rect(parent, alloc, false);
}
}
}
widget->allocation = *alloc;
gtk_widget_set_allocation(widget, alloc);
// adjust child positions
for (const GList* p = pizza->m_children; p; p = p->next)
@@ -103,44 +121,50 @@ static void size_allocate(GtkWidget* widget, GtkAllocation* alloc)
}
}
static void realize(GtkWidget* widget)
static void pizza_realize(GtkWidget* widget)
{
parent_class->realize(widget);
wxPizza* pizza = WX_PIZZA(widget);
if (pizza->m_border_style)
if (pizza->m_windowStyle & wxPizza::BORDER_STYLES)
{
int border_x, border_y;
pizza->get_border_widths(border_x, border_y);
int x = widget->allocation.x + border_x;
int y = widget->allocation.y + border_y;
int w = widget->allocation.width - 2 * border_x;
int h = widget->allocation.height - 2 * border_y;
GtkBorder border;
pizza->get_border(border);
GtkAllocation a;
gtk_widget_get_allocation(widget, &a);
int x = a.x + border.left;
int y = a.y + border.top;
int w = a.width - border.left - border.right;
int h = a.height - border.top - border.bottom;
if (w < 0) w = 0;
if (h < 0) h = 0;
gdk_window_move_resize(widget->window, x, y, w, h);
gdk_window_move_resize(gtk_widget_get_window(widget), x, y, w, h);
}
}
static void show(GtkWidget* widget)
static void pizza_show(GtkWidget* widget)
{
if (widget->parent && WX_PIZZA(widget)->m_border_style)
GtkWidget* parent = gtk_widget_get_parent(widget);
if (parent && (WX_PIZZA(widget)->m_windowStyle & wxPizza::BORDER_STYLES))
{
// invalidate whole allocation so borders will be drawn properly
const GtkAllocation& a = widget->allocation;
gtk_widget_queue_draw_area(widget->parent, a.x, a.y, a.width, a.height);
GtkAllocation a;
gtk_widget_get_allocation(widget, &a);
gtk_widget_queue_draw_area(parent, a.x, a.y, a.width, a.height);
}
parent_class->show(widget);
}
static void hide(GtkWidget* widget)
static void pizza_hide(GtkWidget* widget)
{
if (widget->parent && WX_PIZZA(widget)->m_border_style)
GtkWidget* parent = gtk_widget_get_parent(widget);
if (parent && (WX_PIZZA(widget)->m_windowStyle & wxPizza::BORDER_STYLES))
{
// invalidate whole allocation so borders will be erased properly
const GtkAllocation& a = widget->allocation;
gtk_widget_queue_draw_area(widget->parent, a.x, a.y, a.width, a.height);
GtkAllocation a;
gtk_widget_get_allocation(widget, &a);
gtk_widget_queue_draw_area(parent, a.x, a.y, a.width, a.height);
}
parent_class->hide(widget);
@@ -168,8 +192,35 @@ static void pizza_remove(GtkContainer* container, GtkWidget* widget)
}
}
#ifdef __WXGTK3__
static void pizza_get_preferred_width(GtkWidget* widget, int* minimum, int* natural)
{
*minimum = 0;
gtk_widget_get_size_request(widget, natural, NULL);
if (*natural < 0)
*natural = 0;
}
static void pizza_get_preferred_height(GtkWidget* widget, int* minimum, int* natural)
{
*minimum = 0;
gtk_widget_get_size_request(widget, NULL, natural);
if (*natural < 0)
*natural = 0;
}
// Needed to implement GtkScrollable interface, but we don't care about the
// properties. wxWindowGTK handles the adjustments and scroll policy.
static void pizza_get_property(GObject*, guint, GValue*, GParamSpec*)
{
}
static void pizza_set_property(GObject*, guint, const GValue*, GParamSpec*)
{
}
#else
// not used, but needs to exist so gtk_widget_set_scroll_adjustments will work
static void set_scroll_adjustments(GtkWidget*, GtkAdjustment*, GtkAdjustment*)
static void pizza_set_scroll_adjustments(GtkWidget*, GtkAdjustment*, GtkAdjustment*)
{
}
@@ -211,21 +262,33 @@ g_cclosure_user_marshal_VOID__OBJECT_OBJECT (GClosure *closure,
g_marshal_value_peek_object (param_values + 2),
data2);
}
#endif
static void class_init(void* g_class, void*)
{
GtkWidgetClass* widget_class = (GtkWidgetClass*)g_class;
widget_class->size_allocate = size_allocate;
widget_class->realize = realize;
widget_class->show = show;
widget_class->hide = hide;
widget_class->size_allocate = pizza_size_allocate;
widget_class->realize = pizza_realize;
widget_class->show = pizza_show;
widget_class->hide = pizza_hide;
GtkContainerClass* container_class = (GtkContainerClass*)g_class;
container_class->add = pizza_add;
container_class->remove = pizza_remove;
wxPizzaClass* klass = (wxPizzaClass*)g_class;
#ifdef __WXGTK3__
widget_class->get_preferred_width = pizza_get_preferred_width;
widget_class->get_preferred_height = pizza_get_preferred_height;
GObjectClass *gobject_class = G_OBJECT_CLASS(g_class);
gobject_class->set_property = pizza_set_property;
gobject_class->get_property = pizza_get_property;
g_object_class_override_property(gobject_class, PROP_HADJUSTMENT, "hadjustment");
g_object_class_override_property(gobject_class, PROP_VADJUSTMENT, "vadjustment");
g_object_class_override_property(gobject_class, PROP_HSCROLL_POLICY, "hscroll-policy");
g_object_class_override_property(gobject_class, PROP_VSCROLL_POLICY, "vscroll-policy");
#else
wxPizzaClass* klass = static_cast<wxPizzaClass*>(g_class);
// needed to make widget appear scrollable to GTK+
klass->set_scroll_adjustments = set_scroll_adjustments;
klass->set_scroll_adjustments = pizza_set_scroll_adjustments;
widget_class->set_scroll_adjustments_signal =
g_signal_new(
"set_scroll_adjustments",
@@ -235,7 +298,7 @@ static void class_init(void* g_class, void*)
NULL, NULL,
g_cclosure_user_marshal_VOID__OBJECT_OBJECT,
G_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
#endif
parent_class = GTK_WIDGET_CLASS(g_type_class_peek_parent(g_class));
}
@@ -243,7 +306,7 @@ static void class_init(void* g_class, void*)
GType wxPizza::type()
{
static GtkType type;
static GType type;
if (type == 0)
{
const GTypeInfo info = {
@@ -256,6 +319,10 @@ GType wxPizza::type()
};
type = g_type_register_static(
GTK_TYPE_FIXED, "wxPizza", &info, GTypeFlags(0));
#ifdef __WXGTK3__
const GInterfaceInfo interface_info = { NULL, NULL, NULL };
g_type_add_interface_static(type, GTK_TYPE_SCROLLABLE, &interface_info);
#endif
}
return type;
}
@@ -267,10 +334,8 @@ GtkWidget* wxPizza::New(long windowStyle)
pizza->m_children = NULL;
pizza->m_scroll_x = 0;
pizza->m_scroll_y = 0;
pizza->m_is_scrollable = (windowStyle & (wxHSCROLL | wxVSCROLL)) != 0;
// mask off border styles not useable with wxPizza
pizza->m_border_style = int(windowStyle & BORDER_STYLES);
#if GTK_CHECK_VERSION(3,0,0) || defined(GTK_DISABLE_DEPRECATED)
pizza->m_windowStyle = windowStyle;
#ifdef __WXGTK3__
gtk_widget_set_has_window(widget, true);
#else
gtk_fixed_set_has_window(GTK_FIXED(widget), true);
@@ -335,10 +400,13 @@ extern "C" {
static void scroll_adjust(GtkWidget* widget, void* data)
{
const AdjustData* p = static_cast<AdjustData*>(data);
widget->allocation.x += p->dx;
widget->allocation.y += p->dy;
GtkAllocation a;
gtk_widget_get_allocation(widget, &a);
a.x += p->dx;
a.y += p->dy;
gtk_widget_set_allocation(widget, &a);
if (widget->window == p->window)
if (gtk_widget_get_window(widget) == p->window)
{
// GtkFrame requires a queue_resize, otherwise parts of
// the frame newly exposed by the scroll are not drawn.
@@ -357,44 +425,46 @@ void wxPizza::scroll(int dx, int dy)
dx = -dx;
m_scroll_x -= dx;
m_scroll_y -= dy;
if (widget->window)
GdkWindow* window = gtk_widget_get_window(widget);
if (window)
{
gdk_window_scroll(widget->window, dx, dy);
gdk_window_scroll(window, dx, dy);
// Adjust child allocations. Doing a queue_resize on the children is not
// enough, sometimes they redraw in the wrong place during fast scrolling.
AdjustData data = { widget->window, dx, dy };
AdjustData data = { window, dx, dy };
gtk_container_forall(GTK_CONTAINER(widget), scroll_adjust, &data);
}
}
void wxPizza::get_border_widths(int& x, int& y)
void wxPizza::get_border(GtkBorder& border)
{
x = y = 0;
if (m_border_style == 0)
return;
#ifndef __WXUNIVERSAL__
if (m_border_style & wxBORDER_SIMPLE)
x = y = 1;
else if (m_is_scrollable /* || (m_border_style & wxBORDER_THEME) */)
if (m_windowStyle & wxBORDER_SIMPLE)
border.left = border.right = border.top = border.bottom = 1;
else if (m_windowStyle & (wxBORDER_RAISED | wxBORDER_SUNKEN | wxBORDER_THEME))
{
GtkWidget *style_widget = wxGTKPrivate::GetTreeWidget();
#ifdef __WXGTK3__
GtkStyleContext* sc;
if (m_windowStyle & (wxHSCROLL | wxVSCROLL))
sc = gtk_widget_get_style_context(wxGTKPrivate::GetTreeWidget());
else
sc = gtk_widget_get_style_context(wxGTKPrivate::GetEntryWidget());
if (style_widget->style)
{
x = style_widget->style->xthickness;
y = style_widget->style->ythickness;
}
gtk_style_context_get_border(sc, GTK_STATE_FLAG_NORMAL, &border);
#else // !__WXGTK3__
GtkStyle* style;
if (m_windowStyle & (wxHSCROLL | wxVSCROLL))
style = gtk_widget_get_style(wxGTKPrivate::GetTreeWidget());
else
style = gtk_widget_get_style(wxGTKPrivate::GetEntryWidget());
border.left = border.right = style->xthickness;
border.top = border.bottom = style->ythickness;
#endif // !__WXGTK3__
}
else
#endif // !__WXUNIVERSAL__
{
GtkWidget *style_widget = wxGTKPrivate::GetEntryWidget();
if (style_widget->style)
{
x = style_widget->style->xthickness;
y = style_widget->style->ythickness;
}
border.left = border.right = border.top = border.bottom = 0;
}
#endif
}

View File

@@ -32,12 +32,17 @@
#include "wx/caret.h"
#include "wx/fontutil.h"
#include "wx/sysopt.h"
#ifdef __WXGTK3__
#include "wx/gtk/dc.h"
#endif
#include <ctype.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/private/win_gtk.h"
#include "wx/gtk/private/gtk2-compat.h"
#include "wx/gtk/private/event.h"
#include "wx/gtk/private/win_gtk.h"
using namespace wxGTKImpl;
#ifdef GDK_WINDOWING_X11
@@ -48,7 +53,7 @@ typedef guint KeySym;
#endif
#include <gdk/gdkkeysyms.h>
#if GTK_CHECK_VERSION(3,0,0)
#ifdef __WXGTK3__
#include <gdk/gdkkeysyms-compat.h>
#endif
@@ -222,35 +227,47 @@ int g_lastButtonNumber = 0;
#define TRACE_FOCUS wxT("focus")
//-----------------------------------------------------------------------------
// "expose_event" of m_wxwindow
// "expose_event"/"draw" from m_wxwindow
//-----------------------------------------------------------------------------
extern "C" {
static gboolean
gtk_window_expose_callback( GtkWidget*,
GdkEventExpose *gdk_event,
wxWindow *win )
#ifdef __WXGTK3__
static gboolean draw(GtkWidget*, cairo_t* cr, wxWindow* win)
{
if (gtk_cairo_should_draw_window(cr, win->GTKGetDrawingWindow()))
win->GTKSendPaintEvents(cr);
return false;
}
#else // !__WXGTK3__
static gboolean expose_event(GtkWidget*, GdkEventExpose* gdk_event, wxWindow* win)
{
if (gdk_event->window == win->GTKGetDrawingWindow())
{
win->GetUpdateRegion() = wxRegion( gdk_event->region );
win->GtkSendPaintEvents();
}
// Let parent window draw window-less widgets
return FALSE;
win->GTKSendPaintEvents(gdk_event->region);
return false;
}
#endif // !__WXGTK3__
}
#ifndef __WXUNIVERSAL__
//-----------------------------------------------------------------------------
// "expose_event" from m_wxwindow->parent, for drawing border
// "expose_event"/"draw" from m_wxwindow->parent, for drawing border
//-----------------------------------------------------------------------------
extern "C" {
static gboolean
expose_event_border(GtkWidget* widget, GdkEventExpose* gdk_event, wxWindow* win)
#ifdef __WXGTK3__
draw_border(GtkWidget*, cairo_t* cr, wxWindow* win)
#else
draw_border(GtkWidget* widget, GdkEventExpose* gdk_event, wxWindow* win)
#endif
{
#ifdef __WXGTK3__
if (!gtk_cairo_should_draw_window(cr, gtk_widget_get_parent_window(win->m_wxwindow)))
#else
if (gdk_event->window != gtk_widget_get_parent_window(win->m_wxwindow))
#endif
return false;
if (!win->IsShown())
@@ -268,11 +285,31 @@ expose_event_border(GtkWidget* widget, GdkEventExpose* gdk_event, wxWindow* win)
if (win->HasFlag(wxBORDER_SIMPLE))
{
#ifdef __WXGTK3__
GtkStyleContext* sc = gtk_widget_get_style_context(win->m_wxwindow);
GdkRGBA c;
gtk_style_context_get_border_color(sc, GTK_STATE_FLAG_NORMAL, &c);
gdk_cairo_set_source_rgba(cr, &c);
cairo_set_line_width(cr, 1);
cairo_rectangle(cr, x + 0.5, y + 0.5, w - 1, h - 1);
cairo_stroke(cr);
#else
gdk_draw_rectangle(gdk_event->window,
gtk_widget_get_style(widget)->black_gc, false, x, y, w - 1, h - 1);
#endif
}
else
else if (win->HasFlag(wxBORDER_RAISED | wxBORDER_SUNKEN | wxBORDER_THEME))
{
#ifdef __WXGTK3__
//TODO: wxBORDER_RAISED/wxBORDER_SUNKEN
GtkStyleContext* sc;
if (win->HasFlag(wxHSCROLL | wxVSCROLL))
sc = gtk_widget_get_style_context(wxGTKPrivate::GetTreeWidget());
else
sc = gtk_widget_get_style_context(wxGTKPrivate::GetEntryWidget());
gtk_render_frame(sc, cr, x, y, w, h);
#else // !__WXGTK3__
GtkShadowType shadow = GTK_SHADOW_IN;
if (win->HasFlag(wxBORDER_RAISED))
shadow = GTK_SHADOW_OUT;
@@ -292,6 +329,7 @@ expose_event_border(GtkWidget* widget, GdkEventExpose* gdk_event, wxWindow* win)
gtk_paint_shadow(
gtk_widget_get_style(win->m_wxwindow), gdk_event->window, GTK_STATE_NORMAL,
shadow, &clipRect, wxGTKPrivate::GetEntryWidget(), detail, x, y, w, h);
#endif // !__WXGTK3__
}
return false;
}
@@ -308,13 +346,16 @@ parent_set(GtkWidget* widget, GtkWidget* old_parent, wxWindow* win)
if (old_parent)
{
g_signal_handlers_disconnect_by_func(
old_parent, (void*)expose_event_border, win);
old_parent, (void*)draw_border, win);
}
GtkWidget* parent = gtk_widget_get_parent(widget);
if (parent)
{
g_signal_connect_after(parent, "expose_event",
G_CALLBACK(expose_event_border), win);
#ifdef __WXGTK3__
g_signal_connect_after(parent, "draw", G_CALLBACK(draw_border), win);
#else
g_signal_connect_after(parent, "expose_event", G_CALLBACK(draw_border), win);
#endif
}
}
}
@@ -1258,7 +1299,7 @@ extern "C"
//-----------------------------------------------------------------------------
static gboolean
gtk_window_button_press_callback( GtkWidget *widget,
gtk_window_button_press_callback( GtkWidget* WXUNUSED_IN_GTK3(widget),
GdkEventButton *gdk_event,
wxWindowGTK *win )
{
@@ -1291,6 +1332,7 @@ gtk_window_button_press_callback( GtkWidget *widget,
wxEventType event_type = wxEVT_NULL;
#ifndef __WXGTK3__
if ( gdk_event->type == GDK_2BUTTON_PRESS &&
gdk_event->button >= 1 && gdk_event->button <= 3 )
{
@@ -1301,6 +1343,7 @@ gtk_window_button_press_callback( GtkWidget *widget,
display->button_click_time[1] = 0;
display->button_click_time[0] = 0;
}
#endif // !__WXGTK3__
if (gdk_event->button == 1)
{
@@ -1894,16 +1937,6 @@ gtk_window_realized_callback(GtkWidget* WXUNUSED(widget), wxWindowGTK* win)
win->GTKHandleRealized();
}
//-----------------------------------------------------------------------------
// "unrealize" from m_wxwindow
//-----------------------------------------------------------------------------
static void unrealize(GtkWidget*, wxWindowGTK* win)
{
if (win->m_imData)
gtk_im_context_set_client_window(win->m_imData->context, NULL);
}
//-----------------------------------------------------------------------------
// "size_allocate" from m_wxwindow or m_widget
//-----------------------------------------------------------------------------
@@ -1915,10 +1948,10 @@ size_allocate(GtkWidget*, GtkAllocation* alloc, wxWindow* win)
int h = alloc->height;
if (win->m_wxwindow)
{
int border_x, border_y;
WX_PIZZA(win->m_wxwindow)->get_border_widths(border_x, border_y);
w -= 2 * border_x;
h -= 2 * border_y;
GtkBorder border;
WX_PIZZA(win->m_wxwindow)->get_border(border);
w -= border.left + border.right;
h -= border.top + border.bottom;
if (w < 0) w = 0;
if (h < 0) h = 0;
}
@@ -1963,29 +1996,40 @@ gtk_window_grab_broken( GtkWidget*,
#endif
//-----------------------------------------------------------------------------
// "style_set"
// "style_set"/"style_updated"
//-----------------------------------------------------------------------------
static
void gtk_window_style_set_callback( GtkWidget *WXUNUSED(widget),
GtkStyle *previous_style,
wxWindow* win )
#ifdef __WXGTK3__
static void style_updated(GtkWidget*, wxWindow* win)
#else
static void style_updated(GtkWidget*, GtkStyle*, wxWindow* win)
#endif
{
if (win && previous_style)
if (win->IsTopLevel())
{
if (win->IsTopLevel())
{
wxSysColourChangedEvent event;
event.SetEventObject(win);
win->GTKProcessEvent(event);
}
else
{
// Border width could change, which will change client size.
// Make sure size event occurs for this
win->m_oldClientWidth = 0;
}
wxSysColourChangedEvent event;
event.SetEventObject(win);
win->GTKProcessEvent(event);
}
else
{
// Border width could change, which will change client size.
// Make sure size event occurs for this
win->m_oldClientWidth = 0;
}
}
//-----------------------------------------------------------------------------
// "unrealize" from m_wxwindow
//-----------------------------------------------------------------------------
static void unrealize(GtkWidget*, wxWindow* win)
{
if (win->m_imData)
gtk_im_context_set_client_window(win->m_imData->context, NULL);
g_signal_handlers_disconnect_by_func(
win->m_wxwindow, (void*)style_updated, win);
}
} // extern "C"
@@ -2036,6 +2080,20 @@ void wxWindowGTK::GTKHandleRealized()
GTKProcessEvent( event );
GTKUpdateCursor(true, false);
if (m_wxwindow &&
(IsTopLevel() || HasFlag(wxBORDER_RAISED | wxBORDER_SUNKEN | wxBORDER_THEME)))
{
// attaching to style changed signal after realization avoids initial
// changes we don't care about
g_signal_connect(m_wxwindow,
#ifdef __WXGTK3__
"style_updated",
#else
"style_set",
#endif
G_CALLBACK(style_updated), this);
}
}
// ----------------------------------------------------------------------------
@@ -2091,6 +2149,19 @@ bool wxGetKeyState(wxKeyCode WXUNUSED(key))
}
#endif // __WINDOWS__
static void GetMouseState(int& x, int& y, GdkModifierType& mask)
{
wxWindow* tlw = NULL;
if (!wxTopLevelWindows.empty())
tlw = wxTopLevelWindows.front();
GdkDisplay* display;
if (tlw && tlw->m_widget)
display = gtk_widget_get_display(tlw->m_widget);
else
display = gdk_display_get_default();
gdk_display_get_pointer(display, NULL, &x, &y, &mask);
}
wxMouseState wxGetMouseState()
{
wxMouseState ms;
@@ -2099,7 +2170,7 @@ wxMouseState wxGetMouseState()
gint y;
GdkModifierType mask;
gdk_window_get_pointer(NULL, &x, &y, &mask);
GetMouseState(x, y, mask);
ms.SetX(x);
ms.SetY(y);
@@ -2147,6 +2218,9 @@ void wxWindowGTK::Init()
m_noExpose = false;
m_nativeSizeEvent = false;
#ifdef __WXGTK3__
m_paintContext = NULL;
#endif
m_isScrolling = false;
m_mouseButtonDown = false;
@@ -2387,11 +2461,14 @@ void wxWindowGTK::PostCreation()
IsTransparentBackgroundSupported() )
{
GdkScreen *screen = gtk_widget_get_screen (m_widget);
#ifdef __WXGTK3__
gtk_widget_set_visual(m_widget, gdk_screen_get_rgba_visual(screen));
#else
GdkColormap *rgba_colormap = gdk_screen_get_rgba_colormap (screen);
if (rgba_colormap)
gtk_widget_set_colormap(m_widget, rgba_colormap);
#endif
}
#endif // wxGTK_HAS_COMPOSITING_SUPPORT
@@ -2400,9 +2477,11 @@ void wxWindowGTK::PostCreation()
if (!m_noExpose)
{
// these get reported to wxWidgets -> wxPaintEvent
g_signal_connect (m_wxwindow, "expose_event",
G_CALLBACK (gtk_window_expose_callback), this);
#ifdef __WXGTK3__
g_signal_connect(m_wxwindow, "draw", G_CALLBACK(draw), this);
#else
g_signal_connect(m_wxwindow, "expose_event", G_CALLBACK(expose_event), this);
#endif
if (GetLayoutDirection() == wxLayout_LeftToRight)
gtk_widget_set_redraw_on_allocate(m_wxwindow, HasFlag(wxFULL_REPAINT_ON_RESIZE));
@@ -2476,7 +2555,9 @@ void wxWindowGTK::PostCreation()
}
#if GTK_CHECK_VERSION(2, 8, 0)
#ifndef __WXGTK3__
if ( gtk_check_version(2,8,0) == NULL )
#endif
{
// Make sure we can notify the app when mouse capture is lost
if ( m_wxwindow )
@@ -2542,10 +2623,6 @@ void wxWindowGTK::ConnectWidget( GtkWidget *widget )
G_CALLBACK (gtk_window_enter_callback), this);
g_signal_connect (widget, "leave_notify_event",
G_CALLBACK (gtk_window_leave_callback), this);
if (m_wxwindow && (IsTopLevel() || HasFlag(wxBORDER_RAISED | wxBORDER_SUNKEN | wxBORDER_THEME)))
g_signal_connect (m_wxwindow, "style_set",
G_CALLBACK (gtk_window_style_set_callback), this);
}
bool wxWindowGTK::Destroy()
@@ -2758,6 +2835,8 @@ void wxWindowGTK::DoGetClientSize( int *width, int *height ) const
gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(m_widget),
&policy[ScrollDir_Horz],
&policy[ScrollDir_Vert]);
const int scrollbar_spacing =
GTK_SCROLLED_WINDOW_GET_CLASS(m_widget)->scrollbar_spacing;
for ( int i = 0; i < ScrollDir_Max; i++ )
{
@@ -2784,15 +2863,32 @@ void wxWindowGTK::DoGetClientSize( int *width, int *height ) const
continue;
}
GtkScrolledWindowClass *scroll_class =
GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT_GET_CLASS(m_widget) );
GtkRequisition req;
#ifdef __WXGTK3__
GtkWidget* widget = GTK_WIDGET(range);
if (i == ScrollDir_Horz)
{
if (height)
{
gtk_widget_get_preferred_height(widget, NULL, &req.height);
h -= req.height + scrollbar_spacing;
}
}
else
{
if (width)
{
gtk_widget_get_preferred_width(widget, NULL, &req.width);
w -= req.width + scrollbar_spacing;
}
}
#else // !__WXGTK3__
gtk_widget_size_request(GTK_WIDGET(range), &req);
if (i == ScrollDir_Horz)
h -= req.height + scroll_class->scrollbar_spacing;
h -= req.height + scrollbar_spacing;
else
w -= req.width + scroll_class->scrollbar_spacing;
w -= req.width + scrollbar_spacing;
#endif // !__WXGTK3__
}
}
@@ -2815,10 +2911,9 @@ wxSize wxWindowGTK::DoGetBorderSize() const
if ( !m_wxwindow )
return wxWindowBase::DoGetBorderSize();
int x, y;
WX_PIZZA(m_wxwindow)->get_border_widths(x, y);
return 2*wxSize(x, y);
GtkBorder border;
WX_PIZZA(m_wxwindow)->get_border(border);
return wxSize(border.left + border.right, border.top + border.bottom);
}
void wxWindowGTK::DoGetPosition( int *x, int *y ) const
@@ -3588,7 +3683,7 @@ void wxWindowGTK::WarpPointer( int x, int y )
ClientToScreen(&x, &y);
GdkDisplay* display = gtk_widget_get_display(m_widget);
GdkScreen* screen = gtk_widget_get_screen(m_widget);
#ifdef __WXGTK30__
#ifdef __WXGTK3__
GdkDeviceManager* manager = gdk_display_get_device_manager(display);
gdk_device_warp(gdk_device_manager_get_client_pointer(manager), screen, x, y);
#else
@@ -3707,16 +3802,23 @@ bool wxWindowGTK::DoIsExposed( int x, int y, int w, int h ) const
return m_updateRegion.Contains(x, y, w, h) != wxOutRegion;
}
void wxWindowGTK::GtkSendPaintEvents()
#ifdef __WXGTK3__
void wxWindowGTK::GTKSendPaintEvents(cairo_t* cr)
#else
void wxWindowGTK::GTKSendPaintEvents(const GdkRegion* region)
#endif
{
if (!m_wxwindow)
{
m_updateRegion.Clear();
return;
}
#ifdef __WXGTK3__
m_paintContext = cr;
double x1, y1, x2, y2;
cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
m_updateRegion = wxRegion(int(x1), int(y1), int(x2 - x1), int(y2 - y1));
#else // !__WXGTK3__
m_updateRegion = wxRegion(region);
#if wxGTK_HAS_COMPOSITING_SUPPORT
cairo_t* cr = NULL;
#endif
#endif // !__WXGTK3__
// Clip to paint region in wxClientDC
m_clipPaintRegion = true;
@@ -3727,8 +3829,7 @@ void wxWindowGTK::GtkSendPaintEvents()
// Transform m_updateRegion under RTL
m_updateRegion.Clear();
gint width;
gdk_drawable_get_size(gtk_widget_get_window(m_wxwindow), &width, NULL);
const int width = gdk_window_get_width(GTKGetDrawingWindow());
wxRegionIterator upd( m_nativeUpdateRegion );
while (upd)
@@ -3757,20 +3858,26 @@ void wxWindowGTK::GtkSendPaintEvents()
// explicitly paint.
// NB: it works also for top level windows (but this is the
// windows manager which then does the compositing job)
#ifndef __WXGTK3__
cr = gdk_cairo_create(m_wxwindow->window);
gdk_cairo_region(cr, m_nativeUpdateRegion.GetRegion());
cairo_clip(cr);
#endif
cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
cairo_paint(cr);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
#ifndef __WXGTK3__
cairo_surface_flush(cairo_get_target(cr));
#endif
}
#endif // wxGTK_HAS_COMPOSITING_SUPPORT
break;
case wxBG_STYLE_ERASE:
{
#ifdef __WXGTK3__
wxGTKCairoDC dc(cr);
#else
wxWindowDC dc( (wxWindow*)this );
dc.SetDeviceClippingRegion( m_updateRegion );
@@ -3783,7 +3890,7 @@ void wxWindowGTK::GtkSendPaintEvents()
dc.SetBackground(GetBackgroundColour());
dc.Clear();
}
#endif // !__WXGTK3__
wxEraseEvent erase_event( GetId(), &dc );
erase_event.SetEventObject( this );
@@ -3798,34 +3905,28 @@ void wxWindowGTK::GtkSendPaintEvents()
case wxBG_STYLE_SYSTEM:
if ( GetThemeEnabled() )
{
GdkWindow* gdkWindow = GTKGetDrawingWindow();
const int w = gdk_window_get_width(gdkWindow);
const int h = gdk_window_get_height(gdkWindow);
#ifdef __WXGTK3__
GtkStyleContext* sc = gtk_widget_get_style_context(m_wxwindow);
gtk_render_background(sc, cr, 0, 0, w, h);
#else
// find ancestor from which to steal background
wxWindow *parent = wxGetTopLevelParent((wxWindow *)this);
if (!parent)
parent = (wxWindow*)this;
if (gtk_widget_get_mapped(parent->m_widget))
{
wxRegionIterator upd( m_nativeUpdateRegion );
while (upd)
{
GdkRectangle rect;
rect.x = upd.GetX();
rect.y = upd.GetY();
rect.width = upd.GetWidth();
rect.height = upd.GetHeight();
gtk_paint_flat_box(gtk_widget_get_style(parent->m_widget),
GTKGetDrawingWindow(),
GdkRectangle rect;
m_nativeUpdateRegion.GetBox(rect.x, rect.y, rect.width, rect.height);
gtk_paint_flat_box(gtk_widget_get_style(parent->m_widget),
gdkWindow,
gtk_widget_get_state(m_wxwindow),
GTK_SHADOW_NONE,
&rect,
parent->m_widget,
(char *)"base",
0, 0, -1, -1 );
++upd;
}
}
0, 0, w, h);
#endif // !__WXGTK3__
}
break;
@@ -3855,13 +3956,14 @@ void wxWindowGTK::GtkSendPaintEvents()
wxWindow *compositeChild = node->GetData();
if (compositeChild->GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT)
{
#ifndef __WXGTK3__
if (cr == NULL)
{
cr = gdk_cairo_create(m_wxwindow->window);
gdk_cairo_region(cr, m_nativeUpdateRegion.GetRegion());
cairo_clip(cr);
}
#endif // !__WXGTK3__
GtkWidget *child = compositeChild->m_wxwindow;
GtkAllocation alloc;
gtk_widget_get_allocation(child, &alloc);
@@ -3873,13 +3975,17 @@ void wxWindowGTK::GtkSendPaintEvents()
cairo_paint(cr);
}
}
#ifndef __WXGTK3__
if (cr)
cairo_destroy(cr);
#endif
}
#endif // wxGTK_HAS_COMPOSITING_SUPPORT
m_clipPaintRegion = false;
#ifdef __WXGTK3__
m_paintContext = NULL;
#endif
m_updateRegion.Clear();
m_nativeUpdateRegion.Clear();
}
@@ -3929,11 +4035,13 @@ bool wxWindowGTK::SetBackgroundColour( const wxColour &colour )
if (!wxWindowBase::SetBackgroundColour(colour))
return false;
#ifndef __WXGTK3__
if (colour.IsOk())
{
// We need the pixel value e.g. for background clearing.
m_backgroundColour.CalcPixel(gtk_widget_get_colormap(m_widget));
}
#endif
// apply style change (forceStyle=true so that new style is applied
// even if the bg colour changed from valid to wxNullColour)
@@ -3951,11 +4059,13 @@ bool wxWindowGTK::SetForegroundColour( const wxColour &colour )
return false;
}
#ifndef __WXGTK3__
if (colour.IsOk())
{
// We need the pixel value e.g. for background clearing.
m_foregroundColour.CalcPixel(gtk_widget_get_colormap(m_widget));
}
#endif
// apply style change (forceStyle=true so that new style is applied
// even if the bg colour changed from valid to wxNullColour):
@@ -3969,6 +4079,7 @@ PangoContext *wxWindowGTK::GTKGetPangoDefaultContext()
return gtk_widget_get_pango_context( m_widget );
}
#ifndef __WXGTK3__
GtkRcStyle *wxWindowGTK::GTKCreateWidgetStyle(bool forceStyle)
{
// do we need to apply any changes at all?
@@ -4037,15 +4148,20 @@ GtkRcStyle *wxWindowGTK::GTKCreateWidgetStyle(bool forceStyle)
return style;
}
#endif // !__WXGTK3__
void wxWindowGTK::GTKApplyWidgetStyle(bool forceStyle)
void wxWindowGTK::GTKApplyWidgetStyle(bool WXUNUSED_IN_GTK3(forceStyle))
{
#ifdef __WXGTK3__
DoApplyWidgetStyle(NULL);
#else
GtkRcStyle *style = GTKCreateWidgetStyle(forceStyle);
if ( style )
{
DoApplyWidgetStyle(style);
g_object_unref(style);
}
#endif
// Style change may affect GTK+'s size calculation:
InvalidateBestSize();
@@ -4053,30 +4169,39 @@ void wxWindowGTK::GTKApplyWidgetStyle(bool forceStyle)
void wxWindowGTK::DoApplyWidgetStyle(GtkRcStyle *style)
{
if ( m_wxwindow )
{
// block the signal temporarily to avoid sending
// wxSysColourChangedEvents when we change the colours ourselves
bool unblock = false;
if ( IsTopLevel() )
{
unblock = true;
g_signal_handlers_block_by_func(
m_wxwindow, (void *)gtk_window_style_set_callback, this);
}
GtkWidget* widget = m_wxwindow ? m_wxwindow : m_widget;
gtk_widget_modify_style(m_wxwindow, style);
if ( unblock )
{
g_signal_handlers_unblock_by_func(
m_wxwindow, (void *)gtk_window_style_set_callback, this);
}
}
else
// block the signal temporarily to avoid sending
// wxSysColourChangedEvents when we change the colours ourselves
bool unblock = false;
if (m_wxwindow && IsTopLevel())
{
gtk_widget_modify_style(m_widget, style);
unblock = true;
g_signal_handlers_block_by_func(
m_wxwindow, (void*)style_updated, this);
}
GTKApplyStyle(widget, style);
if (unblock)
{
g_signal_handlers_unblock_by_func(
m_wxwindow, (void*)style_updated, this);
}
}
void wxWindowGTK::GTKApplyStyle(GtkWidget* widget, GtkRcStyle* WXUNUSED_IN_GTK3(style))
{
#ifdef __WXGTK3__
const PangoFontDescription* pfd = NULL;
if (m_font.IsOk())
pfd = pango_font_description_copy(m_font.GetNativeFontInfo()->description);
gtk_widget_override_font(widget, pfd);
gtk_widget_override_color(widget, GTK_STATE_FLAG_NORMAL, m_foregroundColour);
gtk_widget_override_background_color(widget, GTK_STATE_FLAG_NORMAL, m_backgroundColour);
#else
gtk_widget_modify_style(widget, style);
#endif
}
bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style)
@@ -4084,6 +4209,7 @@ bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style)
if (!wxWindowBase::SetBackgroundStyle(style))
return false;
#ifndef __WXGTK3__
GdkWindow *window;
if ( m_wxwindow )
{
@@ -4120,6 +4246,7 @@ bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style)
// even if the bg colour changed from valid to wxNullColour):
GTKApplyWidgetStyle(true);
}
#endif // !__WXGTK3__
return true;
}
@@ -4127,6 +4254,7 @@ bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style)
bool wxWindowGTK::IsTransparentBackgroundSupported(wxString* reason) const
{
#if wxGTK_HAS_COMPOSITING_SUPPORT
#ifndef __WXGTK3__
if (gtk_check_version(wxGTK_VERSION_REQUIRED_FOR_COMPOSITING) != NULL)
{
if (reason)
@@ -4138,6 +4266,7 @@ bool wxWindowGTK::IsTransparentBackgroundSupported(wxString* reason) const
return false;
}
#endif // !__WXGTK3__
// NB: We don't check here if the particular kind of widget supports
// transparency, we check only if it would be possible for a generic window
@@ -4563,17 +4692,9 @@ wxWindow* wxFindWindowAtPointer(wxPoint& pt)
// Get the current mouse position.
wxPoint wxGetMousePosition()
{
wxWindow* tlw = NULL;
if (!wxTopLevelWindows.empty())
tlw = wxTopLevelWindows.front();
GdkDisplay* display;
if (tlw && tlw->m_widget)
display = gtk_widget_get_display(tlw->m_widget);
else
display = gdk_display_get_default();
int x, y;
gdk_display_get_pointer(display, NULL, &x, &y, NULL);
GdkModifierType unused;
GetMouseState(x, y, unused);
return wxPoint(x, y);
}

View File

@@ -256,15 +256,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxGStreamerMediaBackend, wxMediaBackend)
//-----------------------------------------------------------------------------
#ifdef __WXGTK__
extern "C" {
static gboolean gtk_window_expose_callback(GtkWidget *widget,
GdkEventExpose *event,
wxGStreamerMediaBackend *be)
static gboolean
#ifdef __WXGTK3__
draw(GtkWidget* widget, cairo_t* cr, wxGStreamerMediaBackend* be)
#else
expose_event(GtkWidget* widget, GdkEventExpose* event, wxGStreamerMediaBackend* be)
#endif
{
if(event->count > 0)
return FALSE;
GdkWindow* window = gtk_widget_get_window(widget);
// I've seen this recommended somewhere...
// TODO: Is this needed? Maybe it is just cruft...
// gst_x_overlay_set_xwindow_id( GST_X_OVERLAY(be->m_xoverlay),
@@ -282,9 +280,17 @@ static gboolean gtk_window_expose_callback(GtkWidget *widget,
else
{
// draw a black background like some other backends do....
gdk_draw_rectangle (window, widget->style->black_gc, TRUE, 0, 0,
#ifdef __WXGTK3__
GtkAllocation a;
gtk_widget_get_allocation(widget, &a);
cairo_rectangle(cr, 0, 0, a.width, a.height);
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_fill(cr);
#else
gdk_draw_rectangle (event->window, widget->style->black_gc, TRUE, 0, 0,
widget->allocation.width,
widget->allocation.height);
#endif
}
return FALSE;
@@ -310,11 +316,15 @@ static gint gtk_window_realize_callback(GtkWidget* widget,
wxASSERT(window);
gst_x_overlay_set_xwindow_id( GST_X_OVERLAY(be->m_xoverlay),
GDK_WINDOW_XWINDOW( window )
GDK_WINDOW_XID(window)
);
g_signal_connect (be->GetControl()->m_wxwindow,
"expose_event",
G_CALLBACK(gtk_window_expose_callback), be);
#ifdef __WXGTK3__
"draw", G_CALLBACK(draw),
#else
"expose_event", G_CALLBACK(expose_event),
#endif
be);
return 0;
}
}
@@ -716,16 +726,19 @@ void wxGStreamerMediaBackend::SetupXOverlay()
#endif
gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(m_xoverlay),
#ifdef __WXGTK__
GDK_WINDOW_XWINDOW( window )
GDK_WINDOW_XID(window)
#else
ctrl->GetHandle()
#endif
);
#ifdef __WXGTK__
g_signal_connect(m_ctrl->m_wxwindow,
// m_ctrl->m_wxwindow/*m_ctrl->m_widget*/,
"expose_event",
G_CALLBACK(gtk_window_expose_callback), this);
#ifdef __WXGTK3__
"draw", G_CALLBACK(draw),
#else
"expose_event", G_CALLBACK(expose_event),
#endif
this);
} // end if GtkPizza realized
#endif
}