changes to make wxGTK compile with GTK+ 2.0: now it does but the minimal

sample crashes on startup


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14567 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2002-03-12 19:24:30 +00:00
parent 7fccee998d
commit 9e691f46b2
65 changed files with 1902 additions and 1700 deletions

View File

@@ -331,7 +331,6 @@ dnl ===========================================================================
dnl "3rd party" macros included here because they are not widely available
dnl ===========================================================================
dnl ---------------------------------------------------------------------------
dnl test for availability of iconv()
dnl ---------------------------------------------------------------------------
@@ -410,199 +409,3 @@ size_t iconv();
AC_SUBST(LIBICONV)
])
dnl ---------------------------------------------------------------------------
dnl test for GTK+ 2.0
dnl ---------------------------------------------------------------------------
dnl AM_PATH_GTK_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
dnl
AC_DEFUN(AM_PATH_GTK_2_0,
[dnl
dnl Get the cflags and libraries from the gtk-config-2.0 script
dnl
AC_ARG_WITH(gtk-prefix,[ --with-gtk-prefix=PFX Prefix where GTK is installed (optional)],
gtk_config_prefix="$withval", gtk_config_prefix="")
AC_ARG_WITH(gtk-exec-prefix,[ --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
, enable_gtktest=yes)
for module in . $4
do
case "$module" in
gthread)
gtk_config_args="$gtk_config_args gthread"
;;
esac
done
if test x$gtk_config_exec_prefix != x ; then
gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
if test x${GTK_CONFIG_2_0+set} != xset ; then
GTK_CONFIG_2_0=$gtk_config_exec_prefix/bin/gtk-config-2.0
fi
fi
if test x$gtk_config_prefix != x ; then
gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
if test x${GTK_CONFIG_2_0+set} != xset ; then
GTK_CONFIG_2_0=$gtk_config_prefix/bin/gtk-config-2.0
fi
fi
AC_PATH_PROG(GTK_CONFIG_2_0, gtk-config-2.0, no)
min_gtk_version=ifelse([$1], ,1.3.1,$1)
AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
no_gtk=""
if test "$GTK_CONFIG_2_0" = "no" ; then
no_gtk=yes
else
GTK_CFLAGS=`$GTK_CONFIG_2_0 $gtk_config_args --cflags`
GTK_LIBS=`$GTK_CONFIG_2_0 $gtk_config_args --libs`
gtk_config_major_version=`$GTK_CONFIG_2_0 $gtk_config_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
gtk_config_minor_version=`$GTK_CONFIG_2_0 $gtk_config_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
gtk_config_micro_version=`$GTK_CONFIG_2_0 $gtk_config_args --version | \
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 gtk-config-2.0 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;
system ("touch conf.gtktest");
/* 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*** 'gtk-config-2.0 --version' 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 gtk-config-2.0 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 gtk-config-2.0 was wrong, set the environment variable GTK_CONFIG_2_0\n");
printf("*** to point to the correct copy of gtk-config-2.0, and remove the file config.cache\n");
printf("*** before re-running configure\n");
}
#if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION)
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);
}
#endif /* defined (GTK_MAJOR_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 gtk-config-2.0 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 GTK_CONFIG_2_0 environment to point to the\n");
printf("*** correct copy of gtk-config-2.0. (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 "$GTK_CONFIG_2_0" = "no" ; then
echo "*** The gtk-config-2.0 script installed by GTK could not be found"
echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the GTK_CONFIG_2_0 environment variable to the"
echo "*** full path to gtk-config-2.0."
else
if test -f conf.gtktest ; then
:
else
echo "*** Could not run GTK test program, checking why..."
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 "***"
echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
echo "*** came with the system with the command"
echo "***"
echo "*** rpm --erase --nodeps gtk gtk-devel" ],
[ 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 was incorrectly installed"
echo "*** or that you have moved GTK since it was installed. In the latter case, you"
echo "*** may want to edit the gtk-config-2.0 script: $GTK_CONFIG_2_0" ])
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
])

141
aclocal.m4 vendored
View File

@@ -1,14 +1,15 @@
dnl aclocal.m4 generated automatically by aclocal 1.4
# aclocal.m4 generated automatically by aclocal 1.6 -*- Autoconf -*-
dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
# Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
# Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
dnl PARTICULAR PURPOSE.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
dnl ---------------------------------------------------------------------------
dnl
@@ -343,7 +344,6 @@ dnl ===========================================================================
dnl "3rd party" macros included here because they are not widely available
dnl ===========================================================================
dnl ---------------------------------------------------------------------------
dnl test for availability of iconv()
dnl ---------------------------------------------------------------------------
@@ -423,60 +423,71 @@ size_t iconv();
])
dnl ---------------------------------------------------------------------------
dnl test for GTK+ 2.0
dnl ---------------------------------------------------------------------------
# Configure paths for GTK+
# Owen Taylor 1997-2001
dnl AM_PATH_GTK_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
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_2_0,
[dnl
dnl Get the cflags and libraries from the gtk-config-2.0 script
dnl Get the cflags and libraries from pkg-config
dnl
AC_ARG_WITH(gtk-prefix,[ --with-gtk-prefix=PFX Prefix where GTK is installed (optional)],
gtk_config_prefix="$withval", gtk_config_prefix="")
AC_ARG_WITH(gtk-exec-prefix,[ --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
AC_ARG_ENABLE(gtktest, [ --disable-gtktest do not try to compile and run a test GTK+ program],
, enable_gtktest=yes)
pkg_config_args=gtk+-2.0
for module in . $4
do
case "$module" in
gthread)
gtk_config_args="$gtk_config_args gthread"
pkg_config_args="$pkg_config_args gthread-2.0"
;;
esac
done
if test x$gtk_config_exec_prefix != x ; then
gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
if test x${GTK_CONFIG_2_0+set} != xset ; then
GTK_CONFIG_2_0=$gtk_config_exec_prefix/bin/gtk-config-2.0
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
if test x$gtk_config_prefix != x ; then
gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
if test x${GTK_CONFIG_2_0+set} != xset ; then
GTK_CONFIG_2_0=$gtk_config_prefix/bin/gtk-config-2.0
min_gtk_version=ifelse([$1], ,2.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
AC_PATH_PROG(GTK_CONFIG_2_0, gtk-config-2.0, no)
min_gtk_version=ifelse([$1], ,1.3.1,$1)
AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
no_gtk=""
if test "$GTK_CONFIG_2_0" = "no" ; then
no_gtk=yes
else
GTK_CFLAGS=`$GTK_CONFIG_2_0 $gtk_config_args --cflags`
GTK_LIBS=`$GTK_CONFIG_2_0 $gtk_config_args --libs`
gtk_config_major_version=`$GTK_CONFIG_2_0 $gtk_config_args --version | \
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+-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
gtk_config_minor_version=`$GTK_CONFIG_2_0 $gtk_config_args --version | \
gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
gtk_config_micro_version=`$GTK_CONFIG_2_0 $gtk_config_args --version | \
gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
if test "x$enable_gtktest" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS"
@@ -484,8 +495,8 @@ AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run
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 gtk-config-2.0 to some extent
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([
@@ -512,19 +523,17 @@ main ()
(gtk_minor_version != $gtk_config_minor_version) ||
(gtk_micro_version != $gtk_config_micro_version))
{
printf("\n*** 'gtk-config-2.0 --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
printf("\n*** 'pkg-config --modversion gtk+-2.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 gtk-config-2.0 was correct, then it is best\n");
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 gtk-config-2.0 was wrong, set the environment variable GTK_CONFIG_2_0\n");
printf("*** to point to the correct copy of gtk-config-2.0, and remove the file config.cache\n");
printf("*** before re-running configure\n");
printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
printf("*** to point to the correct configuration files\n");
}
#if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION)
else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
(gtk_minor_version != GTK_MINOR_VERSION) ||
(gtk_micro_version != GTK_MICRO_VERSION))
@@ -534,7 +543,6 @@ main ()
printf("*** library (version %d.%d.%d)\n",
gtk_major_version, gtk_minor_version, gtk_micro_version);
}
#endif /* defined (GTK_MAJOR_VERSION) ... */
else
{
if ((gtk_major_version > major) ||
@@ -552,10 +560,10 @@ main ()
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 gtk-config-2.0 shell script is\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 GTK_CONFIG_2_0 environment to point to the\n");
printf("*** correct copy of gtk-config-2.0. (In this case, you will have to\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");
}
@@ -572,16 +580,14 @@ main ()
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
if test "$GTK_CONFIG_2_0" = "no" ; then
echo "*** The gtk-config-2.0 script installed by GTK could not be found"
echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the GTK_CONFIG_2_0 environment variable to the"
echo "*** full path to gtk-config-2.0."
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..."
echo "*** Could not run GTK+ test program, checking why..."
CFLAGS="$CFLAGS $GTK_CFLAGS"
LIBS="$LIBS $GTK_LIBS"
AC_TRY_LINK([
@@ -589,23 +595,18 @@ main ()
#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 "*** 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 "***"
echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
echo "*** came with the system with the command"
echo "***"
echo "*** rpm --erase --nodeps gtk gtk-devel" ],
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 was incorrectly installed"
echo "*** or that you have moved GTK since it was installed. In the latter case, you"
echo "*** may want to edit the gtk-config-2.0 script: $GTK_CONFIG_2_0" ])
echo "*** exact error that occured. This usually means GTK+ was incorrectly installed"
echo "*** or that you have moved GTK+ since it was installed. In the latter case, you"
echo "*** may want to edit the pkg-config script: $PKG_CONFIG" ])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi

1550
configure vendored

File diff suppressed because it is too large Load Diff

View File

@@ -720,7 +720,7 @@ AC_ARG_WITH(microwin, [ --with-microwin use MicroWindows], [wxUSE_
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, [ --enable-gtk2 use GTK+ 2.0 if available (EXPERIMENTAL)],wxUSE_GTK2=1,wxUSE_GTK2=0)
AC_ARG_ENABLE(gtk2, [ --enable-gtk2 use GTK+ 2.0 if available (EXPERIMENTAL)],wxUSE_GTK2="yes",wxUSE_GTK2="no")
WX_ARG_SYS_WITH(libpng, [ --with-libpng use libpng (PNG image format)], wxUSE_LIBPNG)
WX_ARG_SYS_WITH(libjpeg, [ --with-libjpeg use libjpeg (JPEG file format)], wxUSE_LIBJPEG)

View File

@@ -1878,6 +1878,7 @@ typedef unsigned long Atom; /* this might fail on a few architectures */
#endif // Motif
#ifdef __WXGTK__
/* Stand-ins for GLIB types */
typedef char gchar;
typedef signed char gint8;
@@ -1888,24 +1889,28 @@ typedef void* gpointer;
typedef struct _GSList GSList;
/* Stand-ins for GDK types */
typedef gulong GdkAtom;
typedef struct _GdkColor GdkColor;
typedef struct _GdkColormap GdkColormap;
typedef struct _GdkFont GdkFont;
typedef struct _GdkGC GdkGC;
typedef struct _GdkVisual GdkVisual;
#ifdef __WXGTK20__
typedef struct _GdkAtom *GdkAtom;
typedef struct _GdkDrawable GdkWindow;
typedef struct _GdkDrawable GdkBitmap;
typedef struct _GdkDrawable GdkPixmap;
#else
#else // GTK+ 1.2
typedef gulong GdkAtom;
typedef struct _GdkWindow GdkWindow;
typedef struct _GdkWindow GdkBitmap;
typedef struct _GdkWindow GdkPixmap;
#endif
#endif // GTK+ 1.2/2.0
typedef struct _GdkCursor GdkCursor;
typedef struct _GdkRegion GdkRegion;
typedef struct _GdkDragContext GdkDragContext;
#ifdef HAVE_XIM
typedef struct _GdkIC GdkIC;
typedef struct _GdkICAttr GdkICAttr;
@@ -1936,7 +1941,8 @@ typedef GtkWidget *WXWidget;
typedef struct _PangoContext PangoContext;
typedef struct _PangoLayout PangoLayout;
typedef struct _PangoFontDescription PangoFontDescription;
#endif
#endif // GTK+ 2.0
#endif // GTK
#ifdef __WXMGL__

138
include/wx/gtk/private.h Normal file
View File

@@ -0,0 +1,138 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private.h
// Purpose: wxGTK private macros, functions &c
// Author: Vadim Zeitlin
// Modified by:
// Created: 12.03.02
// RCS-ID: $Id$
// Copyright: (c) 2002 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_H_
#define _WX_GTK_PRIVATE_H_
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/event.h"
// fail all version tests if the GTK+ version is so ancient that it doesn't
// even have GTK_CHECK_VERSION
#ifndef GTK_CHECK_VERSION
#define GTK_CHECK_VERSION(a, b, c) 0
#endif
// GTK+ 2.0 compatibility define is broken when used from C++ as it casts enum
// to int implicitly
#ifdef __WXGTK20__
#undef gtk_signal_disconnect_by_func
#define gtk_signal_disconnect_by_func(object,func,data) \
gtk_signal_compat_matched((object), (func), (data), \
(GSignalMatchType)(G_SIGNAL_MATCH_FUNC | \
G_SIGNAL_MATCH_DATA), 0)
#endif
// child is not a member of GTK_BUTTON() any more in GTK+ 2.0
#ifdef __WXGTK20__
#define BUTTON_CHILD(w) GTK_BIN((w))->child
#else
#define BUTTON_CHILD(w) GTK_BUTTON((w))->child
#endif
// event_window has disappeared from GtkToggleButton in GTK+ 2.0
#ifdef __WXGTK20__
#define TOGGLE_BUTTON_EVENT_WIN(w) GTK_BUTTON((w))->event_window
#else
#define TOGGLE_BUTTON_EVENT_WIN(w) GTK_TOGGLE_BUTTON((w))->event_window
#endif
// get the font from a style
//
// TODO: GdkFont has been replaced by PangoFontDescription in GTK+ 2.0
// and we really should use it instead of GdkFont (see also dclient.cpp)
#ifdef __WXGTK20__
#define GET_STYLE_FONT(style) gtk_style_get_font(style)
#define SET_STYLE_FONT(style, font) gtk_style_set_font(style, font)
#else
#define GET_STYLE_FONT(style) ((style)->font)
#define SET_STYLE_FONT(style, fnt) \
gdk_font_unref( style->font ); \
style->font = gdk_font_ref( fnt )
#endif
// gtk_editable_{copy|cut|paste}_clipboard() had an extra argument under
// previous GTK+ versions but no more
#if defined(__WXGTK20__) || (GTK_MINOR_VERSION > 0)
#define DUMMY_CLIPBOARD_ARG
#else
#define DUMMY_CLIPBOARD_ARG ,0
#endif
// _GtkEditable is now private
#ifdef __WXGTK20__
#define GET_EDITABLE_POS(w) gtk_editable_get_position(GTK_EDITABLE(w))
#define SET_EDITABLE_POS(w, pos) \
gtk_editable_set_position(GTK_EDITABLE(w), (pos))
#else
#define GET_EDITABLE_POS(w) GTK_EDITABLE((w))->current_pos
#define SET_EDITABLE_POS(w, pos) \
GTK_EDITABLE((w))->current_pos = (pos)
#endif
// this GtkNotebook struct field has been renamed
#ifdef __WXGTK20__
#define NOTEBOOK_PANEL(nb) GTK_NOTEBOOK(nb)->event_window
#else
#define NOTEBOOK_PANEL(nb) GTK_NOTEBOOK(nb)->panel
#endif
// VZ: I _think_ that in GTK+ 2.0 the scroll type is passed to the
// value_changed callback as a 2nd argument but I'm not at all sure about
// it, if this is false all occurences of this macro must be changed!
#ifdef __WXGTK20__
#define SCROLLBAR_CBACK_ARG GtkScrollType scrollType,
#define GET_SCROLL_TYPE(w) scrollType
#else
#define SCROLLBAR_CBACK_ARG
#define GET_SCROLL_TYPE(w) GTK_RANGE((w))->scroll_type
#endif
// translate a GTK+ scroll type to a wxEventType
inline wxEventType GtkScrollTypeToWx(guint scrollType)
{
wxEventType command;
switch ( scrollType )
{
case GTK_SCROLL_STEP_BACKWARD:
command = wxEVT_SCROLL_LINEUP;
break;
case GTK_SCROLL_STEP_FORWARD:
command = wxEVT_SCROLL_LINEDOWN;
break;
case GTK_SCROLL_PAGE_BACKWARD:
command = wxEVT_SCROLL_PAGEUP;
break;
case GTK_SCROLL_PAGE_FORWARD:
command = wxEVT_SCROLL_PAGEDOWN;
break;
default:
command = wxEVT_SCROLL_THUMBTRACK;
}
return command;
}
inline wxEventType GtkScrollWinTypeToWx(guint scrollType)
{
// GtkScrollTypeToWx() returns SCROLL_XXX, not SCROLLWIN_XXX as we need
return GtkScrollTypeToWx(scrollType) +
wxEVT_SCROLLWIN_TOP - wxEVT_SCROLL_TOP;
}
#endif // _WX_GTK_PRIVATE_H_

View File

@@ -122,8 +122,8 @@ public:
void OnPaint(wxPaintEvent& event);
void OnChar(wxKeyEvent& event);
void GtkVScroll( float value );
void GtkHScroll( float value );
void GtkVScroll( float value, unsigned int scroll_type );
void GtkHScroll( float value, unsigned int scroll_type );
void GtkVConnectEvent();
void GtkHConnectEvent();
void GtkVDisconnectEvent();

138
include/wx/gtk1/private.h Normal file
View File

@@ -0,0 +1,138 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/private.h
// Purpose: wxGTK private macros, functions &c
// Author: Vadim Zeitlin
// Modified by:
// Created: 12.03.02
// RCS-ID: $Id$
// Copyright: (c) 2002 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_H_
#define _WX_GTK_PRIVATE_H_
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/event.h"
// fail all version tests if the GTK+ version is so ancient that it doesn't
// even have GTK_CHECK_VERSION
#ifndef GTK_CHECK_VERSION
#define GTK_CHECK_VERSION(a, b, c) 0
#endif
// GTK+ 2.0 compatibility define is broken when used from C++ as it casts enum
// to int implicitly
#ifdef __WXGTK20__
#undef gtk_signal_disconnect_by_func
#define gtk_signal_disconnect_by_func(object,func,data) \
gtk_signal_compat_matched((object), (func), (data), \
(GSignalMatchType)(G_SIGNAL_MATCH_FUNC | \
G_SIGNAL_MATCH_DATA), 0)
#endif
// child is not a member of GTK_BUTTON() any more in GTK+ 2.0
#ifdef __WXGTK20__
#define BUTTON_CHILD(w) GTK_BIN((w))->child
#else
#define BUTTON_CHILD(w) GTK_BUTTON((w))->child
#endif
// event_window has disappeared from GtkToggleButton in GTK+ 2.0
#ifdef __WXGTK20__
#define TOGGLE_BUTTON_EVENT_WIN(w) GTK_BUTTON((w))->event_window
#else
#define TOGGLE_BUTTON_EVENT_WIN(w) GTK_TOGGLE_BUTTON((w))->event_window
#endif
// get the font from a style
//
// TODO: GdkFont has been replaced by PangoFontDescription in GTK+ 2.0
// and we really should use it instead of GdkFont (see also dclient.cpp)
#ifdef __WXGTK20__
#define GET_STYLE_FONT(style) gtk_style_get_font(style)
#define SET_STYLE_FONT(style, font) gtk_style_set_font(style, font)
#else
#define GET_STYLE_FONT(style) ((style)->font)
#define SET_STYLE_FONT(style, fnt) \
gdk_font_unref( style->font ); \
style->font = gdk_font_ref( fnt )
#endif
// gtk_editable_{copy|cut|paste}_clipboard() had an extra argument under
// previous GTK+ versions but no more
#if defined(__WXGTK20__) || (GTK_MINOR_VERSION > 0)
#define DUMMY_CLIPBOARD_ARG
#else
#define DUMMY_CLIPBOARD_ARG ,0
#endif
// _GtkEditable is now private
#ifdef __WXGTK20__
#define GET_EDITABLE_POS(w) gtk_editable_get_position(GTK_EDITABLE(w))
#define SET_EDITABLE_POS(w, pos) \
gtk_editable_set_position(GTK_EDITABLE(w), (pos))
#else
#define GET_EDITABLE_POS(w) GTK_EDITABLE((w))->current_pos
#define SET_EDITABLE_POS(w, pos) \
GTK_EDITABLE((w))->current_pos = (pos)
#endif
// this GtkNotebook struct field has been renamed
#ifdef __WXGTK20__
#define NOTEBOOK_PANEL(nb) GTK_NOTEBOOK(nb)->event_window
#else
#define NOTEBOOK_PANEL(nb) GTK_NOTEBOOK(nb)->panel
#endif
// VZ: I _think_ that in GTK+ 2.0 the scroll type is passed to the
// value_changed callback as a 2nd argument but I'm not at all sure about
// it, if this is false all occurences of this macro must be changed!
#ifdef __WXGTK20__
#define SCROLLBAR_CBACK_ARG GtkScrollType scrollType,
#define GET_SCROLL_TYPE(w) scrollType
#else
#define SCROLLBAR_CBACK_ARG
#define GET_SCROLL_TYPE(w) GTK_RANGE((w))->scroll_type
#endif
// translate a GTK+ scroll type to a wxEventType
inline wxEventType GtkScrollTypeToWx(guint scrollType)
{
wxEventType command;
switch ( scrollType )
{
case GTK_SCROLL_STEP_BACKWARD:
command = wxEVT_SCROLL_LINEUP;
break;
case GTK_SCROLL_STEP_FORWARD:
command = wxEVT_SCROLL_LINEDOWN;
break;
case GTK_SCROLL_PAGE_BACKWARD:
command = wxEVT_SCROLL_PAGEUP;
break;
case GTK_SCROLL_PAGE_FORWARD:
command = wxEVT_SCROLL_PAGEDOWN;
break;
default:
command = wxEVT_SCROLL_THUMBTRACK;
}
return command;
}
inline wxEventType GtkScrollWinTypeToWx(guint scrollType)
{
// GtkScrollTypeToWx() returns SCROLL_XXX, not SCROLLWIN_XXX as we need
return GtkScrollTypeToWx(scrollType) +
wxEVT_SCROLLWIN_TOP - wxEVT_SCROLL_TOP;
}
#endif // _WX_GTK_PRIVATE_H_

View File

@@ -122,8 +122,8 @@ public:
void OnPaint(wxPaintEvent& event);
void OnChar(wxKeyEvent& event);
void GtkVScroll( float value );
void GtkHScroll( float value );
void GtkVScroll( float value, unsigned int scroll_type );
void GtkHScroll( float value, unsigned int scroll_type );
void GtkVConnectEvent();
void GtkHConnectEvent();
void GtkVDisconnectEvent();

View File

@@ -21,13 +21,23 @@
#include "wx/dcmemory.h"
#include "wx/app.h"
#ifdef __WXGTK20__
// need this to get gdk_image_new_bitmap()
#define GDK_ENABLE_BROKEN
#endif
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#ifdef __WXGTK20__
#include <gdk/gdkimage.h>
#else // GTK+ 1.2
// VZ: is this still needed? seems to compile fine without it...
#if (GTK_MINOR_VERSION > 0)
#include <gdk/gdkrgb.h>
#endif
#endif // GTK+ 2.0/1.2
extern void gdk_wx_draw_bitmap (GdkDrawable *drawable,
GdkGC *gc,

View File

@@ -17,8 +17,7 @@
#include "wx/bmpbuttn.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// classes
@@ -199,7 +198,8 @@ wxString wxBitmapButton::GetLabel() const
void wxBitmapButton::ApplyWidgetStyle()
{
if (GTK_BUTTON(m_widget)->child == NULL) return;
if ( !BUTTON_CHILD(m_widget) )
return;
wxButton::ApplyWidgetStyle();
}
@@ -236,8 +236,8 @@ void wxBitmapButton::OnSetBitmap()
GdkBitmap *mask = (GdkBitmap *) NULL;
if (the_one.GetMask()) mask = the_one.GetMask()->GetBitmap();
GtkButton *bin = GTK_BUTTON(m_widget);
if (bin->child == NULL)
GtkWidget *child = BUTTON_CHILD(m_widget);
if (child == NULL)
{
// initial bitmap
GtkWidget *pixmap = gtk_pixmap_new(the_one.GetPixmap(), mask);
@@ -246,7 +246,7 @@ void wxBitmapButton::OnSetBitmap()
}
else
{ // subsequent bitmaps
GtkPixmap *g_pixmap = GTK_PIXMAP(bin->child);
GtkPixmap *g_pixmap = GTK_PIXMAP(child);
gtk_pixmap_set(g_pixmap, the_one.GetPixmap(), mask);
}
}

View File

@@ -17,8 +17,7 @@
#include "wx/button.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// classes
@@ -163,7 +162,7 @@ void wxButton::SetLabel( const wxString &label )
wxControl::SetLabel( label );
gtk_label_set( GTK_LABEL( GTK_BUTTON(m_widget)->child ), GetLabel().mbc_str() );
gtk_label_set( GTK_LABEL( BUTTON_CHILD(m_widget) ), GetLabel().mbc_str() );
}
bool wxButton::Enable( bool enable )
@@ -171,7 +170,7 @@ bool wxButton::Enable( bool enable )
if ( !wxControl::Enable( enable ) )
return FALSE;
gtk_widget_set_sensitive( GTK_BUTTON(m_widget)->child, enable );
gtk_widget_set_sensitive( BUTTON_CHILD(m_widget), enable );
return TRUE;
}
@@ -180,7 +179,7 @@ void wxButton::ApplyWidgetStyle()
{
SetWidgetStyle();
gtk_widget_set_style( m_widget, m_widgetStyle );
gtk_widget_set_style( GTK_BUTTON(m_widget)->child, m_widgetStyle );
gtk_widget_set_style( BUTTON_CHILD(m_widget), m_widgetStyle );
}
wxSize wxButton::DoGetBestSize() const

View File

@@ -18,8 +18,7 @@
#include "wx/checkbox.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -107,7 +106,7 @@ bool wxCheckBox::Create(wxWindow *parent,
else
{
m_widgetCheckbox = gtk_check_button_new_with_label( m_label.mbc_str() );
m_widgetLabel = GTK_BUTTON( m_widgetCheckbox )->child;
m_widgetLabel = BUTTON_CHILD( m_widgetCheckbox );
m_widget = m_widgetCheckbox;
}
@@ -188,7 +187,7 @@ void wxCheckBox::ApplyWidgetStyle()
bool wxCheckBox::IsOwnGtkWindow( GdkWindow *window )
{
return (window == GTK_TOGGLE_BUTTON(m_widget)->event_window);
return window == TOGGLE_BUTTON_EVENT_WIN(m_widget);
}
void wxCheckBox::OnInternalIdle()
@@ -196,14 +195,15 @@ void wxCheckBox::OnInternalIdle()
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;
if (GTK_TOGGLE_BUTTON(m_widgetCheckbox)->event_window && cursor.Ok())
GdkWindow *event_window = TOGGLE_BUTTON_EVENT_WIN(m_widgetCheckbox);
if ( event_window && cursor.Ok() )
{
/* I now set the cursor the anew in every OnInternalIdle call
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
gdk_window_set_cursor( GTK_TOGGLE_BUTTON(m_widgetCheckbox)->event_window, cursor.GetCursor() );
gdk_window_set_cursor( event_window, cursor.GetCursor() );
}
UpdateWindowUI();

View File

@@ -18,8 +18,7 @@
#include "wx/choice.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -229,8 +228,10 @@ int wxChoice::FindString( const wxString &string ) const
{
GtkBin *bin = GTK_BIN( child->data );
GtkLabel *label = (GtkLabel *) NULL;
if (bin->child) label = GTK_LABEL(bin->child);
if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
if (bin->child)
label = GTK_LABEL(bin->child);
if (!label)
label = GTK_LABEL( BUTTON_CHILD(m_widget) );
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
@@ -282,8 +283,10 @@ wxString wxChoice::GetString( int n ) const
if (count == n)
{
GtkLabel *label = (GtkLabel *) NULL;
if (bin->child) label = GTK_LABEL(bin->child);
if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
if (bin->child)
label = GTK_LABEL(bin->child);
if (!label)
label = GTK_LABEL( BUTTON_CHILD(m_widget) );
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
@@ -337,8 +340,10 @@ void wxChoice::ApplyWidgetStyle()
GtkBin *bin = GTK_BIN( child->data );
GtkWidget *label = (GtkWidget *) NULL;
if (bin->child) label = bin->child;
if (!label) label = GTK_BUTTON(m_widget)->child;
if (bin->child)
label = bin->child;
if (!label)
label = BUTTON_CHILD(m_widget);
gtk_widget_set_style( label, m_widgetStyle );
@@ -434,7 +439,8 @@ wxSize wxChoice::DoGetBestSize() const
if ( ret.x < 80 )
ret.x = 80;
ret.y = 16 + gdk_char_height( m_widget->style->font, 'H' );
ret.y = 16 + gdk_char_height(GET_STYLE_FONT( m_widget->style ), 'H');
return ret;
}

View File

@@ -20,8 +20,7 @@
#include "wx/textctrl.h" // for wxEVT_COMMAND_TEXT_UPDATED
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -492,11 +491,7 @@ void wxComboBox::Copy()
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
#if defined(__WXGTK13__) || (GTK_MINOR_VERSION > 0)
gtk_editable_copy_clipboard( GTK_EDITABLE(entry) );
#else
gtk_editable_copy_clipboard( GTK_EDITABLE(entry), 0 );
#endif
gtk_editable_copy_clipboard( GTK_EDITABLE(entry) DUMMY_CLIPBOARD_ARG );
}
void wxComboBox::Cut()
@@ -504,11 +499,7 @@ void wxComboBox::Cut()
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
#if defined(__WXGTK13__) || (GTK_MINOR_VERSION > 0)
gtk_editable_cut_clipboard( GTK_EDITABLE(entry) );
#else
gtk_editable_cut_clipboard( GTK_EDITABLE(entry), 0 );
#endif
gtk_editable_cut_clipboard( GTK_EDITABLE(entry) DUMMY_CLIPBOARD_ARG );
}
void wxComboBox::Paste()
@@ -516,11 +507,7 @@ void wxComboBox::Paste()
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
#if defined(__WXGTK13__) || (GTK_MINOR_VERSION > 0)
gtk_editable_paste_clipboard( GTK_EDITABLE(entry) );
#else
gtk_editable_paste_clipboard( GTK_EDITABLE(entry), 0 );
#endif
gtk_editable_paste_clipboard( GTK_EDITABLE(entry) DUMMY_CLIPBOARD_ARG);
}
void wxComboBox::SetInsertionPoint( long pos )
@@ -540,8 +527,7 @@ void wxComboBox::SetInsertionPointEnd()
long wxComboBox::GetInsertionPoint() const
{
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
return (long) GTK_EDITABLE(entry)->current_pos;
return (long) GET_EDITABLE_POS( GTK_COMBO(m_widget)->entry );
}
long wxComboBox::GetLastPosition() const

View File

@@ -1358,11 +1358,11 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
y = YLOG2DEV(y);
#if defined(__WXGTK20__) && wxUSE_WCHAR_T
/* FIXME: the layout engine should probably be abstracted at a higher level in wxDC... */
// TODO: the layout engine should be abstracted at a higher level!
PangoLayout *layout = pango_layout_new(m_context);
pango_layout_set_font_description(layout, m_fontdesc);
{
wxWX2MBbuf data = text.mb_str(wxConvUTF8);
const wxWX2MBbuf data = text.mb_str(wxConvUTF8);
pango_layout_set_text(layout, data, strlen(data));
}
PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data;
@@ -1371,7 +1371,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
wxCoord width = rect.width;
wxCoord height = rect.height;
gdk_draw_layout( m_window, m_textGC, x, y, layout );
#else
#else // GTK+ 1.x
wxCoord width = gdk_string_width( font, text.mbc_str() );
wxCoord height = font->ascent + font->descent;
@@ -1382,7 +1382,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
gdk_gc_set_foreground( m_textGC, m_textForegroundColour.GetColor() );
}
gdk_draw_string( m_window, font, m_textGC, x, y + font->ascent, text.mbc_str() );
#endif
#endif // GTK+ 2.0/1.x
/* CMB 17/7/98: simple underline: ignores scaling and underlying
X font's XA_UNDERLINE_POSITION and XA_UNDERLINE_THICKNESS

View File

@@ -21,8 +21,8 @@
#include "wx/intl.h"
#include "wx/utils.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include <gdk/gdkprivate.h>
#include <gtk/gtkdnd.h>

View File

@@ -30,9 +30,8 @@
#include <strings.h>
#include <gdk/gdk.h>
#include "wx/gtk/private.h"
#include <gdk/gdkprivate.h>
#include <gtk/gtk.h>
// ----------------------------------------------------------------------------
// constants
@@ -656,13 +655,13 @@ extern GdkFont *GtkGetDefaultGuiFont()
GtkStyle *def = gtk_rc_get_style( widget );
if (def)
{
g_systemDefaultGuiFont = gdk_font_ref( def->font );
g_systemDefaultGuiFont = gdk_font_ref( GET_STYLE_FONT(def) );
}
else
{
def = gtk_widget_get_default_style();
if (def)
g_systemDefaultGuiFont = gdk_font_ref( def->font );
g_systemDefaultGuiFont = gdk_font_ref( GET_STYLE_FONT(def) );
}
gtk_widget_destroy( widget );
}

View File

@@ -22,7 +22,7 @@
#include "wx/debug.h"
#include "wx/msgdlg.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -133,13 +133,13 @@ wxFontDialog::wxFontDialog( wxWindow *parent, wxFontData *fontdata )
GTK_SIGNAL_FUNC(gtk_fontdialog_ok_callback), (gpointer*)this );
// strange way to internationalize
gtk_label_set( GTK_LABEL( GTK_BUTTON(sel->ok_button)->child ), wxConvCurrent->cWX2MB(_("OK")) );
gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->ok_button) ), wxConvCurrent->cWX2MB(_("OK")) );
gtk_signal_connect( GTK_OBJECT(sel->cancel_button), "clicked",
GTK_SIGNAL_FUNC(gtk_fontdialog_cancel_callback), (gpointer*)this );
// strange way to internationalize
gtk_label_set( GTK_LABEL( GTK_BUTTON(sel->cancel_button)->child ), wxConvCurrent->cWX2MB(_("Cancel")) );
gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->cancel_button) ), wxConvCurrent->cWX2MB(_("Cancel")) );
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
GTK_SIGNAL_FUNC(gtk_fontdialog_delete_callback), (gpointer)this );

View File

@@ -34,8 +34,8 @@
#include "wx/dcclient.h"
#include <glib.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h>

View File

@@ -363,12 +363,12 @@ wxMenuBar *wxMDIChildFrame::GetMenuBar() const
void wxMDIChildFrame::Activate()
{
#if (GTK_MINOR_VERSION > 0)
#if defined(__WXGTK20__) || (GTK_MINOR_VERSION > 0)
wxMDIParentFrame* parent = (wxMDIParentFrame*) GetParent();
GtkNotebook* notebook = GTK_NOTEBOOK(parent->m_widget);
gint pageno = gtk_notebook_page_num( notebook, m_page->child );
gint pageno = gtk_notebook_page_num( notebook, m_widget );
gtk_notebook_set_page( notebook, pageno );
#else
#else // GTK+ 1.0
// the only way I can see to do this under gtk+ 1.0.X would
// be to keep track of page numbers, start at first and
// do "next" enough times to get to this page number - messy
@@ -402,7 +402,7 @@ void wxMDIChildFrame::SetTitle( const wxString &title )
wxMDIParentFrame* parent = (wxMDIParentFrame*) GetParent();
GtkNotebook* notebook = GTK_NOTEBOOK(parent->m_widget);
gtk_notebook_set_tab_label_text(notebook, m_page->child, title.mbc_str());
gtk_notebook_set_tab_label_text(notebook, m_widget, title.mbc_str());
}
//-----------------------------------------------------------------------------

View File

@@ -22,9 +22,26 @@
#include "wx/accel.h"
#endif // wxUSE_ACCEL
#include <gdk/gdk.h>
#include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
// FIXME: is this right? somehow I don't think so (VZ)
#ifdef __WXGTK20__
#include <glib-object.h>
#define gtk_accel_group_attach(g, o) _gtk_accel_group_attach((g), (o))
#define gtk_accel_group_detach(g, o) _gtk_accel_group_detach((g), (o))
#define gtk_menu_ensure_uline_accel_group(m) gtk_menu_get_accel_group(m)
#define ACCEL_OBJECT GObject
#define ACCEL_OBJECTS(a) (a)->acceleratables
#define ACCEL_OBJ_CAST(obj) G_OBJECT(obj)
#else // GTK+ 1.x
#define ACCEL_OBJECT GtkObject
#define ACCEL_OBJECTS(a) (a)->attach_objects
#define ACCEL_OBJ_CAST(obj) GTK_OBJECT(obj)
#endif
//-----------------------------------------------------------------------------
// idle system
@@ -33,7 +50,7 @@
extern void wxapp_install_idle_handler();
extern bool g_isIdle;
#if (GTK_MINOR_VERSION > 0) && wxUSE_ACCEL
#if GTK_CHECK_VERSION(1, 2, 0) && wxUSE_ACCEL
static wxString GetHotKey( const wxMenuItem& item );
#endif
@@ -41,6 +58,13 @@ static wxString GetHotKey( const wxMenuItem& item );
// substitute for missing GtkPixmapMenuItem
//-----------------------------------------------------------------------------
// FIXME: I can't make this compile with GTK+ 2.0, disabling for now (VZ)
#ifndef __WXGTK20__
#define USE_MENU_BITMAPS
#endif
#ifdef USE_MENU_BITMAPS
#define GTK_TYPE_PIXMAP_MENU_ITEM (gtk_pixmap_menu_item_get_type ())
#define GTK_PIXMAP_MENU_ITEM(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_PIXMAP_MENU_ITEM, GtkPixmapMenuItem))
#define GTK_PIXMAP_MENU_ITEM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_PIXMAP_MENU_ITEM, GtkPixmapMenuItemClass))
@@ -77,6 +101,8 @@ GtkWidget* gtk_pixmap_menu_item_new (void);
void gtk_pixmap_menu_item_set_pixmap (GtkPixmapMenuItem *menu_item,
GtkWidget *pixmap);
#endif // USE_MENU_BITMAPS
//-----------------------------------------------------------------------------
// idle system
//-----------------------------------------------------------------------------
@@ -91,7 +117,7 @@ static wxString wxReplaceUnderscore( const wxString& title )
{
if (*pc == wxT('&'))
{
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
str << wxT('_');
}
else if (*pc == wxT('/'))
@@ -139,7 +165,7 @@ wxMenuBar::wxMenuBar( long style )
m_menus.DeleteContents( TRUE );
/* GTK 1.2.0 doesn't have gtk_item_factory_get_item(), but GTK 1.2.1 has. */
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
m_accel = gtk_accel_group_new();
m_factory = gtk_item_factory_new( GTK_TYPE_MENU_BAR, "<main>", m_accel );
m_menubar = gtk_item_factory_get_widget( m_factory, "<main>" );
@@ -180,7 +206,7 @@ wxMenuBar::wxMenuBar()
m_menus.DeleteContents( TRUE );
/* GTK 1.2.0 doesn't have gtk_item_factory_get_item(), but GTK 1.2.1 has. */
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
m_accel = gtk_accel_group_new();
m_factory = gtk_item_factory_new( GTK_TYPE_MENU_BAR, "<main>", m_accel );
m_menubar = gtk_item_factory_get_widget( m_factory, "<main>" );
@@ -204,13 +230,13 @@ static void wxMenubarUnsetInvokingWindow( wxMenu *menu, wxWindow *win )
{
menu->SetInvokingWindow( (wxWindow*) NULL );
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
wxWindow *top_frame = win;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
/* support for native hot keys */
gtk_accel_group_detach( menu->m_accel, GTK_OBJECT(top_frame->m_widget) );
gtk_accel_group_detach( menu->m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) );
#endif
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
@@ -227,16 +253,16 @@ static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win )
{
menu->SetInvokingWindow( win );
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
wxWindow *top_frame = win;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
/* support for native hot keys */
GtkObject *obj = GTK_OBJECT(top_frame->m_widget);
if ( !g_slist_find( menu->m_accel->attach_objects, obj ) )
ACCEL_OBJECT *obj = ACCEL_OBJ_CAST(top_frame->m_widget);
if ( !g_slist_find( ACCEL_OBJECTS(menu->m_accel), obj ) )
gtk_accel_group_attach( menu->m_accel, obj );
#endif
#endif // GTK+ 1.2.1+
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
while (node)
@@ -251,16 +277,16 @@ static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win )
void wxMenuBar::SetInvokingWindow( wxWindow *win )
{
m_invokingWindow = win;
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
wxWindow *top_frame = win;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
/* support for native key accelerators indicated by underscroes */
GtkObject *obj = GTK_OBJECT(top_frame->m_widget);
if ( !g_slist_find( m_accel->attach_objects, obj ) )
ACCEL_OBJECT *obj = ACCEL_OBJ_CAST(top_frame->m_widget);
if ( !g_slist_find( ACCEL_OBJECTS(m_accel), obj ) )
gtk_accel_group_attach( m_accel, obj );
#endif
#endif // GTK+ 1.2.1+
wxMenuList::Node *node = m_menus.GetFirst();
while (node)
@@ -274,14 +300,14 @@ void wxMenuBar::SetInvokingWindow( wxWindow *win )
void wxMenuBar::UnsetInvokingWindow( wxWindow *win )
{
m_invokingWindow = (wxWindow*) NULL;
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
wxWindow *top_frame = win;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
/* support for native key accelerators indicated by underscroes */
gtk_accel_group_detach( m_accel, GTK_OBJECT(top_frame->m_widget) );
#endif
gtk_accel_group_detach( m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) );
#endif // GTK+ 1.2.1+
wxMenuList::Node *node = m_menus.GetFirst();
while (node)
@@ -308,7 +334,7 @@ bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title)
menu->SetTitle( str );
/* GTK 1.2.0 doesn't have gtk_item_factory_get_item(), but GTK 1.2.1 has. */
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
/* local buffer in multibyte form */
wxString buf;
@@ -527,7 +553,7 @@ wxString wxMenuBar::GetLabelTop( size_t pos ) const
wxString label;
wxString text( menu->GetTitle() );
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
for ( const wxChar *pc = text.c_str(); *pc; pc++ )
{
if ( *pc == wxT('_') || *pc == wxT('&') )
@@ -764,7 +790,7 @@ void wxMenuItem::DoSetText( const wxString& str )
{
if (*pc == wxT('&'))
{
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
m_text << wxT('_');
}
else if ( *pc == wxT('_') ) // escape underscores
@@ -774,7 +800,7 @@ void wxMenuItem::DoSetText( const wxString& str )
else if (*pc == wxT('/')) /* we have to filter out slashes ... */
{
m_text << wxT('\\'); /* ... and replace them with back slashes */
#endif
#endif // GTK+ 1.2.0+
}
else
m_text << *pc;
@@ -782,13 +808,14 @@ void wxMenuItem::DoSetText( const wxString& str )
/* only GTK 1.2 knows about hot keys */
m_hotKey = wxT("");
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
if(*pc == wxT('\t'))
{
pc++;
m_hotKey = pc;
}
#endif
#endif // GTK+ 1.2.0+
}
#if wxUSE_ACCEL
@@ -869,7 +896,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMenu,wxEvtHandler)
void wxMenu::Init()
{
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
m_accel = gtk_accel_group_new();
m_factory = gtk_item_factory_new( GTK_TYPE_MENU, "<main>", m_accel );
m_menu = gtk_item_factory_get_widget( m_factory, "<main>" );
@@ -879,7 +906,7 @@ void wxMenu::Init()
m_owner = (GtkWidget*) NULL;
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
/* Tearoffs are entries, just like separators. So if we want this
menu to be a tear-off one, we just append a tearoff entry
immediately. */
@@ -894,7 +921,7 @@ void wxMenu::Init()
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
//GtkWidget *menuItem = gtk_item_factory_get_widget( m_factory, "<main>/tearoff" );
}
#endif
#endif // GTK+ 1.2.0+
// append the title as the very first entry if we have it
if ( !!m_title )
@@ -917,11 +944,13 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
{
GtkWidget *menuItem;
#if defined(USE_MENU_BITMAPS) || !GTK_CHECK_VERSION(1, 2, 0)
bool appended = FALSE;
#endif
if ( mitem->IsSeparator() )
{
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
GtkItemFactoryEntry entry;
entry.path = (char *)"/sep";
entry.callback = (GtkItemFactoryCallback) NULL;
@@ -939,7 +968,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
}
else if ( mitem->IsSubMenu() )
{
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
/* text has "_" instead of "&" after mitem->SetText() */
wxString text( mitem->GetText() );
@@ -971,6 +1000,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
if ( m_invokingWindow )
wxMenubarSetInvokingWindow(mitem->GetSubMenu(), m_invokingWindow);
}
#ifdef USE_MENU_BITMAPS
else if (mitem->GetBitmap().Ok()) // An item with bitmap
{
wxString text( mitem->GetText() );
@@ -1006,9 +1036,10 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
appended = TRUE; // We've done this, don't do it again
}
#endif // USE_MENU_BITMAPS
else // a normal item
{
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
/* text has "_" instead of "&" after mitem->SetText() */
wxString text( mitem->GetText() );
@@ -1064,7 +1095,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
(gpointer)this );
}
#if GTK_MINOR_VERSION == 0
#if !GTK_CHECK_VERSION(1, 2, 0)
if (!appended)
{
gtk_menu_append( GTK_MENU(m_menu), menuItem );
@@ -1144,7 +1175,7 @@ int wxMenu::FindMenuIdByMenuItem( GtkWidget *menuItem ) const
// helpers
// ----------------------------------------------------------------------------
#if (GTK_MINOR_VERSION > 0) && wxUSE_ACCEL
#if GTK_CHECK_VERSION(1, 2, 0) && wxUSE_ACCEL
static wxString GetHotKey( const wxMenuItem& item )
{
@@ -1225,6 +1256,8 @@ static wxString GetHotKey( const wxMenuItem& item )
// substitute for missing GtkPixmapMenuItem
//-----------------------------------------------------------------------------
#ifdef USE_MENU_BITMAPS
/*
* Copyright (C) 1998, 1999, 2000 Free Software Foundation
* All rights reserved.
@@ -1595,4 +1628,5 @@ changed_have_pixmap_status (GtkPixmapMenuItem *menu_item)
gtk_widget_queue_resize(GTK_WIDGET(menu_item));
}
#endif // USE_MENU_BITMAPS

View File

@@ -21,9 +21,9 @@
#include "wx/intl.h"
#include "wx/log.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/win_gtk.h"
#include <gdk/gdkkeysyms.h>
// ----------------------------------------------------------------------------
@@ -686,7 +686,7 @@ void wxNotebook::ApplyWidgetStyle()
bool wxNotebook::IsOwnGtkWindow( GdkWindow *window )
{
return ((m_widget->window == window) ||
(GTK_NOTEBOOK(m_widget)->panel == window));
(NOTEBOOK_PANEL(m_widget) == window));
}
//-----------------------------------------------------------------------------

View File

@@ -21,8 +21,7 @@
#include "wx/frame.h"
#include "wx/log.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h>
#include "wx/gtk/win_gtk.h"
@@ -427,10 +426,10 @@ int wxRadioBox::FindString( const wxString &s ) const
wxNode *node = m_boxes.First();
while (node)
{
GtkButton *button = GTK_BUTTON( node->Data() );
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
if (s == label->label)
return count;
GtkLabel *label = GTK_LABEL( button->child );
if (s == label->label) return count;
count++;
node = node->Next();
@@ -504,8 +503,7 @@ wxString wxRadioBox::GetString( int n ) const
wxCHECK_MSG( node, wxT(""), wxT("radiobox wrong index") );
GtkButton *button = GTK_BUTTON( node->Data() );
GtkLabel *label = GTK_LABEL( button->child );
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
return wxString( label->label );
}
@@ -527,8 +525,7 @@ void wxRadioBox::SetString( int item, const wxString& label )
wxCHECK_RET( node, wxT("radiobox wrong index") );
GtkButton *button = GTK_BUTTON( node->Data() );
GtkLabel *g_label = GTK_LABEL( button->child );
GtkLabel *g_label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
gtk_label_set( g_label, label.mbc_str() );
}
@@ -542,9 +539,10 @@ bool wxRadioBox::Enable( bool enable )
while (node)
{
GtkButton *button = GTK_BUTTON( node->Data() );
GtkWidget *label = button->child;
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) );
gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
gtk_widget_set_sensitive( label, enable );
gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
node = node->Next();
}
@@ -560,9 +558,10 @@ void wxRadioBox::Enable( int item, bool enable )
wxCHECK_RET( node, wxT("radiobox wrong index") );
GtkButton *button = GTK_BUTTON( node->Data() );
GtkWidget *label = button->child;
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) );
gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
gtk_widget_set_sensitive( label, enable );
gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
}
void wxRadioBox::Show( int item, bool show )
@@ -591,7 +590,8 @@ wxString wxRadioBox::GetStringSelection() const
GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
if (button->active)
{
GtkLabel *label = GTK_LABEL( GTK_BUTTON(button)->child );
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
return label->label;
}
node = node->Next();
@@ -663,8 +663,7 @@ void wxRadioBox::ApplyWidgetStyle()
GtkWidget *widget = GTK_WIDGET( node->Data() );
gtk_widget_set_style( widget, m_widgetStyle );
GtkButton *button = GTK_BUTTON( node->Data() );
gtk_widget_set_style( button->child, m_widgetStyle );
gtk_widget_set_style( BUTTON_CHILD(node->Data()), m_widgetStyle );
node = node->Next();
}

View File

@@ -18,8 +18,7 @@
#include "wx/radiobut.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -148,8 +147,7 @@ void wxRadioButton::SetLabel( const wxString& label )
wxCHECK_RET( m_widget != NULL, wxT("invalid radiobutton") );
wxControl::SetLabel( label );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkLabel *g_label = GTK_LABEL( bin->child );
GtkLabel *g_label = GTK_LABEL( BUTTON_CHILD(m_widget) );
gtk_label_set( g_label, GetLabel().mbc_str() );
}
@@ -188,7 +186,7 @@ bool wxRadioButton::Enable( bool enable )
if ( !wxControl::Enable( enable ) )
return FALSE;
gtk_widget_set_sensitive( GTK_BUTTON(m_widget)->child, enable );
gtk_widget_set_sensitive( BUTTON_CHILD(m_widget), enable );
return TRUE;
}
@@ -197,12 +195,12 @@ void wxRadioButton::ApplyWidgetStyle()
{
SetWidgetStyle();
gtk_widget_set_style( m_widget, m_widgetStyle );
gtk_widget_set_style( GTK_BUTTON(m_widget)->child, m_widgetStyle );
gtk_widget_set_style( BUTTON_CHILD(m_widget), m_widgetStyle );
}
bool wxRadioButton::IsOwnGtkWindow( GdkWindow *window )
{
return (window == GTK_TOGGLE_BUTTON(m_widget)->event_window);
return window == TOGGLE_BUTTON_EVENT_WIN(m_widget);
}
void wxRadioButton::OnInternalIdle()
@@ -210,14 +208,15 @@ void wxRadioButton::OnInternalIdle()
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;
if (GTK_TOGGLE_BUTTON(m_widget)->event_window && cursor.Ok())
GdkWindow *win = TOGGLE_BUTTON_EVENT_WIN(m_widget);
if ( win && cursor.Ok())
{
/* I now set the cursor the anew in every OnInternalIdle call
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
gdk_window_set_cursor( GTK_TOGGLE_BUTTON(m_widget)->event_window, cursor.GetCursor() );
gdk_window_set_cursor( win, cursor.GetCursor() );
}
UpdateWindowUI();

View File

@@ -20,12 +20,11 @@
// headers
// ----------------------------------------------------------------------------
#include "wx/log.h"
#include "wx/region.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/log.h"
#include "wx/gtk/private.h"
// ----------------------------------------------------------------------------
// wxRegionRefData: private class containing the information about the region
@@ -87,7 +86,7 @@ void wxRegion::InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
m_refData = new wxRegionRefData();
#ifdef __WXGTK20__
M_REGIONDATA->m_region = gdk_region_rectangle( rect );
M_REGIONDATA->m_region = gdk_region_rectangle( &rect );
#else
GdkRegion *reg = gdk_region_new();
M_REGIONDATA->m_region = gdk_region_union_with_rect( reg, &rect );
@@ -170,7 +169,7 @@ bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
{
m_refData = new wxRegionRefData();
#ifdef __WXGTK20__
M_REGIONDATA->m_region = gdk_region_rectangle( rect );
M_REGIONDATA->m_region = gdk_region_rectangle( &rect );
#else
GdkRegion *reg = gdk_region_new();
M_REGIONDATA->m_region = gdk_region_union_with_rect( reg, &rect );
@@ -498,9 +497,9 @@ void wxRIRefData::CreateRects( const wxRegion& region )
if (!gdkregion) return;
#ifdef __WXGTK20__
GdkRectangles *gdkrects = NULL;
GdkRectangle *gdkrects = NULL;
gint numRects = 0;
gdk_region_get_rectangles( gdkregion, &gdkrect, &numRects );
gdk_region_get_rectangles( gdkregion, &gdkrects, &numRects );
m_numRects = numRects;
if (numRects)
@@ -516,8 +515,8 @@ void wxRIRefData::CreateRects( const wxRegion& region )
wr.height = gr.height;
}
}
g_delete( gdkrects ); // delete []
#else
g_free( gdkrects );
#else // GTK+ 1.x
Region r = ((GdkRegionPrivate *)gdkregion)->xregion;
if (r)
{
@@ -536,7 +535,7 @@ void wxRIRefData::CreateRects( const wxRegion& region )
}
}
}
#endif
#endif // GTK+ 2.0/1.x
}
wxRegionIterator::wxRegionIterator()

View File

@@ -22,8 +22,7 @@
#include <math.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -45,7 +44,11 @@ static const float sensitivity = 0.02;
// "value_changed"
//-----------------------------------------------------------------------------
static void gtk_scrollbar_callback( GtkAdjustment *adjust, wxScrollBar *win )
// FIXME: is GtkScrollType really passed to us as 2nd argument?
static void gtk_scrollbar_callback( GtkAdjustment *adjust,
SCROLLBAR_CBACK_ARG
wxScrollBar *win )
{
if (g_isIdle) wxapp_install_idle_handler();
@@ -57,13 +60,7 @@ static void gtk_scrollbar_callback( GtkAdjustment *adjust, wxScrollBar *win )
win->m_oldPos = adjust->value;
GtkRange *range = GTK_RANGE( win->m_widget );
wxEventType command = wxEVT_SCROLL_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLL_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLL_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLL_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLL_PAGEDOWN;
wxEventType command = GtkScrollTypeToWx(GET_SCROLL_TYPE(win->m_widget));
double dvalue = adjust->value;
int value = (int)(dvalue < 0 ? dvalue - 0.5 : dvalue + 0.5);
@@ -93,7 +90,10 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *widget,
// g_blockEventsOnScroll = TRUE; doesn't work in DialogEd
// FIXME: there is no slider field any more, what was meant here?
#ifndef __WXGTK20__
win->m_isScrolling = (gdk_event->window == widget->slider);
#endif
return FALSE;
}
@@ -316,11 +316,14 @@ void wxScrollBar::SetViewLength( int viewLength )
bool wxScrollBar::IsOwnGtkWindow( GdkWindow *window )
{
GtkRange *range = GTK_RANGE(m_widget);
return ( (window == GTK_WIDGET(range)->window) ||
(window == range->trough) ||
(window == range->slider) ||
(window == range->step_forw) ||
(window == range->step_back) );
return ( (window == GTK_WIDGET(range)->window)
#ifndef __WXGTK20__
|| (window == range->trough)
|| (window == range->slider)
|| (window == range->step_forw)
|| (window == range->step_back)
#endif // GTK+ 1.x
);
}
void wxScrollBar::ApplyWidgetStyle()

View File

@@ -31,10 +31,10 @@
#include "wx/utils.h"
#include "wx/dcclient.h"
#include "wx/gtk/scrolwin.h"
#include "wx/scrolwin.h"
#include "wx/panel.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/win_gtk.h"
// ----------------------------------------------------------------------------
@@ -72,7 +72,9 @@ extern bool g_isIdle;
// "value_changed" from m_vAdjust
//-----------------------------------------------------------------------------
static void gtk_scrolled_window_vscroll_callback( GtkAdjustment *adjust, wxScrolledWindow *win )
static void gtk_scrolled_window_vscroll_callback( GtkAdjustment *adjust,
SCROLLBAR_CBACK_ARG
wxScrolledWindow *win )
{
if (g_isIdle)
wxapp_install_idle_handler();
@@ -81,14 +83,17 @@ static void gtk_scrolled_window_vscroll_callback( GtkAdjustment *adjust, wxScrol
if (!win->m_hasVMT) return;
win->GtkVScroll( adjust->value );
win->GtkVScroll( adjust->value,
GET_SCROLL_TYPE(GTK_SCROLLED_WINDOW(win->m_widget)->vscrollbar) );
}
//-----------------------------------------------------------------------------
// "value_changed" from m_hAdjust
//-----------------------------------------------------------------------------
static void gtk_scrolled_window_hscroll_callback( GtkAdjustment *adjust, wxScrolledWindow *win )
static void gtk_scrolled_window_hscroll_callback( GtkAdjustment *adjust,
SCROLLBAR_CBACK_ARG
wxScrolledWindow *win )
{
if (g_isIdle)
wxapp_install_idle_handler();
@@ -96,7 +101,8 @@ static void gtk_scrolled_window_hscroll_callback( GtkAdjustment *adjust, wxScrol
if (g_blockEventsOnDrag) return;
if (!win->m_hasVMT) return;
win->GtkHScroll( adjust->value );
win->GtkHScroll( adjust->value,
GET_SCROLL_TYPE(GTK_SCROLLED_WINDOW(win->m_widget)->hscrollbar) );
}
//-----------------------------------------------------------------------------
@@ -111,7 +117,11 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *widget,
wxapp_install_idle_handler();
g_blockEventsOnScroll = TRUE;
// FIXME: there is no slider field any more, what was meant here?
#ifndef __WXGTK20__
win->m_isScrolling = (gdk_event->window == widget->slider);
#endif
return FALSE;
}
@@ -512,7 +522,9 @@ void wxScrolledWindow::Scroll( int x_pos, int y_pos )
}
}
void wxScrolledWindow::GtkVScroll( float value )
// TODO: [VH]Scroll functions should be combined
void wxScrolledWindow::GtkVScroll( float value, unsigned int scroll_type )
{
if (!m_targetWindow)
return;
@@ -525,21 +537,14 @@ void wxScrolledWindow::GtkVScroll( float value )
if (y_pos == m_yScrollPosition)
return;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget);
GtkRange *range = GTK_RANGE(scrolledWindow->vscrollbar);
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
wxEventType command = GtkScrollWinTypeToWx(scroll_type);
wxScrollWinEvent event( command, y_pos, wxVERTICAL );
event.SetEventObject( this );
GetEventHandler()->ProcessEvent( event );
}
void wxScrolledWindow::GtkHScroll( float value )
void wxScrolledWindow::GtkHScroll( float value, unsigned int scroll_type )
{
if (!m_targetWindow)
return;
@@ -552,14 +557,7 @@ void wxScrolledWindow::GtkHScroll( float value )
if (x_pos == m_xScrollPosition)
return;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget);
GtkRange *range = GTK_RANGE(scrolledWindow->hscrollbar);
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
wxEventType command = GtkScrollWinTypeToWx(scroll_type);
wxScrollWinEvent event( command, x_pos, wxHORIZONTAL );
event.SetEventObject( this );

View File

@@ -19,8 +19,7 @@
#include <math.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -41,7 +40,9 @@ static const float sensitivity = 0.02;
// "value_changed"
//-----------------------------------------------------------------------------
static void gtk_slider_callback( GtkAdjustment *adjust, wxSlider *win )
static void gtk_slider_callback( GtkAdjustment *adjust,
SCROLLBAR_CBACK_ARG
wxSlider *win )
{
if (g_isIdle) wxapp_install_idle_handler();
@@ -53,13 +54,7 @@ static void gtk_slider_callback( GtkAdjustment *adjust, wxSlider *win )
win->m_oldPos = adjust->value;
GtkRange *range = GTK_RANGE( win->m_widget );
wxEventType command = wxEVT_SCROLL_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLL_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLL_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLL_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLL_PAGEDOWN;
wxEventType command = GtkScrollTypeToWx(GET_SCROLL_TYPE(win->m_widget));
double dvalue = adjust->value;
int value = (int)(dvalue < 0 ? dvalue - 0.5 : dvalue + 0.5);
@@ -247,11 +242,14 @@ int wxSlider::GetLineSize() const
bool wxSlider::IsOwnGtkWindow( GdkWindow *window )
{
GtkRange *range = GTK_RANGE(m_widget);
return ( (window == GTK_WIDGET(range)->window) ||
(window == range->trough) ||
(window == range->slider) ||
(window == range->step_forw) ||
(window == range->step_back) );
return ( (window == GTK_WIDGET(range)->window)
#ifndef __WXGTK20__
|| (window == range->trough)
|| (window == range->slider)
|| (window == range->step_forw)
|| (window == range->step_back)
#endif // GTK+ 1.x
);
}
void wxSlider::ApplyWidgetStyle()

View File

@@ -21,8 +21,7 @@
#include <math.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system

View File

@@ -26,9 +26,8 @@
#include "wx/frame.h"
#include "glib.h"
#include "gdk/gdk.h"
#include "gtk/gtk.h"
#include <glib.h>
#include "wx/gtk/private.h"
extern GdkFont *GtkGetDefaultGuiFont();
@@ -222,7 +221,14 @@ bool wxToolBar::Create( wxWindow *parent,
GtkOrientation orient = style & wxTB_VERTICAL ? GTK_ORIENTATION_VERTICAL
: GTK_ORIENTATION_HORIZONTAL;
#ifdef __WXGTK20__
m_toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
gtk_toolbar_set_orientation(m_toolbar, orient);
gtk_toolbar_set_style(m_toolbar, GTK_TOOLBAR_ICONS);
#else
m_toolbar = GTK_TOOLBAR( gtk_toolbar_new( orient, GTK_TOOLBAR_ICONS ) );
#endif
SetToolSeparation(7);
@@ -242,8 +248,11 @@ bool wxToolBar::Create( wxWindow *parent,
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
// FIXME: there is no such function for toolbars in 2.0
#ifndef __WXGTK20__
if (style & wxTB_FLAT)
gtk_toolbar_set_button_relief( GTK_TOOLBAR(m_toolbar), GTK_RELIEF_NONE );
#endif
m_fg = new GdkColor;
@@ -270,8 +279,9 @@ bool wxToolBar::Create( wxWindow *parent,
GTK_TOOLBAR(m_toolbar)->tooltips->tip_window ) );
g_style->bg[GTK_STATE_NORMAL] = *m_bg;
gdk_font_unref( g_style->font );
g_style->font = gdk_font_ref( GtkGetDefaultGuiFont() );
SET_STYLE_FONT(g_style, GtkGetDefaultGuiFont());
gtk_widget_set_style( GTK_TOOLBAR(m_toolbar)->tooltips->tip_window, g_style );
m_parent->DoAddChild( this );
@@ -478,7 +488,11 @@ void wxToolBar::SetMargins( int x, int y )
void wxToolBar::SetToolSeparation( int separation )
{
// FIXME: this function disappeared
#ifndef __WXGTK20__
gtk_toolbar_set_space_size( m_toolbar, separation );
#endif
m_toolSeparation = separation;
}

View File

@@ -23,9 +23,13 @@
#include <ctype.h>
#include <math.h> // for fabs
#include "gdk/gdk.h"
#include "gtk/gtk.h"
#include "gdk/gdkkeysyms.h"
// TODO: reimplement wxTextCtrl using GtkTextView
#ifdef __WXGTK20__
#define GTK_ENABLE_BROKEN // need this to get GtkText at all
#endif // __WXGTK20__
#include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h>
//-----------------------------------------------------------------------------
// idle system
@@ -212,7 +216,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
bool multi_line = (style & wxTE_MULTILINE) != 0;
if (multi_line)
{
#if (GTK_MINOR_VERSION > 2)
#ifdef __WXGTK13__
/* a multi-line edit control: create a vertical scrollbar by default and
horizontal if requested */
bool bHasHScrollbar = (style & wxHSCROLL) != 0;
@@ -234,7 +238,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
/* always wrap words */
gtk_text_set_word_wrap( GTK_TEXT(m_text), TRUE );
#if (GTK_MINOR_VERSION > 2)
#ifdef __WXGTK13__
/* put the horizontal scrollbar in the lower left hand corner */
if (bHasHScrollbar)
{
@@ -296,7 +300,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
{
gint tmp = 0;
#if GTK_MINOR_VERSION == 0
#if !GTK_CHECK_VERSION(1, 2, 0)
// if we don't realize it, GTK 1.0.6 dies with a SIGSEGV in
// gtk_editable_insert_text()
gtk_widget_realize(m_text);
@@ -312,8 +316,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
if (multi_line)
{
/* bring editable's cursor uptodate. bug in GTK. */
GTK_EDITABLE(m_text)->current_pos = gtk_text_get_point( GTK_TEXT(m_text) );
SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
}
}
@@ -446,7 +449,7 @@ void wxTextCtrl::WriteText( const wxString &text )
if ( m_windowStyle & wxTE_MULTILINE )
{
// After cursor movements, gtk_text_get_point() is wrong by one.
gtk_text_set_point( GTK_TEXT(m_text), GTK_EDITABLE(m_text)->current_pos );
gtk_text_set_point( GTK_TEXT(m_text), GET_EDITABLE_POS(m_text) );
// if we have any special style, use it
if ( !m_defaultStyle.IsDefault() )
@@ -457,24 +460,24 @@ void wxTextCtrl::WriteText( const wxString &text )
}
else // no style
{
gint len = GTK_EDITABLE(m_text)->current_pos;
gint len = GET_EDITABLE_POS(m_text);
gtk_editable_insert_text( GTK_EDITABLE(m_text), txt, txtlen, &len );
}
// Bring editable's cursor back uptodate.
GTK_EDITABLE(m_text)->current_pos = gtk_text_get_point( GTK_TEXT(m_text) );
SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
}
else // single line
{
// This moves the cursor pos to behind the inserted text.
gint len = GTK_EDITABLE(m_text)->current_pos;
gint len = GET_EDITABLE_POS(m_text);
gtk_editable_insert_text( GTK_EDITABLE(m_text), txt, txtlen, &len );
// Bring editable's cursor uptodate.
GTK_EDITABLE(m_text)->current_pos += text.Len();
len += text.Len();
// Bring entry's cursor uptodate.
gtk_entry_set_position( GTK_ENTRY(m_text), GTK_EDITABLE(m_text)->current_pos );
gtk_entry_set_position( GTK_ENTRY(m_text), len );
}
m_modified = TRUE;
@@ -643,7 +646,7 @@ void wxTextCtrl::SetInsertionPoint( long pos )
/* bring editable's cursor uptodate. another bug in GTK. */
GTK_EDITABLE(m_text)->current_pos = gtk_text_get_point( GTK_TEXT(m_text) );
SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
}
else
{
@@ -651,7 +654,7 @@ void wxTextCtrl::SetInsertionPoint( long pos )
/* bring editable's cursor uptodate. bug in GTK. */
GTK_EDITABLE(m_text)->current_pos = (guint32)pos;
SET_EDITABLE_POS(m_text, (guint32)pos);
}
}
@@ -810,7 +813,7 @@ long wxTextCtrl::GetInsertionPoint() const
{
wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") );
return (long) GTK_EDITABLE(m_text)->current_pos;
return (long) GET_EDITABLE_POS(m_text);
}
long wxTextCtrl::GetLastPosition() const
@@ -855,33 +858,21 @@ void wxTextCtrl::Cut()
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
#if (GTK_MINOR_VERSION > 0)
gtk_editable_cut_clipboard( GTK_EDITABLE(m_text) );
#else
gtk_editable_cut_clipboard( GTK_EDITABLE(m_text), 0 );
#endif
gtk_editable_cut_clipboard( GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG );
}
void wxTextCtrl::Copy()
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
#if (GTK_MINOR_VERSION > 0)
gtk_editable_copy_clipboard( GTK_EDITABLE(m_text) );
#else
gtk_editable_copy_clipboard( GTK_EDITABLE(m_text), 0 );
#endif
gtk_editable_copy_clipboard( GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG );
}
void wxTextCtrl::Paste()
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
#if (GTK_MINOR_VERSION > 0)
gtk_editable_paste_clipboard( GTK_EDITABLE(m_text) );
#else
gtk_editable_paste_clipboard( GTK_EDITABLE(m_text), 0 );
#endif
gtk_editable_paste_clipboard( GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG );
}
// Undo/redo
@@ -917,21 +908,27 @@ void wxTextCtrl::GetSelection(long* fromOut, long* toOut) const
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
long from, to;
gint from, to;
#ifdef __WXGTK20__
if ( !gtk_editable_get_selection_bounds(GTK_EDITABLE(m_text), &from, &to) )
#else
if ( !(GTK_EDITABLE(m_text)->has_selection) )
#endif
{
from =
to = GetInsertionPoint();
}
else // got selection
{
#ifndef __WXGTK20__
from = (long) GTK_EDITABLE(m_text)->selection_start_pos;
to = (long) GTK_EDITABLE(m_text)->selection_end_pos;
#endif
if ( from > to )
{
// exchange them to be compatible with wxMSW
long tmp = from;
gint tmp = from;
from = to;
to = tmp;
}
@@ -947,7 +944,11 @@ bool wxTextCtrl::IsEditable() const
{
wxCHECK_MSG( m_text != NULL, FALSE, wxT("invalid text ctrl") );
#ifdef __WXGTK20__
return gtk_editable_get_editable(GTK_EDITABLE(m_text));
#else
return GTK_EDITABLE(m_text)->editable;
#endif
}
bool wxTextCtrl::IsModified() const

View File

@@ -15,8 +15,7 @@
#if wxUSE_TOGGLEBTN
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
extern void wxapp_install_idle_handler();
extern bool g_isIdle;
@@ -125,8 +124,7 @@ void wxToggleButton::SetLabel(const wxString& label)
wxControl::SetLabel(label);
gtk_label_set(GTK_LABEL(GTK_BUTTON(m_widget)->child),
GetLabel().mbc_str());
gtk_label_set(GTK_LABEL(BUTTON_CHILD(m_widget)), GetLabel().mbc_str());
}
bool wxToggleButton::Enable(bool enable /*=TRUE*/)
@@ -134,7 +132,7 @@ bool wxToggleButton::Enable(bool enable /*=TRUE*/)
if (!wxControl::Enable(enable))
return FALSE;
gtk_widget_set_sensitive(GTK_BUTTON(m_widget)->child, enable);
gtk_widget_set_sensitive(BUTTON_CHILD(m_widget), enable);
return TRUE;
}
@@ -143,12 +141,12 @@ void wxToggleButton::ApplyWidgetStyle()
{
SetWidgetStyle();
gtk_widget_set_style(m_widget, m_widgetStyle);
gtk_widget_set_style(GTK_BUTTON(m_widget)->child, m_widgetStyle);
gtk_widget_set_style(BUTTON_CHILD(m_widget), m_widgetStyle);
}
bool wxToggleButton::IsOwnGtkWindow(GdkWindow *window)
{
return (window == GTK_TOGGLE_BUTTON(m_widget)->event_window);
return window == TOGGLE_BUTTON_EVENT_WIN(m_widget);
}
void wxToggleButton::OnInternalIdle()
@@ -158,14 +156,15 @@ void wxToggleButton::OnInternalIdle()
if (g_globalCursor.Ok())
cursor = g_globalCursor;
if (GTK_TOGGLE_BUTTON(m_widget)->event_window && cursor.Ok()) {
GdkWindow *win = TOGGLE_BUTTON_EVENT_WIN(m_widget);
if ( win && cursor.Ok() )
{
/* I now set the cursor the anew in every OnInternalIdle call
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
gdk_window_set_cursor(GTK_TOGGLE_BUTTON(m_widget)->event_window,
cursor.GetCursor());
gdk_window_set_cursor(win, cursor.GetCursor());
}
UpdateWindowUI();

View File

@@ -18,8 +18,7 @@
#include "wx/window.h"
#include "wx/tooltip.h"
#include "gtk/gtk.h"
#include "gdk/gdk.h"
#include "wx/gtk/private.h"
extern GdkFont *GtkGetDefaultGuiFont();
@@ -67,7 +66,7 @@ void wxToolTip::Apply( wxWindow *win )
ss_bg.blue = 50000;
gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_bg );
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
gtk_tooltips_force_window( ss_tooltips );
GtkStyle *g_style =
@@ -76,11 +75,11 @@ void wxToolTip::Apply( wxWindow *win )
g_style->fg[GTK_STATE_NORMAL] = ss_fg;
g_style->bg[GTK_STATE_NORMAL] = ss_bg;
gdk_font_unref( g_style->font );
g_style->font = gdk_font_ref( GtkGetDefaultGuiFont() );
SET_STYLE_FONT( g_style, GtkGetDefaultGuiFont() );
gtk_widget_set_style( ss_tooltips->tip_window, g_style );
#else
#else // GTK+ 1.0
gtk_tooltips_set_colors( ss_tooltips, &ss_bg, &ss_fg );
#endif
}

View File

@@ -376,7 +376,14 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
win_type = GTK_WINDOW_POPUP;
if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)
{
// there is no more GTK_WINDOW_DIALOG in 2.0
#ifdef __WXGTK20__
win_type = GTK_WINDOW_TOPLEVEL;
#else
win_type = GTK_WINDOW_DIALOG;
#endif
}
m_widget = gtk_window_new( win_type );

View File

@@ -50,8 +50,10 @@ static void gtk_pizza_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_pizza_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
#ifndef __WXGTK20__
static void gtk_pizza_draw (GtkWidget *widget,
GdkRectangle *area);
#endif /* __WXGTK20__ */
static gint gtk_pizza_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_pizza_add (GtkContainer *container,
@@ -146,7 +148,9 @@ gtk_pizza_class_init (GtkPizzaClass *klass)
widget_class->unrealize = gtk_pizza_unrealize;
widget_class->size_request = gtk_pizza_size_request;
widget_class->size_allocate = gtk_pizza_size_allocate;
#ifndef __WXGTK20__
widget_class->draw = gtk_pizza_draw;
#endif
widget_class->expose_event = gtk_pizza_expose;
container_class->add = gtk_pizza_add;
@@ -160,7 +164,6 @@ gtk_pizza_class_init (GtkPizzaClass *klass)
widget_class->set_scroll_adjustments_signal =
gtk_signal_new ("set_scroll_adjustments",
GTK_RUN_LAST,
#ifdef __WXGTK20__
GTK_CLASS_TYPE(object_class),
#else
@@ -708,6 +711,8 @@ gtk_pizza_size_allocate (GtkWidget *widget,
}
}
#ifndef __WXGTK20__
static void
gtk_pizza_draw (GtkWidget *widget,
GdkRectangle *area)
@@ -744,6 +749,8 @@ gtk_pizza_draw (GtkWidget *widget,
}
}
#endif /* __WXGTK20__ */
static gint
gtk_pizza_expose (GtkWidget *widget,
GdkEventExpose *event)
@@ -1048,6 +1055,7 @@ gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy)
{
GtkWidget *widget;
XEvent xevent;
XID win;
gint x,y,w,h,border;
@@ -1142,10 +1150,12 @@ gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy)
gtk_pizza_position_children (pizza);
gdk_flush();
win = GDK_WINDOW_XWINDOW (pizza->bin_window);
while (XCheckIfEvent(GDK_WINDOW_XDISPLAY (pizza->bin_window),
&xevent,
gtk_pizza_expose_predicate,
(XPointer)&GDK_WINDOW_XWINDOW (pizza->bin_window)))
(XPointer)&win))
{
GdkEvent event;
GtkWidget *event_widget;

View File

@@ -54,8 +54,7 @@
#include <math.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include <gdk/gdkprivate.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h>
@@ -65,6 +64,12 @@
#include "wx/gtk/win_gtk.h"
#ifdef __WXGTK20__
#define SET_CONTAINER_FOCUS(w, d) gtk_widget_child_focus((w), (d))
#else
#define SET_CONTAINER_FOCUS(w, d) gtk_container_focus(GTK_CONTAINER(w), (d))
#endif
//-----------------------------------------------------------------------------
// documentation on internals
//-----------------------------------------------------------------------------
@@ -1857,7 +1862,9 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_
// "value_changed" from m_vAdjust
//-----------------------------------------------------------------------------
static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win )
static void gtk_window_vscroll_callback( GtkAdjustment *adjust,
SCROLLBAR_CBACK_ARG
wxWindowGTK *win )
{
DEBUG_MAIN_THREAD
@@ -1873,14 +1880,7 @@ static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win
win->m_oldVerticalPos = adjust->value;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
GtkRange *range = GTK_RANGE( scrolledWindow->vscrollbar );
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(win->m_widget));
int value = (int)(adjust->value+0.5);
@@ -1893,7 +1893,9 @@ static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win
// "value_changed" from m_hAdjust
//-----------------------------------------------------------------------------
static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win )
static void gtk_window_hscroll_callback( GtkAdjustment *adjust,
SCROLLBAR_CBACK_ARG
wxWindowGTK *win )
{
DEBUG_MAIN_THREAD
@@ -1906,17 +1908,10 @@ static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win
float diff = adjust->value - win->m_oldHorizontalPos;
if (fabs(diff) < 0.2) return;
wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(win->m_widget));
win->m_oldHorizontalPos = adjust->value;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
GtkRange *range = GTK_RANGE( scrolledWindow->hscrollbar );
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
int value = (int)(adjust->value+0.5);
wxScrollWinEvent event( command, value, wxHORIZONTAL );
@@ -1939,7 +1934,11 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *widget,
g_blockEventsOnScroll = TRUE;
// FIXME: there is no 'slider' field in GTK+ 2.0 any more
#ifndef __WXGTK20__
win->m_isScrolling = (gdk_event->window == widget->slider);
#endif
return FALSE;
}
@@ -2341,7 +2340,8 @@ bool wxWindowGTK::Create( wxWindow *parent,
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
#ifndef __WXUNIVERSAL__
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
GtkPizza *pizza = GTK_PIZZA(m_wxwindow);
if (HasFlag(wxRAISED_BORDER))
@@ -2360,7 +2360,7 @@ bool wxWindowGTK::Create( wxWindow *parent,
{
gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_NONE );
}
#else // GTK_MINOR_VERSION == 0
#else // GTK+ 1.0
GtkViewport *viewport = GTK_VIEWPORT(scrolledWindow->viewport);
if (HasFlag(wxRAISED_BORDER))
@@ -2375,17 +2375,18 @@ bool wxWindowGTK::Create( wxWindow *parent,
{
gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE );
}
#endif // GTK_MINOR_VERSION
#endif // GTK+ > 1.0/<= 1.0
#endif // __WXUNIVERSAL__
GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
m_acceptsFocus = TRUE;
#if (GTK_MINOR_VERSION == 0)
#if !GTK_CHECK_VERSION(1, 2, 0)
// shut the viewport up
gtk_viewport_set_hadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
gtk_viewport_set_vadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
#endif // GTK_MINOR_VERSION == 0
#endif // GTK+ 1.0
// I _really_ don't want scrollbars in the beginning
m_vAdjust->lower = 0.0;
@@ -3167,7 +3168,7 @@ void wxWindowGTK::SetFocus()
}
else if (GTK_IS_CONTAINER(m_widget))
{
gtk_container_focus( GTK_CONTAINER(m_widget), GTK_DIR_TAB_FORWARD );
SET_CONTAINER_FOCUS( m_widget, GTK_DIR_TAB_FORWARD );
}
else
{
@@ -3541,10 +3542,9 @@ GtkStyle *wxWindowGTK::GetWidgetStyle()
if (m_widgetStyle)
{
GtkStyle *remake = gtk_style_copy( m_widgetStyle );
#ifdef __WXGTK20__
/* FIXME: is this necessary? */
_G_TYPE_IGC(remake, GtkObjectClass) = _G_TYPE_IGC(m_widgetStyle, GtkObjectClass);
#else
// FIXME: no more klass in 2.0
#ifndef __WXGTK20__
remake->klass = m_widgetStyle->klass;
#endif
@@ -3559,10 +3559,9 @@ GtkStyle *wxWindowGTK::GetWidgetStyle()
def = gtk_widget_get_default_style();
m_widgetStyle = gtk_style_copy( def );
#ifdef __WXGTK20__
/* FIXME: is this necessary? */
_G_TYPE_IGC(m_widgetStyle, GtkObjectClass) = _G_TYPE_IGC(def, GtkObjectClass);
#else
// FIXME: no more klass in 2.0
#ifndef __WXGTK20__
m_widgetStyle->klass = def->klass;
#endif
}
@@ -3590,8 +3589,7 @@ void wxWindowGTK::SetWidgetStyle()
if (m_font != wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ))
{
gdk_font_unref( style->font );
style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
SET_STYLE_FONT(style, m_font.GetInternalFont( 1.0 ));
}
if (m_foregroundColour.Ok())
@@ -3701,6 +3699,9 @@ static gint gs_pop_y = 0;
extern "C" void wxPopupMenuPositionCallback( GtkMenu *menu,
gint *x, gint *y,
#ifdef __WXGTK20__
gboolean * WXUNUSED(whatever),
#endif
gpointer WXUNUSED(user_data) )
{
// ensure that the menu appears entirely on screen

View File

@@ -21,13 +21,23 @@
#include "wx/dcmemory.h"
#include "wx/app.h"
#ifdef __WXGTK20__
// need this to get gdk_image_new_bitmap()
#define GDK_ENABLE_BROKEN
#endif
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#ifdef __WXGTK20__
#include <gdk/gdkimage.h>
#else // GTK+ 1.2
// VZ: is this still needed? seems to compile fine without it...
#if (GTK_MINOR_VERSION > 0)
#include <gdk/gdkrgb.h>
#endif
#endif // GTK+ 2.0/1.2
extern void gdk_wx_draw_bitmap (GdkDrawable *drawable,
GdkGC *gc,

View File

@@ -17,8 +17,7 @@
#include "wx/bmpbuttn.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// classes
@@ -199,7 +198,8 @@ wxString wxBitmapButton::GetLabel() const
void wxBitmapButton::ApplyWidgetStyle()
{
if (GTK_BUTTON(m_widget)->child == NULL) return;
if ( !BUTTON_CHILD(m_widget) )
return;
wxButton::ApplyWidgetStyle();
}
@@ -236,8 +236,8 @@ void wxBitmapButton::OnSetBitmap()
GdkBitmap *mask = (GdkBitmap *) NULL;
if (the_one.GetMask()) mask = the_one.GetMask()->GetBitmap();
GtkButton *bin = GTK_BUTTON(m_widget);
if (bin->child == NULL)
GtkWidget *child = BUTTON_CHILD(m_widget);
if (child == NULL)
{
// initial bitmap
GtkWidget *pixmap = gtk_pixmap_new(the_one.GetPixmap(), mask);
@@ -246,7 +246,7 @@ void wxBitmapButton::OnSetBitmap()
}
else
{ // subsequent bitmaps
GtkPixmap *g_pixmap = GTK_PIXMAP(bin->child);
GtkPixmap *g_pixmap = GTK_PIXMAP(child);
gtk_pixmap_set(g_pixmap, the_one.GetPixmap(), mask);
}
}

View File

@@ -17,8 +17,7 @@
#include "wx/button.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// classes
@@ -163,7 +162,7 @@ void wxButton::SetLabel( const wxString &label )
wxControl::SetLabel( label );
gtk_label_set( GTK_LABEL( GTK_BUTTON(m_widget)->child ), GetLabel().mbc_str() );
gtk_label_set( GTK_LABEL( BUTTON_CHILD(m_widget) ), GetLabel().mbc_str() );
}
bool wxButton::Enable( bool enable )
@@ -171,7 +170,7 @@ bool wxButton::Enable( bool enable )
if ( !wxControl::Enable( enable ) )
return FALSE;
gtk_widget_set_sensitive( GTK_BUTTON(m_widget)->child, enable );
gtk_widget_set_sensitive( BUTTON_CHILD(m_widget), enable );
return TRUE;
}
@@ -180,7 +179,7 @@ void wxButton::ApplyWidgetStyle()
{
SetWidgetStyle();
gtk_widget_set_style( m_widget, m_widgetStyle );
gtk_widget_set_style( GTK_BUTTON(m_widget)->child, m_widgetStyle );
gtk_widget_set_style( BUTTON_CHILD(m_widget), m_widgetStyle );
}
wxSize wxButton::DoGetBestSize() const

View File

@@ -18,8 +18,7 @@
#include "wx/checkbox.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -107,7 +106,7 @@ bool wxCheckBox::Create(wxWindow *parent,
else
{
m_widgetCheckbox = gtk_check_button_new_with_label( m_label.mbc_str() );
m_widgetLabel = GTK_BUTTON( m_widgetCheckbox )->child;
m_widgetLabel = BUTTON_CHILD( m_widgetCheckbox );
m_widget = m_widgetCheckbox;
}
@@ -188,7 +187,7 @@ void wxCheckBox::ApplyWidgetStyle()
bool wxCheckBox::IsOwnGtkWindow( GdkWindow *window )
{
return (window == GTK_TOGGLE_BUTTON(m_widget)->event_window);
return window == TOGGLE_BUTTON_EVENT_WIN(m_widget);
}
void wxCheckBox::OnInternalIdle()
@@ -196,14 +195,15 @@ void wxCheckBox::OnInternalIdle()
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;
if (GTK_TOGGLE_BUTTON(m_widgetCheckbox)->event_window && cursor.Ok())
GdkWindow *event_window = TOGGLE_BUTTON_EVENT_WIN(m_widgetCheckbox);
if ( event_window && cursor.Ok() )
{
/* I now set the cursor the anew in every OnInternalIdle call
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
gdk_window_set_cursor( GTK_TOGGLE_BUTTON(m_widgetCheckbox)->event_window, cursor.GetCursor() );
gdk_window_set_cursor( event_window, cursor.GetCursor() );
}
UpdateWindowUI();

View File

@@ -18,8 +18,7 @@
#include "wx/choice.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -229,8 +228,10 @@ int wxChoice::FindString( const wxString &string ) const
{
GtkBin *bin = GTK_BIN( child->data );
GtkLabel *label = (GtkLabel *) NULL;
if (bin->child) label = GTK_LABEL(bin->child);
if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
if (bin->child)
label = GTK_LABEL(bin->child);
if (!label)
label = GTK_LABEL( BUTTON_CHILD(m_widget) );
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
@@ -282,8 +283,10 @@ wxString wxChoice::GetString( int n ) const
if (count == n)
{
GtkLabel *label = (GtkLabel *) NULL;
if (bin->child) label = GTK_LABEL(bin->child);
if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
if (bin->child)
label = GTK_LABEL(bin->child);
if (!label)
label = GTK_LABEL( BUTTON_CHILD(m_widget) );
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
@@ -337,8 +340,10 @@ void wxChoice::ApplyWidgetStyle()
GtkBin *bin = GTK_BIN( child->data );
GtkWidget *label = (GtkWidget *) NULL;
if (bin->child) label = bin->child;
if (!label) label = GTK_BUTTON(m_widget)->child;
if (bin->child)
label = bin->child;
if (!label)
label = BUTTON_CHILD(m_widget);
gtk_widget_set_style( label, m_widgetStyle );
@@ -434,7 +439,8 @@ wxSize wxChoice::DoGetBestSize() const
if ( ret.x < 80 )
ret.x = 80;
ret.y = 16 + gdk_char_height( m_widget->style->font, 'H' );
ret.y = 16 + gdk_char_height(GET_STYLE_FONT( m_widget->style ), 'H');
return ret;
}

View File

@@ -20,8 +20,7 @@
#include "wx/textctrl.h" // for wxEVT_COMMAND_TEXT_UPDATED
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -492,11 +491,7 @@ void wxComboBox::Copy()
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
#if defined(__WXGTK13__) || (GTK_MINOR_VERSION > 0)
gtk_editable_copy_clipboard( GTK_EDITABLE(entry) );
#else
gtk_editable_copy_clipboard( GTK_EDITABLE(entry), 0 );
#endif
gtk_editable_copy_clipboard( GTK_EDITABLE(entry) DUMMY_CLIPBOARD_ARG );
}
void wxComboBox::Cut()
@@ -504,11 +499,7 @@ void wxComboBox::Cut()
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
#if defined(__WXGTK13__) || (GTK_MINOR_VERSION > 0)
gtk_editable_cut_clipboard( GTK_EDITABLE(entry) );
#else
gtk_editable_cut_clipboard( GTK_EDITABLE(entry), 0 );
#endif
gtk_editable_cut_clipboard( GTK_EDITABLE(entry) DUMMY_CLIPBOARD_ARG );
}
void wxComboBox::Paste()
@@ -516,11 +507,7 @@ void wxComboBox::Paste()
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
#if defined(__WXGTK13__) || (GTK_MINOR_VERSION > 0)
gtk_editable_paste_clipboard( GTK_EDITABLE(entry) );
#else
gtk_editable_paste_clipboard( GTK_EDITABLE(entry), 0 );
#endif
gtk_editable_paste_clipboard( GTK_EDITABLE(entry) DUMMY_CLIPBOARD_ARG);
}
void wxComboBox::SetInsertionPoint( long pos )
@@ -540,8 +527,7 @@ void wxComboBox::SetInsertionPointEnd()
long wxComboBox::GetInsertionPoint() const
{
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
return (long) GTK_EDITABLE(entry)->current_pos;
return (long) GET_EDITABLE_POS( GTK_COMBO(m_widget)->entry );
}
long wxComboBox::GetLastPosition() const

View File

@@ -1358,11 +1358,11 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
y = YLOG2DEV(y);
#if defined(__WXGTK20__) && wxUSE_WCHAR_T
/* FIXME: the layout engine should probably be abstracted at a higher level in wxDC... */
// TODO: the layout engine should be abstracted at a higher level!
PangoLayout *layout = pango_layout_new(m_context);
pango_layout_set_font_description(layout, m_fontdesc);
{
wxWX2MBbuf data = text.mb_str(wxConvUTF8);
const wxWX2MBbuf data = text.mb_str(wxConvUTF8);
pango_layout_set_text(layout, data, strlen(data));
}
PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data;
@@ -1371,7 +1371,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
wxCoord width = rect.width;
wxCoord height = rect.height;
gdk_draw_layout( m_window, m_textGC, x, y, layout );
#else
#else // GTK+ 1.x
wxCoord width = gdk_string_width( font, text.mbc_str() );
wxCoord height = font->ascent + font->descent;
@@ -1382,7 +1382,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
gdk_gc_set_foreground( m_textGC, m_textForegroundColour.GetColor() );
}
gdk_draw_string( m_window, font, m_textGC, x, y + font->ascent, text.mbc_str() );
#endif
#endif // GTK+ 2.0/1.x
/* CMB 17/7/98: simple underline: ignores scaling and underlying
X font's XA_UNDERLINE_POSITION and XA_UNDERLINE_THICKNESS

View File

@@ -21,8 +21,8 @@
#include "wx/intl.h"
#include "wx/utils.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include <gdk/gdkprivate.h>
#include <gtk/gtkdnd.h>

View File

@@ -30,9 +30,8 @@
#include <strings.h>
#include <gdk/gdk.h>
#include "wx/gtk/private.h"
#include <gdk/gdkprivate.h>
#include <gtk/gtk.h>
// ----------------------------------------------------------------------------
// constants
@@ -656,13 +655,13 @@ extern GdkFont *GtkGetDefaultGuiFont()
GtkStyle *def = gtk_rc_get_style( widget );
if (def)
{
g_systemDefaultGuiFont = gdk_font_ref( def->font );
g_systemDefaultGuiFont = gdk_font_ref( GET_STYLE_FONT(def) );
}
else
{
def = gtk_widget_get_default_style();
if (def)
g_systemDefaultGuiFont = gdk_font_ref( def->font );
g_systemDefaultGuiFont = gdk_font_ref( GET_STYLE_FONT(def) );
}
gtk_widget_destroy( widget );
}

View File

@@ -22,7 +22,7 @@
#include "wx/debug.h"
#include "wx/msgdlg.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -133,13 +133,13 @@ wxFontDialog::wxFontDialog( wxWindow *parent, wxFontData *fontdata )
GTK_SIGNAL_FUNC(gtk_fontdialog_ok_callback), (gpointer*)this );
// strange way to internationalize
gtk_label_set( GTK_LABEL( GTK_BUTTON(sel->ok_button)->child ), wxConvCurrent->cWX2MB(_("OK")) );
gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->ok_button) ), wxConvCurrent->cWX2MB(_("OK")) );
gtk_signal_connect( GTK_OBJECT(sel->cancel_button), "clicked",
GTK_SIGNAL_FUNC(gtk_fontdialog_cancel_callback), (gpointer*)this );
// strange way to internationalize
gtk_label_set( GTK_LABEL( GTK_BUTTON(sel->cancel_button)->child ), wxConvCurrent->cWX2MB(_("Cancel")) );
gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->cancel_button) ), wxConvCurrent->cWX2MB(_("Cancel")) );
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
GTK_SIGNAL_FUNC(gtk_fontdialog_delete_callback), (gpointer)this );

View File

@@ -34,8 +34,8 @@
#include "wx/dcclient.h"
#include <glib.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h>

View File

@@ -363,12 +363,12 @@ wxMenuBar *wxMDIChildFrame::GetMenuBar() const
void wxMDIChildFrame::Activate()
{
#if (GTK_MINOR_VERSION > 0)
#if defined(__WXGTK20__) || (GTK_MINOR_VERSION > 0)
wxMDIParentFrame* parent = (wxMDIParentFrame*) GetParent();
GtkNotebook* notebook = GTK_NOTEBOOK(parent->m_widget);
gint pageno = gtk_notebook_page_num( notebook, m_page->child );
gint pageno = gtk_notebook_page_num( notebook, m_widget );
gtk_notebook_set_page( notebook, pageno );
#else
#else // GTK+ 1.0
// the only way I can see to do this under gtk+ 1.0.X would
// be to keep track of page numbers, start at first and
// do "next" enough times to get to this page number - messy
@@ -402,7 +402,7 @@ void wxMDIChildFrame::SetTitle( const wxString &title )
wxMDIParentFrame* parent = (wxMDIParentFrame*) GetParent();
GtkNotebook* notebook = GTK_NOTEBOOK(parent->m_widget);
gtk_notebook_set_tab_label_text(notebook, m_page->child, title.mbc_str());
gtk_notebook_set_tab_label_text(notebook, m_widget, title.mbc_str());
}
//-----------------------------------------------------------------------------

View File

@@ -22,9 +22,26 @@
#include "wx/accel.h"
#endif // wxUSE_ACCEL
#include <gdk/gdk.h>
#include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
// FIXME: is this right? somehow I don't think so (VZ)
#ifdef __WXGTK20__
#include <glib-object.h>
#define gtk_accel_group_attach(g, o) _gtk_accel_group_attach((g), (o))
#define gtk_accel_group_detach(g, o) _gtk_accel_group_detach((g), (o))
#define gtk_menu_ensure_uline_accel_group(m) gtk_menu_get_accel_group(m)
#define ACCEL_OBJECT GObject
#define ACCEL_OBJECTS(a) (a)->acceleratables
#define ACCEL_OBJ_CAST(obj) G_OBJECT(obj)
#else // GTK+ 1.x
#define ACCEL_OBJECT GtkObject
#define ACCEL_OBJECTS(a) (a)->attach_objects
#define ACCEL_OBJ_CAST(obj) GTK_OBJECT(obj)
#endif
//-----------------------------------------------------------------------------
// idle system
@@ -33,7 +50,7 @@
extern void wxapp_install_idle_handler();
extern bool g_isIdle;
#if (GTK_MINOR_VERSION > 0) && wxUSE_ACCEL
#if GTK_CHECK_VERSION(1, 2, 0) && wxUSE_ACCEL
static wxString GetHotKey( const wxMenuItem& item );
#endif
@@ -41,6 +58,13 @@ static wxString GetHotKey( const wxMenuItem& item );
// substitute for missing GtkPixmapMenuItem
//-----------------------------------------------------------------------------
// FIXME: I can't make this compile with GTK+ 2.0, disabling for now (VZ)
#ifndef __WXGTK20__
#define USE_MENU_BITMAPS
#endif
#ifdef USE_MENU_BITMAPS
#define GTK_TYPE_PIXMAP_MENU_ITEM (gtk_pixmap_menu_item_get_type ())
#define GTK_PIXMAP_MENU_ITEM(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_PIXMAP_MENU_ITEM, GtkPixmapMenuItem))
#define GTK_PIXMAP_MENU_ITEM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_PIXMAP_MENU_ITEM, GtkPixmapMenuItemClass))
@@ -77,6 +101,8 @@ GtkWidget* gtk_pixmap_menu_item_new (void);
void gtk_pixmap_menu_item_set_pixmap (GtkPixmapMenuItem *menu_item,
GtkWidget *pixmap);
#endif // USE_MENU_BITMAPS
//-----------------------------------------------------------------------------
// idle system
//-----------------------------------------------------------------------------
@@ -91,7 +117,7 @@ static wxString wxReplaceUnderscore( const wxString& title )
{
if (*pc == wxT('&'))
{
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
str << wxT('_');
}
else if (*pc == wxT('/'))
@@ -139,7 +165,7 @@ wxMenuBar::wxMenuBar( long style )
m_menus.DeleteContents( TRUE );
/* GTK 1.2.0 doesn't have gtk_item_factory_get_item(), but GTK 1.2.1 has. */
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
m_accel = gtk_accel_group_new();
m_factory = gtk_item_factory_new( GTK_TYPE_MENU_BAR, "<main>", m_accel );
m_menubar = gtk_item_factory_get_widget( m_factory, "<main>" );
@@ -180,7 +206,7 @@ wxMenuBar::wxMenuBar()
m_menus.DeleteContents( TRUE );
/* GTK 1.2.0 doesn't have gtk_item_factory_get_item(), but GTK 1.2.1 has. */
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
m_accel = gtk_accel_group_new();
m_factory = gtk_item_factory_new( GTK_TYPE_MENU_BAR, "<main>", m_accel );
m_menubar = gtk_item_factory_get_widget( m_factory, "<main>" );
@@ -204,13 +230,13 @@ static void wxMenubarUnsetInvokingWindow( wxMenu *menu, wxWindow *win )
{
menu->SetInvokingWindow( (wxWindow*) NULL );
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
wxWindow *top_frame = win;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
/* support for native hot keys */
gtk_accel_group_detach( menu->m_accel, GTK_OBJECT(top_frame->m_widget) );
gtk_accel_group_detach( menu->m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) );
#endif
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
@@ -227,16 +253,16 @@ static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win )
{
menu->SetInvokingWindow( win );
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
wxWindow *top_frame = win;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
/* support for native hot keys */
GtkObject *obj = GTK_OBJECT(top_frame->m_widget);
if ( !g_slist_find( menu->m_accel->attach_objects, obj ) )
ACCEL_OBJECT *obj = ACCEL_OBJ_CAST(top_frame->m_widget);
if ( !g_slist_find( ACCEL_OBJECTS(menu->m_accel), obj ) )
gtk_accel_group_attach( menu->m_accel, obj );
#endif
#endif // GTK+ 1.2.1+
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
while (node)
@@ -251,16 +277,16 @@ static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win )
void wxMenuBar::SetInvokingWindow( wxWindow *win )
{
m_invokingWindow = win;
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
wxWindow *top_frame = win;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
/* support for native key accelerators indicated by underscroes */
GtkObject *obj = GTK_OBJECT(top_frame->m_widget);
if ( !g_slist_find( m_accel->attach_objects, obj ) )
ACCEL_OBJECT *obj = ACCEL_OBJ_CAST(top_frame->m_widget);
if ( !g_slist_find( ACCEL_OBJECTS(m_accel), obj ) )
gtk_accel_group_attach( m_accel, obj );
#endif
#endif // GTK+ 1.2.1+
wxMenuList::Node *node = m_menus.GetFirst();
while (node)
@@ -274,14 +300,14 @@ void wxMenuBar::SetInvokingWindow( wxWindow *win )
void wxMenuBar::UnsetInvokingWindow( wxWindow *win )
{
m_invokingWindow = (wxWindow*) NULL;
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
wxWindow *top_frame = win;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
/* support for native key accelerators indicated by underscroes */
gtk_accel_group_detach( m_accel, GTK_OBJECT(top_frame->m_widget) );
#endif
gtk_accel_group_detach( m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) );
#endif // GTK+ 1.2.1+
wxMenuList::Node *node = m_menus.GetFirst();
while (node)
@@ -308,7 +334,7 @@ bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title)
menu->SetTitle( str );
/* GTK 1.2.0 doesn't have gtk_item_factory_get_item(), but GTK 1.2.1 has. */
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 1)
/* local buffer in multibyte form */
wxString buf;
@@ -527,7 +553,7 @@ wxString wxMenuBar::GetLabelTop( size_t pos ) const
wxString label;
wxString text( menu->GetTitle() );
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
for ( const wxChar *pc = text.c_str(); *pc; pc++ )
{
if ( *pc == wxT('_') || *pc == wxT('&') )
@@ -764,7 +790,7 @@ void wxMenuItem::DoSetText( const wxString& str )
{
if (*pc == wxT('&'))
{
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
m_text << wxT('_');
}
else if ( *pc == wxT('_') ) // escape underscores
@@ -774,7 +800,7 @@ void wxMenuItem::DoSetText( const wxString& str )
else if (*pc == wxT('/')) /* we have to filter out slashes ... */
{
m_text << wxT('\\'); /* ... and replace them with back slashes */
#endif
#endif // GTK+ 1.2.0+
}
else
m_text << *pc;
@@ -782,13 +808,14 @@ void wxMenuItem::DoSetText( const wxString& str )
/* only GTK 1.2 knows about hot keys */
m_hotKey = wxT("");
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
if(*pc == wxT('\t'))
{
pc++;
m_hotKey = pc;
}
#endif
#endif // GTK+ 1.2.0+
}
#if wxUSE_ACCEL
@@ -869,7 +896,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMenu,wxEvtHandler)
void wxMenu::Init()
{
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
m_accel = gtk_accel_group_new();
m_factory = gtk_item_factory_new( GTK_TYPE_MENU, "<main>", m_accel );
m_menu = gtk_item_factory_get_widget( m_factory, "<main>" );
@@ -879,7 +906,7 @@ void wxMenu::Init()
m_owner = (GtkWidget*) NULL;
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
/* Tearoffs are entries, just like separators. So if we want this
menu to be a tear-off one, we just append a tearoff entry
immediately. */
@@ -894,7 +921,7 @@ void wxMenu::Init()
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
//GtkWidget *menuItem = gtk_item_factory_get_widget( m_factory, "<main>/tearoff" );
}
#endif
#endif // GTK+ 1.2.0+
// append the title as the very first entry if we have it
if ( !!m_title )
@@ -917,11 +944,13 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
{
GtkWidget *menuItem;
#if defined(USE_MENU_BITMAPS) || !GTK_CHECK_VERSION(1, 2, 0)
bool appended = FALSE;
#endif
if ( mitem->IsSeparator() )
{
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
GtkItemFactoryEntry entry;
entry.path = (char *)"/sep";
entry.callback = (GtkItemFactoryCallback) NULL;
@@ -939,7 +968,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
}
else if ( mitem->IsSubMenu() )
{
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
/* text has "_" instead of "&" after mitem->SetText() */
wxString text( mitem->GetText() );
@@ -971,6 +1000,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
if ( m_invokingWindow )
wxMenubarSetInvokingWindow(mitem->GetSubMenu(), m_invokingWindow);
}
#ifdef USE_MENU_BITMAPS
else if (mitem->GetBitmap().Ok()) // An item with bitmap
{
wxString text( mitem->GetText() );
@@ -1006,9 +1036,10 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
appended = TRUE; // We've done this, don't do it again
}
#endif // USE_MENU_BITMAPS
else // a normal item
{
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
/* text has "_" instead of "&" after mitem->SetText() */
wxString text( mitem->GetText() );
@@ -1064,7 +1095,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
(gpointer)this );
}
#if GTK_MINOR_VERSION == 0
#if !GTK_CHECK_VERSION(1, 2, 0)
if (!appended)
{
gtk_menu_append( GTK_MENU(m_menu), menuItem );
@@ -1144,7 +1175,7 @@ int wxMenu::FindMenuIdByMenuItem( GtkWidget *menuItem ) const
// helpers
// ----------------------------------------------------------------------------
#if (GTK_MINOR_VERSION > 0) && wxUSE_ACCEL
#if GTK_CHECK_VERSION(1, 2, 0) && wxUSE_ACCEL
static wxString GetHotKey( const wxMenuItem& item )
{
@@ -1225,6 +1256,8 @@ static wxString GetHotKey( const wxMenuItem& item )
// substitute for missing GtkPixmapMenuItem
//-----------------------------------------------------------------------------
#ifdef USE_MENU_BITMAPS
/*
* Copyright (C) 1998, 1999, 2000 Free Software Foundation
* All rights reserved.
@@ -1595,4 +1628,5 @@ changed_have_pixmap_status (GtkPixmapMenuItem *menu_item)
gtk_widget_queue_resize(GTK_WIDGET(menu_item));
}
#endif // USE_MENU_BITMAPS

View File

@@ -21,9 +21,9 @@
#include "wx/intl.h"
#include "wx/log.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/win_gtk.h"
#include <gdk/gdkkeysyms.h>
// ----------------------------------------------------------------------------
@@ -686,7 +686,7 @@ void wxNotebook::ApplyWidgetStyle()
bool wxNotebook::IsOwnGtkWindow( GdkWindow *window )
{
return ((m_widget->window == window) ||
(GTK_NOTEBOOK(m_widget)->panel == window));
(NOTEBOOK_PANEL(m_widget) == window));
}
//-----------------------------------------------------------------------------

View File

@@ -21,8 +21,7 @@
#include "wx/frame.h"
#include "wx/log.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h>
#include "wx/gtk/win_gtk.h"
@@ -427,10 +426,10 @@ int wxRadioBox::FindString( const wxString &s ) const
wxNode *node = m_boxes.First();
while (node)
{
GtkButton *button = GTK_BUTTON( node->Data() );
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
if (s == label->label)
return count;
GtkLabel *label = GTK_LABEL( button->child );
if (s == label->label) return count;
count++;
node = node->Next();
@@ -504,8 +503,7 @@ wxString wxRadioBox::GetString( int n ) const
wxCHECK_MSG( node, wxT(""), wxT("radiobox wrong index") );
GtkButton *button = GTK_BUTTON( node->Data() );
GtkLabel *label = GTK_LABEL( button->child );
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
return wxString( label->label );
}
@@ -527,8 +525,7 @@ void wxRadioBox::SetString( int item, const wxString& label )
wxCHECK_RET( node, wxT("radiobox wrong index") );
GtkButton *button = GTK_BUTTON( node->Data() );
GtkLabel *g_label = GTK_LABEL( button->child );
GtkLabel *g_label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
gtk_label_set( g_label, label.mbc_str() );
}
@@ -542,9 +539,10 @@ bool wxRadioBox::Enable( bool enable )
while (node)
{
GtkButton *button = GTK_BUTTON( node->Data() );
GtkWidget *label = button->child;
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) );
gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
gtk_widget_set_sensitive( label, enable );
gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
node = node->Next();
}
@@ -560,9 +558,10 @@ void wxRadioBox::Enable( int item, bool enable )
wxCHECK_RET( node, wxT("radiobox wrong index") );
GtkButton *button = GTK_BUTTON( node->Data() );
GtkWidget *label = button->child;
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) );
gtk_widget_set_sensitive( GTK_WIDGET(button), enable );
gtk_widget_set_sensitive( label, enable );
gtk_widget_set_sensitive( GTK_WIDGET(label), enable );
}
void wxRadioBox::Show( int item, bool show )
@@ -591,7 +590,8 @@ wxString wxRadioBox::GetStringSelection() const
GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
if (button->active)
{
GtkLabel *label = GTK_LABEL( GTK_BUTTON(button)->child );
GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
return label->label;
}
node = node->Next();
@@ -663,8 +663,7 @@ void wxRadioBox::ApplyWidgetStyle()
GtkWidget *widget = GTK_WIDGET( node->Data() );
gtk_widget_set_style( widget, m_widgetStyle );
GtkButton *button = GTK_BUTTON( node->Data() );
gtk_widget_set_style( button->child, m_widgetStyle );
gtk_widget_set_style( BUTTON_CHILD(node->Data()), m_widgetStyle );
node = node->Next();
}

View File

@@ -18,8 +18,7 @@
#include "wx/radiobut.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -148,8 +147,7 @@ void wxRadioButton::SetLabel( const wxString& label )
wxCHECK_RET( m_widget != NULL, wxT("invalid radiobutton") );
wxControl::SetLabel( label );
GtkButton *bin = GTK_BUTTON( m_widget );
GtkLabel *g_label = GTK_LABEL( bin->child );
GtkLabel *g_label = GTK_LABEL( BUTTON_CHILD(m_widget) );
gtk_label_set( g_label, GetLabel().mbc_str() );
}
@@ -188,7 +186,7 @@ bool wxRadioButton::Enable( bool enable )
if ( !wxControl::Enable( enable ) )
return FALSE;
gtk_widget_set_sensitive( GTK_BUTTON(m_widget)->child, enable );
gtk_widget_set_sensitive( BUTTON_CHILD(m_widget), enable );
return TRUE;
}
@@ -197,12 +195,12 @@ void wxRadioButton::ApplyWidgetStyle()
{
SetWidgetStyle();
gtk_widget_set_style( m_widget, m_widgetStyle );
gtk_widget_set_style( GTK_BUTTON(m_widget)->child, m_widgetStyle );
gtk_widget_set_style( BUTTON_CHILD(m_widget), m_widgetStyle );
}
bool wxRadioButton::IsOwnGtkWindow( GdkWindow *window )
{
return (window == GTK_TOGGLE_BUTTON(m_widget)->event_window);
return window == TOGGLE_BUTTON_EVENT_WIN(m_widget);
}
void wxRadioButton::OnInternalIdle()
@@ -210,14 +208,15 @@ void wxRadioButton::OnInternalIdle()
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;
if (GTK_TOGGLE_BUTTON(m_widget)->event_window && cursor.Ok())
GdkWindow *win = TOGGLE_BUTTON_EVENT_WIN(m_widget);
if ( win && cursor.Ok())
{
/* I now set the cursor the anew in every OnInternalIdle call
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
gdk_window_set_cursor( GTK_TOGGLE_BUTTON(m_widget)->event_window, cursor.GetCursor() );
gdk_window_set_cursor( win, cursor.GetCursor() );
}
UpdateWindowUI();

View File

@@ -20,12 +20,11 @@
// headers
// ----------------------------------------------------------------------------
#include "wx/log.h"
#include "wx/region.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/log.h"
#include "wx/gtk/private.h"
// ----------------------------------------------------------------------------
// wxRegionRefData: private class containing the information about the region
@@ -87,7 +86,7 @@ void wxRegion::InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
m_refData = new wxRegionRefData();
#ifdef __WXGTK20__
M_REGIONDATA->m_region = gdk_region_rectangle( rect );
M_REGIONDATA->m_region = gdk_region_rectangle( &rect );
#else
GdkRegion *reg = gdk_region_new();
M_REGIONDATA->m_region = gdk_region_union_with_rect( reg, &rect );
@@ -170,7 +169,7 @@ bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
{
m_refData = new wxRegionRefData();
#ifdef __WXGTK20__
M_REGIONDATA->m_region = gdk_region_rectangle( rect );
M_REGIONDATA->m_region = gdk_region_rectangle( &rect );
#else
GdkRegion *reg = gdk_region_new();
M_REGIONDATA->m_region = gdk_region_union_with_rect( reg, &rect );
@@ -498,9 +497,9 @@ void wxRIRefData::CreateRects( const wxRegion& region )
if (!gdkregion) return;
#ifdef __WXGTK20__
GdkRectangles *gdkrects = NULL;
GdkRectangle *gdkrects = NULL;
gint numRects = 0;
gdk_region_get_rectangles( gdkregion, &gdkrect, &numRects );
gdk_region_get_rectangles( gdkregion, &gdkrects, &numRects );
m_numRects = numRects;
if (numRects)
@@ -516,8 +515,8 @@ void wxRIRefData::CreateRects( const wxRegion& region )
wr.height = gr.height;
}
}
g_delete( gdkrects ); // delete []
#else
g_free( gdkrects );
#else // GTK+ 1.x
Region r = ((GdkRegionPrivate *)gdkregion)->xregion;
if (r)
{
@@ -536,7 +535,7 @@ void wxRIRefData::CreateRects( const wxRegion& region )
}
}
}
#endif
#endif // GTK+ 2.0/1.x
}
wxRegionIterator::wxRegionIterator()

View File

@@ -22,8 +22,7 @@
#include <math.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -45,7 +44,11 @@ static const float sensitivity = 0.02;
// "value_changed"
//-----------------------------------------------------------------------------
static void gtk_scrollbar_callback( GtkAdjustment *adjust, wxScrollBar *win )
// FIXME: is GtkScrollType really passed to us as 2nd argument?
static void gtk_scrollbar_callback( GtkAdjustment *adjust,
SCROLLBAR_CBACK_ARG
wxScrollBar *win )
{
if (g_isIdle) wxapp_install_idle_handler();
@@ -57,13 +60,7 @@ static void gtk_scrollbar_callback( GtkAdjustment *adjust, wxScrollBar *win )
win->m_oldPos = adjust->value;
GtkRange *range = GTK_RANGE( win->m_widget );
wxEventType command = wxEVT_SCROLL_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLL_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLL_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLL_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLL_PAGEDOWN;
wxEventType command = GtkScrollTypeToWx(GET_SCROLL_TYPE(win->m_widget));
double dvalue = adjust->value;
int value = (int)(dvalue < 0 ? dvalue - 0.5 : dvalue + 0.5);
@@ -93,7 +90,10 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *widget,
// g_blockEventsOnScroll = TRUE; doesn't work in DialogEd
// FIXME: there is no slider field any more, what was meant here?
#ifndef __WXGTK20__
win->m_isScrolling = (gdk_event->window == widget->slider);
#endif
return FALSE;
}
@@ -316,11 +316,14 @@ void wxScrollBar::SetViewLength( int viewLength )
bool wxScrollBar::IsOwnGtkWindow( GdkWindow *window )
{
GtkRange *range = GTK_RANGE(m_widget);
return ( (window == GTK_WIDGET(range)->window) ||
(window == range->trough) ||
(window == range->slider) ||
(window == range->step_forw) ||
(window == range->step_back) );
return ( (window == GTK_WIDGET(range)->window)
#ifndef __WXGTK20__
|| (window == range->trough)
|| (window == range->slider)
|| (window == range->step_forw)
|| (window == range->step_back)
#endif // GTK+ 1.x
);
}
void wxScrollBar::ApplyWidgetStyle()

View File

@@ -31,10 +31,10 @@
#include "wx/utils.h"
#include "wx/dcclient.h"
#include "wx/gtk/scrolwin.h"
#include "wx/scrolwin.h"
#include "wx/panel.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include "wx/gtk/win_gtk.h"
// ----------------------------------------------------------------------------
@@ -72,7 +72,9 @@ extern bool g_isIdle;
// "value_changed" from m_vAdjust
//-----------------------------------------------------------------------------
static void gtk_scrolled_window_vscroll_callback( GtkAdjustment *adjust, wxScrolledWindow *win )
static void gtk_scrolled_window_vscroll_callback( GtkAdjustment *adjust,
SCROLLBAR_CBACK_ARG
wxScrolledWindow *win )
{
if (g_isIdle)
wxapp_install_idle_handler();
@@ -81,14 +83,17 @@ static void gtk_scrolled_window_vscroll_callback( GtkAdjustment *adjust, wxScrol
if (!win->m_hasVMT) return;
win->GtkVScroll( adjust->value );
win->GtkVScroll( adjust->value,
GET_SCROLL_TYPE(GTK_SCROLLED_WINDOW(win->m_widget)->vscrollbar) );
}
//-----------------------------------------------------------------------------
// "value_changed" from m_hAdjust
//-----------------------------------------------------------------------------
static void gtk_scrolled_window_hscroll_callback( GtkAdjustment *adjust, wxScrolledWindow *win )
static void gtk_scrolled_window_hscroll_callback( GtkAdjustment *adjust,
SCROLLBAR_CBACK_ARG
wxScrolledWindow *win )
{
if (g_isIdle)
wxapp_install_idle_handler();
@@ -96,7 +101,8 @@ static void gtk_scrolled_window_hscroll_callback( GtkAdjustment *adjust, wxScrol
if (g_blockEventsOnDrag) return;
if (!win->m_hasVMT) return;
win->GtkHScroll( adjust->value );
win->GtkHScroll( adjust->value,
GET_SCROLL_TYPE(GTK_SCROLLED_WINDOW(win->m_widget)->hscrollbar) );
}
//-----------------------------------------------------------------------------
@@ -111,7 +117,11 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *widget,
wxapp_install_idle_handler();
g_blockEventsOnScroll = TRUE;
// FIXME: there is no slider field any more, what was meant here?
#ifndef __WXGTK20__
win->m_isScrolling = (gdk_event->window == widget->slider);
#endif
return FALSE;
}
@@ -512,7 +522,9 @@ void wxScrolledWindow::Scroll( int x_pos, int y_pos )
}
}
void wxScrolledWindow::GtkVScroll( float value )
// TODO: [VH]Scroll functions should be combined
void wxScrolledWindow::GtkVScroll( float value, unsigned int scroll_type )
{
if (!m_targetWindow)
return;
@@ -525,21 +537,14 @@ void wxScrolledWindow::GtkVScroll( float value )
if (y_pos == m_yScrollPosition)
return;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget);
GtkRange *range = GTK_RANGE(scrolledWindow->vscrollbar);
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
wxEventType command = GtkScrollWinTypeToWx(scroll_type);
wxScrollWinEvent event( command, y_pos, wxVERTICAL );
event.SetEventObject( this );
GetEventHandler()->ProcessEvent( event );
}
void wxScrolledWindow::GtkHScroll( float value )
void wxScrolledWindow::GtkHScroll( float value, unsigned int scroll_type )
{
if (!m_targetWindow)
return;
@@ -552,14 +557,7 @@ void wxScrolledWindow::GtkHScroll( float value )
if (x_pos == m_xScrollPosition)
return;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget);
GtkRange *range = GTK_RANGE(scrolledWindow->hscrollbar);
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
wxEventType command = GtkScrollWinTypeToWx(scroll_type);
wxScrollWinEvent event( command, x_pos, wxHORIZONTAL );
event.SetEventObject( this );

View File

@@ -19,8 +19,7 @@
#include <math.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
@@ -41,7 +40,9 @@ static const float sensitivity = 0.02;
// "value_changed"
//-----------------------------------------------------------------------------
static void gtk_slider_callback( GtkAdjustment *adjust, wxSlider *win )
static void gtk_slider_callback( GtkAdjustment *adjust,
SCROLLBAR_CBACK_ARG
wxSlider *win )
{
if (g_isIdle) wxapp_install_idle_handler();
@@ -53,13 +54,7 @@ static void gtk_slider_callback( GtkAdjustment *adjust, wxSlider *win )
win->m_oldPos = adjust->value;
GtkRange *range = GTK_RANGE( win->m_widget );
wxEventType command = wxEVT_SCROLL_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLL_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLL_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLL_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLL_PAGEDOWN;
wxEventType command = GtkScrollTypeToWx(GET_SCROLL_TYPE(win->m_widget));
double dvalue = adjust->value;
int value = (int)(dvalue < 0 ? dvalue - 0.5 : dvalue + 0.5);
@@ -247,11 +242,14 @@ int wxSlider::GetLineSize() const
bool wxSlider::IsOwnGtkWindow( GdkWindow *window )
{
GtkRange *range = GTK_RANGE(m_widget);
return ( (window == GTK_WIDGET(range)->window) ||
(window == range->trough) ||
(window == range->slider) ||
(window == range->step_forw) ||
(window == range->step_back) );
return ( (window == GTK_WIDGET(range)->window)
#ifndef __WXGTK20__
|| (window == range->trough)
|| (window == range->slider)
|| (window == range->step_forw)
|| (window == range->step_back)
#endif // GTK+ 1.x
);
}
void wxSlider::ApplyWidgetStyle()

View File

@@ -21,8 +21,7 @@
#include <math.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system

View File

@@ -26,9 +26,8 @@
#include "wx/frame.h"
#include "glib.h"
#include "gdk/gdk.h"
#include "gtk/gtk.h"
#include <glib.h>
#include "wx/gtk/private.h"
extern GdkFont *GtkGetDefaultGuiFont();
@@ -222,7 +221,14 @@ bool wxToolBar::Create( wxWindow *parent,
GtkOrientation orient = style & wxTB_VERTICAL ? GTK_ORIENTATION_VERTICAL
: GTK_ORIENTATION_HORIZONTAL;
#ifdef __WXGTK20__
m_toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
gtk_toolbar_set_orientation(m_toolbar, orient);
gtk_toolbar_set_style(m_toolbar, GTK_TOOLBAR_ICONS);
#else
m_toolbar = GTK_TOOLBAR( gtk_toolbar_new( orient, GTK_TOOLBAR_ICONS ) );
#endif
SetToolSeparation(7);
@@ -242,8 +248,11 @@ bool wxToolBar::Create( wxWindow *parent,
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
// FIXME: there is no such function for toolbars in 2.0
#ifndef __WXGTK20__
if (style & wxTB_FLAT)
gtk_toolbar_set_button_relief( GTK_TOOLBAR(m_toolbar), GTK_RELIEF_NONE );
#endif
m_fg = new GdkColor;
@@ -270,8 +279,9 @@ bool wxToolBar::Create( wxWindow *parent,
GTK_TOOLBAR(m_toolbar)->tooltips->tip_window ) );
g_style->bg[GTK_STATE_NORMAL] = *m_bg;
gdk_font_unref( g_style->font );
g_style->font = gdk_font_ref( GtkGetDefaultGuiFont() );
SET_STYLE_FONT(g_style, GtkGetDefaultGuiFont());
gtk_widget_set_style( GTK_TOOLBAR(m_toolbar)->tooltips->tip_window, g_style );
m_parent->DoAddChild( this );
@@ -478,7 +488,11 @@ void wxToolBar::SetMargins( int x, int y )
void wxToolBar::SetToolSeparation( int separation )
{
// FIXME: this function disappeared
#ifndef __WXGTK20__
gtk_toolbar_set_space_size( m_toolbar, separation );
#endif
m_toolSeparation = separation;
}

View File

@@ -23,9 +23,13 @@
#include <ctype.h>
#include <math.h> // for fabs
#include "gdk/gdk.h"
#include "gtk/gtk.h"
#include "gdk/gdkkeysyms.h"
// TODO: reimplement wxTextCtrl using GtkTextView
#ifdef __WXGTK20__
#define GTK_ENABLE_BROKEN // need this to get GtkText at all
#endif // __WXGTK20__
#include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h>
//-----------------------------------------------------------------------------
// idle system
@@ -212,7 +216,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
bool multi_line = (style & wxTE_MULTILINE) != 0;
if (multi_line)
{
#if (GTK_MINOR_VERSION > 2)
#ifdef __WXGTK13__
/* a multi-line edit control: create a vertical scrollbar by default and
horizontal if requested */
bool bHasHScrollbar = (style & wxHSCROLL) != 0;
@@ -234,7 +238,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
/* always wrap words */
gtk_text_set_word_wrap( GTK_TEXT(m_text), TRUE );
#if (GTK_MINOR_VERSION > 2)
#ifdef __WXGTK13__
/* put the horizontal scrollbar in the lower left hand corner */
if (bHasHScrollbar)
{
@@ -296,7 +300,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
{
gint tmp = 0;
#if GTK_MINOR_VERSION == 0
#if !GTK_CHECK_VERSION(1, 2, 0)
// if we don't realize it, GTK 1.0.6 dies with a SIGSEGV in
// gtk_editable_insert_text()
gtk_widget_realize(m_text);
@@ -312,8 +316,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
if (multi_line)
{
/* bring editable's cursor uptodate. bug in GTK. */
GTK_EDITABLE(m_text)->current_pos = gtk_text_get_point( GTK_TEXT(m_text) );
SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
}
}
@@ -446,7 +449,7 @@ void wxTextCtrl::WriteText( const wxString &text )
if ( m_windowStyle & wxTE_MULTILINE )
{
// After cursor movements, gtk_text_get_point() is wrong by one.
gtk_text_set_point( GTK_TEXT(m_text), GTK_EDITABLE(m_text)->current_pos );
gtk_text_set_point( GTK_TEXT(m_text), GET_EDITABLE_POS(m_text) );
// if we have any special style, use it
if ( !m_defaultStyle.IsDefault() )
@@ -457,24 +460,24 @@ void wxTextCtrl::WriteText( const wxString &text )
}
else // no style
{
gint len = GTK_EDITABLE(m_text)->current_pos;
gint len = GET_EDITABLE_POS(m_text);
gtk_editable_insert_text( GTK_EDITABLE(m_text), txt, txtlen, &len );
}
// Bring editable's cursor back uptodate.
GTK_EDITABLE(m_text)->current_pos = gtk_text_get_point( GTK_TEXT(m_text) );
SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
}
else // single line
{
// This moves the cursor pos to behind the inserted text.
gint len = GTK_EDITABLE(m_text)->current_pos;
gint len = GET_EDITABLE_POS(m_text);
gtk_editable_insert_text( GTK_EDITABLE(m_text), txt, txtlen, &len );
// Bring editable's cursor uptodate.
GTK_EDITABLE(m_text)->current_pos += text.Len();
len += text.Len();
// Bring entry's cursor uptodate.
gtk_entry_set_position( GTK_ENTRY(m_text), GTK_EDITABLE(m_text)->current_pos );
gtk_entry_set_position( GTK_ENTRY(m_text), len );
}
m_modified = TRUE;
@@ -643,7 +646,7 @@ void wxTextCtrl::SetInsertionPoint( long pos )
/* bring editable's cursor uptodate. another bug in GTK. */
GTK_EDITABLE(m_text)->current_pos = gtk_text_get_point( GTK_TEXT(m_text) );
SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
}
else
{
@@ -651,7 +654,7 @@ void wxTextCtrl::SetInsertionPoint( long pos )
/* bring editable's cursor uptodate. bug in GTK. */
GTK_EDITABLE(m_text)->current_pos = (guint32)pos;
SET_EDITABLE_POS(m_text, (guint32)pos);
}
}
@@ -810,7 +813,7 @@ long wxTextCtrl::GetInsertionPoint() const
{
wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") );
return (long) GTK_EDITABLE(m_text)->current_pos;
return (long) GET_EDITABLE_POS(m_text);
}
long wxTextCtrl::GetLastPosition() const
@@ -855,33 +858,21 @@ void wxTextCtrl::Cut()
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
#if (GTK_MINOR_VERSION > 0)
gtk_editable_cut_clipboard( GTK_EDITABLE(m_text) );
#else
gtk_editable_cut_clipboard( GTK_EDITABLE(m_text), 0 );
#endif
gtk_editable_cut_clipboard( GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG );
}
void wxTextCtrl::Copy()
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
#if (GTK_MINOR_VERSION > 0)
gtk_editable_copy_clipboard( GTK_EDITABLE(m_text) );
#else
gtk_editable_copy_clipboard( GTK_EDITABLE(m_text), 0 );
#endif
gtk_editable_copy_clipboard( GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG );
}
void wxTextCtrl::Paste()
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
#if (GTK_MINOR_VERSION > 0)
gtk_editable_paste_clipboard( GTK_EDITABLE(m_text) );
#else
gtk_editable_paste_clipboard( GTK_EDITABLE(m_text), 0 );
#endif
gtk_editable_paste_clipboard( GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG );
}
// Undo/redo
@@ -917,21 +908,27 @@ void wxTextCtrl::GetSelection(long* fromOut, long* toOut) const
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
long from, to;
gint from, to;
#ifdef __WXGTK20__
if ( !gtk_editable_get_selection_bounds(GTK_EDITABLE(m_text), &from, &to) )
#else
if ( !(GTK_EDITABLE(m_text)->has_selection) )
#endif
{
from =
to = GetInsertionPoint();
}
else // got selection
{
#ifndef __WXGTK20__
from = (long) GTK_EDITABLE(m_text)->selection_start_pos;
to = (long) GTK_EDITABLE(m_text)->selection_end_pos;
#endif
if ( from > to )
{
// exchange them to be compatible with wxMSW
long tmp = from;
gint tmp = from;
from = to;
to = tmp;
}
@@ -947,7 +944,11 @@ bool wxTextCtrl::IsEditable() const
{
wxCHECK_MSG( m_text != NULL, FALSE, wxT("invalid text ctrl") );
#ifdef __WXGTK20__
return gtk_editable_get_editable(GTK_EDITABLE(m_text));
#else
return GTK_EDITABLE(m_text)->editable;
#endif
}
bool wxTextCtrl::IsModified() const

View File

@@ -15,8 +15,7 @@
#if wxUSE_TOGGLEBTN
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
extern void wxapp_install_idle_handler();
extern bool g_isIdle;
@@ -125,8 +124,7 @@ void wxToggleButton::SetLabel(const wxString& label)
wxControl::SetLabel(label);
gtk_label_set(GTK_LABEL(GTK_BUTTON(m_widget)->child),
GetLabel().mbc_str());
gtk_label_set(GTK_LABEL(BUTTON_CHILD(m_widget)), GetLabel().mbc_str());
}
bool wxToggleButton::Enable(bool enable /*=TRUE*/)
@@ -134,7 +132,7 @@ bool wxToggleButton::Enable(bool enable /*=TRUE*/)
if (!wxControl::Enable(enable))
return FALSE;
gtk_widget_set_sensitive(GTK_BUTTON(m_widget)->child, enable);
gtk_widget_set_sensitive(BUTTON_CHILD(m_widget), enable);
return TRUE;
}
@@ -143,12 +141,12 @@ void wxToggleButton::ApplyWidgetStyle()
{
SetWidgetStyle();
gtk_widget_set_style(m_widget, m_widgetStyle);
gtk_widget_set_style(GTK_BUTTON(m_widget)->child, m_widgetStyle);
gtk_widget_set_style(BUTTON_CHILD(m_widget), m_widgetStyle);
}
bool wxToggleButton::IsOwnGtkWindow(GdkWindow *window)
{
return (window == GTK_TOGGLE_BUTTON(m_widget)->event_window);
return window == TOGGLE_BUTTON_EVENT_WIN(m_widget);
}
void wxToggleButton::OnInternalIdle()
@@ -158,14 +156,15 @@ void wxToggleButton::OnInternalIdle()
if (g_globalCursor.Ok())
cursor = g_globalCursor;
if (GTK_TOGGLE_BUTTON(m_widget)->event_window && cursor.Ok()) {
GdkWindow *win = TOGGLE_BUTTON_EVENT_WIN(m_widget);
if ( win && cursor.Ok() )
{
/* I now set the cursor the anew in every OnInternalIdle call
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
gdk_window_set_cursor(GTK_TOGGLE_BUTTON(m_widget)->event_window,
cursor.GetCursor());
gdk_window_set_cursor(win, cursor.GetCursor());
}
UpdateWindowUI();

View File

@@ -18,8 +18,7 @@
#include "wx/window.h"
#include "wx/tooltip.h"
#include "gtk/gtk.h"
#include "gdk/gdk.h"
#include "wx/gtk/private.h"
extern GdkFont *GtkGetDefaultGuiFont();
@@ -67,7 +66,7 @@ void wxToolTip::Apply( wxWindow *win )
ss_bg.blue = 50000;
gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_bg );
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
gtk_tooltips_force_window( ss_tooltips );
GtkStyle *g_style =
@@ -76,11 +75,11 @@ void wxToolTip::Apply( wxWindow *win )
g_style->fg[GTK_STATE_NORMAL] = ss_fg;
g_style->bg[GTK_STATE_NORMAL] = ss_bg;
gdk_font_unref( g_style->font );
g_style->font = gdk_font_ref( GtkGetDefaultGuiFont() );
SET_STYLE_FONT( g_style, GtkGetDefaultGuiFont() );
gtk_widget_set_style( ss_tooltips->tip_window, g_style );
#else
#else // GTK+ 1.0
gtk_tooltips_set_colors( ss_tooltips, &ss_bg, &ss_fg );
#endif
}

View File

@@ -376,7 +376,14 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
win_type = GTK_WINDOW_POPUP;
if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)
{
// there is no more GTK_WINDOW_DIALOG in 2.0
#ifdef __WXGTK20__
win_type = GTK_WINDOW_TOPLEVEL;
#else
win_type = GTK_WINDOW_DIALOG;
#endif
}
m_widget = gtk_window_new( win_type );

View File

@@ -50,8 +50,10 @@ static void gtk_pizza_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_pizza_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
#ifndef __WXGTK20__
static void gtk_pizza_draw (GtkWidget *widget,
GdkRectangle *area);
#endif /* __WXGTK20__ */
static gint gtk_pizza_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_pizza_add (GtkContainer *container,
@@ -146,7 +148,9 @@ gtk_pizza_class_init (GtkPizzaClass *klass)
widget_class->unrealize = gtk_pizza_unrealize;
widget_class->size_request = gtk_pizza_size_request;
widget_class->size_allocate = gtk_pizza_size_allocate;
#ifndef __WXGTK20__
widget_class->draw = gtk_pizza_draw;
#endif
widget_class->expose_event = gtk_pizza_expose;
container_class->add = gtk_pizza_add;
@@ -160,7 +164,6 @@ gtk_pizza_class_init (GtkPizzaClass *klass)
widget_class->set_scroll_adjustments_signal =
gtk_signal_new ("set_scroll_adjustments",
GTK_RUN_LAST,
#ifdef __WXGTK20__
GTK_CLASS_TYPE(object_class),
#else
@@ -708,6 +711,8 @@ gtk_pizza_size_allocate (GtkWidget *widget,
}
}
#ifndef __WXGTK20__
static void
gtk_pizza_draw (GtkWidget *widget,
GdkRectangle *area)
@@ -744,6 +749,8 @@ gtk_pizza_draw (GtkWidget *widget,
}
}
#endif /* __WXGTK20__ */
static gint
gtk_pizza_expose (GtkWidget *widget,
GdkEventExpose *event)
@@ -1048,6 +1055,7 @@ gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy)
{
GtkWidget *widget;
XEvent xevent;
XID win;
gint x,y,w,h,border;
@@ -1142,10 +1150,12 @@ gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy)
gtk_pizza_position_children (pizza);
gdk_flush();
win = GDK_WINDOW_XWINDOW (pizza->bin_window);
while (XCheckIfEvent(GDK_WINDOW_XDISPLAY (pizza->bin_window),
&xevent,
gtk_pizza_expose_predicate,
(XPointer)&GDK_WINDOW_XWINDOW (pizza->bin_window)))
(XPointer)&win))
{
GdkEvent event;
GtkWidget *event_widget;

View File

@@ -54,8 +54,7 @@
#include <math.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include <gdk/gdkprivate.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h>
@@ -65,6 +64,12 @@
#include "wx/gtk/win_gtk.h"
#ifdef __WXGTK20__
#define SET_CONTAINER_FOCUS(w, d) gtk_widget_child_focus((w), (d))
#else
#define SET_CONTAINER_FOCUS(w, d) gtk_container_focus(GTK_CONTAINER(w), (d))
#endif
//-----------------------------------------------------------------------------
// documentation on internals
//-----------------------------------------------------------------------------
@@ -1857,7 +1862,9 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_
// "value_changed" from m_vAdjust
//-----------------------------------------------------------------------------
static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win )
static void gtk_window_vscroll_callback( GtkAdjustment *adjust,
SCROLLBAR_CBACK_ARG
wxWindowGTK *win )
{
DEBUG_MAIN_THREAD
@@ -1873,14 +1880,7 @@ static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win
win->m_oldVerticalPos = adjust->value;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
GtkRange *range = GTK_RANGE( scrolledWindow->vscrollbar );
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(win->m_widget));
int value = (int)(adjust->value+0.5);
@@ -1893,7 +1893,9 @@ static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win
// "value_changed" from m_hAdjust
//-----------------------------------------------------------------------------
static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win )
static void gtk_window_hscroll_callback( GtkAdjustment *adjust,
SCROLLBAR_CBACK_ARG
wxWindowGTK *win )
{
DEBUG_MAIN_THREAD
@@ -1906,17 +1908,10 @@ static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win
float diff = adjust->value - win->m_oldHorizontalPos;
if (fabs(diff) < 0.2) return;
wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(win->m_widget));
win->m_oldHorizontalPos = adjust->value;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
GtkRange *range = GTK_RANGE( scrolledWindow->hscrollbar );
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
int value = (int)(adjust->value+0.5);
wxScrollWinEvent event( command, value, wxHORIZONTAL );
@@ -1939,7 +1934,11 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *widget,
g_blockEventsOnScroll = TRUE;
// FIXME: there is no 'slider' field in GTK+ 2.0 any more
#ifndef __WXGTK20__
win->m_isScrolling = (gdk_event->window == widget->slider);
#endif
return FALSE;
}
@@ -2341,7 +2340,8 @@ bool wxWindowGTK::Create( wxWindow *parent,
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
#ifndef __WXUNIVERSAL__
#if (GTK_MINOR_VERSION > 0)
#if GTK_CHECK_VERSION(1, 2, 0)
GtkPizza *pizza = GTK_PIZZA(m_wxwindow);
if (HasFlag(wxRAISED_BORDER))
@@ -2360,7 +2360,7 @@ bool wxWindowGTK::Create( wxWindow *parent,
{
gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_NONE );
}
#else // GTK_MINOR_VERSION == 0
#else // GTK+ 1.0
GtkViewport *viewport = GTK_VIEWPORT(scrolledWindow->viewport);
if (HasFlag(wxRAISED_BORDER))
@@ -2375,17 +2375,18 @@ bool wxWindowGTK::Create( wxWindow *parent,
{
gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE );
}
#endif // GTK_MINOR_VERSION
#endif // GTK+ > 1.0/<= 1.0
#endif // __WXUNIVERSAL__
GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
m_acceptsFocus = TRUE;
#if (GTK_MINOR_VERSION == 0)
#if !GTK_CHECK_VERSION(1, 2, 0)
// shut the viewport up
gtk_viewport_set_hadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
gtk_viewport_set_vadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
#endif // GTK_MINOR_VERSION == 0
#endif // GTK+ 1.0
// I _really_ don't want scrollbars in the beginning
m_vAdjust->lower = 0.0;
@@ -3167,7 +3168,7 @@ void wxWindowGTK::SetFocus()
}
else if (GTK_IS_CONTAINER(m_widget))
{
gtk_container_focus( GTK_CONTAINER(m_widget), GTK_DIR_TAB_FORWARD );
SET_CONTAINER_FOCUS( m_widget, GTK_DIR_TAB_FORWARD );
}
else
{
@@ -3541,10 +3542,9 @@ GtkStyle *wxWindowGTK::GetWidgetStyle()
if (m_widgetStyle)
{
GtkStyle *remake = gtk_style_copy( m_widgetStyle );
#ifdef __WXGTK20__
/* FIXME: is this necessary? */
_G_TYPE_IGC(remake, GtkObjectClass) = _G_TYPE_IGC(m_widgetStyle, GtkObjectClass);
#else
// FIXME: no more klass in 2.0
#ifndef __WXGTK20__
remake->klass = m_widgetStyle->klass;
#endif
@@ -3559,10 +3559,9 @@ GtkStyle *wxWindowGTK::GetWidgetStyle()
def = gtk_widget_get_default_style();
m_widgetStyle = gtk_style_copy( def );
#ifdef __WXGTK20__
/* FIXME: is this necessary? */
_G_TYPE_IGC(m_widgetStyle, GtkObjectClass) = _G_TYPE_IGC(def, GtkObjectClass);
#else
// FIXME: no more klass in 2.0
#ifndef __WXGTK20__
m_widgetStyle->klass = def->klass;
#endif
}
@@ -3590,8 +3589,7 @@ void wxWindowGTK::SetWidgetStyle()
if (m_font != wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ))
{
gdk_font_unref( style->font );
style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
SET_STYLE_FONT(style, m_font.GetInternalFont( 1.0 ));
}
if (m_foregroundColour.Ok())
@@ -3701,6 +3699,9 @@ static gint gs_pop_y = 0;
extern "C" void wxPopupMenuPositionCallback( GtkMenu *menu,
gint *x, gint *y,
#ifdef __WXGTK20__
gboolean * WXUNUSED(whatever),
#endif
gpointer WXUNUSED(user_data) )
{
// ensure that the menu appears entirely on screen