Mercurial > dwindows
changeset 3:67a643a734d9
Import
author | ktk@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 03 Jul 2001 07:50:39 +0000 |
parents | 36c5f0ce3fbe |
children | e248987dfabf |
files | Makefile.in acinclude.m4 aclocal.m4 ci.c ci.def compat.c compat.h config.h.in configure configure.in dirent.h dll/dw.dll dll/dwcompat.dll dw.def dw.h dwcompat.def dwcompatw.def dww.def gtk/dw.c lib/dw.lib lib/dwcompat.lib makefile.vac makefile.vc os2/dirent.c os2/dw.c readme win/dirent.c win/dw.c winmain.c |
diffstat | 29 files changed, 25634 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile.in Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,84 @@ +CC = @CC@ +CCFLAGS = @CFLAGS@ -g -O2 -Wall -D__UNIX__ -DBUILD_DLL -DDW_RESOURCES +LFLAGS = @LIBS@ +INCPATH = -I../../include -I. +DESTDIR = ./lib/ +MLFLAGS = -L$(DESTDIR) +TARGET = dw +SRCS = gtk/dw.c +OBJECTS = gtk/dw.o +SRCS2 = compat.c +OBJECTS2= compat.o +TARGET2 = dwcompat +VER_MAJ = 1 +VER_MIN = 0 + +.SUFFIXES: .c .h + +.c.o: + $(CC) -c $(CCFLAGS) $(INCPATH) -o $@ $< + + +# Link flags shared objects +SYSCONF_LFLAGS_SHOBJ = -shared + +# Linking shared libraries +# - Build the $(TARGET) library, eg. lib$(TARGET).so.0.0 +# - Place target in $(DESTDIR) - which has a trailing / +# - Usually needs to incorporate $(VER_MAJ) and $(VER_MIN) +# +SYSCONF_LINK_SHLIB = gcc +SYSCONF_LINK_TARGET_SHARED = lib$(TARGET).so.$(VER_MAJ).$(VER_MIN) +SYSCONF_LINK_LIB_SHARED = $(SYSCONF_LINK_SHLIB) -shared -Wl,-soname,lib$(TARGET).so.$(VER_MAJ) \ + -o $(SYSCONF_LINK_TARGET_SHARED) \ + $(OBJECTS) $(LFLAGS); \ + mv $(SYSCONF_LINK_TARGET_SHARED) $(DESTDIR); \ + cd $(DESTDIR); \ + rm -f lib$(TARGET).so lib$(TARGET).so.$(VER_MAJ); \ + ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so; \ + ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ) + +SYSCONF_LINK_TARGET_SHARED2 = lib$(TARGET2).so.$(VER_MAJ).$(VER_MIN) +SYSCONF_LINK_LIB_SHARED2 = $(SYSCONF_LINK_SHLIB) -shared -Wl,-soname,lib$(TARGET2).so.$(VER_MAJ) \ + -o $(SYSCONF_LINK_TARGET_SHARED2) \ + $(OBJECTS2) $(LFLAGS); \ + mv $(SYSCONF_LINK_TARGET_SHARED2) $(DESTDIR); \ + cd $(DESTDIR); \ + rm -f lib$(TARGET2).so lib$(TARGET2).so.$(VER_MAJ); \ + ln -s $(SYSCONF_LINK_TARGET_SHARED2) lib$(TARGET2).so; \ + ln -s $(SYSCONF_LINK_TARGET_SHARED2) lib$(TARGET2).so.$(VER_MAJ) + + +# Linking static libraries +# - Build the $(TARGET) library, eg. lib$(TARGET).a +# - Place target in $(DESTDIR) - which has a trailing / +# +SYSCONF_AR = ar cqs +SYSCONF_LINK_TARGET_STATIC = lib$(TARGET).a +SYSCONF_LINK_LIB_STATIC = rm -f $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) ; \ + $(SYSCONF_AR) $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) $(OBJECTS) + + + +####### Build rules + +SYSCONF_LINK_TARGET = $(SYSCONF_LINK_TARGET_SHARED) +SYSCONF_LINK_LIB = $(SYSCONF_LINK_LIB_SHARED) + +SYSCONF_LINK_TARGET2 = $(SYSCONF_LINK_TARGET_SHARED2) +SYSCONF_LINK_LIB2 = $(SYSCONF_LINK_LIB_SHARED2) + +all: $(SYSCONF_LINK_TARGET) $(SYSCONF_LINK_TARGET2) + +clean: + rm -f *.so + rm -f *.o + rm -f *~ + rm -f *.a + rm -f gtk/*.o + +$(SYSCONF_LINK_TARGET2): $(OBJECTS2) + $(SYSCONF_LINK_LIB2) + +$(SYSCONF_LINK_TARGET): $(OBJECTS) + $(SYSCONF_LINK_LIB)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/acinclude.m4 Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,1127 @@ +dnl aclocal.m4 generated automatically by aclocal 1.4a + +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. + +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. + +# Configure paths for GLIB +# Owen Taylor 97-11-3 + +dnl AM_PATH_GLIB([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]]) +dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if "gmodule" or +dnl gthread is specified in MODULES, pass to glib-config +dnl +AC_DEFUN(AM_PATH_GLIB, +[dnl +dnl Get the cflags and libraries from the glib-config script +dnl +AC_ARG_WITH(glib-prefix,[ --with-glib-prefix=PFX Prefix where GLIB is installed (optional)], + glib_config_prefix="$withval", glib_config_prefix="") +AC_ARG_WITH(glib-exec-prefix,[ --with-glib-exec-prefix=PFX Exec prefix where GLIB is installed (optional)], + glib_config_exec_prefix="$withval", glib_config_exec_prefix="") +AC_ARG_ENABLE(glibtest, [ --disable-glibtest Do not try to compile and run a test GLIB program], + , enable_glibtest=yes) + + if test x$glib_config_exec_prefix != x ; then + glib_config_args="$glib_config_args --exec-prefix=$glib_config_exec_prefix" + if test x${GLIB_CONFIG+set} != xset ; then + GLIB_CONFIG=$glib_config_exec_prefix/bin/glib-config + fi + fi + if test x$glib_config_prefix != x ; then + glib_config_args="$glib_config_args --prefix=$glib_config_prefix" + if test x${GLIB_CONFIG+set} != xset ; then + GLIB_CONFIG=$glib_config_prefix/bin/glib-config + fi + fi + + for module in . $4 + do + case "$module" in + gmodule) + glib_config_args="$glib_config_args gmodule" + ;; + gthread) + glib_config_args="$glib_config_args gthread" + ;; + esac + done + + AC_PATH_PROG(GLIB_CONFIG, glib-config, no) + min_glib_version=ifelse([$1], ,1.2.0,$1) + AC_MSG_CHECKING(for GLIB - version >= $min_glib_version) + no_glib="" + if test "$GLIB_CONFIG" = "no" ; then + no_glib=yes + else + GLIB_CFLAGS=`$GLIB_CONFIG $glib_config_args --cflags` + GLIB_LIBS=`$GLIB_CONFIG $glib_config_args --libs` + glib_config_major_version=`$GLIB_CONFIG $glib_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + glib_config_minor_version=`$GLIB_CONFIG $glib_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + glib_config_micro_version=`$GLIB_CONFIG $glib_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_glibtest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GLIB_CFLAGS" + LIBS="$GLIB_LIBS $LIBS" +dnl +dnl Now check if the installed GLIB is sufficiently new. (Also sanity +dnl checks the results of glib-config to some extent +dnl + rm -f conf.glibtest + AC_TRY_RUN([ +#include <glib.h> +#include <stdio.h> +#include <stdlib.h> + +int +main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.glibtest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_glib_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_glib_version"); + exit(1); + } + + if ((glib_major_version != $glib_config_major_version) || + (glib_minor_version != $glib_config_minor_version) || + (glib_micro_version != $glib_config_micro_version)) + { + printf("\n*** 'glib-config --version' returned %d.%d.%d, but GLIB (%d.%d.%d)\n", + $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version, + glib_major_version, glib_minor_version, glib_micro_version); + printf ("*** was found! If glib-config was correct, then it is best\n"); + printf ("*** to remove the old version of GLIB. 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 glib-config was wrong, set the environment variable GLIB_CONFIG\n"); + printf("*** to point to the correct copy of glib-config, and remove the file config.cache\n"); + printf("*** before re-running configure\n"); + } + else if ((glib_major_version != GLIB_MAJOR_VERSION) || + (glib_minor_version != GLIB_MINOR_VERSION) || + (glib_micro_version != GLIB_MICRO_VERSION)) + { + printf("*** GLIB header files (version %d.%d.%d) do not match\n", + GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION); + printf("*** library (version %d.%d.%d)\n", + glib_major_version, glib_minor_version, glib_micro_version); + } + else + { + if ((glib_major_version > major) || + ((glib_major_version == major) && (glib_minor_version > minor)) || + ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** An old version of GLIB (%d.%d.%d) was found.\n", + glib_major_version, glib_minor_version, glib_micro_version); + printf("*** You need a version of GLIB newer than %d.%d.%d. The latest version of\n", + major, minor, micro); + printf("*** GLIB 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 glib-config shell script is\n"); + printf("*** being found. The easiest way to fix this is to remove the old version\n"); + printf("*** of GLIB, but you can also set the GLIB_CONFIG environment to point to the\n"); + printf("*** correct copy of glib-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + } + return 1; +} +],, no_glib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_glib" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$GLIB_CONFIG" = "no" ; then + echo "*** The glib-config script installed by GLIB could not be found" + echo "*** If GLIB was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the GLIB_CONFIG environment variable to the" + echo "*** full path to glib-config." + else + if test -f conf.glibtest ; then + : + else + echo "*** Could not run GLIB test program, checking why..." + CFLAGS="$CFLAGS $GLIB_CFLAGS" + LIBS="$LIBS $GLIB_LIBS" + AC_TRY_LINK([ +#include <glib.h> +#include <stdio.h> +], [ return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding GLIB or finding the wrong" + echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means GLIB was incorrectly installed" + echo "*** or that you have moved GLIB since it was installed. In the latter case, you" + echo "*** may want to edit the glib-config script: $GLIB_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GLIB_CFLAGS="" + GLIB_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(GLIB_CFLAGS) + AC_SUBST(GLIB_LIBS) + rm -f conf.glibtest +]) + +# Configure paths for GTK+ +# Owen Taylor 97-11-3 + +dnl AM_PATH_GTK([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, +[dnl +dnl Get the cflags and libraries from the gtk-config 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+set} != xset ; then + GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config + 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+set} != xset ; then + GTK_CONFIG=$gtk_config_prefix/bin/gtk-config + fi + fi + + AC_PATH_PROG(GTK_CONFIG, gtk-config, no) + min_gtk_version=ifelse([$1], ,1.2.0,$1) + AC_MSG_CHECKING(for GTK - version >= $min_gtk_version) + no_gtk="" + if test "$GTK_CONFIG" = "no" ; then + no_gtk=yes + else + GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags` + GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs` + gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + gtk_config_micro_version=`$GTK_CONFIG $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 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, µ) != 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 --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 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 was wrong, set the environment variable GTK_CONFIG\n"); + printf("*** to point to the correct copy of gtk-config, 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 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 environment to point to the\n"); + printf("*** correct copy of gtk-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + } + return 1; +} +],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_gtk" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$GTK_CONFIG" = "no" ; then + echo "*** The gtk-config 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 environment variable to the" + echo "*** full path to gtk-config." + 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 "*** 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 script: $GTK_CONFIG" ]) + 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 +]) + +# Configure paths for IMLIB +# David Walluck 99-9-18 +# Frank Belew 98-8-31 +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor + +dnl AM_PATH_IMLIB([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for IMLIB, and define IMLIB_CFLAGS and IMLIB_LIBS +dnl +AC_DEFUN(AM_PATH_IMLIB, +[dnl +dnl Get the cflags and libraries from the imlib-config script +dnl +AC_ARG_WITH(imlib-prefix,[ --with-imlib-prefix=PFX Prefix where IMLIB is installed (optional)], + imlib_prefix="$withval", imlib_prefix="") +AC_ARG_WITH(imlib-exec-prefix,[ --with-imlib-exec-prefix=PFX Exec prefix where IMLIB is installed (optional)], + imlib_exec_prefix="$withval", imlib_exec_prefix="") +AC_ARG_ENABLE(imlibtest, [ --disable-imlibtest Do not try to compile and run a test IMLIB program], + , enable_imlibtest=yes) + + if test x$imlib_exec_prefix != x ; then + imlib_args="$imlib_args --exec-prefix=$imlib_exec_prefix" + if test x${IMLIB_CONFIG+set} != xset ; then + IMLIB_CONFIG=$imlib_exec_prefix/bin/imlib-config + fi + fi + if test x$imlib_prefix != x ; then + imlib_args="$imlib_args --prefix=$imlib_prefix" + if test x${IMLIB_CONFIG+set} != xset ; then + IMLIB_CONFIG=$imlib_prefix/bin/imlib-config + fi + fi + + AC_PATH_PROG(IMLIB_CONFIG, imlib-config, no) + min_imlib_version=ifelse([$1], ,1.9.4,$1) + AC_MSG_CHECKING(for IMLIB - version >= $min_imlib_version) + no_imlib="" + if test "$IMLIB_CONFIG" = "no" ; then + no_imlib=yes + else + IMLIB_CFLAGS=`$IMLIB_CONFIG $imlibconf_args --cflags` + IMLIB_LIBS=`$IMLIB_CONFIG $imlibconf_args --libs` + + imlib_major_version=`$IMLIB_CONFIG $imlib_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + imlib_minor_version=`$IMLIB_CONFIG $imlib_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + imlib_micro_version=`$IMLIB_CONFIG $imlib_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_imlibtest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $IMLIB_CFLAGS" + LIBS="$LIBS $IMLIB_LIBS" +dnl +dnl Now check if the installed IMLIB is sufficiently new. (Also sanity +dnl checks the results of imlib-config to some extent +dnl + rm -f conf.imlibtest + AC_TRY_RUN([ +#include <stdio.h> +#include <stdlib.h> +#include <Imlib.h> + +int main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.imlibtest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_imlib_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_imlib_version"); + exit(1); + } + + if (($imlib_major_version > major) || + (($imlib_major_version == major) && ($imlib_minor_version > minor)) || + (($imlib_major_version == major) && ($imlib_minor_version == minor) && + ($imlib_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'imlib-config --version' returned %d.%d.%d, but the minimum version\n", $imlib_major_version, $imlib_minor_version, $imlib_micro_version); + printf("*** of IMLIB required is %d.%d.%d. If imlib-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If imlib-config was wrong, set the environment variable IMLIB_CONFIG\n"); + printf("*** to point to the correct copy of imlib-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +],, no_imlib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_imlib" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$IMLIB_CONFIG" = "no" ; then + echo "*** The imlib-config script installed by IMLIB could not be found" + echo "*** If IMLIB was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the IMLIB_CONFIG environment variable to the" + echo "*** full path to imlib-config." + else + if test -f conf.imlibtest ; then + : + else + echo "*** Could not run IMLIB test program, checking why..." + CFLAGS="$CFLAGS $IMLIB_CFLAGS" + LIBS="$LIBS $IMLIB_LIBS" + AC_TRY_LINK([ +#include <stdio.h> +#include <Imlib.h> +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding IMLIB or finding the wrong" + echo "*** version of IMLIB. If it is not finding IMLIB, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means IMLIB was incorrectly installed" + echo "*** or that you have moved IMLIB since it was installed. In the latter case, you" + echo "*** may want to edit the imlib-config script: $IMLIB_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + IMLIB_CFLAGS="" + IMLIB_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(IMLIB_CFLAGS) + AC_SUBST(IMLIB_LIBS) + rm -f conf.imlibtest +]) + +# Check for gdk-imlib +AC_DEFUN(AM_PATH_GDK_IMLIB, +[dnl +dnl Get the cflags and libraries from the imlib-config script +dnl +AC_ARG_WITH(imlib-prefix,[ --with-imlib-prefix=PFX Prefix where IMLIB is installed (optional)], + imlib_prefix="$withval", imlib_prefix="") +AC_ARG_WITH(imlib-exec-prefix,[ --with-imlib-exec-prefix=PFX Exec prefix where IMLIB is installed (optional)], + imlib_exec_prefix="$withval", imlib_exec_prefix="") +AC_ARG_ENABLE(imlibtest, [ --disable-imlibtest Do not try to compile and run a test IMLIB program], + , enable_imlibtest=yes) + + if test x$imlib_exec_prefix != x ; then + imlib_args="$imlib_args --exec-prefix=$imlib_exec_prefix" + if test x${IMLIB_CONFIG+set} != xset ; then + IMLIB_CONFIG=$imlib_exec_prefix/bin/imlib-config + fi + fi + if test x$imlib_prefix != x ; then + imlib_args="$imlib_args --prefix=$imlib_prefix" + if test x${IMLIB_CONFIG+set} != xset ; then + IMLIB_CONFIG=$imlib_prefix/bin/imlib-config + fi + fi + + AC_PATH_PROG(IMLIB_CONFIG, imlib-config, no) + min_imlib_version=ifelse([$1], ,1.9.4,$1) + AC_MSG_CHECKING(for IMLIB - version >= $min_imlib_version) + no_imlib="" + if test "$IMLIB_CONFIG" = "no" ; then + no_imlib=yes + else + GDK_IMLIB_CFLAGS=`$IMLIB_CONFIG $imlibconf_args --cflags-gdk` + GDK_IMLIB_LIBS=`$IMLIB_CONFIG $imlibconf_args --libs-gdk` + + imlib_major_version=`$IMLIB_CONFIG $imlib_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + imlib_minor_version=`$IMLIB_CONFIG $imlib_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + imlib_micro_version=`$IMLIB_CONFIG $imlib_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_imlibtest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GDK_IMLIB_CFLAGS" + LIBS="$LIBS $GDK_IMLIB_LIBS" +dnl +dnl Now check if the installed IMLIB is sufficiently new. (Also sanity +dnl checks the results of imlib-config to some extent +dnl + rm -f conf.imlibtest + AC_TRY_RUN([ +#include <stdio.h> +#include <stdlib.h> +#include <gdk_imlib.h> + +int main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.gdkimlibtest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_imlib_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_imlib_version"); + exit(1); + } + + if (($imlib_major_version > major) || + (($imlib_major_version == major) && ($imlib_minor_version > minor)) || + (($imlib_major_version == major) && ($imlib_minor_version == minor) && + ($imlib_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'imlib-config --version' returned %d.%d.%d, but the minimum version\n", $imlib_major_version, $imlib_minor_version, $imlib_micro_version); + printf("*** of IMLIB required is %d.%d.%d. If imlib-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If imlib-config was wrong, set the environment variable IMLIB_CONFIG\n"); + printf("*** to point to the correct copy of imlib-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +],, no_imlib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_imlib" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$IMLIB_CONFIG" = "no" ; then + echo "*** The imlib-config script installed by IMLIB could not be found" + echo "*** If IMLIB was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the IMLIB_CONFIG environment variable to the" + echo "*** full path to imlib-config." + else + if test -f conf.gdkimlibtest ; then + : + else + echo "*** Could not run IMLIB test program, checking why..." + CFLAGS="$CFLAGS $GDK_IMLIB_CFLAGS" + LIBS="$LIBS $GDK_IMLIB_LIBS" + AC_TRY_LINK([ +#include <stdio.h> +#include <gdk_imlib.h> +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding IMLIB or finding the wrong" + echo "*** version of IMLIB. If it is not finding IMLIB, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means IMLIB was incorrectly installed" + echo "*** or that you have moved IMLIB since it was installed. In the latter case, you" + echo "*** may want to edit the imlib-config script: $IMLIB_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GDK_IMLIB_CFLAGS="" + GDK_IMLIB_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(GDK_IMLIB_CFLAGS) + AC_SUBST(GDK_IMLIB_LIBS) + rm -f conf.gdkimlibtest +]) + +# Configure paths for ESD +# David Walluck 99-9-20 +# Manish Singh 98-9-30 +# stolen back from Frank Belew +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor + +dnl AM_PATH_ESD([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for ESD, and define ESD_CFLAGS and ESD_LIBS +dnl +AC_DEFUN(AM_PATH_ESD, +[dnl +dnl Get the cflags and libraries from the esd-config script +dnl +AC_ARG_WITH(esd-prefix,[ --with-esd-prefix=PFX Prefix where ESD is installed (optional)], + esd_prefix="$withval", esd_prefix="") +AC_ARG_WITH(esd-exec-prefix,[ --with-esd-exec-prefix=PFX Exec prefix where ESD is installed (optional)], + esd_exec_prefix="$withval", esd_exec_prefix="") +AC_ARG_ENABLE(esdtest, [ --disable-esdtest Do not try to compile and run a test ESD program], + , enable_esdtest=yes) + + if test x$esd_exec_prefix != x ; then + esd_args="$esd_args --exec-prefix=$esd_exec_prefix" + if test x${ESD_CONFIG+set} != xset ; then + ESD_CONFIG=$esd_exec_prefix/bin/esd-config + fi + fi + if test x$esd_prefix != x ; then + esd_args="$esd_args --prefix=$esd_prefix" + if test x${ESD_CONFIG+set} != xset ; then + ESD_CONFIG=$esd_prefix/bin/esd-config + fi + fi + + AC_PATH_PROG(ESD_CONFIG, esd-config, no) + min_esd_version=ifelse([$1], ,0.2.5,$1) + AC_MSG_CHECKING(for ESD - version >= $min_esd_version) + no_esd="" + if test "$ESD_CONFIG" = "no" ; then + no_esd=yes + else + ESD_CFLAGS=`$ESD_CONFIG $esdconf_args --cflags` + ESD_LIBS=`$ESD_CONFIG $esdconf_args --libs` + + esd_major_version=`$ESD_CONFIG $esd_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + esd_minor_version=`$ESD_CONFIG $esd_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + esd_micro_version=`$ESD_CONFIG $esd_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_esdtest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $ESD_CFLAGS" + LIBS="$LIBS $ESD_LIBS" +dnl +dnl Now check if the installed ESD is sufficiently new. (Also sanity +dnl checks the results of esd-config to some extent +dnl + rm -f conf.esdtest + AC_TRY_RUN([ +#include <stdio.h> +#include <stdlib.h> +#include <esd.h> + +int main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.esdtest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_esd_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_esd_version"); + exit(1); + } + + if (($esd_major_version > major) || + (($esd_major_version == major) && ($esd_minor_version > minor)) || + (($esd_major_version == major) && ($esd_minor_version == minor) && ($esd_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'esd-config --version' returned %d.%d.%d, but the minimum version\n", $esd_major_version, $esd_minor_version, $esd_micro_version); + printf("*** of ESD required is %d.%d.%d. If esd-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If esd-config was wrong, set the environment variable ESD_CONFIG\n"); + printf("*** to point to the correct copy of esd-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +],, no_esd=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_esd" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$ESD_CONFIG" = "no" ; then + echo "*** The esd-config script installed by ESD could not be found" + echo "*** If ESD was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the ESD_CONFIG environment variable to the" + echo "*** full path to esd-config." + else + if test -f conf.esdtest ; then + : + else + echo "*** Could not run ESD test program, checking why..." + CFLAGS="$CFLAGS $ESD_CFLAGS" + LIBS="$LIBS $ESD_LIBS" + AC_TRY_LINK([ +#include <stdio.h> +#include <esd.h> +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding ESD or finding the wrong" + echo "*** version of ESD. If it is not finding ESD, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means ESD was incorrectly installed" + echo "*** or that you have moved ESD since it was installed. In the latter case, you" + echo "*** may want to edit the esd-config script: $ESD_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + ESD_CFLAGS="" + ESD_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(ESD_CFLAGS) + AC_SUBST(ESD_LIBS) + rm -f conf.esdtest +]) + +# Configure paths for AUDIOFILE +# Bertrand Guiheneuf 98-10-21 +# stolen from esd.m4 in esound : +# Manish Singh 98-9-30 +# stolen back from Frank Belew +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor + +dnl AM_PATH_AUDIOFILE([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for AUDIOFILE, and define AUDIOFILE_CFLAGS and AUDIOFILE_LIBS +dnl +AC_DEFUN(AM_PATH_AUDIOFILE, +[dnl +dnl Get the cflags and libraries from the audiofile-config script +dnl +AC_ARG_WITH(audiofile-prefix,[ --with-audiofile-prefix=PFX Prefix where AUDIOFILE is installed (optional)], + audiofile_prefix="$withval", audiofile_prefix="") +AC_ARG_WITH(audiofile-exec-prefix,[ --with-audiofile-exec-prefix=PFX Exec prefix where AUDIOFILE is installed + (optional)], + audiofile_exec_prefix="$withval", audiofile_exec_prefix="") +AC_ARG_ENABLE(audiofiletest, [ --disable-audiofiletest Do not try to compile and run a test AUDIOFILE program], + , enable_audiofiletest=yes) + + if test x$audiofile_exec_prefix != x ; then + audiofile_args="$audiofile_args --exec-prefix=$audiofile_exec_prefix" + if test x${AUDIOFILE_CONFIG+set} != xset ; then + AUDIOFILE_CONFIG=$audiofile_exec_prefix/bin/audiofile-config + fi + fi + if test x$audiofile_prefix != x ; then + audiofile_args="$audiofile_args --prefix=$audiofile_prefix" + if test x${AUDIOFILE_CONFIG+set} != xset ; then + AUDIOFILE_CONFIG=$audiofile_prefix/bin/audiofile-config + fi + fi + + AC_PATH_PROG(AUDIOFILE_CONFIG, audiofile-config, no) + min_audiofile_version=ifelse([$1], ,0.1.5,$1) + AC_MSG_CHECKING(for AUDIOFILE - version >= $min_audiofile_version) + no_audiofile="" + if test "$AUDIOFILE_CONFIG" = "no" ; then + no_audiofile=yes + else + AUDIOFILE_LIBS=`$AUDIOFILE_CONFIG $audiofileconf_args --libs` + AUDIOFILE_CFLAGS=`$AUDIOFILE_CONFIG $audiofileconf_args --cflags` + audiofile_major_version=`$AUDIOFILE_CONFIG $audiofile_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + audiofile_minor_version=`$AUDIOFILE_CONFIG $audiofile_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + audiofile_micro_version=`$AUDIOFILE_CONFIG $audiofile_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_audiofiletest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $AUDIOFILE_CFLAGS" + LIBS="$LIBS $AUDIOFILE_LIBS" +dnl +dnl Now check if the installed AUDIOFILE is sufficiently new. (Also sanity +dnl checks the results of audiofile-config to some extent +dnl + rm -f conf.audiofiletest + AC_TRY_RUN([ +#include <stdio.h> +#include <stdlib.h> +#include <audiofile.h> + +int main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.audiofiletest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_audiofile_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_audiofile_version"); + exit(1); + } + + if (($audiofile_major_version > major) || + (($audiofile_major_version == major) && ($audiofile_minor_version > minor)) || + (($audiofile_major_version == major) && ($audiofile_minor_version == minor) && ($audiofile_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'audiofile-config --version' returned %d.%d.%d, but the minimum version\n", $audiofile_major_version, $audiofile_minor_version, $audiofile_micro_version); + printf("*** of AUDIOFILE required is %d.%d.%d. If audiofile-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If audiofile-config was wrong, set the environment variable AUDIOFILE_CONFIG\n"); + printf("*** to point to the correct copy of audiofile-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +],, no_audiofile=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_audiofile" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$AUDIOFILE_CONFIG" = "no" ; then + echo "*** The audiofile-config script installed by AUDIOFILE could not be found" + echo "*** If AUDIOFILE was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the AUDIOFILE_CONFIG environment variable to the" + echo "*** full path to audiofile-config." + else + if test -f conf.audiofiletest ; then + : + else + echo "*** Could not run AUDIOFILE test program, checking why..." + CFLAGS="$CFLAGS $AUDIOFILE_CFLAGS" + LIBS="$LIBS $AUDIOFILE_LIBS" + AC_TRY_LINK([ +#include <stdio.h> +#include <audiofile.h> +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding AUDIOFILE or finding the wrong" + echo "*** version of AUDIOFILE. If it is not finding AUDIOFILE, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means AUDIOFILE was incorrectly installed" + echo "*** or that you have moved AUDIOFILE since it was installed. In the latter case, you" + echo "*** may want to edit the audiofile-config script: $AUDIOFILE_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + AUDIOFILE_CFLAGS="" + AUDIOFILE_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(AUDIOFILE_CFLAGS) + AC_SUBST(AUDIOFILE_LIBS) + rm -f conf.audiofiletest +]) +# Configure paths for GNOME +# David Walluck 99-9-24 + +dnl AM_PATH_GNOME([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for GNOME, and define GNOME_CFLAGS and GNOME_LIBS +dnl +AC_DEFUN(AM_PATH_GNOME, +[dnl +dnl Get the cflags and libraries from the gnome-config script +dnl +AC_ARG_WITH(gnome-prefix,[ --with-gnome-prefix=PFX Prefix where GNOME is installed (optional)], + gnome_prefix="$withval", gnome_prefix="") +AC_ARG_WITH(gnome-exec-prefix,[ --with-gnome-exec-prefix=PFX Exec prefix where GNOME is installed (optional)], + gnome_exec_prefix="$withval", gnome_exec_prefix="") +AC_ARG_ENABLE(gnometest, [ --disable-gnometest Do not try to compile and run a test GNOME program], + , enable_gnometest=yes) + + if test x$gnome_exec_prefix != x ; then + gnome_args="$gnome_args --exec-prefix=$gnome_exec_prefix" + if test x${GNOME_CONFIG+set} != xset ; then + GNOME_CONFIG=$gnome_exec_prefix/bin/gnome-config + fi + fi + if test x$gnome_prefix != x ; then + gnome_args="$gnome_args --prefix=$gnome_prefix" + if test x${GNOME_CONFIG+set} != xset ; then + GNOME_CONFIG=$gnome_prefix/bin/gnome-config + fi + fi + + AC_PATH_PROG(GNOME_CONFIG, gnome-config, no) + min_gnome_version=ifelse([$1], ,0.2.7,$1) + AC_MSG_CHECKING(for GNOME - version >= $min_gnome_version) + no_gnome="" + if test "$GNOME_CONFIG" = "no" ; then + no_gnome=yes + else + GNOME_CFLAGS=`$GNOME_CONFIG $gnomeconf_args gnome --cflags` + GNOME_LIBS=`$GNOME_CONFIG $gnomeconf_args gnome --libs` + + gnome_major_version=`$GNOME_CONFIG $gnome_args --version | \ + sed 's/gnome-libs //' | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + gnome_minor_version=`$GNOME_CONFIG $gnome_args --version | \ + sed 's/gnome-libs //' | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + gnome_micro_version=`$GNOME_CONFIG $gnome_config_args --version | \ + sed 's/gnome-libs //' | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_gnometest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GNOME_CFLAGS" + LIBS="$LIBS $GNOME_LIBS" +dnl +dnl Now check if the installed GNOME is sufficiently new. (Also sanity +dnl checks the results of gnome-config to some extent +dnl + rm -f conf.gnometest + AC_TRY_RUN([ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <gnome.h> + +int main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.gnometest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_gnome_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_gnome_version"); + exit(1); + } + + if (($gnome_major_version > major) || + (($gnome_major_version == major) && ($gnome_minor_version > minor)) || + (($gnome_major_version == major) && ($gnome_minor_version == minor) && ($gnome_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'gnome-config --version' returned %d.%d.%d, but the minimum version\n", $gnome_major_version, $gnome_minor_version, $gnome_micro_version); + printf("*** of GNOME required is %d.%d.%d. If gnome-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If gnome-config was wrong, set the environment variable GNOME_CONFIG\n"); + printf("*** to point to the correct copy of gnome-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +],, no_gnome=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_gnome" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$GNOME_CONFIG" = "no" ; then + echo "*** The gnome-config script installed by GNOME could not be found" + echo "*** If GNOME was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the GNOME_CONFIG environment variable to the" + echo "*** full path to gnome-config." + else + if test -f conf.gnometest ; then + : + else + echo "*** Could not run GNOME test program, checking why..." + CFLAGS="$CFLAGS $GNOME_CFLAGS" + LIBS="$LIBS $GNOME_LIBS" + AC_TRY_LINK([ +#include <stdio.h> +#include <gnome.h> +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding GNOME or finding the wrong" + echo "*** version of GNOME. If it is not finding GNOME, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means GNOME was incorrectly installed" + echo "*** or that you have moved GNOME since it was installed. In the latter case, you" + echo "*** may want to edit the gnome-config script: $GNOME_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GNOME_CFLAGS="" + GNOME_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(GNOME_CFLAGS) + AC_SUBST(GNOME_LIBS) + rm -f conf.gnometest +])
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/aclocal.m4 Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,1140 @@ +dnl aclocal.m4 generated automatically by aclocal 1.4a + +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. + +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. + +dnl aclocal.m4 generated automatically by aclocal 1.4a + +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. + +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. + +# Configure paths for GLIB +# Owen Taylor 97-11-3 + +dnl AM_PATH_GLIB([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]]) +dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if "gmodule" or +dnl gthread is specified in MODULES, pass to glib-config +dnl +AC_DEFUN(AM_PATH_GLIB, +[dnl +dnl Get the cflags and libraries from the glib-config script +dnl +AC_ARG_WITH(glib-prefix,[ --with-glib-prefix=PFX Prefix where GLIB is installed (optional)], + glib_config_prefix="$withval", glib_config_prefix="") +AC_ARG_WITH(glib-exec-prefix,[ --with-glib-exec-prefix=PFX Exec prefix where GLIB is installed (optional)], + glib_config_exec_prefix="$withval", glib_config_exec_prefix="") +AC_ARG_ENABLE(glibtest, [ --disable-glibtest Do not try to compile and run a test GLIB program], + , enable_glibtest=yes) + + if test x$glib_config_exec_prefix != x ; then + glib_config_args="$glib_config_args --exec-prefix=$glib_config_exec_prefix" + if test x${GLIB_CONFIG+set} != xset ; then + GLIB_CONFIG=$glib_config_exec_prefix/bin/glib-config + fi + fi + if test x$glib_config_prefix != x ; then + glib_config_args="$glib_config_args --prefix=$glib_config_prefix" + if test x${GLIB_CONFIG+set} != xset ; then + GLIB_CONFIG=$glib_config_prefix/bin/glib-config + fi + fi + + for module in . $4 + do + case "$module" in + gmodule) + glib_config_args="$glib_config_args gmodule" + ;; + gthread) + glib_config_args="$glib_config_args gthread" + ;; + esac + done + + AC_PATH_PROG(GLIB_CONFIG, glib-config, no) + min_glib_version=ifelse([$1], ,1.2.0,$1) + AC_MSG_CHECKING(for GLIB - version >= $min_glib_version) + no_glib="" + if test "$GLIB_CONFIG" = "no" ; then + no_glib=yes + else + GLIB_CFLAGS=`$GLIB_CONFIG $glib_config_args --cflags` + GLIB_LIBS=`$GLIB_CONFIG $glib_config_args --libs` + glib_config_major_version=`$GLIB_CONFIG $glib_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + glib_config_minor_version=`$GLIB_CONFIG $glib_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + glib_config_micro_version=`$GLIB_CONFIG $glib_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_glibtest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GLIB_CFLAGS" + LIBS="$GLIB_LIBS $LIBS" +dnl +dnl Now check if the installed GLIB is sufficiently new. (Also sanity +dnl checks the results of glib-config to some extent +dnl + rm -f conf.glibtest + AC_TRY_RUN([ +#include <glib.h> +#include <stdio.h> +#include <stdlib.h> + +int +main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.glibtest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_glib_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_glib_version"); + exit(1); + } + + if ((glib_major_version != $glib_config_major_version) || + (glib_minor_version != $glib_config_minor_version) || + (glib_micro_version != $glib_config_micro_version)) + { + printf("\n*** 'glib-config --version' returned %d.%d.%d, but GLIB (%d.%d.%d)\n", + $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version, + glib_major_version, glib_minor_version, glib_micro_version); + printf ("*** was found! If glib-config was correct, then it is best\n"); + printf ("*** to remove the old version of GLIB. 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 glib-config was wrong, set the environment variable GLIB_CONFIG\n"); + printf("*** to point to the correct copy of glib-config, and remove the file config.cache\n"); + printf("*** before re-running configure\n"); + } + else if ((glib_major_version != GLIB_MAJOR_VERSION) || + (glib_minor_version != GLIB_MINOR_VERSION) || + (glib_micro_version != GLIB_MICRO_VERSION)) + { + printf("*** GLIB header files (version %d.%d.%d) do not match\n", + GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION); + printf("*** library (version %d.%d.%d)\n", + glib_major_version, glib_minor_version, glib_micro_version); + } + else + { + if ((glib_major_version > major) || + ((glib_major_version == major) && (glib_minor_version > minor)) || + ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** An old version of GLIB (%d.%d.%d) was found.\n", + glib_major_version, glib_minor_version, glib_micro_version); + printf("*** You need a version of GLIB newer than %d.%d.%d. The latest version of\n", + major, minor, micro); + printf("*** GLIB 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 glib-config shell script is\n"); + printf("*** being found. The easiest way to fix this is to remove the old version\n"); + printf("*** of GLIB, but you can also set the GLIB_CONFIG environment to point to the\n"); + printf("*** correct copy of glib-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + } + return 1; +} +],, no_glib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_glib" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$GLIB_CONFIG" = "no" ; then + echo "*** The glib-config script installed by GLIB could not be found" + echo "*** If GLIB was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the GLIB_CONFIG environment variable to the" + echo "*** full path to glib-config." + else + if test -f conf.glibtest ; then + : + else + echo "*** Could not run GLIB test program, checking why..." + CFLAGS="$CFLAGS $GLIB_CFLAGS" + LIBS="$LIBS $GLIB_LIBS" + AC_TRY_LINK([ +#include <glib.h> +#include <stdio.h> +], [ return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding GLIB or finding the wrong" + echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means GLIB was incorrectly installed" + echo "*** or that you have moved GLIB since it was installed. In the latter case, you" + echo "*** may want to edit the glib-config script: $GLIB_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GLIB_CFLAGS="" + GLIB_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(GLIB_CFLAGS) + AC_SUBST(GLIB_LIBS) + rm -f conf.glibtest +]) + +# Configure paths for GTK+ +# Owen Taylor 97-11-3 + +dnl AM_PATH_GTK([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, +[dnl +dnl Get the cflags and libraries from the gtk-config 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+set} != xset ; then + GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config + 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+set} != xset ; then + GTK_CONFIG=$gtk_config_prefix/bin/gtk-config + fi + fi + + AC_PATH_PROG(GTK_CONFIG, gtk-config, no) + min_gtk_version=ifelse([$1], ,1.2.0,$1) + AC_MSG_CHECKING(for GTK - version >= $min_gtk_version) + no_gtk="" + if test "$GTK_CONFIG" = "no" ; then + no_gtk=yes + else + GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags` + GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs` + gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + gtk_config_micro_version=`$GTK_CONFIG $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 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, µ) != 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 --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 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 was wrong, set the environment variable GTK_CONFIG\n"); + printf("*** to point to the correct copy of gtk-config, 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 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 environment to point to the\n"); + printf("*** correct copy of gtk-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + } + return 1; +} +],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_gtk" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$GTK_CONFIG" = "no" ; then + echo "*** The gtk-config 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 environment variable to the" + echo "*** full path to gtk-config." + 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 "*** 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 script: $GTK_CONFIG" ]) + 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 +]) + +# Configure paths for IMLIB +# David Walluck 99-9-18 +# Frank Belew 98-8-31 +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor + +dnl AM_PATH_IMLIB([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for IMLIB, and define IMLIB_CFLAGS and IMLIB_LIBS +dnl +AC_DEFUN(AM_PATH_IMLIB, +[dnl +dnl Get the cflags and libraries from the imlib-config script +dnl +AC_ARG_WITH(imlib-prefix,[ --with-imlib-prefix=PFX Prefix where IMLIB is installed (optional)], + imlib_prefix="$withval", imlib_prefix="") +AC_ARG_WITH(imlib-exec-prefix,[ --with-imlib-exec-prefix=PFX Exec prefix where IMLIB is installed (optional)], + imlib_exec_prefix="$withval", imlib_exec_prefix="") +AC_ARG_ENABLE(imlibtest, [ --disable-imlibtest Do not try to compile and run a test IMLIB program], + , enable_imlibtest=yes) + + if test x$imlib_exec_prefix != x ; then + imlib_args="$imlib_args --exec-prefix=$imlib_exec_prefix" + if test x${IMLIB_CONFIG+set} != xset ; then + IMLIB_CONFIG=$imlib_exec_prefix/bin/imlib-config + fi + fi + if test x$imlib_prefix != x ; then + imlib_args="$imlib_args --prefix=$imlib_prefix" + if test x${IMLIB_CONFIG+set} != xset ; then + IMLIB_CONFIG=$imlib_prefix/bin/imlib-config + fi + fi + + AC_PATH_PROG(IMLIB_CONFIG, imlib-config, no) + min_imlib_version=ifelse([$1], ,1.9.4,$1) + AC_MSG_CHECKING(for IMLIB - version >= $min_imlib_version) + no_imlib="" + if test "$IMLIB_CONFIG" = "no" ; then + no_imlib=yes + else + IMLIB_CFLAGS=`$IMLIB_CONFIG $imlibconf_args --cflags` + IMLIB_LIBS=`$IMLIB_CONFIG $imlibconf_args --libs` + + imlib_major_version=`$IMLIB_CONFIG $imlib_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + imlib_minor_version=`$IMLIB_CONFIG $imlib_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + imlib_micro_version=`$IMLIB_CONFIG $imlib_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_imlibtest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $IMLIB_CFLAGS" + LIBS="$LIBS $IMLIB_LIBS" +dnl +dnl Now check if the installed IMLIB is sufficiently new. (Also sanity +dnl checks the results of imlib-config to some extent +dnl + rm -f conf.imlibtest + AC_TRY_RUN([ +#include <stdio.h> +#include <stdlib.h> +#include <Imlib.h> + +int main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.imlibtest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_imlib_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_imlib_version"); + exit(1); + } + + if (($imlib_major_version > major) || + (($imlib_major_version == major) && ($imlib_minor_version > minor)) || + (($imlib_major_version == major) && ($imlib_minor_version == minor) && + ($imlib_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'imlib-config --version' returned %d.%d.%d, but the minimum version\n", $imlib_major_version, $imlib_minor_version, $imlib_micro_version); + printf("*** of IMLIB required is %d.%d.%d. If imlib-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If imlib-config was wrong, set the environment variable IMLIB_CONFIG\n"); + printf("*** to point to the correct copy of imlib-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +],, no_imlib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_imlib" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$IMLIB_CONFIG" = "no" ; then + echo "*** The imlib-config script installed by IMLIB could not be found" + echo "*** If IMLIB was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the IMLIB_CONFIG environment variable to the" + echo "*** full path to imlib-config." + else + if test -f conf.imlibtest ; then + : + else + echo "*** Could not run IMLIB test program, checking why..." + CFLAGS="$CFLAGS $IMLIB_CFLAGS" + LIBS="$LIBS $IMLIB_LIBS" + AC_TRY_LINK([ +#include <stdio.h> +#include <Imlib.h> +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding IMLIB or finding the wrong" + echo "*** version of IMLIB. If it is not finding IMLIB, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means IMLIB was incorrectly installed" + echo "*** or that you have moved IMLIB since it was installed. In the latter case, you" + echo "*** may want to edit the imlib-config script: $IMLIB_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + IMLIB_CFLAGS="" + IMLIB_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(IMLIB_CFLAGS) + AC_SUBST(IMLIB_LIBS) + rm -f conf.imlibtest +]) + +# Check for gdk-imlib +AC_DEFUN(AM_PATH_GDK_IMLIB, +[dnl +dnl Get the cflags and libraries from the imlib-config script +dnl +AC_ARG_WITH(imlib-prefix,[ --with-imlib-prefix=PFX Prefix where IMLIB is installed (optional)], + imlib_prefix="$withval", imlib_prefix="") +AC_ARG_WITH(imlib-exec-prefix,[ --with-imlib-exec-prefix=PFX Exec prefix where IMLIB is installed (optional)], + imlib_exec_prefix="$withval", imlib_exec_prefix="") +AC_ARG_ENABLE(imlibtest, [ --disable-imlibtest Do not try to compile and run a test IMLIB program], + , enable_imlibtest=yes) + + if test x$imlib_exec_prefix != x ; then + imlib_args="$imlib_args --exec-prefix=$imlib_exec_prefix" + if test x${IMLIB_CONFIG+set} != xset ; then + IMLIB_CONFIG=$imlib_exec_prefix/bin/imlib-config + fi + fi + if test x$imlib_prefix != x ; then + imlib_args="$imlib_args --prefix=$imlib_prefix" + if test x${IMLIB_CONFIG+set} != xset ; then + IMLIB_CONFIG=$imlib_prefix/bin/imlib-config + fi + fi + + AC_PATH_PROG(IMLIB_CONFIG, imlib-config, no) + min_imlib_version=ifelse([$1], ,1.9.4,$1) + AC_MSG_CHECKING(for IMLIB - version >= $min_imlib_version) + no_imlib="" + if test "$IMLIB_CONFIG" = "no" ; then + no_imlib=yes + else + GDK_IMLIB_CFLAGS=`$IMLIB_CONFIG $imlibconf_args --cflags-gdk` + GDK_IMLIB_LIBS=`$IMLIB_CONFIG $imlibconf_args --libs-gdk` + + imlib_major_version=`$IMLIB_CONFIG $imlib_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + imlib_minor_version=`$IMLIB_CONFIG $imlib_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + imlib_micro_version=`$IMLIB_CONFIG $imlib_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_imlibtest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GDK_IMLIB_CFLAGS" + LIBS="$LIBS $GDK_IMLIB_LIBS" +dnl +dnl Now check if the installed IMLIB is sufficiently new. (Also sanity +dnl checks the results of imlib-config to some extent +dnl + rm -f conf.imlibtest + AC_TRY_RUN([ +#include <stdio.h> +#include <stdlib.h> +#include <gdk_imlib.h> + +int main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.gdkimlibtest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_imlib_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_imlib_version"); + exit(1); + } + + if (($imlib_major_version > major) || + (($imlib_major_version == major) && ($imlib_minor_version > minor)) || + (($imlib_major_version == major) && ($imlib_minor_version == minor) && + ($imlib_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'imlib-config --version' returned %d.%d.%d, but the minimum version\n", $imlib_major_version, $imlib_minor_version, $imlib_micro_version); + printf("*** of IMLIB required is %d.%d.%d. If imlib-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If imlib-config was wrong, set the environment variable IMLIB_CONFIG\n"); + printf("*** to point to the correct copy of imlib-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +],, no_imlib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_imlib" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$IMLIB_CONFIG" = "no" ; then + echo "*** The imlib-config script installed by IMLIB could not be found" + echo "*** If IMLIB was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the IMLIB_CONFIG environment variable to the" + echo "*** full path to imlib-config." + else + if test -f conf.gdkimlibtest ; then + : + else + echo "*** Could not run IMLIB test program, checking why..." + CFLAGS="$CFLAGS $GDK_IMLIB_CFLAGS" + LIBS="$LIBS $GDK_IMLIB_LIBS" + AC_TRY_LINK([ +#include <stdio.h> +#include <gdk_imlib.h> +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding IMLIB or finding the wrong" + echo "*** version of IMLIB. If it is not finding IMLIB, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means IMLIB was incorrectly installed" + echo "*** or that you have moved IMLIB since it was installed. In the latter case, you" + echo "*** may want to edit the imlib-config script: $IMLIB_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GDK_IMLIB_CFLAGS="" + GDK_IMLIB_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(GDK_IMLIB_CFLAGS) + AC_SUBST(GDK_IMLIB_LIBS) + rm -f conf.gdkimlibtest +]) + +# Configure paths for ESD +# David Walluck 99-9-20 +# Manish Singh 98-9-30 +# stolen back from Frank Belew +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor + +dnl AM_PATH_ESD([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for ESD, and define ESD_CFLAGS and ESD_LIBS +dnl +AC_DEFUN(AM_PATH_ESD, +[dnl +dnl Get the cflags and libraries from the esd-config script +dnl +AC_ARG_WITH(esd-prefix,[ --with-esd-prefix=PFX Prefix where ESD is installed (optional)], + esd_prefix="$withval", esd_prefix="") +AC_ARG_WITH(esd-exec-prefix,[ --with-esd-exec-prefix=PFX Exec prefix where ESD is installed (optional)], + esd_exec_prefix="$withval", esd_exec_prefix="") +AC_ARG_ENABLE(esdtest, [ --disable-esdtest Do not try to compile and run a test ESD program], + , enable_esdtest=yes) + + if test x$esd_exec_prefix != x ; then + esd_args="$esd_args --exec-prefix=$esd_exec_prefix" + if test x${ESD_CONFIG+set} != xset ; then + ESD_CONFIG=$esd_exec_prefix/bin/esd-config + fi + fi + if test x$esd_prefix != x ; then + esd_args="$esd_args --prefix=$esd_prefix" + if test x${ESD_CONFIG+set} != xset ; then + ESD_CONFIG=$esd_prefix/bin/esd-config + fi + fi + + AC_PATH_PROG(ESD_CONFIG, esd-config, no) + min_esd_version=ifelse([$1], ,0.2.5,$1) + AC_MSG_CHECKING(for ESD - version >= $min_esd_version) + no_esd="" + if test "$ESD_CONFIG" = "no" ; then + no_esd=yes + else + ESD_CFLAGS=`$ESD_CONFIG $esdconf_args --cflags` + ESD_LIBS=`$ESD_CONFIG $esdconf_args --libs` + + esd_major_version=`$ESD_CONFIG $esd_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + esd_minor_version=`$ESD_CONFIG $esd_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + esd_micro_version=`$ESD_CONFIG $esd_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_esdtest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $ESD_CFLAGS" + LIBS="$LIBS $ESD_LIBS" +dnl +dnl Now check if the installed ESD is sufficiently new. (Also sanity +dnl checks the results of esd-config to some extent +dnl + rm -f conf.esdtest + AC_TRY_RUN([ +#include <stdio.h> +#include <stdlib.h> +#include <esd.h> + +int main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.esdtest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_esd_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_esd_version"); + exit(1); + } + + if (($esd_major_version > major) || + (($esd_major_version == major) && ($esd_minor_version > minor)) || + (($esd_major_version == major) && ($esd_minor_version == minor) && ($esd_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'esd-config --version' returned %d.%d.%d, but the minimum version\n", $esd_major_version, $esd_minor_version, $esd_micro_version); + printf("*** of ESD required is %d.%d.%d. If esd-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If esd-config was wrong, set the environment variable ESD_CONFIG\n"); + printf("*** to point to the correct copy of esd-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +],, no_esd=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_esd" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$ESD_CONFIG" = "no" ; then + echo "*** The esd-config script installed by ESD could not be found" + echo "*** If ESD was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the ESD_CONFIG environment variable to the" + echo "*** full path to esd-config." + else + if test -f conf.esdtest ; then + : + else + echo "*** Could not run ESD test program, checking why..." + CFLAGS="$CFLAGS $ESD_CFLAGS" + LIBS="$LIBS $ESD_LIBS" + AC_TRY_LINK([ +#include <stdio.h> +#include <esd.h> +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding ESD or finding the wrong" + echo "*** version of ESD. If it is not finding ESD, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means ESD was incorrectly installed" + echo "*** or that you have moved ESD since it was installed. In the latter case, you" + echo "*** may want to edit the esd-config script: $ESD_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + ESD_CFLAGS="" + ESD_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(ESD_CFLAGS) + AC_SUBST(ESD_LIBS) + rm -f conf.esdtest +]) + +# Configure paths for AUDIOFILE +# Bertrand Guiheneuf 98-10-21 +# stolen from esd.m4 in esound : +# Manish Singh 98-9-30 +# stolen back from Frank Belew +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor + +dnl AM_PATH_AUDIOFILE([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for AUDIOFILE, and define AUDIOFILE_CFLAGS and AUDIOFILE_LIBS +dnl +AC_DEFUN(AM_PATH_AUDIOFILE, +[dnl +dnl Get the cflags and libraries from the audiofile-config script +dnl +AC_ARG_WITH(audiofile-prefix,[ --with-audiofile-prefix=PFX Prefix where AUDIOFILE is installed (optional)], + audiofile_prefix="$withval", audiofile_prefix="") +AC_ARG_WITH(audiofile-exec-prefix,[ --with-audiofile-exec-prefix=PFX Exec prefix where AUDIOFILE is installed + (optional)], + audiofile_exec_prefix="$withval", audiofile_exec_prefix="") +AC_ARG_ENABLE(audiofiletest, [ --disable-audiofiletest Do not try to compile and run a test AUDIOFILE program], + , enable_audiofiletest=yes) + + if test x$audiofile_exec_prefix != x ; then + audiofile_args="$audiofile_args --exec-prefix=$audiofile_exec_prefix" + if test x${AUDIOFILE_CONFIG+set} != xset ; then + AUDIOFILE_CONFIG=$audiofile_exec_prefix/bin/audiofile-config + fi + fi + if test x$audiofile_prefix != x ; then + audiofile_args="$audiofile_args --prefix=$audiofile_prefix" + if test x${AUDIOFILE_CONFIG+set} != xset ; then + AUDIOFILE_CONFIG=$audiofile_prefix/bin/audiofile-config + fi + fi + + AC_PATH_PROG(AUDIOFILE_CONFIG, audiofile-config, no) + min_audiofile_version=ifelse([$1], ,0.1.5,$1) + AC_MSG_CHECKING(for AUDIOFILE - version >= $min_audiofile_version) + no_audiofile="" + if test "$AUDIOFILE_CONFIG" = "no" ; then + no_audiofile=yes + else + AUDIOFILE_LIBS=`$AUDIOFILE_CONFIG $audiofileconf_args --libs` + AUDIOFILE_CFLAGS=`$AUDIOFILE_CONFIG $audiofileconf_args --cflags` + audiofile_major_version=`$AUDIOFILE_CONFIG $audiofile_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + audiofile_minor_version=`$AUDIOFILE_CONFIG $audiofile_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + audiofile_micro_version=`$AUDIOFILE_CONFIG $audiofile_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_audiofiletest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $AUDIOFILE_CFLAGS" + LIBS="$LIBS $AUDIOFILE_LIBS" +dnl +dnl Now check if the installed AUDIOFILE is sufficiently new. (Also sanity +dnl checks the results of audiofile-config to some extent +dnl + rm -f conf.audiofiletest + AC_TRY_RUN([ +#include <stdio.h> +#include <stdlib.h> +#include <audiofile.h> + +int main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.audiofiletest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_audiofile_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_audiofile_version"); + exit(1); + } + + if (($audiofile_major_version > major) || + (($audiofile_major_version == major) && ($audiofile_minor_version > minor)) || + (($audiofile_major_version == major) && ($audiofile_minor_version == minor) && ($audiofile_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'audiofile-config --version' returned %d.%d.%d, but the minimum version\n", $audiofile_major_version, $audiofile_minor_version, $audiofile_micro_version); + printf("*** of AUDIOFILE required is %d.%d.%d. If audiofile-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If audiofile-config was wrong, set the environment variable AUDIOFILE_CONFIG\n"); + printf("*** to point to the correct copy of audiofile-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +],, no_audiofile=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_audiofile" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$AUDIOFILE_CONFIG" = "no" ; then + echo "*** The audiofile-config script installed by AUDIOFILE could not be found" + echo "*** If AUDIOFILE was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the AUDIOFILE_CONFIG environment variable to the" + echo "*** full path to audiofile-config." + else + if test -f conf.audiofiletest ; then + : + else + echo "*** Could not run AUDIOFILE test program, checking why..." + CFLAGS="$CFLAGS $AUDIOFILE_CFLAGS" + LIBS="$LIBS $AUDIOFILE_LIBS" + AC_TRY_LINK([ +#include <stdio.h> +#include <audiofile.h> +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding AUDIOFILE or finding the wrong" + echo "*** version of AUDIOFILE. If it is not finding AUDIOFILE, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means AUDIOFILE was incorrectly installed" + echo "*** or that you have moved AUDIOFILE since it was installed. In the latter case, you" + echo "*** may want to edit the audiofile-config script: $AUDIOFILE_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + AUDIOFILE_CFLAGS="" + AUDIOFILE_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(AUDIOFILE_CFLAGS) + AC_SUBST(AUDIOFILE_LIBS) + rm -f conf.audiofiletest +]) +# Configure paths for GNOME +# David Walluck 99-9-24 + +dnl AM_PATH_GNOME([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for GNOME, and define GNOME_CFLAGS and GNOME_LIBS +dnl +AC_DEFUN(AM_PATH_GNOME, +[dnl +dnl Get the cflags and libraries from the gnome-config script +dnl +AC_ARG_WITH(gnome-prefix,[ --with-gnome-prefix=PFX Prefix where GNOME is installed (optional)], + gnome_prefix="$withval", gnome_prefix="") +AC_ARG_WITH(gnome-exec-prefix,[ --with-gnome-exec-prefix=PFX Exec prefix where GNOME is installed (optional)], + gnome_exec_prefix="$withval", gnome_exec_prefix="") +AC_ARG_ENABLE(gnometest, [ --disable-gnometest Do not try to compile and run a test GNOME program], + , enable_gnometest=yes) + + if test x$gnome_exec_prefix != x ; then + gnome_args="$gnome_args --exec-prefix=$gnome_exec_prefix" + if test x${GNOME_CONFIG+set} != xset ; then + GNOME_CONFIG=$gnome_exec_prefix/bin/gnome-config + fi + fi + if test x$gnome_prefix != x ; then + gnome_args="$gnome_args --prefix=$gnome_prefix" + if test x${GNOME_CONFIG+set} != xset ; then + GNOME_CONFIG=$gnome_prefix/bin/gnome-config + fi + fi + + AC_PATH_PROG(GNOME_CONFIG, gnome-config, no) + min_gnome_version=ifelse([$1], ,0.2.7,$1) + AC_MSG_CHECKING(for GNOME - version >= $min_gnome_version) + no_gnome="" + if test "$GNOME_CONFIG" = "no" ; then + no_gnome=yes + else + GNOME_CFLAGS=`$GNOME_CONFIG $gnomeconf_args gnome --cflags` + GNOME_LIBS=`$GNOME_CONFIG $gnomeconf_args gnome --libs` + + gnome_major_version=`$GNOME_CONFIG $gnome_args --version | \ + sed 's/gnome-libs //' | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + gnome_minor_version=`$GNOME_CONFIG $gnome_args --version | \ + sed 's/gnome-libs //' | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + gnome_micro_version=`$GNOME_CONFIG $gnome_config_args --version | \ + sed 's/gnome-libs //' | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_gnometest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GNOME_CFLAGS" + LIBS="$LIBS $GNOME_LIBS" +dnl +dnl Now check if the installed GNOME is sufficiently new. (Also sanity +dnl checks the results of gnome-config to some extent +dnl + rm -f conf.gnometest + AC_TRY_RUN([ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <gnome.h> + +int main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.gnometest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_gnome_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_gnome_version"); + exit(1); + } + + if (($gnome_major_version > major) || + (($gnome_major_version == major) && ($gnome_minor_version > minor)) || + (($gnome_major_version == major) && ($gnome_minor_version == minor) && ($gnome_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'gnome-config --version' returned %d.%d.%d, but the minimum version\n", $gnome_major_version, $gnome_minor_version, $gnome_micro_version); + printf("*** of GNOME required is %d.%d.%d. If gnome-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If gnome-config was wrong, set the environment variable GNOME_CONFIG\n"); + printf("*** to point to the correct copy of gnome-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +],, no_gnome=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_gnome" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$GNOME_CONFIG" = "no" ; then + echo "*** The gnome-config script installed by GNOME could not be found" + echo "*** If GNOME was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the GNOME_CONFIG environment variable to the" + echo "*** full path to gnome-config." + else + if test -f conf.gnometest ; then + : + else + echo "*** Could not run GNOME test program, checking why..." + CFLAGS="$CFLAGS $GNOME_CFLAGS" + LIBS="$LIBS $GNOME_LIBS" + AC_TRY_LINK([ +#include <stdio.h> +#include <gnome.h> +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding GNOME or finding the wrong" + echo "*** version of GNOME. If it is not finding GNOME, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means GNOME was incorrectly installed" + echo "*** or that you have moved GNOME since it was installed. In the latter case, you" + echo "*** may want to edit the gnome-config script: $GNOME_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GNOME_CFLAGS="" + GNOME_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(GNOME_CFLAGS) + AC_SUBST(GNOME_LIBS) + rm -f conf.gnometest +]) +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ci.c Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,217 @@ +#define INCL_DOS +#define INCL_WIN + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include "dw.h" + + +unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | + DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; + +HWND mainwindow, + entryfield, + okbutton, + cancelbutton, + lbbox, + stext, + buttonbox; + +int test_callback(HWND window, void *data) +{ + dw_window_destroy((HWND)data); + exit(0); + return -1; +} + +void archive_add(void) +{ + HWND browsebutton, browsebox; + + mainwindow = dw_window_new(HWND_DESKTOP, "Add new archive", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX); + + lbbox = dw_box_new(BOXVERT, 10); + + dw_box_pack_start(mainwindow, lbbox, 150, 70, TRUE, TRUE, 0); + + /* Archive Name */ + stext = dw_text_new("Archive Name", 0); + + dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER); + + dw_box_pack_start(lbbox, stext, 130, 15, TRUE, TRUE, 2); + + browsebox = dw_box_new(BOXHORZ, 0); + + dw_box_pack_start(lbbox, browsebox, 130, 15, TRUE, TRUE, 0); + + entryfield = dw_entryfield_new("", 100L); + + dw_box_pack_start(browsebox, entryfield, 100, 15, TRUE, TRUE, 4); + + browsebutton = dw_button_new("Browse", 1001L); + + dw_box_pack_start(browsebox, browsebutton, 30, 15, TRUE, TRUE, 0); + + dw_window_set_color(browsebox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + dw_window_set_font(browsebutton, "9.WarpSans"); + dw_window_set_font(stext, "9.WarpSans"); + dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY); + dw_window_set_font(entryfield, "9.WarpSans"); + + /* Archive Description */ + stext = dw_text_new("Archive Description", 0); + + dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER); + + dw_box_pack_start(lbbox, stext, 130, 15, TRUE, TRUE, 4); + + entryfield = dw_entryfield_new("", 100L); + + dw_box_pack_start(lbbox, entryfield, 130, 15, TRUE, TRUE, 4); + + dw_window_set_font(stext, "9.WarpSans"); + dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY); + dw_window_set_font(entryfield, "9.WarpSans"); + + /* Comments */ + stext = dw_text_new("Comments", 0); + + dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER); + + dw_box_pack_start(lbbox, stext, 130, 15, TRUE, TRUE, 4); + + entryfield = dw_entryfield_new("", 100L); + + dw_box_pack_start(lbbox, entryfield, 130, 15, TRUE, TRUE, 4); + + dw_window_set_font(stext, "9.WarpSans"); + dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY); + dw_window_set_font(entryfield, "9.WarpSans"); + + /* Buttons */ + buttonbox = dw_box_new(BOXHORZ, 10); + + dw_box_pack_start(lbbox, buttonbox, 140, 210, TRUE, TRUE, 0); + + okbutton = dw_button_new("Ok", 1001L); + + dw_box_pack_start(buttonbox, okbutton, 130, 30, TRUE, TRUE, 2); + + cancelbutton = dw_button_new("Cancel", 1002L); + + dw_box_pack_start(buttonbox, cancelbutton, 130, 30, TRUE, TRUE, 2); + + /* Set some nice fonts and colors */ + dw_window_set_color(lbbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + dw_window_set_color(buttonbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + dw_window_set_font(okbutton, "9.WarpSans"); + dw_window_set_font(cancelbutton, "9.WarpSans"); + + dw_signal_connect(browsebutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); + dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); + dw_signal_connect(cancelbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); + dw_signal_connect(mainwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); + + dw_window_set_usize(mainwindow, 340, 250); + + dw_window_show(mainwindow); +} + +void object_add(void) +{ + mainwindow = dw_window_new(HWND_DESKTOP, "Add new object", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX); + + lbbox = dw_box_new(BOXVERT, 10); + + dw_box_pack_start(mainwindow, lbbox, 150, 70, TRUE, TRUE, 0); + + /* Object Name */ + stext = dw_text_new("Object Name", 0); + + dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER); + + dw_box_pack_start(lbbox, stext, 130, 15, TRUE, TRUE, 0); + + entryfield = dw_entryfield_new("", 100L); + + dw_box_pack_start(lbbox, entryfield, 130, 15, TRUE, TRUE, 0); + + dw_window_set_font(stext, "9.WarpSans"); + dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY); + dw_window_set_font(entryfield, "9.WarpSans"); + + /* Object ID */ + stext = dw_text_new("Object ID", 0); + + dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER); + + dw_box_pack_start(lbbox, stext, 130, 15, TRUE, TRUE, 0); + + entryfield = dw_entryfield_new("", 100L); + + dw_box_pack_start(lbbox, entryfield, 130, 15, TRUE, TRUE, 0); + + dw_window_set_font(stext, "9.WarpSans"); + dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY); + dw_window_set_font(entryfield, "9.WarpSans"); + + /* Object Type */ + stext = dw_text_new("Object Type", 0); + + dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER); + + dw_box_pack_start(lbbox, stext, 130, 15, TRUE, TRUE, 0); + + entryfield = dw_entryfield_new("", 100L); + + dw_box_pack_start(lbbox, entryfield, 130, 15, TRUE, TRUE, 0); + + dw_window_set_font(stext, "9.WarpSans"); + dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY); + dw_window_set_font(entryfield, "9.WarpSans"); + + /* Buttons */ + buttonbox = dw_box_new(BOXHORZ, 10); + + dw_box_pack_start(lbbox, buttonbox, 140, 210, TRUE, TRUE, 0); + + okbutton = dw_button_new("Ok", 1001L); + + dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, TRUE, 0); + + cancelbutton = dw_button_new("Cancel", 1002L); + + dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, TRUE, 0); + + /* Set some nice fonts and colors */ + dw_window_set_color(lbbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + dw_window_set_color(buttonbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + dw_window_set_font(okbutton, "9.WarpSans"); + dw_window_set_font(cancelbutton, "9.WarpSans"); + + dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); + dw_signal_connect(cancelbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); + dw_signal_connect(mainwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); + + dw_window_set_usize(mainwindow, 340, 250); + + dw_window_show(mainwindow); +} + +/* + * Let's demonstrate the functionality of this library. :) + */ +int main(void) +{ + dw_init(TRUE); + + archive_add(); + dw_main(0L, NULL); + + object_add(); + dw_main(0L, NULL); + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ci.def Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,3 @@ +NAME CI WINDOWAPI + +DESCRIPTION 'Create Installer'
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compat.c Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,379 @@ +/* $Id$ */ + +#include "compat.h" +#if defined(__OS2__) || defined(__WIN32__) +#include <share.h> +#endif + +int sockread (int a, void *b, int c, int d) +{ +#if defined(__IBMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__)) + return recv(a,b,c,d); +#else + return read(a,b,c); +#endif +} + +int sockwrite (int a, void *b, int c, int d) +{ +#if defined(__IBMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__)) + return send(a,b,c,d); +#else + return write(a,b,c); +#endif +} + +int sockclose(int a) +{ +#ifdef __IBMC__ + return soclose(a); +#elif defined(__WIN32__) && !defined(__CYGWIN32__) + return closesocket(a); +#else + return close(a); +#endif +} + +int makedir(char *path) +{ +#if defined(__IBMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__)) + return mkdir(path); +#else + return mkdir(path,S_IRWXU); +#endif +} + +void nonblock(int fd) +{ +#ifdef __IBMC__ + static int _nonblock = 1; + + ioctl(fd, FIONBIO, (char *)&_nonblock, sizeof(_nonblock)); +#elif defined(__WIN32__) && !defined(__CYGWIN32__) + static unsigned long _nonblock = 1; + + ioctlsocket(fd, FIONBIO, &_nonblock); +#else + fcntl(fd, F_SETFL, O_NONBLOCK); +#endif +} + +int socksprintf(int fd, char *format, ...) +{ + va_list args; + char outbuf[1024]; + int len; + + va_start(args, format); + vsprintf(outbuf, format, args); + va_end(args); + + len = strlen(outbuf); + sockwrite(fd, outbuf, len, 0); + + return len; +} + +void sockinit(void) +{ +#ifdef __IBMC__ + sock_init(); +#elif defined(__WIN32__) || defined(WINNT) + WSADATA wsa; + + WSAStartup(MAKEWORD (1, 1), &wsa); +#endif /* !WIN32 */ +} + +void sockshutdown(void) +{ +#if defined(__WIN32__) || defined(WINNT) + WSACleanup(); +#endif /* !WIN32 */ +} + +int sockpipe(int *pipes) +{ +#ifndef NO_DOMAIN_SOCKETS +#ifndef HAVE_PIPE + struct sockaddr_un un; +#endif +#else + struct sockaddr_in server_addr; + struct sockaddr_in listen_addr = { 0 }; + int len = sizeof(struct sockaddr_in); + struct hostent *he; +#endif +#ifndef HAVE_PIPE + int tmpsock; +#endif + +#ifdef HAVE_PIPE + return pipe(pipes); +#elif !defined(NO_DOMAIN_SOCKETS) + static int instance = -1; + + instance++; + + /* Use UNIX domain sockets to pass messages */ + tmpsock = socket(AF_UNIX, SOCK_STREAM, 0); + pipes[1] = socket(AF_UNIX, SOCK_STREAM, 0); + memset(&un, 0, sizeof(un)); + un.sun_family=AF_UNIX; + sprintf(un.sun_path, PIPENAME, instance); + bind(tmpsock, (struct sockaddr *)&un, sizeof(un)); + listen(tmpsock, 0); + connect(pipes[1], (struct sockaddr *)&un, sizeof(un)); + pipes[0] = accept(tmpsock, 0, 0); + sockclose(tmpsock); +#else + /* Use localhost socket to pass messages if no domain sockets */ + he = gethostbyname("localhost"); + + if(he) + { + memset(&server_addr, 0, sizeof(server_addr)); + server_addr.sin_family = AF_INET; + server_addr.sin_port = 0; + server_addr.sin_addr.s_addr = INADDR_ANY; + if ((tmpsock = socket(AF_INET, SOCK_STREAM, 0)) < 0 || bind(tmpsock, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0 || listen(tmpsock, 0) < 0) + return -1; + + memset(&listen_addr, 0, sizeof(listen_addr)); + getsockname(tmpsock, (struct sockaddr *)&listen_addr, &len); + + server_addr.sin_family = AF_INET; + server_addr.sin_port = listen_addr.sin_port; + server_addr.sin_addr.s_addr = *((unsigned long *)he->h_addr); + if((pipes[1] = socket(AF_INET, SOCK_STREAM, 0)) < 0 || connect(pipes[1], (struct sockaddr *)&server_addr, sizeof(server_addr))) + return -1; + else + pipes[0] = accept(tmpsock, 0, 0); + sockclose(tmpsock); + } + else + return -1; +#endif + if(pipes[0] < 0 || pipes[1] < 0) + return -1; + return 0; +} + +/* Return in K to avoid big problems exceeding an + unsigned long when no 64bit integers are available */ +#if defined(__IBMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__)) +unsigned long drivefree(int drive) +#else +unsigned long long drivefree(int drive) +#endif +{ +#if defined(__EMX__) || defined(__OS2__) + ULONG aulFSInfoBuf[40] = {0}; + APIRET rc = NO_ERROR; + + DosError(FERR_DISABLEHARDERR); + rc = DosQueryFSInfo(drive, + FSIL_ALLOC, + (PVOID)aulFSInfoBuf, + sizeof(aulFSInfoBuf)); + + DosError(FERR_ENABLEHARDERR); + if (rc != NO_ERROR) + return 0; + + return (unsigned long)((aulFSInfoBuf[3] * aulFSInfoBuf[1] * (USHORT)aulFSInfoBuf[4])/1024); +#elif defined(__WIN32__) || defined(WINNT) + char buffer[10] = "C:\\"; + DWORD spc, bps, fc, tc; + + buffer[0] = drive + 'A' - 1; + + if(GetDiskFreeSpace(buffer, &spc, &bps, &fc, &tc) == 0) + return 0; + return (unsigned long)(spc*bps*(fc/1024)); +#else + return 0; +#endif +} + +int isdrive(int drive) +{ +#if defined(__EMX__) || defined(__OS2__) + APIRET rc = NO_ERROR; + FSINFO volinfo; + + DosError(FERR_DISABLEHARDERR); + rc = DosQueryFSInfo(drive, + FSIL_VOLSER, + (PVOID)&volinfo, + sizeof(FSINFO)); + + DosError(FERR_ENABLEHARDERR); + if (rc == NO_ERROR) + return 1; + +#elif defined(__WIN32__) || defined(WINNT) + char buffer[10] = "C:\\", volname[100]; + DWORD spc, bps, fc; + + buffer[0] = drive + 'A' - 1; + + if(GetVolumeInformation(buffer, volname, 100, &spc, &bps, &fc, NULL, 0) != 0) + return 1; +#endif + return 0; +} + +void setfileinfo(char *filename, char *url) +{ + time_t ltime; + struct tm *tm; + char buffer[200], timebuf[200]; +#ifdef __OS2__ + const unsigned fea2listsize = 6000; + char *pData; + EAOP2 eaop2; + PFEA2 pFEA2; +#else + FILE *urlfile; +#endif + + ltime = time(NULL); + + tm = localtime(<ime); + + strftime(timebuf, 200, "%c", tm); + + sprintf(buffer, "%s %s", url, timebuf); + +#ifdef __OS2__ + eaop2.fpGEA2List = 0; + eaop2.fpFEA2List = (PFEA2LIST)malloc(fea2listsize); + pFEA2 = &eaop2.fpFEA2List->list[0]; + + pFEA2->fEA = 0; + /* .COMMENTS is 9 characters long */ + pFEA2->cbName = 9; + + /* space for the type and length field. */ + pFEA2->cbValue = strlen(buffer)+2*sizeof(USHORT); + + strcpy(pFEA2->szName, ".COMMENTS"); + pData = pFEA2->szName+pFEA2->cbName+1; + /* data begins at first byte after the name */ + + *(USHORT*)pData = EAT_ASCII; /* type */ + *((USHORT*)pData+1) = strlen(buffer); /* length */ + strcpy(pData+2*sizeof(USHORT), buffer);/* content */ + + pFEA2->oNextEntryOffset = 0; + + eaop2.fpFEA2List->cbList = ((PCHAR)pData+2*sizeof(USHORT)+ + pFEA2->cbValue)-((PCHAR)eaop2.fpFEA2List); + + DosSetPathInfo(filename, + FIL_QUERYEASIZE, + &eaop2, + sizeof(eaop2), + 0); + + free((void *)eaop2.fpFEA2List); +#else + + if((urlfile = fopen("handyftp.url", "a"))!=NULL) + { + fprintf(urlfile, "%s\n", buffer); + fclose(urlfile); + } +#endif +} + +#if defined(__OS2__) || defined(__WIN32__) +typedef struct _fsinfo { + FILE *fp; + int fd; +} FSInfo; + +FSInfo *FSIRoot = NULL; + +#define FSI_MAX 100 +#endif + +/* Sharable fopen() and fclose() calls. */ +FILE *fsopen(char *path, char *modes) +{ +#if defined(__OS2__) || defined(__WIN32__) + int z; + + if(!FSIRoot) + FSIRoot = calloc(sizeof(struct _fsinfo), FSI_MAX); + + for(z=0;z<FSI_MAX;z++) + { + if(FSIRoot[z].fd < 1) + { + int s, sopenmode = 0, wrmode = 0; + + /* Check the flags passed */ + for(s=0;s<3;s++) + { + if(modes[s] == 'b') + sopenmode |= O_BINARY; + if(modes[s] == 'r') + wrmode |= O_RDONLY; + if(modes[s] == 'w') + wrmode |= O_WRONLY; + if(modes[s] == 'a') + sopenmode |= O_APPEND; + if(modes[s] == 't') + sopenmode |= O_TEXT; + } + + /* Check the read/write request */ + if((wrmode & O_RDONLY) && (wrmode & O_WRONLY)) + sopenmode |= O_RDWR; + else + sopenmode |= wrmode; + FSIRoot[z].fd = _sopen(path, sopenmode, SH_DENYNO, S_IREAD|S_IWRITE); + if(FSIRoot[z].fd > 0) + { + FSIRoot[z].fp = fdopen(FSIRoot[z].fd, modes); + + return FSIRoot[z].fp; + } + } + } + return NULL; +#else + return fopen(path, modes); +#endif +} + +int fsclose(FILE *fp) +{ +#if defined(__OS2__) || defined(__WIN32__) + if(FSIRoot) + { + + int z; + for(z=0;z<FSI_MAX;z++) + { + if(fp == FSIRoot[z].fp) + { + int ret = fclose(fp); + close(FSIRoot[z].fd); + FSIRoot[z].fd = 0; + FSIRoot[z].fp = NULL; + return ret; + } + } + } +#endif + return fclose(fp); +} + +char *fsgets(char *str, int size, FILE *stream) +{ + return fgets(str, size, stream); +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compat.h Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,194 @@ +/* $Id$ */ + +/* This header includes and defines everything needed for a given OS/compiler */ +#if !defined(__EMX__) && !defined(__IBMC__) && !defined(__WIN32__) && !defined(WINNT) +#include "config.h" + +#define msleep(a) usleep(a*1000) +#endif /* Unix */ + +#include <sys/types.h> +#if HAVE_DIRENT_H +#include <dirent.h> +#define NAMLEN(dirent) strlen((dirent)->d_name) +#else +#define dirent direct +#define NAMLEN(dirent) (dirent)->d_namlen +#if HAVE_SYS_NDIR_H +#include <sys/ndir.h> +#endif /* HAVE_SYS_NDIR_H */ +#if HAVE_SYS_DIR_H +#include <sys/dir.h> +#endif /* HAVE_SYS_DIR_H */ +#if HAVE_NDIR_H +#include <ndir.h> +#endif /* HAVE_NDIR_H */ +#endif /* HAVE_DIRENT_H */ + +#ifdef DIRSEP +#undef DIRSEP +#endif + +#if defined(__EMX__) || defined(__IBMC__) || defined(__WIN32__) || defined(WINNT) +#include <io.h> +#include <process.h> + +#define DIRSEP "\\" +#define INIDIR "." +#define TYPDIR "." +#else +#define DIRSEP "/" +#define INIDIR "~/.handyftp" +#define TYPDIR "/usr/local/handyftp" +#endif + +/* OS/2 */ +#if defined(__EMX__) || defined(__IBMC__) +#define INCL_WIN +#define INCL_GPI +#define INCL_VIO +#define INCL_NLS +#define INCL_DOS +#define INCL_DEV +#define INCL_DOSERRORS + +#define msleep(a) DosSleep(a) + +#ifdef __EMX__ +#define FD_SETSIZE 1024 +#define strcasecmp stricmp +#define strncasecmp strnicmp +#endif /* __EMX__ */ + +#ifndef OS2 +#define OS2 +#endif /* OS2 */ + +#include <os2.h> + +#ifndef BKS_TABBEDDIALOG +#define BKS_TABBEDDIALOG 0x0800 +#endif + +#define PIPENAME "\\socket\\handyftp%d" +#define TPIPENAME "\\socket\\handyftpt%d" +#else +#define PIPENAME "/tmp/handyftp%d" +#define TPIPENAME "/tmp/handyftpt%d" +#endif /* __EMX__ || __IBMC__ */ + +#ifdef __IBMC__ +#define BSD_SELECT + +#include <types.h> +#include <time.h> +#include <sys/stat.h> +#include <sys/select.h> +#include <sys/ioctl.h> +#include <direct.h> +#include <stdarg.h> +/* For VAC we are using the Mozilla dirent.c */ +#include "dirent.h" +#endif + +/* Windows */ +#if defined(__WIN32__) || defined(WINNT) +#include <windows.h> +#include <winsock.h> +#include <time.h> +#include <process.h> +#include <sys/stat.h> +#ifdef MSVC +#include "dirent.h" +#else +#include <dir.h> +#include <dirent.h> +#endif +#include <stdarg.h> + +#if defined(__CYGWIN32__) || defined(__MINGW32__) +#include <sys/un.h> +#endif /* __CYGWIN32__ || __MINGW32__ */ + +#ifndef __CYGWIN32__ +#define NO_DOMAIN_SOCKETS +#endif /* __CYGWIN32__ */ + +#if defined(_P_NOWAIT) && !defined(P_NOWAIT) +#define P_NOWAIT _P_NOWAIT +#endif + +#define strcasecmp stricmp +#define strncasecmp strnicmp +#define msleep Sleep + +#endif /* WIN32 */ + +/* Everything else ;) */ +#include <stdio.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif /* HAVE_UNISTD_H */ +#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif +#include <stdlib.h> +#include <stddef.h> +#include <signal.h> +#include <fcntl.h> + +#if !defined(__WIN32__) && !defined(WINNT) +#include <sys/time.h> +#include <sys/socket.h> +#include <sys/un.h> +#include <netinet/in.h> +#include <netdb.h> +#include <arpa/nameser.h> +#include <resolv.h> +#ifdef STDC_HEADERS +#include <stdarg.h> +#include <string.h> +#endif /* STDC_HEADERS */ +#endif /* !WIN32 */ + +#ifndef _MAX_PATH +#define _MAX_PATH 255 +#endif + +/* IBM C doesn't allow "t" in the mode parameter + * because it violates the ANSI standard. + */ +#ifdef __IBMC__ +#define FOPEN_READ_TEXT "r" +#define FOPEN_WRITE_TEXT "w" +#define FOPEN_APPEND_TEXT "a" +#else +#define FOPEN_READ_TEXT "rt" +#define FOPEN_WRITE_TEXT "wt" +#define FOPEN_APPEND_TEXT "at" +#endif +#define FOPEN_READ_BINARY "rb" +#define FOPEN_WRITE_BINARY "wb" +#define FOPEN_APPEND_BINARY "ab" + +/* Compatibility layer for IBM C/Winsock */ +int sockread (int a, void *b, int c, int d); +int sockwrite (int a, void *b, int c, int d); +int sockclose(int a); +int socksprintf(int fd, char *format, ...); +int sockpipe(int *pipes); +void sockinit(void); +void sockshutdown(void); +int makedir(char *path); +void nonblock(int fd); +void setfileinfo(char *filename, char *url); +#if defined(__IBMC__) || defined(__WIN32__) +unsigned long drivefree(int drive); +#else +unsigned long long drivefree(int drive); +#endif +int isdrive(int drive); +FILE *fsopen(char *path, char *modes); +int fsclose(FILE *fp); +char *fsgets(char *str, int size, FILE *stream); +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config.h.in Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,34 @@ +/* config.h.in. Generated automatically from configure.in by autoheader. */ + +/* Define if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define if you have the connect function. */ +#undef HAVE_CONNECT + +/* Define if you have the pipe function. */ +#undef HAVE_PIPE + +/* Define if you have the <dirent.h> header file. */ +#undef HAVE_DIRENT_H + +/* Define if you have the <ndir.h> header file. */ +#undef HAVE_NDIR_H + +/* Define if you have the <sys/dir.h> header file. */ +#undef HAVE_SYS_DIR_H + +/* Define if you have the <sys/ndir.h> header file. */ +#undef HAVE_SYS_NDIR_H + +/* Define if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H + +/* Define if you have the <sys/stat.h> header file. */ +#undef HAVE_SYS_STAT_H + +/* Determine whether we have the pipe function */ +#undef HAVE_PIPE + +/* Define if IMLIB is available. */ +#undef USE_IMLIB
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/configure Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,4741 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by Autoconf 2.49e. +# +# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# Name of the executable. +as_me=`echo "$0" |sed 's,.*[\\/],,'` + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +as_executable_p="test -f" + +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + +# NLS nuisances. +$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; } +$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; } +$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; } +$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; } +$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; } +$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; } +$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; } +$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; } + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; } + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +exec 6>&1 + +# +# Initializations. +# +ac_default_prefix=/usr/local +cross_compiling=no +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +# Avoid depending upon Character Ranges. +ac_cr_az='abcdefghijklmnopqrstuvwxyz' +ac_cr_AZ='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +ac_cr_09='0123456789' +ac_cr_alnum=$ac_cr_az$ac_cr_AZ$ac_cr_09 + +# Sed expression to map a string onto a valid sh and CPP variable names. +ac_tr_sh="sed y%*+%pp%;s%[^_$ac_cr_alnum]%_%g" +ac_tr_cpp="sed y%*$ac_cr_az%P$ac_cr_AZ%;s%[^_$ac_cr_alnum]%_%g" + +ac_unique_file="winmain.c" + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= + +ac_prev= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_option in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$ac_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$ac_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "enable_$ac_feature='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$ac_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package| sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "with_$ac_package='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$ac_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$ac_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$ac_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir \ + exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + NONE ) ;; + *) { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: should be removed in autoconf 3.0. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo "$ac_prog" | sed 's%[\\/][^\\/][^\\/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "$as_me: error: cannot find sources in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } + else + { echo "$as_me: error: cannot find sources in $srcdir" >&2 + { (exit 1); exit 1; }; } + fi +fi +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPP_set=${CPP+set} +ac_env_CPP_value=$CPP +ac_cv_env_CPP_set=${CPP+set} +ac_cv_env_CPP_value=$CPP +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<EOF +\`configure' configures this package to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +EOF + + cat <<EOF +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +EOF + + cat <<\EOF +EOF +fi + +if test -n "$ac_init_help"; then + + cat <<\EOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --disable-glibtest Do not try to compile and run a test GLIB program + --disable-gtktest Do not try to compile and run a test GTK program + --disable-imlibtest Do not try to compile and run a test IMLIB program + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-glib-prefix=PFX Prefix where GLIB is installed (optional) + --with-glib-exec-prefix=PFX Exec prefix where GLIB is installed (optional) + --with-gtk-prefix=PFX Prefix where GTK is installed (optional) + --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional) + --with-imlib-prefix=PFX Prefix where IMLIB is installed (optional) + --with-imlib-exec-prefix=PFX Exec prefix where IMLIB is installed (optional) + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a + nonstandard directory <lib dir> + CPP C preprocessor + CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have + headers in a nonstandard directory <include dir> + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +EOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_subdir in : $ac_subdirs_all; do test "x$ac_subdir" = x: && continue + cd $ac_subdir + # A "../" for each directory in /$ac_subdir. + ac_dots=`echo $ac_subdir | + sed 's,^\./,,;s,[^/]$,&/,;s,[^/]*/,../,g'` + + case $srcdir in + .) # No --srcdir option. We are building in place. + ac_sub_srcdir=$srcdir ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_sub_srcdir=$srcdir/$ac_subdir ;; + *) # Relative path. + ac_sub_srcdir=$ac_dots$srcdir/$ac_subdir ;; + esac + + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_sub_srcdir/configure.gnu; then + echo + $SHELL $ac_sub_srcdir/configure.gnu --help=recursive + elif test -f $ac_sub_srcdir/configure; then + echo + $SHELL $ac_sub_srcdir/configure --help=recursive + elif test -f $ac_sub_srcdir/configure.ac || + test -f $ac_sub_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_subdir" >&2 + fi + cd $ac_popdir + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\EOF + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +EOF + exit 0 +fi +exec 5>config.log +cat >&5 <<EOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by $as_me, which was +generated by GNU Autoconf 2.49e. Invocation command line was + + $ $0 $@ + +EOF +{ +cat <<_ASUNAME +## ---------- ## +## Platform. ## +## ---------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +PATH = $PATH + +_ASUNAME +} >&5 + +cat >&5 <<EOF +## ------------ ## +## Core tests. ## +## ------------ ## + +EOF + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell meta-characters. +ac_configure_args= +ac_sep= +for ac_arg +do + case $ac_arg in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + ac_sep=" " ;; + *) ac_configure_args="$ac_configure_args$ac_sep$ac_arg" + ac_sep=" " ;; + esac + # Get rid of the leading space. +done + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + echo >&5 + echo "## ----------------- ##" >&5 + echo "## Cache variables. ##" >&5 + echo "## ----------------- ##" >&5 + echo >&5 + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$ac_cr_alnum]*_cv_[_$ac_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$ac_cr_alnum]*_cv_[_$ac_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} >&5 + sed "/^$/d" confdefs.h >conftest.log + if test -s conftest.log; then + echo >&5 + echo "## ------------ ##" >&5 + echo "## confdefs.h. ##" >&5 + echo "## ------------ ##" >&5 + echo >&5 + cat conftest.log >&5 + fi + (echo; echo) >&5 + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" >&5 + echo "$as_me: exit $exit_status" >&5 + rm -rf conftest* confdefs* core core.* *.core conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_status=$?; ac_signal='$ac_signal'; { (exit $ac_status); exit $ac_status; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >confdefs.h + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + { echo "$as_me:824: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + cat "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:835: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi +else + { echo "$as_me:843: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_suggest_removing_cache=false +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val="\$ac_cv_env_${ac_var}_value" + eval ac_new_val="\$ac_env_${ac_var}_value" + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:859: WARNING: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: WARNING: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_suggest_removing_cache=: ;; + ,set) + { echo "$as_me:863: WARNING: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: WARNING: \`$ac_var' was not set in the previous run" >&2;} + ac_suggest_removing_cache=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:869: WARNING: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: WARNING: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:871: WARNING: former value: $ac_old_val" >&5 +echo "$as_me: WARNING: former value: $ac_old_val" >&2;} + { echo "$as_me:873: WARNING: current value: $ac_new_val" >&5 +echo "$as_me: WARNING: current value: $ac_new_val" >&2;} + ac_suggest_removing_cache=: + fi;; + esac +done +if $ac_suggest_removing_cache; then + { echo "$as_me:880: WARNING: changes in the environment can compromise the build" >&5 +echo "$as_me: WARNING: changes in the environment can compromise the build" >&2;} + { echo "$as_me:882: WARNING: consider removing $cache_file and starting over" >&5 +echo "$as_me: WARNING: consider removing $cache_file and starting over" >&2;} +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac +echo "#! $SHELL" >conftest.sh +echo "exit 0" >>conftest.sh +chmod +x conftest.sh +if { (echo "$as_me:901: PATH=\".;.\"; conftest.sh") >&5 + (PATH=".;."; conftest.sh) 2>&5 + ac_status=$? + echo "$as_me:904: \$? = $ac_status" >&5 + (exit $ac_status); }; then + ac_path_separator=';' +else + ac_path_separator=: +fi +PATH_SEPARATOR="$ac_path_separator" +rm -f conftest.sh + +ac_config_headers="$ac_config_headers config.h" + +INCLUDES="-I." + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo "$as_me:925: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_CC="${ac_tool_prefix}gcc" +echo "$as_me:940: found $ac_dir/$ac_word" >&5 +{ ac_try='$ac_dir/$ac_word --version </dev/null >&2' + { (eval echo "$as_me:942: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:945: \$? = $ac_status" >&5 + (exit $ac_status); }; } +break +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:954: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:957: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo "$as_me:966: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_ac_ct_CC="gcc" +echo "$as_me:981: found $ac_dir/$ac_word" >&5 +{ ac_try='$ac_dir/$ac_word --version </dev/null >&2' + { (eval echo "$as_me:983: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:986: \$? = $ac_status" >&5 + (exit $ac_status); }; } +break +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:995: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:998: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +echo "$as_me:1011: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_CC="${ac_tool_prefix}cc" +echo "$as_me:1026: found $ac_dir/$ac_word" >&5 +{ ac_try='$ac_dir/$ac_word --version </dev/null >&2' + { (eval echo "$as_me:1028: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1031: \$? = $ac_status" >&5 + (exit $ac_status); }; } +break +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:1040: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:1043: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:1052: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_ac_ct_CC="cc" +echo "$as_me:1067: found $ac_dir/$ac_word" >&5 +{ ac_try='$ac_dir/$ac_word --version </dev/null >&2' + { (eval echo "$as_me:1069: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1072: \$? = $ac_status" >&5 + (exit $ac_status); }; } +break +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:1081: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:1084: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:1097: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue +fi +ac_cv_prog_CC="cc" +echo "$as_me:1117: found $ac_dir/$ac_word" >&5 +{ ac_try='$ac_dir/$ac_word --version </dev/null >&2' + { (eval echo "$as_me:1119: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1122: \$? = $ac_status" >&5 + (exit $ac_status); }; } +break +done + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" ${1+"$@"} + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:1145: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:1148: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:1159: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_CC="$ac_tool_prefix$ac_prog" +echo "$as_me:1174: found $ac_dir/$ac_word" >&5 +{ ac_try='$ac_dir/$ac_word --version </dev/null >&2' + { (eval echo "$as_me:1176: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1179: \$? = $ac_status" >&5 + (exit $ac_status); }; } +break +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:1188: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:1191: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:1204: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_ac_ct_CC="$ac_prog" +echo "$as_me:1219: found $ac_dir/$ac_word" >&5 +{ ac_try='$ac_dir/$ac_word --version </dev/null >&2' + { (eval echo "$as_me:1221: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1224: \$? = $ac_status" >&5 + (exit $ac_status); }; } +break +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:1233: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:1236: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CC" && break +done + + CC=$ac_ct_CC +fi + +fi + +test -z "$CC" && { { echo "$as_me:1248: error: no acceptable cc found in \$PATH" >&5 +echo "$as_me: error: no acceptable cc found in \$PATH" >&2;} + { (exit 1); exit 1; }; } + +cat >conftest.$ac_ext <<_ACEOF +#line 1253 "configure" +#include "confdefs.h" + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compiler, and finding out an intuition +# of exeext. +echo "$as_me:1269: checking for C compiler default output" >&5 +echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:1272: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:1275: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `ls a.exe conftest.exe a.* conftest conftest.* 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;; + a.out ) # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +{ { echo "$as_me:1292: error: C compiler cannot create executables" >&5 +echo "$as_me: error: C compiler cannot create executables" >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +echo "$as_me:1298: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 + +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:1303: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (eval echo "$as_me:1309: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1312: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:1319: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +echo "$as_me:1327: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +rm -f a.out a.exe conftest$ac_cv_exeext +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:1334: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:1336: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:1339: checking for executable suffix" >&5 +echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6 +if { (eval echo "$as_me:1341: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:1344: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + { { echo "$as_me:1360: error: cannot compute EXEEXT: cannot compile and link" >&5 +echo "$as_me: error: cannot compute EXEEXT: cannot compile and link" >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +echo "$as_me:1366: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +echo "$as_me:1372: checking for object suffix" >&5 +echo $ECHO_N "checking for object suffix... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 1378 "configure" +#include "confdefs.h" + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:1390: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1393: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +{ { echo "$as_me:1405: error: cannot compute OBJEXT: cannot compile" >&5 +echo "$as_me: error: cannot compute OBJEXT: cannot compile" >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:1412: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:1416: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 1422 "configure" +#include "confdefs.h" + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:1437: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1440: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:1443: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1446: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_compiler_gnu=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:1458: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:1464: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 1470 "configure" +#include "confdefs.h" + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:1482: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1485: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:1488: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1491: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_prog_cc_g=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:1501: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:1528: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1531: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:1534: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1537: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + ''\ + '#include <stdlib.h>' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +#line 1549 "configure" +#include "confdefs.h" +#include <stdlib.h> +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:1562: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1565: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:1568: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1571: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +continue +fi +rm -f conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +#line 1581 "configure" +#include "confdefs.h" +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:1593: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1596: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:1599: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1602: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext +done +echo '#ifdef __cplusplus' >>confdefs.h +echo $ac_declaration >>confdefs.h +echo '#endif' >>confdefs.h + +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +# Extract the first word of "gmake", so it can be a program name with args. +set dummy gmake; ac_word=$2 +echo "$as_me:1628: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_MAKE+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$MAKE"; then + ac_cv_prog_MAKE="$MAKE" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_MAKE="gmake" +echo "$as_me:1643: found $ac_dir/$ac_word" >&5 +{ ac_try='$ac_dir/$ac_word --version </dev/null >&2' + { (eval echo "$as_me:1645: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1648: \$? = $ac_status" >&5 + (exit $ac_status); }; } +break +done + +fi +fi +MAKE=$ac_cv_prog_MAKE +if test -n "$MAKE"; then + echo "$as_me:1657: result: $MAKE" >&5 +echo "${ECHO_T}$MAKE" >&6 +else + echo "$as_me:1660: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +if test x"$MAKE" = x; then + # Extract the first word of "make", so it can be a program name with args. +set dummy make; ac_word=$2 +echo "$as_me:1667: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_MAKE+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$MAKE"; then + ac_cv_prog_MAKE="$MAKE" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_MAKE="make" +echo "$as_me:1682: found $ac_dir/$ac_word" >&5 +{ ac_try='$ac_dir/$ac_word --version </dev/null >&2' + { (eval echo "$as_me:1684: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1687: \$? = $ac_status" >&5 + (exit $ac_status); }; } +break +done + +fi +fi +MAKE=$ac_cv_prog_MAKE +if test -n "$MAKE"; then + echo "$as_me:1696: result: $MAKE" >&5 +echo "${ECHO_T}$MAKE" >&6 +else + echo "$as_me:1699: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f $ac_dir/shtool; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:1722: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 +echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} + { (exit 1); exit 1; }; } +fi +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:1742: checking for a BSD compatible install" >&5 +echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_save_IFS=$IFS; IFS=$ac_path_separator + for ac_dir in $PATH; do + IFS=$ac_save_IFS + # Account for people who put trailing slashes in PATH elements. + case $ac_dir/ in + / | ./ | .// | /cC/* \ + | /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* \ + | /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + if $as_executable_p "$ac_dir/$ac_prog"; then + if test $ac_prog = install && + grep dspmsg "$ac_dir/$ac_prog" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$ac_dir/$ac_prog" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi +fi +echo "$as_me:1791: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +echo "$as_me:1807: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + # Use a header file that comes with gcc, so configuring glibc +# with a fresh cross-compiler works. +# On the NeXT, cc -E runs the code through the compiler's parser, +# not just through cpp. "Syntax error" is here to catch this case. +ac_c_preproc_warn_flag=maybe +cat >conftest.$ac_ext <<_ACEOF +#line 1826 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax error +_ACEOF +if { (eval echo "$as_me:1831: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:1837: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Now check whether non-existent headers can be detected and how +# Skip if ac_cpp_err is not empty - ac_cpp is broken +if test -z "$ac_cpp_err"; then + cat >conftest.$ac_ext <<_ACEOF +#line 1852 "configure" +#include "confdefs.h" +#include <ac_nonexistent.h> +_ACEOF +if { (eval echo "$as_me:1856: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:1862: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # cannot detect missing includes at all +ac_cpp_err=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + if test "x$ac_cpp_err" = xmaybe; then + ac_c_preproc_warn_flag=yes + else + ac_c_preproc_warn_flag= + fi + ac_cpp_err= +fi +rm -f conftest.err conftest.$ac_ext +fi +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_ext + if test -z "$ac_cpp_err"; then + break + fi + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + # Use a header file that comes with gcc, so configuring glibc +# with a fresh cross-compiler works. +# On the NeXT, cc -E runs the code through the compiler's parser, +# not just through cpp. "Syntax error" is here to catch this case. +ac_c_preproc_warn_flag=maybe +cat >conftest.$ac_ext <<_ACEOF +#line 1908 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax error +_ACEOF +if { (eval echo "$as_me:1913: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:1919: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Now check whether non-existent headers can be detected and how +# Skip if ac_cpp_err is not empty - ac_cpp is broken +if test -z "$ac_cpp_err"; then + cat >conftest.$ac_ext <<_ACEOF +#line 1934 "configure" +#include "confdefs.h" +#include <ac_nonexistent.h> +_ACEOF +if { (eval echo "$as_me:1938: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:1944: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # cannot detect missing includes at all +ac_cpp_err=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + if test "x$ac_cpp_err" = xmaybe; then + ac_c_preproc_warn_flag=yes + else + ac_c_preproc_warn_flag= + fi + ac_cpp_err= +fi +rm -f conftest.err conftest.$ac_ext +fi +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_ext + ac_cv_prog_CPP=$CPP +fi +echo "$as_me:1977: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6 +if test -n "$ac_cpp_err"; then + { { echo "$as_me:1980: error: C preprocessor \"$CPP\" fails sanity check" >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;} + { (exit 1); exit 1; }; } +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +echo "$as_me:1990: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 1996 "configure" +#include "confdefs.h" +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h> + +_ACEOF +if { (eval echo "$as_me:2004: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:2010: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_header_stdc=no +fi +rm -f conftest.err conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +#line 2032 "configure" +#include "confdefs.h" +#include <string.h> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +#line 2050 "configure" +#include "confdefs.h" +#include <stdlib.h> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +#line 2071 "configure" +#include "confdefs.h" +#include <ctype.h> +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:2097: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:2100: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:2102: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2105: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_header_stdc=no +fi +rm -f conftest$ac_exeext conftest.$ac_ext +fi +fi +fi +echo "$as_me:2118: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + +ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do + ac_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $ac_tr_sh` +echo "$as_me:2131: checking for $ac_hdr that defines DIR" >&5 +echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6 +if eval "test \"\${$ac_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 2137 "configure" +#include "confdefs.h" +#include <sys/types.h> +#include <$ac_hdr> + +int +main () +{ +DIR *dirp = 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2151: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2154: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2157: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2160: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$ac_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$ac_ac_Header=no" +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:2170: result: `eval echo '${'$ac_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$ac_ac_Header'}'`" >&6 +if test `eval echo '${'$ac_ac_Header'}'` = yes; then + cat >>confdefs.h <<EOF +#define `echo "HAVE_$ac_hdr" | $ac_tr_cpp` 1 +EOF + +ac_header_dirent=$ac_hdr; break +fi + +done +# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. +if test $ac_header_dirent = dirent.h; then + echo "$as_me:2183: checking for opendir in -ldir" >&5 +echo $ECHO_N "checking for opendir in -ldir... $ECHO_C" >&6 +if test "${ac_cv_lib_dir_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldir $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line 2191 "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir (); +int +main () +{ +opendir (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:2210: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:2213: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:2216: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2219: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dir_opendir=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_dir_opendir=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:2230: result: $ac_cv_lib_dir_opendir" >&5 +echo "${ECHO_T}$ac_cv_lib_dir_opendir" >&6 +if test $ac_cv_lib_dir_opendir = yes; then + LIBS="$LIBS -ldir" +fi + +else + echo "$as_me:2237: checking for opendir in -lx" >&5 +echo $ECHO_N "checking for opendir in -lx... $ECHO_C" >&6 +if test "${ac_cv_lib_x_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lx $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line 2245 "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir (); +int +main () +{ +opendir (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:2264: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:2267: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:2270: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2273: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_x_opendir=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_x_opendir=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:2284: result: $ac_cv_lib_x_opendir" >&5 +echo "${ECHO_T}$ac_cv_lib_x_opendir" >&6 +if test $ac_cv_lib_x_opendir = yes; then + LIBS="$LIBS -lx" +fi + +fi + +for ac_header in unistd.h +do +ac_ac_Header=`echo "ac_cv_header_$ac_header" | $ac_tr_sh` +echo "$as_me:2295: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$ac_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 2301 "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:2305: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:2311: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + eval "$ac_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + eval "$ac_ac_Header=no" +fi +rm -f conftest.err conftest.$ac_ext +fi +echo "$as_me:2330: result: `eval echo '${'$ac_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$ac_ac_Header'}'`" >&6 +if test `eval echo '${'$ac_ac_Header'}'` = yes; then + cat >>confdefs.h <<EOF +#define `echo "HAVE_$ac_header" | $ac_tr_cpp` 1 +EOF + +fi +done + +for ac_header in sys/stat.h +do +ac_ac_Header=`echo "ac_cv_header_$ac_header" | $ac_tr_sh` +echo "$as_me:2343: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$ac_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 2349 "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:2353: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:2359: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + eval "$ac_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + eval "$ac_ac_Header=no" +fi +rm -f conftest.err conftest.$ac_ext +fi +echo "$as_me:2378: result: `eval echo '${'$ac_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$ac_ac_Header'}'`" >&6 +if test `eval echo '${'$ac_ac_Header'}'` = yes; then + cat >>confdefs.h <<EOF +#define `echo "HAVE_$ac_header" | $ac_tr_cpp` 1 +EOF + +fi +done + +for ac_func in pipe +do +ac_ac_var=`echo "ac_cv_func_$ac_func" | $ac_tr_sh` +echo "$as_me:2391: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$ac_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 2397 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +char (*f) (); + +int +main () +{ +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +f = $ac_func; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:2428: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:2431: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:2434: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2437: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$ac_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$ac_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:2447: result: `eval echo '${'$ac_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$ac_ac_var'}'`" >&6 +if test `eval echo '${'$ac_ac_var'}'` = yes; then + cat >>confdefs.h <<EOF +#define `echo "HAVE_$ac_func" | $ac_tr_cpp` 1 +EOF + +cat >>confdefs.h <<\EOF +#define HAVE_PIPE 1 +EOF + +fi +done + +for ac_func in connect +do +ac_ac_var=`echo "ac_cv_func_$ac_func" | $ac_tr_sh` +echo "$as_me:2464: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$ac_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 2470 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +char (*f) (); + +int +main () +{ +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +f = $ac_func; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:2501: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:2504: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:2507: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2510: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$ac_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$ac_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:2520: result: `eval echo '${'$ac_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$ac_ac_var'}'`" >&6 +if test `eval echo '${'$ac_ac_var'}'` = yes; then + cat >>confdefs.h <<EOF +#define `echo "HAVE_$ac_func" | $ac_tr_cpp` 1 +EOF + +fi +done + +if test x"$ac_cv_func_connect" = x"no"; then + if test -z "$libsocket"; then + echo "$as_me:2532: checking for socket in -lsocket" >&5 +echo $ECHO_N "checking for socket in -lsocket... $ECHO_C" >&6 +if test "${ac_cv_lib_socket_socket+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsocket $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line 2540 "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char socket (); +int +main () +{ +socket (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:2559: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:2562: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:2565: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2568: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_socket_socket=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_socket_socket=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:2579: result: $ac_cv_lib_socket_socket" >&5 +echo "${ECHO_T}$ac_cv_lib_socket_socket" >&6 +if test $ac_cv_lib_socket_socket = yes; then + LIBS="$LIBS -lsocket" +fi + + fi + + if test -z "$libinet"; then + echo "$as_me:2588: checking for socket in -linet" >&5 +echo $ECHO_N "checking for socket in -linet... $ECHO_C" >&6 +if test "${ac_cv_lib_inet_socket+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-linet $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line 2596 "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char socket (); +int +main () +{ +socket (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:2615: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:2618: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:2621: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2624: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_inet_socket=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_inet_socket=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:2635: result: $ac_cv_lib_inet_socket" >&5 +echo "${ECHO_T}$ac_cv_lib_inet_socket" >&6 +if test $ac_cv_lib_inet_socket = yes; then + libnsl=1; LIBS="$LIBS -linet -lnsl_s" +fi + + fi + + if test -z "$libnsl"; then + echo "$as_me:2644: checking for gethostname in -lnsl" >&5 +echo $ECHO_N "checking for gethostname in -lnsl... $ECHO_C" >&6 +if test "${ac_cv_lib_nsl_gethostname+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lnsl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line 2652 "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char gethostname (); +int +main () +{ +gethostname (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:2671: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:2674: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:2677: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2680: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_nsl_gethostname=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_nsl_gethostname=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:2691: result: $ac_cv_lib_nsl_gethostname" >&5 +echo "${ECHO_T}$ac_cv_lib_nsl_gethostname" >&6 +if test $ac_cv_lib_nsl_gethostname = yes; then + LIBS="$LIBS -lnsl" +fi + + fi +fi + +echo "$as_me:2700: checking for getpwnam in -lsun" >&5 +echo $ECHO_N "checking for getpwnam in -lsun... $ECHO_C" >&6 +if test "${ac_cv_lib_sun_getpwnam+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsun $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line 2708 "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char getpwnam (); +int +main () +{ +getpwnam (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:2727: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:2730: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:2733: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2736: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_sun_getpwnam=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_sun_getpwnam=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:2747: result: $ac_cv_lib_sun_getpwnam" >&5 +echo "${ECHO_T}$ac_cv_lib_sun_getpwnam" >&6 +if test $ac_cv_lib_sun_getpwnam = yes; then + LIBS="$LIBS -lsun" +fi + +echo "$as_me:2753: checking for inet_addr in -ldgc" >&5 +echo $ECHO_N "checking for inet_addr in -ldgc... $ECHO_C" >&6 +if test "${ac_cv_lib_dgc_inet_addr+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldgc $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line 2761 "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char inet_addr (); +int +main () +{ +inet_addr (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:2780: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:2783: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:2786: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2789: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dgc_inet_addr=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_dgc_inet_addr=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:2800: result: $ac_cv_lib_dgc_inet_addr" >&5 +echo "${ECHO_T}$ac_cv_lib_dgc_inet_addr" >&6 +if test $ac_cv_lib_dgc_inet_addr = yes; then + LIBS="$LIBS -ldgc" +fi + +echo "$as_me:2806: checking for gethostbyname in -lresolv" >&5 +echo $ECHO_N "checking for gethostbyname in -lresolv... $ECHO_C" >&6 +if test "${ac_cv_lib_resolv_gethostbyname+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lresolv $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line 2814 "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char gethostbyname (); +int +main () +{ +gethostbyname (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:2833: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:2836: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:2839: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2842: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_resolv_gethostbyname=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_resolv_gethostbyname=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:2853: result: $ac_cv_lib_resolv_gethostbyname" >&5 +echo "${ECHO_T}$ac_cv_lib_resolv_gethostbyname" >&6 +if test $ac_cv_lib_resolv_gethostbyname = yes; then + LIBS="$LIBS -lresolv" +fi + +# Check whether --with-glib-prefix or --without-glib-prefix was given. +if test "${with_glib_prefix+set}" = set; then + withval="$with_glib_prefix" + glib_config_prefix="$withval" +else + glib_config_prefix="" +fi; + +# Check whether --with-glib-exec-prefix or --without-glib-exec-prefix was given. +if test "${with_glib_exec_prefix+set}" = set; then + withval="$with_glib_exec_prefix" + glib_config_exec_prefix="$withval" +else + glib_config_exec_prefix="" +fi; +# Check whether --enable-glibtest or --disable-glibtest was given. +if test "${enable_glibtest+set}" = set; then + enableval="$enable_glibtest" + +else + enable_glibtest=yes +fi; + + if test x$glib_config_exec_prefix != x ; then + glib_config_args="$glib_config_args --exec-prefix=$glib_config_exec_prefix" + if test x${GLIB_CONFIG+set} != xset ; then + GLIB_CONFIG=$glib_config_exec_prefix/bin/glib-config + fi + fi + if test x$glib_config_prefix != x ; then + glib_config_args="$glib_config_args --prefix=$glib_config_prefix" + if test x${GLIB_CONFIG+set} != xset ; then + GLIB_CONFIG=$glib_config_prefix/bin/glib-config + fi + fi + + for module in . + do + case "$module" in + gmodule) + glib_config_args="$glib_config_args gmodule" + ;; + gthread) + glib_config_args="$glib_config_args gthread" + ;; + esac + done + + # Extract the first word of "glib-config", so it can be a program name with args. +set dummy glib-config; ac_word=$2 +echo "$as_me:2909: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_GLIB_CONFIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $GLIB_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_GLIB_CONFIG="$GLIB_CONFIG" # Let the user override the test with a path. + ;; + *) + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + if $as_executable_p "$ac_dir/$ac_word"; then + ac_cv_path_GLIB_CONFIG="$ac_dir/$ac_word" + echo "$as_me:2926: found $ac_dir/$ac_word" >&5 + { ac_try='$ac_dir/$ac_word --version </dev/null >&2' + { (eval echo "$as_me:2928: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2931: \$? = $ac_status" >&5 + (exit $ac_status); }; } + break +fi +done + + test -z "$ac_cv_path_GLIB_CONFIG" && ac_cv_path_GLIB_CONFIG="no" + ;; +esac +fi +GLIB_CONFIG=$ac_cv_path_GLIB_CONFIG + +if test -n "$GLIB_CONFIG"; then + echo "$as_me:2944: result: $GLIB_CONFIG" >&5 +echo "${ECHO_T}$GLIB_CONFIG" >&6 +else + echo "$as_me:2947: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + min_glib_version=1.2.0 + echo "$as_me:2952: checking for GLIB - version >= $min_glib_version" >&5 +echo $ECHO_N "checking for GLIB - version >= $min_glib_version... $ECHO_C" >&6 + no_glib="" + if test "$GLIB_CONFIG" = "no" ; then + no_glib=yes + else + GLIB_CFLAGS=`$GLIB_CONFIG $glib_config_args --cflags` + GLIB_LIBS=`$GLIB_CONFIG $glib_config_args --libs` + glib_config_major_version=`$GLIB_CONFIG $glib_config_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` + glib_config_minor_version=`$GLIB_CONFIG $glib_config_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` + glib_config_micro_version=`$GLIB_CONFIG $glib_config_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` + if test "x$enable_glibtest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GLIB_CFLAGS" + LIBS="$GLIB_LIBS $LIBS" + rm -f conf.glibtest + if test "$cross_compiling" = yes; then + echo $ac_n "cross compiling; assumed OK... $ac_c" +else + cat >conftest.$ac_ext <<_ACEOF +#line 2976 "configure" +#include "confdefs.h" + +#include <glib.h> +#include <stdio.h> +#include <stdlib.h> + +int +main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.glibtest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_glib_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_glib_version"); + exit(1); + } + + if ((glib_major_version != $glib_config_major_version) || + (glib_minor_version != $glib_config_minor_version) || + (glib_micro_version != $glib_config_micro_version)) + { + printf("\n*** 'glib-config --version' returned %d.%d.%d, but GLIB (%d.%d.%d)\n", + $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version, + glib_major_version, glib_minor_version, glib_micro_version); + printf ("*** was found! If glib-config was correct, then it is best\n"); + printf ("*** to remove the old version of GLIB. 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 glib-config was wrong, set the environment variable GLIB_CONFIG\n"); + printf("*** to point to the correct copy of glib-config, and remove the file config.cache\n"); + printf("*** before re-running configure\n"); + } + else if ((glib_major_version != GLIB_MAJOR_VERSION) || + (glib_minor_version != GLIB_MINOR_VERSION) || + (glib_micro_version != GLIB_MICRO_VERSION)) + { + printf("*** GLIB header files (version %d.%d.%d) do not match\n", + GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION); + printf("*** library (version %d.%d.%d)\n", + glib_major_version, glib_minor_version, glib_micro_version); + } + else + { + if ((glib_major_version > major) || + ((glib_major_version == major) && (glib_minor_version > minor)) || + ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** An old version of GLIB (%d.%d.%d) was found.\n", + glib_major_version, glib_minor_version, glib_micro_version); + printf("*** You need a version of GLIB newer than %d.%d.%d. The latest version of\n", + major, minor, micro); + printf("*** GLIB 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 glib-config shell script is\n"); + printf("*** being found. The easiest way to fix this is to remove the old version\n"); + printf("*** of GLIB, but you can also set the GLIB_CONFIG environment to point to the\n"); + printf("*** correct copy of glib-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + } + return 1; +} + +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:3053: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3056: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:3058: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3061: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +no_glib=yes +fi +rm -f conftest$ac_exeext conftest.$ac_ext +fi + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_glib" = x ; then + echo "$as_me:3077: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + : + else + echo "$as_me:3081: result: no" >&5 +echo "${ECHO_T}no" >&6 + if test "$GLIB_CONFIG" = "no" ; then + echo "*** The glib-config script installed by GLIB could not be found" + echo "*** If GLIB was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the GLIB_CONFIG environment variable to the" + echo "*** full path to glib-config." + else + if test -f conf.glibtest ; then + : + else + echo "*** Could not run GLIB test program, checking why..." + CFLAGS="$CFLAGS $GLIB_CFLAGS" + LIBS="$LIBS $GLIB_LIBS" + cat >conftest.$ac_ext <<_ACEOF +#line 3096 "configure" +#include "confdefs.h" + +#include <glib.h> +#include <stdio.h> + +int +main () +{ + return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:3111: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3114: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:3117: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3120: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding GLIB or finding the wrong" + echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 + echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means GLIB was incorrectly installed" + echo "*** or that you have moved GLIB since it was installed. In the latter case, you" + echo "*** may want to edit the glib-config script: $GLIB_CONFIG" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GLIB_CFLAGS="" + GLIB_LIBS="" + { { echo "$as_me:3146: error: { { echo \"$as_me:3146: error: Cannot find GLIB: Is glib-config in path?\" >&5 +echo \"$as_me: error: Cannot find GLIB: Is glib-config in path?\" >&2;} + { (exit 1); exit 1; }; }" >&5 +echo "$as_me: error: { { echo \"$as_me:3149: error: Cannot find GLIB: Is glib-config in path?\" >&5 +echo \"$as_me: error: Cannot find GLIB: Is glib-config in path?\" >&2;} + { (exit 1); exit 1; }; }" >&2;} + { (exit 1); exit 1; }; } + fi + + rm -f conf.glibtest + +# Check whether --with-gtk-prefix or --without-gtk-prefix was given. +if test "${with_gtk_prefix+set}" = set; then + withval="$with_gtk_prefix" + gtk_config_prefix="$withval" +else + gtk_config_prefix="" +fi; + +# Check whether --with-gtk-exec-prefix or --without-gtk-exec-prefix was given. +if test "${with_gtk_exec_prefix+set}" = set; then + withval="$with_gtk_exec_prefix" + gtk_config_exec_prefix="$withval" +else + gtk_config_exec_prefix="" +fi; +# Check whether --enable-gtktest or --disable-gtktest was given. +if test "${enable_gtktest+set}" = set; then + enableval="$enable_gtktest" + +else + enable_gtktest=yes +fi; + + for module in . gthread + 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+set} != xset ; then + GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config + 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+set} != xset ; then + GTK_CONFIG=$gtk_config_prefix/bin/gtk-config + fi + fi + + # Extract the first word of "gtk-config", so it can be a program name with args. +set dummy gtk-config; ac_word=$2 +echo "$as_me:3204: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_GTK_CONFIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $GTK_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_GTK_CONFIG="$GTK_CONFIG" # Let the user override the test with a path. + ;; + *) + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + if $as_executable_p "$ac_dir/$ac_word"; then + ac_cv_path_GTK_CONFIG="$ac_dir/$ac_word" + echo "$as_me:3221: found $ac_dir/$ac_word" >&5 + { ac_try='$ac_dir/$ac_word --version </dev/null >&2' + { (eval echo "$as_me:3223: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3226: \$? = $ac_status" >&5 + (exit $ac_status); }; } + break +fi +done + + test -z "$ac_cv_path_GTK_CONFIG" && ac_cv_path_GTK_CONFIG="no" + ;; +esac +fi +GTK_CONFIG=$ac_cv_path_GTK_CONFIG + +if test -n "$GTK_CONFIG"; then + echo "$as_me:3239: result: $GTK_CONFIG" >&5 +echo "${ECHO_T}$GTK_CONFIG" >&6 +else + echo "$as_me:3242: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + min_gtk_version=1.2.0 + echo "$as_me:3247: checking for GTK - version >= $min_gtk_version" >&5 +echo $ECHO_N "checking for GTK - version >= $min_gtk_version... $ECHO_C" >&6 + no_gtk="" + if test "$GTK_CONFIG" = "no" ; then + no_gtk=yes + else + GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags` + GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs` + gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` + gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` + gtk_config_micro_version=`$GTK_CONFIG $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" + rm -f conf.gtktest + if test "$cross_compiling" = yes; then + echo $ac_n "cross compiling; assumed OK... $ac_c" +else + cat >conftest.$ac_ext <<_ACEOF +#line 3271 "configure" +#include "confdefs.h" + +#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, µ) != 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 --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 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 was wrong, set the environment variable GTK_CONFIG\n"); + printf("*** to point to the correct copy of gtk-config, 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 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 environment to point to the\n"); + printf("*** correct copy of gtk-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + } + return 1; +} + +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:3350: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3353: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:3355: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3358: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +no_gtk=yes +fi +rm -f conftest$ac_exeext conftest.$ac_ext +fi + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_gtk" = x ; then + echo "$as_me:3374: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + : + else + echo "$as_me:3378: result: no" >&5 +echo "${ECHO_T}no" >&6 + if test "$GTK_CONFIG" = "no" ; then + echo "*** The gtk-config 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 environment variable to the" + echo "*** full path to gtk-config." + 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" + cat >conftest.$ac_ext <<_ACEOF +#line 3393 "configure" +#include "confdefs.h" + +#include <gtk/gtk.h> +#include <stdio.h> + +int +main () +{ + return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:3408: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3411: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:3414: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3417: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding GTK or finding the wrong" + echo "*** version of GTK. If it is not finding GTK, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 + 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 script: $GTK_CONFIG" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GTK_CFLAGS="" + GTK_LIBS="" + { { echo "$as_me:3443: error: { { echo \"$as_me:3443: error: Cannot find GTK: Is gtk-config in path?\" >&5 +echo \"$as_me: error: Cannot find GTK: Is gtk-config in path?\" >&2;} + { (exit 1); exit 1; }; }" >&5 +echo "$as_me: error: { { echo \"$as_me:3446: error: Cannot find GTK: Is gtk-config in path?\" >&5 +echo \"$as_me: error: Cannot find GTK: Is gtk-config in path?\" >&2;} + { (exit 1); exit 1; }; }" >&2;} + { (exit 1); exit 1; }; } + fi + + rm -f conf.gtktest + +echo "$as_me:3454: checking for pthread.h" >&5 +echo $ECHO_N "checking for pthread.h... $ECHO_C" >&6 +if test "${ac_cv_header_pthread_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 3460 "configure" +#include "confdefs.h" +#include <pthread.h> +_ACEOF +if { (eval echo "$as_me:3464: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:3470: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_cv_header_pthread_h=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_header_pthread_h=no +fi +rm -f conftest.err conftest.$ac_ext +fi +echo "$as_me:3489: result: $ac_cv_header_pthread_h" >&5 +echo "${ECHO_T}$ac_cv_header_pthread_h" >&6 +if test $ac_cv_header_pthread_h = yes; then + : +else + { { echo "$as_me:3494: error: pthread header not found. Dynamic Windows cannot build without it." >&5 +echo "$as_me: error: pthread header not found. Dynamic Windows cannot build without it." >&2;} + { (exit 1); exit 1; }; } +fi + +echo "$as_me:3499: checking for pthread_attr_init in -lpthread" >&5 +echo $ECHO_N "checking for pthread_attr_init in -lpthread... $ECHO_C" >&6 +if test "${ac_cv_lib_pthread_pthread_attr_init+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpthread $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line 3507 "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char pthread_attr_init (); +int +main () +{ +pthread_attr_init (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:3526: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3529: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:3532: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3535: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_pthread_pthread_attr_init=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_pthread_pthread_attr_init=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:3546: result: $ac_cv_lib_pthread_pthread_attr_init" >&5 +echo "${ECHO_T}$ac_cv_lib_pthread_pthread_attr_init" >&6 +if test $ac_cv_lib_pthread_pthread_attr_init = yes; then + PTHREAD_LIBS="-lpthread" +else + echo "$as_me:3551: checking for pthread_attr_init in -lpthreads" >&5 +echo $ECHO_N "checking for pthread_attr_init in -lpthreads... $ECHO_C" >&6 +if test "${ac_cv_lib_pthreads_pthread_attr_init+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpthreads $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line 3559 "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char pthread_attr_init (); +int +main () +{ +pthread_attr_init (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:3578: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3581: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:3584: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3587: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_pthreads_pthread_attr_init=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_pthreads_pthread_attr_init=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:3598: result: $ac_cv_lib_pthreads_pthread_attr_init" >&5 +echo "${ECHO_T}$ac_cv_lib_pthreads_pthread_attr_init" >&6 +if test $ac_cv_lib_pthreads_pthread_attr_init = yes; then + PTHREAD_LIBS="-lpthreads" +else + echo "$as_me:3603: checking for pthread_attr_init in -lc_r" >&5 +echo $ECHO_N "checking for pthread_attr_init in -lc_r... $ECHO_C" >&6 +if test "${ac_cv_lib_c_r_pthread_attr_init+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lc_r $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line 3611 "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char pthread_attr_init (); +int +main () +{ +pthread_attr_init (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:3630: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3633: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:3636: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3639: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_c_r_pthread_attr_init=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_c_r_pthread_attr_init=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:3650: result: $ac_cv_lib_c_r_pthread_attr_init" >&5 +echo "${ECHO_T}$ac_cv_lib_c_r_pthread_attr_init" >&6 +if test $ac_cv_lib_c_r_pthread_attr_init = yes; then + PTHREAD_LIBS="-lc_r" +else + { { echo "$as_me:3655: error: pthread library not found. HandyFTP cannot build without it. + " >&5 +echo "$as_me: error: pthread library not found. HandyFTP cannot build without it. + " >&2;} + { (exit 1); exit 1; }; } + +fi + +fi + +fi + +# Check whether --with-imlib-prefix or --without-imlib-prefix was given. +if test "${with_imlib_prefix+set}" = set; then + withval="$with_imlib_prefix" + imlib_prefix="$withval" +else + imlib_prefix="" +fi; + +# Check whether --with-imlib-exec-prefix or --without-imlib-exec-prefix was given. +if test "${with_imlib_exec_prefix+set}" = set; then + withval="$with_imlib_exec_prefix" + imlib_exec_prefix="$withval" +else + imlib_exec_prefix="" +fi; +# Check whether --enable-imlibtest or --disable-imlibtest was given. +if test "${enable_imlibtest+set}" = set; then + enableval="$enable_imlibtest" + +else + enable_imlibtest=yes +fi; + + if test x$imlib_exec_prefix != x ; then + imlib_args="$imlib_args --exec-prefix=$imlib_exec_prefix" + if test x${IMLIB_CONFIG+set} != xset ; then + IMLIB_CONFIG=$imlib_exec_prefix/bin/imlib-config + fi + fi + if test x$imlib_prefix != x ; then + imlib_args="$imlib_args --prefix=$imlib_prefix" + if test x${IMLIB_CONFIG+set} != xset ; then + IMLIB_CONFIG=$imlib_prefix/bin/imlib-config + fi + fi + + # Extract the first word of "imlib-config", so it can be a program name with args. +set dummy imlib-config; ac_word=$2 +echo "$as_me:3705: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_IMLIB_CONFIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $IMLIB_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_IMLIB_CONFIG="$IMLIB_CONFIG" # Let the user override the test with a path. + ;; + *) + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + if $as_executable_p "$ac_dir/$ac_word"; then + ac_cv_path_IMLIB_CONFIG="$ac_dir/$ac_word" + echo "$as_me:3722: found $ac_dir/$ac_word" >&5 + { ac_try='$ac_dir/$ac_word --version </dev/null >&2' + { (eval echo "$as_me:3724: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3727: \$? = $ac_status" >&5 + (exit $ac_status); }; } + break +fi +done + + test -z "$ac_cv_path_IMLIB_CONFIG" && ac_cv_path_IMLIB_CONFIG="no" + ;; +esac +fi +IMLIB_CONFIG=$ac_cv_path_IMLIB_CONFIG + +if test -n "$IMLIB_CONFIG"; then + echo "$as_me:3740: result: $IMLIB_CONFIG" >&5 +echo "${ECHO_T}$IMLIB_CONFIG" >&6 +else + echo "$as_me:3743: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + min_imlib_version=1.9.4 + echo "$as_me:3748: checking for IMLIB - version >= $min_imlib_version" >&5 +echo $ECHO_N "checking for IMLIB - version >= $min_imlib_version... $ECHO_C" >&6 + no_imlib="" + if test "$IMLIB_CONFIG" = "no" ; then + no_imlib=yes + else + GDK_IMLIB_CFLAGS=`$IMLIB_CONFIG $imlibconf_args --cflags-gdk` + GDK_IMLIB_LIBS=`$IMLIB_CONFIG $imlibconf_args --libs-gdk` + + imlib_major_version=`$IMLIB_CONFIG $imlib_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` + imlib_minor_version=`$IMLIB_CONFIG $imlib_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` + imlib_micro_version=`$IMLIB_CONFIG $imlib_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` + if test "x$enable_imlibtest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GDK_IMLIB_CFLAGS" + LIBS="$LIBS $GDK_IMLIB_LIBS" + rm -f conf.imlibtest + if test "$cross_compiling" = yes; then + echo $ac_n "cross compiling; assumed OK... $ac_c" +else + cat >conftest.$ac_ext <<_ACEOF +#line 3773 "configure" +#include "confdefs.h" + +#include <stdio.h> +#include <stdlib.h> +#include <gdk_imlib.h> + +int main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.gdkimlibtest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_imlib_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_imlib_version"); + exit(1); + } + + if (($imlib_major_version > major) || + (($imlib_major_version == major) && ($imlib_minor_version > minor)) || + (($imlib_major_version == major) && ($imlib_minor_version == minor) && + ($imlib_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'imlib-config --version' returned %d.%d.%d, but the minimum version\n", $imlib_major_version, $imlib_minor_version, $imlib_micro_version); + printf("*** of IMLIB required is %d.%d.%d. If imlib-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If imlib-config was wrong, set the environment variable IMLIB_CONFIG\n"); + printf("*** to point to the correct copy of imlib-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:3815: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3818: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:3820: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3823: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +no_imlib=yes +fi +rm -f conftest$ac_exeext conftest.$ac_ext +fi + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_imlib" = x ; then + echo "$as_me:3839: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + cat >>confdefs.h <<\EOF +#define USE_IMLIB 1 +EOF + + else + echo "$as_me:3846: result: no" >&5 +echo "${ECHO_T}no" >&6 + if test "$IMLIB_CONFIG" = "no" ; then + echo "*** The imlib-config script installed by IMLIB could not be found" + echo "*** If IMLIB was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the IMLIB_CONFIG environment variable to the" + echo "*** full path to imlib-config." + else + if test -f conf.gdkimlibtest ; then + : + else + echo "*** Could not run IMLIB test program, checking why..." + CFLAGS="$CFLAGS $GDK_IMLIB_CFLAGS" + LIBS="$LIBS $GDK_IMLIB_LIBS" + cat >conftest.$ac_ext <<_ACEOF +#line 3861 "configure" +#include "confdefs.h" + +#include <stdio.h> +#include <gdk_imlib.h> + +int +main () +{ + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:3876: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3879: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:3882: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3885: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding IMLIB or finding the wrong" + echo "*** version of IMLIB. If it is not finding IMLIB, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 + echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means IMLIB was incorrectly installed" + echo "*** or that you have moved IMLIB since it was installed. In the latter case, you" + echo "*** may want to edit the imlib-config script: $IMLIB_CONFIG" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GDK_IMLIB_CFLAGS="" + GDK_IMLIB_LIBS="" + { { echo "$as_me:3911: error: IMLIB not found or too old. Dynamic Windows cannot build without it." >&5 +echo "$as_me: error: IMLIB not found or too old. Dynamic Windows cannot build without it." >&2;} + { (exit 1); exit 1; }; } + fi + + rm -f conf.gdkimlibtest + +CFLAGS="$CFLAGS $GTK_CFLAGS $GDK_IMLIB_FLAGS" +LIBS="$LIBS $GTK_LIBS $PTHREAD_LIBS $GDK_IMLIB_LIBS" + +RM="rm -f" +LN="ln -s" +CP="cp" +MV="mv" +MKDIR="mkdir" + +ac_config_files="$ac_config_files Makefile:Makefile.in" +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overriden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$ac_cr_alnum]*_cv_[_$ac_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n \ + "s/^\\([_$ac_cr_alnum]*_cv_[_$ac_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if cmp -s $cache_file confcache; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' +fi + +DEFS=-DHAVE_CONFIG_H + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:4007: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated automatically by configure. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +SHELL=\${CONFIG_SHELL-$SHELL} +ac_cs_invocation="\$0 \$@" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# Name of the executable. +as_me=`echo "$0" |sed 's,.*[\\/],,'` + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +as_executable_p="test -f" + +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + +# NLS nuisances. +$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; } +$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; } +$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; } +$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; } +$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; } +$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; } +$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; } +$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; } + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; } + +exec 6>&1 + +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\EOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Report bugs to <bug-autoconf@gnu.org>." +EOF + +cat >>$CONFIG_STATUS <<EOF +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.49e, + with options \"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\" + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +INSTALL="$INSTALL" +EOF + +cat >>$CONFIG_STATUS <<\EOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + shift + set dummy "$ac_option" "$ac_optarg" ${1+"$@"} + shift + ;; + -*);; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_need_defaults=false;; + esac + + case $1 in + # Handling of the options. +EOF +cat >>$CONFIG_STATUS <<EOF + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running $SHELL $0 " $ac_configure_args " --no-create --no-recursion" + exec $SHELL $0 $ac_configure_args --no-create --no-recursion ;; +EOF +cat >>$CONFIG_STATUS <<\EOF + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:4180: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + shift + CONFIG_FILES="$CONFIG_FILES $1" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + shift + CONFIG_HEADERS="$CONFIG_HEADERS $1" + ac_need_defaults=false;; + + # Handling of arguments. + 'Makefile' ) CONFIG_FILES="$CONFIG_FILES Makefile:Makefile.in" ;; + 'config.h' ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + + # This is an error. + -*) { { echo "$as_me:4203: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + *) { { echo "$as_me:4208: error: invalid argument: $1" >&5 +echo "$as_me: error: invalid argument: $1" >&2;} + { (exit 1); exit 1; }; };; + esac + shift +done + +exec 5>>config.log +cat >&5 << _ACEOF + +## ----------------------- ## +## Running config.status. ## +## ----------------------- ## + +This file was extended by $as_me 2.49e, executed with + > $ac_cs_invocation +on `(hostname || uname -n) 2>/dev/null | sed 1q` + +_ACEOF +EOF + +cat >>$CONFIG_STATUS <<\EOF +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers +fi + +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit $?); exit $?; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. +: ${TMPDIR=/tmp} +{ + tmp=`(umask 077 && mktemp -d -q "$TMPDIR/csXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=$TMPDIR/cs$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in $TMPDIR" >&2 + { (exit 1); exit 1; } +} + +EOF + +cat >>$CONFIG_STATUS <<EOF + +# +# CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@DEFS@,$DEFS,;t t +s,@LIBS@,$LIBS,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@MAKE@,$MAKE,;t t +s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s,@INSTALL_DATA@,$INSTALL_DATA,;t t +s,@CPP@,$CPP,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@GLIB_CONFIG@,$GLIB_CONFIG,;t t +s,@GLIB_CFLAGS@,$GLIB_CFLAGS,;t t +s,@GLIB_LIBS@,$GLIB_LIBS,;t t +s,@GTK_CONFIG@,$GTK_CONFIG,;t t +s,@GTK_CFLAGS@,$GTK_CFLAGS,;t t +s,@GTK_LIBS@,$GTK_LIBS,;t t +s,@IMLIB_CONFIG@,$IMLIB_CONFIG,;t t +s,@GDK_IMLIB_CFLAGS@,$GDK_IMLIB_CFLAGS,;t t +s,@GDK_IMLIB_LIBS@,$GDK_IMLIB_LIBS,;t t +s,@INCLUDES@,$INCLUDES,;t t +s,@RM@,$RM,;t t +s,@LN@,$LN,;t t +s,@CP@,$CP,;t t +s,@MV@,$MV,;t t +s,@MKDIR@,$MKDIR,;t t +CEOF + +EOF + + cat >>$CONFIG_STATUS <<\EOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat + fi +fi # test -n "$CONFIG_FILES" + +EOF +cat >>$CONFIG_STATUS <<\EOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + { case "$ac_dir" in + [\\/]* | ?:[\\/]* ) as_incr_dir=;; + *) as_incr_dir=.;; +esac +as_dummy="$ac_dir" +for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do + case $as_mkdir_dir in + # Skip DOS drivespec + ?:) as_incr_dir=$as_mkdir_dir ;; + *) + as_incr_dir=$as_incr_dir/$as_mkdir_dir + test -d "$as_incr_dir" || mkdir "$as_incr_dir" + ;; + esac +done; } + + ac_dir_suffix="/`echo $ac_dir|sed 's,^\./,,'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo "$ac_dir_suffix" | sed 's,/[^/]*,../,g'` + else + ac_dir_suffix= ac_dots= + fi + + case $srcdir in + .) ac_srcdir=. + if test -z "$ac_dots"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_dots | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_dots$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_dots$srcdir ;; + esac + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_dots$INSTALL ;; + esac + + if test x"$ac_file" != x-; then + { echo "$as_me:4443: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated automatically by config.status. */ + configure_input="Generated automatically from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:4461: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo $f;; + *) # Relative + if test -f "$f"; then + # Build tree + echo $f + elif test -f "$srcdir/$f"; then + # Source tree + echo $srcdir/$f + else + # /dev/null tree + { { echo "$as_me:4474: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } +EOF +cat >>$CONFIG_STATUS <<EOF + sed "$ac_vpsub +$extrasub +EOF +cat >>$CONFIG_STATUS <<\EOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;t t +s,@srcdir@,$ac_srcdir,;t t +s,@top_srcdir@,$ac_top_srcdir,;t t +s,@INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + +done +EOF +cat >>$CONFIG_STATUS <<\EOF + +# +# CONFIG_HEADER section. +# + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='[ ].*$,\1#\2' +ac_dC=' ' +ac_dD=',;t' +# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='$,\1#\2define\3' +ac_uC=' ' +ac_uD=',;t' + +for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + test x"$ac_file" != x- && { echo "$as_me:4535: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:4546: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo $f;; + *) # Relative + if test -f "$f"; then + # Build tree + echo $f + elif test -f "$srcdir/$f"; then + # Source tree + echo $srcdir/$f + else + # /dev/null tree + { { echo "$as_me:4559: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + # Remove the trailing spaces. + sed 's/[ ]*$//' $ac_file_inputs >$tmp/in + +EOF + +# Transform confdefs.h into two sed scripts, `conftest.defines' and +# `conftest.undefs', that substitutes the proper values into +# config.h.in to produce config.h. The first handles `#define' +# templates, and the second `#undef' templates. +# And first: Protect against being on the right side of a sed subst in +# config.status. Protect against being in an unquoted here document +# in config.status. +rm -f conftest.defines conftest.undefs +# Using a here document instead of a string reduces the quoting nightmare. +# Putting comments in sed scripts is not portable. +# +# `end' is used to avoid that the second main sed command (meant for +# 0-ary CPP macros) applies to n-ary macro definitions. +# See the Autoconf documentation for `clear'. +cat >confdef2sed.sed <<\EOF +s/[\\&,]/\\&/g +s,[\\$`],\\&,g +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\(\([^ (][^ (]*\)([^)]*)\)[ ]*\(.*\)$,${ac_dA}\2${ac_dB}\1${ac_dC}\3${ac_dD},gp +t end +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp +: end +EOF +# If some macros were called several times there might be several times +# the same #defines, which is useless. Nevertheless, we may not want to +# sort them, since we want the *last* AC-DEFINE to be honored. +uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines +sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs +rm -f confdef2sed.sed + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >>conftest.undefs <<\EOF +s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, +EOF + +# Break up conftest.defines because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS +echo ' if egrep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS +echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS +echo ' :' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.defines >/dev/null +do + # Write a limited-size here document to $tmp/defines.sed. + echo ' cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS + # Speed up: don't consider the non `#define' lines. + echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/defines.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines +echo ' fi # egrep' >>$CONFIG_STATUS +echo >>$CONFIG_STATUS + +# Break up conftest.undefs because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #undef templates' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.undefs >/dev/null +do + # Write a limited-size here document to $tmp/undefs.sed. + echo ' cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS + # Speed up: don't consider the non `#undef' + echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/undefs.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail + rm -f conftest.undefs + mv conftest.tail conftest.undefs +done +rm -f conftest.undefs + +cat >>$CONFIG_STATUS <<\EOF + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated automatically by config.status. */ + if test x"$ac_file" = x-; then + echo "/* Generated automatically by configure. */" >$tmp/config.h + else + echo "/* $ac_file. Generated automatically by configure. */" >$tmp/config.h + fi + cat $tmp/in >>$tmp/config.h + rm -f $tmp/in + if test x"$ac_file" != x-; then + if cmp -s $ac_file $tmp/config.h 2>/dev/null; then + { echo "$as_me:4676: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + { case "$ac_dir" in + [\\/]* | ?:[\\/]* ) as_incr_dir=;; + *) as_incr_dir=.;; +esac +as_dummy="$ac_dir" +for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do + case $as_mkdir_dir in + # Skip DOS drivespec + ?:) as_incr_dir=$as_mkdir_dir ;; + *) + as_incr_dir=$as_incr_dir/$as_mkdir_dir + test -d "$as_incr_dir" || mkdir "$as_incr_dir" + ;; + esac +done; } + + fi + rm -f $ac_file + mv $tmp/config.h $ac_file + fi + else + cat $tmp/config.h + rm -f $tmp/config.h + fi +done +EOF + +cat >>$CONFIG_STATUS <<\EOF + +{ (exit 0); exit 0; } +EOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + exec 5>/dev/null + $SHELL $CONFIG_STATUS || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/configure.in Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,76 @@ +AC_INIT(winmain.c) +AC_CONFIG_HEADER(config.h) + +INCLUDES="-I." + +AC_PROG_CC + +AC_CHECK_PROG(MAKE, gmake, gmake) +if test x"$MAKE" = x; then + AC_CHECK_PROG(MAKE, make, make) +fi + +AC_PROG_INSTALL + +AC_SUBST(MAKE) + +AC_HEADER_STDC +AC_HEADER_DIRENT +AC_CHECK_HEADERS(unistd.h) +AC_CHECK_HEADERS(sys/stat.h) + +AC_CHECK_FUNCS(pipe, AC_DEFINE(HAVE_PIPE,1,Determine whether we have the pipe function)) + +AC_CHECK_FUNCS(connect) +if test x"$ac_cv_func_connect" = x"no"; then + if test -z "$libsocket"; then + AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket",) + fi + + dnl this is for isc. need the nsl_s library as well. + if test -z "$libinet"; then + AC_CHECK_LIB(inet, socket, libnsl=1; LIBS="$LIBS -linet -lnsl_s",) + fi + + if test -z "$libnsl"; then + AC_CHECK_LIB(nsl, gethostname, LIBS="$LIBS -lnsl",) + fi +fi + +AC_CHECK_LIB(sun, getpwnam, LIBS="$LIBS -lsun",) +AC_CHECK_LIB(dgc, inet_addr, LIBS="$LIBS -ldgc",) +AC_CHECK_LIB(resolv, gethostbyname, LIBS="$LIBS -lresolv",) + +AM_PATH_GLIB(1.2.0,,AC_MSG_ERROR(AC_MSG_ERROR(Cannot find GLIB: Is glib-config in path?))) +AM_PATH_GTK(1.2.0,,AC_MSG_ERROR(AC_MSG_ERROR(Cannot find GTK: Is gtk-config in path?)), gthread) + +AC_CHECK_HEADER(pthread.h,,AC_MSG_ERROR([pthread header not found. Dynamic Windows cannot build without it.])) +AC_CHECK_LIB(pthread, pthread_attr_init, PTHREAD_LIBS="-lpthread", +AC_CHECK_LIB(pthreads, pthread_attr_init, PTHREAD_LIBS="-lpthreads", + AC_CHECK_LIB(c_r, pthread_attr_init, PTHREAD_LIBS="-lc_r", + AC_MSG_ERROR(pthread library not found. HandyFTP cannot build without it. + ) + ) + ) +) + +AM_PATH_GDK_IMLIB(1.9.4, AC_DEFINE(USE_IMLIB), AC_MSG_ERROR(IMLIB not found or too old. Dynamic Windows cannot build without it.)) + +CFLAGS="$CFLAGS $GTK_CFLAGS $GDK_IMLIB_FLAGS" +LIBS="$LIBS $GTK_LIBS $PTHREAD_LIBS $GDK_IMLIB_LIBS" + +RM="rm -f" +LN="ln -s" +CP="cp" +MV="mv" +MKDIR="mkdir" + + +AC_SUBST(INCLUDES) +AC_SUBST(RM) +AC_SUBST(LN) +AC_SUBST(CP) +AC_SUBST(MV) +AC_SUBST(MKDIR) + +AC_OUTPUT(Makefile:Makefile.in) \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dirent.h Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,181 @@ +#ifdef OS2 +#ifndef __DIRENT_H__ +#define __DIRENT_H__ + +#ifdef __EMX__ +#include <sys/param.h> +#else +#if defined(__IBMC__) || defined(__IBMCPP__) || defined(XP_W32_MSVC) +#include <stdio.h> +#ifdef MAXPATHLEN + #undef MAXPATHLEN +#endif +#define MAXPATHLEN (FILENAME_MAX*4) +#define MAXNAMLEN FILENAME_MAX + +#else +#include <param.h> +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* attribute stuff */ +#ifndef A_RONLY +# define A_RONLY 0x01 +# define A_HIDDEN 0x02 +# define A_SYSTEM 0x04 +# define A_LABEL 0x08 +# define A_DIR 0x10 +# define A_ARCHIVE 0x20 +#endif + +struct dirent { +#if defined(OS2) || defined(WIN32) /* use the layout of EMX to avoid trouble */ + int d_ino; /* Dummy */ + int d_reclen; /* Dummy, same as d_namlen */ + int d_namlen; /* length of name */ + char d_name[MAXNAMLEN + 1]; + unsigned long d_size; + unsigned short d_attribute; /* attributes (see above) */ + unsigned short d_time; /* modification time */ + unsigned short d_date; /* modification date */ +#else + char d_name[MAXNAMLEN + 1]; /* garentee null termination */ + char d_attribute; /* .. extension .. */ + unsigned long d_size; /* .. extension .. */ +#endif +}; + +typedef struct _dirdescr DIR; +/* the structs do not have to be defined here */ + +extern DIR *opendir(const char *); +extern DIR *openxdir(const char *, unsigned); +extern struct dirent *readdir(DIR *); +extern void seekdir(DIR *, long); +extern long telldir(DIR *); +extern void closedir(DIR *); +#define rewinddir(dirp) seekdir(dirp, 0L) + +extern char * abs_path(const char *name, char *buffer, int len); + +#ifndef S_IFMT +#define S_IFMT ( S_IFDIR | S_IFREG ) +#endif + +#ifndef S_ISDIR +#define S_ISDIR( m ) (((m) & S_IFMT) == S_IFDIR) +#endif + +#ifndef S_ISREG +#define S_ISREG( m ) (((m) & S_IFMT) == S_IFREG) +#endif + +#ifdef __cplusplus +} +#endif + +#endif +#endif + +#ifdef WIN32 +#ifndef __DIRENT_H__ +#define __DIRENT_H__ +/* + * @(#)msd_dir.h 1.4 87/11/06 Public Domain. + * + * A public domain implementation of BSD directory routines for + * MS-DOS. Written by Michael Rendell ({uunet,utai}michael@garfield), + * August 1897 + * + * Extended by Peter Lim (lim@mullian.oz) to overcome some MS DOS quirks + * and returns 2 more pieces of information - file size & attribute. + * Plus a little reshuffling of some #define's positions December 1987 + * + * Some modifications by Martin Junius 02-14-89 + * + * AK900712 + * AK910410 abs_path - make absolute path + * + */ + +#ifdef __EMX__ +#include <sys/param.h> +#else +#if defined(__IBMC__) || defined(__IBMCPP__) || defined(MSVC) +#include <stdio.h> +#ifdef MAXPATHLEN + #undef MAXPATHLEN +#endif +#define MAXPATHLEN (FILENAME_MAX*4) +#define MAXNAMLEN FILENAME_MAX +#else +#include <param.h> +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* attribute stuff */ +#ifndef A_RONLY +# define A_RONLY 0x01 +# define A_HIDDEN 0x02 +# define A_SYSTEM 0x04 +# define A_LABEL 0x08 +# define A_DIR 0x10 +# define A_ARCHIVE 0x20 +#endif + +struct dirent { +#if defined(OS2) || defined(WIN32) /* use the layout of EMX to avoid trouble */ + int d_ino; /* Dummy */ + int d_reclen; /* Dummy, same as d_namlen */ + int d_namlen; /* length of name */ + char d_name[MAXNAMLEN + 1]; + unsigned long d_size; + unsigned short d_attribute; /* attributes (see above) */ + unsigned short d_time; /* modification time */ + unsigned short d_date; /* modification date */ +#else + char d_name[MAXNAMLEN + 1]; /* garentee null termination */ + char d_attribute; /* .. extension .. */ + unsigned long d_size; /* .. extension .. */ +#endif +}; + +typedef struct _dirdescr DIR; +/* the structs do not have to be defined here */ + +extern DIR *opendir(const char *); +extern DIR *openxdir(const char *, unsigned); +extern struct dirent *readdir(DIR *); +extern void seekdir(DIR *, long); +extern long telldir(DIR *); +extern void closedir(DIR *); +#define rewinddir(dirp) seekdir(dirp, 0L) + +extern char * abs_path(const char *name, char *buffer, int len); + +#ifndef S_IFMT +#define S_IFMT ( S_IFDIR | S_IFREG ) +#endif + +#ifndef S_ISDIR +#define S_ISDIR( m ) (((m) & S_IFMT) == S_IFDIR) +#endif + +#ifndef S_ISREG +#define S_ISREG( m ) (((m) & S_IFMT) == S_IFREG) +#endif + +#ifdef __cplusplus +} +#endif + +#endif +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dw.def Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,186 @@ +LIBRARY DW INITINSTANCE TERMINSTANCE + +PROTMODE + +DESCRIPTION 'Dynamic Windows for OS/2' + +CODE LOADONCALL +DATA NONSHARED LOADONCALL + +EXPORTS + dw_init @10 + dw_main @11 + dw_exit @12 + dw_beep @13 + dw_messagebox @14 + dw_yesno @15 + dw_environment_query @16 + dw_exec @17 + dw_browse @18 + dw_file_browse @19 + dw_user_dir @20 + dw_flush @21 + dw_free @22 + + dw_box_new @40 + dw_groupbox_new @41 + dw_box_pack_start @42 + dw_box_pack_end @43 + dw_box_pack_splitbar_start @44 + dw_box_pack_splitbar_end @45 + + dw_window_new @50 + dw_window_show @51 + dw_window_hide @52 + dw_window_destroy @53 + dw_window_set_font @54 + dw_window_set_color @55 + dw_window_set_pos @56 + dw_window_set_usize @57 + dw_window_set_pos_size @58 + dw_window_get_pos_size @59 + dw_window_set_style @60 + dw_window_set_icon @61 + dw_window_set_bitmap @62 + dw_window_get_text @63 + dw_window_set_text @64 + dw_window_disable @65 + dw_window_enable @66 + dw_window_capture @67 + dw_window_release @68 + dw_window_reparent @69 + dw_window_function @70 + dw_window_from_id @71 + dw_window_set_border @72 + + dw_bitmap_new @80 + + dw_button_new @90 + dw_bitmapbutton_new @91 + + dw_text_new @100 + + dw_entryfield_new @110 + dw_entryfield_password_new @111 + + dw_combobox_new @120 + + dw_radiobutton_new @130 + + dw_listbox_new @140 + dw_listbox_append @141 + dw_listbox_clear @142 + dw_listbox_count @143 + dw_listbox_set_top @144 + dw_listbox_select @145 + dw_listbox_delete @146 + dw_listbox_query_text @147 + dw_listbox_set_text @148 + dw_listbox_selected @149 + dw_listbox_selected_multi @150 + + dw_slider_new @160 + dw_slider_query_range @161 + dw_slider_set_pos @162 + + dw_mle_new @170 + dw_mle_import @171 + dw_mle_export @172 + dw_mle_query @173 + dw_mle_delete @174 + dw_mle_clear @175 + dw_mle_freeze @176 + dw_mle_thaw @177 + dw_mle_set @178 + dw_mle_set_visible @179 + dw_mle_search @180 + + dw_spinbutton_new @190 + dw_spinbutton_set_pos @191 + dw_spinbutton_set_limits @192 + dw_entryfield_set_limit @193 + dw_spinbutton_query @194 + + dw_checkbox_new @200 + dw_checkbox_query @201 + dw_checkbox_set @202 + + dw_icon_load @210 + dw_icon_free @211 + + dw_container_new @220 + dw_container_setup @221 + dw_container_alloc @222 + dw_container_set_item @223 + dw_container_set_row_title @224 + dw_container_insert @225 + dw_container_clear @226 + dw_container_set_view @227 + dw_container_query_start @228 + dw_container_query_next @229 + + dw_filesystem_setup @240 + dw_filesystem_set_item @241 + dw_filesystem_set_file @242 + + dw_screen_width @250 + dw_screen_height @251 + + dw_color_depth @260 + dw_color_foreground_set @261 + dw_color_background_set @262 + + dw_notebook_new @270 + dw_notebook_page_new @271 + dw_notebook_page_destroy @272 + dw_notebook_page_set_text @273 + dw_notebook_page_set_status_text @274 + dw_notebook_page_set @275 + dw_notebook_page_query @276 + dw_notebook_pack @277 + + dw_menu_new @280 + dw_menubar_new @281 + dw_menu_append_item @282 + dw_menu_item_set_check @283 + dw_menu_popup @284 + dw_menu_destroy @285 + + dw_pointer_query_pos @290 + dw_pointer_set_pos @291 + + dw_mutex_new @300 + dw_mutex_close @301 + dw_mutex_lock @302 + dw_mutex_unlock @303 + + dw_event_new @310 + dw_event_reset @311 + dw_event_post @312 + dw_event_wait @313 + dw_event_close @314 + + dw_thread_new @320 + dw_thread_end @321 + dw_thread_id @322 + + dw_render_new @330 + dw_draw_point @331 + dw_draw_line @332 + dw_draw_rect @333 + dw_draw_text @334 + + dw_pixmap_bitblt @340 + dw_pixmap_new @341 + dw_pixmap_grab @342 + dw_pixmap_destroy @343 + + dw_dialog_new @350 + dw_dialog_dismiss @351 + dw_dialog_wait @352 + + dw_signal_connect @360 + dw_signal_disconnect_by_window @361 + dw_signal_disconnect_by_data @362 + dw_signal_disconnect_by_name @363 +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dw.h Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,693 @@ +/* $Id$ */ + +#ifndef _H_DW +#define _H_DW + +#if defined(__OS2__) || defined(__WIN32__) || defined(WINNT) || defined(__EMX__) +/* OS/2 or Windows */ + +/* Used internally */ +#define TYPEBOX 0 +#define TYPEITEM 1 + +#define SIZESTATIC 0 +#define SIZEEXPAND 1 + +#define SPLITBAR_WIDTH 3 +#define BUBBLE_HELP_MAX 256 + +#if defined(__OS2__) || defined(__EMX__) +#define INCL_DOS +#define INCL_WIN +#define INCL_GPI + +#include <os2.h> + +/* Lets make some platform independent defines :) */ +#define DW_DT_LEFT DT_LEFT +#define DW_DT_QUERYEXTENT DT_QUERYEXTENT +#define DW_DT_UNDERSCORE DT_UNDERSCORE +#define DW_DT_STRIKEOUT DT_STRIKEOUT +#define DW_DT_TEXTATTRS DT_TEXTATTRS +#define DW_DT_EXTERNALLEADING DT_EXTERNALLEADING +#define DW_DT_CENTER DT_CENTER +#define DW_DT_RIGHT DT_RIGHT +#define DW_DT_TOP DT_TOP +#define DW_DT_VCENTER DT_VCENTER +#define DW_DT_BOTTOM DT_BOTTOM +#define DW_DT_HALFTONE DT_HALFTONE +#define DW_DT_MNEMONIC DT_MNEMONIC +#define DW_DT_WORDBREAK DT_WORDBREAK +#define DW_DT_ERASERECT DT_ERASERECT + +#define DW_CLR_WHITE 16 +#define DW_CLR_BLACK 17 +#define DW_CLR_BLUE CLR_BLUE +#define DW_CLR_RED CLR_RED +#define DW_CLR_PINK CLR_PINK +#define DW_CLR_GREEN CLR_GREEN +#define DW_CLR_CYAN CLR_CYAN +#define DW_CLR_YELLOW CLR_YELLOW +#define DW_CLR_DARKGRAY CLR_DARKGRAY +#define DW_CLR_DARKBLUE CLR_DARKBLUE +#define DW_CLR_DARKRED CLR_DARKRED +#define DW_CLR_DARKPINK CLR_DARKPINK +#define DW_CLR_DARKGREEN CLR_DARKGREEN +#define DW_CLR_DARKCYAN CLR_DARKCYAN +#define DW_CLR_BROWN CLR_BROWN +#define DW_CLR_PALEGRAY CLR_PALEGRAY + +#define DW_FCF_TITLEBAR FCF_TITLEBAR +#define DW_FCF_SYSMENU FCF_SYSMENU +#define DW_FCF_MENU FCF_MENU +#define DW_FCF_SIZEBORDER FCF_SIZEBORDER +#define DW_FCF_MINBUTTON FCF_MINBUTTON +#define DW_FCF_MAXBUTTON FCF_MAXBUTTON +#define DW_FCF_MINMAX FCF_MINMAX +#define DW_FCF_VERTSCROLL FCF_VERTSCROLL +#define DW_FCF_HORZSCROLL FCF_HORZSCROLL +#define DW_FCF_DLGBORDER FCF_DLGBORDER +#define DW_FCF_BORDER FCF_BORDER +#define DW_FCF_SHELLPOSITION FCF_SHELLPOSITION +#define DW_FCF_TASKLIST FCF_TASKLIST +#define DW_FCF_NOBYTEALIGN FCF_NOBYTEALIGN +#define DW_FCF_NOMOVEWITHOWNER FCF_NOMOVEWITHOWNER +#define DW_FCF_SYSMODAL FCF_SYSMODAL +#define DW_FCF_HIDEBUTTON FCF_HIDEBUTTON +#define DW_FCF_HIDEMAX FCF_HIDEMAX +#define DW_FCF_AUTOICON FCF_AUTOICON + +#define DW_CFA_BITMAPORICON CFA_BITMAPORICON +#define DW_CFA_STRING CFA_STRING +#define DW_CFA_ULONG CFA_ULONG +#define DW_CFA_TIME CFA_TIME +#define DW_CFA_DATE CFA_DATE +#define DW_CFA_CENTER CFA_CENTER +#define DW_CFA_LEFT CFA_LEFT +#define DW_CFA_RIGHT CFA_RIGHT +#define DW_CFA_HORZSEPARATOR CFA_HORZSEPARATOR +#define DW_CFA_SEPARATOR CFA_SEPARATOR + +#define DW_CA_DETAILSVIEWTITLES CA_DETAILSVIEWTITLES +#define DW_CV_MINI CV_MINI +#define DW_CV_DETAIL CV_DETAIL + +#define DW_SLS_READONLY SLS_READONLY +#define DW_SLS_RIBBONSTRIP SLS_RIBBONSTRIP + +#define DW_CCS_SINGLESEL CCS_SINGLESEL +#define DW_CCS_EXTENDSEL CCS_EXTENDSEL + +#define DW_LS_MULTIPLESEL LS_MULTIPLESEL + +#define DW_LIT_NONE -1 + +#define DW_MLE_CASESENSITIVE MLFSEARCH_CASESENSITIVE + +typedef struct _hpixmap { + unsigned long width, height; + HDC hdc; + HPS hps; + HBITMAP hbm; + HWND handle; +} *HPIXMAP; + +typedef struct _hmenui { + HWND menu; +} *HMENUI; + +extern HAB dwhab; +extern HMQ dwhmq; +#endif + +#if defined(__WIN32__) || defined(WINNT) +#include <windows.h> +#include <commctrl.h> + +/* Cygwin doesn't seem to have these... */ +#if defined(__CYGWIN32__) +#define LVS_EX_GRIDLINES 0x00000001 +#define LVS_EX_FULLROWSELECT 0x00000020 +#define LVM_SETEXTENDEDLISTVIEWSTYLE (0x1000 + 54) +#define ListView_SetExtendedListViewStyle(hwndLV, dw) (DWORD)SendMessage((hwndLV), LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dw) +#endif +#ifndef UDM_SETPOS32 +#define UDM_SETPOS32 (WM_USER+113) +#endif +#ifndef UDM_GETPOS32 +#define UDM_GETPOS32 (WM_USER+114) +#endif + +/* Lets make some platform independent defines :) */ +#define DW_DT_LEFT SS_LEFT +#define DW_DT_QUERYEXTENT 0 +#define DW_DT_UNDERSCORE 0 +#define DW_DT_STRIKEOUT 0 +#define DW_DT_TEXTATTRS 0 +#define DW_DT_EXTERNALLEADING 0 +#define DW_DT_CENTER SS_CENTER +#define DW_DT_RIGHT SS_RIGHT +#define DW_DT_TOP 0 +#define DW_DT_VCENTER 0 +#define DW_DT_BOTTOM 0 +#define DW_DT_HALFTONE 0 +#define DW_DT_MNEMONIC 0 +#define DW_DT_WORDBREAK 0 +#define DW_DT_ERASERECT 0 + +/* These corespond to the entries in the color + * arrays in the Win32 dw.c, they are also the + * same as DOS ANSI colors. + */ +#define DW_CLR_BLACK 0 +#define DW_CLR_DARKRED 1 +#define DW_CLR_DARKGREEN 2 +#define DW_CLR_BROWN 3 +#define DW_CLR_DARKBLUE 4 +#define DW_CLR_DARKPINK 5 +#define DW_CLR_DARKCYAN 6 +#define DW_CLR_PALEGRAY 7 +#define DW_CLR_DARKGRAY 8 +#define DW_CLR_RED 9 +#define DW_CLR_GREEN 10 +#define DW_CLR_YELLOW 11 +#define DW_CLR_BLUE 12 +#define DW_CLR_PINK 13 +#define DW_CLR_CYAN 14 +#define DW_CLR_WHITE 15 + +#define DW_FCF_TITLEBAR WS_CAPTION +#define DW_FCF_SYSMENU WS_SYSMENU +#define DW_FCF_MENU 0 +#define DW_FCF_SIZEBORDER WS_THICKFRAME +#define DW_FCF_MINBUTTON WS_MINIMIZEBOX +#define DW_FCF_MAXBUTTON WS_MAXIMIZEBOX +#define DW_FCF_MINMAX (WS_MINIMIZEBOX|WS_MAXIMIZEBOX) +#define DW_FCF_VERTSCROLL WS_VSCROLL +#define DW_FCF_HORZSCROLL WS_HSCROLL +#define DW_FCF_DLGBORDER WS_DLGFRAME +#define DW_FCF_BORDER WS_BORDER +#define DW_FCF_SHELLPOSITION 0 +#define DW_FCF_TASKLIST WS_VSCROLL +#define DW_FCF_NOBYTEALIGN 0 +#define DW_FCF_NOMOVEWITHOWNER 0 +#define DW_FCF_SYSMODAL 0 +#define DW_FCF_HIDEBUTTON WS_MINIMIZEBOX +#define DW_FCF_HIDEMAX 0 +#define DW_FCF_AUTOICON 0 + +#define DW_CFA_BITMAPORICON 1 +#define DW_CFA_STRING 1 << 2 +#define DW_CFA_ULONG 1 << 3 +#define DW_CFA_TIME 1 << 4 +#define DW_CFA_DATE 1 << 5 +#define DW_CFA_CENTER 1 << 6 +#define DW_CFA_LEFT 1 << 7 +#define DW_CFA_RIGHT 1 << 8 +#define DW_CFA_HORZSEPARATOR 0 +#define DW_CFA_SEPARATOR 0 + +#define DW_CA_DETAILSVIEWTITLES 0 +#define DW_CV_MINI 0 +#define DW_CV_DETAIL 0 + +#define DW_SLS_READONLY 0 +#define DW_SLS_RIBBONSTRIP 0 + +#define DW_CCS_SINGLESEL 0 +#define DW_CCS_EXTENDSEL 0 + +#define DW_LS_MULTIPLESEL LBS_MULTIPLESEL + +#define DW_LIT_NONE -1 + +#define DW_MLE_CASESENSITIVE 1 + +#define STATICCLASSNAME "STATIC" +#define COMBOBOXCLASSNAME "COMBOBOX" +#define LISTBOXCLASSNAME "LISTBOX" +#define BUTTONCLASSNAME "BUTTON" +#define POPUPMENUCLASSNAME "POPUPMENU" +#define EDITCLASSNAME "EDIT" +#define FRAMECLASSNAME "FRAME" + +#define ClassName "dynamicwindows" +#define SplitbarClassName "dwsplitbar" +#define ObjectClassName "dwobjectclass" +#define DefaultFont NULL + +typedef struct _color { + int fore; + int back; + HWND buddy; + int user; + HBRUSH hbrush; + char fontname[128]; + WNDPROC pOldProc; +} ColorInfo; + +typedef struct _notebookpage { + ColorInfo cinfo; + TC_ITEM item; + HWND hwnd; + int realid; +} NotebookPage; + +typedef unsigned long HAB; +typedef HANDLE HMTX; +typedef HANDLE HEV; + +typedef struct _container { + ColorInfo cinfo; + ULONG *flags; + WNDPROC pOldProc; +} ContainerInfo; + +typedef struct _hpixmap { + unsigned long width, height; + HBITMAP hbm; + HDC hdc; + HWND handle; + void *bits; +} *HPIXMAP; + +typedef struct _hmenui { + HMENU menu; + HWND hwnd; +} *HMENUI; + +#endif + +typedef struct _item { + /* Item type - Box or Item */ + int type; + /* Handle to Frame or Window */ + HWND hwnd; + /* Width and Height of static size */ + int width, height, origwidth, origheight; + /* Size Type - Static or Expand */ + int hsize, vsize; + /* Padding */ + int pad; + /* Ratio of current item */ + float xratio, yratio; +} Item; + +typedef struct _box { +#if defined(__WIN32__) || defined(WINNT) + ColorInfo cinfo; +#elif defined(__OS2__) + PFNWP oldproc; +#endif + /* Number of items in the box */ + int count; + /* Box type - horizontal or vertical */ + int type; + /* Padding */ + int pad, parentpad; + /* Groupbox */ + HWND grouphwnd; + /* Used as temporary storage in the calculation stage */ + int upx, upy, minheight, minwidth; + /* Ratio in this box */ + float xratio, yratio, parentxratio, parentyratio; + /* Used for calculating individual item ratios */ + int width, height; + /* Array of item structures */ + struct _item *items; +} Box; + +typedef struct _bubblebutton { +#if defined(__WIN32__) || defined(WINNT) + ColorInfo cinfo; +#endif + unsigned long id; + char bubbletext[BUBBLE_HELP_MAX]; +#if defined(__OS2__) || defined(__EMX__) + PFNWP pOldProc; +#else + WNDPROC pOldProc; +#endif +} BubbleButton; + +void dw_box_pack_start_stub(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad); +void dw_box_pack_end_stub(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad); +#else +/* GTK */ +#include <gtk/gtk.h> +#include <gdk/gdkx.h> +#include <gdk/gdkprivate.h> +#include <pthread.h> + +/* Lets make some platform independent defines :) */ +#define DW_DT_LEFT 1 +#define DW_DT_UNDERSCORE (1 << 1) +#define DW_DT_STRIKEOUT (1 << 2) +#define DW_DT_CENTER (1 << 3) +#define DW_DT_RIGHT (1 << 4) +#define DW_DT_TOP (1 << 5) +#define DW_DT_VCENTER (1 << 6) +#define DW_DT_BOTTOM (1 << 7) +#define DW_DT_HALFTONE (1 << 8) +#define DW_DT_MNEMONIC (1 << 9) +#define DW_DT_WORDBREAK (1 << 10) +#define DW_DT_ERASERECT (1 << 11) + +#define DW_CLR_BLACK 0 +#define DW_CLR_DARKRED 1 +#define DW_CLR_DARKGREEN 2 +#define DW_CLR_BROWN 3 +#define DW_CLR_DARKBLUE 4 +#define DW_CLR_DARKPINK 5 +#define DW_CLR_DARKCYAN 6 +#define DW_CLR_PALEGRAY 7 +#define DW_CLR_DARKGRAY 8 +#define DW_CLR_RED 9 +#define DW_CLR_GREEN 10 +#define DW_CLR_YELLOW 11 +#define DW_CLR_BLUE 12 +#define DW_CLR_PINK 13 +#define DW_CLR_CYAN 14 +#define DW_CLR_WHITE 15 + +#define DW_FCF_TITLEBAR 1 +#define DW_FCF_SYSMENU (1 << 1) +#define DW_FCF_MENU (1 << 2) +#define DW_FCF_SIZEBORDER (1 << 3) +#define DW_FCF_MINBUTTON (1 << 4) +#define DW_FCF_MAXBUTTON (1 << 5) +#define DW_FCF_MINMAX (1 << 6) +#define DW_FCF_VERTSCROLL (1 << 7) +#define DW_FCF_HORZSCROLL (1 << 8) +#define DW_FCF_DLGBORDER (1 << 9) +#define DW_FCF_BORDER (1 << 10) +#define DW_FCF_SHELLPOSITION (1 << 11) +#define DW_FCF_TASKLIST (1 << 12) +#define DW_FCF_NOBYTEALIGN (1 << 13) +#define DW_FCF_NOMOVEWITHOWNER (1 << 14) +#define DW_FCF_SYSMODAL (1 << 15) +#define DW_FCF_HIDEBUTTON (1 << 16) +#define DW_FCF_HIDEMAX (1 << 17) +#define DW_FCF_AUTOICON (1 << 18) + +#define DW_CFA_BITMAPORICON 1 +#define DW_CFA_STRING (1 << 1) +#define DW_CFA_ULONG (1 << 2) +#define DW_CFA_TIME (1 << 3) +#define DW_CFA_DATE (1 << 4) +#define DW_CFA_CENTER (1 << 5) +#define DW_CFA_LEFT (1 << 6) +#define DW_CFA_RIGHT (1 << 7) +#define DW_CFA_HORZSEPARATOR (1 << 8) +#define DW_CFA_SEPARATOR (1 << 9) + +#define DW_CA_DETAILSVIEWTITLES 1 +#define DW_CV_MINI (1 << 1) +#define DW_CV_DETAIL (1 << 2) + +#define DW_SLS_READONLY 1 +#define DW_SLS_RIBBONSTRIP (1 << 1) + +#define DW_CCS_SINGLESEL 1 +#define DW_CCS_EXTENDSEL (1 << 1) + +#define DW_LS_MULTIPLESEL 1 + +#define DW_LIT_NONE -1 + +#define DW_MLE_CASESENSITIVE 1 + +#define DW_DESKTOP ((HWND)0) +#define HWND_DESKTOP ((HWND)0) + +typedef GtkWidget *HWND; +typedef void *HAB; +typedef unsigned long ULONG; +typedef unsigned char UCHAR; +typedef long LONG; +typedef unsigned short USHORT; +typedef short SHORT; +typedef pthread_mutex_t HMTX; +typedef struct _dw_unix_event { + pthread_mutex_t mutex; + pthread_cond_t event; + pthread_t thread; + int alive; + int posted; +} *HEV; +typedef pthread_t DWTID; + +typedef struct _hpixmap { + unsigned long width, height; + GdkPixmap *pixmap; + HWND handle; +} *HPIXMAP; + +typedef struct _hmenui { + GtkWidget *menu; +} *HMENUI; + +typedef struct _resource_struct { + long resource_max, *resource_id; + char **resource_data; +} DWResources; + +#if !defined(DW_RESOURCES) || defined(BUILD_DLL) +static DWResources _resources = { 0, 0, 0 }; +#else +extern DWResources _resources; +#endif + +#endif + +#if !defined(__OS2__) && !defined(__EMX__) +typedef struct _CDATE +{ + UCHAR day; + UCHAR month; + USHORT year; +} CDATE; +typedef CDATE *PCDATE; + +typedef struct _CTIME +{ + UCHAR hours; + UCHAR minutes; + UCHAR seconds; + UCHAR ucReserved; +} CTIME; +typedef CTIME *PCTIME; +#endif + +#if defined(__OS2__) || defined(__WIN32__) || defined(WINNT) || defined(__EMX__) +typedef unsigned long DWTID; +#endif + +typedef struct _dwenv { + /* Operating System Name */ + char osName[30]; + /* Versions and builds */ + short MajorVersion, MinorVersion, MajorBuild, MinorBuild; +} DWEnv; + + +typedef struct _dwexpose { + int x, y; + int width, height; +} DWExpose; + +typedef struct _dwdialog { + HEV eve; + int done; + void *data, *result; +} DWDialog; + +#define DW_SIGNAL_FUNC(a) ((void *)a) + +#define DW_BUTTON1_MASK 1 +#define DW_BUTTON2_MASK (1 << 1) +#define DW_BUTTON3_MASK (1 << 2) + +#define DW_EXEC_CON 0 +#define DW_EXEC_GUI 1 + +#define DW_FILE_OPEN 0 +#define DW_FILE_SAVE 1 + +#define BOXHORZ 0 +#define BOXVERT 1 + +#define DW_PIXMAP_WIDTH(x) (x ? x->width : 0) +#define DW_PIXMAP_HEIGHT(x) (x ? x->height : 0) + +#define DW_RGB_COLOR (0xFF000000) +#define DW_RGB_MASK (0x00FFFFFF) +#define DW_RED_MASK (0x000000FF) +#define DW_GREEN_MASK (0x0000FF00) +#define DW_BLUE_MASK (0x00FF0000) +#define DW_RED_VALUE(a) (a & DW_RED_MASK) +#define DW_GREEN_VALUE(a) ((a & DW_GREEN_MASK) >> 8) +#define DW_BLUE_VALUE(a) ((a & DW_BLUE_MASK) >> 16) +#define DW_RGB(a, b, c) (0xFF000000 | a | b << 8 | c << 16) + +#ifdef __OS2__ +#define DW_OS2_RGB(a) ((DW_RED_VALUE(a) << 16) | (DW_GREEN_VALUE(a) << 8) | DW_BLUE_VALUE(a)) +#endif + +/* Public function prototypes */ +void dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad); +void dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad); +#if !defined(__OS2__) && !defined(__WIN32__) +int dw_int_init(DWResources *res, int newthread); +#define dw_init(a) dw_int_init(&_resources, a) +#else +int dw_init(int newthread); +#endif +void dw_main(HAB currenthab, void *filterfunc); +void dw_free(void *ptr); +int dw_window_show(HWND handle); +int dw_window_hide(HWND handle); +int dw_window_destroy(HWND handle); +int dw_window_set_font(HWND handle, char *fontname); +int dw_window_set_color(HWND handle, unsigned long fore, unsigned long back); +HWND dw_window_new(HWND hwndOwner, char *title, unsigned long flStyle); +HWND dw_box_new(int type, int pad); +HWND dw_groupbox_new(int type, int pad, char *title); +HWND dw_bitmap_new(unsigned long id); +HWND dw_bitmapbutton_new(char *text, unsigned long id); +HWND dw_container_new(unsigned long id); +HWND dw_text_new(char *text, unsigned long id); +HWND dw_mle_new(unsigned long id); +HWND dw_entryfield_new(char *text, unsigned long id); +HWND dw_entryfield_password_new(char *text, ULONG id); +HWND dw_combobox_new(char *text, unsigned long id); +HWND dw_button_new(char *text, unsigned long id); +HWND dw_spinbutton_new(char *text, unsigned long id); +HWND dw_radiobutton_new(char *text, ULONG id); +HWND dw_slider_new(unsigned long id); +HWND dw_checkbox_new(char *text, unsigned long id); +HWND dw_listbox_new(unsigned long id, int multi); +void dw_listbox_append(HWND handle, char *text); +void dw_listbox_clear(HWND handle); +int dw_listbox_count(HWND handle); +void dw_listbox_set_top(HWND handle, int top); +void dw_listbox_select(HWND handle, int index, int state); +void dw_listbox_delete(HWND handle, int index); +void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length); +void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer); +unsigned int dw_listbox_selected(HWND handle); +int dw_listbox_selected_multi(HWND handle, int where); +unsigned int dw_slider_query_range(HWND handle); +void dw_slider_set_pos(HWND handle, unsigned int position); +void dw_window_set_pos(HWND handle, unsigned long x, unsigned long y); +void dw_window_set_usize(HWND handle, unsigned long width, unsigned long height); +void dw_window_set_pos_size(HWND handle, unsigned long x, unsigned long y, unsigned long width, unsigned long height); +void dw_window_get_pos_size(HWND handle, unsigned long *x, unsigned long *y, unsigned long *width, unsigned long *height); +void dw_window_set_style(HWND handle, unsigned long style, unsigned long mask); +void dw_window_set_icon(HWND handle, unsigned long id); +void dw_window_set_bitmap(HWND handle, unsigned long id); +char *dw_window_get_text(HWND handle); +void dw_window_set_text(HWND handle, char *text); +int dw_window_set_border(HWND handle, int border); +void dw_window_disable(HWND handle); +void dw_window_enable(HWND handle); +void dw_window_capture(HWND handle); +void dw_window_release(void); +void dw_window_reparent(HWND handle, HWND newparent); +unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint); +void dw_mle_export(HWND handle, char *buffer, int startpoint, int length); +void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines); +void dw_mle_delete(HWND handle, int startpoint, int length); +void dw_mle_clear(HWND handle); +void dw_mle_freeze(HWND handle); +void dw_mle_thaw(HWND handle); +void dw_mle_set(HWND handle, int point); +void dw_mle_set_visible(HWND handle, int line); +int dw_mle_search(HWND handle, char *text, int point, unsigned long flags); +void dw_spinbutton_set_pos(HWND handle, long position); +void dw_spinbutton_set_limits(HWND handle, long upper, long lower); +void dw_entryfield_set_limit(HWND handle, ULONG limit); +long dw_spinbutton_query(HWND handle); +int dw_checkbox_query(HWND handle); +void dw_checkbox_set(HWND handle, int value); +int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator); +unsigned long dw_icon_load(unsigned long module, unsigned long id); +void dw_icon_free(unsigned long handle); +void *dw_container_alloc(HWND handle, int rowcount); +void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data); +void dw_container_set_row_title(void *pointer, int row, char *title); +void dw_container_insert(HWND handle, void *pointer, int rowcount); +void dw_container_clear(HWND handle); +void dw_container_set_view(HWND handle, unsigned long flags, int iconwidth, int iconheight); +char *dw_container_query_start(HWND handle, unsigned long flags); +char *dw_container_query_next(HWND handle, unsigned long flags); +int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count); +void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data); +void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon); +int dw_screen_width(void); +int dw_screen_height(void); +unsigned long dw_color_depth(void); +HWND dw_notebook_new(unsigned long id, int top); +unsigned long dw_notebook_page_new(HWND handle, unsigned long flags, int front); +void dw_notebook_page_destroy(HWND handle, unsigned int pageid); +void dw_notebook_page_set_text(HWND handle, unsigned long pageid, char *text); +void dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, char *text); +void dw_notebook_page_set(HWND handle, unsigned int pageid); +unsigned int dw_notebook_page_query(HWND handle); +void dw_notebook_pack(HWND handle, unsigned long pageid, HWND page); +void dw_box_pack_splitbar_start(HWND box); +void dw_box_pack_splitbar_end(HWND box); +HMENUI dw_menu_new(unsigned long id); +HMENUI dw_menubar_new(HWND location); +HWND dw_menu_append_item(HMENUI menu, char *title, unsigned long id, unsigned long flags, int end, int check, HMENUI submenu); +void dw_menu_item_set_check(HMENUI menu, int id, int check); +void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y); +void dw_menu_destroy(HMENUI *menu); +void dw_pointer_query_pos(long *x, long *y); +void dw_pointer_set_pos(long x, long y); +void dw_window_function(HWND handle, void *function, void *data); +HWND dw_window_from_id(HWND handle, int id); +HMTX dw_mutex_new(void); +void dw_mutex_close(HMTX mutex); +void dw_mutex_lock(HMTX mutex); +void dw_mutex_unlock(HMTX mutex); +HEV dw_event_new(void); +int dw_event_reset(HEV eve); +int dw_event_post(HEV eve); +int dw_event_wait(HEV eve, unsigned long timeout); +int dw_event_close (HEV *eve); +DWTID dw_thread_new(void *func, void *data, int stack); +void dw_thread_end(void); +DWTID dw_thread_id(void); +void dw_exit(int exitcode); +HWND dw_render_new(unsigned long id); +void dw_color_foreground_set(unsigned long value); +void dw_color_background_set(unsigned long value); +void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y); +void dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2); +void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height); +void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text); +void dw_flush(void); +void dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc); +HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth); +HPIXMAP dw_pixmap_grab(HWND handle, ULONG id); +void dw_pixmap_destroy(HPIXMAP pixmap); +void dw_beep(int freq, int dur); +int dw_messagebox(char *title, char *format, ...); +int dw_yesno(char *title, char *text); +void dw_environment_query(DWEnv *env); +int dw_exec(char *program, int type, char **params); +int dw_browse(char *url); +char *dw_file_browse(char *title, char *defpath, char *ext, int flags); +char *dw_user_dir(void); +DWDialog *dw_dialog_new(void *data); +int dw_dialog_dismiss(DWDialog *dialog, void *result); +void *dw_dialog_wait(DWDialog *dialog); +#ifndef NO_SIGNALS +void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data); +void dw_signal_disconnect_by_window(HWND window); +void dw_signal_disconnect_by_data(HWND window, void *data); +void dw_signal_disconnect_by_name(HWND window, char *signame); +#endif + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwcompat.def Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,34 @@ +LIBRARY DWCOMPAT INITINSTANCE TERMINSTANCE + +PROTMODE + +DESCRIPTION 'Dynamic Windows Compatibility Module for OS/2' + +CODE LOADONCALL +DATA NONSHARED LOADONCALL + +EXPORTS + sockread @10 + sockwrite @11 + sockclose @12 + socksprintf @13 + sockpipe @14 + sockinit @15 + sockshutdown @16 + + makedir @20 + nonblock @21 + setfileinfo @22 + drivefree @23 + isdrive @24 + + opendir @30 + openxdir @31 + readdir @32 + seekdir @33 + telldir @34 + closedir @35 + + fsopen @40 + fsclose @41 + fsgets @42
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwcompatw.def Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,30 @@ +LIBRARY DWCOMPAT + +DESCRIPTION 'Dynamic Windows Compatibility Module for Win32' + +EXPORTS + sockread @10 + sockwrite @11 + sockclose @12 + socksprintf @13 + sockpipe @14 + sockinit @15 + sockshutdown @16 + + makedir @20 + nonblock @21 + setfileinfo @22 + drivefree @23 + isdrive @24 + + opendir @30 + openxdir @31 + readdir @32 + seekdir @33 + telldir @34 + closedir @35 + + fsopen @40 + fsclose @41 + fsgets @42 +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dww.def Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,183 @@ +LIBRARY DW + +DESCRIPTION 'Dynamic Windows for Win32' + +EXPORTS + Win32_Set_Instance @1 + + dw_init @10 + dw_main @11 + dw_exit @12 + dw_beep @13 + dw_messagebox @14 + dw_yesno @15 + dw_environment_query @16 + dw_exec @17 + dw_browse @18 + dw_file_browse @19 + dw_user_dir @20 + dw_flush @21 + dw_free @22 + + dw_box_new @40 + dw_groupbox_new @41 + dw_box_pack_start @42 + dw_box_pack_end @43 + dw_box_pack_splitbar_start @44 + dw_box_pack_splitbar_end @45 + + dw_window_new @50 + dw_window_show @51 + dw_window_hide @52 + dw_window_destroy @53 + dw_window_set_font @54 + dw_window_set_color @55 + dw_window_set_pos @56 + dw_window_set_usize @57 + dw_window_set_pos_size @58 + dw_window_get_pos_size @59 + dw_window_set_style @60 + dw_window_set_icon @61 + dw_window_set_bitmap @62 + dw_window_get_text @63 + dw_window_set_text @64 + dw_window_disable @65 + dw_window_enable @66 + dw_window_capture @67 + dw_window_release @68 + dw_window_reparent @69 + dw_window_function @70 + dw_window_from_id @71 + dw_window_set_border @72 + + dw_bitmap_new @80 + + dw_button_new @90 + dw_bitmapbutton_new @91 + + dw_text_new @100 + + dw_entryfield_new @110 + dw_entryfield_password_new @111 + + dw_combobox_new @120 + + dw_radiobutton_new @130 + + dw_listbox_new @140 + dw_listbox_append @141 + dw_listbox_clear @142 + dw_listbox_count @143 + dw_listbox_set_top @144 + dw_listbox_select @145 + dw_listbox_delete @146 + dw_listbox_query_text @147 + dw_listbox_set_text @148 + dw_listbox_selected @149 + dw_listbox_selected_multi @150 + + dw_slider_new @160 + dw_slider_query_range @161 + dw_slider_set_pos @162 + + dw_mle_new @170 + dw_mle_import @171 + dw_mle_export @172 + dw_mle_query @173 + dw_mle_delete @174 + dw_mle_clear @175 + dw_mle_freeze @176 + dw_mle_thaw @177 + dw_mle_set @178 + dw_mle_set_visible @179 + dw_mle_search @180 + + dw_spinbutton_new @190 + dw_spinbutton_set_pos @191 + dw_spinbutton_set_limits @192 + dw_entryfield_set_limit @193 + dw_spinbutton_query @194 + + dw_checkbox_new @200 + dw_checkbox_query @201 + dw_checkbox_set @202 + + dw_icon_load @210 + dw_icon_free @211 + + dw_container_new @220 + dw_container_setup @221 + dw_container_alloc @222 + dw_container_set_item @223 + dw_container_set_row_title @224 + dw_container_insert @225 + dw_container_clear @226 + dw_container_set_view @227 + dw_container_query_start @228 + dw_container_query_next @229 + + dw_filesystem_setup @240 + dw_filesystem_set_item @241 + dw_filesystem_set_file @242 + + dw_screen_width @250 + dw_screen_height @251 + + dw_color_depth @260 + dw_color_foreground_set @261 + dw_color_background_set @262 + + dw_notebook_new @270 + dw_notebook_page_new @271 + dw_notebook_page_destroy @272 + dw_notebook_page_set_text @273 + dw_notebook_page_set_status_text @274 + dw_notebook_page_set @275 + dw_notebook_page_query @276 + dw_notebook_pack @277 + + dw_menu_new @280 + dw_menubar_new @281 + dw_menu_append_item @282 + dw_menu_item_set_check @283 + dw_menu_popup @284 + dw_menu_destroy @285 + + dw_pointer_query_pos @290 + dw_pointer_set_pos @291 + + dw_mutex_new @300 + dw_mutex_close @301 + dw_mutex_lock @302 + dw_mutex_unlock @303 + + dw_event_new @310 + dw_event_reset @311 + dw_event_post @312 + dw_event_wait @313 + dw_event_close @314 + + dw_thread_new @320 + dw_thread_end @321 + dw_thread_id @322 + + dw_render_new @330 + dw_draw_point @331 + dw_draw_line @332 + dw_draw_rect @333 + dw_draw_text @334 + + dw_pixmap_bitblt @340 + dw_pixmap_new @341 + dw_pixmap_grab @342 + dw_pixmap_destroy @343 + + dw_dialog_new @350 + dw_dialog_dismiss @351 + dw_dialog_wait @352 + + dw_signal_connect @360 + dw_signal_disconnect_by_window @361 + dw_signal_disconnect_by_data @362 + dw_signal_disconnect_by_name @363 +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gtk/dw.c Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,4251 @@ +/* + * Dynamic Windows: + * A GTK like implementation of the PM GUI + * GTK forwarder module for portabilty. + * + * (C) 2000,2001 Brian Smith <dbsoft@technologist.com> + * + */ +#include "dw.h" +#include <string.h> +#include <stdlib.h> +#include <sys/utsname.h> +#include <stdarg.h> +#include <stdio.h> +#include <unistd.h> +#include <errno.h> +#include <sys/time.h> +#include "config.h" +#ifdef USE_IMLIB +#include <gdk_imlib.h> +#endif + +/* These are used for resource management */ +#if defined(DW_RESOURCES) && !defined(BUILD_DLL) +extern DWResources _resources; +#endif + +char monthlist[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", + "Sep", "Oct", "Nov", "Dec" }; +GdkColor _colors[] = +{ + { 0, 0x0000, 0x0000, 0x0000 }, /* 0 black */ + { 0, 0xbbbb, 0x0000, 0x0000 }, /* 1 red */ + { 0, 0x0000, 0xbbbb, 0x0000 }, /* 2 green */ + { 0, 0xaaaa, 0xaaaa, 0x0000 }, /* 3 yellow */ + { 0, 0x0000, 0x0000, 0xcccc }, /* 4 blue */ + { 0, 0xbbbb, 0x0000, 0xbbbb }, /* 5 magenta */ + { 0, 0x0000, 0xbbbb, 0xbbbb }, /* 6 cyan */ + { 0, 0xaaaa, 0xaaaa, 0xaaaa }, /* 7 white */ + { 0, 0x7777, 0x7777, 0x7777 }, /* 8 grey */ + { 0, 0xffff, 0x0000, 0x0000 }, /* 9 bright red */ + { 0, 0x0000, 0xffff, 0x0000 }, /* 10 bright green */ + { 0, 0xeeee, 0xeeee, 0x0000 }, /* 11 bright yellow */ + { 0, 0x0000, 0x0000, 0xffff }, /* 12 bright blue */ + { 0, 0xffff, 0x0000, 0xffff }, /* 13 bright magenta */ + { 0, 0x0000, 0xeeee, 0xeeee }, /* 14 bright cyan */ + { 0, 0xffff, 0xffff, 0xffff }, /* 15 bright white */ +}; + +GdkColor _foreground = { 0, 0x0000, 0x0000, 0x0000 }; +GdkColor _background = { 0, 0xaaaa, 0xaaaa, 0xaaaa }; + +char *_dw_browse_file = NULL; +int _dw_file_active = 0, _dw_file_ready = 0; +pthread_t _dw_thread = (pthread_t)-1; +int _dw_mutex_locked = FALSE; + +#define DW_MUTEX_LOCK { if(pthread_self() != _dw_thread && _dw_mutex_locked == FALSE) { gdk_threads_enter(); _dw_mutex_locked = TRUE; _locked_by_me = TRUE; } } +#define DW_MUTEX_UNLOCK { if(pthread_self() != _dw_thread && _locked_by_me == TRUE) { gdk_threads_leave(); _dw_mutex_locked = FALSE; _locked_by_me = FALSE; } } + +/* Currently the non Imlib method does not work */ +#ifndef USE_IMLIB +#define USE_IMLIB +#endif + +GdkColormap *_dw_cmap = NULL; + +/* Signal forwarder prototypes */ +gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data); +gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data); +gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data); +gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data); +gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data); +gint _generic_event(GtkWidget *widget, gpointer data); +gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data); +void _activate_event(GtkWidget *widget, gpointer data); +void _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data); +void _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data); +void _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data); +void _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data); + +typedef struct +{ + void *func; + char name[30]; + +} SignalList; + +typedef struct +{ + HWND window; + void *func; + gpointer data; + +} SignalHandler; + +#define SIGNALMAX 12 + +/* A list of signal forwarders, to account for paramater differences. */ +SignalList SignalTranslate[SIGNALMAX] = { + { _configure_event, "configure_event" }, + { _key_press_event, "key_press_event" }, + { _button_press_event, "button_press_event" }, + { _button_release_event, "button_release_event" }, + { _motion_notify_event, "motion_notify_event" }, + { _delete_event, "delete_event" }, + { _expose_event, "expose_event" }, + { _activate_event, "activate" }, + { _generic_event, "clicked" }, + { _container_select_event, "container-select" }, + { _container_context_event, "container-context" }, + { _item_select_event, "item-select" } +}; + +/* Finds the translation function for a given signal name */ +void *_findsigfunc(char *signame) +{ + int z; + + for(z=0;z<SIGNALMAX;z++) + { + if(strcasecmp(signame, SignalTranslate[z].name) == 0) + return SignalTranslate[z].func; + } + return NULL; +} + +gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data) +{ + SignalHandler *work = (SignalHandler *)data; + + if(work) + { + int (*buttonfunc)(HWND, int, int, int, void *) = work->func; + int mybutton = event->button; + + if(event->button == 3) + mybutton = 2; + else if(event->button == 2) + mybutton = 3; + + buttonfunc(widget, event->x, event->y, mybutton, work->data); + } + return TRUE; +} + +gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data) +{ + SignalHandler *work = (SignalHandler *)data; + + if(work) + { + int (*buttonfunc)(HWND, int, int, int, void *) = work->func; + int mybutton = event->button; + + if(event->button == 3) + mybutton = 2; + else if(event->button == 2) + mybutton = 3; + + buttonfunc(widget, event->x, event->y, mybutton, work->data); + } + return TRUE; +} + +gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) +{ + SignalHandler *work = (SignalHandler *)data; + + if(work) + { + int (*motionfunc)(HWND, int, int, int, void *) = work->func; + int keys = 0, x, y; + GdkModifierType state; + + if (event->is_hint) + gdk_window_get_pointer (event->window, &x, &y, &state); + else + { + x = event->x; + y = event->y; + state = event->state; + } + + if (state & GDK_BUTTON1_MASK) + keys = DW_BUTTON1_MASK; + if (state & GDK_BUTTON3_MASK) + keys |= DW_BUTTON2_MASK; + if (state & GDK_BUTTON2_MASK) + keys |= DW_BUTTON3_MASK; + + motionfunc(widget, x, y, keys, work->data); + } + return TRUE; +} + +gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) +{ + SignalHandler *work = (SignalHandler *)data; + + if(work) + { + int (*closefunc)(HWND, void *) = work->func; + + closefunc(widget, data); + } + return TRUE; +} + +gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data) +{ + SignalHandler *work = (SignalHandler *)data; + + if(work) + { + int (*keypressfunc)(HWND, int, void *) = work->func; + + keypressfunc(widget, *event->string, work->data); + } + return TRUE; +} + +gint _generic_event(GtkWidget *widget, gpointer data) +{ + SignalHandler *work = (SignalHandler *)data; + + if(work) + { + int (*genericfunc)(HWND, void *) = work->func; + + genericfunc(widget, work->data); + } + return TRUE; +} + +void _activate_event(GtkWidget *widget, gpointer data) +{ + SignalHandler *work = (SignalHandler *)data; + + if(work) + { + void (*activatefunc)(HWND, void *) = work->func; + + activatefunc(work->window, work->data); + } + return; +} + +gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) +{ + SignalHandler *work = (SignalHandler *)data; + + if(work) + { + int (*sizefunc)(HWND, int, int, void *) = work->func; + + sizefunc(widget, event->width, event->height, work->data); + } + return TRUE; +} + +void _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) +{ + SignalHandler *work = (SignalHandler *)data; + + if(work) + { + DWExpose exp; + int (*exposefunc)(HWND, DWExpose *, void *) = work->func; + + exp.x = event->area.x; + exp.y = event->area.y; + exp.width = event->area.width; + exp.height = event->area.height; + exposefunc(widget, &exp, work->data); + } +} + +void _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data) +{ + SignalHandler *work = (SignalHandler *)data; + + if(work) + { + int (*selectfunc)(HWND, int, void *) = work->func; + GList *list; + int item = 0; + + if(GTK_IS_COMBO(work->window)) + list = GTK_LIST(GTK_COMBO(work->window)->list)->children; + else if(GTK_IS_LIST(widget)) + list = GTK_LIST(widget)->children; + else + return; + + while(list) + { + if(list->data == (gpointer)child) + { + gtk_object_set_data(GTK_OBJECT(work->window), "item", (gpointer)item); + selectfunc(work->window, item, work->data); + break; + } + item++; + list = list->next; + } + } +} + +void _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data) +{ + SignalHandler *work = (SignalHandler *)data; + + if(work) + { + if(event->button == 3) + { + void (*contextfunc)(HWND, char *, int, int, void *) = work->func; + char *text; + int row, col; + + gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col); + + text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row); + contextfunc(work->window, text, event->x, event->y, work->data); + } + } +} + +void _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data) +{ + SignalHandler *work = (SignalHandler *)data; + + if(work) + { + if(event->button == 1 && event->type == GDK_2BUTTON_PRESS) + { + void (*contextfunc)(HWND, char *, void *) = work->func; + char *text; + int row, col; + + gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col); + + text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row); + contextfunc(work->window, text, work->data); + } + } +} + +void _select_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data) +{ + GList *tmp = (GList *)gtk_object_get_data(GTK_OBJECT(widget), "selectlist"); + char *rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row); + + if(rowdata) + { + tmp = g_list_append(tmp, rowdata); + gtk_object_set_data(GTK_OBJECT(widget), "selectlist", tmp); + } + +} + +void _unselect_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data) +{ + GList *tmp = (GList *)gtk_object_get_data(GTK_OBJECT(widget), "selectlist"); + char *rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row); + + if(rowdata) + { + g_list_remove(tmp, rowdata); + gtk_object_set_data(GTK_OBJECT(widget), "selectlist", tmp); + } +} + +GdkPixmap *_find_pixmap(GdkBitmap **bitmap, long id, HWND handle) +{ + char *data = NULL; + int z; + + for(z=0;z<_resources.resource_max;z++) + { + if(_resources.resource_id[z] == id) + { + data = _resources.resource_data[z]; + break; + } + } + + if(data) + { + GdkPixmap *icon_pixmap = NULL; +#ifndef USE_IMLIB + GtkStyle *iconstyle; + + /* hmmm why do we need the handle here? */ + iconstyle = gtk_widget_get_style(handle); + if (!icon_pixmap) + icon_pixmap = gdk_pixmap_create_from_xpm_d(handle->window, bitmap, &iconstyle->bg[GTK_STATE_NORMAL], &data); +#else + gdk_imlib_data_to_pixmap((char **)data, &icon_pixmap, bitmap); +#endif + return icon_pixmap; + } + return NULL; +} + +void _size_allocate(GtkWindow *window) +{ + XSizeHints sizehints; + + sizehints.base_width = 1; + sizehints.base_height = 1; + sizehints.width_inc = 1; + sizehints.height_inc = 1; + sizehints.min_width = 8; + sizehints.min_height = 8; + + sizehints.flags = (PBaseSize|PMinSize|PResizeInc); + + XSetWMNormalHints (GDK_DISPLAY(), + GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window), + &sizehints); + gdk_flush (); +} + +/* + * Initializes the Dynamic Windows engine. + * Parameters: + * newthread: True if this is the only thread. + * False if there is already a message loop running. + */ +int dw_int_init(DWResources *res, int newthread) +{ + int z; + + if(res) + { + _resources.resource_max = res->resource_max; + _resources.resource_id = res->resource_id; + _resources.resource_data = res->resource_data; + } + gtk_set_locale(); + g_thread_init(NULL); + gtk_init(0, NULL); +#ifdef USE_IMLIB + gdk_imlib_init(); +#endif + /* Add colors to the system colormap */ + _dw_cmap = gdk_colormap_get_system(); + for(z=0;z<16;z++) + gdk_color_alloc(_dw_cmap, &_colors[z]); + return TRUE; +} + +/* + * Runs a message loop for Dynamic Windows. + * Parameters: + * currenthab: The handle to the current anchor block + * or NULL if this DW is handling the message loop. + * func: Function pointer to the message filter function. + */ +void dw_main(HAB currenthab, void *func) +{ + _dw_thread = pthread_self(); + gdk_threads_enter(); + gtk_main(); + gdk_threads_leave(); +} + +/* + * Free's memory allocated by dynamic windows. + * Parameters: + * ptr: Pointer to dynamic windows allocated + * memory to be free()'d. + */ +void dw_free(void *ptr) +{ + free(ptr); +} + +/* + * Allocates and initializes a dialog struct. + * Parameters: + * data: User defined data to be passed to functions. + */ +DWDialog *dw_dialog_new(void *data) +{ + DWDialog *tmp = malloc(sizeof(DWDialog)); + + tmp->eve = dw_event_new(); + dw_event_reset(tmp->eve); + tmp->data = data; + tmp->done = FALSE; + tmp->result = NULL; + + return tmp; +} + +/* + * Accepts a dialog struct and returns the given data to the + * initial called of dw_dialog_wait(). + * Parameters: + * dialog: Pointer to a dialog struct aquired by dw_dialog_new). + * result: Data to be returned by dw_dialog_wait(). + */ +int dw_dialog_dismiss(DWDialog *dialog, void *result) +{ + dialog->result = result; + if(pthread_self() == _dw_thread) + gtk_main_quit(); + else + dw_event_post(dialog->eve); + dialog->done = TRUE; + return 0; +} + +/* + * Accepts a dialog struct waits for dw_dialog_dismiss() to be + * called by a signal handler with the given dialog struct. + * Parameters: + * dialog: Pointer to a dialog struct aquired by dw_dialog_new). + */ +void *dw_dialog_wait(DWDialog *dialog) +{ + void *tmp; + + if(pthread_self() == _dw_thread) + gtk_main(); + else + dw_event_wait(dialog->eve, -1); + + dw_event_close(&dialog->eve); + tmp = dialog->result; + free(dialog); + return tmp; +} + +void _delete(GtkWidget *widget, GtkWidget *event, gpointer param) +{ + gtk_widget_destroy(GTK_WIDGET(param)); +} + +void _delete2(GtkWidget *widget, gpointer param) +{ + gtk_widget_destroy(GTK_WIDGET(param)); +} + + +/* + * Displays a Message Box with given text and title.. + * Parameters: + * title: The title of the message box. + * format: printf style format string. + * ...: Additional variables for use in the format. + */ +int dw_messagebox(char *title, char *format, ...) +{ + va_list args; + char outbuf[256]; + GtkWidget *dialog, + *button, + *label; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + va_start(args, format); + vsprintf(outbuf, format, args); + va_end(args); + + dialog = gtk_dialog_new(); + + gtk_window_set_title(GTK_WINDOW(dialog), title); + + button = gtk_button_new_with_label("Ok"); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), button, TRUE, TRUE, 0); + gtk_widget_show(button); + + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(_delete2), (gpointer)dialog); + gtk_signal_connect(GTK_OBJECT(dialog), "delete_event", GTK_SIGNAL_FUNC(_delete), (gpointer)dialog); + + label = gtk_label_new(outbuf); + gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 20); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), label, TRUE, TRUE, 0); + gtk_widget_show(label); + + gtk_widget_show(dialog); + + DW_MUTEX_UNLOCK; + + return strlen(outbuf); +} + +/* + * Displays a Message Box with given text and title.. + * Parameters: + * title: The title of the message box. + * text: The text to display in the box. + * Returns: + * True if YES False of NO. + */ +int dw_yesno(char *title, char *text) +{ + return FALSE; +} + +/* + * Makes the window visible. + * Parameters: + * handle: The window handle to make visible. + */ +int dw_window_show(HWND handle) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + gtk_widget_show(handle); + DW_MUTEX_UNLOCK; + return 0; +} + +/* + * Makes the window invisible. + * Parameters: + * handle: The window handle to make visible. + */ +int dw_window_hide(HWND handle) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + gtk_widget_hide(handle); + DW_MUTEX_UNLOCK; + return 0; +} + +/* + * Destroys a window and all of it's children. + * Parameters: + * handle: The window handle to destroy. + */ +int dw_window_destroy(HWND handle) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + gtk_widget_destroy(handle); + DW_MUTEX_UNLOCK; + return 0; +} + +/* + * Changes a window's parent to newparent. + * Parameters: + * handle: The window handle to destroy. + * newparent: The window's new parent window. + */ +void dw_window_reparent(HWND handle, HWND newparent) +{ + gtk_widget_reparent(handle, newparent); +} + +int _set_font(HWND handle, char *fontname) +{ + GtkStyle *style; + GdkFont *font = NULL; + int retval = FALSE; + + font = gdk_font_load(fontname); + + if(font) + { + style = gtk_widget_get_style(handle); + style->font = font; + gtk_widget_set_style(handle, style); + retval = TRUE; + } + return retval; +} + +/* + * Sets the font used by a specified window (widget) handle. + * Parameters: + * handle: The window (widget) handle. + * fontname: Name and size of the font in the form "size.fontname" + */ +int dw_window_set_font(HWND handle, char *fontname) +{ + GtkWidget *handle2 = handle; + char *font; + int _locked_by_me = FALSE; + gpointer data; + + DW_MUTEX_LOCK; + if(GTK_IS_SCROLLED_WINDOW(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); + if(tmp) + handle2 = tmp; + } + font = strdup(fontname); + + data = gtk_object_get_data(GTK_OBJECT(handle2), "fontname"); + if(data) + free(data); + + if(font) + gtk_object_set_data(GTK_OBJECT(handle2), "fontname", (gpointer)font); + + DW_MUTEX_UNLOCK; + return TRUE; +} + +int _set_color(HWND handle, unsigned long fore, unsigned long back) +{ + GtkStyle *style; + + if(fore & DW_RGB_COLOR || back & DW_RGB_COLOR) + { + GdkColor forecolor = { 0, DW_RED_VALUE(fore) << 8, DW_GREEN_VALUE(fore) << 8, DW_BLUE_VALUE(fore) << 8 }; + GdkColor backcolor = { 0, DW_RED_VALUE(back) << 8, DW_GREEN_VALUE(back) << 8, DW_BLUE_VALUE(back) << 8 }; + + gdk_color_alloc(_dw_cmap, &forecolor); + gdk_color_alloc(_dw_cmap, &backcolor); + + style = gtk_widget_get_style(handle); + style->fg[0] = forecolor; + style->bg[0] = backcolor; + gtk_widget_set_style(handle, style); + } + else + { + style = gtk_widget_get_style(handle); + style->fg[0] = _colors[fore]; + style->bg[0] = _colors[back]; + gtk_widget_set_style(handle, style); + } + + return TRUE; +} +/* + * Sets the colors used by a specified window (widget) handle. + * Parameters: + * handle: The window (widget) handle. + * fore: Foreground color in RGB format. + * back: Background color in RGB format. + */ +int dw_window_set_color(HWND handle, unsigned long fore, unsigned long back) +{ + GtkWidget *handle2 = handle; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + + if(GTK_IS_SCROLLED_WINDOW(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); + if(tmp) + handle2 = tmp; + } + + gtk_object_set_data(GTK_OBJECT(handle2), "fore", (gpointer)fore); + gtk_object_set_data(GTK_OBJECT(handle2), "back", (gpointer)back); + + _set_color(handle2, fore, back); + + DW_MUTEX_UNLOCK; + return TRUE; +} + +/* + * Sets the font used by a specified window (widget) handle. + * Parameters: + * handle: The window (widget) handle. + * border: Size of the window border in pixels. + */ +int dw_window_set_border(HWND handle, int border) +{ + /* TODO */ + return 0; +} + +/* + * Captures the mouse input to this window. + * Parameters: + * handle: Handle to receive mouse input. + */ +void dw_window_capture(HWND handle) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + gdk_pointer_grab(handle->window, TRUE, GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK, NULL, NULL, GDK_CURRENT_TIME); + DW_MUTEX_UNLOCK; +} + +/* + * Releases previous mouse capture. + */ +void dw_window_release(void) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + gdk_pointer_ungrab(GDK_CURRENT_TIME); + DW_MUTEX_UNLOCK; +} + +/* + * Create a new Window Frame. + * Parameters: + * owner: The Owner's window handle or HWND_DESKTOP. + * title: The Window title. + * flStyle: Style flags, see the PM reference. + */ +HWND dw_window_new(HWND hwndOwner, char *title, unsigned long flStyle) +{ + GtkWidget *tmp; + int _locked_by_me = FALSE; + int flags = 0; + + DW_MUTEX_LOCK; + tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL); + + gtk_window_set_title(GTK_WINDOW(tmp), title); + if(!(flStyle & DW_FCF_SIZEBORDER)) + gtk_window_set_policy(GTK_WINDOW(tmp), FALSE, FALSE, TRUE); + + gtk_widget_realize(tmp); + + if(flStyle & DW_FCF_TITLEBAR) + flags |= GDK_DECOR_TITLE; + + if(flStyle & DW_FCF_MINMAX) + flags |= GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE; + + if(flStyle & DW_FCF_SIZEBORDER) + flags |= GDK_DECOR_RESIZEH; + + if(flStyle & DW_FCF_BORDER) + flags |= GDK_DECOR_BORDER; + + gdk_window_set_decorations(tmp->window, flags); + + DW_MUTEX_UNLOCK; + return tmp; +} + +/* + * Create a new Box to be packed. + * Parameters: + * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). + * pad: Number of pixels to pad around the box. + */ +HWND dw_box_new(int type, int pad) +{ + GtkWidget *tmp; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(type == BOXVERT) + tmp = gtk_vbox_new(FALSE, pad); + else + tmp = gtk_hbox_new(FALSE, pad); + gtk_widget_show(tmp); + DW_MUTEX_UNLOCK; + return tmp; +} + +/* + * Create a new Group Box to be packed. + * Parameters: + * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). + * pad: Number of pixels to pad around the box. + * title: Text to be displayined in the group outline. + */ +HWND dw_groupbox_new(int type, int pad, char *title) +{ + return dw_box_new(type, pad); +} + +/* + * Create a bitmap object to be packed. + * Parameters: + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_bitmap_new(unsigned long id) +{ + GdkPixmap *pixmap= NULL; + GdkBitmap *bitmap; + GtkWidget *tmp; + char * test_xpm[] = { + "1 1 1 1", + " c None", + " "}; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; +#ifndef USE_IMLIB + GtkStyle *iconstyle; + + /* hmmm why do we need the handle here? */ + iconstyle = gtk_widget_get_style(handle); + if (!pixmap) + pixmap = gdk_pixmap_create_from_xpm_d(handle->window, &bitmap, &iconstyle->bg[GTK_STATE_NORMAL], &test_xpm); +#else + gdk_imlib_data_to_pixmap(test_xpm, &pixmap, &bitmap); +#endif + tmp = gtk_pixmap_new(pixmap, bitmap); + gtk_widget_show(tmp); + gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); + DW_MUTEX_UNLOCK; + return tmp; +} + +/* + * Create a notebook object to be packed. + * Parameters: + * id: An ID to be used for getting the resource from the + * resource file. + */ +HWND dw_notebook_new(unsigned long id, int top) +{ + GtkWidget *tmp; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + tmp = gtk_notebook_new(); + if(top) + gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_TOP); + else + gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_BOTTOM); + gtk_widget_show(tmp); + gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); + DW_MUTEX_UNLOCK; + return tmp; +} + +/* + * Create a menu object to be popped up. + * Parameters: + * id: An ID to be used for getting the resource from the + * resource file. + */ +HMENUI dw_menu_new(unsigned long id) +{ + int _locked_by_me = FALSE; + HMENUI tmp = malloc(sizeof(struct _hmenui));; + + if(!tmp) + return NULL; + + DW_MUTEX_LOCK; + tmp->menu = gtk_menu_new(); + gtk_widget_show(tmp->menu); + gtk_object_set_data(GTK_OBJECT(tmp->menu), "id", (gpointer)id); + DW_MUTEX_UNLOCK; + return tmp; +} + +/* + * Create a menubar on a window. + * Parameters: + * location: Handle of a window frame to be attached to. + */ +HMENUI dw_menubar_new(HWND location) +{ + GtkWidget *box; + int _locked_by_me = FALSE; + HMENUI tmp = malloc(sizeof(struct _hmenui));; + + if(!tmp) + return NULL; + + DW_MUTEX_LOCK; + tmp->menu = gtk_menu_bar_new(); + box = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(location)); + gtk_widget_show(tmp->menu); + + if(box) + gtk_box_pack_end(GTK_BOX(box), tmp->menu, FALSE, FALSE, 0); + + DW_MUTEX_UNLOCK; + return tmp; +} + +/* + * Destroys a menu created with dw_menubar_new or dw_menu_new. + * Parameters: + * menu: Handle of a menu. + */ +void dw_menu_destroy(HMENUI *menu) +{ + if(menu && *menu) + { + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + gtk_widget_destroy((*menu)->menu); + free(*menu); + *menu = NULL; + DW_MUTEX_UNLOCK; + } +} + +void _removetilde(char *dest, char *src) +{ + int z, cur=0; + + for(z=0;z<strlen(src);z++) + { + if(src[z] != '~') + { + dest[cur] = src[z]; + cur++; + } + } + dest[cur] = 0; +} + +/* + * Adds a menuitem or submenu to an existing menu. + * Parameters: + * menu: The handle the the existing menu. + * title: The title text on the menu item to be added. + * id: An ID to be used for message passing. + * flags: Extended attributes to set on the menu. + * end: If TRUE memu is positioned at the end of the menu. + * check: If TRUE menu is "check"able. + * submenu: Handle to an existing menu to be a submenu or NULL. + */ +HWND dw_menu_append_item(HMENUI menu, char *title, unsigned long id, unsigned long flags, int end, int check, HMENUI submenu) +{ + GtkWidget *tmphandle; + char *tempbuf = malloc(strlen(title)+1); + int _locked_by_me = FALSE; + + if(!menu || !menu->menu) + { + free(tempbuf); + return NULL; + } + + DW_MUTEX_LOCK; + _removetilde(tempbuf, title); + + if(strlen(tempbuf) == 0) + tmphandle=gtk_menu_item_new(); + else + { + if(check) + { + char numbuf[10]; + tmphandle=gtk_check_menu_item_new_with_label(tempbuf); + gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(tmphandle), TRUE); + sprintf(numbuf, "%lu", id); + gtk_object_set_data(GTK_OBJECT(menu->menu), numbuf, (gpointer)tmphandle); + } + else + tmphandle=gtk_menu_item_new_with_label(tempbuf); + } + + gtk_widget_show(tmphandle); + + if(submenu) + gtk_menu_item_set_submenu(GTK_MENU_ITEM(tmphandle), submenu->menu); + + if(GTK_IS_MENU_BAR(menu->menu)) + gtk_menu_bar_append(GTK_MENU_BAR(menu->menu), tmphandle); + else + gtk_menu_append(GTK_MENU(menu->menu), tmphandle); + + gtk_object_set_data(GTK_OBJECT(tmphandle), "id", (gpointer)id); + free(tempbuf); + DW_MUTEX_UNLOCK; + return tmphandle; +} + +/* + * Sets the state of a menu item check. + * Parameters: + * menu: The handle the the existing menu. + * id: Menuitem id. + * check: TRUE for checked FALSE for not checked. + */ +void dw_menu_item_set_check(HMENUI menu, int id, int check) +{ + char numbuf[10]; + GtkWidget *tmphandle; + int _locked_by_me = FALSE; + + if(!menu || !menu->menu) + return; + + DW_MUTEX_LOCK; + sprintf(numbuf, "%d", id); + tmphandle = gtk_object_get_data(GTK_OBJECT(menu->menu), numbuf); + + if(tmphandle) + { + if(GTK_CHECK_MENU_ITEM(tmphandle)->active != check) + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(tmphandle), check); + } + DW_MUTEX_UNLOCK; +} + +/* + * Pops up a context menu at given x and y coordinates. + * Parameters: + * menu: The handle the the existing menu. + * parent: Handle to the window initiating the popup. + * x: X coordinate. + * y: Y coordinate. + */ +void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) +{ + int _locked_by_me = FALSE; + + if(!menu || !*menu) + return; + + DW_MUTEX_LOCK; + gtk_menu_popup(GTK_MENU((*menu)->menu), NULL, NULL, NULL, NULL, x, y); + free(*menu); + *menu = NULL; + DW_MUTEX_UNLOCK; +} + + +/* + * Returns the current X and Y coordinates of the mouse pointer. + * Parameters: + * x: Pointer to variable to store X coordinate. + * y: Pointer to variable to store Y coordinate. + */ +void dw_pointer_query_pos(long *x, long *y) +{ + GdkModifierType state; + int gx, gy; + + gdk_window_get_pointer (GDK_ROOT_PARENT(), &gx, &gy, &state); + *x = gx; + *y = gy; +} + +/* + * Sets the X and Y coordinates of the mouse pointer. + * Parameters: + * x: X coordinate. + * y: Y coordinate. + */ +void dw_pointer_set_pos(long x, long y) +{ + XWarpPointer(GDK_DISPLAY(), None, GDK_ROOT_WINDOW(), 0,0,0,0, x, y); +} + +/* + * Create a container object to be packed. + * Parameters: + * id: An ID to be used for getting the resource from the + * resource file. + */ +HWND dw_container_new(unsigned long id) +{ + GtkWidget *tmp; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + tmp = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tmp), + GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); + + gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); + gtk_widget_show(tmp); + + DW_MUTEX_UNLOCK; + return tmp; +} + +/* + * Create a new static text window (widget) to be packed. + * Parameters: + * text: The text to be display by the static text widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_text_new(char *text, unsigned long id) +{ + GtkWidget *tmp; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + tmp = gtk_label_new(text); + gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_LEFT); + gtk_widget_show(tmp); + gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); + DW_MUTEX_UNLOCK; + return tmp; +} + +/* + * Create a new Multiline Editbox window (widget) to be packed. + * Parameters: + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_mle_new(unsigned long id) +{ + GtkWidget *tmp, *tmpbox, *scroller; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + tmpbox = gtk_hbox_new(FALSE, 0); + tmp = gtk_text_new(NULL, NULL); + gtk_text_set_word_wrap(GTK_TEXT(tmp), FALSE); + gtk_text_set_line_wrap(GTK_TEXT(tmp), FALSE); + scroller = gtk_vscrollbar_new(GTK_TEXT(tmp)->vadj); + GTK_WIDGET_UNSET_FLAGS(scroller, GTK_CAN_FOCUS); + gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); + gtk_object_set_data(GTK_OBJECT(tmpbox), "mle", (gpointer)tmp); + gtk_box_pack_start(GTK_BOX(tmpbox), tmp, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(tmpbox), scroller, FALSE, TRUE, 0); + gtk_widget_show(tmp); + gtk_widget_show(scroller); + gtk_widget_show(tmpbox); + DW_MUTEX_UNLOCK; + return tmpbox; +} + +/* + * Create a new Entryfield window (widget) to be packed. + * Parameters: + * text: The default text to be in the entryfield widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_entryfield_new(char *text, unsigned long id) +{ + GtkWidget *tmp; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + tmp = gtk_entry_new(); + + gtk_entry_set_text(GTK_ENTRY(tmp), text); + + gtk_widget_show(tmp); + gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); + + DW_MUTEX_UNLOCK; + return tmp; +} + +/* + * Create a new Entryfield (password) window (widget) to be packed. + * Parameters: + * text: The default text to be in the entryfield widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_entryfield_password_new(char *text, ULONG id) +{ + GtkWidget *tmp; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + tmp = gtk_entry_new(); + + gtk_entry_set_visibility(GTK_ENTRY(tmp), FALSE); + gtk_entry_set_text(GTK_ENTRY(tmp), text); + + gtk_widget_show(tmp); + gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); + + DW_MUTEX_UNLOCK; + return tmp; +} + +/* + * Create a new Combobox window (widget) to be packed. + * Parameters: + * text: The default text to be in the combpbox widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_combobox_new(char *text, unsigned long id) +{ + GtkWidget *tmp; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + tmp = gtk_combo_new(); + gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(tmp)->entry), text); + gtk_combo_set_use_arrows(GTK_COMBO(tmp), TRUE); + gtk_object_set_user_data(GTK_OBJECT(tmp), NULL); + gtk_widget_show(tmp); + gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); + DW_MUTEX_UNLOCK; + return tmp; +} + +/* + * Create a new button window (widget) to be packed. + * Parameters: + * text: The text to be display by the static text widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_button_new(char *text, unsigned long id) +{ + GtkWidget *tmp; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + tmp = gtk_button_new_with_label(text); + gtk_widget_show(tmp); + gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); + DW_MUTEX_UNLOCK; + return tmp; +} + +/* + * Create a new bitmap button window (widget) to be packed. + * Parameters: + * text: Bubble help text to be displayed. + * id: An ID of a bitmap in the resource file. + */ +HWND dw_bitmapbutton_new(char *text, unsigned long id) +{ + GtkWidget *tmp; + GtkWidget *bitmap; + GtkTooltips *tooltips; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + tmp = gtk_button_new(); + bitmap = dw_bitmap_new(id); + + if(bitmap) + { + dw_window_set_bitmap(bitmap, id); + gtk_container_add (GTK_CONTAINER(tmp), bitmap); + } + gtk_widget_show(tmp); + if(text) + { + tooltips = gtk_tooltips_new(); + gtk_tooltips_set_colors(tooltips, &_colors[DW_CLR_BLACK], &_colors[DW_CLR_YELLOW]); + gtk_tooltips_set_tip(tooltips, tmp, text, NULL); + gtk_object_set_data(GTK_OBJECT(tmp), "tooltip", (gpointer)tooltips); + } + gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); + DW_MUTEX_UNLOCK; + return tmp; +} + +/* + * Create a new spinbutton window (widget) to be packed. + * Parameters: + * text: The text to be display by the static text widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_spinbutton_new(char *text, unsigned long id) +{ + GtkAdjustment *adj; + GtkWidget *tmp; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + adj = (GtkAdjustment *)gtk_adjustment_new (1.0, 0.0, 100.0, 1.0, 5.0, 0.0); + tmp = gtk_spin_button_new (adj, 0, 0); + gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(tmp), TRUE); + gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(tmp), TRUE); + gtk_widget_show(tmp); + gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); + DW_MUTEX_UNLOCK; + return tmp; +} + +/* + * Create a new radiobutton window (widget) to be packed. + * Parameters: + * text: The text to be display by the static text widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_radiobutton_new(char *text, ULONG id) +{ + /* This will have to be fixed in the future. */ + GtkWidget *tmp; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + tmp = gtk_radio_button_new_with_label(NULL, text); + gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); + gtk_widget_show(tmp); + + DW_MUTEX_UNLOCK; + return tmp; +} + +/* + * Create a new slider window (widget) to be packed. + * Parameters: + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_slider_new(unsigned long id) +{ + GtkWidget *tmp; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + tmp = gtk_progress_bar_new(); + gtk_widget_show(tmp); + gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); + DW_MUTEX_UNLOCK; + return tmp; +} + +/* + * Create a new checkbox window (widget) to be packed. + * Parameters: + * text: The text to be display by the static text widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_checkbox_new(char *text, unsigned long id) +{ + GtkWidget *tmp; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + tmp = gtk_check_button_new_with_label(text); + gtk_widget_show(tmp); + gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); + DW_MUTEX_UNLOCK; + return tmp; +} + +/* + * Create a new listbox window (widget) to be packed. + * Parameters: + * id: An ID to be used with WinWindowFromID() or 0L. + * multi: Multiple select TRUE or FALSE. + */ +HWND dw_listbox_new(unsigned long id, int multi) +{ + GtkWidget *tmp, *list; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + tmp = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp), + GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); + + list = gtk_list_new(); + gtk_list_set_selection_mode(GTK_LIST(list), multi ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE); + + gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp), + list); + gtk_object_set_user_data(GTK_OBJECT(tmp), list); + gtk_widget_show(list); + gtk_widget_show(tmp); + gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); + + DW_MUTEX_UNLOCK; + return tmp; +} + +/* + * Sets the icon used for a given window. + * Parameters: + * handle: Handle to the window. + * id: An ID to be used to specify the icon. + */ +void dw_window_set_icon(HWND handle, unsigned long id) +{ + GdkBitmap *bitmap; + GdkPixmap *icon_pixmap; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + icon_pixmap = _find_pixmap(&bitmap, id, handle); + + if(handle->window && icon_pixmap) + gdk_window_set_icon(handle->window, NULL, icon_pixmap, bitmap); + + DW_MUTEX_UNLOCK; +} + +/* + * Sets the bitmap used for a given static window. + * Parameters: + * handle: Handle to the window. + * id: An ID to be used to specify the icon. + */ +void dw_window_set_bitmap(HWND handle, unsigned long id) +{ + GdkBitmap *bitmap; + GdkPixmap *tmp; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + tmp = _find_pixmap(&bitmap, id, handle); + if(tmp) + gtk_pixmap_set(GTK_PIXMAP(handle), tmp, bitmap); + DW_MUTEX_UNLOCK; +} + +/* + * Sets the text used for a given window. + * Parameters: + * handle: Handle to the window. + * text: The text associsated with a given window. + */ +void dw_window_set_text(HWND handle, char *text) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_ENTRY(handle)) + gtk_entry_set_text(GTK_ENTRY(handle), text); + else if(GTK_IS_COMBO(handle)) + gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(handle)->entry), text); + else if(GTK_IS_LABEL(handle)) + gtk_label_set_text(GTK_LABEL(handle), text); + DW_MUTEX_UNLOCK; +} + +/* + * Gets the text used for a given window. + * Parameters: + * handle: Handle to the window. + * Returns: + * text: The text associsated with a given window. + */ +char *dw_window_get_text(HWND handle) +{ + char *possible = ""; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_ENTRY(handle)) + possible = gtk_entry_get_text(GTK_ENTRY(handle)); + else if(GTK_IS_COMBO(handle)) + possible = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(handle)->entry)); + + DW_MUTEX_UNLOCK; + return strdup(possible); +} + +/* + * Disables given window (widget). + * Parameters: + * handle: Handle to the window. + */ +void dw_window_disable(HWND handle) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + gtk_widget_set_sensitive(handle, FALSE); + DW_MUTEX_UNLOCK; +} + +/* + * Enables given window (widget). + * Parameters: + * handle: Handle to the window. + */ +void dw_window_enable(HWND handle) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + gtk_widget_set_sensitive(handle, TRUE); + DW_MUTEX_UNLOCK; +} + +/* + * Adds text to an MLE box and returns the current point. + * Parameters: + * handle: Handle to the MLE to be queried. + * buffer: Text buffer to be imported. + * startpoint: Point to start entering text. + */ +unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint) +{ + unsigned int tmppoint = startpoint; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_BOX(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); + + if(tmp && GTK_IS_TEXT(tmp)) + { + gtk_text_set_point(GTK_TEXT(tmp), startpoint < 0 ? 0 : startpoint); + gtk_text_insert(GTK_TEXT(tmp), NULL, NULL, NULL, buffer, -1); + tmppoint = gtk_text_get_point(GTK_TEXT(tmp)); + } + } + DW_MUTEX_UNLOCK; + return tmppoint; +} + +/* + * Grabs text from an MLE box. + * Parameters: + * handle: Handle to the MLE to be queried. + * buffer: Text buffer to be exported. + * startpoint: Point to start grabbing text. + * length: Amount of text to be grabbed. + */ +void dw_mle_export(HWND handle, char *buffer, int startpoint, int length) +{ + int _locked_by_me = FALSE; + gchar *text; + + DW_MUTEX_LOCK; + if(GTK_IS_BOX(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); + + if(tmp && GTK_IS_TEXT(tmp)) + { + text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), startpoint, startpoint + length); + if(text) + { + strcpy(buffer, text); + g_free(text); + } + } + } + DW_MUTEX_UNLOCK; +} + +/* + * Obtains information about an MLE box. + * Parameters: + * handle: Handle to the MLE to be queried. + * bytes: A pointer to a variable to return the total bytes. + * lines: A pointer to a variable to return the number of lines. + */ +void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines) +{ + int _locked_by_me = FALSE; + + if(bytes) + *bytes = 0; + if(lines) + *lines = 0; + + DW_MUTEX_LOCK; + if(GTK_IS_BOX(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); + + if(tmp && GTK_IS_TEXT(tmp)) + { + if(bytes) + *bytes = gtk_text_get_length(GTK_TEXT(tmp)); + if(lines) + { + gchar *text; + + *lines = 0; + text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, bytes ? *bytes : gtk_text_get_length(GTK_TEXT(tmp))); + + if(text) + { + int z, len = strlen(text); + + for(z=0;z<len;z++) + { + if(text[z] == '\n') + (*lines)++; + } + g_free(text); + } + } + } + } + DW_MUTEX_UNLOCK; +} + +/* + * Deletes text from an MLE box. + * Parameters: + * handle: Handle to the MLE to be deleted from. + * startpoint: Point to start deleting text. + * length: Amount of text to be deleted. + */ +void dw_mle_delete(HWND handle, int startpoint, int length) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_BOX(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); + + if(tmp && GTK_IS_TEXT(tmp)) + { + gtk_text_set_point(GTK_TEXT(tmp), startpoint); + gtk_text_forward_delete(GTK_TEXT(tmp), length); + } + } + DW_MUTEX_UNLOCK; +} + +/* + * Clears all text from an MLE box. + * Parameters: + * handle: Handle to the MLE to be cleared. + */ +void dw_mle_clear(HWND handle) +{ + int length, _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_BOX(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); + + if(tmp && GTK_IS_TEXT(tmp)) + { + length = gtk_text_get_length(GTK_TEXT(tmp)); + gtk_text_set_point(GTK_TEXT(tmp), 0); + gtk_text_forward_delete(GTK_TEXT(tmp), length); + } + } + DW_MUTEX_UNLOCK; +} + +/* + * Sets the visible line of an MLE box. + * Parameters: + * handle: Handle to the MLE. + * line: Line to be visible. + */ +void dw_mle_set_visible(HWND handle, int line) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_BOX(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); + + if(tmp && GTK_IS_TEXT(tmp)) + { + unsigned long lines; + float pos, ratio; + + dw_mle_query(handle, NULL, &lines); + + if(lines) + { + ratio = (float)line/(float)lines; + + pos = (ratio * (float)(GTK_TEXT(tmp)->vadj->upper - GTK_TEXT(tmp)->vadj->lower)) + GTK_TEXT(tmp)->vadj->lower; + + gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos); + } + } + } + DW_MUTEX_UNLOCK; +} + +/* + * Sets the current cursor position of an MLE box. + * Parameters: + * handle: Handle to the MLE to be positioned. + * point: Point to position cursor. + */ +void dw_mle_set(HWND handle, int point) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_BOX(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); + + if(tmp && GTK_IS_TEXT(tmp)) + { + gtk_text_set_point(GTK_TEXT(tmp), point); + } + } + DW_MUTEX_UNLOCK; +} + +/* + * Finds text in an MLE box. + * Parameters: + * handle: Handle to the MLE to be cleared. + * text: Text to search for. + * point: Start point of search. + * flags: Search specific flags. + */ +int dw_mle_search(HWND handle, char *text, int point, unsigned long flags) +{ + int _locked_by_me = FALSE, retval = 0; + + DW_MUTEX_LOCK; + if(GTK_IS_BOX(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); + + if(tmp && GTK_IS_TEXT(tmp)) + { + int len = gtk_text_get_length(GTK_TEXT(tmp)); + gchar *tmpbuf; + + tmpbuf = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, len); + if(tmpbuf) + { + int z, textlen; + + textlen = strlen(text); + + if(flags & DW_MLE_CASESENSITIVE) + { + for(z=point;z<(len-textlen) && !retval;z++) + { + if(strncmp(&tmpbuf[z], text, textlen) == 0) + retval = z + textlen; + } + } + else + { + for(z=point;z<(len-textlen) && !retval;z++) + { + if(strncasecmp(&tmpbuf[z], text, textlen) == 0) + retval = z + textlen; + } + } + + if(retval) + { + gtk_text_set_point(GTK_TEXT(tmp), retval - textlen); + gtk_editable_select_region(&(GTK_TEXT(tmp)->editable), retval - textlen, retval); + } + + g_free(tmpbuf); + } + } + } + + DW_MUTEX_UNLOCK; + return retval; +} + +/* + * Stops redrawing of an MLE box. + * Parameters: + * handle: Handle to the MLE to freeze. + */ +void dw_mle_freeze(HWND handle) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_BOX(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); + + if(tmp && GTK_IS_TEXT(tmp)) + { + gtk_text_freeze(GTK_TEXT(tmp)); + } + } + DW_MUTEX_UNLOCK; +} + +/* + * Resumes redrawing of an MLE box. + * Parameters: + * handle: Handle to the MLE to thaw. + */ +void dw_mle_thaw(HWND handle) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_BOX(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); + + if(tmp && GTK_IS_TEXT(tmp)) + { + gtk_text_thaw(GTK_TEXT(tmp)); + } + } + DW_MUTEX_UNLOCK; +} + +/* + * Returns the range of the slider. + * Parameters: + * handle: Handle to the slider to be queried. + */ +unsigned int dw_slider_query_range(HWND handle) +{ + return 100; +} + +/* + * Sets the slider position. + * Parameters: + * handle: Handle to the slider to be set. + * position: Position of the slider withing the range. + */ +void dw_slider_set_pos(HWND handle, unsigned int position) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + gtk_progress_bar_update(GTK_PROGRESS_BAR(handle), (gfloat)position/100); + DW_MUTEX_UNLOCK; +} + +/* + * Sets the spinbutton value. + * Parameters: + * handle: Handle to the spinbutton to be set. + * position: Current value of the spinbutton. + */ +void dw_spinbutton_set_pos(HWND handle, long position) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + gtk_spin_button_set_value(GTK_SPIN_BUTTON(handle), (gfloat)position); + DW_MUTEX_UNLOCK; +} + +/* + * Sets the spinbutton limits. + * Parameters: + * handle: Handle to the spinbutton to be set. + * position: Current value of the spinbutton. + * position: Current value of the spinbutton. + */ +void dw_spinbutton_set_limits(HWND handle, long upper, long lower) +{ + long curval; + GtkAdjustment *adj; + int _locked_by_me = FALSE; + + curval = dw_spinbutton_query(handle); + DW_MUTEX_LOCK; + adj = (GtkAdjustment *)gtk_adjustment_new((gfloat)curval, (gfloat)lower, (gfloat)upper, 1.0, 5.0, 0.0); + DW_MUTEX_UNLOCK; +} + +/* + * Sets the entryfield character limit. + * Parameters: + * handle: Handle to the spinbutton to be set. + * limit: Number of characters the entryfield will take. + */ +void dw_entryfield_set_limit(HWND handle, ULONG limit) +{ + /* TODO: can this be done after the fact? */ +} + +/* + * Returns the current value of the spinbutton. + * Parameters: + * handle: Handle to the spinbutton to be queried. + */ +long dw_spinbutton_query(HWND handle) +{ + long retval; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + retval = (long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(handle)); + DW_MUTEX_UNLOCK; + + return retval; +} + +/* + * Returns the state of the checkbox. + * Parameters: + * handle: Handle to the checkbox to be queried. + */ +int dw_checkbox_query(HWND handle) +{ + int retval; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + retval = GTK_TOGGLE_BUTTON(handle)->active; + DW_MUTEX_UNLOCK; + + return retval; +} + +/* + * Sets the state of the checkbox. + * Parameters: + * handle: Handle to the checkbox to be queried. + * value: TRUE for checked, FALSE for unchecked. + */ +void dw_checkbox_set(HWND handle, int value) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(handle), value); + DW_MUTEX_UNLOCK; +} + +int _dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator, int extra) +{ + GtkWidget *clist; + char numbuf[10]; + int z; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + clist = gtk_clist_new_with_titles(count, (gchar **)titles); + if(!clist) + { + DW_MUTEX_UNLOCK; + return FALSE; + } + + gtk_signal_connect(GTK_OBJECT(clist), "select_row", GTK_SIGNAL_FUNC(_select_row), NULL); + gtk_signal_connect(GTK_OBJECT(clist), "unselect_row", GTK_SIGNAL_FUNC(_unselect_row), NULL); + + gtk_clist_set_column_auto_resize(GTK_CLIST(clist), 0, TRUE); + gtk_container_add(GTK_CONTAINER(handle), clist); + gtk_object_set_user_data(GTK_OBJECT(handle), (gpointer)clist); + gtk_widget_show(clist); + gtk_object_set_data(GTK_OBJECT(clist), "colcount", (gpointer)count); + + if(extra) + gtk_clist_set_column_width(GTK_CLIST(clist), 1, 120); + + for(z=0;z<count;z++) + { + if(!extra || z > 1) + gtk_clist_set_column_width(GTK_CLIST(clist), z, 50); + sprintf(numbuf, "%d", z); + gtk_object_set_data(GTK_OBJECT(clist), numbuf, (gpointer)flags[z]); + } + + DW_MUTEX_UNLOCK; + return TRUE; +} + +/* + * Sets up the container columns. + * Parameters: + * handle: Handle to the container to be configured. + * flags: An array of unsigned longs with column flags. + * titles: An array of strings with column text titles. + * count: The number of columns (this should match the arrays). + * separator: The column number that contains the main separator. + * (this item may only be used in OS/2) + */ +int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) +{ + return _dw_container_setup(handle, flags, titles, count, separator, 0); +} + +/* + * Sets up the filesystem columns, note: filesystem always has an icon/filename field. + * Parameters: + * handle: Handle to the container to be configured. + * flags: An array of unsigned longs with column flags. + * titles: An array of strings with column text titles. + * count: The number of columns (this should match the arrays). + */ +int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) +{ + char **newtitles = malloc(sizeof(char *) * (count + 2)); + unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); + + newtitles[0] = "Icon"; + newtitles[1] = "Filename"; + + newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR; + newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; + + memcpy(&newtitles[2], titles, sizeof(char *) * count); + memcpy(&newflags[2], flags, sizeof(unsigned long) * count); + + _dw_container_setup(handle, newflags, newtitles, count + 2, 2, 1); + + free(newtitles); + free(newflags); + return TRUE; +} + +/* + * Obtains an icon from a module (or header in GTK). + * Parameters: + * module: Handle to module (DLL) in OS/2 and Windows. + * id: A unsigned long id int the resources on OS/2 and + * Windows, on GTK this is converted to a pointer + * to an embedded XPM. + */ +unsigned long dw_icon_load(unsigned long module, unsigned long id) +{ + return id; +} + +/* + * Frees a loaded resource in OS/2 and Windows. + * Parameters: + * handle: Handle to icon returned by dw_icon_load(). + */ +void dw_icon_free(unsigned long handle) +{ +} + +/* + * Allocates memory used to populate a container. + * Parameters: + * handle: Handle to the container window (widget). + * rowcount: The number of items to be populated. + */ +void *dw_container_alloc(HWND handle, int rowcount) +{ + int z, count = 0; + GtkWidget *clist; + char **blah; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); + if(!clist) + { + DW_MUTEX_UNLOCK; + return NULL; + } + + count = (int)gtk_object_get_data(GTK_OBJECT(clist), "colcount"); + + if(!count) + { + DW_MUTEX_UNLOCK; + return NULL; + } + + blah = malloc(sizeof(char *) * count); + memset(blah, 0, sizeof(char *) * count); + + gtk_clist_freeze(GTK_CLIST(clist)); + for(z=0;z<rowcount;z++) + { + gtk_clist_append(GTK_CLIST(clist), blah); + } + free(blah); + DW_MUTEX_UNLOCK; + return (void *)handle; +} + +/* + * Sets an item in specified row and column to the given data. + * Parameters: + * handle: Handle to the container window (widget). + * pointer: Pointer to the allocated memory in dw_container_alloc(). + * column: Zero based column of data being set. + * row: Zero based row of data being set. + * data: Pointer to the data to be added. + */ +void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) +{ + char numbuf[10], textbuffer[100]; + int flag = 0; + GtkWidget *clist; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); + if(!clist) + { + DW_MUTEX_UNLOCK; + return; + } + + sprintf(numbuf, "%d", column); + flag = (int)gtk_object_get_data(GTK_OBJECT(clist), numbuf); + + if(flag & DW_CFA_BITMAPORICON) + { + long hicon = *((long *)data); + GdkBitmap *bitmap; + GdkPixmap *pixmap = _find_pixmap(&bitmap, hicon, clist); + + if(pixmap) + gtk_clist_set_pixmap(GTK_CLIST(clist), row, column, pixmap, bitmap); + } + else if(flag & DW_CFA_STRING) + { + char *tmp = *((char **)data); + gtk_clist_set_text(GTK_CLIST(clist), row, column, tmp); + } + else if(flag & DW_CFA_ULONG) + { + ULONG tmp = *((ULONG *)data); + + sprintf(textbuffer, "%lu", tmp); + + gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); + } + else if(flag & DW_CFA_DATE) + { + CDATE fdate = *((CDATE *)data); + + sprintf(textbuffer, "%s %d, %d", monthlist[fdate.month], fdate.day, fdate.year); + gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); + } + else if(flag & DW_CFA_TIME) + { + CTIME ftime = *((CTIME *)data); + + if(ftime.hours > 12) + sprintf(textbuffer, "%d:%s%dpm", ftime.hours - 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes); + else + sprintf(textbuffer, "%d:%s%dam", ftime.hours ? ftime.hours : 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes); + gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); + } + DW_MUTEX_UNLOCK; +} + +/* + * Sets an item in specified row and column to the given data. + * Parameters: + * handle: Handle to the container window (widget). + * pointer: Pointer to the allocated memory in dw_container_alloc(). + * column: Zero based column of data being set. + * row: Zero based row of data being set. + * data: Pointer to the data to be added. + */ +void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) +{ + dw_container_set_item(handle, pointer, 0, row, (void *)&icon); + dw_container_set_item(handle, pointer, 1, row, (void *)&filename); +} + +/* + * Sets an item in specified row and column to the given data. + * Parameters: + * handle: Handle to the container window (widget). + * pointer: Pointer to the allocated memory in dw_container_alloc(). + * column: Zero based column of data being set. + * row: Zero based row of data being set. + * data: Pointer to the data to be added. + */ +void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) +{ + dw_container_set_item(handle, pointer, column + 2, row, data); +} + +/* + * Sets the title of a row in the container. + * Parameters: + * pointer: Pointer to the allocated memory in dw_container_alloc(). + * row: Zero based row of data being set. + * title: String title of the item. + */ +void dw_container_set_row_title(void *pointer, int row, char *title) +{ + GtkWidget *clist; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(pointer)); + + if(clist) + gtk_clist_set_row_data(GTK_CLIST(clist), row, (gpointer)title); + DW_MUTEX_UNLOCK; +} + +/* + * Sets the title of a row in the container. + * Parameters: + * handle: Handle to the container window (widget). + * pointer: Pointer to the allocated memory in dw_container_alloc(). + * rowcount: The number of rows to be inserted. + */ +void dw_container_insert(HWND handle, void *pointer, int rowcount) +{ + GtkWidget *clist; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + clist = gtk_object_get_user_data(GTK_OBJECT(handle)); + + if(clist && GTK_IS_CLIST(clist)) + gtk_clist_thaw(GTK_CLIST(clist)); + DW_MUTEX_UNLOCK; +} + +/* + * Removes all rows from a container. + * Parameters: + * handle: Handle to the window (widget) to be cleared. + */ +void dw_container_clear(HWND handle) +{ + GtkWidget *clist; + GList *list; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); + if(clist && GTK_IS_CLIST(clist)) + { + list = (GList *)gtk_object_get_data(GTK_OBJECT(clist), "selectlist"); + g_list_free(list); + gtk_object_set_data(GTK_OBJECT(clist), "selectlist", NULL); + gtk_clist_clear(GTK_CLIST(clist)); + } + DW_MUTEX_UNLOCK; +} + +/* + * Removes all rows from a container. + * Parameters: + * handle: Handle to the window (widget) to be cleared. + */ +void dw_container_set_view(HWND handle, unsigned long flags, int iconwidth, int iconheight) +{ +} + +/* + * Starts a new query of a container. + * Parameters: + * handle: Handle to the window (widget) to be queried. + * flags: If this parameter is DW_CRA_SELECTED it will only + * return items that are currently selected. Otherwise + * it will return all records in the container. + */ +char *dw_container_query_start(HWND handle, unsigned long flags) +{ + GtkWidget *clist; + GList *list; + char *retval = NULL; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); + + if(!clist) + { + DW_MUTEX_UNLOCK; + return NULL; + } + + /* If there is an old query list, free it */ + list = (GList *)gtk_object_get_data(GTK_OBJECT(clist), "querylist"); + if(list) + g_list_free(list); + + /* Move the current selection list to the query list, and remove the + * current selection list. + */ + list = (GList *)gtk_object_get_data(GTK_OBJECT(clist), "selectlist"); + gtk_object_set_data(GTK_OBJECT(clist), "selectlist", NULL); + gtk_object_set_data(GTK_OBJECT(clist), "querylist", (gpointer)list); + gtk_clist_unselect_all(GTK_CLIST(clist)); + + if(list) + { + gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)1); + if(list->data) + retval = list->data; + else + retval = ""; + } + DW_MUTEX_UNLOCK; + return retval; +} + +/* + * Continues an existing query of a container. + * Parameters: + * handle: Handle to the window (widget) to be queried. + * flags: If this parameter is DW_CRA_SELECTED it will only + * return items that are currently selected. Otherwise + * it will return all records in the container. + */ +char *dw_container_query_next(HWND handle, unsigned long flags) +{ + GtkWidget *clist; + GList *list; + char *retval = NULL; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); + + if(!clist) + { + DW_MUTEX_UNLOCK; + return NULL; + } + + list = (GList *)gtk_object_get_data(GTK_OBJECT(clist), "querylist"); + + if(list) + { + int counter = 0, pos = (int)gtk_object_get_data(GTK_OBJECT(clist), "querypos"); + gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)pos+1); + + while(list && counter < pos) + { + list = list->next; + counter++; + } + + if(list && list->data) + retval = list->data; + else if(list && !list->data) + retval = ""; + } + DW_MUTEX_UNLOCK; + return retval; +} + +/* + * Creates a rendering context widget (window) to be packed. + * Parameters: + * id: An id to be used with dw_window_from_id. + * Returns: + * A handle to the widget or NULL on failure. + */ +HWND dw_render_new(unsigned long id) +{ + int _locked_by_me = FALSE; + GtkWidget *tmp; + + DW_MUTEX_LOCK; + tmp = gtk_drawing_area_new(); + gtk_widget_set_events(tmp, GDK_EXPOSURE_MASK + | GDK_LEAVE_NOTIFY_MASK + | GDK_BUTTON_PRESS_MASK + | GDK_POINTER_MOTION_MASK + | GDK_POINTER_MOTION_HINT_MASK); + gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); + gtk_widget_show(tmp); + DW_MUTEX_UNLOCK; + return tmp; +} + +/* Sets the current foreground drawing color. + * Parameters: + * red: red value. + * green: green value. + * blue: blue value. + */ +void dw_color_foreground_set(unsigned long value) +{ + int _locked_by_me = FALSE; + GdkColor color = { 0, DW_RED_VALUE(value) << 8, DW_GREEN_VALUE(value) << 8, DW_BLUE_VALUE(value) << 8 }; + + DW_MUTEX_LOCK; + gdk_color_alloc(_dw_cmap, &color); + _foreground = color; + DW_MUTEX_UNLOCK; +} + +/* Sets the current background drawing color. + * Parameters: + * red: red value. + * green: green value. + * blue: blue value. + */ +void dw_color_background_set(unsigned long value) +{ + int _locked_by_me = FALSE; + GdkColor color = { 0, DW_RED_VALUE(value) << 8, DW_GREEN_VALUE(value) << 8, DW_BLUE_VALUE(value) << 8 }; + + DW_MUTEX_LOCK; + gdk_color_alloc(_dw_cmap, &color); + _background = color; + DW_MUTEX_UNLOCK; +} + +GdkGC *_set_colors(GdkWindow *window) +{ + GdkGC *gc; + if(!window) + return NULL; + gc = gdk_gc_new(window); + if(gc) + { + gdk_gc_set_foreground(gc, &_foreground); + gdk_gc_set_background(gc, &_background); + } + return gc; +} + +/* Draw a point on a window (preferably a render window). + * Parameters: + * handle: Handle to the window. + * pixmap: Handle to the pixmap. (choose only one of these) + * x: X coordinate. + * y: Y coordinate. + */ +void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) +{ + int _locked_by_me = FALSE; + GdkGC *gc = NULL; + + DW_MUTEX_LOCK; + if(handle) + gc = _set_colors(handle->window); + else if(pixmap) + gc = _set_colors(pixmap->pixmap); + if(gc) + { + gdk_draw_point(handle ? handle->window : pixmap->pixmap, gc, x, y); + gdk_gc_unref(gc); + } + DW_MUTEX_UNLOCK; +} + +/* Draw a line on a window (preferably a render window). + * Parameters: + * handle: Handle to the window. + * pixmap: Handle to the pixmap. (choose only one of these) + * x1: First X coordinate. + * y1: First Y coordinate. + * x2: Second X coordinate. + * y2: Second Y coordinate. + */ +void dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) +{ + int _locked_by_me = FALSE; + GdkGC *gc = NULL; + + DW_MUTEX_LOCK; + if(handle) + gc = _set_colors(handle->window); + else if(pixmap) + gc = _set_colors(pixmap->pixmap); + if(gc) + { + gdk_draw_line(handle ? handle->window : pixmap->pixmap, gc, x1, y1, x2, y2); + gdk_gc_unref(gc); + } + DW_MUTEX_UNLOCK; +} + +/* Draw a rectangle on a window (preferably a render window). + * Parameters: + * handle: Handle to the window. + * pixmap: Handle to the pixmap. (choose only one of these) + * x: X coordinate. + * y: Y coordinate. + * width: Width of rectangle. + * height: Height of rectangle. + */ +void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) +{ + int _locked_by_me = FALSE; + GdkGC *gc = NULL; + + DW_MUTEX_LOCK; + if(handle) + gc = _set_colors(handle->window); + else if(pixmap) + gc = _set_colors(pixmap->pixmap); + if(gc) + { + gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc, fill, x, y, width, height); + gdk_gc_unref(gc); + } + DW_MUTEX_UNLOCK; +} + +/* Draw text on a window (preferably a render window). + * Parameters: + * handle: Handle to the window. + * pixmap: Handle to the pixmap. (choose only one of these) + * x: X coordinate. + * y: Y coordinate. +* text: Text to be displayed. + */ +void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) +{ + int _locked_by_me = FALSE; + GdkGC *gc = NULL; + GdkFont *font; + char *fontname = "fixed"; + + DW_MUTEX_LOCK; + if(handle) + { + fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "fontname"); + gc = _set_colors(handle->window); + } + else if(pixmap) + { + fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "fontname"); + gc = _set_colors(pixmap->pixmap); + } + if(gc) + { + font = gdk_font_load(fontname); + if(font) + { + gint ascent; + + gdk_text_extents(font, text, strlen(text), NULL, NULL, NULL, &ascent, NULL); + gdk_draw_text(handle ? handle->window : pixmap->pixmap, font, gc, x, y + ascent, text, strlen(text)); + gdk_gc_unref(gc); + gdk_font_unref(font); + } + } + DW_MUTEX_UNLOCK; +} + +/* + * Creates a pixmap with given parameters. + * Parameters: + * handle: Window handle the pixmap is associated with. + * width: Width of the pixmap in pixels. + * height: Height of the pixmap in pixels. + * depth: Color depth of the pixmap. + * Returns: + * A handle to a pixmap or NULL on failure. + */ +HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) +{ + int _locked_by_me = FALSE; + HPIXMAP pixmap; + + if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) + return NULL; + + if (!depth) + depth = 24; + + pixmap->width = width; pixmap->height = height; + + + DW_MUTEX_LOCK; + pixmap->handle = handle; + pixmap->pixmap = gdk_pixmap_new(handle->window, width, height, depth); + DW_MUTEX_UNLOCK; + return pixmap; +} + +/* + * Creates a pixmap from internal resource graphic specified by id. + * Parameters: + * handle: Window handle the pixmap is associated with. + * id: Resource ID associated with requested pixmap. + * Returns: + * A handle to a pixmap or NULL on failure. + */ +HPIXMAP dw_pixmap_grab(HWND handle, ULONG id) +{ + GdkBitmap *bitmap; + HPIXMAP pixmap; + int _locked_by_me = FALSE; + + if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) + return NULL; + + + DW_MUTEX_LOCK; + pixmap->pixmap = _find_pixmap(&bitmap, id, handle); + if(pixmap->pixmap) + { + GdkPixmapPrivate *pvt = (GdkPixmapPrivate *)pixmap->pixmap; + pixmap->width = pvt->width; pixmap->height = pvt->height; + } + DW_MUTEX_UNLOCK; + return pixmap; +} + +/* Call this after drawing to the screen to make sure + * anything you have drawn is visible. + */ +void dw_flush(void) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + gdk_flush(); + DW_MUTEX_UNLOCK; +} + +/* + * Destroys an allocated pixmap. + * Parameters: + * pixmap: Handle to a pixmap returned by + * dw_pixmap_new.. + */ +void dw_pixmap_destroy(HPIXMAP pixmap) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + gdk_pixmap_unref(pixmap->pixmap); + free(pixmap); + DW_MUTEX_UNLOCK; +} + +/* + * Copies from one item to another. + * Parameters: + * dest: Destination window handle. + * destp: Destination pixmap. (choose only one). + * xdest: X coordinate of destination. + * ydest: Y coordinate of destination. + * width: Width of area to copy. + * height: Height of area to copy. + * src: Source window handle. + * srcp: Source pixmap. (choose only one). + * xsrc: X coordinate of source. + * ysrc: Y coordinate of source. + */ +void dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) +{ + int _locked_by_me = FALSE; + GdkGC *gc = NULL; + + if((!dest && !destp) || (!src && !srcp)) + return; + + DW_MUTEX_LOCK; + if(dest) + gc = _set_colors(dest->window); + else if(src) + gc = _set_colors(src->window); + else if(destp) + gc = gdk_gc_new(destp->pixmap); + else if(srcp) + gc = gdk_gc_new(srcp->pixmap); + + if(gc) + { + gdk_draw_pixmap(dest ? dest->window : destp->pixmap, gc, src ? src->window : srcp->pixmap, xsrc, ysrc, xdest, ydest, width, height); + gdk_gc_unref(gc); + } + DW_MUTEX_UNLOCK; +} + +/* + * Emits a beep. + * Parameters: + * freq: Frequency. + * dur: Duration. + */ +void dw_beep(int freq, int dur) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + gdk_beep(); + DW_MUTEX_UNLOCK; +} + +/* + * Returns the handle to an unnamed mutex semaphore. + */ +HMTX dw_mutex_new(void) +{ + HMTX mutex; + + pthread_mutex_init(&mutex, NULL); + return mutex; +} + +/* + * Closes a semaphore created by dw_mutex_new(). + * Parameters: + * mutex: The handle to the mutex returned by dw_mutex_new(). + */ +void dw_mutex_close(HMTX mutex) +{ + pthread_mutex_destroy(&mutex); +} + +/* + * Tries to gain access to the semaphore, if it can't it blocks. + * Parameters: + * mutex: The handle to the mutex returned by dw_mutex_new(). + */ +void dw_mutex_lock(HMTX mutex) +{ + pthread_mutex_lock(&mutex); +} + +/* + * Reliquishes the access to the semaphore. + * Parameters: + * mutex: The handle to the mutex returned by dw_mutex_new(). + */ +void dw_mutex_unlock(HMTX mutex) +{ + pthread_mutex_unlock(&mutex); +} + +/* + * Returns the handle to an unnamed event semaphore. + */ +HEV dw_event_new(void) +{ + HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event)); + + if(!eve) + return NULL; + + /* We need to be careful here, mutexes on Linux are + * FAST by default but are error checking on other + * systems such as FreeBSD and OS/2, perhaps others. + */ + pthread_mutex_init (&(eve->mutex), NULL); + pthread_mutex_lock (&(eve->mutex)); + pthread_cond_init (&(eve->event), NULL); + + pthread_mutex_unlock (&(eve->mutex)); + eve->alive = 1; + eve->posted = 0; + + return eve; +} + +/* + * Resets a semaphore created by dw_event_new(). + * Parameters: + * eve: The handle to the event returned by dw_event_new(). + */ +int dw_event_reset (HEV eve) +{ + if(!eve) + return FALSE; + + pthread_mutex_lock (&(eve->mutex)); + pthread_cond_broadcast (&(eve->event)); + pthread_cond_init (&(eve->event), NULL); + eve->posted = 0; + pthread_mutex_unlock (&(eve->mutex)); + return 0; +} + +/* + * Posts a semaphore created by dw_event_new(). Causing all threads + * waiting on this event in dw_event_wait to continue. + * Parameters: + * eve: The handle to the event returned by dw_event_new(). + */ +int dw_event_post (HEV eve) +{ + if(!eve) + return FALSE; + + pthread_mutex_lock (&(eve->mutex)); + pthread_cond_broadcast (&(eve->event)); + eve->posted = 1; + pthread_mutex_unlock (&(eve->mutex)); + return 0; +} + +/* + * Waits on a semaphore created by dw_event_new(), until the + * event gets posted or until the timeout expires. + * Parameters: + * eve: The handle to the event returned by dw_event_new(). + */ +int dw_event_wait(HEV eve, unsigned long timeout) +{ + int rc; + struct timeval now; + struct timespec timeo; + + if(!eve) + return FALSE; + + if(eve->posted) + return 0; + + pthread_mutex_lock (&(eve->mutex)); + gettimeofday(&now, 0); + timeo.tv_sec = now.tv_sec + (timeout / 1000); + timeo.tv_nsec = now.tv_usec * 1000; + rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo); + pthread_mutex_unlock (&(eve->mutex)); + if(!rc) + return 1; + if(rc == ETIMEDOUT) + return -1; + return 0; +} + +/* + * Closes a semaphore created by dw_event_new(). + * Parameters: + * eve: The handle to the event returned by dw_event_new(). + */ +int dw_event_close(HEV *eve) +{ + if(!eve || !(*eve)) + return FALSE; + + pthread_mutex_lock (&((*eve)->mutex)); + pthread_cond_destroy (&((*eve)->event)); + pthread_mutex_unlock (&((*eve)->mutex)); + pthread_mutex_destroy (&((*eve)->mutex)); + free(*eve); + *eve = NULL; + + return TRUE; +} + +/* + * Creates a new thread with a starting point of func. + * Parameters: + * func: Function which will be run in the new thread. + * data: Parameter(s) passed to the function. + * stack: Stack size of new thread (OS/2 and Windows only). + */ +DWTID dw_thread_new(void *func, void *data, int stack) +{ + DWTID gtkthread; + + pthread_create(>kthread, NULL, func, data); + return gtkthread; +} + +/* + * Ends execution of current thread immediately. + */ +void dw_thread_end(void) +{ + pthread_exit(NULL); +} + +/* + * Cleanly terminates a DW session, should be signal handler safe. + * Parameters: + * exitcode: Exit code reported to the operating system. + */ +void dw_exit(int exitcode) +{ + exit(exitcode); +} + +/* + * Pack windows (widgets) into a box from the end (or bottom). + * Parameters: + * box: Window handle of the box to be packed into. + * item: Window handle of the item to be back. + * width: Width in pixels of the item or -1 to be self determined. + * height: Height in pixels of the item or -1 to be self determined. + * hsize: TRUE if the window (widget) should expand horizontally to fill space given. + * vsize: TRUE if the window (widget) should expand vertically to fill space given. + * pad: Number of pixels of padding around the item. + */ +void dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) +{ + int expand = (hsize == FALSE && vsize == FALSE) ? FALSE : TRUE; + int _locked_by_me = FALSE; + + if(!box) + return; + + DW_MUTEX_LOCK; + + if(!item) + { + item = gtk_label_new(""); + gtk_widget_show(item); + } + + if(GTK_IS_BOX(box)) + { + gtk_box_pack_end(GTK_BOX(box), item, expand, TRUE, pad); + gtk_widget_set_usize(item, width, height); + if(GTK_IS_RADIO_BUTTON(item)) + { + GSList *group; + GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "group"); + + if(groupstart) + { + group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart)); + gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); + } + else + gtk_object_set_data(GTK_OBJECT(box), "group", (gpointer)item); + } + } + else + { + GtkWidget *vbox = gtk_vbox_new(FALSE, 0); + + gtk_container_add(GTK_CONTAINER(box), vbox); + gtk_box_pack_end(GTK_BOX(vbox), item, expand, TRUE, 0); + gtk_widget_show(vbox); + + gtk_widget_set_usize(item, width, height); + gtk_object_set_user_data(GTK_OBJECT(box), vbox); + } + DW_MUTEX_UNLOCK; +} + +/* + * Sets the size of a given window (widget). + * Parameters: + * handle: Window (widget) handle. + * width: New width in pixels. + * height: New height in pixels. + */ +void dw_window_set_usize(HWND handle, unsigned long width, unsigned long height) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_WINDOW(handle)) + _size_allocate(GTK_WINDOW(handle)); +#if 0 + gtk_window_set_default_size(GTK_WINDOW(handle), width, height); + else +#endif + gtk_widget_set_usize(handle, width, height); + DW_MUTEX_UNLOCK; +} + +/* + * Returns the width of the screen. + */ +int dw_screen_width(void) +{ + int retval; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + retval = gdk_screen_width(); + DW_MUTEX_UNLOCK; + return retval; +} + +/* + * Returns the height of the screen. + */ +int dw_screen_height(void) +{ + int retval; + int _locked_by_me = FALSE; + + DW_MUTEX_UNLOCK; + retval = gdk_screen_height(); + DW_MUTEX_UNLOCK; + return retval; +} + +/* This should return the current color depth */ +unsigned long dw_color_depth(void) +{ + int retval; + int _locked_by_me = FALSE; + + DW_MUTEX_UNLOCK; + retval = gdk_colormap_get_system_size(); + DW_MUTEX_UNLOCK; + return retval; +} + +/* + * Sets the position of a given window (widget). + * Parameters: + * handle: Window (widget) handle. + * x: X location from the bottom left. + * y: Y location from the bottom left. + */ +void dw_window_set_pos(HWND handle, unsigned long x, unsigned long y) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(handle->window) + gdk_window_move(handle->window, x, y); + DW_MUTEX_UNLOCK; +} + +/* + * Sets the position and size of a given window (widget). + * Parameters: + * handle: Window (widget) handle. + * x: X location from the bottom left. + * y: Y location from the bottom left. + * width: Width of the widget. + * height: Height of the widget. + */ +void dw_window_set_pos_size(HWND handle, unsigned long x, unsigned long y, unsigned long width, unsigned long height) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_WINDOW(handle)) + { + _size_allocate(GTK_WINDOW(handle)); + gtk_widget_set_uposition(handle, x, y); + gtk_window_set_default_size(GTK_WINDOW(handle), width, height); + } + else if(handle->window) + { + gdk_window_resize(handle->window, width, height); + gdk_window_move(handle->window, x, y); + } + DW_MUTEX_UNLOCK; +} + +/* + * Gets the position and size of a given window (widget). + * Parameters: + * handle: Window (widget) handle. + * x: X location from the bottom left. + * y: Y location from the bottom left. + * width: Width of the widget. + * height: Height of the widget. + */ +void dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height) +{ + int _locked_by_me = FALSE; + gint gx, gy, gwidth, gheight, gdepth; + + if(handle->window) + { + DW_MUTEX_LOCK; + gdk_window_get_geometry(handle->window, &gx, &gy, &gwidth, &gheight, &gdepth); + gdk_window_get_root_origin(handle->window, &gx, &gy); + if(x) + *x = gx; + if(y) + *y = gy; + if(width) + *width = gwidth; + if(height) + *height = gheight; + DW_MUTEX_UNLOCK; + } +} + +/* + * Sets the style of a given window (widget). + * Parameters: + * handle: Window (widget) handle. + * width: New width in pixels. + * height: New height in pixels. + */ +void dw_window_set_style(HWND handle, unsigned long style, unsigned long mask) +{ + GtkWidget *handle2 = handle; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_SCROLLED_WINDOW(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); + if(tmp) + handle2 = tmp; + } + if(GTK_IS_CLIST(handle2)) + { + if(style & DW_CCS_EXTENDSEL) + gtk_clist_set_selection_mode(GTK_CLIST(handle2), GTK_SELECTION_MULTIPLE); + if(style & DW_CCS_SINGLESEL) + gtk_clist_set_selection_mode(GTK_CLIST(handle2), GTK_SELECTION_SINGLE); + } + DW_MUTEX_UNLOCK; +} + +/* + * Adds a new page to specified notebook. + * Parameters: + * handle: Window (widget) handle. + * flags: Any additional page creation flags. + * front: If TRUE page is added at the beginning. + */ +unsigned long dw_notebook_page_new(HWND handle, unsigned long flags, int front) +{ + int z; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + for(z=0;z<256;z++) + if(!gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), z)) + { + DW_MUTEX_UNLOCK; + return z; + } + + DW_MUTEX_UNLOCK; + + /* Hopefully this won't happen. */ + return 256; +} + +/* + * Remove a page from a notebook. + * Parameters: + * handle: Handle to the notebook widget. + * pageid: ID of the page to be destroyed. + */ +void dw_notebook_page_destroy(HWND handle, unsigned int pageid) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + gtk_notebook_remove_page(GTK_NOTEBOOK(handle), pageid); + DW_MUTEX_UNLOCK; +} + +/* + * Queries the currently visible page ID. + * Parameters: + * handle: Handle to the notebook widget. + */ +unsigned int dw_notebook_page_query(HWND handle) +{ + int retval; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + retval = gtk_notebook_get_current_page(GTK_NOTEBOOK(handle)); + DW_MUTEX_UNLOCK; + return retval; +} + +/* + * Sets the currently visibale page ID. + * Parameters: + * handle: Handle to the notebook widget. + * pageid: ID of the page to be made visible. + */ +void dw_notebook_page_set(HWND handle, unsigned int pageid) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + gtk_notebook_set_page(GTK_NOTEBOOK(handle), pageid); + DW_MUTEX_UNLOCK; +} + + +/* + * Sets the text on the specified notebook tab. + * Parameters: + * handle: Notebook handle. + * pageid: Page ID of the tab to set. + * text: Pointer to the text to set. + */ +void dw_notebook_page_set_text(HWND handle, unsigned long pageid, char *text) +{ + GtkWidget *child; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), pageid); + if(child) + gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(handle), child, text); + DW_MUTEX_UNLOCK; +} + +/* + * Sets the text on the specified notebook tab status area. + * Parameters: + * handle: Notebook handle. + * pageid: Page ID of the tab to set. + * text: Pointer to the text to set. + */ +void dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, char *text) +{ + /* TODO (if possible) */ +} + +/* + * Packs the specified box into the notebook page. + * Parameters: + * handle: Handle to the notebook to be packed. + * pageid: Page ID in the notebook which is being packed. + * page: Box handle to be packed. + */ +void dw_notebook_pack(HWND handle, unsigned long pageid, HWND page) +{ + GtkWidget *label; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + label = gtk_label_new(""); + + gtk_notebook_append_page (GTK_NOTEBOOK(handle), page, label); + DW_MUTEX_UNLOCK; +} + +/* + * Appends the specified text to the listbox's (or combobox) entry list. + * Parameters: + * handle: Handle to the listbox to be appended to. + * text: Text to append into listbox. + */ +void dw_listbox_append(HWND handle, char *text) +{ + GtkWidget *handle2 = handle; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_SCROLLED_WINDOW(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); + if(tmp) + handle2 = tmp; + } + if(GTK_IS_LIST(handle2)) + { + GtkWidget *list_item; + GList *tmp; + char *font = (char *)gtk_object_get_data(GTK_OBJECT(handle), "font"); + unsigned long fore = (unsigned long)gtk_object_get_data(GTK_OBJECT(handle), "fore"); + unsigned long back = (unsigned long)gtk_object_get_data(GTK_OBJECT(handle), "back"); + + list_item=gtk_list_item_new_with_label(text); + + if(font) + _set_font(GTK_LIST_ITEM(list_item)->item.bin.child, font); + if(fore && back) + _set_color(GTK_LIST_ITEM(list_item)->item.bin.child, fore, back); + + tmp = g_list_append(NULL, list_item); + gtk_widget_show(list_item); + gtk_list_append_items(GTK_LIST(handle2),tmp); + } + else if(GTK_IS_COMBO(handle2)) + { + GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2)); + char *addtext = strdup(text); + + if(addtext) + { + tmp = g_list_append(tmp, addtext); + gtk_object_set_user_data(GTK_OBJECT(handle2), tmp); + gtk_combo_set_popdown_strings(GTK_COMBO(handle2), tmp); + } + } + DW_MUTEX_UNLOCK; +} + +/* + * Clears the listbox's (or combobox) list of all entries. + * Parameters: + * handle: Handle to the listbox to be cleared. + */ +void dw_listbox_clear(HWND handle) +{ + GtkWidget *handle2 = handle; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_SCROLLED_WINDOW(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); + if(tmp) + handle2 = tmp; + } + if(GTK_IS_COMBO(handle2)) + { + GList *list, *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2)); + + if(tmp) + { + list = tmp; + while(list) + { + if(list->data) + free(list->data); + list=list->next; + } + g_list_free(tmp); + } + gtk_object_set_user_data(GTK_OBJECT(handle2), NULL); + } + else if(GTK_IS_LIST(handle2)) + { + int count = dw_listbox_count(handle); + + gtk_list_clear_items(GTK_LIST(handle2), 0, count - 1); + } + DW_MUTEX_UNLOCK; +} + +/* + * Returns the listbox's item count. + * Parameters: + * handle: Handle to the listbox to be counted + */ +int dw_listbox_count(HWND handle) +{ + GtkWidget *handle2 = handle; + int retval = 0; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_SCROLLED_WINDOW(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); + if(tmp) + handle2 = tmp; + } + else if(GTK_IS_COMBO(handle)) + { + handle2 = GTK_COMBO(handle)->list; + } + if(GTK_IS_LIST(handle2)) + { + GList *list = GTK_LIST(handle2)->children; + while(list) + { + list = list->next; + retval++; + } + } + DW_MUTEX_UNLOCK; + return retval; +} + +/* + * Sets the topmost item in the viewport. + * Parameters: + * handle: Handle to the listbox to be cleared. + * top: Index to the top item. + */ +void dw_listbox_set_top(HWND handle, int top) +{ + GtkWidget *handle2 = handle; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_SCROLLED_WINDOW(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); + if(tmp) + handle2 = tmp; + } + if(GTK_IS_LIST(handle2)) + { + int count = dw_listbox_count(handle); + GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle)); + float pos, ratio; + + if(count) + { + ratio = (float)top/(float)count; + + pos = (ratio * (float)(adj->upper - adj->lower)) + adj->lower; + + gtk_adjustment_set_value(adj, pos); + } + } + DW_MUTEX_UNLOCK; +} + +/* + * Copies the given index item's text into buffer. + * Parameters: + * handle: Handle to the listbox to be queried. + * index: Index into the list to be queried. + * buffer: Buffer where text will be copied. + * length: Length of the buffer (including NULL). + */ +void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length) +{ + GtkWidget *handle2 = handle; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_SCROLLED_WINDOW(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); + if(tmp) + handle2 = tmp; + } + else if(GTK_IS_COMBO(handle)) + { + handle2 = GTK_COMBO(handle)->list; + } + if(GTK_IS_LIST(handle2)) + { + int counter = 0; + GList *list = GTK_LIST(handle2)->children; + + while(list) + { + if(counter == index) + { + gchar *text = ""; + + if(GTK_IS_LIST_ITEM(list->data)) + { + GtkListItem *li = GTK_LIST_ITEM(list->data); + + if(GTK_IS_ITEM(&(li->item))) + { + GtkItem *i = &(li->item); + + if(GTK_IS_BIN(&(i->bin))) + { + GtkBin *b = &(i->bin); + + if(GTK_IS_LABEL(b->child)) + gtk_label_get(GTK_LABEL(b->child), &text); + } + } + } + else if(GTK_IS_COMBO(handle) && list->data) + text = (gchar *)list->data; + + strncpy(buffer, (char *)text, length); + break; + } + list = list->next; + counter++; + } + } + DW_MUTEX_UNLOCK; +} + +/* + * Sets the text of a given listbox entry. + * Parameters: + * handle: Handle to the listbox to be queried. + * index: Index into the list to be queried. + * buffer: Buffer where text will be copied. + */ +void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) +{ + GtkWidget *handle2 = handle; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_SCROLLED_WINDOW(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); + if(tmp) + handle2 = tmp; + } + else if(GTK_IS_COMBO(handle)) + { + handle2 = GTK_COMBO(handle)->list; + } + if(GTK_IS_LIST(handle2)) + { + int counter = 0; + GList *list = GTK_LIST(handle2)->children; + + while(list) + { + if(counter == index) + { + + if(GTK_IS_LIST_ITEM(list->data)) + { + GtkListItem *li = GTK_LIST_ITEM(list->data); + + if(GTK_IS_ITEM(&(li->item))) + { + GtkItem *i = &(li->item); + + if(GTK_IS_BIN(&(i->bin))) + { + GtkBin *b = &(i->bin); + + if(GTK_IS_LABEL(b->child)) + gtk_label_set_text(GTK_LABEL(b->child), buffer); + } + } + } + else if(GTK_IS_COMBO(handle)) + { + if(list->data) + g_free(list->data); + list->data = g_strdup(buffer); + } + break; + } + list = list->next; + counter++; + } + } + DW_MUTEX_UNLOCK; +} + +/* + * Returns the index to the item in the list currently selected. + * Parameters: + * handle: Handle to the listbox to be queried. + */ +unsigned int dw_listbox_selected(HWND handle) +{ + GtkWidget *handle2 = handle; + int retval = DW_LIT_NONE; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_SCROLLED_WINDOW(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); + if(tmp) + handle2 = tmp; + } + else if(GTK_IS_COMBO(handle)) + { + retval = (unsigned int)gtk_object_get_data(GTK_OBJECT(handle), "item"); + DW_MUTEX_UNLOCK; + return retval; + } + if(GTK_IS_LIST(handle2)) + { + int counter = 0; + GList *list = GTK_LIST(handle2)->children; + while(list) + { + if(list == GTK_LIST(handle2)->selection) + { + retval = counter; + break; + } + + list = list->next; + counter++; + } + } + DW_MUTEX_UNLOCK; + return retval; +} + +/* + * Sets the selection state of a given index. + * Parameters: + * handle: Handle to the listbox to be set. + * index: Item index. + * state: TRUE if selected FALSE if unselected. + */ +void dw_listbox_select(HWND handle, int index, int state) +{ + GtkWidget *handle2 = handle; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_SCROLLED_WINDOW(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); + if(tmp) + handle2 = tmp; + } + else if(GTK_IS_COMBO(handle)) + { + handle2 = GTK_COMBO(handle)->list; + } + if(GTK_IS_LIST(handle2)) + { + if(state) + gtk_list_select_item(GTK_LIST(handle2), index); + else + gtk_list_unselect_item(GTK_LIST(handle2), index); + } + DW_MUTEX_UNLOCK; +} + +/* + * Deletes the item with given index from the list. + * Parameters: + * handle: Handle to the listbox to be set. + * index: Item index. + */ +void dw_listbox_delete(HWND handle, int index) +{ + GtkWidget *handle2 = handle; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_SCROLLED_WINDOW(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); + if(tmp) + handle2 = tmp; + } + else if(GTK_IS_COMBO(handle)) + { + handle2 = GTK_COMBO(handle)->list; + } + if(GTK_IS_LIST(handle2)) + gtk_list_clear_items(GTK_LIST(handle2), index, index); + DW_MUTEX_UNLOCK; +} + + +/* + * Pack a splitbar (sizer) into the specified box from the start. + * Parameters: + * box: Window handle of the box to be packed into. + */ +void dw_box_pack_splitbar_start(HWND box) +{ + /* TODO */ +} + +/* + * Pack a splitbar (sizer) into the specified box from the end. + * Parameters: + * box: Window handle of the box to be packed into. + */ +void dw_box_pack_splitbar_end(HWND box) +{ + /* TODO */ +} + +/* + * Pack windows (widgets) into a box from the start (or top). + * Parameters: + * box: Window handle of the box to be packed into. + * item: Window handle of the item to be back. + * width: Width in pixels of the item or -1 to be self determined. + * height: Height in pixels of the item or -1 to be self determined. + * hsize: TRUE if the window (widget) should expand horizontally to fill space given. + * vsize: TRUE if the window (widget) should expand vertically to fill space given. + * pad: Number of pixels of padding around the item. + */ +void dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) +{ + int expand = (hsize == FALSE && vsize == FALSE) ? FALSE : TRUE; + int _locked_by_me = FALSE; + + if(!box) + return; + + DW_MUTEX_LOCK; + + if(!item) + { + item = gtk_label_new(""); + gtk_widget_show(item); + } + + if(GTK_IS_BOX(box)) + { + gtk_box_pack_start(GTK_BOX(box), item, expand, TRUE, pad); + gtk_widget_set_usize(item, width, height); + if(GTK_IS_RADIO_BUTTON(item)) + { + GSList *group; + GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "group"); + + if(groupstart) + { + group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart)); + gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); + } + else + gtk_object_set_data(GTK_OBJECT(box), "group", (gpointer)item); + } + } + else + { + GtkWidget *vbox = gtk_vbox_new(FALSE, 0); + + gtk_container_add(GTK_CONTAINER(box), vbox); + gtk_box_pack_end(GTK_BOX(vbox), item, expand, TRUE, 0); + gtk_widget_show(vbox); + + gtk_widget_set_usize(item, width, height); + gtk_object_set_user_data(GTK_OBJECT(box), vbox); + } + DW_MUTEX_UNLOCK; +} + +/* + * Returns some information about the current operating environment. + * Parameters: + * env: Pointer to a DWEnv struct. + */ +void dw_environment_query(DWEnv *env) +{ + struct utsname name; + char tempbuf[100]; + int len, z; + + uname(&name); + strcpy(env->osName, name.sysname); + strcpy(tempbuf, name.release); + + env->MajorBuild = env->MinorBuild = 0; + + len = strlen(tempbuf); + + for(z=1;z<len;z++) + { + if(tempbuf[z] == '.') + { + tempbuf[z] = '\0'; + env->MajorVersion = atoi(&tempbuf[z-1]); + env->MinorVersion = atoi(&tempbuf[z+1]); + return; + } + } + env->MajorVersion = atoi(tempbuf); + env->MinorVersion = 0; +} + +/* Internal function to handle the file OK press */ +void _gtk_file_ok(GtkWidget *widget, GtkWidget *window) +{ + char *tmp; + + tmp = gtk_file_selection_get_filename(GTK_FILE_SELECTION(window)); + if(tmp) + _dw_browse_file = strdup(tmp); + gtk_widget_destroy(GTK_WIDGET(window)); + if(pthread_self() == _dw_thread) + gtk_main_quit(); + _dw_file_ready = 1; +} + +/* Internal function to handle the file Cancel press */ +void _gtk_file_cancel(GtkWidget *widget, GtkWidget *window) +{ + gtk_widget_destroy(GTK_WIDGET(window)); + if(pthread_self() == _dw_thread) + gtk_main_quit(); + _dw_file_ready = 1; + +} + +/* + * Opens a file dialog and queries user selection. + * Parameters: + * title: Title bar text for dialog. + * defpath: The default path of the open dialog. + * ext: Default file extention. + * flags: DW_FILE_OPEN or DW_FILE_SAVE. + * Returns: + * NULL on error. A malloced buffer containing + * the file path on success. + * + */ +char *dw_file_browse(char *title, char *defpath, char *ext, int flags) +{ + GtkWidget *filew; + char *tmpvar; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + + /* The DW mutex should be sufficient for + * insuring no thread changes this unknowingly. + */ + if(_dw_file_active) + { + DW_MUTEX_UNLOCK; + return NULL; + } + + _dw_file_active = 1; + _dw_file_ready = 0; + + filew = gtk_file_selection_new(title); + + gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew)->ok_button), "clicked", (GtkSignalFunc) _gtk_file_ok, filew); + gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew)->cancel_button), "clicked", (GtkSignalFunc) _gtk_file_cancel, filew); + + if(defpath) + gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew), defpath); + + gtk_widget_show(filew); + + DW_MUTEX_UNLOCK; + + if(pthread_self() == _dw_thread) + gtk_main(); + else + { + /* This should be an event semaphore */ + while(!_dw_file_ready) + usleep(100); + } + + tmpvar = _dw_browse_file; + _dw_browse_file = NULL; + _dw_file_ready = _dw_file_active = 0; + + return tmpvar; +} + + +/* + * Execute and external program in a seperate session. + * Parameters: + * program: Program name with optional path. + * type: Either DW_EXEC_CON or DW_EXEC_GUI. + * params: An array of pointers to string arguements. + * Returns: + * -1 on error. + */ +int dw_exec(char *program, int type, char **params) +{ + int ret = -1; + + if((ret = fork()) == 0) + { + int i; + + for (i = 3; i < 256; i++) + close(i); + setsid(); + if(type == DW_EXEC_GUI) + { + execvp(program, params); + } + else if(type == DW_EXEC_CON) + { + char **tmpargs; + + if(!params) + { + tmpargs = malloc(sizeof(char *)); + tmpargs[0] = NULL; + } + else + { + int z = 0; + + while(params[z]) + { + z++; + } + tmpargs = malloc(sizeof(char *)*(z+3)); + z=0; + tmpargs[0] = "xterm"; + tmpargs[1] = "-e"; + while(params[z]) + { + tmpargs[z+2] = params[z]; + z++; + } + tmpargs[z+2] = NULL; + } + execvp("xterm", tmpargs); + free(tmpargs); + } + /* If we got here exec failed */ + _exit(-1); + } + return ret; +} + +/* + * Loads a web browser pointed at the given URL. + * Parameters: + * url: Uniform resource locator. + */ +int dw_browse(char *url) +{ + /* Is there a way to find the webbrowser in Unix? */ + char *execargs[3], *browser = "netscape"; + + execargs[0] = browser; + execargs[1] = url; + execargs[2] = NULL; + + return dw_exec(browser, DW_EXEC_GUI, execargs); +} + +/* + * Returns a pointer to a static buffer which containes the + * current user directory. Or the root directory (C:\ on + * OS/2 and Windows). + */ +char *dw_user_dir(void) +{ + static char _user_dir[1024] = ""; + + if(!_user_dir[0]) + { + char *home = getenv("HOME"); + + if(home) + strcpy(_user_dir, home); + else + strcpy(_user_dir, "/"); + } + return _user_dir; +} + +/* + * Call a function from the window (widget)'s context. + * Parameters: + * handle: Window handle of the widget. + * function: Function pointer to be called. + * data: Pointer to the data to be passed to the function. + */ +void dw_window_function(HWND handle, void *function, void *data) +{ + /* TODO */ +} + +#ifndef NO_SIGNALS +/* + * Add a callback to a window event. + * Parameters: + * window: Window handle of signal to be called back. + * signame: A string pointer identifying which signal to be hooked. + * sigfunc: The pointer to the function to be used as the callback. + * data: User data to be passed to the handler function. + */ +void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) +{ + SignalHandler *work = malloc(sizeof(SignalHandler)); + void *thisfunc = _findsigfunc(signame); + char *thisname = signame; + HWND thiswindow = window; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_SCROLLED_WINDOW(thiswindow)) + { + thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window)); + } + + if(GTK_IS_MENU_ITEM(thiswindow) && strcmp(signame, "clicked") == 0) + { + thisname = "activate"; + thisfunc = _findsigfunc(thisname); + } + else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, "container-context") == 0) + { + thisname = "button_press_event"; + thisfunc = _findsigfunc("container-context"); + } + else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, "container-select") == 0) + { + thisname = "button_press_event"; + thisfunc = _findsigfunc("container-select"); + } + else if(GTK_IS_COMBO(thiswindow) && strcmp(signame, "item-select") == 0) + { + thisname = "select_child"; + thiswindow = GTK_COMBO(thiswindow)->list; + } + else if(GTK_IS_LIST(thiswindow) && strcmp(signame, "item-select") == 0) + { + thisname = "select_child"; + } + + if(!thisfunc || !thiswindow) + { + free(work); + DW_MUTEX_UNLOCK; + return; + } + + work->window = window; + work->data = data; + work->func = sigfunc; + + gtk_signal_connect(GTK_OBJECT(thiswindow), thisname, GTK_SIGNAL_FUNC(thisfunc), work); + DW_MUTEX_UNLOCK; +} + +/* + * Removes callbacks for a given window with given name. + * Parameters: + * window: Window handle of callback to be removed. + */ +void dw_signal_disconnect_by_name(HWND window, char *signame) +{ +#if 0 + gtk_signal_disconnect_by_name(window, signame); +#endif +} + +/* + * Removes all callbacks for a given window. + * Parameters: + * window: Window handle of callback to be removed. + */ +void dw_signal_disconnect_by_window(HWND window) +{ +#if 0 + gtk_signal_disconnect_by_window(window); +#endif +} + +/* + * Removes all callbacks for a given window with specified data. + * Parameters: + * window: Window handle of callback to be removed. + * data: Pointer to the data to be compared against. + */ +void dw_signal_disconnect_by_data(HWND window, void *data) +{ + dw_signal_disconnect_by_data(window, data); +} +#endif + +#ifdef TEST +HWND mainwindow, + listbox, + okbutton, + cancelbutton, + lbbox, + stext, + buttonbox, + testwindow, + testbox, + testok, + testcancel, + testbox2, + testok2, + testcancel2, + notebook; +int count = 2; + +int test_callback(HWND window, void *data) +{ + dw_window_destroy((HWND)data); + /* Return -1 to allow the default handlers to return. */ + count--; + if(!count) + exit(0); + return -1; +} + +/* + * Let's demonstrate the functionality of this library. :) + */ +int main(void) +{ + unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | + DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; + int pageid; + + dw_init(TRUE); + + /* Try a little server dialog. :) */ + mainwindow = dw_window_new(DW_DESKTOP, "Server", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX); + + lbbox = dw_box_new(BOXVERT, 10); + + dw_box_pack_start(mainwindow, lbbox, 0, 0, TRUE, TRUE, 0); + + stext = dw_text_new("Choose a server:", 0); + + dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER); + + dw_box_pack_start(lbbox, stext, 130, 15, FALSE, FALSE, 10); + + listbox = dw_listbox_new(100L, FALSE); + + dw_box_pack_start(lbbox, listbox, 130, 200, TRUE, TRUE, 10); + + buttonbox = dw_box_new(BOXHORZ, 0); + + dw_box_pack_start(lbbox, buttonbox, 0, 0, TRUE, TRUE, 0); + + okbutton = dw_button_new("Ok", 1001L); + + dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, TRUE, 5); + + cancelbutton = dw_button_new("Cancel", 1002L); + + dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, TRUE, 5); + + /* Set some nice fonts and colors */ + dw_window_set_color(lbbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + dw_window_set_color(buttonbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + dw_window_set_font(stext, "9.WarpSans"); + dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY); + dw_window_set_font(listbox, "9.WarpSans"); + dw_window_set_font(okbutton, "9.WarpSans"); + dw_window_set_font(cancelbutton, "9.WarpSans"); + + dw_window_show(mainwindow); + + dw_window_set_usize(mainwindow, 170, 340); + + /* Another small example */ + flStyle |= DW_FCF_MINMAX | DW_FCF_SIZEBORDER; + + testwindow = dw_window_new(DW_DESKTOP, "Wow a test dialog! :) yay!", flStyle); + + testbox = dw_box_new(BOXVERT, 0); + + dw_box_pack_start(testwindow, testbox, 0, 0, TRUE, TRUE, 0); + + notebook = dw_notebook_new(1010L, TRUE); + + dw_box_pack_start(testbox, notebook, 100, 100, TRUE, TRUE, 0); + + testbox = dw_box_new(BOXVERT, 10); + + pageid = dw_notebook_page_new(notebook, 0L, FALSE); + + dw_notebook_pack(notebook, pageid, testbox); + + dw_notebook_page_set_text(notebook, pageid, "Test page"); + dw_notebook_page_set_status_text(notebook, pageid, "Test page"); + + testok = dw_button_new("Ok", 1003L); + + dw_box_pack_start(testbox, testok, 60, 40, TRUE, TRUE, 10); + + testcancel = dw_button_new("Cancel", 1004L); + + dw_box_pack_start(testbox, testcancel, 60, 40, TRUE, TRUE, 10); + + testbox2 = dw_box_new(BOXHORZ, 0); + + dw_box_pack_start(testbox, testbox2, 0, 0, TRUE, TRUE, 0); + + testok2 = dw_button_new("Ok", 1003L); + + dw_box_pack_start(testbox2, testok2, 60, 40, TRUE, TRUE, 10); + + dw_box_pack_splitbar_start(testbox2); + + testcancel2 = dw_button_new("Cancel", 1004L); + + dw_box_pack_start(testbox2, testcancel2, 60, 40, TRUE, TRUE, 10); + + /* Set some nice fonts and colors */ + dw_window_set_color(testbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + dw_window_set_color(testbox2, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + dw_window_set_font(testok, "9.WarpSans"); + dw_window_set_font(testcancel, "9.WarpSans"); + dw_window_set_font(testok2, "9.WarpSans"); + dw_window_set_font(testcancel2, "9.WarpSans"); + + dw_window_show(testwindow); + + /* Setup the function callbacks */ + dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); + dw_signal_connect(cancelbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); + dw_signal_connect(testok, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); + dw_signal_connect(testcancel, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); + dw_signal_connect(testok2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); + dw_signal_connect(testcancel2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); + dw_signal_connect(mainwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); + dw_signal_connect(testwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); + + dw_main(0L, NULL); + + return 0; +} +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/makefile.vac Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,46 @@ +.SUFFIXES: .c .obj + +.all: \ + .\dw.dll \ + .\dwcompat.dll + +.c.obj: + icc.exe /DOS2 /DTCPV40HDRS /DBUILD_DLL /I. /I..\..\include /Tdc /Sp1 /Ss /Wprorearet /Wpro+ /V"Dynamic Windows Compatibility" /Ti /Gm /Gd- /G5 /Ge- /C /W3 /Wini+ /Wpar+ /Wpro+ /Wuse+ %s + +.\dw.dll: \ + .\os2\dw.obj + @echo " Link::Linker " + icc.exe @<< + /B" /NOE /de /ST:32768 /nologo /li" + /Fe"dw.dll" dw.def + .\dw.obj + so32dll.lib + tcp32dll.lib +<< + IMPLIB DW.LIB DW.DEF + copy dw.lib lib\dw.lib + copy dw.dll dll\dw.dll + +.\dwcompat.dll: \ + .\os2\dirent.obj \ + .\compat.obj + @echo " Link::Linker " + icc.exe @<< + /B" /NOE /de /ST:32768 /nologo /li" + /Fe"dwcompat.dll" dwcompat.def + .\dirent.obj + .\compat.obj + so32dll.lib + tcp32dll.lib +<< + IMPLIB DWCOMPAT.LIB DWCOMPAT.DEF + copy dwcompat.lib lib\dwcompat.lib + copy dwcompat.dll dll\dwcompat.dll + +clean : + @if exist *.obj del *.obj + @if exist *.map del *.map + @if exist *.lib del *.lib + @if exist *.dll del *.dll + @if exist *.exe del *.exe +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/makefile.vc Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,68 @@ +# +FXLIBDIR=..\..\lib +FXDLLDIR=..\..\dll + +CC = cl +CFLAGS = -c -G5 -GD -Zp1 -DWIN32 -D__WIN32__ -DMSVC -DBUILD_DLL -I..\..\include -I. +CFLAGS_DEBUG = -Zi +CFLAGS_COMPILE = -MTd +LIBS = wsock32.lib kernel32.lib user32.lib comctl32.lib gdi32.lib advapi32.lib shell32.lib comdlg32.lib +RES = +LINKFLAGS = -machine:i386 -debug:full -debugtype:cv +DLLLINKFLAGS = -dll +LINK = link +DEFFILE = dww.def +DEFFILE2 = dwcompatw.def + +OBJS = dw.obj + +OBJS2 = compat.obj dirent.obj + +all: dw dwcompat + +clean: + -erase *.dll + -erase *.exe + -erase *.opt + -erase *.lib + -erase *.obj + -erase *.map + -erase *.pdb + -erase *.ilk + -erase *.exp + -erase *~ + +dw: dw.dll + +dw.dll: $(OBJS) $(DEFFILE) + $(LINK) @<< +-out:$(@) -def:$(DEFFILE) +$(LINKFLAGS) $(DLLLINKFLAGS) +$(OBJS) $(RES) +$(LIBS) +<< + lib /def:$(DEFFILE) + copy dw.lib $(FXLIBDIR)\dw.lib + copy dw.dll $(FXDLLDIR)\dw.dll + +dwcompat: dwcompat.dll + +dwcompat.dll: $(OBJS2) $(DEFFILE2) + $(LINK) @<< +-out:$(@) -def:$(DEFFILE2) +$(LINKFLAGS) $(DLLLINKFLAGS) +$(OBJS2) $(RES) +$(LIBS) +<< + lib /def:$(DEFFILE2) + copy dwcompat.lib $(FXLIBDIR)\dwcompat.lib + copy dwcompat.dll $(FXDLLDIR)\dwcompat.dll + +dw.obj: + $(CC) $(CFLAGS) $(CFLAGS_DEBUG) $(CFLAGS_COMPILE) win\dw.c + +dirent.obj: + $(CC) $(CFLAGS) $(CFLAGS_DEBUG) $(CFLAGS_COMPILE) win\dirent.c + +.c.obj: + $(CC) $(CFLAGS) $(CFLAGS_DEBUG) $(CFLAGS_COMPILE) $*.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os2/dirent.c Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,302 @@ +#ifdef OS2 + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> + +#include "dirent.h" +#include <errno.h> + +/*#ifndef __EMX__ +#include <libx.h> +#endif */ + +#define INCL_DOSFILEMGR +#define INCL_DOSERRORS +#include <os2.h> + +# define FFBUF FILEFINDBUF3 +# define Word ULONG + /* + * LS20 recommends a request count of 100, but according to the + * APAR text it does not lead to missing files, just to funny + * numbers of returned entries. + * + * LS30 HPFS386 requires a count greater than 2, or some files + * are missing (those starting with a character less that '.'). + * + * Novell looses entries which overflow the buffer. In previous + * versions of dirent2, this could have lead to missing files + * when the average length of 100 directory entries was 40 bytes + * or more (quite unlikely for files on a Novell server). + * + * Conclusion: Make sure that the entries all fit into the buffer + * and that the buffer is large enough for more than 2 entries + * (each entry is at most 300 bytes long). And ignore the LS20 + * effect. + */ +# define Count 25 +# define BufSz (25 * (sizeof(FILEFINDBUF3)+1)) + +#if defined(__IBMC__) || defined(__IBMCPP__) + #define error(rc) _doserrno = rc, errno = EOS2ERR +#else + #define error(rc) errno = 255 +#endif + +struct _dirdescr { + HDIR handle; /* DosFindFirst handle */ + char fstype; /* filesystem type */ + Word count; /* valid entries in <ffbuf> */ + long number; /* absolute number of next entry */ + int index; /* relative number of next entry */ + FFBUF * next; /* pointer to next entry */ + char name[MAXPATHLEN+3]; /* directory name */ + unsigned attrmask; /* attribute mask for seekdir */ + struct dirent entry; /* buffer for directory entry */ + BYTE ffbuf[BufSz]; +}; + +/* + * Return first char of filesystem type, or 0 if unknown. + */ +static char +getFSType(const char *path) +{ + static char cache[1+26]; + char drive[3], info[512]; + Word unit, infolen; + char r; + + if (isalpha(path[0]) && path[1] == ':') { + unit = toupper(path[0]) - '@'; + path += 2; + } else { + ULONG driveMap; + if (DosQueryCurrentDisk(&unit, &driveMap)) + return 0; + } + + if ((path[0] == '\\' || path[0] == '/') + && (path[1] == '\\' || path[1] == '/')) + return 0; + + if (cache [unit]) + return cache [unit]; + + drive[0] = '@' + unit; + drive[1] = ':'; + drive[2] = '\0'; + infolen = sizeof info; + if (DosQueryFSAttach(drive, 0, FSAIL_QUERYNAME, (PVOID)info, &infolen)) + return 0; + if (infolen >= sizeof(FSQBUFFER2)) { + FSQBUFFER2 *p = (FSQBUFFER2 *)info; + r = p->szFSDName[p->cbName]; + } else + r = 0; + return cache [unit] = r; +} + +char * +abs_path(const char *name, char *buffer, int len) +{ + char buf[4]; + if (isalpha(name[0]) && name[1] == ':' && name[2] == '\0') { + buf[0] = name[0]; + buf[1] = name[1]; + buf[2] = '.'; + buf[3] = '\0'; + name = buf; + } + if (DosQueryPathInfo((PSZ)name, FIL_QUERYFULLNAME, buffer, len)) + return NULL; + return buffer; +} + +DIR * +openxdir(const char *path, unsigned att_mask) +{ + DIR *dir; + char name[MAXPATHLEN+3]; + Word rc; + + dir = malloc(sizeof(DIR)); + if (dir == NULL) { + errno = ENOMEM; + return NULL; + } + + strncpy(name, path, MAXPATHLEN); + name[MAXPATHLEN] = '\0'; + switch (name[strlen(name)-1]) { + default: + strcat(name, "\\"); + case '\\': + case '/': + case ':': + ; + } + strcat(name, "."); + if (!abs_path(name, dir->name, MAXPATHLEN+1)) + strcpy(dir->name, name); + if (dir->name[strlen(dir->name)-1] == '\\') + strcat(dir->name, "*"); + else + strcat(dir->name, "\\*"); + + dir->fstype = getFSType(dir->name); + dir->attrmask = att_mask | A_DIR; + + dir->handle = HDIR_CREATE; + dir->count = 100; + rc = DosFindFirst(dir->name, &dir->handle, dir->attrmask, + dir->ffbuf, sizeof dir->ffbuf, &dir->count, FIL_STANDARD); + switch (rc) { + default: + free(dir); + error(rc); + return NULL; + case NO_ERROR: + case ERROR_NO_MORE_FILES: + ; + } + + dir->number = 0; + dir->index = 0; + dir->next = (FFBUF *)dir->ffbuf; + + return (DIR *)dir; +} + +DIR * +opendir(const char *pathname) +{ + return openxdir(pathname, 0); +} + +struct dirent * +readdir(DIR *dir) +{ + static int dummy_ino = 2; + + if (dir->index == dir->count) { + Word rc; + dir->count = 100; + rc = DosFindNext(dir->handle, dir->ffbuf, + sizeof dir->ffbuf, &dir->count); + if (rc) { + error(rc); + return NULL; + } + + dir->index = 0; + dir->next = (FFBUF *)dir->ffbuf; + } + + if (dir->index == dir->count) + return NULL; + + memcpy(dir->entry.d_name, dir->next->achName, dir->next->cchName); + dir->entry.d_name[dir->next->cchName] = '\0'; + dir->entry.d_ino = dummy_ino++; + dir->entry.d_reclen = dir->next->cchName; + dir->entry.d_namlen = dir->next->cchName; + dir->entry.d_size = dir->next->cbFile; + dir->entry.d_attribute = dir->next->attrFile; + dir->entry.d_time = *(USHORT *)&dir->next->ftimeLastWrite; + dir->entry.d_date = *(USHORT *)&dir->next->fdateLastWrite; + + switch (dir->fstype) { + case 'F': /* FAT */ + case 'C': /* CDFS */ + if (dir->next->attrFile & FILE_DIRECTORY) + strupr(dir->entry.d_name); + else + strlwr(dir->entry.d_name); + } + + dir->next = (FFBUF *)((BYTE *)dir->next + dir->next->oNextEntryOffset); + ++dir->number; + ++dir->index; + + return &dir->entry; +} + +long +telldir(DIR *dir) +{ + return dir->number; +} + +void +seekdir(DIR *dir, long off) +{ + if (dir->number > off) { + char name[MAXPATHLEN+2]; + Word rc; + + DosFindClose(dir->handle); + + strcpy(name, dir->name); + strcat(name, "*"); + + dir->handle = HDIR_CREATE; + dir->count = 32767; + rc = DosFindFirst(name, &dir->handle, dir->attrmask, + dir->ffbuf, sizeof dir->ffbuf, &dir->count, FIL_STANDARD); + switch (rc) { + default: + error(rc); + return; + case NO_ERROR: + case ERROR_NO_MORE_FILES: + ; + } + + dir->number = 0; + dir->index = 0; + dir->next = (FFBUF *)dir->ffbuf; + } + + while (dir->number < off && readdir(dir)) + ; +} + +void +closedir(DIR *dir) +{ + DosFindClose(dir->handle); + free(dir); +} + +/*****************************************************************************/ + +#ifdef TEST + +main(int argc, char **argv) +{ + int i; + DIR *dir; + struct dirent *ep; + + for (i = 1; i < argc; ++i) { + dir = opendir(argv[i]); + if (!dir) + continue; + while (ep = readdir(dir)) + if (strchr("\\/:", argv[i] [strlen(argv[i]) - 1])) + printf("%s%s\n", argv[i], ep->d_name); + else + printf("%s/%s\n", argv[i], ep->d_name); + closedir(dir); + } + + return 0; +} + +#endif + +#endif /* OS2 */ +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os2/dw.c Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,5743 @@ +/* + * Dynamic Windows: + * A GTK like implementation of the PM GUI + * + * (C) 2000,2001 Brian Smith <dbsoft@technologist.com> + * (C) 2000 Achim Hasenmueller <achimha@innotek.de> + * (C) 2000 Peter Nielsen <peter@pmview.com> + * (C) 1998 Sergey I. Yevtushenko (some code borrowed from cell toolkit) + * + */ +#define INCL_DOS +#define INCL_DOSERRORS +#define INCL_WIN +#define INCL_GPI + +#include <os2.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <stdarg.h> +#include <stddef.h> +#include <ctype.h> +#include <process.h> +#include "dw.h" + +#define QWP_USER 0 + +char ClassName[] = "dynamicwindows"; +char SplitbarClassName[] = "dwsplitbar"; +char DefaultFont[] = "9.WarpSans"; + +/* this is the callback handle for the window procedure + * make sure you always match the calling convention! + */ +int (* EXPENTRY filterfunc)(HWND, ULONG, MPARAM, MPARAM) = 0L; + +HAB dwhab = 0; +HMQ dwhmq = 0; +DWTID _dwtid = 0; +LONG _foreground = 0xAAAAAA, _background = 0; + +HWND hwndBubble = NULLHANDLE, hwndBubbleLast = NULLHANDLE; +PRECORDCORE pCore = NULL; + +#ifndef min +#define min(a, b) (((a < b) ? a : b)) +#endif + +#ifdef DWDEBUG +FILE *f; + +void reopen(void) +{ + fclose(f); + f = fopen("dw.log", "at"); +} +#endif + +static LONG lColor[SPLITBAR_WIDTH] = +{ + DW_CLR_BLACK, + DW_CLR_PALEGRAY, + DW_CLR_WHITE +}; + +#ifdef NO_SIGNALS +#define USE_FILTER +#else +typedef struct _sighandler +{ + struct _sighandler *next; + ULONG message; + HWND window; + void *signalfunction; + void *data; + +} SignalHandler; + +SignalHandler *Root = NULL; + +typedef struct +{ + ULONG message; + char name[30]; + +} SignalList; + +/* List of signals and their equivilent OS/2 message */ +#define SIGNALMAX 11 + +SignalList SignalTranslate[SIGNALMAX] = { + { WM_SIZE, "configure_event" }, + { WM_CHAR, "key_press_event" }, + { WM_BUTTON1DOWN, "button_press_event" }, + { WM_BUTTON1UP, "button_release_event"}, + { WM_MOUSEMOVE, "motion_notify_event" }, + { WM_CLOSE, "delete_event" }, + { WM_PAINT, "expose_event" }, + { WM_COMMAND, "clicked" }, + { CN_ENTER, "container-select" }, + { CN_CONTEXTMENU, "container-context" }, + { LN_SELECT, "item-select" } +}; + +/* This function adds a signal handler callback into the linked list. + */ +void _new_signal(ULONG message, HWND window, void *signalfunction, void *data) +{ + SignalHandler *new = malloc(sizeof(SignalHandler)); + + new->message = message; + new->window = window; + new->signalfunction = signalfunction; + new->data = data; + new->next = NULL; + + if (!Root) + Root = new; + else + { + SignalHandler *prev = NULL, *tmp = Root; + while(tmp) + { + prev = tmp; + tmp = tmp->next; + } + if(prev) + prev->next = new; + else + Root = new; + } +} + +/* Finds the message number for a given signal name */ +ULONG _findsigmessage(char *signame) +{ + int z; + + for(z=0;z<SIGNALMAX;z++) + { + if(stricmp(signame, SignalTranslate[z].name) == 0) + return SignalTranslate[z].message; + } + return 0L; +} +#endif + +/* This function removes and handlers on windows and frees + * the user memory allocated to it. + */ +void _free_window_memory(HWND handle) +{ + HENUM henum; + HWND child; + +#ifndef NO_SIGNALS + dw_signal_disconnect_by_window(handle); +#endif + + henum = WinBeginEnumWindows(handle); + while((child = WinGetNextWindow(henum)) != NULLHANDLE) + { + void *ptr = (void *)WinQueryWindowPtr(handle, QWP_USER); + + if(ptr) + { + WinSetWindowPtr(handle, QWP_USER, 0); + free(ptr); + } + + _free_window_memory(child); + } + WinEndEnumWindows(henum); + return; +} + +/* This function returns 1 if the window (widget) handle + * passed to it is a valid window that can gain input focus. + */ +int _validate_focus(HWND handle) +{ + char tmpbuf[100]; + + if(!handle) + return 0; + + WinQueryClassName(handle, 99, tmpbuf); + + /* These are the window classes which can + * obtain input focus. + */ + if(strncmp(tmpbuf, "#2", 2)==0 || /* Entryfield */ + strncmp(tmpbuf, "#3", 2)==0 || /* Button */ + strncmp(tmpbuf, "#6", 2)==0 || /* Combobox */ + strncmp(tmpbuf, "#7", 2)==0 || /* List box */ + strncmp(tmpbuf, "#10", 3)==0 || /* MLE */ + strncmp(tmpbuf, "#32", 3)==0 || /* Spinbutton */ + strncmp(tmpbuf, "#37", 3)== 0) /* Container */ + return 1; + return 0; +} + +int _focus_check_box(Box *box, HWND handle, int start) +{ + int z; + static HWND lasthwnd, firsthwnd; + static int finish_searching; + + /* Start is 2 when we have cycled completely and + * need to set the focus to the last widget we found + * that was valid. + */ + if(start == 2) + { + if(lasthwnd) + WinSetFocus(HWND_DESKTOP, lasthwnd); + return 0; + } + + /* Start is 1 when we are entering the function + * for the first time, it is zero when entering + * the function recursively. + */ + if(start == 1) + { + lasthwnd = handle; + finish_searching = 0; + firsthwnd = 0; + } + + /* Vertical boxes are inverted on OS/2 */ + if(box->type == BOXVERT) + { + for(z=0;z<box->count;z++) + { + if(box->items[z].type == TYPEBOX) + { + Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER); + + if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0)) + return 1; + } + else + { + if(box->items[z].hwnd == handle) + { + if(lasthwnd == handle && firsthwnd) + WinSetFocus(HWND_DESKTOP, firsthwnd); + else if(lasthwnd == handle && !firsthwnd) + finish_searching = 1; + else + WinSetFocus(HWND_DESKTOP, lasthwnd); + + /* If we aren't looking for the last handle, + * return immediately. + */ + if(!finish_searching) + return 1; + } + if(_validate_focus(box->items[z].hwnd)) + { + /* Start is 3 when we are looking for the + * first valid item in the layout. + */ + if(start == 3) + { + WinSetFocus(HWND_DESKTOP, box->items[z].hwnd); + return 1; + } + + if(!firsthwnd) + firsthwnd = box->items[z].hwnd; + + lasthwnd = box->items[z].hwnd; + } + else + { + char tmpbuf[100] = ""; + + WinQueryClassName(box->items[z].hwnd, 99, tmpbuf); + if(strncmp(tmpbuf, "#40", 3)==0) /* Notebook */ + { + Box *notebox; + HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND, + (MPARAM)dw_notebook_page_query(box->items[z].hwnd), 0); + + if(page) + { + notebox = (Box *)WinQueryWindowPtr(page, QWP_USER); + + if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0)) + return 1; + } + } + } + } + } + } + else + { + for(z=box->count-1;z>-1;z--) + { + if(box->items[z].type == TYPEBOX) + { + Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER); + + if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0)) + return 1; + } + else + { + if(box->items[z].hwnd == handle) + { + if(lasthwnd == handle && firsthwnd) + WinSetFocus(HWND_DESKTOP, firsthwnd); + else if(lasthwnd == handle && !firsthwnd) + finish_searching = 1; + else + WinSetFocus(HWND_DESKTOP, lasthwnd); + + /* If we aren't looking for the last handle, + * return immediately. + */ + if(!finish_searching) + return 1; + } + if(_validate_focus(box->items[z].hwnd)) + { + /* Start is 3 when we are looking for the + * first valid item in the layout. + */ + if(start == 3) + { + WinSetFocus(HWND_DESKTOP, box->items[z].hwnd); + return 1; + } + + if(!firsthwnd) + firsthwnd = box->items[z].hwnd; + + lasthwnd = box->items[z].hwnd; + } + else + { + char tmpbuf[100] = ""; + + WinQueryClassName(box->items[z].hwnd, 99, tmpbuf); + if(strncmp(tmpbuf, "#40", 3)==0) /* Notebook */ + { + Box *notebox; + HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND, + (MPARAM)dw_notebook_page_query(box->items[z].hwnd), 0); + + if(page) + { + notebox = (Box *)WinQueryWindowPtr(page, QWP_USER); + + if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0)) + return 1; + } + } + } + } + } + } + return 0; +} + +/* This function finds the first widget in the + * layout and moves the current focus to it. + */ +void _initial_focus(HWND handle) +{ + Box *thisbox; + HWND box; + + box = WinWindowFromID(handle, FID_CLIENT); + if(box) + thisbox = WinQueryWindowPtr(box, QWP_USER); + + if(thisbox) + { + _focus_check_box(thisbox, handle, 3); + } +} + +/* This function finds the current widget in the + * layout and moves the current focus to the next item. + */ +void _shift_focus(HWND handle) +{ + Box *thisbox; + HWND box, lastbox = WinQueryWindow(handle, QW_PARENT); + + /* Find the toplevel window */ + while((box = WinQueryWindow(lastbox, QW_PARENT)) > 0x80000001) + { + lastbox = box; + } + + thisbox = WinQueryWindowPtr(lastbox, QWP_USER); + if(!thisbox) + { + box = WinWindowFromID(lastbox, FID_CLIENT); + if(box) + thisbox = WinQueryWindowPtr(box, QWP_USER); + } + if(thisbox) + { + if(_focus_check_box(thisbox, handle, 1) == 0) + _focus_check_box(thisbox, handle, 2); + } +} + +/* ResetWindow: + * Resizes window to the exact same size to trigger + * recalculation of frame. + */ +void _ResetWindow(HWND hwndFrame) +{ + SWP swp; + + WinQueryWindowPos(hwndFrame, &swp); + WinSetWindowPos(hwndFrame, HWND_TOP, 0, 0, swp.cx, swp.cy-1, SWP_SIZE); + WinSetWindowPos(hwndFrame, HWND_TOP, 0, 0, swp.cx, swp.cy, SWP_SIZE); +} + +/* This function will recursively search a box and add up the total height of it */ +void _count_size(HWND box, int type, int *xsize, int *xorigsize) +{ + int size = 0, origsize = 0, z; + Box *tmp = WinQueryWindowPtr(box, QWP_USER); + + if(!tmp) + { + *xsize = *xorigsize = 0; + return; + } + + if(type == tmp->type) + { + /* If the box is going in the direction we want, then we + * return the entire sum of the items. + */ + for(z=0;z<tmp->count;z++) + { + if(tmp->items[z].type == TYPEBOX) + { + int s, os; + + _count_size(tmp->items[z].hwnd, type, &s, &os); + size += s; + origsize += os; + } + else + { + size += (type == BOXHORZ ? tmp->items[z].width : tmp->items[z].height); + origsize += (type == BOXHORZ ? tmp->items[z].origwidth : tmp->items[z].origheight); + } + } + } + else + { + /* If the box is not going in the direction we want, then we only + * want to return the maximum value. + */ + int tmpsize = 0, tmporigsize = 0; + + for(z=0;z<tmp->count;z++) + { + if(tmp->items[z].type == TYPEBOX) + _count_size(tmp->items[z].hwnd, type, &tmpsize, &tmporigsize); + else + { + tmpsize = (type == BOXHORZ ? tmp->items[z].width : tmp->items[z].height); + tmporigsize = (type == BOXHORZ ? tmp->items[z].origwidth : tmp->items[z].origheight); + } + + if(tmpsize > size) + size = tmpsize; + } + } + + *xsize = size; + *xorigsize = origsize; +} + + +/* Function: TrackRectangle + * Abstract: Tracks given rectangle. + * + * If rclBounds is NULL, then track rectangle on entire desktop. + * rclTrack is in window coorditates and will be mapped to + * desktop. + */ + +BOOL _TrackRectangle(HWND hwndBase, RECTL* rclTrack, RECTL* rclBounds) +{ + TRACKINFO track; + APIRET rc; + + track.cxBorder = 1; + track.cyBorder = 1; + track.cxGrid = 1; + track.cyGrid = 1; + track.cxKeyboard = 8; + track.cyKeyboard = 8; + + if(!rclTrack) + return FALSE; + + if(rclBounds) + { + track.rclBoundary = *rclBounds; + } + else + { + track.rclBoundary.yTop = + track.rclBoundary.xRight = 3000; + track.rclBoundary.yBottom = + track.rclBoundary.xLeft = -3000; + } + + track.rclTrack = *rclTrack; + + WinMapWindowPoints(hwndBase, + HWND_DESKTOP, + (PPOINTL)&track.rclTrack, + 2); + + track.ptlMinTrackSize.x = track.rclTrack.xRight + - track.rclTrack.xLeft; + track.ptlMinTrackSize.y = track.rclTrack.yTop + - track.rclTrack.yBottom; + track.ptlMaxTrackSize.x = track.rclTrack.xRight + - track.rclTrack.xLeft; + track.ptlMaxTrackSize.y = track.rclTrack.yTop + - track.rclTrack.yBottom; + + track.fs = TF_MOVE | TF_ALLINBOUNDARY; + + rc = WinTrackRect(HWND_DESKTOP, 0, &track); + + if(rc) + *rclTrack = track.rclTrack; + + return rc; +} + +/* This function calculates how much space the widgets and boxes require + * and does expansion as necessary. + */ +int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy, + int pass, int *usedpadx, int *usedpady) +{ + int z, currentx = 0, currenty = 0; + int vectorx = 0, vectory = 0; + int uymax = 0, uxmax = 0; + int upymax = 0, upxmax = 0; + /* Used for the SIZEEXPAND */ + int nux = *usedx, nuy = *usedy; + int nupx = *usedpadx, nupy = *usedpady; + + (*usedx) += (thisbox->pad * 2); + (*usedy) += (thisbox->pad * 2); + + for(z=0;z<thisbox->count;z++) + { + if(thisbox->items[z].type == TYPEBOX) + { + int initialx, initialy; + Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); + + initialx = x - (*usedx); + initialy = y - (*usedy); + + if(tmp) + { + int newx, newy; + int nux = *usedx, nuy = *usedy; + int upx = *usedpadx + (tmp->pad*2), upy = *usedpady + (tmp->pad*2); + + /* On the second pass we know how big the box needs to be and how + * much space we have, so we can calculate a ratio for the new box. + */ + if(pass == 2) + { + int deep = *depth + 1; + + _resize_box(tmp, &deep, x, y, &nux, &nuy, 1, &upx, &upy); + + tmp->upx = upx - *usedpadx; + tmp->upy = upy - *usedpady; + + newx = x - nux; + newy = y - nuy; + + tmp->width = thisbox->items[z].width = initialx - newx; + tmp->height = thisbox->items[z].height = initialy - newy; + + tmp->parentxratio = thisbox->xratio; + tmp->parentyratio = thisbox->yratio; + + tmp->parentpad = tmp->pad; + + /* Just in case */ + tmp->xratio = thisbox->xratio; + tmp->yratio = thisbox->yratio; + +#ifdef DWDEBUG + if(pass > 1) + { + fprintf(f, "FARK! depth %d\r\nwidth = %d, height = %d, nux = %d, nuy = %d, upx = %d, upy = %d xratio = %f, yratio = %f\r\n\r\n", + *depth, thisbox->items[z].width, thisbox->items[z].height, nux, nuy, tmp->upx, tmp->upy, tmp->xratio, tmp->yratio); + reopen(); + } +#endif + if(thisbox->type == BOXVERT) + { + if((thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) + tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))); + } + else + { + if((thisbox->items[z].width-tmp->upx)!=0) + tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx)); + } + if(thisbox->type == BOXHORZ) + { + if((thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) + tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))); + } + else + { + if((thisbox->items[z].height-tmp->upy)!=0) + tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy)); + } + + nux = *usedx; nuy = *usedy; + upx = *usedpadx + (tmp->pad*2); upy = *usedpady + (tmp->pad*2); + } + + (*depth)++; + +#ifdef DWDEBUG + if(pass > 1) + { + fprintf(f, "Before Resize Box depth %d\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d xratio = %f, yratio = %f\r\n\r\n", + *depth, x, y, *usedx, *usedy, *usedpadx, *usedpady, tmp->xratio, tmp->yratio); + reopen(); + } +#endif + + _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &upx, &upy); + + (*depth)--; + + newx = x - nux; + newy = y - nuy; + + tmp->minwidth = thisbox->items[z].width = initialx - newx; + tmp->minheight = thisbox->items[z].height = initialy - newy; + +#ifdef DWDEBUG + if(pass > 1) + { + fprintf(f, "After Resize Box depth %d\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d width = %d, height = %d\r\n\r\n", + *depth, x, y, *usedx, *usedy, *usedpadx, *usedpady, thisbox->items[z].width, thisbox->items[z].height); + reopen(); + } +#endif + } + } + + if(pass > 1 && *depth > 0) + { + if(thisbox->type == BOXVERT) + thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2)))); + else + thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx)); + + if(thisbox->type == BOXHORZ) + thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2)))); + else + thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy)); +#ifdef DWDEBUG + fprintf(f, "RATIO- xratio = %f, yratio = %f, width = %d, height = %d, pad = %d, box xratio = %f, box yratio = %f, parent xratio = %f, parent yratio = %f, minwidth = %d, minheight = %d, width = %d, height = %d, upx = %d, upy = %d\r\n\r\n", + thisbox->items[z].xratio, thisbox->items[z].yratio, thisbox->items[z].width, thisbox->items[z].height, thisbox->items[z].pad, thisbox->xratio, thisbox->yratio, thisbox->parentxratio, thisbox->parentyratio, thisbox->minwidth, thisbox->minheight, thisbox->width, thisbox->height, thisbox->upx, thisbox->upy); + reopen(); +#endif + } + else + { + thisbox->items[z].xratio = thisbox->xratio; + thisbox->items[z].yratio = thisbox->yratio; + } + + if(thisbox->type == BOXVERT) + { + if((thisbox->items[z].width + (thisbox->items[z].pad*2)) > uxmax) + uxmax = (thisbox->items[z].width + (thisbox->items[z].pad*2)); + if(thisbox->items[z].hsize != SIZEEXPAND) + { + if(((thisbox->items[z].pad*2) + thisbox->items[z].width) > upxmax) + upxmax = (thisbox->items[z].pad*2) + thisbox->items[z].width; + } + else + { + if(thisbox->items[z].pad*2 > upxmax) + upxmax = thisbox->items[z].pad*2; + } + } + else + { + if(thisbox->items[z].width == -1) + { + /* figure out how much space this item requires */ + /* thisbox->items[z].width = */ + } + else + { + (*usedx) += thisbox->items[z].width + (thisbox->items[z].pad*2); + if(thisbox->items[z].hsize != SIZEEXPAND) + (*usedpadx) += (thisbox->items[z].pad*2) + thisbox->items[z].width; + else + (*usedpadx) += thisbox->items[z].pad*2; + } + } + if(thisbox->type == BOXHORZ) + { + if((thisbox->items[z].height + (thisbox->items[z].pad*2)) > uymax) + uymax = (thisbox->items[z].height + (thisbox->items[z].pad*2)); + if(thisbox->items[z].vsize != SIZEEXPAND) + { + if(((thisbox->items[z].pad*2) + thisbox->items[z].height) > upymax) + upymax = (thisbox->items[z].pad*2) + thisbox->items[z].height; + } + else + { + if(thisbox->items[z].pad*2 > upymax) + upymax = thisbox->items[z].pad*2; + } + } + else + { + if(thisbox->items[z].height == -1) + { + /* figure out how much space this item requires */ + /* thisbox->items[z].height = */ + } + else + { + (*usedy) += thisbox->items[z].height + (thisbox->items[z].pad*2); + if(thisbox->items[z].vsize != SIZEEXPAND) + (*usedpady) += (thisbox->items[z].pad*2) + thisbox->items[z].height; + else + (*usedpady) += thisbox->items[z].pad*2; + } + } + } + + (*usedx) += uxmax; + (*usedy) += uymax; + (*usedpadx) += upxmax; + (*usedpady) += upymax; + + currentx += thisbox->pad; + currenty += thisbox->pad; + +#ifdef DWDEBUG + fprintf(f, "Done Calc depth %d\r\nusedx = %d, usedy = %d, usedpadx = %d, usedpady = %d, currentx = %d, currenty = %d, uxmax = %d, uymax = %d\r\n\r\n", + *depth, *usedx, *usedy, *usedpadx, *usedpady, currentx, currenty, uxmax, uymax); + reopen(); +#endif + + /* The second pass is for expansion and actual placement. */ + if(pass > 1) + { + /* Any SIZEEXPAND items should be set to uxmax/uymax */ + for(z=0;z<thisbox->count;z++) + { + if(thisbox->items[z].hsize == SIZEEXPAND && thisbox->type == BOXVERT) + thisbox->items[z].width = uxmax-(thisbox->items[z].pad*2); + if(thisbox->items[z].vsize == SIZEEXPAND && thisbox->type == BOXHORZ) + thisbox->items[z].height = uymax-(thisbox->items[z].pad*2); + /* Run this code segment again to finalize the sized after setting uxmax/uymax values. */ + if(thisbox->items[z].type == TYPEBOX) + { + Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); + + if(tmp) + { + if(*depth > 0) + { + if(thisbox->type == BOXVERT) + { + tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/((float)(tmp->minwidth-((thisbox->items[z].pad*2)+(thisbox->pad*2)))); + tmp->width = thisbox->items[z].width; + } + if(thisbox->type == BOXHORZ) + { + tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/((float)(tmp->minheight-((thisbox->items[z].pad*2)+(thisbox->pad*2)))); + tmp->height = thisbox->items[z].height; + } + } + + (*depth)++; + + /*tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx) )/((float)(tmp->minwidth-tmp->upx)); + tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(tmp->minheight-tmp->upy));*/ + +#ifdef DWDEBUG + fprintf(f, "2- Resize Box depth %d\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d xratio = %f, yratio = %f,\r\nupx = %d, upy = %d, width = %d, height = %d, minwidth = %d, minheight = %d, box xratio = %f, box yratio = %f\r\n\r\n", + *depth, x, y, *usedx, *usedy, *usedpadx, *usedpady, tmp->xratio, tmp->yratio, tmp->upx, tmp->upy, thisbox->items[z].width, thisbox->items[z].height, tmp->minwidth, tmp->minheight, thisbox->xratio, thisbox->yratio); + reopen(); +#endif + + _resize_box(tmp, depth, x, y, &nux, &nuy, 3, &nupx, &nupy); + + (*depth)--; + + } + } + } + + for(z=0;z<(thisbox->count);z++) + { + int height = thisbox->items[z].height; + int width = thisbox->items[z].width; + int pad = thisbox->items[z].pad; + HWND handle = thisbox->items[z].hwnd; + + /* When upxmax != pad*2 then ratios are incorrect. */ + vectorx = (int)((width*thisbox->items[z].xratio)-width); + vectory = (int)((height*thisbox->items[z].yratio)-height); + + if(width > 0 && height > 0) + { + char tmpbuf[100]; + /* This is a hack to fix rounding of the sizing */ + if(*depth == 0) + { + vectorx++; + vectory++; + } + + /* If this item isn't going to expand... reset the vectors to 0 */ + if(thisbox->items[z].vsize != SIZEEXPAND) + vectory = 0; + if(thisbox->items[z].hsize != SIZEEXPAND) + vectorx = 0; + + WinQueryClassName(handle, 99, tmpbuf); + + if(strncmp(tmpbuf, "#2", 2)==0) + { + /* Make the combobox big enough to drop down. :) */ + WinSetWindowPos(handle, HWND_TOP, currentx + pad, (currenty + pad) - 100, + width + vectorx, (height + vectory) + 100, SWP_MOVE | SWP_SIZE | SWP_ZORDER); + } + else if(strncmp(tmpbuf, "#6", 2)==0) + { + /* Entryfields on OS/2 have a thick border that isn't on Windows and GTK */ + WinSetWindowPos(handle, HWND_TOP, (currentx + pad) + 3, (currenty + pad) + 3, + (width + vectorx) - 6, (height + vectory) - 6, SWP_MOVE | SWP_SIZE | SWP_ZORDER); + } + else + { + WinSetWindowPos(handle, HWND_TOP, currentx + pad, currenty + pad, + width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER); + if(thisbox->items[z].type == TYPEBOX) + { + Box *boxinfo = WinQueryWindowPtr(handle, QWP_USER); + + if(boxinfo && boxinfo->grouphwnd) + WinSetWindowPos(boxinfo->grouphwnd, HWND_TOP, 0, 0, + width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER); + + } + + } + +#ifdef DWDEBUG + fprintf(f, "Window Pos depth %d\r\ncurrentx = %d, currenty = %d, pad = %d, width = %d, height = %d, vectorx = %d, vectory = %d, Box type = %s\r\n\r\n", + *depth, currentx, currenty, pad, width, height, vectorx, vectory,thisbox->type == BOXHORZ ? "Horizontal" : "Vertical"); + reopen(); +#endif + + if(thisbox->type == BOXHORZ) + currentx += width + vectorx + (pad * 2); + if(thisbox->type == BOXVERT) + currenty += height + vectory + (pad * 2); + } + } + } + return 0; +} + +void _do_resize(Box *thisbox, int x, int y) +{ + if(x != 0 && y != 0) { + if(thisbox) + { + int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0; + + _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady); + + if(usedx-usedpadx == 0 || usedy-usedpady == 0) + return; + + thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx)); + thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady)); + +#ifdef DWDEBUG + fprintf(f, "WM_SIZE Resize Box Pass 1\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d xratio = %f, yratio = %f\r\n\r\n", + x, y, usedx, usedy, usedpadx, usedpady, thisbox->xratio, thisbox->yratio); + reopen(); +#endif + + usedx = usedy = usedpadx = usedpady = depth = 0; + + _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady); +#ifdef DWDEBUG + fprintf(f, "WM_SIZE Resize Box Pass 2\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d\r\n", + x, y, usedx, usedy, usedpadx, usedpady); + reopen(); +#endif + } + } +} + +/* This procedure handles WM_QUERYTRACKINFO requests from the frame */ +MRESULT EXPENTRY _sizeproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) +{ + PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER); + + switch(msg) + { + case WM_QUERYTRACKINFO: + { + if(blah && *blah) + { + PTRACKINFO ptInfo; + int res; + PFNWP myfunc = *blah; + res = (int)myfunc(hWnd, msg, mp1, mp2); + + ptInfo = (PTRACKINFO)(mp2); + + ptInfo->ptlMinTrackSize.y = 8; + ptInfo->ptlMinTrackSize.x = 8; + + return (MRESULT)res; + } + } + } + if(blah && *blah) + { + PFNWP myfunc = *blah; + return myfunc(hWnd, msg, mp1, mp2); + } + + return WinDefWindowProc(hWnd, msg, mp1, mp2); +} +/* Originally just intended for entryfields, it now serves as a generic + * procedure for handling TAB presses to change input focus on controls. + */ +MRESULT EXPENTRY _entryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) +{ + PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER); + + switch(msg) + { + case WM_CHAR: + if(SHORT1FROMMP(mp2) == '\t') + { + _shift_focus(hWnd); + return FALSE; + } + break; + } + if(blah && *blah) + { + PFNWP myfunc = *blah; + return myfunc(hWnd, msg, mp1, mp2); + } + + return WinDefWindowProc(hWnd, msg, mp1, mp2); +} + +/* Handle correct painting of a combobox with the WS_CLIPCHILDREN + * flag enabled, and also handle TABs to switch input focus. + */ +MRESULT EXPENTRY _comboproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) +{ + PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER); + + switch(msg) + { + case WM_CHAR: + if(SHORT1FROMMP(mp2) == '\t') + { + _shift_focus(hWnd); + return FALSE; + } + break; + case WM_PAINT: + { + HWND parent = WinQueryWindow(hWnd, QW_PARENT); + ULONG bcol, av[32]; + HPS hpsPaint; + POINTL ptl; /* Add 6 because it has a thick border like the entryfield */ + unsigned long width, height, thumbheight = WinQuerySysValue(HWND_DESKTOP, SV_CYVSCROLLARROW) + 6; + + WinQueryPresParam(parent, PP_BACKGROUNDCOLORINDEX, 0, &bcol, sizeof(ULONG), &av, QPF_ID1COLORINDEX | QPF_NOINHERIT); + dw_window_get_pos_size(hWnd, 0, 0, &width, &height); + + hpsPaint = WinGetPS(hWnd); + GpiSetColor(hpsPaint, CLR_PALEGRAY); + + ptl.x = 0; + ptl.y = 99; + GpiMove(hpsPaint, &ptl); + + ptl.x = width; + ptl.y = height - thumbheight; + GpiBox(hpsPaint, DRO_FILL, &ptl, 0, 0); + + WinReleasePS(hpsPaint); + } + break; + } + if(blah && *blah) + { + PFNWP myfunc = *blah; + return myfunc(hWnd, msg, mp1, mp2); + } + + return WinDefWindowProc(hWnd, msg, mp1, mp2); +} + +void _GetPPFont(HWND hwnd, char *buff) +{ + ULONG AttrFound; + BYTE AttrValue[128]; + ULONG cbRetLen; + + cbRetLen = WinQueryPresParam(hwnd, + PP_FONTNAMESIZE, + 0, + &AttrFound, + sizeof(AttrValue), + &AttrValue, + QPF_NOINHERIT); + + if(PP_FONTNAMESIZE == AttrFound && cbRetLen) + { + memcpy(buff, AttrValue, cbRetLen); + } +} + +/* Returns height of specified window. */ +int _get_height(HWND handle) +{ + unsigned long height; + dw_window_get_pos_size(handle, NULL, NULL, NULL, &height); + return (int)height; +} + +/* Find the height of the frame a desktop style window is sitting on */ +int _get_frame_height(HWND handle) +{ + while(handle) + { + HWND client; + if((client = WinWindowFromID(handle, FID_CLIENT)) != NULLHANDLE) + { + return _get_height(WinQueryWindow(handle, QW_PARENT)); + } + handle = WinQueryWindow(handle, QW_PARENT); + } + return dw_screen_height(); +} + +#ifndef NO_SIGNALS +MRESULT EXPENTRY _run_event(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) +{ + int result = -1; + SignalHandler *tmp = Root; + ULONG origmsg = msg; + + if(msg == WM_BUTTON2DOWN || msg == WM_BUTTON3DOWN) + msg = WM_BUTTON1DOWN; + if(msg == WM_BUTTON2UP || msg == WM_BUTTON3UP) + msg = WM_BUTTON1UP; + + /* Find any callbacks for this function */ + while(tmp) + { + if(tmp->message == msg || msg == WM_CONTROL) + { + switch(msg) + { + case WM_SIZE: + { + int (*sizefunc)(HWND, int, int, void *) = (int (*)(HWND, int, int, void *))tmp->signalfunction; + + if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd) + { + result = sizefunc(tmp->window, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), tmp->data); + tmp = NULL; + } + } + break; + case WM_BUTTON1DOWN: + { + POINTS pts = (*((POINTS*)&mp1)); + int (*buttonfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction; + + if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window) + { + int button; + + switch(origmsg) + { + case WM_BUTTON1DOWN: + button = 1; + break; + case WM_BUTTON2DOWN: + button = 2; + break; + case WM_BUTTON3DOWN: + button = 3; + break; + } + + result = buttonfunc(tmp->window, pts.x, _get_frame_height(tmp->window) - pts.y, button, tmp->data); + tmp = NULL; + } + } + break; + case WM_BUTTON1UP: + { + POINTS pts = (*((POINTS*)&mp1)); + int (*buttonfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction; + + if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window) + { + int button; + + switch(origmsg) + { + case WM_BUTTON1UP: + button = 1; + break; + case WM_BUTTON2UP: + button = 2; + break; + case WM_BUTTON3UP: + button = 3; + break; + } + + result = buttonfunc(tmp->window, pts.x, WinQueryWindow(tmp->window, QW_PARENT) == HWND_DESKTOP ? dw_screen_height() - pts.y : _get_height(tmp->window) - pts.y, button, tmp->data); + tmp = NULL; + } + } + break; + case WM_MOUSEMOVE: + { + int (*motionfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction; + + if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window) + { + int keys = 0; + SHORT x = SHORT1FROMMP(mp1), y = SHORT2FROMMP(mp1); + + if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000) + keys = DW_BUTTON1_MASK; + if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) & 0x8000) + keys |= DW_BUTTON2_MASK; + if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) & 0x8000) + keys |= DW_BUTTON3_MASK; + + result = motionfunc(tmp->window, x, _get_frame_height(tmp->window) - y, keys, tmp->data); + tmp = NULL; + } + } + break; + case WM_CHAR: + { + int (*keypressfunc)(HWND, int, void *) = (int (*)(HWND, int, void *))tmp->signalfunction; + + if(hWnd == tmp->window) + { + result = keypressfunc(tmp->window, SHORT1FROMMP(mp2), tmp->data); + tmp = NULL; + } + } + break; + case WM_CLOSE: + { + int (*closefunc)(HWND, void *) = (int (*)(HWND, void *))tmp->signalfunction; + + if(hWnd == tmp->window || hWnd == WinWindowFromID(tmp->window, FID_CLIENT)) + { + result = closefunc(tmp->window, tmp->data); + tmp = NULL; + } + } + break; + case WM_PAINT: + { + HPS hps; + DWExpose exp; + int (*exposefunc)(HWND, DWExpose *, void *) = (int (*)(HWND, DWExpose *, void *))tmp->signalfunction; + RECTL rc; + + if(hWnd == tmp->window) + { + int height = _get_height(hWnd); + + hps = WinBeginPaint(hWnd, 0L, &rc); + exp.x = rc.xLeft; + exp.y = height - rc.yTop - 1; + exp.width = rc.xRight - rc. xLeft; + exp.height = rc.yTop - rc.yBottom; + result = exposefunc(hWnd, &exp, tmp->data); + WinEndPaint(hps); + } + } + break; + case WM_COMMAND: + { + int (*clickfunc)(HWND, void *) = (int (*)(HWND, void *))tmp->signalfunction; + ULONG command = COMMANDMSG(&msg)->cmd; + + if(tmp->window < 65536 && command == tmp->window) + { + result = clickfunc(tmp->window, tmp->data); + tmp = NULL; + } + } + break; + case WM_CONTROL: + if(tmp->message == SHORT2FROMMP(mp1)) + { + switch(SHORT2FROMMP(mp1)) + { + case CN_ENTER: + { + int (*containerselectfunc)(HWND, char *, void *) = (int (*)(HWND, char *, void *))tmp->signalfunction; + int id = SHORT1FROMMP(mp1); + HWND conthwnd = dw_window_from_id(hWnd, id); + char *text = NULL; + + if(mp2) + { + PRECORDCORE pre; + + pre = ((PNOTIFYRECORDENTER)mp2)->pRecord; + if(pre) + text = pre->pszIcon; + } + + if(tmp->window == conthwnd) + { + result = containerselectfunc(tmp->window, text, tmp->data); + tmp = NULL; + } + } + break; + case CN_CONTEXTMENU: + { + int (*containercontextfunc)(HWND, char *, int, int, void *) = (int (*)(HWND, char *, int, int, void *))tmp->signalfunction; + int id = SHORT1FROMMP(mp1); + HWND conthwnd = dw_window_from_id(hWnd, id); + char *text = NULL; + LONG x,y; + + if(mp2) + { + PRECORDCORE pre; + + pre = (PRECORDCORE)mp2; + text = pre->pszIcon; + } + + + dw_pointer_query_pos(&x, &y); + + if(tmp->window == conthwnd) + { + result = containercontextfunc(tmp->window, text, x, y, tmp->data); + tmp = NULL; + } + } + break; + case LN_SELECT: + { + int (*listboxselectfunc)(HWND, int, void *) = (int (*)(HWND, int, void *))tmp->signalfunction; + int id = SHORT1FROMMP(mp1); + HWND conthwnd = dw_window_from_id(hWnd, id); + + if(tmp->window == conthwnd || (!id && tmp->window == (HWND)mp2)) + { + char buf1[500], classbuf[100]; + unsigned int index = dw_listbox_selected(tmp->window); + + dw_listbox_query_text(tmp->window, index, buf1, 500); + + WinQueryClassName(tmp->window, 99, classbuf); + + if(id && strncmp(classbuf, "#6", 2)==0) + { + char *buf2; + + buf2 = dw_window_get_text(tmp->window); + + /* This is to make sure the listboxselect function doesn't + * get called if the user is modifying the entry text. + */ + if(buf2 && *buf2 && *buf1 && strncmp(buf1, buf2, 500) == 0) + result = listboxselectfunc(tmp->window, index, tmp->data); + + if(buf2) + free(buf2); + } + else + result = listboxselectfunc(tmp->window, index, tmp->data); + + tmp = NULL; + } + } + break; + } + } + break; + } + } + if(tmp) + tmp = tmp->next; + + } + + return (MRESULT)result; +} +#endif + +/* Handles control messages sent to the box (owner). */ +MRESULT EXPENTRY _controlproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) +{ + Box *blah = WinQueryWindowPtr(hWnd, QWP_USER); + + switch(msg) + { + case WM_CONTROL: + _run_event(hWnd, msg, mp1, mp2); + break; + } + if(blah && blah->oldproc) + { + return blah->oldproc(hWnd, msg, mp1, mp2); + } + + return WinDefWindowProc(hWnd, msg, mp1, mp2); +} + +/* The main window procedure for Dynamic Windows, all the resizing code is done here. */ +MRESULT EXPENTRY _wndproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) +{ + int result = -1; + static int command_active = 0; + void (* windowfunc)(PVOID) = 0L; + + if(filterfunc) + result = filterfunc(hWnd, msg, mp1, mp2); + +#ifndef NO_SIGNALS + if(result == -1 && !command_active) + { + /* Make sure we don't end up in infinite recursion */ + command_active = 1; + + result = (int)_run_event(hWnd, msg, mp1, mp2); + + command_active = 0; + } +#endif + + /* Now that any handlers are done... do normal processing */ + switch( msg ) + { + case WM_ERASEBACKGROUND: + return 0; + + case WM_PAINT: + { + HPS hps; + RECTL rc; + + hps = WinBeginPaint( hWnd, 0L, &rc ); + WinEndPaint( hps ); + break; + } + + case WM_SIZE: + { + Box *mybox = (Box *)WinQueryWindowPtr(hWnd, QWP_USER); + + if(!SHORT1FROMMP(mp2) && !SHORT2FROMMP(mp2)) + return (MPARAM)TRUE; + + if(mybox) + { + /* Hide the window when recalculating to reduce + * CPU load. + */ + WinShowWindow(hWnd, FALSE); + + _do_resize(mybox, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2)); + + WinShowWindow(hWnd, TRUE); + } + } + break; + case WM_MINMAXFRAME: + { + Box *mybox = (Box *)WinQueryWindowPtr(hWnd, QWP_USER); + SWP *swp = (SWP *)mp1; + + if(mybox && (swp->fl & SWP_MAXIMIZE)) + { + int z; + + /* Hide the window when recalculating to reduce + * CPU load. + */ + WinShowWindow(hWnd, FALSE); + + _do_resize(mybox, swp->cx, swp->cy); + + if(mybox->count == 1 && mybox->items[0].type == TYPEBOX) + { + mybox = (Box *)WinQueryWindowPtr(mybox->items[0].hwnd, QWP_USER); + + for(z=0;z<mybox->count;z++) + { + char tmpbuf[100]; + + WinQueryClassName(mybox->items[z].hwnd, 99, tmpbuf); + + /* If we have a notebook we resize the page again. */ + if(strncmp(tmpbuf, "#40", 3)==0) + { + unsigned long x, y, width, height; + int page = dw_notebook_page_query(mybox->items[z].hwnd); + HWND pagehwnd = (HWND)WinSendMsg(mybox->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND, MPFROMLONG(page), 0); + RECTL rc; + + Box *pagebox = (Box *)WinQueryWindowPtr(pagehwnd, QWP_USER); + if(pagebox) + { + dw_window_get_pos_size(mybox->items[z].hwnd, &x, &y, &width, &height); + + rc.xLeft = x; + rc.yBottom = y; + rc.xRight = x + width; + rc.yTop = y + height; + + WinSendMsg(mybox->items[z].hwnd, BKM_CALCPAGERECT, (MPARAM)&rc, (MPARAM)TRUE); + + _do_resize(pagebox, rc.xRight - rc.xLeft, rc.yTop - rc.yBottom); + } + + } + } + + } + + WinShowWindow(hWnd, TRUE); + } + } + break; + case WM_CLOSE: + dw_window_destroy(WinQueryWindow(hWnd, QW_PARENT)); + return (MRESULT)TRUE; + case WM_USER: + windowfunc = (void (*)(void *))mp1; + + if(windowfunc) + windowfunc((void *)mp2); + break; + case WM_CHAR: + if(SHORT1FROMMP(mp2) == '\t') + { + _shift_focus(hWnd); + return FALSE; + } + break; + case WM_DESTROY: + /* Free memory before destroying */ + _free_window_memory(hWnd); + break; + } + if(filterfunc && result != -1) + return (MRESULT)result; + else + return WinDefWindowProc(hWnd, msg, mp1, mp2); +} + +void _changebox(Box *thisbox, int percent, int type) +{ + int z; + + for(z=0;z<thisbox->count;z++) + { + if(thisbox->items[z].type == TYPEBOX) + { + Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); + _changebox(tmp, percent, type); + } + else + { + if(type == BOXHORZ) + { + if(thisbox->items[z].hsize == SIZEEXPAND) + thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0))); + } + else + { + if(thisbox->items[z].vsize == SIZEEXPAND) + thisbox->items[z].height = (int)(((float)thisbox->items[z].origheight) * (((float)percent)/((float)100.0))); + } + } + } +} + +/* This handles any activity on the splitbars (sizers) */ +MRESULT EXPENTRY _splitwndproc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) +{ + HWND hwndFrame = 0; + Box *thisbox = 0; + + hwndFrame = WinQueryWindow(hwnd, QW_PARENT); + if(hwndFrame) + thisbox = WinQueryWindowPtr(hwndFrame, QWL_USER); + + switch (msg) + { + case WM_ACTIVATE: + case WM_SETFOCUS: + return (MRESULT)(FALSE); + + case WM_PAINT: + { + HPS hpsPaint; + RECTL rclPaint; + POINTL ptlStart[SPLITBAR_WIDTH]; + POINTL ptlEnd[SPLITBAR_WIDTH]; + USHORT i; + + hpsPaint = WinBeginPaint(hwnd, 0, 0); + WinQueryWindowRect(hwnd, &rclPaint); + + if(thisbox->type == BOXHORZ) + { + for(i = 0; i < SPLITBAR_WIDTH; i++) + { + ptlStart[i].x = rclPaint.xLeft + i; + ptlStart[i].y = rclPaint.yTop; + + ptlEnd[i].x = rclPaint.xLeft + i; + ptlEnd[i].y = rclPaint.yBottom; + } + } + else + { + for(i = 0; i < SPLITBAR_WIDTH; i++) + { + ptlStart[i].x = rclPaint.xLeft; + ptlStart[i].y = rclPaint.yBottom + i; + + ptlEnd[i].x = rclPaint.xRight; + ptlEnd[i].y = rclPaint.yBottom + i; + } + } + + for(i = 0; i < SPLITBAR_WIDTH; i++) + { + GpiSetColor( hpsPaint, lColor[i]); + GpiMove(hpsPaint, &ptlStart[i]); + GpiLine(hpsPaint, &ptlEnd[i]); + } + WinEndPaint(hpsPaint); + } + return MRFROMSHORT(FALSE); + + case WM_MOUSEMOVE: + { + if(thisbox->type == BOXHORZ) + WinSetPointer(HWND_DESKTOP, + WinQuerySysPointer(HWND_DESKTOP, + SPTR_SIZEWE, + FALSE)); + else + WinSetPointer(HWND_DESKTOP, + WinQuerySysPointer(HWND_DESKTOP, + SPTR_SIZENS, + FALSE)); + } + return MRFROMSHORT(FALSE); + case WM_BUTTON1DOWN: + { + APIRET rc; + RECTL rclFrame; + RECTL rclBounds; + RECTL rclStart; + USHORT startSize, orig, actual; + + WinQueryWindowRect(hwnd, &rclFrame); + WinQueryWindowRect(hwnd, &rclStart); + + WinQueryWindowRect(hwndFrame, &rclBounds); + + WinMapWindowPoints(hwndFrame, HWND_DESKTOP, + (PPOINTL)&rclBounds, 2); + WinMapWindowPoints(hwnd, HWND_DESKTOP, + (PPOINTL)&rclStart, 2); + + { + int z, pastsplitbar = FALSE, found = FALSE; + orig = actual = 0; + + for(z=0;z<thisbox->count;z++) + { + if(thisbox->items[z].hwnd == hwnd) + pastsplitbar = TRUE; + else + { + if(thisbox->type == BOXHORZ) + { + int tmpwidth, tmporigwidth; + + if(thisbox->items[z].type == TYPEBOX) + _count_size(thisbox->items[z].hwnd, BOXHORZ, &tmpwidth, &tmporigwidth); + else + { + tmpwidth = thisbox->items[z].width; + tmporigwidth = thisbox->items[z].origwidth; + } + + if(thisbox->items[z].hsize != SIZESTATIC && tmpwidth > actual && tmporigwidth) + { + found = pastsplitbar; + orig = tmporigwidth; + actual = tmpwidth; + } + } + else + { + int tmpheight, tmporigheight; + + if(thisbox->items[z].type == TYPEBOX) + _count_size(thisbox->items[z].hwnd, BOXVERT, &tmpheight, &tmporigheight); + else + { + tmpheight = thisbox->items[z].height; + tmporigheight = thisbox->items[z].origheight; + } + + if(thisbox->items[z].vsize != SIZESTATIC && tmpheight > actual && tmporigheight) + { + found = pastsplitbar; + orig = tmporigheight; + actual = tmpheight; + } + } + } + } + + /* If we couldn't determine a valid scale... then abort */ + if(!orig || !actual) + return MRFROMSHORT(FALSE); + + if(thisbox->type == BOXHORZ) + { + if(found) + startSize = (rclStart.xLeft - rclBounds.xLeft) + * (((float)actual)/((float)orig)); + else + startSize = (rclStart.xLeft - rclBounds.xLeft) + * (((float)orig)/((float)actual)); + } + else + { + if(found) + startSize = (rclStart.yBottom - rclBounds.yBottom) + * (((float)actual)/((float)orig)); + else + startSize = (rclStart.yBottom - rclBounds.yBottom) + * (((float)orig)/((float)actual)); + } + } + + rc = _TrackRectangle(hwnd, &rclFrame, &rclBounds); + + if(rc == TRUE) + { + USHORT usNewRB; + USHORT percent; + int z; + + if(thisbox->type == BOXHORZ) + { + usNewRB = rclFrame.xLeft + - rclBounds.xLeft; + } + else + { + usNewRB = rclFrame.yBottom + - rclBounds.yBottom; + } + + /* We don't want the item to disappear completely */ + if(!usNewRB) + usNewRB++; + + if(!startSize) + startSize++; + + percent = (usNewRB*100)/startSize; + + for(z=0;z<thisbox->count;z++) + { + if(thisbox->items[z].type == TYPEBOX) + { + Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); + _changebox(tmp, percent, thisbox->type); + } + else + { + if(thisbox->items[z].hwnd == hwnd) + percent = (startSize*100)/usNewRB; + + if(thisbox->type == BOXHORZ) + { + if(thisbox->items[z].hsize == SIZEEXPAND) + thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0))); + } + else + { + if(thisbox->items[z].vsize == SIZEEXPAND) + thisbox->items[z].height = (int)(((float)thisbox->items[z].origheight) * (((float)percent)/((float)100.0))); + } + } + } + + _ResetWindow(WinQueryWindow(hwnd, QW_OWNER)); + } + } + return MRFROMSHORT(FALSE); + } + return WinDefWindowProc(hwnd, msg, mp1, mp2); +} + +/* Function: BubbleProc + * Abstract: Subclass procedure for bubble help + */ +MRESULT EXPENTRY _BubbleProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) +{ + MRESULT res; + PFNWP proc = (PFNWP)WinQueryWindowPtr(hwnd, QWL_USER); + + if(proc) + res = proc(hwnd, msg, mp1, mp2); + else + res = WinDefWindowProc(hwnd, msg, mp1, mp2); + + if(msg == WM_PAINT) + { + POINTL ptl; + HPS hpsTemp; + RECTL rcl; + int height, width; + + WinQueryWindowRect(hwnd, &rcl); + height = rcl.yTop - rcl.yBottom - 1; + width = rcl.xRight - rcl.xLeft - 1; + + /* Draw a border around the bubble help */ + hpsTemp = WinGetPS(hwnd); + GpiSetColor(hpsTemp, DW_CLR_BLACK); + ptl.x = ptl.y = 0; + GpiMove(hpsTemp, &ptl); + ptl.x = 0; + ptl.y = height; + GpiLine(hpsTemp, &ptl); + ptl.x = ptl.y = 0; + GpiMove(hpsTemp, &ptl); + ptl.y = 0; + ptl.x = width; + GpiLine(hpsTemp, &ptl); + ptl.x = width; + ptl.y = height; + GpiMove(hpsTemp, &ptl); + ptl.x = 0; + ptl.y = height; + GpiLine(hpsTemp, &ptl); + ptl.x = width; + ptl.y = height; + GpiMove(hpsTemp, &ptl); + ptl.y = 0; + ptl.x = width; + GpiLine(hpsTemp, &ptl); + WinReleasePS(hpsTemp); + } + return res; +} + +/* Function: BtProc + * Abstract: Subclass procedure for buttons + */ + +MRESULT EXPENTRY _BtProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) +{ + BubbleButton *bubble; + + bubble = (BubbleButton *)WinQueryWindowPtr(hwnd, QWL_USER); + + if(!bubble) + return WinDefWindowProc(hwnd, msg, mp1, mp2); + + switch(msg) + { +#ifndef NO_SIGNALS + case WM_BUTTON1UP: + { + SignalHandler *tmp = Root; + + if(WinIsWindowEnabled(hwnd)) + { + /* Find any callbacks for this function */ + while(tmp) + { + if(tmp->message == WM_COMMAND) + { + /* Make sure it's the right window, and the right ID */ + if(tmp->window == hwnd) + { + /* Due to the fact that if we run the function + * here, finishing actions on the button will occur + * after we run the signal handler. So we post the + * message so the button can finish what it needs to + * do before we run our handler. + */ + WinPostMsg(hwnd, WM_USER, (MPARAM)tmp, 0); + tmp = NULL; + } + } + if(tmp) + tmp= tmp->next; + } + } + } + break; + case WM_USER: + { + SignalHandler *tmp = (SignalHandler *)mp1; + int (*clickfunc)(HWND, void *) = NULL; + + if(tmp) + { + clickfunc = (int (*)(HWND, void *))tmp->signalfunction; + + clickfunc(tmp->window, tmp->data); + } + } + break; +#endif + case WM_CHAR: + { +#ifndef NO_SIGNALS + /* A button press should also occur for an ENTER or SPACE press + * while the button has the active input focus. + */ + if(SHORT1FROMMP(mp2) == '\r' || SHORT1FROMMP(mp2) == ' ') + { + SignalHandler *tmp = Root; + + /* Find any callbacks for this function */ + while(tmp) + { + if(tmp->message == WM_COMMAND) + { + /* Make sure it's the right window, and the right ID */ + if(tmp->window == hwnd) + { + WinPostMsg(hwnd, WM_USER, (MPARAM)tmp, 0); + tmp = NULL; + } + } + if(tmp) + tmp= tmp->next; + } + } +#endif + if(SHORT1FROMMP(mp2) == '\t') + { + _shift_focus(hwnd); + return FALSE; + } + } + break; + case 0x041f: + if (hwndBubble) + { + WinDestroyWindow(hwndBubble); + hwndBubble = 0; + } + break; + + case 0x041e: + + if(!*bubble->bubbletext) + break; + + + if(hwndBubble) + { + WinDestroyWindow(hwndBubble); + hwndBubble = 0; + } + + if(!hwndBubble) + { + HPS hpsTemp = 0; + LONG lHight; + LONG lWidth; + POINTL txtPointl[TXTBOX_COUNT]; + POINTL ptlWork = {0,0}; + ULONG ulColor = DW_CLR_YELLOW; + void *blah; + + hwndBubbleLast = hwnd; + hwndBubble = WinCreateWindow(HWND_DESKTOP, + WC_STATIC, + "", + SS_TEXT | + DT_CENTER | + DT_VCENTER, + 0,0,0,0, + HWND_DESKTOP, + HWND_TOP, + 0, + NULL, + NULL); + + WinSetPresParam(hwndBubble, + PP_FONTNAMESIZE, + sizeof(DefaultFont), + DefaultFont); + + + WinSetPresParam(hwndBubble, + PP_BACKGROUNDCOLORINDEX, + sizeof(ulColor), + &ulColor); + + WinSetWindowText(hwndBubble, + bubble->bubbletext); + + WinMapWindowPoints(hwnd, HWND_DESKTOP, &ptlWork, 1); + + hpsTemp = WinGetPS(hwndBubble); + GpiQueryTextBox(hpsTemp, + strlen(bubble->bubbletext), + bubble->bubbletext, + TXTBOX_COUNT, + txtPointl); + WinReleasePS(hpsTemp); + + lWidth = txtPointl[TXTBOX_TOPRIGHT].x - + txtPointl[TXTBOX_TOPLEFT ].x + 8; + + lHight = txtPointl[TXTBOX_TOPLEFT].y - + txtPointl[TXTBOX_BOTTOMLEFT].y + 8; + + ptlWork.y -= lHight; + + blah = (void *)WinSubclassWindow(hwndBubble, _BubbleProc); + + if(blah) + WinSetWindowPtr(hwndBubble, QWP_USER, blah); + + WinSetWindowPos(hwndBubble, + HWND_TOP, + ptlWork.x, + ptlWork.y, + lWidth, + lHight, + SWP_SIZE | SWP_MOVE | SWP_SHOW); + } + break; + } + + if(!bubble->pOldProc) + return WinDefWindowProc(hwnd, msg, mp1, mp2); + return bubble->pOldProc(hwnd, msg, mp1, mp2); +} + +MRESULT EXPENTRY _RendProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) +{ + int res = 0; +#ifndef NO_SIGNALS + res = (int)_run_event(hwnd, msg, mp1, mp2); +#endif + switch(msg) + { + case WM_BUTTON1DOWN: + case WM_BUTTON2DOWN: + case WM_BUTTON3DOWN: + if(!res) + WinSetFocus(HWND_DESKTOP, hwnd); + return (MPARAM)TRUE; + } + return WinDefWindowProc(hwnd, msg, mp1, mp2); +} + +/* + * Initializes the Dynamic Windows engine. + * Parameters: + * newthread: True if this is the only thread. + * False if there is already a message loop running. + */ +int dw_init(int newthread) +{ + APIRET rc; + + if(newthread) + { + dwhab = WinInitialize(0); + dwhmq = WinCreateMsgQueue(dwhab, 0); + } + + rc = WinRegisterClass(dwhab, ClassName, _wndproc, CS_SIZEREDRAW | CS_CLIPCHILDREN, 32); + rc = WinRegisterClass(dwhab, SplitbarClassName, _splitwndproc, 0L, 32); + +#ifdef DWDEBUG + f = fopen("dw.log", "wt"); +#endif + return rc; +} + +/* + * Runs a message loop for Dynamic Windows. + * Parameters: + * currenthab: The handle to the current anchor block + * or NULL if this DW is handling the message loop. + * func: Function pointer to the message filter function. + */ +void dw_main(HAB currenthab, void *func) +{ + QMSG qmsg; + HAB habtouse; + + if(!currenthab) + habtouse = dwhab; + else + habtouse = currenthab; + + /* Setup the filter function */ + filterfunc = (int (* EXPENTRY)(HWND, ULONG, MPARAM, MPARAM))func; + + _dwtid = dw_thread_id(); + + while (WinGetMsg(habtouse, &qmsg, 0, 0, 0)) + WinDispatchMsg(habtouse, &qmsg); + +#ifdef DWDEBUG + fclose(f); +#endif + + if(!currenthab) + { + WinDestroyMsgQueue(dwhmq); + WinTerminate(dwhab); + } +} + +/* + * Free's memory allocated by dynamic windows. + * Parameters: + * ptr: Pointer to dynamic windows allocated + * memory to be free()'d. + */ +void dw_free(void *ptr) +{ + free(ptr); +} + +/* + * Allocates and initializes a dialog struct. + * Parameters: + * data: User defined data to be passed to functions. + */ +DWDialog *dw_dialog_new(void *data) +{ + DWDialog *tmp = malloc(sizeof(DWDialog)); + + tmp->eve = dw_event_new(); + dw_event_reset(tmp->eve); + tmp->data = data; + tmp->done = FALSE; + tmp->result = NULL; + + return tmp; +} + +/* + * Accepts a dialog struct and returns the given data to the + * initial called of dw_dialog_wait(). + * Parameters: + * dialog: Pointer to a dialog struct aquired by dw_dialog_new). + * result: Data to be returned by dw_dialog_wait(). + */ +int dw_dialog_dismiss(DWDialog *dialog, void *result) +{ + dialog->result = result; + dw_event_post(dialog->eve); + dialog->done = TRUE; + return 0; +} + +/* + * Accepts a dialog struct waits for dw_dialog_dismiss() to be + * called by a signal handler with the given dialog struct. + * Parameters: + * dialog: Pointer to a dialog struct aquired by dw_dialog_new). + */ +void *dw_dialog_wait(DWDialog *dialog) +{ + QMSG qmsg; + void *tmp; + + while (WinGetMsg(dwhab, &qmsg, 0, 0, 0)) + { + WinDispatchMsg(dwhab, &qmsg); + if(dialog->done) + break; + } + dw_event_close(&dialog->eve); + tmp = dialog->result; + free(dialog); + return tmp; +} + + +/* + * Displays a Message Box with given text and title.. + * Parameters: + * title: The title of the message box. + * format: printf style format string. + * ...: Additional variables for use in the format. + */ +int dw_messagebox(char *title, char *format, ...) +{ + va_list args; + char outbuf[1024]; + + va_start(args, format); + vsprintf(outbuf, format, args); + va_end(args); + + WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, outbuf, title, 0, MB_OK | MB_INFORMATION | MB_MOVEABLE); + + return strlen(outbuf); +} + +/* + * Displays a Message Box with given text and title.. + * Parameters: + * title: The title of the message box. + * text: The text to display in the box. + * Returns: + * True if YES False of NO. + */ +int dw_yesno(char *title, char *text) +{ + if(WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, title, 0, MB_YESNO | MB_INFORMATION | MB_MOVEABLE | MB_SYSTEMMODAL)==MBID_YES) + return TRUE; + return FALSE; +} + +/* + * Makes the window visible. + * Parameters: + * handle: The window handle to make visible. + */ +int dw_window_show(HWND handle) +{ + int rc = WinSetWindowPos(handle, NULLHANDLE, 0, 0, 0, 0, SWP_SHOW); + HSWITCH hswitch; + SWCNTRL swcntrl; + + WinSetFocus(HWND_DESKTOP, handle); + _initial_focus(handle); + + /* If this window has a switch list entry make sure it is visible */ + hswitch = WinQuerySwitchHandle(handle, 0); + if(hswitch) + { + WinQuerySwitchEntry(hswitch, &swcntrl); + swcntrl.uchVisibility = SWL_VISIBLE; + WinChangeSwitchEntry(hswitch, &swcntrl); + } + return rc; + +} + +/* + * Makes the window invisible. + * Parameters: + * handle: The window handle to make visible. + */ +int dw_window_hide(HWND handle) +{ + HSWITCH hswitch; + SWCNTRL swcntrl; + + /* If this window has a switch list entry make sure it is invisible */ + hswitch = WinQuerySwitchHandle(handle, 0); + if(hswitch) + { + WinQuerySwitchEntry(hswitch, &swcntrl); + swcntrl.uchVisibility = SWL_INVISIBLE; + WinChangeSwitchEntry(hswitch, &swcntrl); + } + return WinShowWindow(handle, FALSE); +} + +/* + * Destroys a window and all of it's children. + * Parameters: + * handle: The window handle to destroy. + */ +int dw_window_destroy(HWND handle) +{ + return WinDestroyWindow(handle); +} + +/* + * Changes a window's parent to newparent. + * Parameters: + * handle: The window handle to destroy. + * newparent: The window's new parent window. + */ +void dw_window_reparent(HWND handle, HWND newparent) +{ + HWND blah = WinWindowFromID(newparent, FID_CLIENT); + WinSetParent(handle, blah ? blah : newparent, TRUE); +} + +/* + * Sets the font used by a specified window (widget) handle. + * Parameters: + * handle: The window (widget) handle. + * fontname: Name and size of the font in the form "size.fontname" + */ +int dw_window_set_font(HWND handle, char *fontname) +{ + return WinSetPresParam(handle, PP_FONTNAMESIZE, strlen(fontname)+1, fontname); +} + +/* + * Sets the colors used by a specified window (widget) handle. + * Parameters: + * handle: The window (widget) handle. + * fore: Foreground color in DW_RGB format or a default color index. + * back: Background color in DW_RGB format or a default color index. + */ +int dw_window_set_color(HWND handle, ULONG fore, ULONG back) +{ + if((fore & DW_RGB_COLOR) == DW_RGB_COLOR) + { + RGB2 rgb2; + + rgb2.bBlue = DW_BLUE_VALUE(fore); + rgb2.bGreen = DW_GREEN_VALUE(fore); + rgb2.bRed = DW_RED_VALUE(fore); + rgb2.fcOptions = 0; + + WinSetPresParam(handle, PP_FOREGROUNDCOLOR, sizeof(RGB2), &rgb2); + + } + if((back & DW_RGB_COLOR) == DW_RGB_COLOR) + { + RGB2 rgb2; + + rgb2.bBlue = DW_BLUE_VALUE(back); + rgb2.bGreen = DW_GREEN_VALUE(back); + rgb2.bRed = DW_RED_VALUE(back); + rgb2.fcOptions = 0; + + WinSetPresParam(handle, PP_BACKGROUNDCOLOR, sizeof(RGB2), &rgb2); + return 0; + } + if((fore & DW_RGB_COLOR) == DW_RGB_COLOR) + return 0; + + /* Slight conversion */ + if(fore == DW_CLR_BLACK) + fore = CLR_BLACK; + if(fore == DW_CLR_WHITE) + fore = CLR_WHITE; + + if(back == DW_CLR_BLACK) + back = CLR_BLACK; + if(back == DW_CLR_WHITE) + back = CLR_WHITE; + + return (WinSetPresParam(handle, PP_FOREGROUNDCOLORINDEX, sizeof(ULONG), &fore) | + WinSetPresParam(handle, PP_BACKGROUNDCOLORINDEX, sizeof(ULONG), &back)); +} + +/* + * Sets the font used by a specified window (widget) handle. + * Parameters: + * handle: The window (widget) handle. + * border: Size of the window border in pixels. + */ +int dw_window_set_border(HWND handle, int border) +{ + WinSendMsg(handle, WM_SETBORDERSIZE, MPFROMSHORT(border), MPFROMSHORT(border)); + return 0; +} + +/* + * Captures the mouse input to this window. + * Parameters: + * handle: Handle to receive mouse input. + */ +void dw_window_capture(HWND handle) +{ + WinSetCapture(HWND_DESKTOP, handle); +} + +/* + * Releases previous mouse capture. + */ +void dw_window_release(void) +{ + WinSetCapture(HWND_DESKTOP, NULLHANDLE); +} + +/* + * Tracks this window movement. + * Parameters: + * handle: Handle to frame to be tracked. + */ +void dw_window_track(HWND handle) +{ + WinSendMsg(handle, WM_TRACKFRAME, MPFROMSHORT(TF_MOVE), 0); +} + +/* + * Create a new Window Frame. + * Parameters: + * owner: The Owner's window handle or HWND_DESKTOP. + * title: The Window title. + * flStyle: Style flags, see the PM reference. + */ +HWND dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) +{ + HWND hwndclient = 0, hwndframe; + Box *newbox = malloc(sizeof(Box)); + PFNWP *blah = malloc(sizeof(PFNWP)); + + newbox->pad = 0; + newbox->type = BOXVERT; + newbox->count = 0; + + flStyle |= FCF_NOBYTEALIGN; + + hwndframe = WinCreateStdWindow(hwndOwner, 0L, &flStyle, ClassName, title, 0L, NULLHANDLE, 0L, &hwndclient); + *blah = WinSubclassWindow(hwndframe, _sizeproc); + WinSetWindowPtr(hwndframe, QWP_USER, blah); + WinSetWindowPtr(hwndclient, QWP_USER, newbox); + + return hwndframe; +} + +/* + * Create a new Box to be packed. + * Parameters: + * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). + * pad: Number of pixels to pad around the box. + */ +HWND dw_box_new(int type, int pad) +{ + Box *newbox = malloc(sizeof(Box)); + HWND hwndframe; + + newbox->pad = pad; + newbox->type = type; + newbox->count = 0; + newbox->grouphwnd = NULLHANDLE; + + hwndframe = WinCreateWindow(HWND_OBJECT, + WC_FRAME, + NULL, + WS_VISIBLE | WS_CLIPCHILDREN, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + 0L, + NULL, + NULL); + + newbox->oldproc = WinSubclassWindow(hwndframe, _controlproc); + WinSetWindowPtr(hwndframe, QWP_USER, newbox); + dw_window_set_color(hwndframe, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + return hwndframe; +} + +/* + * Create a new Group Box to be packed. + * Parameters: + * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). + * pad: Number of pixels to pad around the box. + * title: Text to be displayined in the group outline. + */ +HWND dw_groupbox_new(int type, int pad, char *title) +{ + Box *newbox = malloc(sizeof(Box)); + HWND hwndframe; + + newbox->pad = pad; + newbox->type = type; + newbox->count = 0; + + hwndframe = WinCreateWindow(HWND_OBJECT, + WC_FRAME, + NULL, + WS_VISIBLE, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + 0L, + NULL, + NULL); + + newbox->grouphwnd = WinCreateWindow(hwndframe, + WC_STATIC, + title, + WS_VISIBLE | SS_GROUPBOX | + WS_GROUP, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + 0L, + NULL, + NULL); + + WinSetWindowPtr(hwndframe, QWP_USER, newbox); + dw_window_set_color(hwndframe, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + dw_window_set_color(newbox->grouphwnd, DW_CLR_BLACK, DW_CLR_PALEGRAY); + dw_window_set_font(newbox->grouphwnd, DefaultFont); + return hwndframe; +} + +/* + * Create a bitmap object to be packed. + * Parameters: + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_bitmap_new(ULONG id) +{ + return WinCreateWindow(HWND_OBJECT, + WC_STATIC, + NULL, + WS_VISIBLE | SS_TEXT, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + id, + NULL, + NULL); +} + +/* + * Create a notebook object to be packed. + * Parameters: + * id: An ID to be used for getting the resource from the + * resource file. + */ +HWND dw_notebook_new(ULONG id, int top) +{ + ULONG flags; + HWND tmp; + + if(top) + flags = BKS_MAJORTABTOP; + else + flags = BKS_MAJORTABBOTTOM; + + tmp = WinCreateWindow(HWND_OBJECT, + WC_NOTEBOOK, + NULL, + WS_VISIBLE | + BKS_TABBEDDIALOG | + flags, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + id, + NULL, + NULL); + + dw_window_set_font(tmp, DefaultFont); + return tmp; +} + +/* + * Create a menu object to be popped up. + * Parameters: + * id: An ID to be used for getting the resource from the + * resource file. + */ +HMENUI dw_menu_new(ULONG id) +{ + HMENUI tmp = malloc(sizeof(struct _hmenui)); + + if(!tmp) + return NULL; + + tmp->menu = WinCreateWindow(HWND_OBJECT, + WC_MENU, + NULL, + WS_VISIBLE, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + id, + NULL, + NULL); + return tmp; +} + +/* + * Create a menubar on a window. + * Parameters: + * location: Handle of a window frame to be attached to. + */ +HMENUI dw_menubar_new(HWND location) +{ + HMENUI tmp = malloc(sizeof(struct _hmenui)); + + if(!tmp) + return NULL; + + tmp->menu = WinCreateWindow(location, + WC_MENU, + NULL, + WS_VISIBLE | MS_ACTIONBAR, + 0,0,2000,1000, + location, + HWND_TOP, + FID_MENU, + NULL, + NULL); + return tmp; +} + +/* + * Destroys a menu created with dw_menubar_new or dw_menu_new. + * Parameters: + * menu: Handle of a menu. + */ +void dw_menu_destroy(HMENUI *menu) +{ + if(menu && *menu) + { + WinDestroyWindow((*menu)->menu); + free(*menu); + *menu = NULL; + } +} + +/* + * Adds a menuitem or submenu to an existing menu. + * Parameters: + * menu: The handle the the existing menu. + * title: The title text on the menu item to be added. + * id: An ID to be used for message passing. + * flags: Extended attributes to set on the menu. + * end: If TRUE memu is positioned at the end of the menu. + * check: If TRUE menu is "check"able. + * submenu: Handle to an existing menu to be a submenu or NULL. + */ +HWND dw_menu_append_item(HMENUI menux, char *title, ULONG id, ULONG flags, int end, int check, HMENUI submenu) +{ + MENUITEM miSubMenu; + HWND menu; + + if(!menux) + return NULLHANDLE; + + menu = menux->menu; + + if(end) + miSubMenu.iPosition=MIT_END; + else + miSubMenu.iPosition=0; + + if(strlen(title) == 0) + miSubMenu.afStyle=MIS_SEPARATOR | flags; + else + miSubMenu.afStyle=MIS_TEXT | flags; + miSubMenu.afAttribute=0; + miSubMenu.id=id; + miSubMenu.hwndSubMenu = submenu ? submenu->menu : 0; + miSubMenu.hItem=NULLHANDLE; + + WinSendMsg(menu, + MM_INSERTITEM, + MPFROMP(&miSubMenu), + MPFROMP(title)); + return (HWND)id; +} + +/* + * Sets the state of a menu item check. + * Parameters: + * menu: The handle the the existing menu. + * id: Menuitem id. + * check: TRUE for checked FALSE for not checked. + */ +void dw_menu_item_set_check(HMENUI menux, int id, int check) +{ + HWND menu; + + if(!menux) + return; + + menu = menux->menu; + + if(check) + WinSendMsg(menu, MM_SETITEMATTR, MPFROM2SHORT(id, TRUE), + MPFROM2SHORT(MIA_CHECKED, MIA_CHECKED)); + else + WinSendMsg(menu, MM_SETITEMATTR, MPFROM2SHORT(id, TRUE), + MPFROM2SHORT(MIA_CHECKED, 0)); +} + +/* + * Pops up a context menu at given x and y coordinates. + * Parameters: + * menu: The handle the the existing menu. + * parent: Handle to the window initiating the popup. + * x: X coordinate. + * y: Y coordinate. + */ +void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) +{ + if(menu && *menu) + { + WinPopupMenu(HWND_DESKTOP, parent, (*menu)->menu, x, dw_screen_height() - y, 0, PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_VCONSTRAIN | PU_HCONSTRAIN); + free(*menu); + *menu = NULL; + } +} + +/* + * Returns the current X and Y coordinates of the mouse pointer. + * Parameters: + * x: Pointer to variable to store X coordinate. + * y: Pointer to variable to store Y coordinate. + */ +void dw_pointer_query_pos(long *x, long *y) +{ + POINTL ptl; + + WinQueryPointerPos(HWND_DESKTOP, &ptl); + if(x && y) + { + *x = ptl.x; + *y = dw_screen_height() - ptl.y; + } +} + +/* + * Sets the X and Y coordinates of the mouse pointer. + * Parameters: + * x: X coordinate. + * y: Y coordinate. + */ +void dw_pointer_set_pos(long x, long y) +{ + WinSetPointerPos(HWND_DESKTOP, x, dw_screen_height() - y); +} + +/* + * Create a container object to be packed. + * Parameters: + * id: An ID to be used for getting the resource from the + * resource file. + */ +HWND dw_container_new(ULONG id) +{ + HWND tmp = WinCreateWindow(HWND_OBJECT, + WC_CONTAINER, + NULL, + WS_VISIBLE | CCS_READONLY | + CCS_SINGLESEL | CCS_AUTOPOSITION, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + id, + NULL, + NULL); + dw_window_set_font(tmp, DefaultFont); + return tmp; +} + +/* + * Create a new static text window (widget) to be packed. + * Parameters: + * text: The text to be display by the static text widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_text_new(char *text, ULONG id) +{ + HWND tmp = WinCreateWindow(HWND_OBJECT, + WC_STATIC, + text, + WS_VISIBLE | SS_TEXT, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + id, + NULL, + NULL); + dw_window_set_font(tmp, DefaultFont); + dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); + return tmp; +} + +/* + * Create a new Multiline Editbox window (widget) to be packed. + * Parameters: + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_mle_new(ULONG id) +{ + HWND tmp = WinCreateWindow(HWND_OBJECT, + WC_MLE, + "", + WS_VISIBLE | + MLS_BORDER | MLS_IGNORETAB | + MLS_READONLY | MLS_VSCROLL, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + id, + NULL, + NULL); + dw_window_set_font(tmp, DefaultFont); + dw_window_set_font(tmp, DefaultFont); + return tmp; +} + +/* + * Create a new Entryfield window (widget) to be packed. + * Parameters: + * text: The default text to be in the entryfield widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_entryfield_new(char *text, ULONG id) +{ + PFNWP *blah = malloc(sizeof(PFNWP)); + HWND tmp = WinCreateWindow(HWND_OBJECT, + WC_ENTRYFIELD, + text, + WS_VISIBLE | ES_MARGIN | + ES_AUTOSCROLL | WS_TABSTOP, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + id, + NULL, + NULL); + dw_window_set_font(tmp, DefaultFont); + *blah = WinSubclassWindow(tmp, _entryproc); + WinSetWindowPtr(tmp, QWP_USER, blah); + return tmp; +} + +/* + * Create a new Entryfield (password) window (widget) to be packed. + * Parameters: + * text: The default text to be in the entryfield widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_entryfield_password_new(char *text, ULONG id) +{ + PFNWP *blah = malloc(sizeof(PFNWP)); + HWND tmp = WinCreateWindow(HWND_OBJECT, + WC_ENTRYFIELD, + text, + WS_VISIBLE | ES_MARGIN | ES_UNREADABLE | + ES_AUTOSCROLL | WS_TABSTOP, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + id, + NULL, + NULL); + dw_window_set_font(tmp, DefaultFont); + *blah = WinSubclassWindow(tmp, _entryproc); + WinSetWindowPtr(tmp, QWP_USER, blah); + return tmp; +} + +/* + * Create a new Combobox window (widget) to be packed. + * Parameters: + * text: The default text to be in the combpbox widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_combobox_new(char *text, ULONG id) +{ + PFNWP *blah = malloc(sizeof(PFNWP)); + HWND tmp = WinCreateWindow(HWND_OBJECT, + WC_COMBOBOX, + text, + WS_VISIBLE | CBS_DROPDOWN | WS_GROUP, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + id, + NULL, + NULL); + dw_window_set_font(tmp, DefaultFont); + dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE); + *blah = WinSubclassWindow(tmp, _comboproc); + WinSetWindowPtr(tmp, QWP_USER, blah); + return tmp; +} + +/* + * Create a new button window (widget) to be packed. + * Parameters: + * text: The text to be display by the static text widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_button_new(char *text, ULONG id) +{ + BubbleButton *bubble = malloc(sizeof(BubbleButton)); + + HWND tmp = WinCreateWindow(HWND_OBJECT, + WC_BUTTON, + text, + WS_VISIBLE, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + id, + NULL, + NULL); + + bubble->id = id; + bubble->bubbletext[0] = '\0'; + bubble->pOldProc = WinSubclassWindow(tmp, _BtProc); + + WinSetWindowPtr(tmp, QWP_USER, bubble); + dw_window_set_font(tmp, DefaultFont); + return tmp; +} + +/* Function: GenResIDStr +** Abstract: Generate string '#nnnn' for a given ID for using with Button +** controls +*/ + +void _GenResIDStr(CHAR *buff, ULONG ulID) +{ + char *str; + int slen = 0; + + *buff++ = '#'; + + str = buff; + + do + { + *str++ = (ulID % 10) + '0'; + ulID /= 10; + slen++; + } + while(ulID); + + *str-- = 0; + + for(; str > buff; str--, buff++) + { + *buff ^= *str; + *str ^= *buff; + *buff ^= *str; + } +} + + +/* + * Create a new bitmap button window (widget) to be packed. + * Parameters: + * text: Bubble help text to be displayed. + * id: An ID of a bitmap in the resource file. + */ +HWND dw_bitmapbutton_new(char *text, ULONG id) +{ + char idbuf[256]; + HWND tmp; + BubbleButton *bubble = malloc(sizeof(BubbleButton)); + + _GenResIDStr(idbuf, id); + + tmp = WinCreateWindow(HWND_OBJECT, + WC_BUTTON, + idbuf, + WS_VISIBLE | BS_PUSHBUTTON | + BS_BITMAP | BS_AUTOSIZE | + BS_NOPOINTERFOCUS, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + id, + NULL, + NULL); + + bubble->id = id; + strncpy(bubble->bubbletext, text, BUBBLE_HELP_MAX - 1); + bubble->bubbletext[BUBBLE_HELP_MAX - 1] = '\0'; + bubble->pOldProc = WinSubclassWindow(tmp, _BtProc); + + WinSetWindowPtr(tmp, QWP_USER, bubble); + return tmp; +} + +/* + * Create a new spinbutton window (widget) to be packed. + * Parameters: + * text: The text to be display by the static text widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND +dw_spinbutton_new(char *text, ULONG id) +{ + PFNWP *blah = malloc(sizeof(PFNWP)); + HWND tmp = WinCreateWindow(HWND_OBJECT, + WC_SPINBUTTON, + text, + WS_VISIBLE | SPBS_MASTER, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + id, + NULL, + NULL); + dw_window_set_font(tmp, DefaultFont); + *blah = WinSubclassWindow(tmp, _entryproc); + WinSetWindowPtr(tmp, QWP_USER, blah); + return tmp; +} + +/* + * Create a new radiobutton window (widget) to be packed. + * Parameters: + * text: The text to be display by the static text widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_radiobutton_new(char *text, ULONG id) +{ + PFNWP *blah = malloc(sizeof(PFNWP)); + HWND tmp = WinCreateWindow(HWND_OBJECT, + WC_BUTTON, + text, + WS_VISIBLE | + BS_AUTORADIOBUTTON, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + id, + NULL, + NULL); + dw_window_set_font(tmp, DefaultFont); + dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); + *blah = WinSubclassWindow(tmp, _entryproc); + WinSetWindowPtr(tmp, QWP_USER, blah); + return tmp; +} + +/* + * Create a new slider window (widget) to be packed. + * Parameters: + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_slider_new(ULONG id) +{ + return WinCreateWindow(HWND_OBJECT, + WC_SLIDER, + NULL, + WS_VISIBLE, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + id, + NULL, + NULL); +} + +/* + * Create a new checkbox window (widget) to be packed. + * Parameters: + * text: The text to be display by the static text widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_checkbox_new(char *text, ULONG id) +{ + PFNWP *blah = malloc(sizeof(PFNWP)); + HWND tmp = WinCreateWindow(HWND_OBJECT, + WC_BUTTON, + text, + WS_VISIBLE | BS_AUTOCHECKBOX, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + id, + NULL, + NULL); + dw_window_set_font(tmp, DefaultFont); + dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); + *blah = WinSubclassWindow(tmp, _entryproc); + WinSetWindowPtr(tmp, QWP_USER, blah); + return tmp; +} + +/* + * Create a new listbox window (widget) to be packed. + * Parameters: + * id: An ID to be used with WinWindowFromID() or 0L. + * multi: Multiple select TRUE or FALSE. + */ +HWND dw_listbox_new(ULONG id, int multi) +{ + PFNWP *blah = malloc(sizeof(PFNWP)); + HWND tmp = WinCreateWindow(HWND_OBJECT, + WC_LISTBOX, + NULL, + WS_VISIBLE | LS_NOADJUSTPOS | + (multi ? LS_MULTIPLESEL : 0), + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + id, + NULL, + NULL); + dw_window_set_font(tmp, DefaultFont); + *blah = WinSubclassWindow(tmp, _entryproc); + WinSetWindowPtr(tmp, QWP_USER, blah); + return tmp; +} + +/* + * Sets the icon used for a given window. + * Parameters: + * handle: Handle to the window. + * id: An ID to be used to specify the icon. + */ +void dw_window_set_icon(HWND handle, ULONG id) +{ + HPOINTER icon; + + icon = WinLoadPointer(HWND_DESKTOP,NULLHANDLE,id); + WinSendMsg(handle, WM_SETICON, (MPARAM)icon, 0); +} + +/* + * Sets the bitmap used for a given static window. + * Parameters: + * handle: Handle to the window. + * id: An ID to be used to specify the icon. + */ +void dw_window_set_bitmap(HWND handle, ULONG id) +{ + HBITMAP hbm; + HPS hps = WinGetPS(handle); + + hbm = GpiLoadBitmap(hps, NULLHANDLE, id, 0, 0); + WinSetWindowBits(handle,QWL_STYLE,SS_BITMAP,SS_BITMAP | 0x7f); + WinSendMsg( handle, SM_SETHANDLE, MPFROMP(hbm), NULL ); + /*WinSetWindowULong( hwndDlg, QWL_USER, (ULONG) hbm );*/ + WinReleasePS(hps); +} + +/* + * Sets the text used for a given window. + * Parameters: + * handle: Handle to the window. + * text: The text associsated with a given window. + */ +void dw_window_set_text(HWND handle, char *text) +{ + WinSetWindowText(handle, text); +} + +/* + * Gets the text used for a given window. + * Parameters: + * handle: Handle to the window. + * Returns: + * text: The text associsated with a given window. + */ +char *dw_window_get_text(HWND handle) +{ + char tempbuf[4096] = ""; + + WinQueryWindowText(handle, 4095, tempbuf); + tempbuf[4095] = 0; + + return strdup(tempbuf); +} + +/* + * Disables given window (widget). + * Parameters: + * handle: Handle to the window. + */ +void dw_window_disable(HWND handle) +{ + WinEnableWindow(handle, FALSE); +} + +/* + * Enables given window (widget). + * Parameters: + * handle: Handle to the window. + */ +void dw_window_enable(HWND handle) +{ + WinEnableWindow(handle, TRUE); +} + +/* + * Gets the child window handle with specified ID. + * Parameters: + * handle: Handle to the parent window. + * id: Integer ID of the child. + */ +HWND dw_window_from_id(HWND handle, int id) +{ + HENUM henum; + HWND child; + char tmpbuf[100]; + + henum = WinBeginEnumWindows(handle); + while((child = WinGetNextWindow(henum)) != NULLHANDLE) + { + int windowid = WinQueryWindowUShort(child, QWS_ID); + HWND found; + + WinQueryClassName(child, 99, tmpbuf); + + /* If the child is a box (frame) then recurse into it */ + if(strncmp(tmpbuf, "#1", 2)==0) + if((found = dw_window_from_id(child, id)) != NULLHANDLE) + return found; + + if(windowid && windowid == id) + { + WinEndEnumWindows(henum); + return child; + } + } + WinEndEnumWindows(henum); + return NULLHANDLE; +} + +/* + * Pack windows (widgets) into a box from the end (or bottom). + * Parameters: + * box: Window handle of the box to be packed into. + * item: Window handle of the item to be back. + * width: Width in pixels of the item or -1 to be self determined. + * height: Height in pixels of the item or -1 to be self determined. + * hsize: TRUE if the window (widget) should expand horizontally to fill space given. + * vsize: TRUE if the window (widget) should expand vertically to fill space given. + * pad: Number of pixels of padding around the item. + */ +void dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) +{ + Box *thisbox; + + if(WinWindowFromID(box, FID_CLIENT)) + { + box = WinWindowFromID(box, FID_CLIENT); + thisbox = WinQueryWindowPtr(box, QWP_USER); + } + else + thisbox = WinQueryWindowPtr(box, QWP_USER); + if(thisbox) + { + if(thisbox->type == BOXHORZ) + dw_box_pack_start_stub(box, item, width, height, hsize, vsize, pad); + else + dw_box_pack_end_stub(box, item, width, height, hsize, vsize, pad); + } +} + +void dw_box_pack_end_stub(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) +{ + HWND boxowner = NULLHANDLE; + Box *thisbox; + + if(WinWindowFromID(box, FID_CLIENT)) + { + box = WinWindowFromID(box, FID_CLIENT); + thisbox = WinQueryWindowPtr(box, QWP_USER); + hsize = TRUE; + vsize = TRUE; + } + else + thisbox = WinQueryWindowPtr(box, QWP_USER); + if(!thisbox) + { + box = WinWindowFromID(box, FID_CLIENT); + if(box) + { + thisbox = WinQueryWindowPtr(box, QWP_USER); + hsize = TRUE; + vsize = TRUE; + } + } + if(thisbox) + { + int z; + Item *tmpitem, *thisitem = thisbox->items; + char tmpbuf[100]; + + tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); + + for(z=0;z<thisbox->count;z++) + { + tmpitem[z] = thisitem[z]; + } + + WinQueryClassName(item, 99, tmpbuf); + + if(strncmp(tmpbuf, "#1", 2)==0) + tmpitem[thisbox->count].type = TYPEBOX; + else + tmpitem[thisbox->count].type = TYPEITEM; + + tmpitem[thisbox->count].hwnd = item; + tmpitem[thisbox->count].origwidth = tmpitem[thisbox->count].width = width; + tmpitem[thisbox->count].origheight = tmpitem[thisbox->count].height = height; + tmpitem[thisbox->count].pad = pad; + if(hsize) + tmpitem[thisbox->count].hsize = SIZEEXPAND; + else + tmpitem[thisbox->count].hsize = SIZESTATIC; + + if(vsize) + tmpitem[thisbox->count].vsize = SIZEEXPAND; + else + tmpitem[thisbox->count].vsize = SIZESTATIC; + + thisbox->items = tmpitem; + + if(thisbox->count) + free(thisitem); + + thisbox->count++; + + /* Don't set the ownership if it's an entryfield or combobox */ + WinQueryClassName(item, 99, tmpbuf); + if(strncmp(tmpbuf, "#6", 2)!=0 /*&& strncmp(tmpbuf, "#2", 2)!=0*/) + { + if((boxowner = WinQueryWindow(box, QW_OWNER)) != 0) + WinSetOwner(item, boxowner); + else + WinSetOwner(item, box); + } + WinSetParent(item, box, FALSE); + } +} + +/* + * Sets the size of a given window (widget). + * Parameters: + * handle: Window (widget) handle. + * width: New width in pixels. + * height: New height in pixels. + */ +void dw_window_set_usize(HWND handle, ULONG width, ULONG height) +{ + WinSetWindowPos(handle, NULLHANDLE, 0, 0, width, height, SWP_SHOW | SWP_SIZE); +} + +/* + * Returns the width of the screen. + */ +int dw_screen_width(void) +{ + return WinQuerySysValue(HWND_DESKTOP,SV_CXSCREEN); +} + +/* + * Returns the height of the screen. + */ +int dw_screen_height(void) +{ + return WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN); +} + +/* This should return the current color depth */ +unsigned long dw_color_depth(void) +{ + HDC hdc = WinOpenWindowDC(HWND_DESKTOP); + long colors; + + DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, &colors); + DevCloseDC(hdc); + return colors; +} + + +/* + * Sets the position of a given window (widget). + * Parameters: + * handle: Window (widget) handle. + * x: X location from the bottom left. + * y: Y location from the bottom left. + */ +void dw_window_set_pos(HWND handle, ULONG x, ULONG y) +{ + int myy = _get_frame_height(handle) - (y + _get_height(handle)); + + WinSetWindowPos(handle, NULLHANDLE, x, myy, 0, 0, SWP_MOVE); +} + +/* + * Sets the position and size of a given window (widget). + * Parameters: + * handle: Window (widget) handle. + * x: X location from the bottom left. + * y: Y location from the bottom left. + * width: Width of the widget. + * height: Height of the widget. + */ +void dw_window_set_pos_size(HWND handle, ULONG x, ULONG y, ULONG width, ULONG height) +{ + int myy = _get_frame_height(handle) - (y + height); + + WinSetWindowPos(handle, NULLHANDLE, x, myy, width, height, SWP_MOVE | SWP_SIZE | SWP_SHOW); +} + +/* + * Gets the position and size of a given window (widget). + * Parameters: + * handle: Window (widget) handle. + * x: X location from the bottom left. + * y: Y location from the bottom left. + * width: Width of the widget. + * height: Height of the widget. + */ +void dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height) +{ + SWP swp; + WinQueryWindowPos(handle, &swp); + if(x) + *x = swp.x; + if(y) + *y = _get_frame_height(handle) - (swp.y + swp.cy); + if(width) + *width = swp.cx; + if(height) + *height = swp.cy; +} + +/* + * Sets the style of a given window (widget). + * Parameters: + * handle: Window (widget) handle. + * width: New width in pixels. + * height: New height in pixels. + */ +void dw_window_set_style(HWND handle, ULONG style, ULONG mask) +{ + WinSetWindowBits(handle, QWL_STYLE, style, mask); +} + +/* + * Adds a new page to specified notebook. + * Parameters: + * handle: Window (widget) handle. + * flags: Any additional page creation flags. + * front: If TRUE page is added at the beginning. + */ +ULONG dw_notebook_page_new(HWND handle, ULONG flags, int front) +{ + if(front) + return (ULONG)WinSendMsg(handle, BKM_INSERTPAGE, 0L, + MPFROM2SHORT((BKA_STATUSTEXTON | BKA_AUTOPAGESIZE | BKA_MAJOR | flags), BKA_FIRST)); + return (ULONG)WinSendMsg(handle, BKM_INSERTPAGE, 0L, + MPFROM2SHORT((BKA_STATUSTEXTON | BKA_AUTOPAGESIZE | BKA_MAJOR | flags), BKA_LAST)); +} + +/* + * Remove a page from a notebook. + * Parameters: + * handle: Handle to the notebook widget. + * pageid: ID of the page to be destroyed. + */ +void dw_notebook_page_destroy(HWND handle, unsigned int pageid) +{ + WinSendMsg(handle, BKM_DELETEPAGE, + MPFROMLONG(pageid), (MPARAM)BKA_SINGLE); +} + +/* + * Queries the currently visible page ID. + * Parameters: + * handle: Handle to the notebook widget. + */ +unsigned int dw_notebook_page_query(HWND handle) +{ + return (int)WinSendMsg(handle, BKM_QUERYPAGEID,0L, MPFROM2SHORT(BKA_TOP, BKA_MAJOR)); +} + +/* + * Sets the currently visibale page ID. + * Parameters: + * handle: Handle to the notebook widget. + * pageid: ID of the page to be made visible. + */ +void dw_notebook_page_set(HWND handle, unsigned int pageid) +{ + WinSendMsg(handle, BKM_TURNTOPAGE, MPFROMLONG(pageid), 0L); +} + +/* + * Sets the text on the specified notebook tab. + * Parameters: + * handle: Notebook handle. + * pageid: Page ID of the tab to set. + * text: Pointer to the text to set. + */ +void dw_notebook_page_set_text(HWND handle, ULONG pageid, char *text) +{ + WinSendMsg(handle, BKM_SETTABTEXT, + MPFROMLONG(pageid), MPFROMP(text)); +} + +/* + * Sets the text on the specified notebook tab status area. + * Parameters: + * handle: Notebook handle. + * pageid: Page ID of the tab to set. + * text: Pointer to the text to set. + */ +void dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text) +{ + WinSendMsg(handle, BKM_SETSTATUSLINETEXT, + MPFROMLONG(pageid), MPFROMP(text)); +} + +/* + * Packs the specified box into the notebook page. + * Parameters: + * handle: Handle to the notebook to be packed. + * pageid: Page ID in the notebook which is being packed. + * page: Box handle to be packed. + */ +void dw_notebook_pack(HWND handle, ULONG pageid, HWND page) +{ + HWND tmpbox = dw_box_new(BOXVERT, 0); + + dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0); + WinSubclassWindow(tmpbox, _wndproc); + WinSendMsg(handle, BKM_SETPAGEWINDOWHWND, + MPFROMLONG(pageid), MPFROMHWND(tmpbox)); +} + +/* + * Appends the specified text to the listbox's (or combobox) entry list. + * Parameters: + * handle: Handle to the listbox to be appended to. + * text: Text to append into listbox. + */ +void dw_listbox_append(HWND handle, char *text) +{ + WinSendMsg(handle, + LM_INSERTITEM, + MPFROMSHORT(LIT_END), + MPFROMP(text)); +} + +/* + * Clears the listbox's (or combobox) list of all entries. + * Parameters: + * handle: Handle to the listbox to be cleared. + */ +void dw_listbox_clear(HWND handle) +{ + WinSendMsg(handle, + LM_DELETEALL, 0L, 0L); +} + +/* + * Returns the listbox's item count. + * Parameters: + * handle: Handle to the listbox to be cleared. + */ +int dw_listbox_count(HWND handle) +{ + return (int)WinSendMsg(handle, + LM_QUERYITEMCOUNT,0L, 0L); +} + +/* + * Sets the topmost item in the viewport. + * Parameters: + * handle: Handle to the listbox to be cleared. + * top: Index to the top item. + */ +void dw_listbox_set_top(HWND handle, int top) +{ + WinSendMsg(handle, + LM_SETTOPINDEX, + MPFROMSHORT(top), + 0L); +} + +/* + * Copies the given index item's text into buffer. + * Parameters: + * handle: Handle to the listbox to be queried. + * index: Index into the list to be queried. + * buffer: Buffer where text will be copied. + * length: Length of the buffer (including NULL). + */ +void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length) +{ + WinSendMsg(handle, LM_QUERYITEMTEXT, MPFROM2SHORT(index, length), (MPARAM)buffer); +} + +/* + * Sets the text of a given listbox entry. + * Parameters: + * handle: Handle to the listbox to be queried. + * index: Index into the list to be queried. + * buffer: Buffer where text will be copied. + */ +void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) +{ + WinSendMsg(handle, LM_SETITEMTEXT, MPFROMSHORT(index), (MPARAM)buffer); +} + +/* + * Returns the index to the item in the list currently selected. + * Parameters: + * handle: Handle to the listbox to be queried. + */ +unsigned int dw_listbox_selected(HWND handle) +{ + return (unsigned int)WinSendMsg(handle, + LM_QUERYSELECTION, + MPFROMSHORT(LIT_CURSOR), + 0); +} + +/* + * Returns the index to the current selected item or -1 when done. + * Parameters: + * handle: Handle to the listbox to be queried. + * where: Either the previous return or -1 to restart. + */ +int dw_listbox_selected_multi(HWND handle, int where) +{ + int place = where; + + if(where == -1) + place = LIT_FIRST; + + place = (int)WinSendMsg(handle, + LM_QUERYSELECTION, + MPFROMSHORT(place),0L); + if(place == LIT_NONE) + return -1; + return place; +} + +/* + * Sets the selection state of a given index. + * Parameters: + * handle: Handle to the listbox to be set. + * index: Item index. + * state: TRUE if selected FALSE if unselected. + */ +void dw_listbox_select(HWND handle, int index, int state) +{ + WinSendMsg(handle, LM_SELECTITEM, MPFROMSHORT(index), (MPARAM)state); + _run_event(handle, WM_CONTROL, MPFROM2SHORT(0, LN_SELECT), (MPARAM)handle); +} + +/* + * Deletes the item with given index from the list. + * Parameters: + * handle: Handle to the listbox to be set. + * index: Item index. + */ +void dw_listbox_delete(HWND handle, int index) +{ + WinSendMsg(handle, LM_DELETEITEM, MPFROMSHORT(index), 0); +} + +/* + * Adds text to an MLE box and returns the current point. + * Parameters: + * handle: Handle to the MLE to be queried. + * buffer: Text buffer to be imported. + * startpoint: Point to start entering text. + */ +unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint) +{ + unsigned long point = startpoint; + PBYTE mlebuf; + + /* Work around 64K limit */ + if(!DosAllocMem((PPVOID) &mlebuf, 65536, PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_TILE)) + { + int amount, len = strlen(buffer), written = 0; + + while(written < len) + { + if((len - written) > 65535) + amount = 65535; + else + amount = len - written; + + memcpy(mlebuf, &buffer[written], amount); + mlebuf[amount] = '\0'; + + WinSendMsg(handle, MLM_SETIMPORTEXPORT, MPFROMP(mlebuf), MPFROMLONG(amount+1)); + WinSendMsg(handle, MLM_IMPORT, MPFROMP(&point), MPFROMLONG(amount + 1)); + dw_mle_delete(handle, point, 1); + + written += amount; + } + DosFreeMem(mlebuf); + } + return point - 1; +} + +/* + * Grabs text from an MLE box. + * Parameters: + * handle: Handle to the MLE to be queried. + * buffer: Text buffer to be exported. + * startpoint: Point to start grabbing text. + * length: Amount of text to be grabbed. + */ +void dw_mle_export(HWND handle, char *buffer, int startpoint, int length) +{ + PBYTE mlebuf; + + /* Work around 64K limit */ + if(!DosAllocMem((PPVOID) &mlebuf, 65535, PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_TILE)) + { + int amount, copied, written = 0; + + while(written < length) + { + if((length - written) > 65535) + amount = 65535; + else + amount = length - written; + + WinSendMsg(handle, MLM_SETIMPORTEXPORT, MPFROMP(mlebuf), MPFROMLONG(amount)); + copied = (int)WinSendMsg(handle, MLM_EXPORT, MPFROMP(&startpoint), MPFROMLONG(&amount)); + + if(copied) + { + memcpy(&buffer[written], mlebuf, copied); + + written += copied; + } + else + break; + } + DosFreeMem(mlebuf); + } +} + +/* + * Obtains information about an MLE box. + * Parameters: + * handle: Handle to the MLE to be queried. + * bytes: A pointer to a variable to return the total bytes. + * lines: A pointer to a variable to return the number of lines. + */ +void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines) +{ + if(bytes) + *bytes = (unsigned long)WinSendMsg(handle, MLM_QUERYTEXTLENGTH, 0, 0); + if(lines) + *lines = (unsigned long)WinSendMsg(handle, MLM_QUERYLINECOUNT, 0, 0); +} + +/* + * Deletes text from an MLE box. + * Parameters: + * handle: Handle to the MLE to be deleted from. + * startpoint: Point to start deleting text. + * length: Amount of text to be deleted. + */ +void dw_mle_delete(HWND handle, int startpoint, int length) +{ + char *buf = malloc(length+1); + int z, dellen = length; + + dw_mle_export(handle, buf, startpoint, length); + + for(z=0;z<length-1;z++) + { + if(strncmp(&buf[z], "\r\n", 2) == 0) + dellen--; + } + WinSendMsg(handle, MLM_DELETE, MPFROMLONG(startpoint), MPFROMLONG(dellen)); + free(buf); +} + +/* + * Clears all text from an MLE box. + * Parameters: + * handle: Handle to the MLE to be cleared. + */ +void dw_mle_clear(HWND handle) +{ + unsigned long bytes; + + dw_mle_query(handle, &bytes, NULL); + + WinSendMsg(handle, MLM_DELETE, MPFROMLONG(0), MPFROMLONG(bytes)); +} + +/* + * Sets the visible line of an MLE box. + * Parameters: + * handle: Handle to the MLE to be positioned. + * line: Line to be visible. + */ +void dw_mle_set_visible(HWND handle, int line) +{ + int tmppnt; + + if(line > 10) + { + tmppnt = (int)WinSendMsg(handle, MLM_CHARFROMLINE, MPFROMLONG(line - 10), 0); + WinSendMsg(handle, MLM_SETFIRSTCHAR, MPFROMLONG(tmppnt), 0); + } +} + +/* + * Sets the current cursor position of an MLE box. + * Parameters: + * handle: Handle to the MLE to be positioned. + * point: Point to position cursor. + */ +void dw_mle_set(HWND handle, int point) +{ + WinSendMsg(handle, MLM_SETSEL, MPFROMLONG(point), MPFROMLONG(point)); +} + +/* + * Finds text in an MLE box. + * Parameters: + * handle: Handle to the MLE to be cleared. + * text: Text to search for. + * point: Start point of search. + * flags: Search specific flags. + */ +int dw_mle_search(HWND handle, char *text, int point, unsigned long flags) +{ + MLE_SEARCHDATA msd; + + msd.cb = sizeof(msd); + msd.pchFind = text; + msd.pchReplace = NULL; + msd.cchFind = strlen(text); + msd.cchReplace = 0; + msd.iptStart = point; + msd.iptStop = -1; + + if(WinSendMsg(handle, MLM_SEARCH, MPFROMLONG(MLFSEARCH_SELECTMATCH | flags), (MPARAM)&msd)) + return (int)WinSendMsg(handle, MLM_QUERYSEL,(MPARAM)MLFQS_MAXSEL, 0); + return 0; +} + +/* + * Stops redrawing of an MLE box. + * Parameters: + * handle: Handle to the MLE to freeze. + */ +void dw_mle_freeze(HWND handle) +{ + WinSendMsg(handle, MLM_DISABLEREFRESH, 0, 0); +} + +/* + * Resumes redrawing of an MLE box. + * Parameters: + * handle: Handle to the MLE to thaw. + */ +void dw_mle_thaw(HWND handle) +{ + WinSendMsg(handle, MLM_ENABLEREFRESH, 0, 0); +} + +/* + * Returns the range of the slider. + * Parameters: + * handle: Handle to the slider to be queried. + */ +unsigned int dw_slider_query_range(HWND handle) +{ + return SHORT2FROMMP(WinSendMsg(handle, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), 0)); +} + +/* + * Sets the slider position. + * Parameters: + * handle: Handle to the slider to be set. + * position: Position of the slider withing the range. + */ +void dw_slider_set_pos(HWND handle, unsigned int position) +{ + WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)position); +} + +/* + * Sets the spinbutton value. + * Parameters: + * handle: Handle to the spinbutton to be set. + * position: Current value of the spinbutton. + */ +void dw_spinbutton_set_pos(HWND handle, long position) +{ + WinSendMsg(handle, SPBM_SETCURRENTVALUE, MPFROMLONG((long)position), 0L); +} + +/* + * Sets the spinbutton limits. + * Parameters: + * handle: Handle to the spinbutton to be set. + * upper: Upper limit. + * lower: Lower limit. + */ +void dw_spinbutton_set_limits(HWND handle, long upper, long lower) +{ + WinSendMsg(handle, SPBM_SETLIMITS, MPFROMLONG(upper), MPFROMLONG(lower)); +} + +/* + * Sets the entryfield character limit. + * Parameters: + * handle: Handle to the spinbutton to be set. + * limit: Number of characters the entryfield will take. + */ +void dw_entryfield_set_limit(HWND handle, ULONG limit) +{ + WinSendMsg(handle, EM_SETTEXTLIMIT, (MPARAM)limit, (MPARAM)0); +} + + +/* + * Returns the current value of the spinbutton. + * Parameters: + * handle: Handle to the spinbutton to be queried. + */ +long dw_spinbutton_query(HWND handle) +{ + long tmpval = 0L; + + WinSendMsg(handle, SPBM_QUERYVALUE, (MPARAM)&tmpval,0L); + return tmpval; +} + +/* + * Returns the state of the checkbox. + * Parameters: + * handle: Handle to the checkbox to be queried. + */ +int dw_checkbox_query(HWND handle) +{ + return (int)WinSendMsg(handle,BM_QUERYCHECK,0,0); +} + +/* + * Sets the state of the checkbox. + * Parameters: + * handle: Handle to the checkbox to be queried. + * value: TRUE for checked, FALSE for unchecked. + */ +void dw_checkbox_set(HWND handle, int value) +{ + WinSendMsg(handle,BM_SETCHECK,MPFROMSHORT(value),0); +} + +/* + * Sets up the container columns. + * Parameters: + * handle: Handle to the container to be configured. + * flags: An array of unsigned longs with column flags. + * titles: An array of strings with column text titles. + * count: The number of columns (this should match the arrays). + * separator: The column number that contains the main separator. + * (this item may only be used in OS/2) + */ +int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) +{ + PFIELDINFO details, first, left = NULL; + FIELDINFOINSERT detin; + CNRINFO cnri; + int z; + ULONG size = sizeof(RECORDCORE); + ULONG *offStruct = malloc(count * sizeof(ULONG)); + ULONG *tempflags = malloc((count+1) * sizeof(ULONG)); + ULONG *oldflags = (ULONG *)WinQueryWindowPtr(handle, 0); + + if(!offStruct || !tempflags) + return FALSE; + + memcpy(tempflags, flags, count * sizeof(ULONG)); + tempflags[count] = 0; + + WinSetWindowPtr(handle, 0, tempflags); + + if(oldflags) + free(oldflags); + + while((first = (PFIELDINFO)WinSendMsg(handle, CM_QUERYDETAILFIELDINFO, 0, MPFROMSHORT(CMA_FIRST))) != NULL) + { + WinSendMsg(handle, CM_REMOVEDETAILFIELDINFO, (MPARAM)&first, MPFROM2SHORT(1, CMA_FREE)); + } + + /* Figure out the offsets to the items in the struct */ + for(z=0;z<count;z++) + { + offStruct[z] = size; + if(flags[z] & DW_CFA_BITMAPORICON) + size += sizeof(HPOINTER); + else if(flags[z] & DW_CFA_STRING) + size += sizeof(char *); + else if(flags[z] & DW_CFA_ULONG) + size += sizeof(ULONG); + else if(flags[z] & DW_CFA_DATE) + size += sizeof(CDATE); + else if(flags[z] & DW_CFA_TIME) + size += sizeof(CTIME); + } + + first = details = (PFIELDINFO)WinSendMsg(handle, CM_ALLOCDETAILFIELDINFO, MPFROMLONG(count), 0L); + + if(!first) + { + free(offStruct); + return FALSE; + } + + for(z=0;z<count;z++) + { + if(z==separator-1) + left=details; + details->cb = sizeof(FIELDINFO); + details->flData = flags[z]; + details->flTitle = CFA_FITITLEREADONLY; + details->pTitleData = titles[z]; + details->offStruct = offStruct[z]; + details = details->pNextFieldInfo; + } + + detin.cb = sizeof(FIELDINFOINSERT); + detin.fInvalidateFieldInfo = FALSE; + detin.pFieldInfoOrder = (PFIELDINFO) CMA_FIRST; + detin.cFieldInfoInsert = (ULONG)count; + + WinSendMsg(handle, CM_INSERTDETAILFIELDINFO, MPFROMP(first), MPFROMP(&detin)); + + if(count > separator) + { + cnri.cb = sizeof(CNRINFO); + cnri.pFieldInfoLast = left; + cnri.xVertSplitbar = 150; + + WinSendMsg(handle, CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_PFIELDINFOLAST | CMA_XVERTSPLITBAR)); + } + + free(offStruct); + return TRUE; +} + +/* + * Sets up the filesystem columns, note: filesystem always has an icon/filename field. + * Parameters: + * handle: Handle to the container to be configured. + * flags: An array of unsigned longs with column flags. + * titles: An array of strings with column text titles. + * count: The number of columns (this should match the arrays). + */ +int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) +{ + char **newtitles = malloc(sizeof(char *) * (count + 2)); + unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); + + newtitles[0] = "Icon"; + newtitles[1] = "Filename"; + + newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR; + newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; + + memcpy(&newtitles[2], titles, sizeof(char *) * count); + memcpy(&newflags[2], flags, sizeof(unsigned long) * count); + + dw_container_setup(handle, newflags, newtitles, count + 2, 2); + + free(newtitles); + free(newflags); + return TRUE; +} + +/* + * Obtains an icon from a module (or header in GTK). + * Parameters: + * module: Handle to module (DLL) in OS/2 and Windows. + * id: A unsigned long id int the resources on OS/2 and + * Windows, on GTK this is converted to a pointer + * to an embedded XPM. + */ +unsigned long dw_icon_load(unsigned long module, unsigned long id) +{ + return WinLoadPointer(HWND_DESKTOP,module,id); +} + +/* + * Frees a loaded resource in OS/2 and Windows. + * Parameters: + * handle: Handle to icon returned by dw_icon_load(). + */ +void dw_icon_free(unsigned long handle) +{ + WinDestroyPointer(handle); +} + +/* + * Allocates memory used to populate a container. + * Parameters: + * handle: Handle to the container window (widget). + * rowcount: The number of items to be populated. + */ +void *dw_container_alloc(HWND handle, int rowcount) +{ + ULONG *flags = (ULONG *)WinQueryWindowPtr(handle, 0); + int z, size = 0, totalsize, count = 0; + PRECORDCORE temp; + void *blah; + + if(!flags) + return NULL; + + while(flags[count]) + count++; + + /* Figure out the offsets to the items in the struct */ + for(z=0;z<count;z++) + { + if(flags[z] & DW_CFA_BITMAPORICON) + size += sizeof(HPOINTER); + else if(flags[z] & DW_CFA_STRING) + size += sizeof(char *); + else if(flags[z] & DW_CFA_ULONG) + size += sizeof(ULONG); + else if(flags[z] & DW_CFA_DATE) + size += sizeof(CDATE); + else if(flags[z] & DW_CFA_TIME) + size += sizeof(CTIME); + } + + totalsize = size + sizeof(RECORDCORE); + + blah = (void *)WinSendMsg(handle, CM_ALLOCRECORD, MPFROMLONG(size), MPFROMLONG(rowcount)); + + if(!blah) + return NULL; + + temp = (PRECORDCORE)blah; + + for(z=0;z<rowcount;z++) + { + temp->cb = totalsize; + temp = temp->preccNextRecord; + } + + return blah; +} + +/* + * Sets an item in specified row and column to the given data. + * Parameters: + * handle: Handle to the container window (widget). + * pointer: Pointer to the allocated memory in dw_container_alloc(). + * column: Zero based column of data being set. + * row: Zero based row of data being set. + * data: Pointer to the data to be added. + */ +void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) +{ + ULONG totalsize, size = 0, *flags = (ULONG *)WinQueryWindowPtr(handle, 0); + int z; + PRECORDCORE temp = (PRECORDCORE)pointer; + void *dest; + + if(!flags) + return; + + /* Figure out the offsets to the items in the struct */ + for(z=0;z<column;z++) + { + if(flags[z] & DW_CFA_BITMAPORICON) + size += sizeof(HPOINTER); + else if(flags[z] & DW_CFA_STRING) + size += sizeof(char *); + else if(flags[z] & DW_CFA_ULONG) + size += sizeof(ULONG); + else if(flags[z] & DW_CFA_DATE) + size += sizeof(CDATE); + else if(flags[z] & DW_CFA_TIME) + size += sizeof(CTIME); + } + + totalsize = size + sizeof(RECORDCORE); + + for(z=0;z<row;z++) + temp = temp->preccNextRecord; + + dest = (void *)(((ULONG)temp)+((ULONG)totalsize)); + + if(flags[column] & DW_CFA_BITMAPORICON) + memcpy(dest, data, sizeof(HPOINTER)); + else if(flags[column] & DW_CFA_STRING) + memcpy(dest, data, sizeof(char *)); + else if(flags[column] & DW_CFA_ULONG) + memcpy(dest, data, sizeof(ULONG)); + else if(flags[column] & DW_CFA_DATE) + memcpy(dest, data, sizeof(CDATE)); + else if(flags[column] & DW_CFA_TIME) + memcpy(dest, data, sizeof(CTIME)); +} + +/* + * Sets an item in specified row and column to the given data. + * Parameters: + * handle: Handle to the container window (widget). + * pointer: Pointer to the allocated memory in dw_container_alloc(). + * column: Zero based column of data being set. + * row: Zero based row of data being set. + * data: Pointer to the data to be added. + */ +void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) +{ + dw_container_set_item(handle, pointer, 0, row, (void *)&icon); + dw_container_set_item(handle, pointer, 1, row, (void *)&filename); +} + +/* + * Sets an item in specified row and column to the given data. + * Parameters: + * handle: Handle to the container window (widget). + * pointer: Pointer to the allocated memory in dw_container_alloc(). + * column: Zero based column of data being set. + * row: Zero based row of data being set. + * data: Pointer to the data to be added. + */ +void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) +{ + dw_container_set_item(handle, pointer, column + 2, row, data); +} + +/* + * Sets the title of a row in the container. + * Parameters: + * pointer: Pointer to the allocated memory in dw_container_alloc(). + * row: Zero based row of data being set. + * title: String title of the item. + */ +void dw_container_set_row_title(void *pointer, int row, char *title) +{ + PRECORDCORE temp = (PRECORDCORE)pointer; + int z; + + for(z=0;z<row;z++) + temp = temp->preccNextRecord; + + temp->pszIcon = title; + temp->pszName = title; + temp->pszText = title; +} + +/* + * Sets the title of a row in the container. + * Parameters: + * handle: Handle to the container window (widget). + * pointer: Pointer to the allocated memory in dw_container_alloc(). + * rowcount: The number of rows to be inserted. + */ +void dw_container_insert(HWND handle, void *pointer, int rowcount) +{ + RECORDINSERT recin; + + recin.cb = sizeof(RECORDINSERT); + recin.pRecordOrder = (PRECORDCORE)CMA_END; + recin.pRecordParent = NULL; + recin.zOrder = CMA_TOP; + recin.fInvalidateRecord = TRUE; + recin.cRecordsInsert = rowcount; + + WinSendMsg(handle, CM_INSERTRECORD, MPFROMP(pointer), MPFROMP(&recin)); +} + +/* + * Removes all rows from a container. + * Parameters: + * handle: Handle to the window (widget) to be cleared. + */ +void dw_container_clear(HWND handle) +{ + WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)0L, MPFROM2SHORT(0, CMA_INVALIDATE | CMA_FREE)); +} + +/* + * Removes all rows from a container. + * Parameters: + * handle: Handle to the window (widget) to be cleared. + */ +void dw_container_set_view(HWND handle, unsigned long flags, int iconwidth, int iconheight) +{ + CNRINFO cnrinfo; + + cnrinfo.flWindowAttr = flags; + cnrinfo.slBitmapOrIcon.cx = iconwidth; + cnrinfo.slBitmapOrIcon.cy = iconheight; + + WinSendMsg(handle, CM_SETCNRINFO, &cnrinfo, MPFROMLONG(CMA_FLWINDOWATTR | CMA_SLBITMAPORICON)); +} + +/* + * Starts a new query of a container. + * Parameters: + * handle: Handle to the window (widget) to be queried. + * flags: If this parameter is DW_CRA_SELECTED it will only + * return items that are currently selected. Otherwise + * it will return all records in the container. + */ +char *dw_container_query_start(HWND handle, unsigned long flags) +{ + pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); + if(pCore) + { + if(flags) + { + while(pCore) + { + if(pCore->flRecordAttr & CRA_SELECTED) + return pCore->pszIcon; + pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); + } + } + else + return pCore->pszIcon; + } + return NULL; +} + +/* + * Continues an existing query of a container. + * Parameters: + * handle: Handle to the window (widget) to be queried. + * flags: If this parameter is DW_CRA_SELECTED it will only + * return items that are currently selected. Otherwise + * it will return all records in the container. + */ +char *dw_container_query_next(HWND handle, unsigned long flags) +{ + pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); + if(pCore) + { + if(flags) + { + while(pCore) + { + if(pCore->flRecordAttr & CRA_SELECTED) + return pCore->pszIcon; + + pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); + } + } + else + return pCore->pszIcon; + } + return NULL; +} + +/* + * Creates a rendering context widget (window) to be packed. + * Parameters: + * id: An id to be used with dw_window_from_id. + * Returns: + * A handle to the widget or NULL on failure. + */ +HWND dw_render_new(unsigned long id) +{ + HWND hwndframe = WinCreateWindow(HWND_OBJECT, + WC_FRAME, + NULL, + WS_VISIBLE, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + id, + NULL, + NULL); + WinSubclassWindow(hwndframe, _RendProc); + return hwndframe; +} + +/* Sets the current foreground drawing color. + * Parameters: + * red: red value. + * green: green value. + * blue: blue value. + */ +void dw_color_foreground_set(unsigned long value) +{ + _foreground = DW_RED_VALUE(value) << 16 | DW_GREEN_VALUE(value) << 8 | DW_BLUE_VALUE(value); +} + +/* Sets the current background drawing color. + * Parameters: + * red: red value. + * green: green value. + * blue: blue value. + */ +void dw_color_background_set(unsigned long value) +{ + _background = DW_RED_VALUE(value) << 16 | DW_GREEN_VALUE(value) << 8 | DW_BLUE_VALUE(value); +} + +HPS _set_hps(HPS hps) +{ + LONG alTable[18]; + + GpiQueryLogColorTable(hps, 0L, 0L, 18L, alTable); + + alTable[16] = _foreground; + alTable[17] = _background; + + GpiCreateLogColorTable(hps, + 0L, + LCOLF_CONSECRGB, + 0L, + 18, + alTable); + GpiSetColor(hps, 16); + GpiSetBackColor(hps, 17); + return hps; +} + +HPS _set_colors(HWND handle) +{ + HPS hps = WinGetPS(handle); + + _set_hps(hps); + return hps; +} + +/* Draw a point on a window (preferably a render window). + * Parameters: + * handle: Handle to the window. + * pixmap: Handle to the pixmap. (choose only one of these) + * x: X coordinate. + * y: Y coordinate. + */ +void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) +{ + HPS hps; + int height; + POINTL ptl; + + if(handle) + { + hps = _set_colors(handle); + height = _get_height(handle); + } + else if(pixmap) + { + hps = _set_hps(pixmap->hps); + height = pixmap->height; + } + else + return; + + ptl.x = x; + ptl.y = height - y - 1; + + GpiSetPel(hps, &ptl); + if(!pixmap) + WinReleasePS(hps); +} + +/* Draw a line on a window (preferably a render window). + * Parameters: + * handle: Handle to the window. + * pixmap: Handle to the pixmap. (choose only one of these) + * x1: First X coordinate. + * y1: First Y coordinate. + * x2: Second X coordinate. + * y2: Second Y coordinate. + */ +void dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) +{ + HPS hps; + int height; + POINTL ptl[2]; + + if(handle) + { + hps = _set_colors(handle); + height = _get_height(handle); + } + else if(pixmap) + { + hps = _set_hps(pixmap->hps); + height = pixmap->height; + } + else + return; + + ptl[0].x = x1; + ptl[0].y = height - y1 - 1; + ptl[1].x = x2; + ptl[1].y = height - y2 - 1; + + GpiMove(hps, &ptl[0]); + GpiLine(hps, &ptl[1]); + + if(!pixmap) + WinReleasePS(hps); +} + + +/* Draw text on a window (preferably a render window). + * Parameters: + * handle: Handle to the window. + * pixmap: Handle to the pixmap. (choose only one of these) + * x: X coordinate. + * y: Y coordinate. + * text: Text to be displayed. + */ +void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) +{ + HPS hps; + int size = 9, z, l, height; + POINTL ptl; + FATTRS fat; + SIZEF sizfCharBox; + FONTMETRICS *fm; + LONG lHorzRes, lVertRes, lRequestFonts, lNumberFonts; + HDC hdc; + char fontname[128]; + + if(handle) + { + hps = _set_colors(handle); + height = _get_height(handle); + _GetPPFont(handle, fontname); + } + else if(pixmap) + { + hps = _set_hps(pixmap->hps); + height = pixmap->height; + _GetPPFont(pixmap->handle, fontname); + } + else + return; + + ptl.x = x; + ptl.y = height - y - 2; + + for(z=0;z<strlen(fontname);z++) + { + if(fontname[z]=='.') + break; + } + size = atoi(fontname); + + ptl.y -= size; + + hdc = GpiQueryDevice(hps); + + DevQueryCaps(hdc, CAPS_HORIZONTAL_FONT_RES, 1L, &lHorzRes); + DevQueryCaps(hdc, CAPS_VERTICAL_FONT_RES, 1L, &lVertRes); + + lNumberFonts = GpiQueryFonts(hps, QF_PUBLIC | QF_PRIVATE, &fontname[z+1], &lRequestFonts, 0, NULL); + + fm = malloc(lNumberFonts * sizeof(FONTMETRICS)); + + GpiQueryFonts(hps, QF_PUBLIC | QF_PRIVATE, &fontname[z+1], &lNumberFonts, sizeof(FONTMETRICS), fm); + + fat.lMatch = 0L; + + for(l=0;l<lNumberFonts;l++) + { + if(fm[l].sXDeviceRes == (SHORT)lHorzRes && + fm[l].sYDeviceRes == (SHORT)lVertRes && + (fm[l].fsDefn & 1) == 0 && + fm[l].sNominalPointSize == (size*10)) + { + fat.lMatch = fm[l].lMatch; + break; + } + } + + fat.usRecordLength = sizeof(FATTRS); + fat.fsSelection = 0; + fat.idRegistry = 0; + fat.usCodePage = GpiQueryCp(hps); + fat.lMaxBaselineExt = 0; + fat.lAveCharWidth = 0; + fat.fsType = 0; + fat.fsFontUse = 0; + + strcpy(fat.szFacename , &fontname[z+1]); + + GpiCreateLogFont(hps, NULL, 1L, &fat); + + GpiSetCharSet(hps, 1L); + + if(fm) + free(fm); + else + { + sizfCharBox.cx = MAKEFIXED(size,0); + sizfCharBox.cy = MAKEFIXED(size,0); + GpiSetCharBox(hps, &sizfCharBox); + } + + GpiCharStringAt(hps, &ptl, strlen(text), text); + + if(!pixmap) + WinReleasePS(hps); +} + + + + +/* Draw a rectangle on a window (preferably a render window). + * Parameters: + * handle: Handle to the window. + * pixmap: Handle to the pixmap. (choose only one of these) + * fill: Fill box TRUE or FALSE. + * x: X coordinate. + * y: Y coordinate. + * width: Width of rectangle. + * height: Height of rectangle. + */ +void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) +{ + HPS hps; + int thisheight; + POINTL ptl[2]; + + if(handle) + { + hps = _set_colors(handle); + thisheight = _get_height(handle); + } + else if(pixmap) + { + hps = _set_hps(pixmap->hps); + thisheight = pixmap->height; + } + else + return; + + ptl[0].x = x; + ptl[0].y = thisheight - y - 1; + ptl[1].x = x + width - 1; + ptl[1].y = thisheight - y - height; + + GpiMove(hps, &ptl[0]); + GpiBox(hps, fill ? DRO_OUTLINEFILL : DRO_OUTLINE, &ptl[1], 0, 0); + + if(!pixmap) + WinReleasePS(hps); +} + +/* Call this after drawing to the screen to make sure + * anything you have drawn is visible. + */ +void dw_flush(void) +{ +} + +/* + * Creates a pixmap with given parameters. + * Parameters: + * handle: Window handle the pixmap is associated with. + * width: Width of the pixmap in pixels. + * height: Height of the pixmap in pixels. + * depth: Color depth of the pixmap. + * Returns: + * A handle to a pixmap or NULL on failure. + */ +HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) +{ + BITMAPINFOHEADER bmih; + SIZEL sizl = { 0, 0 }; + HPIXMAP pixmap; + HDC hdc; + HPS hps; + ULONG ulFlags; + LONG cPlanes, cBitCount; + + if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) + return NULL; + + hps = WinGetPS(handle); + + hdc = GpiQueryDevice(hps); + ulFlags = GpiQueryPS(hps, &sizl); + + pixmap->handle = handle; + pixmap->hdc = DevOpenDC(dwhab, OD_MEMORY, "*", 0L, NULL, hdc); + pixmap->hps = GpiCreatePS (dwhab, pixmap->hdc, &sizl, ulFlags | GPIA_ASSOC); + + DevQueryCaps(hdc, CAPS_COLOR_PLANES , 1L, &cPlanes); + if (!depth) + { + DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1L, &cBitCount); + depth = cBitCount; + } + + memset(&bmih, 0, sizeof(BITMAPINFOHEADER)); + bmih.cbFix = sizeof(BITMAPINFOHEADER); + bmih.cx = (SHORT)width; + bmih.cy = (SHORT)height; + bmih.cPlanes = (SHORT)cPlanes; + bmih.cBitCount = (SHORT)depth; + + pixmap->width = width; pixmap->height = height; + + pixmap->hbm = GpiCreateBitmap(pixmap->hps, (PBITMAPINFOHEADER2)&bmih, 0L, NULL, NULL); + + GpiSetBitmap(pixmap->hps, pixmap->hbm); + + if (depth>8) + GpiCreateLogColorTable(pixmap->hps, LCOL_PURECOLOR, LCOLF_RGB, 0, 0, NULL ); + + WinReleasePS(hps); + + return pixmap; +} + +/* + * Creates a pixmap from internal resource graphic specified by id. + * Parameters: + * handle: Window handle the pixmap is associated with. + * id: Resource ID associated with requested pixmap. + * Returns: + * A handle to a pixmap or NULL on failure. + */ +HPIXMAP dw_pixmap_grab(HWND handle, ULONG id) +{ + BITMAPINFOHEADER bmih; + SIZEL sizl = { 0, 0 }; + HPIXMAP pixmap; + HDC hdc; + HPS hps; + ULONG ulFlags; + + if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) + return NULL; + + hps = WinGetPS(handle); + + hdc = GpiQueryDevice(hps); + ulFlags = GpiQueryPS(hps, &sizl); + + pixmap->hdc = DevOpenDC(dwhab, OD_MEMORY, "*", 0L, NULL, hdc); + pixmap->hps = GpiCreatePS (dwhab, pixmap->hdc, &sizl, ulFlags | GPIA_ASSOC); + + pixmap->hbm = GpiLoadBitmap(pixmap->hps, NULLHANDLE, id, 0, 0); + + GpiQueryBitmapParameters(pixmap->hbm, &bmih); + + GpiSetBitmap(pixmap->hps, pixmap->hbm); + + pixmap->width = bmih.cx; pixmap->height = bmih.cy; + + WinReleasePS(hps); + + return pixmap; +} + +/* + * Destroys an allocated pixmap. + * Parameters: + * pixmap: Handle to a pixmap returned by + * dw_pixmap_new.. + */ +void dw_pixmap_destroy(HPIXMAP pixmap) +{ + GpiSetBitmap(pixmap->hps, NULLHANDLE); + GpiDeleteBitmap(pixmap->hbm); + GpiAssociate(pixmap->hps, NULLHANDLE); + GpiDestroyPS(pixmap->hps); + DevCloseDC(pixmap->hdc); + free(pixmap); +} + +/* + * Copies from one item to another. + * Parameters: + * dest: Destination window handle. + * destp: Destination pixmap. (choose only one). + * xdest: X coordinate of destination. + * ydest: Y coordinate of destination. + * width: Width of area to copy. + * height: Height of area to copy. + * src: Source window handle. + * srcp: Source pixmap. (choose only one). + * xsrc: X coordinate of source. + * ysrc: Y coordinate of source. + */ +void dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) +{ + HPS hpsdest; + HPS hpssrc; + POINTL ptl[4]; + int destheight, srcheight; + + if(dest) + { + hpsdest = WinGetPS(dest); + destheight = _get_height(dest); + } + else if(destp) + { + hpsdest = destp->hps; + destheight = destp->height; + } + else + return; + + if(src) + { + hpssrc = WinGetPS(src); + srcheight = _get_height(src); + } + else if(srcp) + { + hpssrc = srcp->hps; + srcheight = srcp->height; + } + else + { + if(!destp) + WinReleasePS(hpsdest); + return; + } + + ptl[0].x = xdest; + ptl[0].y = (destheight - ydest) - height; + ptl[1].x = ptl[0].x + width; + ptl[1].y = destheight - ydest; + ptl[2].x = xsrc; + ptl[2].y = srcheight - (ysrc + height); + ptl[3].x = ptl[2].x + width; + ptl[3].y = ptl[2].y + height; + + GpiBitBlt(hpsdest, hpssrc, 4, ptl, ROP_SRCCOPY, BBO_IGNORE); + + if(!destp) + WinReleasePS(hpsdest); + if(!srcp) + WinReleasePS(hpssrc); +} + +/* + * Emits a beep. + * Parameters: + * freq: Frequency. + * dur: Duration. + */ +void dw_beep(int freq, int dur) +{ + DosBeep(freq, dur); +} + +/* + * Returns the handle to an unnamed mutex semaphore. + */ +HMTX dw_mutex_new(void) +{ + HMTX mutex; + + DosCreateMutexSem(NULL, &mutex, 0, FALSE); + return mutex; +} + +/* + * Closes a semaphore created by dw_mutex_new(). + * Parameters: + * mutex: The handle to the mutex returned by dw_mutex_new(). + */ +void dw_mutex_close(HMTX mutex) +{ + DosCloseMutexSem(mutex); +} + +/* + * Tries to gain access to the semaphore, if it can't it blocks. + * Parameters: + * mutex: The handle to the mutex returned by dw_mutex_new(). + */ +void dw_mutex_lock(HMTX mutex) +{ + DosRequestMutexSem(mutex, SEM_INDEFINITE_WAIT); +} + +/* + * Reliquishes the access to the semaphore. + * Parameters: + * mutex: The handle to the mutex returned by dw_mutex_new(). + */ +void dw_mutex_unlock(HMTX mutex) +{ + DosReleaseMutexSem(mutex); +} + +/* + * Returns the handle to an unnamed event semaphore. + */ +HEV dw_event_new(void) +{ + HEV blah; + + if(DosCreateEventSem (NULL, &blah, 0L, FALSE)) + return 0; + + return blah; +} + +/* + * Resets a semaphore created by dw_event_new(). + * Parameters: + * eve: The handle to the event returned by dw_event_new(). + */ +int dw_event_reset(HEV eve) +{ + ULONG count; + + if(DosResetEventSem(eve, &count)) + return FALSE; + return TRUE; +} + +/* + * Posts a semaphore created by dw_event_new(). Causing all threads + * waiting on this event in dw_event_wait to continue. + * Parameters: + * eve: The handle to the event returned by dw_event_new(). + */ +int dw_event_post(HEV eve) +{ + if(DosPostEventSem(eve)) + return FALSE; + return TRUE; +} + + +/* + * Waits on a semaphore created by dw_event_new(), until the + * event gets posted or until the timeout expires. + * Parameters: + * eve: The handle to the event returned by dw_event_new(). + */ +int dw_event_wait(HEV eve, unsigned long timeout) +{ + int rc = DosWaitEventSem(eve, timeout); + if(!rc) + return 1; + if(rc == ERROR_TIMEOUT) + return -1; + return 0; +} + +/* + * Closes a semaphore created by dw_event_new(). + * Parameters: + * eve: The handle to the event returned by dw_event_new(). + */ +int dw_event_close(HEV *eve) +{ + if(!eve || ~DosCloseEventSem(*eve)) + return FALSE; + return TRUE; +} + +/* + * Encapsulate the message queues on OS/2. + */ +void _dwthreadstart(void *data) +{ + HAB thishab = WinInitialize(0); + HMQ thishmq = WinCreateMsgQueue(dwhab, 0); + void (*threadfunc)(void *) = NULL; + void **tmp = (void **)data; + + threadfunc = (void (*)(void *))tmp[0]; + threadfunc(tmp[1]); + + free(tmp); + + WinDestroyMsgQueue(thishmq); + WinTerminate(thishab); +} + +/* + * Creates a new thread with a starting point of func. + * Parameters: + * func: Function which will be run in the new thread. + * data: Parameter(s) passed to the function. + * stack: Stack size of new thread (OS/2 and Windows only). + */ +DWTID dw_thread_new(void *func, void *data, int stack) +{ + void **tmp = malloc(sizeof(void *) * 2); + + tmp[0] = func; + tmp[1] = data; + + return (DWTID)_beginthread((void (*)(void *))_dwthreadstart, NULL, stack, (void *)tmp); +} + +/* + * Ends execution of current thread immediately. + */ +void dw_thread_end(void) +{ + _endthread(); +} + +/* + * Returns the current thread's ID. + */ +DWTID dw_thread_id(void) +{ + return (DWTID)_threadid; +} + +/* + * Cleanly terminates a DW session, should be signal handler safe. + * Parameters: + * exitcode: Exit code reported to the operating system. + */ +void dw_exit(int exitcode) +{ + /* In case we are in a signal handler, don't + * try to free memory that could possibly be + * free()'d by the runtime already. + */ +#ifndef NO_SIGNALS + Root = NULL; +#endif + exit(exitcode); +} + +/* + * Pack a splitbar (sizer) into the specified box from the start. + * Parameters: + * box: Window handle of the box to be packed into. + */ +void dw_box_pack_splitbar_start(HWND box) +{ + Box *thisbox; + + if(WinWindowFromID(box, FID_CLIENT)) + { + box = WinWindowFromID(box, FID_CLIENT); + thisbox = WinQueryWindowPtr(box, QWP_USER); + } + else + thisbox = WinQueryWindowPtr(box, QWP_USER); + if(thisbox) + { + HWND tmp = WinCreateWindow(HWND_OBJECT, + SplitbarClassName, + NULL, + WS_VISIBLE, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + 0L, + NULL, + NULL); + if(thisbox->type == BOXVERT) + dw_box_pack_start(box, tmp, 1, SPLITBAR_WIDTH, TRUE, FALSE, 0); + else + dw_box_pack_start(box, tmp, SPLITBAR_WIDTH, 1, FALSE, TRUE, 0); + + } +} + +/* + * Pack a splitbar (sizer) into the specified box from the end. + * Parameters: + * box: Window handle of the box to be packed into. + */ +void dw_box_pack_splitbar_end(HWND box) +{ + Box *thisbox; + + if(WinWindowFromID(box, FID_CLIENT)) + { + box = WinWindowFromID(box, FID_CLIENT); + thisbox = WinQueryWindowPtr(box, QWP_USER); + } + else + thisbox = WinQueryWindowPtr(box, QWP_USER); + if(thisbox) + { + HWND tmp = WinCreateWindow(HWND_OBJECT, + SplitbarClassName, + NULL, + WS_VISIBLE, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + 0L, + NULL, + NULL); + if(thisbox->type == BOXVERT) + dw_box_pack_end(box, tmp, 1, SPLITBAR_WIDTH, TRUE, FALSE, 0); + else + dw_box_pack_end(box, tmp, SPLITBAR_WIDTH, 1, FALSE, TRUE, 0); + + } +} + +/* + * Pack windows (widgets) into a box from the start (or top). + * Parameters: + * box: Window handle of the box to be packed into. + * item: Window handle of the item to be back. + * width: Width in pixels of the item or -1 to be self determined. + * height: Height in pixels of the item or -1 to be self determined. + * hsize: TRUE if the window (widget) should expand horizontally to fill space given. + * vsize: TRUE if the window (widget) should expand vertically to fill space given. + * pad: Number of pixels of padding around the item. + */ +void dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) +{ + Box *thisbox; + + if(WinWindowFromID(box, FID_CLIENT)) + { + box = WinWindowFromID(box, FID_CLIENT); + thisbox = WinQueryWindowPtr(box, QWP_USER); + } + else + thisbox = WinQueryWindowPtr(box, QWP_USER); + if(thisbox) + { + if(thisbox->type == BOXHORZ) + dw_box_pack_end_stub(box, item, width, height, hsize, vsize, pad); + else + dw_box_pack_start_stub(box, item, width, height, hsize, vsize, pad); + } +} + +void dw_box_pack_start_stub(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) +{ + HWND boxowner = NULLHANDLE; + Box *thisbox; + + if(WinWindowFromID(box, FID_CLIENT)) + { + box = WinWindowFromID(box, FID_CLIENT); + thisbox = WinQueryWindowPtr(box, QWP_USER); + hsize = TRUE; + vsize = TRUE; + } + else + thisbox = WinQueryWindowPtr(box, QWP_USER); + if(thisbox) + { + int z; + Item *tmpitem, *thisitem = thisbox->items; + char tmpbuf[100]; + + tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); + + for(z=0;z<thisbox->count;z++) + { + tmpitem[z+1] = thisitem[z]; + } + + WinQueryClassName(item, 99, tmpbuf); + + if(strncmp(tmpbuf, "#1", 2)==0) + tmpitem[0].type = TYPEBOX; + else + tmpitem[0].type = TYPEITEM; + + tmpitem[0].hwnd = item; + tmpitem[0].origwidth = tmpitem[0].width = width; + tmpitem[0].origheight = tmpitem[0].height = height; + tmpitem[0].pad = pad; + if(hsize) + tmpitem[0].hsize = SIZEEXPAND; + else + tmpitem[0].hsize = SIZESTATIC; + + if(vsize) + tmpitem[0].vsize = SIZEEXPAND; + else + tmpitem[0].vsize = SIZESTATIC; + + thisbox->items = tmpitem; + + if(thisbox->count) + free(thisitem); + + thisbox->count++; + + WinQueryClassName(item, 99, tmpbuf); + /* Don't set the ownership if it's an entryfield or combobox */ + if(strncmp(tmpbuf, "#6", 2)!=0 /*&& strncmp(tmpbuf, "#2", 2)!=0*/) + { + if((boxowner = WinQueryWindow(box, QW_OWNER)) != 0) + WinSetOwner(item, boxowner); + else + WinSetOwner(item, box); + } + WinSetParent(item, box, FALSE); + } +} + +/* The following two functions graciously contributed by Peter Nielsen. */ +static ULONG _ParseBuildLevel (char* pchBuffer, ULONG ulSize) { + char* pchStart = pchBuffer; + char* pchEnd = pchStart + ulSize - 2; + + while (pchEnd >= pchStart) + { + if ((pchEnd[0] == '#') && (pchEnd[1] == '@')) + { + *pchEnd-- = '\0'; + while (pchEnd >= pchStart) + { + if ((pchEnd[0] == '@') && (pchEnd[1] == '#')) + { + ULONG ulMajor = 0; + ULONG ulMinor = 0; + + char* pch = pchEnd + 2; + while (!isdigit (*pch) && *pch) + pch++; + + while (isdigit (*pch)) + ulMajor = ulMajor * 10 + *pch++ - '0'; + + if (*pch == '.') + { + while (isdigit (*++pch)) + ulMinor = ulMinor * 10 + *pch - '0'; + } + return ((ulMajor << 16) | ulMinor); + } + pchEnd--; + } + } + pchEnd--; + } + return (0); +} + +ULONG _GetSystemBuildLevel(void) { + /* The build level info is normally available in the end of the OS2KRNL file. However, this is not the case in some beta versions of OS/2. + * We first try to find the info in the 256 last bytes of the file. If that fails, we load the entire file and search it completely. + */ + ULONG ulBootDrive = 0; + ULONG ulBuild = 0; + if (DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive, sizeof (ulBootDrive)) == NO_ERROR) + { + char achFileName[11] = { (char)('A'+ulBootDrive-1),':','\\','O','S','2','K','R','N','L','\0' }; + HFILE hfile; + ULONG ulResult; + if (DosOpen (achFileName, &hfile, &ulResult, 0, 0, OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL) == NO_ERROR) + { + ULONG ulFileSize = 0; + if (DosSetFilePtr (hfile, 0, FILE_END, &ulFileSize) == NO_ERROR) + { + const ULONG ulFirstTry = min (256, ulFileSize); + if (DosSetFilePtr (hfile, -(LONG)ulFirstTry, FILE_END, &ulResult) == NO_ERROR) + { + char *pchBuffer = malloc(ulFirstTry); + if (DosRead (hfile, pchBuffer, ulFirstTry, &ulResult) == NO_ERROR) + { + ulBuild = _ParseBuildLevel (pchBuffer, ulFirstTry); + if (ulBuild == 0) + { + if (DosSetFilePtr (hfile, 0, FILE_BEGIN, &ulResult) == NO_ERROR) + { + free(pchBuffer); + pchBuffer = malloc(ulFileSize); + + if (DosRead (hfile, pchBuffer, ulFileSize, &ulResult) == NO_ERROR) + ulBuild = _ParseBuildLevel (pchBuffer, ulFileSize); + } + } + } + free(pchBuffer); + } + } + DosClose (hfile); + } + } + return (ulBuild); +} + + +/* + * Returns some information about the current operating environment. + * Parameters: + * env: Pointer to a DWEnv struct. + */ +void dw_environment_query(DWEnv *env) +{ + ULONG aulBuffer[4]; + ULONG Build; + + if(!env) + return; + + /* Get the OS/2 version. */ + + DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_MS_COUNT,(void *)aulBuffer, 4*sizeof(ULONG)); + + /* The default is OS/2 2.0 */ + strcpy(env->osName,"OS/2"); + env->MajorVersion = 2; + env->MinorVersion = 0; + + Build = _GetSystemBuildLevel(); + env->MinorBuild = Build & 0xFFFF; + env->MajorBuild = Build >> 16; + + if (aulBuffer[0] == 20) + { + int i = (unsigned int)aulBuffer[1]; + if (i > 20) + { + strcpy(env->osName,"Warp"); + env->MajorVersion = (int)i/10; + env->MinorVersion = i-(((int)i/10)*10); + } + else if (i == 10) + env->MinorVersion = 1; + } +} + +/* + * Opens a file dialog and queries user selection. + * Parameters: + * title: Title bar text for dialog. + * defpath: The default path of the open dialog. + * ext: Default file extention. + * flags: DW_FILE_OPEN or DW_FILE_SAVE. + * Returns: + * NULL on error. A malloced buffer containing + * the file path on success. + * + */ +char *dw_file_browse(char *title, char *defpath, char *ext, int flags) +{ + FILEDLG fild; + HWND hwndFile; + int len; + + if(defpath) + strcpy(fild.szFullFile, defpath); + else + strcpy(fild.szFullFile, ""); + + len = strlen(fild.szFullFile); + + if(len) + { + if(fild.szFullFile[len-1] != '\\') + strcat(fild.szFullFile, "\\"); + } + strcat(fild.szFullFile, "*"); + + if(ext) + { + strcat(fild.szFullFile, "."); + strcat(fild.szFullFile, ext); + } + + fild.cbSize = sizeof(FILEDLG); + fild.fl = /*FDS_HELPBUTTON |*/ FDS_CENTER | FDS_OPEN_DIALOG; + fild.pszTitle = title; + fild.pszOKButton = ((flags & DW_FILE_SAVE) ? "Save" : "Open"); + fild.ulUser = 0L; + fild.pfnDlgProc = (PFNWP)WinDefFileDlgProc; + fild.lReturn = 0L; + fild.lSRC = 0L; + fild.hMod = 0; + fild.x = 0; + fild.y = 0; + fild.pszIType = (PSZ)NULL; + fild.papszITypeList = (PAPSZ)NULL; + fild.pszIDrive = (PSZ)NULL; + fild.papszIDriveList= (PAPSZ)NULL; + fild.sEAType = (SHORT)0; + fild.papszFQFilename= (PAPSZ)NULL; + fild.ulFQFCount = 0L; + + hwndFile = WinFileDlg(HWND_DESKTOP, HWND_DESKTOP, &fild); + if(hwndFile) + { + switch(fild.lReturn) + { + case DID_OK: + return strdup(fild.szFullFile); + case DID_CANCEL: + return NULL; + } + } + return NULL; +} + +/* + * Execute and external program in a seperate session. + * Parameters: + * program: Program name with optional path. + * type: Either DW_EXEC_CON or DW_EXEC_GUI. + * params: An array of pointers to string arguements. + * Returns: + * -1 on error. + */ +int dw_exec(char *program, int type, char **params) +{ + return spawnvp(P_NOWAIT, program, params); +} + +/* + * Loads a web browser pointed at the given URL. + * Parameters: + * url: Uniform resource locator. + */ +int dw_browse(char *url) +{ + /* Is there a way to find the webbrowser in Unix? */ + char *execargs[3], browser[1024]; + + PrfQueryProfileString(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS", + "DefaultBrowserExe", NULL, browser, 1024); + + execargs[0] = browser; + execargs[1] = url; + execargs[2] = NULL; + + return dw_exec(browser, DW_EXEC_GUI, execargs); +} + +/* + * Returns a pointer to a static buffer which containes the + * current user directory. Or the root directory (C:\ on + * OS/2 and Windows). + */ +char *dw_user_dir(void) +{ + static char _user_dir[1024] = ""; + + if(!_user_dir[0]) + { + char *home = getenv("HOME"); + + if(home) + strcpy(_user_dir, home); + else + strcpy(_user_dir, "C:\\"); + } + return _user_dir; +} + +/* + * Call a function from the window (widget)'s context. + * Parameters: + * handle: Window handle of the widget. + * function: Function pointer to be called. + * data: Pointer to the data to be passed to the function. + */ +void dw_window_function(HWND handle, void *function, void *data) +{ + WinSendMsg(handle, WM_USER, (MPARAM)function, (MPARAM)data); +} + +#ifndef NO_SIGNALS +/* + * Add a callback to a window event. + * Parameters: + * window: Window handle of signal to be called back. + * signame: A string pointer identifying which signal to be hooked. + * sigfunc: The pointer to the function to be used as the callback. + * data: User data to be passed to the handler function. + */ +void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) +{ + ULONG message = 0L; + + if(window && signame && sigfunc) + { + if((message = _findsigmessage(signame)) != 0) + _new_signal(message, window, sigfunc, data); + } +} + +/* + * Removes callbacks for a given window with given name. + * Parameters: + * window: Window handle of callback to be removed. + */ +void dw_signal_disconnect_by_name(HWND window, char *signame) +{ + SignalHandler *prev = NULL, *tmp = Root; + ULONG message; + + if(!window || !signame || (message = _findsigmessage(signame)) == 0) + return; + + while(tmp) + { + if(tmp->window == window && tmp->message == message) + { + if(prev) + { + prev->next = tmp->next; + free(tmp); + tmp = prev->next; + } + else + { + Root = tmp->next; + free(tmp); + tmp = Root; + } + } + else + { + prev = tmp; + tmp = tmp->next; + } + } +} + +/* + * Removes all callbacks for a given window. + * Parameters: + * window: Window handle of callback to be removed. + */ +void dw_signal_disconnect_by_window(HWND window) +{ + SignalHandler *prev = NULL, *tmp = Root; + + while(tmp) + { + if(tmp->window == window) + { + if(prev) + { + prev->next = tmp->next; + free(tmp); + tmp = prev->next; + } + else + { + Root = tmp->next; + free(tmp); + tmp = Root; + } + } + else + { + prev = tmp; + tmp = tmp->next; + } + } +} + +/* + * Removes all callbacks for a given window with specified data. + * Parameters: + * window: Window handle of callback to be removed. + * data: Pointer to the data to be compared against. + */ +void dw_signal_disconnect_by_data(HWND window, void *data) +{ + SignalHandler *prev = NULL, *tmp = Root; + + while(tmp) + { + if(tmp->window == window && tmp->data == data) + { + if(prev) + { + prev->next = tmp->next; + free(tmp); + tmp = prev->next; + } + else + { + Root = tmp->next; + free(tmp); + tmp = Root; + } + } + else + { + prev = tmp; + tmp = tmp->next; + } + } +} +#endif + +#ifdef TEST +HWND mainwindow, + listbox, + okbutton, + cancelbutton, + lbbox, + stext, + buttonbox, + testwindow, + testbox, + testok, + testcancel, + testbox2, + testok2, + testcancel2, + notebook; +int count = 2; + +#ifdef USE_FILTER +/* Do any handling you need in the filter function */ +LONG testfilter(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) +{ + switch(msg) + { + case WM_COMMAND: + switch (COMMANDMSG(&msg)->cmd) + { + case 1001L: + case 1002L: + dw_window_destroy(mainwindow);; + count--; + break; + case 1003L: + case 1004L: + dw_window_destroy(testwindow);; + count--; + break; + } + if(!count) + exit(0); + break; + } + /* Return -1 to allow the default handlers to return. */ + return TRUE; +} +#else +int test_callback(HWND window, void *data) +{ + dw_window_destroy((HWND)data); + /* Return -1 to allow the default handlers to return. */ + count--; + if(!count) + exit(0); + return -1; +} +#endif + +/* + * Let's demonstrate the functionality of this library. :) + */ +int main(void) +{ + ULONG flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | + DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; + int pageid; + + dw_init(TRUE); + + /* Try a little server dialog. :) */ + mainwindow = dw_window_new(HWND_DESKTOP, "Server", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX); + + lbbox = dw_box_new(BOXVERT, 10); + + dw_box_pack_start(mainwindow, lbbox, 0, 0, TRUE, TRUE, 0); + + stext = dw_text_new("Choose a server:", 0); + + dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER); + + dw_box_pack_start(lbbox, stext, 130, 15, FALSE, FALSE, 10); + + listbox = dw_listbox_new(100L, FALSE); + + dw_box_pack_start(lbbox, listbox, 130, 200, TRUE, TRUE, 10); + + buttonbox = dw_box_new(BOXHORZ, 0); + + dw_box_pack_start(lbbox, buttonbox, 0, 0, TRUE, TRUE, 0); + + okbutton = dw_button_new("Ok", 1001L); + + dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, TRUE, 5); + + cancelbutton = dw_button_new("Cancel", 1002L); + + dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, TRUE, 5); + + /* Set some nice fonts and colors */ + dw_window_set_color(lbbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + dw_window_set_color(buttonbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + dw_window_set_font(stext, "9.WarpSans"); + dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY); + dw_window_set_font(listbox, "9.WarpSans"); + dw_window_set_font(okbutton, "9.WarpSans"); + dw_window_set_font(cancelbutton, "9.WarpSans"); + + dw_window_show(mainwindow); + + dw_window_set_usize(mainwindow, 170, 340); + + /* Another small example */ + flStyle |= FCF_MINMAX | FCF_SIZEBORDER; + + testwindow = dw_window_new(HWND_DESKTOP, "Wow a test dialog! :) yay!", flStyle); + + testbox = dw_box_new(BOXVERT, 0); + + dw_box_pack_start(testwindow, testbox, 0, 0, TRUE, TRUE, 0); + + notebook = dw_notebook_new(1010L, TRUE); + + dw_box_pack_start(testbox, notebook, 100, 100, TRUE, TRUE, 0); + + testbox = dw_box_new(BOXVERT, 10); + + pageid = dw_notebook_page_new(notebook, 0L, FALSE); + + dw_notebook_page_set_text(notebook, pageid, "Test page"); + dw_notebook_page_set_status_text(notebook, pageid, "Test page"); + + dw_notebook_pack(notebook, pageid, testbox); + + testok = dw_button_new("Ok", 1003L); + + dw_box_pack_start(testbox, testok, 60, 40, TRUE, TRUE, 10); + + testcancel = dw_button_new("Cancel", 1004L); + + dw_box_pack_start(testbox, testcancel, 60, 40, TRUE, TRUE, 10); + + testbox2 = dw_box_new(BOXHORZ, 0); + + dw_box_pack_start(testbox, testbox2, 0, 0, TRUE, TRUE, 0); + + testok2 = dw_button_new("Ok", 1003L); + + dw_box_pack_start(testbox2, testok2, 60, 40, TRUE, TRUE, 10); + + dw_box_pack_splitbar_start(testbox2); + + testcancel2 = dw_button_new("Cancel", 1004L); + + dw_box_pack_start(testbox2, testcancel2, 60, 40, TRUE, TRUE, 10); + + /* Set some nice fonts and colors */ + dw_window_set_color(testbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + dw_window_set_color(testbox2, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + dw_window_set_font(testok, "9.WarpSans"); + dw_window_set_font(testcancel, "9.WarpSans"); + dw_window_set_font(testok2, "9.WarpSans"); + dw_window_set_font(testcancel2, "9.WarpSans"); + + dw_window_show(testwindow); + +#ifdef USE_FILTER + dw_main(0L, (void *)testfilter); +#else + /* Setup the function callbacks */ + dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); + dw_signal_connect(cancelbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); + dw_signal_connect(testok, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); + dw_signal_connect(testcancel, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); + dw_signal_connect(testok2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); + dw_signal_connect(testcancel2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); + dw_signal_connect(mainwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); + dw_signal_connect(testwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); + + dw_main(0L, NULL); +#endif + + return 0; +} +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/readme Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,20 @@ +This is an alpha release of dynamic windows. + +Currently it is not quite complete and some functionality is broken. + +Known problems: + +Groupboxes are broken. +Splitbars are based on the original position not the current position, + and don't update until a resize. + +Future features: + +Implementing all of the OS/2 controls. Currently a number of controls have not been implemented. +Implementing a toolbar. + +If you have any questions or suggestions feel free to email me at dbsoft@technologist.com + +Thanks! + +Brian Smith
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/win/dirent.c Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,226 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> + +#include <windows.h> + +#include "dirent.h" +#include <errno.h> + +#define error(rc) errno = 255 + +struct _dirdescr { + HANDLE handle; /* DosFindFirst handle */ + char fstype; /* filesystem type */ + long count; /* valid entries in <ffbuf> */ + long number; /* absolute number of next entry */ + int index; /* relative number of next entry */ + char name[MAXPATHLEN+3]; /* directory name */ + unsigned attrmask; /* attribute mask for seekdir */ + struct dirent entry; /* buffer for directory entry */ + WIN32_FIND_DATA data; +}; + +/* + * Return first char of filesystem type, or 0 if unknown. + */ +static char +getFSType(const char *path) +{ + static char cache[1+26]; + char drive[3]; + ULONG unit; + char r; + + if (isalpha(path[0]) && path[1] == ':') { + unit = toupper(path[0]) - '@'; + path += 2; + } else { + return 0; + } + + if ((path[0] == '\\' || path[0] == '/') + && (path[1] == '\\' || path[1] == '/')) + return 0; + + if (cache [unit]) + return cache [unit]; + + drive[0] = '@' + unit; + drive[1] = ':'; + drive[2] = '\0'; + + r = GetDriveType(drive); + + return cache [unit] = r; +} + +char * +abs_path(const char *name, char *buffer, int len) +{ + char buf[4]; + if (isalpha(name[0]) && name[1] == ':' && name[2] == '\0') { + buf[0] = name[0]; + buf[1] = name[1]; + buf[2] = '.'; + buf[3] = '\0'; + name = buf; + } + if (GetLongPathName(name, buffer, len)) + return NULL; + return buffer; +} + +DIR * +openxdir(const char *path, unsigned att_mask) +{ + DIR *dir; + char name[MAXPATHLEN+3]; + + dir = malloc(sizeof(DIR)); + if (dir == NULL) { + errno = ENOMEM; + return NULL; + } + + strncpy(name, path, MAXPATHLEN); + name[MAXPATHLEN] = '\0'; + switch (name[strlen(name)-1]) { + default: + strcat(name, "\\"); + case '\\': + case '/': + case ':': + ; + } + strcat(name, "."); + if (!abs_path(name, dir->name, MAXPATHLEN+1)) + strcpy(dir->name, name); + if (dir->name[strlen(dir->name)-1] == '\\') + strcat(dir->name, "*"); + else + strcat(dir->name, "\\*"); + + dir->fstype = getFSType(dir->name); + dir->attrmask = att_mask | A_DIR; + + dir->count = 100; + if((dir->handle = FindFirstFile(dir->name, &dir->data))==NULL) + { + free(dir); + error(rc); + return NULL; + } + + dir->number = 0; + dir->index = 0; + + return (DIR *)dir; +} + +DIR * +opendir(const char *pathname) +{ + return openxdir(pathname, 0); +} + +struct dirent * +readdir(DIR *dir) +{ + static int dummy_ino = 2; + + if (dir->number) + { + ULONG rc; + dir->count = 100; + if(!FindNextFile(dir->handle, &(dir->data))) + { + error(rc); + return NULL; + } + + dir->index = 0; + } + + strcpy(dir->entry.d_name, dir->data.cFileName); + dir->entry.d_ino = dummy_ino++; + dir->entry.d_reclen = strlen(dir->data.cFileName); + dir->entry.d_namlen = strlen(dir->data.cFileName); + dir->entry.d_size = dir->data.nFileSizeLow; + dir->entry.d_attribute = dir->data.dwFileAttributes; +#if 0 + dir->entry.d_time = *(USHORT *)&dir->next->ftimeLastWrite; + dir->entry.d_date = *(USHORT *)&dir->next->fdateLastWrite; +#endif + + dir->number++; + dir->index++; + return &dir->entry; +} + +long +telldir(DIR *dir) +{ + return dir->number; +} + +void +seekdir(DIR *dir, long off) +{ + if (dir->number > off) { + char name[MAXPATHLEN+2]; + ULONG rc; + + FindClose(dir->handle); + + strcpy(name, dir->name); + strcat(name, "*"); + + if((dir->handle = FindFirstFile(name, &(dir->data)))==NULL) + { + error(rc); + return; + } + + dir->number = 0; + dir->index = 0; + } + + while (dir->number < off && readdir(dir)) + ; +} + +void +closedir(DIR *dir) +{ + FindClose(dir->handle); + free(dir); +} + +/*****************************************************************************/ + +#ifdef TEST + +main(int argc, char **argv) +{ + int i; + DIR *dir; + struct dirent *ep; + + for (i = 1; i < argc; ++i) { + dir = opendir(argv[i]); + if (!dir) + continue; + while (ep = readdir(dir)) + if (strchr("\\/:", argv[i] [strlen(argv[i]) - 1])) + printf("%s%s\n", argv[i], ep->d_name); + else + printf("%s/%s\n", argv[i], ep->d_name); + closedir(dir); + } + + return 0; +} + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/win/dw.c Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,5568 @@ +/* + * Dynamic Windows: + * A GTK like implementation of the Win32 GUI + * + * (C) 2000,2001 Brian Smith <dbsoft@technologist.com> + * + */ +#define _WIN32_IE 0x0500 +#define WINVER 0x400 +#include <windows.h> +#include <windowsx.h> +#include <commctrl.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <process.h> +#include "dw.h" + +/* this is the callback handle for the window procedure */ +/* make sure you always match the calling convention! */ +int (*filterfunc)(HWND, UINT, WPARAM, LPARAM) = 0L; + +HWND hwndBubble = (HWND)NULL, hwndBubbleLast, DW_HWND_OBJECT = (HWND)NULL; + +HINSTANCE DWInstance = NULL; + +DWORD dwVersion = 0; + +/* I should probably check the actual file version, but this will do for now */ +#define IS_WIN98PLUS (LOBYTE(LOWORD(dwVersion)) > 4 || \ + (LOBYTE(LOWORD(dwVersion)) == 4 && HIBYTE(LOWORD(dwVersion)) > 0)) + +char monthlist[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", + "Sep", "Oct", "Nov", "Dec" }; + +int main(int argc, char *argv[]); + +#define ICON_INDEX_LIMIT 200 +HICON lookup[200]; +HIMAGELIST hSmall, hLarge; + +COLORREF _foreground = RGB(127, 127, 127); +COLORREF _background = 0; +HPEN _hPen; +HBRUSH _hBrush; + +#ifdef DWDEBUG +FILE *f; + +void reopen(void) +{ + fclose(f); + f = fopen("dw.log", "at"); +} +#endif + +BYTE _red[] = { 0x00, 0xbb, 0x00, 0xaa, 0x00, 0xbb, 0x00, 0xaa, 0x77, + 0xff, 0x00, 0xee, 0x00, 0xff, 0x00, 0xff, 0xaa, 0x00 }; +BYTE _green[] = { 0x00, 0x00, 0xbb, 0xaa, 0x00, 0x00, 0xbb, 0xaa, 0x77, + 0x00, 0xff, 0xee, 0x00, 0x00, 0xee, 0xff, 0xaa, 0x00 }; +BYTE _blue[] = { 0x00, 0x00, 0x00, 0x00, 0xcc, 0xbb, 0xbb, 0xaa, 0x77, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xee, 0xff, 0xaa, 0x00}; + +HBRUSH _colors[18]; + +static LONG lColor[SPLITBAR_WIDTH] = +{ + DW_CLR_BLACK, + DW_CLR_PALEGRAY, + DW_CLR_WHITE +}; + +void _resize_notebook_page(HWND handle, int pageid); + +#ifdef NO_SIGNALS +#define USE_FILTER +#else +typedef struct _sighandler +{ + struct _sighandler *next; + ULONG message; + HWND window; + void *signalfunction; + void *data; + +} SignalHandler; + +SignalHandler *Root = NULL; +int _index; + +typedef struct +{ + ULONG message; + char name[30]; + +} SignalList; + +/* List of signals and their equivilent Win32 message */ +#define SIGNALMAX 11 + +SignalList SignalTranslate[SIGNALMAX] = { + { WM_SIZE, "configure_event" }, + { WM_CHAR, "key_press_event" }, + { WM_LBUTTONDOWN, "button_press_event" }, + { WM_LBUTTONUP, "button_release_event" }, + { WM_MOUSEMOVE, "motion_notify_event" }, + { WM_CLOSE, "delete_event" }, + { WM_PAINT, "expose_event" }, + { WM_COMMAND, "clicked" }, + { NM_DBLCLK, "container-select" }, + { NM_RCLICK, "container-context" }, + { LBN_SELCHANGE, "item-select" } +}; + +#ifdef BUILD_DLL +void Win32_Set_Instance(HINSTANCE hInstance) +{ + DWInstance = hInstance; +} +#else +char **_convertargs(int *count, char *start) +{ + char *tmp, *argstart, **argv; + int loc = 0, inquotes = 0; + + (*count) = 1; + + tmp = start; + + /* Count the number of entries */ + if(*start) + { + (*count)++; + + while(*tmp) + { + if(*tmp == '"' && inquotes) + inquotes = 0; + else if(*tmp == '"' && !inquotes) + inquotes = 1; + else if(*tmp == ' ' && !inquotes) + { + /* Push past any white space */ + while(*(tmp+1) == ' ') + tmp++; + /* If we aren't at the end of the command + * line increment the count. + */ + if(*(tmp+1)) + (*count)++; + } + tmp++; + } + } + + argv = (char **)malloc(sizeof(char *) * ((*count)+1)); + argv[0] = malloc(260); + GetModuleFileName(DWInstance, argv[0], 260); + + argstart = tmp = start; + + if(*start) + { + loc = 1; + + while(*tmp) + { + if(*tmp == '"' && inquotes) + { + *tmp = 0; + inquotes = 0; + } + else if(*tmp == '"' && !inquotes) + { + argstart = tmp+1; + inquotes = 1; + } + else if(*tmp == ' ' && !inquotes) + { + *tmp = 0; + argv[loc] = strdup(argstart); + + /* Push past any white space */ + while(*(tmp+1) == ' ') + tmp++; + + /* Move the start pointer */ + argstart = tmp+1; + + /* If we aren't at the end of the command + * line increment the count. + */ + if(*(tmp+1)) + loc++; + } + tmp++; + } + if(*argstart) + argv[loc] = strdup(argstart); + } + argv[loc+1] = NULL; + return argv; +} + +/* Ok this is a really big hack but what the hell ;) */ +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +{ + char **argv; + int argc; + + DWInstance = hInstance; + + argv = _convertargs(&argc, lpCmdLine); + + return main(argc, argv); +} +#endif + +/* This function adds a signal handler callback into the linked list. + */ +void _new_signal(ULONG message, HWND window, void *signalfunction, void *data) +{ + SignalHandler *new = malloc(sizeof(SignalHandler)); + + new->message = message; + new->window = window; + new->signalfunction = signalfunction; + new->data = data; + new->next = NULL; + + if (!Root) + Root = new; + else + { + SignalHandler *prev = NULL, *tmp = Root; + while(tmp) + { + prev = tmp; + tmp = tmp->next; + } + if(prev) + prev->next = new; + else + Root = new; + } +} + +/* Finds the message number for a given signal name */ +ULONG _findsigmessage(char *signame) +{ + int z; + + for(z=0;z<SIGNALMAX;z++) + { + if(stricmp(signame, SignalTranslate[z].name) == 0) + return SignalTranslate[z].message; + } + return 0L; +} +#endif + +/* This function removes and handlers on windows and frees + * the user memory allocated to it. + */ +BOOL CALLBACK _free_window_memory(HWND handle, LPARAM lParam) +{ + void *ptr = (void *)GetWindowLong(handle, GWL_USERDATA); + +#ifndef NO_SIGNALS + dw_signal_disconnect_by_window(handle); +#endif + + if(ptr) + { + SetWindowLong(handle, GWL_USERDATA, 0); + free(ptr); + } + return TRUE; +} + +/* This function returns 1 if the window (widget) handle + * passed to it is a valid window that can gain input focus. + */ +int _validate_focus(HWND handle) +{ + char tmpbuf[100]; + + if(!handle) + return 0; + + GetClassName(handle, tmpbuf, 99); + + /* These are the window classes which can + * obtain input focus. + */ + if(strnicmp(tmpbuf, EDITCLASSNAME, strlen(EDITCLASSNAME))==0 || /* Entryfield */ + strnicmp(tmpbuf, BUTTONCLASSNAME, strlen(BUTTONCLASSNAME))==0 || /* Button */ + strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0 || /* Combobox */ + strnicmp(tmpbuf, LISTBOXCLASSNAME, strlen(LISTBOXCLASSNAME))==0 || /* List box */ + strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS))==0 || /* Spinbutton */ + strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW))== 0) /* Container */ + return 1; + return 0; +} + +HWND _normalize_handle(HWND handle) +{ + char tmpbuf[100] = ""; + + GetClassName(handle, tmpbuf, 99); + if(strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS))==0) /* Spinner */ + { + ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); + + if(cinfo && cinfo->buddy) + return cinfo->buddy; + } + return handle; +} + +int _focus_check_box(Box *box, HWND handle, int start) +{ + int z; + static HWND lasthwnd, firsthwnd; + static int finish_searching; + + /* Start is 2 when we have cycled completely and + * need to set the focus to the last widget we found + * that was valid. + */ + if(start == 2) + { + if(lasthwnd) + SetFocus(lasthwnd); + return 0; + } + + /* Start is 1 when we are entering the function + * for the first time, it is zero when entering + * the function recursively. + */ + if(start == 1) + { + lasthwnd = handle; + finish_searching = 0; + firsthwnd = 0; + } + + for(z=box->count-1;z>-1;z--) + { + if(box->items[z].type == TYPEBOX) + { + Box *thisbox = (Box *)GetWindowLong(box->items[z].hwnd, GWL_USERDATA); + + if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0)) + return 1; + } + else + { + if(box->items[z].hwnd == handle) + { + if(lasthwnd == handle && firsthwnd) + SetFocus(firsthwnd); + else if(lasthwnd == handle && !firsthwnd) + finish_searching = 1; + else + SetFocus(lasthwnd); + + /* If we aren't looking for the last handle, + * return immediately. + */ + if(!finish_searching) + return 1; + } + if(_validate_focus(box->items[z].hwnd)) + { + /* Start is 3 when we are looking for the + * first valid item in the layout. + */ + if(start == 3) + { + SetFocus(_normalize_handle(box->items[z].hwnd)); + return 1; + } + + if(!firsthwnd) + firsthwnd = _normalize_handle(box->items[z].hwnd); + + lasthwnd = _normalize_handle(box->items[z].hwnd); + } + else + { + char tmpbuf[100] = ""; + + GetClassName(box->items[z].hwnd, tmpbuf, 99); + + if(strnicmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0) /* Notebook */ + { + NotebookPage **array = (NotebookPage **)GetWindowLong(box->items[z].hwnd, GWL_USERDATA); + int pageid = TabCtrl_GetCurSel(box->items[z].hwnd); + + if(pageid > -1 && array && array[pageid]) + { + Box *notebox; + + if(array[pageid]->hwnd) + { + notebox = (Box *)GetWindowLong(array[pageid]->hwnd, GWL_USERDATA); + + if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0)) + return 1; + } + } + } + } + } + } + return 0; +} + +/* This function finds the first widget in the + * layout and moves the current focus to it. + */ +void _initial_focus(HWND handle) +{ + Box *thisbox; + + if(handle) + thisbox = (Box *)GetWindowLong(handle, GWL_USERDATA); + + if(thisbox) + { + _focus_check_box(thisbox, handle, 3); + } +} + +/* This function finds the current widget in the + * layout and moves the current focus to the next item. + */ +void _shift_focus(HWND handle) +{ + Box *thisbox; + + HWND box, lastbox = GetParent(handle); + + /* Find the toplevel window */ + while((box = GetParent(lastbox))) + { + lastbox = box; + } + + thisbox = (Box *)GetWindowLong(lastbox, GWL_USERDATA); + if(thisbox) + { + if(_focus_check_box(thisbox, handle, 1) == 0) + _focus_check_box(thisbox, handle, 2); + } +} + +/* ResetWindow: + * Resizes window to the exact same size to trigger + * recalculation of frame. + */ +void _ResetWindow(HWND hwndFrame) +{ + RECT rcl; + + GetWindowRect(hwndFrame, &rcl); + SetWindowPos(hwndFrame, HWND_TOP, 0, 0, rcl.right - rcl.left, + rcl.bottom - rcl.top - 1, SWP_NOMOVE | SWP_NOZORDER); + SetWindowPos(hwndFrame, HWND_TOP, 0, 0, rcl.right - rcl.left, + rcl.bottom - rcl.top, SWP_NOMOVE | SWP_NOZORDER); +} + +/* Function: TrackRectangle + * Abstract: Tracks given rectangle. + * + * If rclBounds is NULL, then track rectangle on entire desktop. + * rclTrack is in window coorditates and will be mapped to + * desktop. + */ + +BOOL _TrackRectangle(HWND hwndBase, RECTL* rclTrack, RECTL* rclBounds) +{ + ULONG rc = 0; +#if 0 + TRACKINFO track; + + track.cxBorder = 1; + track.cyBorder = 1; + track.cxGrid = 1; + track.cyGrid = 1; + track.cxKeyboard = 8; + track.cyKeyboard = 8; + + if(!rclTrack) + return FALSE; + + if(rclBounds) + { + track.rclBoundary = *rclBounds; + } + else + { + track.rclBoundary.yTop = + track.rclBoundary.xRight = 3000; + track.rclBoundary.yBottom = + track.rclBoundary.xLeft = -3000; + } + + track.rclTrack = *rclTrack; + + MapWindowPoints(hwndBase, + HWND_DESKTOP, + (PPOINT)&track.rclTrack, + 2); + + track.ptlMinTrackSize.x = track.rclTrack.xRight + - track.rclTrack.xLeft; + track.ptlMinTrackSize.y = track.rclTrack.yTop + - track.rclTrack.yBottom; + track.ptlMaxTrackSize.x = track.rclTrack.xRight + - track.rclTrack.xLeft; + track.ptlMaxTrackSize.y = track.rclTrack.yTop + - track.rclTrack.yBottom; + + track.fs = TF_MOVE | TF_ALLINBOUNDARY; + + rc = WinTrackRect(HWND_DESKTOP, 0, &track); + + if(rc) + *rclTrack = track.rclTrack; + +#endif + return rc; +} + +/* This function calculates how much space the widgets and boxes require + * and does expansion as necessary. + */ +int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy, + int pass, int *usedpadx, int *usedpady) +{ + int z, currentx = 0, currenty = 0; + int uymax = 0, uxmax = 0; + int upymax = 0, upxmax = 0; + /* Used for the SIZEEXPAND */ + int nux = *usedx, nuy = *usedy; + int nupx = *usedpadx, nupy = *usedpady; + + (*usedx) += (thisbox->pad * 2); + (*usedy) += (thisbox->pad * 2); + + for(z=0;z<thisbox->count;z++) + { + if(thisbox->items[z].type == TYPEBOX) + { + int initialx, initialy; + Box *tmp = (Box *)GetWindowLong(thisbox->items[z].hwnd, GWL_USERDATA); + + initialx = x - (*usedx); + initialy = y - (*usedy); + + if(tmp) + { + int newx, newy; + int nux = *usedx, nuy = *usedy; + int upx = *usedpadx + (tmp->pad*2), upy = *usedpady + (tmp->pad*2); + + /* On the second pass we know how big the box needs to be and how + * much space we have, so we can calculate a ratio for the new box. + */ + if(pass == 2) + { + int deep = *depth + 1; + + _resize_box(tmp, &deep, x, y, &nux, &nuy, 1, &upx, &upy); + + tmp->upx = upx - *usedpadx; + tmp->upy = upy - *usedpady; + + newx = x - nux; + newy = y - nuy; + + tmp->width = thisbox->items[z].width = initialx - newx; + tmp->height = thisbox->items[z].height = initialy - newy; + + tmp->parentxratio = thisbox->xratio; + tmp->parentyratio = thisbox->yratio; + + tmp->parentpad = tmp->pad; + + /* Just in case */ + tmp->xratio = thisbox->xratio; + tmp->yratio = thisbox->yratio; + +#ifdef DWDEBUG + if(pass > 1) + { + fprintf(f, "FARK! depth %d\r\nwidth = %d, height = %d, nux = %d, nuy = %d, upx = %d, upy = %d xratio = %f, yratio = %f\r\n\r\n", + *depth, thisbox->items[z].width, thisbox->items[z].height, nux, nuy, tmp->upx, tmp->upy, tmp->xratio, tmp->yratio); + reopen(); + } +#endif + if(thisbox->type == BOXVERT) + { + if((thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) + tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))); + } + else + { + if((thisbox->items[z].width-tmp->upx)!=0) + tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx)); + } + if(thisbox->type == BOXHORZ) + { + if((thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) + tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))); + } + else + { + if((thisbox->items[z].height-tmp->upy)!=0) + tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy)); + } + + nux = *usedx; nuy = *usedy; + upx = *usedpadx + (tmp->pad*2); upy = *usedpady + (tmp->pad*2); + } + + (*depth)++; + +#ifdef DWDEBUG + if(pass > 1) + { + fprintf(f, "Before Resize Box depth %d\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d xratio = %f, yratio = %f\r\n\r\n", + *depth, x, y, *usedx, *usedy, *usedpadx, *usedpady, tmp->xratio, tmp->yratio); + reopen(); + } +#endif + + _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &upx, &upy); + + (*depth)--; + + newx = x - nux; + newy = y - nuy; + + tmp->minwidth = thisbox->items[z].width = initialx - newx; + tmp->minheight = thisbox->items[z].height = initialy - newy; + +#ifdef DWDEBUG + if(pass > 1) + { + fprintf(f, "After Resize Box depth %d\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d width = %d, height = %d\r\n\r\n", + *depth, x, y, *usedx, *usedy, *usedpadx, *usedpady, thisbox->items[z].width, thisbox->items[z].height); + reopen(); + } +#endif + } + } + + if(pass > 1 && *depth > 0) + { + if(thisbox->type == BOXVERT) + thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2)))); + else + thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx)); + + if(thisbox->type == BOXHORZ) + thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2)))); + else + thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy)); +#ifdef DWDEBUG + fprintf(f, "RATIO- xratio = %f, yratio = %f, width = %d, height = %d, pad = %d, box xratio = %f, box yratio = %f, parent xratio = %f, parent yratio = %f, minwidth = %d, minheight = %d, width = %d, height = %d, upx = %d, upy = %d\r\n\r\n", + thisbox->items[z].xratio, thisbox->items[z].yratio, thisbox->items[z].width, thisbox->items[z].height, thisbox->items[z].pad, thisbox->xratio, thisbox->yratio, thisbox->parentxratio, thisbox->parentyratio, thisbox->minwidth, thisbox->minheight, thisbox->width, thisbox->height, thisbox->upx, thisbox->upy); + reopen(); +#endif + } + else + { + thisbox->items[z].xratio = thisbox->xratio; + thisbox->items[z].yratio = thisbox->yratio; + } + + if(thisbox->type == BOXVERT) + { + if((thisbox->items[z].width + (thisbox->items[z].pad*2)) > uxmax) + uxmax = (thisbox->items[z].width + (thisbox->items[z].pad*2)); + if(thisbox->items[z].hsize != SIZEEXPAND) + { + if(((thisbox->items[z].pad*2) + thisbox->items[z].width) > upxmax) + upxmax = (thisbox->items[z].pad*2) + thisbox->items[z].width; + } + else + { + if(thisbox->items[z].pad*2 > upxmax) + upxmax = thisbox->items[z].pad*2; + } + } + else + { + if(thisbox->items[z].width == -1) + { + /* figure out how much space this item requires */ + /* thisbox->items[z].width = */ + } + else + { + (*usedx) += thisbox->items[z].width + (thisbox->items[z].pad*2); + if(thisbox->items[z].hsize != SIZEEXPAND) + (*usedpadx) += (thisbox->items[z].pad*2) + thisbox->items[z].width; + else + (*usedpadx) += thisbox->items[z].pad*2; + } + } + if(thisbox->type == BOXHORZ) + { + if((thisbox->items[z].height + (thisbox->items[z].pad*2)) > uymax) + uymax = (thisbox->items[z].height + (thisbox->items[z].pad*2)); + if(thisbox->items[z].vsize != SIZEEXPAND) + { + if(((thisbox->items[z].pad*2) + thisbox->items[z].height) > upymax) + upymax = (thisbox->items[z].pad*2) + thisbox->items[z].height; + } + else + { + if(thisbox->items[z].pad*2 > upymax) + upymax = thisbox->items[z].pad*2; + } + } + else + { + if(thisbox->items[z].height == -1) + { + /* figure out how much space this item requires */ + /* thisbox->items[z].height = */ + } + else + { + (*usedy) += thisbox->items[z].height + (thisbox->items[z].pad*2); + if(thisbox->items[z].vsize != SIZEEXPAND) + (*usedpady) += (thisbox->items[z].pad*2) + thisbox->items[z].height; + else + (*usedpady) += thisbox->items[z].pad*2; + } + } + } + + (*usedx) += uxmax; + (*usedy) += uymax; + (*usedpadx) += upxmax; + (*usedpady) += upymax; + + currentx += thisbox->pad; + currenty += thisbox->pad; + +#ifdef DWDEBUG + fprintf(f, "Done Calc depth %d\r\nusedx = %d, usedy = %d, usedpadx = %d, usedpady = %d, currentx = %d, currenty = %d, uxmax = %d, uymax = %d\r\n\r\n", + *depth, *usedx, *usedy, *usedpadx, *usedpady, currentx, currenty, uxmax, uymax); + reopen(); +#endif + + /* The second pass is for expansion and actual placement. */ + if(pass > 1) + { + /* Any SIZEEXPAND items should be set to uxmax/uymax */ + for(z=0;z<thisbox->count;z++) + { + if(thisbox->items[z].hsize == SIZEEXPAND && thisbox->type == BOXVERT) + thisbox->items[z].width = uxmax-(thisbox->items[z].pad*2); + if(thisbox->items[z].vsize == SIZEEXPAND && thisbox->type == BOXHORZ) + thisbox->items[z].height = uymax-(thisbox->items[z].pad*2); + /* Run this code segment again to finalize the sized after setting uxmax/uymax values. */ + if(thisbox->items[z].type == TYPEBOX) + { + Box *tmp = (Box *)GetWindowLong(thisbox->items[z].hwnd, GWL_USERDATA); + + if(tmp) + { + if(*depth > 0) + { + if(thisbox->type == BOXVERT) + { + tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/((float)(tmp->minwidth-((thisbox->items[z].pad*2)+(thisbox->pad*2)))); + tmp->width = thisbox->items[z].width; + } + if(thisbox->type == BOXHORZ) + { + tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/((float)(tmp->minheight-((thisbox->items[z].pad*2)+(thisbox->pad*2)))); + tmp->height = thisbox->items[z].height; + } + } + + (*depth)++; + + /*tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx) )/((float)(tmp->minwidth-tmp->upx)); + tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(tmp->minheight-tmp->upy));*/ + +#ifdef DWDEBUG + fprintf(f, "2- Resize Box depth %d\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d xratio = %f, yratio = %f,\r\nupx = %d, upy = %d, width = %d, height = %d, minwidth = %d, minheight = %d, box xratio = %f, box yratio = %f\r\n\r\n", + *depth, x, y, *usedx, *usedy, *usedpadx, *usedpady, tmp->xratio, tmp->yratio, tmp->upx, tmp->upy, thisbox->items[z].width, thisbox->items[z].height, tmp->minwidth, tmp->minheight, thisbox->xratio, thisbox->yratio); + reopen(); +#endif + + _resize_box(tmp, depth, x, y, &nux, &nuy, 3, &nupx, &nupy); + + (*depth)--; + + } + } + } + + for(z=0;z<(thisbox->count);z++) + { + int height = thisbox->items[z].height; + int width = thisbox->items[z].width; + int pad = thisbox->items[z].pad; + HWND handle = thisbox->items[z].hwnd; + int vectorx, vectory; + + /* When upxmax != pad*2 then ratios are incorrect. */ + vectorx = (int)((width*thisbox->items[z].xratio)-width); + vectory = (int)((height*thisbox->items[z].yratio)-height); + + if(width > 0 && height > 0) + { + char tmpbuf[100]; + /* This is a hack to fix rounding of the sizing */ + if(*depth == 0) + { + vectorx++; + vectory++; + } + + /* If this item isn't going to expand... reset the vectors to 0 */ + if(thisbox->items[z].vsize != SIZEEXPAND) + vectory = 0; + if(thisbox->items[z].hsize != SIZEEXPAND) + vectorx = 0; + + GetClassName(handle, tmpbuf, 99); + + if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0) + { + /* Handle special case Combobox */ + SetWindowPos(handle, HWND_TOP, currentx + pad, currenty + pad, + width + vectorx, (height + vectory) + 400, 0); + } + else if(strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS))==0) + { + /* Handle special case Spinbutton */ + ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); + + SetWindowPos(handle, HWND_TOP, currentx + pad + ((width + vectorx) - 20), currenty + pad, + 20, height + vectory, 0); + + if(cinfo) + { + SetWindowPos(cinfo->buddy, HWND_TOP, currentx + pad, currenty + pad, + (width + vectorx) - 20, height + vectory, 0); + } + } + else + { + /* Everything else */ + SetWindowPos(handle, HWND_TOP, currentx + pad, currenty + pad, + width + vectorx, height + vectory, 0); + if(thisbox->items[z].type == TYPEBOX) + { + Box *boxinfo = (Box *)GetWindowLong(handle, GWL_USERDATA); + + if(boxinfo && boxinfo->grouphwnd) + SetWindowPos(boxinfo->grouphwnd, HWND_TOP, 0, 0, + width + vectorx, height + vectory, 0); + + } + } + + /* Notebook dialog requires additional processing */ + if(strncmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0) + { + RECT rect; + NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); + int pageid = TabCtrl_GetCurSel(handle); + + if(pageid > -1 && array && array[pageid]) + { + GetClientRect(handle,&rect); + TabCtrl_AdjustRect(handle,FALSE,&rect); + MoveWindow(array[pageid]->hwnd,rect.left,rect.top, + rect.right - rect.left,rect.bottom-rect.top, + TRUE); + ShowWindow(array[pageid]->hwnd,SW_SHOWNORMAL); + } + } + +#ifdef DWDEBUG + fprintf(f, "Window Pos depth %d\r\ncurrentx = %d, currenty = %d, pad = %d, width = %d, height = %d, vectorx = %d, vectory = %d, Box type = %s\r\n\r\n", + *depth, currentx, currenty, pad, width, height, vectorx, vectory,thisbox->type == BOXHORZ ? "Horizontal" : "Vertical"); + reopen(); +#endif + + if(thisbox->type == BOXHORZ) + currentx += width + vectorx + (pad * 2); + if(thisbox->type == BOXVERT) + currenty += height + vectory + (pad * 2); + } + } + } + return 0; +} + +void _do_resize(Box *thisbox, int x, int y) +{ + if(x != 0 && y != 0) { + if(thisbox) + { + int usedx = 0, usedy = 0, depth = 0, usedpadx = 0, usedpady = 0; + + _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady); + + thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx)); + thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady)); + +#ifdef DWDEBUG + fprintf(f, "WM_SIZE Resize Box Pass 1\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d xratio = %f, yratio = %f\r\n\r\n", + x, y, usedx, usedy, usedpadx, usedpady, thisbox->xratio, thisbox->yratio); + reopen(); +#endif + + usedpadx = usedpady = usedx = usedy = depth = 0; + + _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady); +#ifdef DWDEBUG + fprintf(f, "WM_SIZE Resize Box Pass 2\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d\r\n", + x, y, usedx, usedy, usedpadx, usedpady); + reopen(); +#endif + } + } +} + +/* The main window procedure for Dynamic Windows, all the resizing code is done here. */ +BOOL CALLBACK _wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) +{ + int result = -1; + static int command_active = 0; +#ifndef NO_SIGNALS + SignalHandler *tmp = Root; +#endif + void (* windowfunc)(PVOID); + ULONG origmsg = msg; + + if(msg == WM_RBUTTONDOWN || msg == WM_MBUTTONDOWN) + msg = WM_LBUTTONDOWN; + if(msg == WM_RBUTTONUP || msg == WM_MBUTTONUP) + msg = WM_LBUTTONUP; + + if(filterfunc) + result = filterfunc(hWnd, msg, mp1, mp2); + +#ifndef NO_SIGNALS + if(result == -1) + { + /* Avoid infinite recursion */ + command_active = 1; + + /* Find any callbacks for this function */ + while(tmp) + { + if(tmp->message == msg || msg == WM_COMMAND) + { + switch(msg) + { + case WM_SIZE: + { + int (*sizefunc)(HWND, int, int, void *) = tmp->signalfunction; + + if(hWnd == tmp->window) + { + result = sizefunc(tmp->window, LOWORD(mp2), HIWORD(mp2), tmp->data); + tmp = NULL; + } + } + break; + case WM_LBUTTONDOWN: + { + POINTS pts = MAKEPOINTS(mp2); + int (*buttonfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction; + + if(hWnd == tmp->window) + { + int button; + + switch(origmsg) + { + case WM_LBUTTONDOWN: + button = 1; + break; + case WM_RBUTTONDOWN: + button = 2; + break; + case WM_MBUTTONDOWN: + button = 3; + break; + } + result = buttonfunc(tmp->window, pts.x, pts.y, button, tmp->data); + tmp = NULL; + } + } + break; + case WM_LBUTTONUP: + { + POINTS pts = MAKEPOINTS(mp2); + int (*buttonfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction; + + if(hWnd == tmp->window) + { + int button; + + switch(origmsg) + { + case WM_LBUTTONUP: + button = 1; + break; + case WM_RBUTTONUP: + button = 2; + break; + case WM_MBUTTONUP: + button = 3; + break; + } + result = buttonfunc(tmp->window, pts.x, pts.y, button, tmp->data); + tmp = NULL; + } + } + break; + case WM_MOUSEMOVE: + { + POINTS pts = MAKEPOINTS(mp2); + int (*motionfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction; + + if(hWnd == tmp->window) + { + int keys = 0; + + if (mp1 & MK_LBUTTON) + keys = DW_BUTTON1_MASK; + if (mp1 & MK_RBUTTON) + keys |= DW_BUTTON2_MASK; + if (mp1 & MK_MBUTTON) + keys |= DW_BUTTON3_MASK; + + result = motionfunc(tmp->window, pts.x, pts.y, keys, tmp->data); + tmp = NULL; + } + } + break; + case WM_CHAR: + { + int (*keypressfunc)(HWND, int, void *) = tmp->signalfunction; + + if(hWnd == tmp->window) + { + result = keypressfunc(tmp->window, LOWORD(mp2), tmp->data); + tmp = NULL; + } + } + break; + case WM_CLOSE: + { + int (*closefunc)(HWND, void *) = tmp->signalfunction; + + if(hWnd == tmp->window) + { + result = closefunc(tmp->window, tmp->data); + tmp = NULL; + } + } + break; + case WM_PAINT: + { + PAINTSTRUCT ps; + DWExpose exp; + int (*exposefunc)(HWND, DWExpose *, void *) = tmp->signalfunction; + + if(hWnd == tmp->window) + { + BeginPaint(hWnd, &ps); + exp.x = ps.rcPaint.left; + exp.y = ps.rcPaint.top; + exp.width = ps.rcPaint.right - ps.rcPaint.left; + exp.height = ps.rcPaint.bottom - ps.rcPaint.top; + result = exposefunc(hWnd, &exp, tmp->data); + EndPaint(hWnd, &ps); + } + } + break; + case WM_COMMAND: + { + int (*clickfunc)(HWND, void *) = tmp->signalfunction; + HWND command; + ULONG passthru = (ULONG)LOWORD(mp1); + ULONG message = HIWORD(mp1); + + command = (HWND)passthru; + + if(message == LBN_SELCHANGE || message == CBN_SELCHANGE) + { + int (*listboxselectfunc)(HWND, int, void *) = tmp->signalfunction; + + if(tmp->message == LBN_SELCHANGE && tmp->window == (HWND)mp2) + { + result = listboxselectfunc(tmp->window, dw_listbox_selected(tmp->window), tmp->data); + tmp = NULL; + } + } /* Make sure it's the right window, and the right ID */ + else if(tmp->window < (HWND)65536 && command == tmp->window) + { + result = clickfunc(tmp->window, tmp->data); + tmp = NULL; + } + } + break; + } + } + if(tmp) + tmp = tmp->next; + } + command_active = 0; + } +#endif + + /* Now that any handlers are done... do normal processing */ + switch( msg ) + { + case WM_PAINT: + { + PAINTSTRUCT ps; + + BeginPaint(hWnd, &ps); + EndPaint(hWnd, &ps); + } + break; + case WM_SIZE: + { + static int lastx = -1, lasty = -1; + static HWND lasthwnd = 0; + + if(lastx != LOWORD(mp2) || lasty != HIWORD(mp2) || lasthwnd != hWnd) + { + Box *mybox = (Box *)GetWindowLong(hWnd, GWL_USERDATA); + + lastx = LOWORD(mp2); + lasty = HIWORD(mp2); + lasthwnd = hWnd; + + _do_resize(mybox,LOWORD(mp2),HIWORD(mp2)); + } + } + break; + case WM_CHAR: + if(LOWORD(mp1) == '\t') + { + _shift_focus(hWnd); + return TRUE; + } + break; + case WM_USER: + windowfunc = (void *)mp1; + + if(windowfunc) + windowfunc((void *)mp2); + break; + case WM_NOTIFY: + { + NMHDR FAR *tem=(NMHDR FAR *)mp2; + + if(tem->code == TCN_SELCHANGING) + { + int num=TabCtrl_GetCurSel(tem->hwndFrom); + NotebookPage **array = (NotebookPage **)GetWindowLong(tem->hwndFrom, GWL_USERDATA); + + if(num > -1 && array && array[num]) + SetParent(array[num]->hwnd, DW_HWND_OBJECT); + + } + else if(tem->code == TCN_SELCHANGE) + { + int num=TabCtrl_GetCurSel(tem->hwndFrom); + NotebookPage **array = (NotebookPage **)GetWindowLong(tem->hwndFrom, GWL_USERDATA); + + if(num > -1 && array && array[num]) + SetParent(array[num]->hwnd, tem->hwndFrom); + + _resize_notebook_page(tem->hwndFrom, num); + } + } + break; + case WM_GETMINMAXINFO: + { + MINMAXINFO *info = (MINMAXINFO *)mp2; + info->ptMinTrackSize.x = 8; + info->ptMinTrackSize.y = 8; + return 0; + } + break; + case WM_DESTROY: + /* Free memory before destroying */ +#if 0 + /* Is this the right message? I seem to be + * getting WM_DESTROY on windows that aren't + * being destroyed. + */ + _free_window_memory(hWnd, 0); + EnumChildWindows(hWnd, _free_window_memory, 0); +#endif + break; + } + if(filterfunc && result != -1) + return result; + else + return DefWindowProc(hWnd, msg, mp1, mp2); +} + +BOOL CALLBACK _framewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) +{ + switch( msg ) + { + case WM_LBUTTONDOWN: + case WM_MBUTTONDOWN: + case WM_RBUTTONDOWN: + SetActiveWindow(hWnd); + break; + case WM_COMMAND: + case WM_NOTIFY: + _wndproc(hWnd, msg, mp1, mp2); + break; + } + return DefWindowProc(hWnd, msg, mp1, mp2); +} + +BOOL CALLBACK _rendwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) +{ + switch( msg ) + { + case WM_LBUTTONDOWN: + case WM_MBUTTONDOWN: + case WM_RBUTTONDOWN: + SetActiveWindow(hWnd); + _wndproc(hWnd, msg, mp1, mp2); + break; + case WM_LBUTTONUP: + case WM_MBUTTONUP: + case WM_RBUTTONUP: + case WM_MOUSEMOVE: + case WM_PAINT: + case WM_SIZE: + case WM_COMMAND: + _wndproc(hWnd, msg, mp1, mp2); + break; + } + return DefWindowProc(hWnd, msg, mp1, mp2); +} + +BOOL CALLBACK _spinnerwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) +{ + ColorInfo *cinfo; + + cinfo = (ColorInfo *)GetWindowLong(hWnd, GWL_USERDATA); + + if(cinfo) + { + switch( msg ) + { + case WM_LBUTTONDOWN: + case WM_MBUTTONDOWN: + case WM_RBUTTONDOWN: + case WM_CHAR: + { + BOOL ret; + + if(!cinfo || !cinfo->pOldProc) + ret = DefWindowProc(hWnd, msg, mp1, mp2); + ret = CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2); + + /* Tell the edit control that a buttonpress has + * occured and to update it's window title. + */ + if(cinfo->buddy) + SendMessage(cinfo->buddy, WM_USER+10, 0, 0); + + return ret; + } + break; + case WM_USER+10: + { + if(cinfo->buddy) + { + char tempbuf[100] = ""; + long position; + + GetWindowText(cinfo->buddy, tempbuf, 99); + + position = atol(tempbuf); + + if(IS_WIN98PLUS) + SendMessage(hWnd, UDM_SETPOS32, 0, (LPARAM)position); + else + SendMessage(hWnd, UDM_SETPOS, 0, (LPARAM)MAKELONG((short)position, 0)); + } + } + break; + } + } + + if(!cinfo || !cinfo->pOldProc) + return DefWindowProc(hWnd, msg, mp1, mp2); + return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2); +} + +BOOL CALLBACK _colorwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) +{ + ColorInfo *cinfo; + char tmpbuf[100]; + + cinfo = (ColorInfo *)GetWindowLong(hWnd, GWL_USERDATA); + + GetClassName(hWnd, tmpbuf, 99); + if(strcmp(tmpbuf, FRAMECLASSNAME) == 0) + cinfo = &(((Box *)cinfo)->cinfo); + + if(cinfo) + { + switch( msg ) + { + case WM_CHAR: + if(LOWORD(mp1) == '\t') + { + if(cinfo->buddy) + _shift_focus(cinfo->buddy); + else + _shift_focus(hWnd); + return FALSE; + } + /* Tell the spinner control that a keypress has + * occured and to update it's internal value. + */ + if(cinfo->buddy) + SendMessage(cinfo->buddy, WM_USER+10, 0, 0); + break; + case WM_USER+10: + { + if(cinfo->buddy) + { + long val, position; + char tmpbuf[100] = ""; + + GetWindowText(cinfo->buddy, tmpbuf, 99); + + position = atol(tmpbuf); + + if(IS_WIN98PLUS) + val = (long)SendMessage(cinfo->buddy, UDM_GETPOS32, 0, 0); + else + val = (long)SendMessage(cinfo->buddy, UDM_GETPOS, 0, 0); + + if(val != position) + { + sprintf(tmpbuf, "%d", val); + SetWindowText(hWnd, tmpbuf); + } + } + } + break; + case WM_KEYUP: + { + if(mp1 == VK_UP || mp1 == VK_DOWN) + { + if(cinfo->buddy) + PostMessage(hWnd, WM_USER+10, 0, 0); + } + } + break; + case WM_CTLCOLORSTATIC: + case WM_CTLCOLORLISTBOX: + case WM_CTLCOLORBTN: + case WM_CTLCOLOREDIT: + case WM_CTLCOLORMSGBOX: + case WM_CTLCOLORSCROLLBAR: + { + ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong((HWND)mp2, GWL_USERDATA); + if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1) + { + if(thiscinfo->fore > -1 && thiscinfo->back > -1 && + thiscinfo->fore < 18 && thiscinfo->back < 18) + { + SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore], + _green[thiscinfo->fore], + _blue[thiscinfo->fore])); + SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back], + _green[thiscinfo->back], + _blue[thiscinfo->back])); + SelectObject((HDC)mp1, _colors[thiscinfo->back]); + return (LRESULT)_colors[thiscinfo->back]; + } + if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR && (thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR) + { + SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore), + DW_GREEN_VALUE(thiscinfo->fore), + DW_BLUE_VALUE(thiscinfo->fore))); + SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back), + DW_GREEN_VALUE(thiscinfo->back), + DW_BLUE_VALUE(thiscinfo->back))); + DeleteObject(thiscinfo->hbrush); + thiscinfo->hbrush = CreateSolidBrush(RGB(DW_RED_VALUE(thiscinfo->back), + DW_GREEN_VALUE(thiscinfo->back), + DW_BLUE_VALUE(thiscinfo->back))); + return (LRESULT)thiscinfo->hbrush; + } + } + + } + break; + } + } + + if(!cinfo || !cinfo->pOldProc) + return DefWindowProc(hWnd, msg, mp1, mp2); + return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2); +} + +BOOL CALLBACK _containerwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) +{ + ContainerInfo *cinfo; + + cinfo = (ContainerInfo *)GetWindowLong(hWnd, GWL_USERDATA); + + switch( msg ) + { + case WM_COMMAND: + case WM_NOTIFY: + _wndproc(hWnd, msg, mp1, mp2); + break; +#ifndef NO_SIGNALS + case WM_LBUTTONDBLCLK: + case WM_CHAR: + { + LV_ITEM lvi; + int iItem; + + if(LOWORD(mp1) == '\t') + { + _shift_focus(hWnd); + return FALSE; + } + + if(msg == WM_CHAR && (char)mp1 != '\r') + break; + + iItem = ListView_GetNextItem(hWnd, -1, LVNI_FOCUSED); + + if(iItem > -1) + { + lvi.iItem = iItem; + lvi.mask = LVIF_PARAM; + + ListView_GetItem(hWnd, &lvi); + } + else + lvi.lParam = (LPARAM)NULL; + + { + SignalHandler *tmp = Root; + + while(tmp) + { + if(tmp->message == NM_DBLCLK && tmp->window == hWnd) + { + int (*containerselectfunc)(HWND, char *, void *) = tmp->signalfunction; + + /* Seems to be having lParam as 1 which really sucks */ + if(lvi.lParam < 100) + lvi.lParam = 0; + + containerselectfunc(tmp->window, (char *)lvi.lParam, tmp->data); + tmp = NULL; + } + if(tmp) + tmp = tmp->next; + } + } + } + break; + case WM_CONTEXTMENU: + { + LONG x,y; + LV_ITEM lvi; + int iItem; + + iItem = ListView_GetNextItem(hWnd, -1, LVNI_FOCUSED); + + if(iItem > -1) + { + lvi.iItem = iItem; + lvi.mask = LVIF_PARAM; + + ListView_GetItem(hWnd, &lvi); + } + else + lvi.lParam = (LPARAM)NULL; + + dw_pointer_query_pos(&x, &y); + + { + SignalHandler *tmp = Root; + + while(tmp) + { + if(tmp->message == NM_RCLICK && tmp->window == hWnd) + { + int (*containercontextfunc)(HWND, char *, int, int, void *) = tmp->signalfunction; + + /* Seems to be having lParam as 1 which really sucks */ + if(lvi.lParam < 100) + lvi.lParam = 0; + + containercontextfunc(tmp->window, (char *)lvi.lParam, x, y, tmp->data); + tmp = NULL; + } + if(tmp) + tmp = tmp->next; + } + } + } + break; +#else + case WM_CHAR: + if(LOWORD(mp1) == '\t') + { + _shift_focus(hWnd); + return FALSE; + } + break; +#endif + } + + if(!cinfo || !cinfo->pOldProc) + return DefWindowProc(hWnd, msg, mp1, mp2); + return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2); +} + +void _changebox(Box *thisbox, int percent, int type) +{ + int z; + + for(z=0;z<thisbox->count;z++) + { + if(thisbox->items[z].type == TYPEBOX) + { + Box *tmp = (Box*)GetWindowLong(thisbox->items[z].hwnd, GWL_USERDATA); + _changebox(tmp, percent, type); + } + else + { + if(type == BOXHORZ) + { + if(thisbox->items[z].hsize == SIZEEXPAND) + thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0))); + } + else + { + if(thisbox->items[z].vsize == SIZEEXPAND) + thisbox->items[z].height = (int)(((float)thisbox->items[z].origheight) * (((float)percent)/((float)100.0))); + } + } + } +} + +/* This handles any activity on the splitbars (sizers) */ +BOOL CALLBACK _splitwndproc(HWND hwnd, UINT msg, WPARAM mp1, LPARAM mp2) +{ + HWND hwndFrame = 0; + Box *thisbox = 0; + + hwndFrame = GetParent(hwnd); + if(hwndFrame) + thisbox = (Box *)GetWindowLong(hwndFrame, GWL_USERDATA); + + switch (msg) + { + case WM_ACTIVATE: + case WM_SETFOCUS: + return FALSE; + + case WM_PAINT: + { + HDC hdcPaint; + PAINTSTRUCT ps; + POINT ptlStart[SPLITBAR_WIDTH]; + POINT ptlEnd[SPLITBAR_WIDTH]; + RECT rcPaint; + USHORT i; + + hdcPaint = BeginPaint(hwnd, &ps); + GetWindowRect(hwnd, &rcPaint); + + if(thisbox->type == BOXHORZ) + { + for(i = 0; i < SPLITBAR_WIDTH; i++) + { + ptlStart[i].x = i; + ptlStart[i].y = 0; + + ptlEnd[i].x = i; + ptlEnd[i].y = rcPaint.bottom - rcPaint.top; + } + } + else + { + for(i = 0; i < SPLITBAR_WIDTH; i++) + { + ptlStart[i].x = 0; + ptlStart[i].y = i; + + ptlEnd[i].x = rcPaint.right - rcPaint.left; + ptlEnd[i].y = i; + } + } + + for(i = 0; i < SPLITBAR_WIDTH; i++) + { + HPEN hPen; + HPEN hOldPen; + + hPen = CreatePen(PS_SOLID, 1, RGB (_red[lColor[i]], _green[lColor[i]], _blue[lColor[i]])); + hOldPen = (HPEN)SelectObject(hdcPaint, hPen); + MoveToEx(hdcPaint, ptlStart[i].x, ptlStart[i].y, NULL); + LineTo(hdcPaint, ptlEnd[i].x, ptlEnd[i].y); + SelectObject(hdcPaint, hOldPen); + DeleteObject(hPen); + } + EndPaint(hwnd, &ps); + } + return FALSE; + case WM_MOUSEMOVE: + { + if(thisbox->type == BOXHORZ) + SetCursor(LoadCursor(NULL, IDC_SIZEWE)); + else + SetCursor(LoadCursor(NULL, IDC_SIZENS)); + } + return FALSE; +#if 0 + case WM_BUTTON1DOWN: + { + ULONG rc; + RECTL rclFrame; + RECTL rclBounds; + RECTL rclStart; + USHORT startSize, orig, actual; + + GetWindowRect(hwnd, &rclFrame); + GetWindowRect(hwnd, &rclStart); + + GetWindowRect(hwndFrame, &rclBounds); + + WinMapWindowPoints(hwndFrame, HWND_DESKTOP, + (PPOINTL)&rclBounds, 2); + WinMapWindowPoints(hwnd, HWND_DESKTOP, + (PPOINTL)&rclStart, 2); + + if(thisbox->type == BOXHORZ) + { + orig = thisbox->items[0].origwidth; + actual = thisbox->items[0].width; + + startSize = (rclStart.xLeft - rclBounds.xLeft) + * (((float)orig)/((float)actual)); + } + else + { + orig = thisbox->items[0].origheight; + actual = thisbox->items[0].height; + + startSize = (rclStart.yBottom - rclBounds.yBottom) + * (((float)actual)/((float)orig)); + } + + rc = _TrackRectangle(hwnd, &rclFrame, &rclBounds); + + if(rc == TRUE) + { + USHORT usNewRB; + USHORT usSize; + USHORT percent; + int z; + + if(thisbox->type == BOXHORZ) + { + usNewRB = rclFrame.xLeft + - rclBounds.xLeft; + usSize = rclBounds.xRight + - rclBounds.xLeft; + } + else + { + usNewRB = rclFrame.yBottom + - rclBounds.yBottom; + usSize = rclBounds.yTop + - rclBounds.yBottom; + } + + percent = (usNewRB*100)/startSize; + + for(z=0;z<thisbox->count;z++) + { + if(thisbox->items[z].type == TYPEBOX) + { + Box *tmp = (Box *)GetWindowLong(thisbox->items[z].hwnd, GWL_USERDATA); + _changebox(tmp, percent, thisbox->type); + } + else + { + if(thisbox->items[z].hwnd == hwnd) + percent = (startSize*100)/usNewRB; + + if(thisbox->type == BOXHORZ) + { + if(thisbox->items[z].hsize == SIZEEXPAND) + thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0))); + } + else + { + if(thisbox->items[z].vsize == SIZEEXPAND) + thisbox->items[z].height = (int)(((float)thisbox->items[z].origheight) * (((float)percent)/((float)100.0))); + } + } + } + + _ResetWindow(GetWindow(hwnd, GW_OWNER)); + } + } + return MRFROMSHORT(FALSE); +#endif + } + return DefWindowProc(hwnd, msg, mp1, mp2); +} + +/* Function: _BtProc + * Abstract: Subclass procedure for buttons + */ + +BOOL CALLBACK _BtProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2) +{ + BubbleButton *bubble; + static int bMouseOver = 0; + POINT point; + RECT rect; + + bubble = (BubbleButton *)GetWindowLong(hwnd, GWL_USERDATA); + + if(!bubble) + return DefWindowProc(hwnd, msg, mp1, mp2); + + switch(msg) + { +#ifndef NO_SIGNALS + case WM_LBUTTONUP: + { + SignalHandler *tmp = Root; + + /* Find any callbacks for this function */ + while(tmp) + { + if(tmp->message == WM_COMMAND) + { + int (*clickfunc)(HWND, void *) = tmp->signalfunction; + + /* Make sure it's the right window, and the right ID */ + if(tmp->window == hwnd) + { + clickfunc(tmp->window, tmp->data); + tmp = NULL; + } + } + if(tmp) + tmp= tmp->next; + } + } + break; +#endif + case WM_CHAR: + { +#ifndef NO_SIGNALS + /* A button press should also occur for an ENTER or SPACE press + * while the button has the active input focus. + */ + if(LOWORD(mp1) == '\r' || LOWORD(mp1) == ' ') + { + SignalHandler *tmp = Root; + + /* Find any callbacks for this function */ + while(tmp) + { + if(tmp->message == WM_COMMAND) + { + int (*clickfunc)(HWND, void *) = tmp->signalfunction; + + /* Make sure it's the right window, and the right ID */ + if(tmp->window == hwnd) + { + clickfunc(tmp->window, tmp->data); + tmp = NULL; + } + } + if(tmp) + tmp= tmp->next; + } + } +#endif + if(LOWORD(mp1) == '\t') + { + _shift_focus(hwnd); + return FALSE; + } + } + break; + case WM_TIMER: + if (hwndBubble) + { + DestroyWindow(hwndBubble); + hwndBubble = 0; + KillTimer(hwnd, 1); + } + break; + + case WM_MOUSEMOVE: + GetCursorPos(&point); + GetWindowRect(hwnd, &rect); + + if(PtInRect(&rect, point)){ + if(hwnd != GetCapture()){ + SetCapture(hwnd); + } + if(!bMouseOver){ + bMouseOver = 1; + if(!*bubble->bubbletext) + break; + + if(hwndBubble) + { + DestroyWindow(hwndBubble); + hwndBubble = 0; + KillTimer(hwndBubbleLast, 1); + } + + if(!hwndBubble) + { + POINTL ptlWork = {0,0}; + ULONG ulColor = DW_CLR_YELLOW; + SIZE size; + HDC hdc; + RECT rect; + void *oldproc; + + /* Use the WS_EX_TOOLWINDOW extended style + * so the window doesn't get listed in the + * taskbar. + */ + hwndBubble = CreateWindowEx(WS_EX_TOOLWINDOW, + STATICCLASSNAME, + bubble->bubbletext, + BS_TEXT | WS_POPUP | + WS_BORDER | + SS_CENTER, + 0,0,50,20, + HWND_DESKTOP, + NULL, + NULL, + NULL); + + dw_window_set_font(hwndBubble, DefaultFont); + dw_window_set_color(hwndBubble, DW_CLR_BLACK, DW_CLR_YELLOW); + + hwndBubbleLast = hwnd; + + SetTimer(hwnd, 1, 3000, NULL); + + hdc = GetDC(hwndBubble); + + GetTextExtentPoint(hdc, bubble->bubbletext, strlen(bubble->bubbletext), &size); + + MapWindowPoints(hwnd, HWND_DESKTOP, (LPPOINT)&ptlWork, 1); + + GetWindowRect(hwnd, &rect); + + SetWindowPos(hwndBubble, + HWND_TOP, + ptlWork.x, + ptlWork.y + (rect.bottom-rect.top) + 1, + size.cx + 2, + size.cy + 2, + SWP_NOACTIVATE | SWP_SHOWWINDOW); + + } + } + } + else{ + /* Calling ReleaseCapture in Win95 also causes WM_CAPTURECHANGED + * to be sent. Be sure to account for that. + */ + ReleaseCapture(); + + if(bMouseOver){ + bMouseOver = 0; + DestroyWindow(hwndBubble); + hwndBubble = 0; + KillTimer(hwndBubbleLast, 1); + } + } + break; + case WM_CAPTURECHANGED: + /* This message means we are losing the capture for some reason + * Either because we intentionally lost it or another window + * stole it + */ + if(bMouseOver){ + bMouseOver = 0; + DestroyWindow(hwndBubble); + hwndBubble = 0; + KillTimer(hwndBubbleLast, 1); + } + break; + } + + if(!bubble->pOldProc) + return DefWindowProc(hwnd, msg, mp1, mp2); + return CallWindowProc(bubble->pOldProc, hwnd, msg, mp1, mp2); +} + +void _resize_notebook_page(HWND handle, int pageid) +{ + RECT rect; + NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); + + if(array && array[pageid]) + { + Box *box = (Box *)GetWindowLong(array[pageid]->hwnd, GWL_USERDATA); + + GetClientRect(handle,&rect); + TabCtrl_AdjustRect(handle,FALSE,&rect); + MoveWindow(array[pageid]->hwnd,rect.left,rect.top, + rect.right - rect.left,rect.bottom-rect.top, + TRUE); + if(box) + _do_resize(box, rect.right - rect.left, rect.bottom - rect.top); + + ShowWindow(array[pageid]->hwnd,SW_SHOWNORMAL); + } +} + +/* + * Initializes the Dynamic Windows engine. + * Parameters: + * newthread: True if this is the only thread. + * False if there is already a message loop running. + */ +int dw_init(int newthread) +{ + WNDCLASS wc; + int z; + INITCOMMONCONTROLSEX icc; + + icc.dwSize = sizeof(INITCOMMONCONTROLSEX); + icc.dwICC = ICC_WIN95_CLASSES; + + InitCommonControlsEx(&icc); + + memset(lookup, 0, sizeof(HICON) * ICON_INDEX_LIMIT); + + memset(&wc, 0, sizeof(WNDCLASS)); + wc.style = CS_DBLCLKS /*| CS_HREDRAW | CS_VREDRAW*/; + wc.lpfnWndProc = (WNDPROC)_wndproc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 32; + wc.hbrBackground = NULL; + wc.lpszMenuName = NULL; + wc.lpszClassName = ClassName; + + RegisterClass(&wc); + + memset(&wc, 0, sizeof(WNDCLASS)); + wc.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = (WNDPROC)_splitwndproc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hbrBackground = NULL; + wc.lpszMenuName = NULL; + wc.lpszClassName = SplitbarClassName; + + RegisterClass(&wc); + + memset(&wc, 0, sizeof(WNDCLASS)); + wc.style = CS_DBLCLKS /*| CS_HREDRAW | CS_VREDRAW*/; + wc.lpfnWndProc = (WNDPROC)_framewndproc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 32; + wc.hbrBackground = (HBRUSH)COLOR_WINDOW; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.lpszMenuName = NULL; + wc.lpszClassName = FRAMECLASSNAME; + + for(z=0;z<18;z++) + _colors[z] = CreateSolidBrush(RGB(_red[z],_green[z],_blue[z])); + + RegisterClass(&wc); + + memset(&wc, 0, sizeof(WNDCLASS)); + wc.style = 0; + wc.lpfnWndProc = (WNDPROC)_wndproc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hbrBackground = NULL; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.lpszMenuName = NULL; + wc.lpszClassName = ObjectClassName; + + RegisterClass(&wc); + + /* Since Windows 95/98/NT don't have a HWND_OBJECT class + * also known as a input only window, I will create a + * temporary window that isn't visible and really does nothing + * except temporarily hold the child windows before they are + * packed into their correct parent. + */ + + DW_HWND_OBJECT = CreateWindow(ObjectClassName, "", 0, 0, 0, + 0, 0, HWND_DESKTOP, NULL, NULL, NULL); + + if(!DW_HWND_OBJECT) + { + dw_messagebox("Dynamic Windows", "Could not initialize the object window. error code %d", GetLastError()); + exit(1); + } + +#ifdef DWDEBUG + f = fopen("dw.log", "wt"); +#endif + /* We need the version to check capability like up-down controls */ + dwVersion = GetVersion(); + + _hPen = CreatePen(PS_SOLID, 1, _foreground); + _hBrush = CreateSolidBrush(_foreground); + + return 0; +} + +/* + * Runs a message loop for Dynamic Windows. + * Parameters: + * currenthab: The handle to the current anchor block + * or NULL if this DW is handling the message loop. + * func: Function pointer to the message filter function. + */ +void dw_main(HAB currenthab, void *func) +{ + MSG msg; + + /* Setup the filter function */ + filterfunc = func; + + while (GetMessage(&msg,NULL,0,0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + +#ifdef DWDEBUG + fclose(f); +#endif +} + +/* + * Free's memory allocated by dynamic windows. + * Parameters: + * ptr: Pointer to dynamic windows allocated + * memory to be free()'d. + */ +void dw_free(void *ptr) +{ + free(ptr); +} + +/* + * Allocates and initializes a dialog struct. + * Parameters: + * data: User defined data to be passed to functions. + */ +DWDialog *dw_dialog_new(void *data) +{ + DWDialog *tmp = malloc(sizeof(DWDialog)); + + tmp->eve = dw_event_new(); + dw_event_reset(tmp->eve); + tmp->data = data; + tmp->done = FALSE; + tmp->result = NULL; + + return tmp; +} + +/* + * Accepts a dialog struct and returns the given data to the + * initial called of dw_dialog_wait(). + * Parameters: + * dialog: Pointer to a dialog struct aquired by dw_dialog_new). + * result: Data to be returned by dw_dialog_wait(). + */ +int dw_dialog_dismiss(DWDialog *dialog, void *result) +{ + dialog->result = result; + dw_event_post(dialog->eve); + dialog->done = TRUE; + return 0; +} + +/* + * Accepts a dialog struct waits for dw_dialog_dismiss() to be + * called by a signal handler with the given dialog struct. + * Parameters: + * dialog: Pointer to a dialog struct aquired by dw_dialog_new). + */ +void *dw_dialog_wait(DWDialog *dialog) +{ + MSG msg; + void *tmp; + + while (GetMessage(&msg,NULL,0,0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + if(dialog->done) + break; + } + dw_event_close(&dialog->eve); + tmp = dialog->result; + free(dialog); + return tmp; +} + +/* + * Displays a Message Box with given text and title.. + * Parameters: + * title: The title of the message box. + * format: printf style format string. + * ...: Additional variables for use in the format. + */ +int dw_messagebox(char *title, char *format, ...) +{ + va_list args; + char outbuf[256]; + + va_start(args, format); + vsprintf(outbuf, format, args); + va_end(args); + + MessageBox(HWND_DESKTOP, outbuf, title, MB_OK); + + return strlen(outbuf); +} + +/* + * Displays a Message Box with given text and title.. + * Parameters: + * title: The title of the message box. + * text: The text to display in the box. + * Returns: + * True if YES False of NO. + */ +int dw_yesno(char *title, char *text) +{ + if(MessageBox(HWND_DESKTOP, text, title, MB_YESNO)==IDYES) + return TRUE; + return FALSE; +} + +/* + * Makes the window visible. + * Parameters: + * handle: The window handle to make visible. + */ +int dw_window_show(HWND handle) +{ + int rc = ShowWindow(handle, TRUE); + SetFocus(handle); + _initial_focus(handle); + return rc; +} + +/* + * Makes the window invisible. + * Parameters: + * handle: The window handle to make visible. + */ +int dw_window_hide(HWND handle) +{ + return ShowWindow(handle, FALSE); +} + +/* + * Destroys a window and all of it's children. + * Parameters: + * handle: The window handle to destroy. + */ +int dw_window_destroy(HWND handle) +{ + return DestroyWindow(handle); +} + +/* + * Changes a window's parent to newparent. + * Parameters: + * handle: The window handle to destroy. + * newparent: The window's new parent window. + */ +void dw_window_reparent(HWND handle, HWND newparent) +{ + SetParent(handle, newparent); +} + +HFONT _aquire_font(char *fontname) +{ + HFONT hfont; + int z, size = 9; + LOGFONT lf; + + if(fontname == DefaultFont) + hfont = GetStockObject(DEFAULT_GUI_FONT); + else + { + for(z=0;z<strlen(fontname);z++) + { + if(fontname[z]=='.') + break; + } + size = atoi(fontname) + 5; + + lf.lfHeight = size; + lf.lfWidth = 0; + lf.lfEscapement = 0; + lf.lfOrientation = 0; + lf.lfItalic = 0; + lf.lfUnderline = 0; + lf.lfStrikeOut = 0; + lf.lfWeight = FW_NORMAL; + lf.lfCharSet = DEFAULT_CHARSET; + lf.lfOutPrecision = 0; + lf.lfClipPrecision = 0; + lf.lfQuality = DEFAULT_QUALITY; + lf.lfPitchAndFamily = DEFAULT_PITCH | FW_DONTCARE; + strcpy(lf.lfFaceName, &fontname[z+1]); + + hfont = CreateFontIndirect(&lf); + } + return hfont; +} + +/* + * Sets the font used by a specified window (widget) handle. + * Parameters: + * handle: The window (widget) handle. + * fontname: Name and size of the font in the form "size.fontname" + */ +int dw_window_set_font(HWND handle, char *fontname) +{ + HFONT hfont = _aquire_font(fontname); + ColorInfo *cinfo; + + cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); + + if(fontname) + { + if(cinfo) + { + strcpy(cinfo->fontname, fontname); + } + else + { + cinfo = calloc(1, sizeof(ColorInfo)); + cinfo->fore = cinfo->back = -1; + cinfo->buddy = 0; + + strcpy(cinfo->fontname, fontname); + + cinfo->pOldProc = SubclassWindow(handle, _colorwndproc); + SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo); + } + } + SendMessage(handle, WM_SETFONT, (WPARAM)hfont, FALSE); + return 0; +} + +/* + * Sets the colors used by a specified window (widget) handle. + * Parameters: + * handle: The window (widget) handle. + * fore: Foreground color in RGB format. + * back: Background color in RGB format. + */ +int dw_window_set_color(HWND handle, ULONG fore, ULONG back) +{ + ColorInfo *cinfo; + char tmpbuf[100]; + + cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); + + GetClassName(handle, tmpbuf, 99); + + if(strnicmp(tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME))==0) + return FALSE; + + if(cinfo) + { + cinfo->fore = fore; + cinfo->back = back; + } + else + { + cinfo = calloc(1, sizeof(ColorInfo)); + + cinfo->fore = fore; + cinfo->back = back; + cinfo->buddy = 0; + + cinfo->pOldProc = SubclassWindow(handle, _colorwndproc); + SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo); + } + return TRUE; +} + +/* + * Sets the font used by a specified window (widget) handle. + * Parameters: + * handle: The window (widget) handle. + * border: Size of the window border in pixels. + */ +int dw_window_set_border(HWND handle, int border) +{ + return 0; +} + +/* + * Captures the mouse input to this window. + * Parameters: + * handle: Handle to receive mouse input. + */ +void dw_window_capture(HWND handle) +{ + SetCapture(handle); +} + +/* + * Releases previous mouse capture. + */ +void dw_window_release(void) +{ + ReleaseCapture(); +} + +/* + * Create a new Window Frame. + * Parameters: + * owner: The Owner's window handle or HWND_DESKTOP. + * title: The Window title. + * flStyle: Style flags, see the DW reference. + */ +HWND dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) +{ + HWND hwndframe; + Box *newbox = malloc(sizeof(Box)); + + newbox->pad = 0; + newbox->type = BOXVERT; + newbox->count = 0; + + if(!(flStyle & WS_CAPTION)) + flStyle |= WS_POPUPWINDOW; + if(flStyle & DW_FCF_TASKLIST) + { + ULONG newflags = (flStyle | WS_CLIPCHILDREN) & ~DW_FCF_TASKLIST; + hwndframe = CreateWindow(ClassName, title, newflags, CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner, NULL, NULL, NULL); + } + else + hwndframe = CreateWindowEx(WS_EX_TOOLWINDOW, ClassName, title, flStyle | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner, NULL, NULL, NULL); + SetWindowLong(hwndframe, GWL_USERDATA, (ULONG)newbox); + + return hwndframe; +} + +/* + * Create a new Box to be packed. + * Parameters: + * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). + * pad: Number of pixels to pad around the box. + */ +HWND dw_box_new(int type, int pad) +{ + Box *newbox = malloc(sizeof(Box)); + HWND hwndframe; + + newbox->pad = pad; + newbox->type = type; + newbox->count = 0; + newbox->grouphwnd = (HWND)NULL; + + hwndframe = CreateWindow(FRAMECLASSNAME, + "", + WS_CHILD | WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + NULL, + NULL, + NULL); + + newbox->cinfo.pOldProc = SubclassWindow(hwndframe, _colorwndproc); + newbox->cinfo.fore = newbox->cinfo.back = -1; + + SetWindowLong(hwndframe, GWL_USERDATA, (ULONG)newbox); + return hwndframe; +} + +/* + * Create a new Group Box to be packed. + * Parameters: + * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). + * pad: Number of pixels to pad around the box. + * title: Text to be displayined in the group outline. + */ +HWND dw_groupbox_new(int type, int pad, char *title) +{ + Box *newbox = malloc(sizeof(Box)); + HWND hwndframe; + + newbox->pad = pad; + newbox->type = type; + newbox->count = 0; + + hwndframe = CreateWindow(FRAMECLASSNAME, + "", + WS_CHILD, + 0,0,2000,1000, + DW_HWND_OBJECT, + NULL, + NULL, + NULL); + + newbox->grouphwnd = CreateWindow(BUTTONCLASSNAME, + title, + WS_CHILD | BS_GROUPBOX | + WS_VISIBLE | WS_CLIPCHILDREN, + 0,0,2000,1000, + hwndframe, + NULL, + NULL, + NULL); + + SetWindowLong(hwndframe, GWL_USERDATA, (ULONG)newbox); + dw_window_set_font(newbox->grouphwnd, DefaultFont); + return hwndframe; +} + +/* + * Create a bitmap object to be packed. + * Parameters: + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_bitmap_new(ULONG id) +{ + return CreateWindow(STATICCLASSNAME, + "", + SS_BITMAP | WS_CHILD | WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + NULL, + NULL, + NULL); +} + +/* + * Create a notebook object to be packed. + * Parameters: + * id: An ID to be used for getting the resource from the + * resource file. + */ +HWND dw_notebook_new(ULONG id, int top) +{ + ULONG flags = 0; + HWND tmp; + NotebookPage **array = calloc(256, sizeof(NotebookPage *)); + + if(!top) + flags = TCS_BOTTOM; + + tmp = CreateWindow(WC_TABCONTROL, + "", + WS_CHILD | WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + NULL, + NULL, + NULL); + SetWindowLong(tmp, GWL_USERDATA, (ULONG)array); + dw_window_set_font(tmp, DefaultFont); + return tmp; +} + +/* + * Create a menu object to be popped up. + * Parameters: + * id: An ID to be used for getting the resource from the + * resource file. + */ +HMENUI dw_menu_new(ULONG id) +{ + HMENUI tmp = malloc(sizeof(struct _hmenui)); + + if(!tmp) + return NULL; + + tmp->menu = CreatePopupMenu(); + tmp->hwnd = NULL; + return tmp; +} + +/* + * Create a menubar on a window. + * Parameters: + * location: Handle of a window frame to be attached to. + */ +HMENUI dw_menubar_new(HWND location) +{ + HMENUI tmp = malloc(sizeof(struct _hmenui)); + + if(!tmp) + return NULL; + + tmp->menu = CreateMenu(); + tmp->hwnd = location; + + SetMenu(location, tmp->menu); + return tmp; +} + +/* + * Destroys a menu created with dw_menubar_new or dw_menu_new. + * Parameters: + * menu: Handle of a menu. + */ +void dw_menu_destroy(HMENUI *menu) +{ + if(menu && *menu) + { + DestroyMenu((*menu)->menu); + free(*menu); + *menu = NULL; + } +} + +/* + * Adds a menuitem or submenu to an existing menu. + * Parameters: + * menu: The handle the the existing menu. + * title: The title text on the menu item to be added. + * id: An ID to be used for message passing. + * end: If TRUE memu is positioned at the end of the menu. + * check: If TRUE menu is "check"able. + * flags: Extended attributes to set on the menu. + * submenu: Handle to an existing menu to be a submenu or NULL. + */ +HWND dw_menu_append_item(HMENUI menux, char *title, ULONG id, ULONG flags, int end, int check, HMENUI submenu) +{ + MENUITEMINFO mii; + HMENU menu; + + if(!menux) + return NULL; + + menu = menux->menu; + + mii.cbSize = sizeof(MENUITEMINFO); + mii.fMask = MIIM_ID | MIIM_SUBMENU | MIIM_TYPE; + + /* Convert from OS/2 style accellerators to Win32 style */ + if(title) + { + char *tmp = title; + + while(*tmp) + { + if(*tmp == '~') + *tmp = '&'; + tmp++; + } + } + + if(title && *title) + mii.fType = MFT_STRING; + else + mii.fType = MFT_SEPARATOR; + + mii.wID = id; + mii.hSubMenu = submenu ? submenu->menu : 0; + mii.dwTypeData = title; + mii.cch = strlen(title); + + InsertMenuItem(menu, 65535, TRUE, &mii); + if(menux->hwnd) + DrawMenuBar(menux->hwnd); + return (HWND)id; +} + +/* + * Sets the state of a menu item check. + * Parameters: + * menu: The handle the the existing menu. + * id: Menuitem id. + * check: TRUE for checked FALSE for not checked. + */ +void dw_menu_item_set_check(HMENUI menux, int id, int check) +{ + MENUITEMINFO mii; + HMENU menu; + + if(!menux) + return; + + menu = menux->menu; + + mii.cbSize = sizeof(MENUITEMINFO); + mii.fMask = MIIM_STATE; + if(check) + mii.fState = MFS_CHECKED; + else + mii.fState = MFS_UNCHECKED; + SetMenuItemInfo(menu, id, FALSE, &mii); +} + +/* + * Pops up a context menu at given x and y coordinates. + * Parameters: + * menu: The handle the the existing menu. + * parent: Handle to the window initiating the popup. + * x: X coordinate. + * y: Y coordinate. + */ +void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) +{ + if(menu && *menu) + { + TrackPopupMenu((*menu)->menu, 0, x, y, 0, parent, NULL); + free(*menu); + *menu = NULL; + } +} + + +/* + * Create a container object to be packed. + * Parameters: + * id: An ID to be used for getting the resource from the + * resource file. + */ +HWND dw_container_new(ULONG id) +{ + HWND tmp = CreateWindow(WC_LISTVIEW, + "", + WS_CHILD | LVS_REPORT | + LVS_SHAREIMAGELISTS | WS_BORDER | + WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + (HMENU)id, + NULL, + NULL); + ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo)); + + if(!cinfo) + { + DestroyWindow(tmp); + return NULL; + } + + cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _containerwndproc); + + SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo); + dw_window_set_font(tmp, DefaultFont); + return tmp; +} + +/* + * Returns the current X and Y coordinates of the mouse pointer. + * Parameters: + * x: Pointer to variable to store X coordinate. + * y: Pointer to variable to store Y coordinate. + */ +void dw_pointer_query_pos(long *x, long *y) +{ + POINT ptl; + + GetCursorPos(&ptl); + if(x && y) + { + *x = ptl.x; + *y = ptl.y; + } +} + +/* + * Sets the X and Y coordinates of the mouse pointer. + * Parameters: + * x: X coordinate. + * y: Y coordinate. + */ +void dw_pointer_set_pos(long x, long y) +{ + SetCursorPos(x, y); +} + +/* + * Create a new static text window (widget) to be packed. + * Parameters: + * text: The text to be display by the static text widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_text_new(char *text, ULONG id) +{ + HWND tmp = CreateWindow(STATICCLASSNAME, + text, + BS_TEXT | WS_CHILD | WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + (HMENU)id, + NULL, + NULL); + dw_window_set_font(tmp, DefaultFont); + return tmp; +} + +/* + * Create a new Multiline Editbox window (widget) to be packed. + * Parameters: + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_mle_new(ULONG id) +{ + + HWND tmp = CreateWindow(EDITCLASSNAME, + "", + WS_BORDER | ES_AUTOHSCROLL | + WS_VSCROLL | ES_MULTILINE | + ES_WANTRETURN | WS_CHILD | + WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + (HMENU)id, + NULL, + NULL); + dw_window_set_font(tmp, DefaultFont); + return tmp; +} + +/* + * Create a new Entryfield window (widget) to be packed. + * Parameters: + * text: The default text to be in the entryfield widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_entryfield_new(char *text, ULONG id) +{ + HWND tmp = CreateWindow(EDITCLASSNAME, + text, + ES_WANTRETURN | WS_CHILD | + WS_BORDER | ES_AUTOHSCROLL | + WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + (HMENU)id, + NULL, + NULL); + ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); + + cinfo->back = cinfo->fore = -1; + cinfo->buddy = 0; + + cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc); + SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo); + dw_window_set_font(tmp, DefaultFont); + return tmp; +} + +/* + * Create a new Entryfield passwird window (widget) to be packed. + * Parameters: + * text: The default text to be in the entryfield widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_entryfield_password_new(char *text, ULONG id) +{ + HWND tmp = CreateWindow(EDITCLASSNAME, + text, + ES_WANTRETURN | WS_CHILD | + ES_PASSWORD | WS_BORDER | + ES_AUTOHSCROLL | WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + (HMENU)id, + NULL, + NULL); + ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); + + cinfo->back = cinfo->fore = -1; + cinfo->buddy = 0; + + cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc); + SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo); + dw_window_set_font(tmp, DefaultFont); + return tmp; +} + +/* + * Create a new Combobox window (widget) to be packed. + * Parameters: + * text: The default text to be in the combpbox widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_combobox_new(char *text, ULONG id) +{ + HWND tmp = CreateWindow(COMBOBOXCLASSNAME, + "", + WS_CHILD | CBS_DROPDOWN | WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + (HMENU)id, + NULL, + NULL); + ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo)); + + if(!cinfo) + { + DestroyWindow(tmp); + return NULL; + } + + cinfo->cinfo.fore = -1; + cinfo->cinfo.back = -1; + cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _containerwndproc); + + SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo); + dw_window_set_font(tmp, DefaultFont); + return tmp; +} + +/* + * Create a new button window (widget) to be packed. + * Parameters: + * text: The text to be display by the static text widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_button_new(char *text, ULONG id) +{ + BubbleButton *bubble = malloc(sizeof(BubbleButton)); + + HWND tmp = CreateWindow(BUTTONCLASSNAME, + text, + WS_CHILD | BS_PUSHBUTTON | WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + (HMENU)id, + NULL, + NULL); + + bubble->id = id; + bubble->bubbletext[0] = '\0'; + bubble->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc); + + SetWindowLong(tmp, GWL_USERDATA, (ULONG)bubble); + dw_window_set_font(tmp, DefaultFont); + return tmp; +} + +/* + * Create a new bitmap button window (widget) to be packed. + * Parameters: + * text: Bubble help text to be displayed. + * id: An ID of a bitmap in the resource file. + */ +HWND dw_bitmapbutton_new(char *text, ULONG id) +{ + HWND tmp; + BubbleButton *bubble = malloc(sizeof(BubbleButton)); + HBITMAP hbitmap = LoadBitmap(DWInstance, MAKEINTRESOURCE(id)); + + tmp = CreateWindow(BUTTONCLASSNAME, + "", + WS_CHILD | BS_PUSHBUTTON | + BS_BITMAP | WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + (HMENU)id, + NULL, + NULL); + + bubble->id = id; + strncpy(bubble->bubbletext, text, BUBBLE_HELP_MAX - 1); + bubble->bubbletext[BUBBLE_HELP_MAX - 1] = '\0'; + bubble->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc); + + SetWindowLong(tmp, GWL_USERDATA, (ULONG)bubble); + + SendMessage(tmp, BM_SETIMAGE, + (WPARAM) IMAGE_BITMAP, + (LPARAM) hbitmap); + return tmp; +} + +/* + * Create a new spinbutton window (widget) to be packed. + * Parameters: + * text: The text to be display by the static text widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_spinbutton_new(char *text, ULONG id) +{ + ULONG *data = malloc(sizeof(ULONG)); + HWND buddy = CreateWindow(EDITCLASSNAME, + text, + WS_CHILD | WS_BORDER | + ES_NUMBER | WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + NULL, + NULL, + NULL); + HWND tmp = CreateUpDownControl( + WS_CHILD | UDS_ALIGNRIGHT | + UDS_ARROWKEYS | UDS_SETBUDDYINT | + UDS_WRAP | UDS_NOTHOUSANDS, + 0, + 0, + 2000, + 1000, + DW_HWND_OBJECT, + id, + DWInstance, + buddy, + 0, + 100, + 0); + ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); + + cinfo->back = cinfo->fore = -1; + cinfo->buddy = tmp; + + cinfo->pOldProc = SubclassWindow(buddy, _colorwndproc); + SetWindowLong(buddy, GWL_USERDATA, (ULONG)cinfo); + + cinfo = calloc(1, sizeof(ColorInfo)); + cinfo->buddy = buddy; + cinfo->pOldProc = SubclassWindow(tmp, _spinnerwndproc); + + SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo); + dw_window_set_font(buddy, DefaultFont); + return tmp; +} + +/* + * Create a new radiobutton window (widget) to be packed. + * Parameters: + * text: The text to be display by the static text widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_radiobutton_new(char *text, ULONG id) +{ + HWND tmp = CreateWindow(BUTTONCLASSNAME, + text, + WS_CHILD | BS_AUTORADIOBUTTON | + WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + (HMENU)id, + NULL, + NULL); + + ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); + + cinfo->back = cinfo->fore = -1; + cinfo->buddy = 0; + cinfo->user = 0; + + cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc); + SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo); + dw_window_set_font(tmp, DefaultFont); + return tmp; +} + + +/* + * Create a new slider window (widget) to be packed. + * Parameters: + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_slider_new(ULONG id) +{ + return CreateWindow(PROGRESS_CLASS, + "", + WS_CHILD | WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + NULL, + NULL, + NULL); +} + +/* + * Create a new checkbox window (widget) to be packed. + * Parameters: + * text: The text to be display by the static text widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_checkbox_new(char *text, ULONG id) +{ + HWND tmp = CreateWindow(BUTTONCLASSNAME, + text, + WS_CHILD | BS_AUTOCHECKBOX | + BS_TEXT | WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + NULL, + NULL, + NULL); + ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); + + cinfo->back = cinfo->fore = -1; + cinfo->buddy = 0; + cinfo->user = 1; + + cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc); + SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo); + dw_window_set_font(tmp, DefaultFont); + return tmp; +} + +/* + * Create a new listbox window (widget) to be packed. + * Parameters: + * id: An ID to be used with WinWindowFromID() or 0L. + * multi: Multiple select TRUE or FALSE. + */ +HWND dw_listbox_new(ULONG id, int multi) +{ + HWND tmp = CreateWindow(LISTBOXCLASSNAME, + "", + LBS_NOINTEGRALHEIGHT | WS_CHILD | LBS_HASSTRINGS | + LBS_NOTIFY | WS_BORDER | WS_CLIPCHILDREN | + WS_VSCROLL | (multi ? LBS_EXTENDEDSEL : 0) , + 0,0,2000,1000, + DW_HWND_OBJECT, + NULL, + NULL, + NULL); + ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo)); + + if(!cinfo) + { + DestroyWindow(tmp); + return NULL; + } + + cinfo->cinfo.fore = -1; + cinfo->cinfo.back = -1; + cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _containerwndproc); + + SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo); + dw_window_set_font(tmp, DefaultFont); + return tmp; +} + +/* + * Sets the icon used for a given window. + * Parameters: + * handle: Handle to the window. + * id: An ID to be used to specify the icon. + */ +void dw_window_set_icon(HWND handle, ULONG id) +{ + HICON hicon = LoadIcon(DWInstance, MAKEINTRESOURCE(id)); + + SendMessage(handle, WM_SETICON, + (WPARAM) IMAGE_ICON, + (LPARAM) hicon); +} + +/* + * Sets the bitmap used for a given static window. + * Parameters: + * handle: Handle to the window. + * id: An ID to be used to specify the icon. + */ +void dw_window_set_bitmap(HWND handle, ULONG id) +{ + HBITMAP hbitmap = LoadBitmap(DWInstance, MAKEINTRESOURCE(id)); + + SendMessage(handle, STM_SETIMAGE, + (WPARAM) IMAGE_BITMAP, + (LPARAM) hbitmap); +} + +/* + * Sets the text used for a given window. + * Parameters: + * handle: Handle to the window. + * text: The text associsated with a given window. + */ +void dw_window_set_text(HWND handle, char *text) +{ + SetWindowText(handle, text); +} + +/* + * Gets the text used for a given window. + * Parameters: + * handle: Handle to the window. + * Returns: + * text: The text associsated with a given window. + */ +char *dw_window_get_text(HWND handle) +{ + char tempbuf[4096] = ""; + + GetWindowText(handle, tempbuf, 4095); + tempbuf[4095] = 0; + + return strdup(tempbuf); +} + +/* + * Disables given window (widget). + * Parameters: + * handle: Handle to the window. + */ +void dw_window_disable(HWND handle) +{ + EnableWindow(handle, FALSE); +} + +/* + * Enables given window (widget). + * Parameters: + * handle: Handle to the window. + */ +void dw_window_enable(HWND handle) +{ + EnableWindow(handle, TRUE); +} + +/* + * Gets the child window handle with specified ID. + * Parameters: + * handle: Handle to the parent window. + * id: Integer ID of the child. + */ +HWND dw_window_from_id(HWND handle, int id) +{ + return 0L; +} +/* + * Pack windows (widgets) into a box from the start (or top). + * Parameters: + * box: Window handle of the box to be packed into. + * item: Window handle of the item to be back. + * width: Width in pixels of the item or -1 to be self determined. + * height: Height in pixels of the item or -1 to be self determined. + * hsize: TRUE if the window (widget) should expand horizontally to fill space given. + * vsize: TRUE if the window (widget) should expand vertically to fill space given. + * pad: Number of pixels of padding around the item. + */ +void dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) +{ + Box *thisbox; + + thisbox = (Box *)GetWindowLong(box, GWL_USERDATA); + if(thisbox) + { + int z; + Item *tmpitem, *thisitem = thisbox->items; + char tmpbuf[100]; + + tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); + + for(z=0;z<thisbox->count;z++) + { + tmpitem[z] = thisitem[z]; + } + + GetClassName(item, tmpbuf, 99); + + if(strnicmp(tmpbuf, FRAMECLASSNAME, 2)==0) + tmpitem[thisbox->count].type = TYPEBOX; + else + tmpitem[thisbox->count].type = TYPEITEM; + + tmpitem[thisbox->count].hwnd = item; + tmpitem[thisbox->count].origwidth = tmpitem[thisbox->count].width = width; + tmpitem[thisbox->count].origheight = tmpitem[thisbox->count].height = height; + tmpitem[thisbox->count].pad = pad; + if(hsize) + tmpitem[thisbox->count].hsize = SIZEEXPAND; + else + tmpitem[thisbox->count].hsize = SIZESTATIC; + + if(vsize) + tmpitem[thisbox->count].vsize = SIZEEXPAND; + else + tmpitem[thisbox->count].vsize = SIZESTATIC; + + thisbox->items = tmpitem; + + if(thisbox->count) + free(thisitem); + + thisbox->count++; + + SetParent(item, box); + ShowWindow(item, SW_SHOW); + if(strncmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS))==0) + { + ColorInfo *cinfo = (ColorInfo *)GetWindowLong(item, GWL_USERDATA); + + if(cinfo) + { + SetParent(cinfo->buddy, box); + ShowWindow(cinfo->buddy, SW_SHOW); + SendMessage(item, UDM_SETBUDDY, (WPARAM)cinfo->buddy, 0); + } + } + } +} + +/* + * Sets the size of a given window (widget). + * Parameters: + * handle: Window (widget) handle. + * width: New width in pixels. + * height: New height in pixels. + */ +void dw_window_set_usize(HWND handle, ULONG width, ULONG height) +{ + SetWindowPos(handle, (HWND)NULL, 0, 0, width, height, SWP_SHOWWINDOW | SWP_NOZORDER | SWP_NOMOVE); +} + +/* + * Returns the width of the screen. + */ +int dw_screen_width(void) +{ + return GetSystemMetrics(SM_CXSCREEN); +} + +/* + * Returns the height of the screen. + */ +int dw_screen_height(void) +{ + return GetSystemMetrics(SM_CYSCREEN); +} + +/* This should return the current color depth */ +unsigned long dw_color_depth(void) +{ + int bpp; + HDC hdc = GetDC(HWND_DESKTOP); + + bpp = GetDeviceCaps(hdc, BITSPIXEL); + + ReleaseDC(HWND_DESKTOP, hdc); + + return bpp; +} + + +/* + * Sets the position of a given window (widget). + * Parameters: + * handle: Window (widget) handle. + * x: X location from the bottom left. + * y: Y location from the bottom left. + */ +void dw_window_set_pos(HWND handle, ULONG x, ULONG y) +{ + SetWindowPos(handle, (HWND)NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER); +} + +/* + * Sets the position and size of a given window (widget). + * Parameters: + * handle: Window (widget) handle. + * x: X location from the bottom left. + * y: Y location from the bottom left. + * width: Width of the widget. + * height: Height of the widget. + */ +void dw_window_set_pos_size(HWND handle, ULONG x, ULONG y, ULONG width, ULONG height) +{ + SetWindowPos(handle, (HWND)NULL, x, y, width, height, SWP_NOZORDER | SWP_SHOWWINDOW); +} + +/* + * Gets the position and size of a given window (widget). + * Parameters: + * handle: Window (widget) handle. + * x: X location from the bottom left. + * y: Y location from the bottom left. + * width: Width of the widget. + * height: Height of the widget. + */ +void dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height) +{ + WINDOWPLACEMENT wp; + + wp.length = sizeof(WINDOWPLACEMENT); + + GetWindowPlacement(handle, &wp); + if(x) + *x = wp.rcNormalPosition.left; + if(y) + *y = wp.rcNormalPosition.top; + if(width) + *width = wp.rcNormalPosition.right - wp.rcNormalPosition.left; + if(height) + *height = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top; + +} + +/* + * Sets the style of a given window (widget). + * Parameters: + * handle: Window (widget) handle. + * width: New width in pixels. + * height: New height in pixels. + */ +void dw_window_set_style(HWND handle, ULONG style, ULONG mask) +{ + ULONG tmp, currentstyle = GetWindowLong(handle, GWL_STYLE); + + tmp = currentstyle | mask; + tmp ^= mask; + tmp |= style; + + SetWindowLong(handle, GWL_STYLE, tmp); +} + +/* Finds the physical ID from the reference ID */ +int _findnotebookid(NotebookPage **array, int pageid) +{ + int z; + + for(z=0;z<256;z++) + { + if(array[z] && array[z]->realid == pageid) + return z; + } + return -1; +} + +/* + * Adds a new page to specified notebook. + * Parameters: + * handle: Window (widget) handle. + * flags: Any additional page creation flags. + * front: If TRUE page is added at the beginning. + */ +ULONG dw_notebook_page_new(HWND handle, ULONG flags, int front) +{ + NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); + + if(array) + { + int z, refid = -1; + + for(z=0;z<256;z++) + { + if(_findnotebookid(array, z) == -1) + { + refid = z; + break; + } + } + + if(refid == -1) + return -1; + + for(z=0;z<256;z++) + { + if(!array[z]) + { + int oldpage = TabCtrl_GetCurSel(handle); + + array[z] = calloc(1, sizeof(NotebookPage)); + array[z]->realid = refid; + array[z]->item.mask = TCIF_TEXT; + array[z]->item.iImage = -1; + array[z]->item.pszText = ""; + TabCtrl_InsertItem(handle, z, &(array[z]->item)); + + if(oldpage > -1 && array[oldpage]) + SetParent(array[oldpage]->hwnd, DW_HWND_OBJECT); + + TabCtrl_SetCurSel(handle, z); + return refid; + } + } + } + return -1; +} + +/* + * Sets the text on the specified notebook tab. + * Parameters: + * handle: Notebook handle. + * pageid: Page ID of the tab to set. + * text: Pointer to the text to set. + */ +void dw_notebook_page_set_text(HWND handle, ULONG pageidx, char *text) +{ + + NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); + int pageid; + + if(!array) + return; + + pageid = _findnotebookid(array, pageidx); + + if(pageid > -1 && array[pageid]) + { + array[pageid]->item.mask = TCIF_TEXT; + array[pageid]->item.pszText = text; + TabCtrl_SetItem(handle, pageid, &(array[pageid]->item)); + _resize_notebook_page(handle, pageid); + } +} + +/* + * Sets the text on the specified notebook tab status area. + * Parameters: + * handle: Notebook handle. + * pageid: Page ID of the tab to set. + * text: Pointer to the text to set. + */ +void dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text) +{ +} + +/* + * Packs the specified box into the notebook page. + * Parameters: + * handle: Handle to the notebook to be packed. + * pageid: Page ID in the notebook which is being packed. + * page: Box handle to be packed. + */ +void dw_notebook_pack(HWND handle, ULONG pageidx, HWND page) +{ + NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); + int pageid; + + if(!array) + return; + + pageid = _findnotebookid(array, pageidx); + + if(pageid > -1 && array[pageid]) + { + HWND tmpbox = dw_box_new(BOXVERT, 0); + + dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0); + SubclassWindow(tmpbox, _wndproc); + if(array[pageid]->hwnd) + dw_window_destroy(array[pageid]->hwnd); + array[pageid]->hwnd = tmpbox; + if(pageidx == dw_notebook_page_query(handle)) + { + SetParent(tmpbox, handle); + _resize_notebook_page(handle, pageid); + } + } +} + +/* + * Remove a page from a notebook. + * Parameters: + * handle: Handle to the notebook widget. + * pageid: ID of the page to be destroyed. + */ +void dw_notebook_page_destroy(HWND handle, unsigned int pageidx) +{ + NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); + int newid = -1, z, pageid; + + if(!array) + return; + + pageid = _findnotebookid(array, pageidx); + + if(pageid < 0) + return; + + if(array[pageid]) + { + SetParent(array[pageid]->hwnd, DW_HWND_OBJECT); + free(array[pageid]); + array[pageid] = NULL; + } + + TabCtrl_DeleteItem(handle, pageid); + + /* Shift the pages over 1 */ + for(z=pageid;z<255;z++) + array[z] = array[z+1]; + array[255] = NULL; + + for(z=0;z<256;z++) + { + if(array[z]) + { + newid = z; + break; + } + } + if(newid > -1) + { + SetParent(array[newid]->hwnd, handle); + _resize_notebook_page(handle, newid); + dw_notebook_page_set(handle, array[newid]->realid); + } +} + +/* + * Queries the currently visible page ID. + * Parameters: + * handle: Handle to the notebook widget. + */ +unsigned int dw_notebook_page_query(HWND handle) +{ + NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); + int physid = TabCtrl_GetCurSel(handle); + + if(physid > -1 && physid < 256 && array && array[physid]) + return array[physid]->realid; + return -1; +} + +/* + * Sets the currently visible page ID. + * Parameters: + * handle: Handle to the notebook widget. + * pageid: ID of the page to be made visible. + */ +void dw_notebook_page_set(HWND handle, unsigned int pageidx) +{ + NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); + int pageid; + + if(!array) + return; + + pageid= _findnotebookid(array, pageidx); + + if(pageid > -1 && pageid < 256) + TabCtrl_SetCurSel(handle, pageid); +} + +/* + * Appends the specified text to the listbox's (or combobox) entry list. + * Parameters: + * handle: Handle to the listbox to be appended to. + * text: Text to append into listbox. + */ +void dw_listbox_append(HWND handle, char *text) +{ + char tmpbuf[100]; + + GetClassName(handle, tmpbuf, 99); + + if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0) + SendMessage(handle, + CB_ADDSTRING, + 0, (LPARAM)text); + else + SendMessage(handle, + LB_ADDSTRING, + 0, (LPARAM)text); +} + +/* + * Clears the listbox's (or combobox) list of all entries. + * Parameters: + * handle: Handle to the listbox to be cleared. + */ +void dw_listbox_clear(HWND handle) +{ + char tmpbuf[100]; + + GetClassName(handle, tmpbuf, 99); + + if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0) + { + char *buf = dw_window_get_text(handle); + + SendMessage(handle, + CB_RESETCONTENT, 0L, 0L); + + if(buf) + { + dw_window_set_text(handle, buf); + free(buf); + } + } + else + SendMessage(handle, + LB_RESETCONTENT, 0L, 0L); +} + +/* + * Sets the text of a given listbox entry. + * Parameters: + * handle: Handle to the listbox to be queried. + * index: Index into the list to be queried. + * buffer: Buffer where text will be copied. + */ +void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) +{ + unsigned int sel = (unsigned int)SendMessage(handle, LB_GETCURSEL, 0, 0); + SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0); + SendMessage(handle, LB_INSERTSTRING, (WPARAM)index, (LPARAM)buffer); + SendMessage(handle, LB_SETCURSEL, (WPARAM)sel, 0); + SendMessage(handle, LB_SETSEL, (WPARAM)TRUE, (LPARAM)sel); +} + +/* + * Copies the given index item's text into buffer. + * Parameters: + * handle: Handle to the listbox to be queried. + * index: Index into the list to be queried. + * buffer: Buffer where text will be copied. + * length: Length of the buffer (including NULL). + */ +void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length) +{ + SendMessage(handle, + LB_GETTEXT, (WPARAM)index, (LPARAM)buffer); +} + +/* + * Returns the index to the item in the list currently selected. + * Parameters: + * handle: Handle to the listbox to be queried. + */ +unsigned int dw_listbox_selected(HWND handle) +{ + char tmpbuf[100]; + + GetClassName(handle, tmpbuf, 99); + + if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0) + return (unsigned int)SendMessage(handle, + CB_GETCURSEL, + 0, 0); + + return (unsigned int)SendMessage(handle, + LB_GETCURSEL, + 0, 0); +} + +/* + * Returns the index to the current selected item or -1 when done. + * Parameters: + * handle: Handle to the listbox to be queried. + * where: Either the previous return or -1 to restart. + */ +int dw_listbox_selected_multi(HWND handle, int where) +{ + int *array, count, z; + + count = (int)SendMessage(handle, LB_GETSELCOUNT, 0, 0); + if(count > 0) + { + array = malloc(sizeof(int)*count); + SendMessage(handle, LB_GETSELITEMS, (WPARAM)count, (LPARAM)array); + + if(where == -1) + { + int ret = array[0]; + free(array); + return ret; + } + for(z=0;z<count;z++) + { + if(array[z] == where && (z+1) < count) + { + int ret = array[z+1]; + free(array); + return ret; + } + } + free(array); + } + return -1; +} + +/* + * Sets the selection state of a given index. + * Parameters: + * handle: Handle to the listbox to be set. + * index: Item index. + * state: TRUE if selected FALSE if unselected. + */ +void dw_listbox_select(HWND handle, int index, int state) +{ + char tmpbuf[100]; + + GetClassName(handle, tmpbuf, 99); + + if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0) + SendMessage(handle, CB_SETCURSEL, (WPARAM)index, 0); + else + { + SendMessage(handle, LB_SETCURSEL, (WPARAM)index, 0); + SendMessage(handle, LB_SETSEL, (WPARAM)state, (LPARAM)index); + } + _wndproc(handle, WM_COMMAND, (WPARAM)(LBN_SELCHANGE << 16), (LPARAM)handle); +} + +/* + * Deletes the item with given index from the list. + * Parameters: + * handle: Handle to the listbox to be set. + * index: Item index. + */ +void dw_listbox_delete(HWND handle, int index) +{ + SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0); +} + +/* + * Returns the listbox's item count. + * Parameters: + * handle: Handle to the listbox to be cleared. + */ +int dw_listbox_count(HWND handle) +{ + char tmpbuf[100]; + + GetClassName(handle, tmpbuf, 99); + + if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0) + return (int)SendMessage(handle, + CB_GETCOUNT,0L, 0L); + + return (int)SendMessage(handle, + LB_GETCOUNT,0L, 0L); +} + +/* + * Sets the topmost item in the viewport. + * Parameters: + * handle: Handle to the listbox to be cleared. + * top: Index to the top item. + */ +void dw_listbox_set_top(HWND handle, int top) +{ + SendMessage(handle, LB_SETTOPINDEX, (WPARAM)top, 0); +} + +#define MLE_MAX 200000 +/* + * Adds text to an MLE box and returns the current point. + * Parameters: + * handle: Handle to the MLE to be queried. + * buffer: Text buffer to be imported. + * startpoint: Point to start entering text. + */ +unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint) +{ + char *tmpbuf = malloc(MLE_MAX+1); + int len; + + if(startpoint < 0) + startpoint = 0; + + GetWindowText(handle, tmpbuf, MLE_MAX); + tmpbuf[MLE_MAX] = 0; + + len = strlen(tmpbuf); + if(len) + memcpy(&tmpbuf[startpoint+strlen(buffer)], &tmpbuf[startpoint], (len-startpoint)); + memcpy(&tmpbuf[startpoint], buffer, strlen(buffer)); + + tmpbuf[len+strlen(buffer)] = 0; + + SetWindowText(handle, tmpbuf); + + free(tmpbuf); + return startpoint+strlen(buffer); +} + +/* + * Grabs text from an MLE box. + * Parameters: + * handle: Handle to the MLE to be queried. + * buffer: Text buffer to be exported. + * startpoint: Point to start grabbing text. + * length: Amount of text to be grabbed. + */ +void dw_mle_export(HWND handle, char *buffer, int startpoint, int length) +{ + char *tmpbuf = malloc(MLE_MAX+1); + + GetWindowText(handle, tmpbuf, MLE_MAX); + tmpbuf[MLE_MAX] = 0; + + memcpy(buffer, &tmpbuf[startpoint], length); + + free(tmpbuf); +} + +/* + * Obtains information about an MLE box. + * Parameters: + * handle: Handle to the MLE to be queried. + * bytes: A pointer to a variable to return the total bytes. + * lines: A pointer to a variable to return the number of lines. + */ +void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines) +{ + char *tmpbuf = malloc(MLE_MAX+1); + + GetWindowText(handle, tmpbuf, MLE_MAX); + tmpbuf[MLE_MAX] = 0; + + if(bytes) + *bytes = strlen(tmpbuf); + if(lines) + *lines = (unsigned long)SendMessage(handle, EM_GETLINECOUNT, 0, 0); + + free(tmpbuf); +} + +/* + * Deletes text from an MLE box. + * Parameters: + * handle: Handle to the MLE to be deleted from. + * startpoint: Point to start deleting text. + * length: Amount of text to be deleted. + */ +void dw_mle_delete(HWND handle, int startpoint, int length) +{ + char *tmpbuf = malloc(MLE_MAX+1); + int len; + + GetWindowText(handle, tmpbuf, MLE_MAX); + tmpbuf[MLE_MAX] = 0; + + len = strlen(tmpbuf); + + strcpy(&tmpbuf[startpoint], &tmpbuf[startpoint+length]); + + SetWindowText(handle, tmpbuf); + + free(tmpbuf); +} + +/* + * Clears all text from an MLE box. + * Parameters: + * handle: Handle to the MLE to be cleared. + */ +void dw_mle_clear(HWND handle) +{ + SetWindowText(handle, ""); +} + +/* + * Sets the visible line of an MLE box. + * Parameters: + * handle: Handle to the MLE. + * line: Line to be visible. + */ +void dw_mle_set_visible(HWND handle, int line) +{ + int point = (int)SendMessage(handle, EM_LINEINDEX, (WPARAM)line, 0); + dw_mle_set(handle, point); +} + +/* + * Sets the current cursor position of an MLE box. + * Parameters: + * handle: Handle to the MLE to be positioned. + * point: Point to position cursor. + */ +void dw_mle_set(HWND handle, int point) +{ + SendMessage(handle, EM_SETSEL, (WPARAM)point, (LPARAM)point); + SendMessage(handle, EM_SCROLLCARET, 0, 0); +} + +/* + * Finds text in an MLE box. + * Parameters: + * handle: Handle to the MLE to be cleared. + * text: Text to search for. + * point: Start point of search. + * flags: Search specific flags. + */ +int dw_mle_search(HWND handle, char *text, int point, unsigned long flags) +{ + char *tmpbuf = malloc(MLE_MAX+1); + int z, len, textlen, retval = 0; + + GetWindowText(handle, tmpbuf, MLE_MAX); + tmpbuf[MLE_MAX] = 0; + + len = strlen(tmpbuf); + textlen = strlen(text); + + if(flags & DW_MLE_CASESENSITIVE) + { + for(z=point;z<(len-textlen) && !retval;z++) + { + if(strncmp(&tmpbuf[z], text, textlen) == 0) + retval = z + textlen; + } + } + else + { + for(z=point;z<(len-textlen) && !retval;z++) + { + if(strnicmp(&tmpbuf[z], text, textlen) == 0) + retval = z + textlen; + } + } + + if(retval) + { + SendMessage(handle, EM_SETSEL, (WPARAM)retval - textlen, (LPARAM)retval); + SendMessage(handle, EM_SCROLLCARET, 0, 0); + } + + free(tmpbuf); + + return retval; +} + +/* + * Stops redrawing of an MLE box. + * Parameters: + * handle: Handle to the MLE to freeze. + */ +void dw_mle_freeze(HWND handle) +{ +} + +/* + * Resumes redrawing of an MLE box. + * Parameters: + * handle: Handle to the MLE to thaw. + */ +void dw_mle_thaw(HWND handle) +{ +} + +/* + * Returns the range of the slider. + * Parameters: + * handle: Handle to the slider to be queried. + */ +unsigned int dw_slider_query_range(HWND handle) +{ + return (unsigned int)SendMessage(handle, PBM_GETRANGE, (WPARAM)FALSE, 0); +} + +/* + * Sets the slider position. + * Parameters: + * handle: Handle to the slider to be set. + * position: Position of the slider withing the range. + */ +void dw_slider_set_pos(HWND handle, unsigned int position) +{ + SendMessage(handle, PBM_SETPOS, (WPARAM)position, 0); +} + +/* + * Sets the spinbutton value. + * Parameters: + * handle: Handle to the spinbutton to be set. + * position: Current value of the spinbutton. + */ +void dw_spinbutton_set_pos(HWND handle, long position) +{ + char tmpbuf[100]; + ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); + + sprintf(tmpbuf, "%d", position); + + if(cinfo && cinfo->buddy) + SetWindowText(cinfo->buddy, tmpbuf); + + if(IS_WIN98PLUS) + SendMessage(handle, UDM_SETPOS32, 0, (LPARAM)position); + else + SendMessage(handle, UDM_SETPOS, 0, (LPARAM)MAKELONG((short)position, 0)); +} + +/* + * Sets the spinbutton limits. + * Parameters: + * handle: Handle to the spinbutton to be set. + * position: Current value of the spinbutton. + * position: Current value of the spinbutton. + */ +void dw_spinbutton_set_limits(HWND handle, long upper, long lower) +{ + if(IS_WIN98PLUS) + SendMessage(handle, UDM_SETRANGE32, (WPARAM)lower,(LPARAM)upper); + else + SendMessage(handle, UDM_SETRANGE32, (WPARAM)((short)lower), + (LPARAM)((short)upper)); +} + +/* + * Sets the entryfield character limit. + * Parameters: + * handle: Handle to the spinbutton to be set. + * limit: Number of characters the entryfield will take. + */ +void dw_entryfield_set_limit(HWND handle, ULONG limit) +{ + SendMessage(handle, EM_SETLIMITTEXT, (WPARAM)limit, 0); +} + +/* + * Returns the current value of the spinbutton. + * Parameters: + * handle: Handle to the spinbutton to be queried. + */ +long dw_spinbutton_query(HWND handle) +{ + if(IS_WIN98PLUS) + return (long)SendMessage(handle, UDM_GETPOS32, 0, 0); + else + return (long)SendMessage(handle, UDM_GETPOS, 0, 0); +} + +/* + * Returns the state of the checkbox. + * Parameters: + * handle: Handle to the checkbox to be queried. + */ +int dw_checkbox_query(HWND handle) +{ + if(SendMessage(handle, BM_GETCHECK, 0, 0) == BST_CHECKED) + return TRUE; + return FALSE; +} + +/* + * Sets the state of the checkbox. + * Parameters: + * handle: Handle to the checkbox to be queried. + * value: TRUE for checked, FALSE for unchecked. + */ +void dw_checkbox_set(HWND handle, int value) +{ + ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); + + if(cinfo && !cinfo->user) + SendMessage(handle, BM_CLICK, 0, 0); + SendMessage(handle, BM_SETCHECK, (WPARAM)value, 0); +} + +/* + * Sets up the container columns. + * Parameters: + * handle: Handle to the container to be configured. + * flags: An array of unsigned longs with column flags. + * titles: An array of strings with column text titles. + * count: The number of columns (this should match the arrays). + * separator: The column number that contains the main separator. + * (only used on OS/2 but must be >= 0 on all) + */ +int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) +{ + ContainerInfo *cinfo = (ContainerInfo *)GetWindowLong(handle, GWL_USERDATA); + int z, l = 0; + unsigned long *tempflags = malloc(sizeof(unsigned long) * (count + 2)); + LV_COLUMN lvc; + + if(separator == -1) + l = 1; + + memcpy(&tempflags[l], flags, sizeof(unsigned long) * count); + tempflags[count + l] = 0; + cinfo->flags = tempflags; + + + for(z=0;z<count;z++) + { + lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM /*| LVCF_FORMAT*/; + lvc.pszText = titles[z]; + lvc.cchTextMax = strlen(titles[z]); + lvc.fmt = flags[z]; + lvc.cx = 75; + lvc.iSubItem = count; + SendMessage(handle, LVM_INSERTCOLUMN, (WPARAM)z + l, (LPARAM)&lvc); + } + ListView_SetExtendedListViewStyle(handle, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES); + return TRUE; +} + +/* + * Sets up the filesystem columns, note: filesystem always has an icon/filename field. + * Parameters: + * handle: Handle to the container to be configured. + * flags: An array of unsigned longs with column flags. + * titles: An array of strings with column text titles. + * count: The number of columns (this should match the arrays). + */ +int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) +{ + LV_COLUMN lvc; + + lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM; + lvc.pszText = "Filename"; + lvc.cchTextMax = 8; + lvc.fmt = 0; + if(!count) + lvc.cx = 300; + else + lvc.cx = 150; + lvc.iSubItem = count; + SendMessage(handle, LVM_INSERTCOLUMN, (WPARAM)0, (LPARAM)&lvc); + dw_container_setup(handle, flags, titles, count, -1); + return TRUE; +} + +/* + * Obtains an icon from a module (or header in GTK). + * Parameters: + * module: Handle to module (DLL) in OS/2 and Windows. + * id: A unsigned long id int the resources on OS/2 and + * Windows, on GTK this is converted to a pointer + * to an embedded XPM. + */ +unsigned long dw_icon_load(unsigned long module, unsigned long id) +{ + return (unsigned long)LoadIcon(DWInstance, MAKEINTRESOURCE(id)); +} + +/* + * Frees a loaded resource in OS/2 and Windows. + * Parameters: + * handle: Handle to icon returned by dw_icon_load(). + */ +void dw_icon_free(unsigned long handle) +{ + DestroyIcon((HICON)handle); +} + +/* + * Allocates memory used to populate a container. + * Parameters: + * handle: Handle to the container window (widget). + * rowcount: The number of items to be populated. + */ +void *dw_container_alloc(HWND handle, int rowcount) +{ + return (void *)handle; +} + +/* Finds a icon in the table, otherwise it adds it to the table + * and returns the index in the table. + */ +int _lookup_icon(HWND handle, HICON hicon) +{ + int z; + static HWND lasthwnd = NULL; + + if(!lookup[0]) + { + hSmall = ImageList_Create(16, 16, FALSE, ICON_INDEX_LIMIT, 0); + hLarge = ImageList_Create(32, 32, FALSE, ICON_INDEX_LIMIT, 0); + } + for(z=0;z<ICON_INDEX_LIMIT;z++) + { + if(!lookup[z]) + { + lookup[z] = hicon; + ImageList_AddIcon(hSmall, hicon); + ImageList_AddIcon(hLarge, hicon); + ListView_SetImageList(handle, hSmall, LVSIL_SMALL); + ListView_SetImageList(handle, hLarge, LVSIL_NORMAL); + lasthwnd = handle; + return z; + } + + if(hicon == lookup[z]) + { + if(lasthwnd != handle) + { + ListView_SetImageList(handle, hSmall, LVSIL_SMALL); + ListView_SetImageList(handle, hLarge, LVSIL_NORMAL); + lasthwnd = handle; + } + return z; + } + } + return -1; +} + +/* + * Sets an item in specified row and column to the given data. + * Parameters: + * handle: Handle to the container window (widget). + * pointer: Pointer to the allocated memory in dw_container_alloc(). + * column: Zero based column of data being set. + * row: Zero based row of data being set. + * data: Pointer to the data to be added. + */ +void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) +{ + LV_ITEM lvi; + + lvi.iItem = row; + lvi.iSubItem = 0; + lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE | LVIF_TEXT; + lvi.pszText = filename; + lvi.cchTextMax = strlen(filename); + lvi.iImage = _lookup_icon(handle, (HICON)icon); + + ListView_InsertItem(handle, &lvi); +} + +/* + * Sets an item in specified row and column to the given data. + * Parameters: + * handle: Handle to the container window (widget). + * pointer: Pointer to the allocated memory in dw_container_alloc(). + * column: Zero based column of data being set. + * row: Zero based row of data being set. + * data: Pointer to the data to be added. + */ +void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) +{ + dw_container_set_item(handle, pointer, column + 1, row, data); +} + +/* + * Sets an item in specified row and column to the given data. + * Parameters: + * handle: Handle to the container window (widget). + * pointer: Pointer to the allocated memory in dw_container_alloc(). + * column: Zero based column of data being set. + * row: Zero based row of data being set. + * data: Pointer to the data to be added. + */ +void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) +{ + ContainerInfo *cinfo = (ContainerInfo *)GetWindowLong(handle, GWL_USERDATA); + ULONG *flags; + LV_ITEM lvi; + char textbuffer[100], *destptr = textbuffer; + + if(!cinfo || !cinfo->flags || !data) + return; + + flags = cinfo->flags; + + lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT; + lvi.iItem = row; + lvi.iSubItem = column; + + if(flags[column] & DW_CFA_BITMAPORICON) + { + HICON hicon = *((HICON *)data); + + lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE; + lvi.pszText = NULL; + lvi.cchTextMax = 0; + lvi.iImage = _lookup_icon(handle, hicon); + } + else if(flags[column] & DW_CFA_STRING) + { + char *tmp = *((char **)data); + + lvi.pszText = tmp; + lvi.cchTextMax = strlen(tmp); + destptr = tmp; + } + else if(flags[column] & DW_CFA_ULONG) + { + ULONG tmp = *((ULONG *)data); + + sprintf(textbuffer, "%lu", tmp); + + lvi.pszText = textbuffer; + lvi.cchTextMax = strlen(textbuffer); + } + else if(flags[column] & DW_CFA_DATE) + { + CDATE fdate = *((CDATE *)data); + + sprintf(textbuffer, "%s %d, %d", monthlist[fdate.month], fdate.day, fdate.year); + lvi.pszText = textbuffer; + lvi.cchTextMax = strlen(textbuffer); + } + else if(flags[column] & DW_CFA_TIME) + { + CTIME ftime = *((CTIME *)data); + + if(ftime.hours > 12) + sprintf(textbuffer, "%d:%s%dpm", ftime.hours - 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes); + else + sprintf(textbuffer, "%d:%s%dam", ftime.hours ? ftime.hours : 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes); + lvi.pszText = textbuffer; + lvi.cchTextMax = strlen(textbuffer); + } + + if(column == 0) + ListView_InsertItem(handle, &lvi); + else + ListView_SetItemText(handle, row, column, destptr); +} + +/* + * Sets the title of a row in the container. + * Parameters: + * pointer: Pointer to the allocated memory in dw_container_alloc(). + * row: Zero based row of data being set. + * title: String title of the item. + */ +void dw_container_set_row_title(void *pointer, int row, char *title) +{ + LV_ITEM lvi; + HWND container = (HWND)pointer; + + lvi.iItem = row; + lvi.iSubItem = 0; + lvi.mask = LVIF_PARAM; + lvi.lParam = (LPARAM)title; + + if(!ListView_SetItem(container, &lvi) && lvi.lParam) + { + free((void *)lvi.lParam); + lvi.lParam = 0; + } + +} + +/* + * Sets the title of a row in the container. + * Parameters: + * handle: Handle to the container window (widget). + * pointer: Pointer to the allocated memory in dw_container_alloc(). + * rowcount: The number of rows to be inserted. + */ +void dw_container_insert(HWND handle, void *pointer, int rowcount) +{ + /* This isn't a separate step in windows. */ +} + +/* + * Removes all rows from a container. + * Parameters: + * handle: Handle to the window (widget) to be cleared. + */ +void dw_container_clear(HWND handle) +{ + /* May need to delete manually so I can + * remove the memory allocated for the + * lParam field. + */ + ListView_DeleteAllItems(handle); +} + +/* + * Removes all rows from a container. + * Parameters: + * handle: Handle to the window (widget) to be cleared. + */ +void dw_container_set_view(HWND handle, unsigned long flags, int iconwidth, int iconheight) +{ +} + +/* + * Starts a new query of a container. + * Parameters: + * handle: Handle to the window (widget) to be queried. + * flags: If this parameter is DW_CRA_SELECTED it will only + * return items that are currently selected. Otherwise + * it will return all records in the container. + */ +char *dw_container_query_start(HWND handle, unsigned long flags) +{ + LV_ITEM lvi; + + if(flags) + _index = ListView_GetNextItem(handle, -1, LVNI_SELECTED); + else + _index = ListView_GetNextItem(handle, -1, LVNI_ALL); + + + lvi.iItem = _index; + lvi.mask = LVIF_PARAM; + + ListView_GetItem(handle, &lvi); + + return (char *)lvi.lParam; +} + +/* + * Continues an existing query of a container. + * Parameters: + * handle: Handle to the window (widget) to be queried. + * flags: If this parameter is DW_CRA_SELECTED it will only + * return items that are currently selected. Otherwise + * it will return all records in the container. + */ +char *dw_container_query_next(HWND handle, unsigned long flags) +{ + LV_ITEM lvi; + + if(flags) + _index = ListView_GetNextItem(handle, _index, LVNI_SELECTED); + else + _index = ListView_GetNextItem(handle, _index, LVNI_ALL); + + if(_index == -1) + return NULL; + + lvi.iItem = _index; + lvi.mask = LVIF_PARAM; + + ListView_GetItem(handle, &lvi); + + return (char *)lvi.lParam; +} + +/* + * Creates a rendering context widget (window) to be packed. + * Parameters: + * id: An id to be used with dw_window_from_id. + * Returns: + * A handle to the widget or NULL on failure. + */ +HWND dw_render_new(unsigned long id) +{ + HWND tmp = CreateWindow(ObjectClassName, + "", + WS_CHILD | WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + NULL, + NULL, + NULL); + SubclassWindow(tmp, _rendwndproc); + return tmp; +} + +/* Sets the current foreground drawing color. + * Parameters: + * red: red value. + * green: green value. + * blue: blue value. + */ +void dw_color_foreground_set(unsigned long value) +{ + DeleteObject(_hPen); + DeleteObject(_hBrush); + _foreground = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value)); + _hPen = CreatePen(PS_SOLID, 1, _foreground); + _hBrush = CreateSolidBrush(_foreground); +} + +/* Sets the current background drawing color. + * Parameters: + * red: red value. + * green: green value. + * blue: blue value. + */ +void dw_color_background_set(unsigned long value) +{ + + _background = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value)); +} + +/* Draw a point on a window (preferably a render window). + * Parameters: + * handle: Handle to the window. + * pixmap: Handle to the pixmap. (choose only one of these) + * x: X coordinate. + * y: Y coordinate. + */ +void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) +{ + HDC hdcPaint; + + if(handle) + hdcPaint = GetDC(handle); + else if(pixmap) + hdcPaint = pixmap->hdc; + else + return; + + SetPixel(hdcPaint, x, y, _foreground); + if(!pixmap) + ReleaseDC(handle, hdcPaint); +} + +/* Draw a line on a window (preferably a render window). + * Parameters: + * handle: Handle to the window. + * pixmap: Handle to the pixmap. (choose only one of these) + * x1: First X coordinate. + * y1: First Y coordinate. + * x2: Second X coordinate. + * y2: Second Y coordinate. + */ +void dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) +{ + HDC hdcPaint; + HPEN oldPen; + + if(handle) + hdcPaint = GetDC(handle); + else if(pixmap) + hdcPaint = pixmap->hdc; + else + return; + + oldPen = SelectObject(hdcPaint, _hPen); + MoveToEx(hdcPaint, x1, y1, NULL); + LineTo(hdcPaint, x2, y2); + SelectObject(hdcPaint, oldPen); + /* For some reason Win98 (at least) fails + * to draw the last pixel. So I do it myself. + */ + SetPixel(hdcPaint, x2, y2, _foreground); + if(!pixmap) + ReleaseDC(handle, hdcPaint); +} + +/* Draw a rectangle on a window (preferably a render window). + * Parameters: + * handle: Handle to the window. + * pixmap: Handle to the pixmap. (choose only one of these) + * x: X coordinate. + * y: Y coordinate. + * width: Width of rectangle. + * height: Height of rectangle. + */ +void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) +{ + HDC hdcPaint; + HPEN oldPen; + HBRUSH oldBrush; + + if(handle) + hdcPaint = GetDC(handle); + else if(pixmap) + hdcPaint = pixmap->hdc; + else + return; + + oldPen = SelectObject(hdcPaint, _hPen); + oldBrush = SelectObject(hdcPaint, _hBrush); + Rectangle(hdcPaint, x, y, x + width, y + height); + SelectObject(hdcPaint, oldPen); + SelectObject(hdcPaint, oldBrush); + if(!pixmap) + ReleaseDC(handle, hdcPaint); +} + +/* Draw text on a window (preferably a render window). + * Parameters: + * handle: Handle to the window. + * pixmap: Handle to the pixmap. (choose only one of these) + * x: X coordinate. + * y: Y coordinate. + * text: Text to be displayed. + */ +void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) +{ + HDC hdc; + int size = 9, z, mustdelete = 0; + HFONT hFont, oldFont; + + if(handle) + { + hdc = GetDC(handle); + hFont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0); + } + else if(pixmap) + { + hdc = pixmap->hdc; + hFont = (HFONT)SendMessage(pixmap->handle, WM_GETFONT, 0, 0); + } + else + return; + + if(!hFont) + { + ColorInfo *cinfo; + + if(handle) + cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); + else + cinfo = (ColorInfo *)GetWindowLong(pixmap->handle, GWL_USERDATA); + + if(cinfo) + { + hFont = _aquire_font(cinfo->fontname); + mustdelete = 1; + } + } + oldFont = SelectObject(hdc, hFont); + SetTextColor(hdc, _foreground); + SetBkMode(hdc, TRANSPARENT); + TextOut(hdc, x, y, text, strlen(text)); + SelectObject(hdc, oldFont); + if(mustdelete) + DeleteObject(hFont); + if(!pixmap) + ReleaseDC(handle, hdc); +} + +/* Call this after drawing to the screen to make sure + * anything you have drawn is visible. + */ +void dw_flush(void) +{ +} + +/* + * Creates a pixmap with given parameters. + * Parameters: + * handle: Window handle the pixmap is associated with. + * width: Width of the pixmap in pixels. + * height: Height of the pixmap in pixels. + * depth: Color depth of the pixmap. + * Returns: + * A handle to a pixmap or NULL on failure. + */ +HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) +{ + HPIXMAP pixmap; + BITMAP bm; + HDC hdc; + + if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) + return NULL; + + hdc = GetDC(handle); + + pixmap->width = width; pixmap->height = height; + + pixmap->handle = handle; + pixmap->hbm = CreateCompatibleBitmap(hdc, width, height); + pixmap->hdc = CreateCompatibleDC(hdc); + + SelectObject(pixmap->hdc, pixmap->hbm); + + ReleaseDC(handle, hdc); + + return pixmap; +} + +/* + * Creates a pixmap from internal resource graphic specified by id. + * Parameters: + * handle: Window handle the pixmap is associated with. + * id: Resource ID associated with requested pixmap. + * Returns: + * A handle to a pixmap or NULL on failure. + */ +HPIXMAP dw_pixmap_grab(HWND handle, ULONG id) +{ + HPIXMAP pixmap; + BITMAP bm; + HDC hdc; + + if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) + return NULL; + + hdc = GetDC(handle); + + + pixmap->hbm = LoadBitmap(DWInstance, MAKEINTRESOURCE(id)); + pixmap->hdc = CreateCompatibleDC(hdc); + + GetObject(pixmap->hbm, sizeof(BITMAP), (void *)&bm); + + pixmap->width = bm.bmWidth; pixmap->height = bm.bmHeight; + + SelectObject(pixmap->hdc, pixmap->hbm); + + ReleaseDC(handle, hdc); + + return pixmap; +} + +/* + * Destroys an allocated pixmap. + * Parameters: + * pixmap: Handle to a pixmap returned by + * dw_pixmap_new.. + */ +void dw_pixmap_destroy(HPIXMAP pixmap) +{ + if(pixmap) + { + DeleteDC(pixmap->hdc); + DeleteObject(pixmap->hbm); + free(pixmap); + } +} + +/* + * Copies from one item to another. + * Parameters: + * dest: Destination window handle. + * destp: Destination pixmap. (choose only one). + * xdest: X coordinate of destination. + * ydest: Y coordinate of destination. + * width: Width of area to copy. + * height: Height of area to copy. + * src: Source window handle. + * srcp: Source pixmap. (choose only one). + * xsrc: X coordinate of source. + * ysrc: Y coordinate of source. + */ +void dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) +{ + HDC hdcdest; + HDC hdcsrc; + + if(dest) + hdcdest = GetDC(dest); + else if(destp) + hdcdest = destp->hdc; + else + return; + + if(src) + hdcsrc = GetDC(src); + else if(srcp) + hdcsrc = srcp->hdc; + else + return; + + BitBlt(hdcdest, xdest, ydest, width, height, hdcsrc, xsrc, ysrc, SRCCOPY); + + if(!destp) + ReleaseDC(dest, hdcdest); + if(!srcp) + ReleaseDC(src, hdcsrc); +} + +/* + * Emits a beep. + * Parameters: + * freq: Frequency. + * dur: Duration. + */ +void dw_beep(int freq, int dur) +{ + Beep(freq, dur); +} + +/* + * Returns the handle to an unnamed mutex semaphore. + */ +HMTX dw_mutex_new(void) +{ + return (HMTX)CreateMutex(NULL, FALSE, NULL); +} + +/* + * Closes a semaphore created by dw_mutex_new(). + * Parameters: + * mutex: The handle to the mutex returned by dw_mutex_new(). + */ +void dw_mutex_close(HMTX mutex) +{ + CloseHandle((HANDLE)mutex); +} + +/* + * Tries to gain access to the semaphore, if it can't it blocks. + * Parameters: + * mutex: The handle to the mutex returned by dw_mutex_new(). + */ +void dw_mutex_lock(HMTX mutex) +{ + WaitForSingleObject((HANDLE)mutex, INFINITE); +} + +/* + * Reliquishes the access to the semaphore. + * Parameters: + * mutex: The handle to the mutex returned by dw_mutex_new(). + */ +void dw_mutex_unlock(HMTX mutex) +{ + ReleaseMutex((HANDLE)mutex); +} + +/* + * Returns the handle to an unnamed event semaphore. + */ +HEV dw_event_new(void) +{ + return CreateEvent(NULL, TRUE, FALSE, NULL); +} + +/* + * Resets a semaphore created by dw_event_new(). + * Parameters: + * eve: The handle to the event returned by dw_event_new(). + */ +int dw_event_reset(HEV eve) +{ + return ResetEvent(eve); +} + +/* + * Posts a semaphore created by dw_event_new(). Causing all threads + * waiting on this event in dw_event_wait to continue. + * Parameters: + * eve: The handle to the event returned by dw_event_new(). + */ +int dw_event_post(HEV eve) +{ + return SetEvent(eve); +} + +/* + * Waits on a semaphore created by dw_event_new(), until the + * event gets posted or until the timeout expires. + * Parameters: + * eve: The handle to the event returned by dw_event_new(). + */ +int dw_event_wait(HEV eve, unsigned long timeout) +{ + int rc; + + rc = WaitForSingleObject(eve, timeout); + if(rc == WAIT_OBJECT_0) + return 1; + if(rc == WAIT_ABANDONED) + return -1; + return 0; +} + +/* + * Closes a semaphore created by dw_event_new(). + * Parameters: + * eve: The handle to the event returned by dw_event_new(). + */ +int dw_event_close(HEV *eve) +{ + if(eve) + return CloseHandle(*eve); + return FALSE; +} + +/* + * Creates a new thread with a starting point of func. + * Parameters: + * func: Function which will be run in the new thread. + * data: Parameter(s) passed to the function. + * stack: Stack size of new thread (OS/2 and Windows only). + */ +DWTID dw_thread_new(void *func, void *data, int stack) +{ +#if defined(__CYGWIN__) + return 0; +#else + return (DWTID)_beginthread((void(*)(void *))func, stack, data); +#endif +} + +/* + * Ends execution of current thread immediately. + */ +void dw_thread_end(void) +{ +#if !defined(__CYGWIN__) + _endthread(); +#endif +} + +/* + * Returns the current thread's ID. + */ +DWTID dw_thread_id(void) +{ +#if defined(__CYGWIN__) + return 0; +#else + return (DWTID)GetCurrentThreadId(); +#endif +} + +/* + * Cleanly terminates a DW session, should be signal handler safe. + * Parameters: + * exitcode: Exit code reported to the operating system. + */ +void dw_exit(int exitcode) +{ + exit(exitcode); +} + +/* + * Pack a splitbar (sizer) into the specified box from the start. + * Parameters: + * box: Window handle of the box to be packed into. + */ +void dw_box_pack_splitbar_start(HWND box) +{ + Box *thisbox = (Box *)GetWindowLong(box, GWL_USERDATA); + + if(thisbox) + { + HWND tmp = CreateWindow(SplitbarClassName, + "", + WS_CHILD | WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + NULL, + NULL, + NULL); + if(thisbox->type == BOXVERT) + dw_box_pack_start(box, tmp, 1, SPLITBAR_WIDTH, TRUE, FALSE, 0); + else + dw_box_pack_start(box, tmp, SPLITBAR_WIDTH, 1, FALSE, TRUE, 0); + + } +} + +/* + * Pack a splitbar (sizer) into the specified box from the end. + * Parameters: + * box: Window handle of the box to be packed into. + */ +void dw_box_pack_splitbar_end(HWND box) +{ + Box *thisbox = (Box *)GetWindowLong(box, GWL_USERDATA); + + if(thisbox) + { + HWND tmp = CreateWindow(SplitbarClassName, + "", + WS_CHILD | WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + NULL, + NULL, + NULL); + if(thisbox->type == BOXVERT) + dw_box_pack_end(box, tmp, 1, SPLITBAR_WIDTH, TRUE, FALSE, 0); + else + dw_box_pack_end(box, tmp, SPLITBAR_WIDTH, 1, FALSE, TRUE, 0); + + } +} + +/* + * Pack windows (widgets) into a box from the end (or bottom). + * Parameters: + * box: Window handle of the box to be packed into. + * item: Window handle of the item to be back. + * width: Width in pixels of the item or -1 to be self determined. + * height: Height in pixels of the item or -1 to be self determined. + * hsize: TRUE if the window (widget) should expand horizontally to fill space given. + * vsize: TRUE if the window (widget) should expand vertically to fill space given. + * pad: Number of pixels of padding around the item. + */ +void dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) +{ + Box *thisbox; + + thisbox = (Box *)GetWindowLong(box, GWL_USERDATA); + if(thisbox) + { + int z; + Item *tmpitem, *thisitem = thisbox->items; + char tmpbuf[100]; + + tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); + + for(z=0;z<thisbox->count;z++) + { + tmpitem[z+1] = thisitem[z]; + } + + GetClassName(item, tmpbuf, 99); + + if(strnicmp(tmpbuf, FRAMECLASSNAME, 2)==0) + tmpitem[0].type = TYPEBOX; + else + tmpitem[0].type = TYPEITEM; + + tmpitem[0].hwnd = item; + tmpitem[0].origwidth = tmpitem[0].width = width; + tmpitem[0].origheight = tmpitem[0].height = height; + tmpitem[0].pad = pad; + if(hsize) + tmpitem[0].hsize = SIZEEXPAND; + else + tmpitem[0].hsize = SIZESTATIC; + + if(vsize) + tmpitem[0].vsize = SIZEEXPAND; + else + tmpitem[0].vsize = SIZESTATIC; + + thisbox->items = tmpitem; + + if(thisbox->count) + free(thisitem); + + thisbox->count++; + + SetParent(item, box); + ShowWindow(item, SW_SHOW); + if(strncmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS))==0) + { + ColorInfo *cinfo = (ColorInfo *)GetWindowLong(item, GWL_USERDATA); + + if(cinfo) + { + SetParent(cinfo->buddy, box); + ShowWindow(cinfo->buddy, SW_SHOW); + SendMessage(item, UDM_SETBUDDY, (WPARAM)cinfo->buddy, 0); + } + } + } +} + +/* + * Returns some information about the current operating environment. + * Parameters: + * env: Pointer to a DWEnv struct. + */ +void dw_environment_query(DWEnv *env) +{ + if(!env) + return; + + /* Get the Windows version. */ + + env->MajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); + env->MinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion))); + + /* Get the build number for Windows NT/Windows 2000. */ + + env->MinorBuild = 0; + + if (dwVersion < 0x80000000) + { + if(env->MajorVersion == 5) + strcpy(env->osName, "Windows 2000"); + else + strcpy(env->osName, "Windows NT"); + + env->MajorBuild = (DWORD)(HIWORD(dwVersion)); + } + else + { + strcpy(env->osName, "Windows 95/98/ME"); + env->MajorBuild = 0; + } +} + +/* + * Opens a file dialog and queries user selection. + * Parameters: + * title: Title bar text for dialog. + * defpath: The default path of the open dialog. + * ext: Default file extention. + * flags: DW_FILE_OPEN or DW_FILE_SAVE. + * Returns: + * NULL on error. A malloced buffer containing + * the file path on success. + * + */ +char *dw_file_browse(char *title, char *defpath, char *ext, int flags) +{ + OPENFILENAME of; + char filenamebuf[1001] = ""; + int rc; + + if(ext) + { + strcpy(filenamebuf, "*."); + strcat(filenamebuf, ext); + } + + memset(&of, 0, sizeof(OPENFILENAME)); + + of.lStructSize = sizeof(OPENFILENAME); + of.hwndOwner = HWND_DESKTOP; + of.hInstance = DWInstance; + of.lpstrInitialDir = defpath; + of.lpstrTitle = title; + of.lpstrFile = filenamebuf; + of.nMaxFile = 1000; + of.lpstrDefExt = ext; + of.Flags = 0; + + if(flags & DW_FILE_SAVE) + rc = GetSaveFileName(&of); + else + rc = GetOpenFileName(&of); + + if(rc) + return strdup(of.lpstrFile); + + return NULL; +} + +/* + * Execute and external program in a seperate session. + * Parameters: + * program: Program name with optional path. + * type: Either DW_EXEC_CON or DW_EXEC_GUI. + * params: An array of pointers to string arguements. + * Returns: + * -1 on error. + */ +int dw_exec(char *program, int type, char **params) +{ + char **newparams; + int retcode, count = 0, z; + + while(params[count]) + { + count++; + } + + newparams = (char **)malloc(sizeof(char *) * (count+1)); + + for(z=0;z<count;z++) + { + newparams[z] = malloc(strlen(params[z])+3); + strcpy(newparams[z], "\""); + strcat(newparams[z], params[z]); + strcat(newparams[z], "\""); + } + newparams[count] = NULL; + + retcode = spawnvp(P_NOWAIT, program, newparams); + + for(z=0;z<count;z++) + { + free(newparams[z]); + } + free(newparams); + + return retcode; +} + +/* + * Loads a web browser pointed at the given URL. + * Parameters: + * url: Uniform resource locator. + */ +int dw_browse(char *url) +{ + char *browseurl = url; + int retcode; + + if(strlen(url) > 7 && strncmp(url, "file://", 7) == 0) + { + int len, z; + + browseurl = &url[7]; + len = strlen(browseurl); + + for(z=0;z<len;z++) + { + if(browseurl[z] == '|') + browseurl[z] = ':'; + if(browseurl[z] == '/') + browseurl[z] = '\\'; + } + } + + retcode = (int)ShellExecute(NULL, "open", browseurl, NULL, NULL, SW_SHOWNORMAL); + if(retcode<33 && retcode != 2) + return -1; + return 1; +} + +/* + * Returns a pointer to a static buffer which containes the + * current user directory. Or the root directory (C:\ on + * OS/2 and Windows). + */ +char *dw_user_dir(void) +{ + static char _user_dir[1024] = ""; + + if(!_user_dir[0]) + { + /* Figure out how to do this the "Windows way" */ + char *home = getenv("HOME"); + + if(home) + strcpy(_user_dir, home); + else + strcpy(_user_dir, "C:\\"); + } + return _user_dir; +} + +/* + * Call a function from the window (widget)'s context. + * Parameters: + * handle: Window handle of the widget. + * function: Function pointer to be called. + * data: Pointer to the data to be passed to the function. + */ +void dw_window_function(HWND handle, void *function, void *data) +{ + SendMessage(handle, WM_USER, (WPARAM)function, (LPARAM)data); +} + +#ifndef NO_SIGNALS +/* + * Add a callback to a window event. + * Parameters: + * window: Window handle of signal to be called back. + * signame: A string pointer identifying which signal to be hooked. + * sigfunc: The pointer to the function to be used as the callback. + * data: User data to be passed to the handler function. + */ +void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) +{ + ULONG message = 0L; + + if(window && signame && sigfunc) + { + if((message = _findsigmessage(signame)) != 0) + _new_signal(message, window, sigfunc, data); + } +} + +/* + * Removes callbacks for a given window with given name. + * Parameters: + * window: Window handle of callback to be removed. + */ +void dw_signal_disconnect_by_name(HWND window, char *signame) +{ + SignalHandler *prev = NULL, *tmp = Root; + ULONG message; + + if(!window || !signame || (message = _findsigmessage(signame)) == 0) + return; + + while(tmp) + { + if(tmp->window == window && tmp->message == message) + { + if(prev) + { + prev->next = tmp->next; + free(tmp); + tmp = prev->next; + } + else + { + Root = tmp->next; + free(tmp); + tmp = Root; + } + } + else + { + prev = tmp; + tmp = tmp->next; + } + } +} + +/* + * Removes all callbacks for a given window. + * Parameters: + * window: Window handle of callback to be removed. + */ +void dw_signal_disconnect_by_window(HWND window) +{ + SignalHandler *prev = NULL, *tmp = Root; + + while(tmp) + { + if(tmp->window == window) + { + if(prev) + { + prev->next = tmp->next; + free(tmp); + tmp = prev->next; + } + else + { + Root = tmp->next; + free(tmp); + tmp = Root; + } + } + else + { + prev = tmp; + tmp = tmp->next; + } + } +} + +/* + * Removes all callbacks for a given window with specified data. + * Parameters: + * window: Window handle of callback to be removed. + * data: Pointer to the data to be compared against. + */ +void dw_signal_disconnect_by_data(HWND window, void *data) +{ + SignalHandler *prev = NULL, *tmp = Root; + + while(tmp) + { + if(tmp->window == window && tmp->data == data) + { + if(prev) + { + prev->next = tmp->next; + free(tmp); + tmp = prev->next; + } + else + { + Root = tmp->next; + free(tmp); + tmp = Root; + } + } + else + { + prev = tmp; + tmp = tmp->next; + } + } +} +#endif + +#ifdef TEST +HWND mainwindow, + listbox, + okbutton, + cancelbutton, + lbbox, + stext, + buttonbox, + testwindow, + testbox, + testok, + testcancel, + testbox2, + testok2, + testcancel2, + notebook; +int count = 2; + +#ifdef USE_FILTER +/* Do any handling you need in the filter function */ +LONG testfilter(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) +{ + switch(msg) + { + case WM_COMMAND: + switch (COMMANDMSG(&msg)->cmd) + { + case 1001L: + case 1002L: + dw_window_destroy(mainwindow);; + count--; + break; + case 1003L: + case 1004L: + dw_window_destroy(testwindow);; + count--; + break; + } + if(!count) + exit(0); + break; + } + /* Return -1 to allow the default handlers to return. */ + return TRUE; +} +#else +int test_callback(HWND window, void *data) +{ + dw_window_destroy((HWND)data); + /* Return -1 to allow the default handlers to return. */ + count--; + if(!count) + exit(0); + return -1; +} +#endif + +/* + * Let's demonstrate the functionality of this library. :) + */ +int WINAPI WinMain( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow +) +{ + ULONG flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | + DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; + int pageid; + + dw_init(TRUE); + + /* Try a little server dialog. :) */ + mainwindow = dw_window_new(HWND_DESKTOP, "Server", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX); + + lbbox = dw_box_new(BOXVERT, 10); + + dw_box_pack_start(mainwindow, lbbox, 0, 0, TRUE, TRUE, 0); + + stext = dw_text_new("Choose a server:", 0); + + dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER); + + dw_box_pack_start(lbbox, stext, 130, 15, FALSE, FALSE, 10); + + listbox = dw_listbox_new(100L, FALSE); + + dw_box_pack_start(lbbox, listbox, 130, 200, TRUE, TRUE, 10); + + buttonbox = dw_box_new(BOXHORZ, 0); + + dw_box_pack_start(lbbox, buttonbox, 0, 0, TRUE, TRUE, 0); + + okbutton = dw_button_new("Ok", 1001L); + + dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, TRUE, 5); + + cancelbutton = dw_button_new("Cancel", 1002L); + + dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, TRUE, 5); + + /* Set some nice fonts and colors */ + dw_window_set_color(lbbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + dw_window_set_color(buttonbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + dw_window_set_font(stext, "9.WarpSans"); + dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY); + dw_window_set_font(listbox, "9.WarpSans"); + dw_window_set_font(okbutton, "9.WarpSans"); + dw_window_set_font(cancelbutton, "9.WarpSans"); + + dw_window_show(mainwindow); + + dw_window_set_usize(mainwindow, 170, 340); + + /* Another small example */ + flStyle |= DW_FCF_MINMAX | DW_FCF_SIZEBORDER; + + testwindow = dw_window_new(HWND_DESKTOP, "Wow a test dialog! :) yay!", flStyle); + + testbox = dw_box_new(BOXVERT, 0); + + dw_box_pack_start(testwindow, testbox, 0, 0, TRUE, TRUE, 0); + + notebook = dw_notebook_new(1010L, TRUE); + + dw_box_pack_start(testbox, notebook, 100, 100, TRUE, TRUE, 0); + + testbox = dw_box_new(BOXVERT, 10); + + pageid = dw_notebook_page_new(notebook, 0L, FALSE); + + dw_notebook_page_set_text(notebook, pageid, "Test page"); + dw_notebook_page_set_status_text(notebook, pageid, "Test page"); + + dw_notebook_pack(notebook, pageid, testbox); + + testok = dw_button_new("Ok", 1003L); + + dw_box_pack_start(testbox, testok, 60, 40, TRUE, TRUE, 10); + + testcancel = dw_button_new("Cancel", 1004L); + + dw_box_pack_start(testbox, testcancel, 60, 40, TRUE, TRUE, 10); + + testbox2 = dw_box_new(BOXHORZ, 0); + + dw_box_pack_start(testbox, testbox2, 0, 0, TRUE, TRUE, 0); + + testok2 = dw_button_new("Ok", 1003L); + + dw_box_pack_start(testbox2, testok2, 60, 40, TRUE, TRUE, 10); + + dw_box_pack_splitbar_start(testbox2); + + testcancel2 = dw_button_new("Cancel", 1004L); + + dw_box_pack_start(testbox2, testcancel2, 60, 40, TRUE, TRUE, 10); + + /* Set some nice fonts and colors */ + dw_window_set_color(testbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + dw_window_set_color(testbox2, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + dw_window_set_font(testok, "9.WarpSans"); + dw_window_set_font(testcancel, "9.WarpSans"); + dw_window_set_font(testok2, "9.WarpSans"); + dw_window_set_font(testcancel2, "9.WarpSans"); + + dw_window_show(testwindow); + +#ifdef USE_FILTER + + dw_main(0L, (void *)testfilter); +#else + /* Setup the function callbacks */ + dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); + dw_signal_connect(cancelbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); + dw_signal_connect(testok, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); + dw_signal_connect(testcancel, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); + dw_signal_connect(testok2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); + dw_signal_connect(testcancel2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); + dw_signal_connect(mainwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); + dw_signal_connect(testwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); + + dw_main(0L, NULL); +#endif + + return 0; +} +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/winmain.c Tue Jul 03 07:50:39 2001 +0000 @@ -0,0 +1,108 @@ +/* Dynamic Windows stub file to allow Win32 applications + * to use the main() entry point instead of WinMain(). + */ + +#include <windows.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <process.h> + +void Win32_Set_Instance(HINSTANCE hInstance); + +char **_convertargs(int *count, char *start, HINSTANCE DWInstance) +{ + char *tmp, *argstart, **argv; + int loc = 0, inquotes = 0; + + (*count) = 1; + + tmp = start; + + /* Count the number of entries */ + if(*start) + { + (*count)++; + + while(*tmp) + { + if(*tmp == '"' && inquotes) + inquotes = 0; + else if(*tmp == '"' && !inquotes) + inquotes = 1; + else if(*tmp == ' ' && !inquotes) + { + /* Push past any white space */ + while(*(tmp+1) == ' ') + tmp++; + /* If we aren't at the end of the command + * line increment the count. + */ + if(*(tmp+1)) + (*count)++; + } + tmp++; + } + } + + argv = (char **)malloc(sizeof(char *) * ((*count)+1)); + argv[0] = malloc(260); + GetModuleFileName(DWInstance, argv[0], 260); + + argstart = tmp = start; + + if(*start) + { + loc = 1; + + while(*tmp) + { + if(*tmp == '"' && inquotes) + { + *tmp = 0; + inquotes = 0; + } + else if(*tmp == '"' && !inquotes) + { + argstart = tmp+1; + inquotes = 1; + } + else if(*tmp == ' ' && !inquotes) + { + *tmp = 0; + argv[loc] = strdup(argstart); + + /* Push past any white space */ + while(*(tmp+1) == ' ') + tmp++; + + /* Move the start pointer */ + argstart = tmp+1; + + /* If we aren't at the end of the command + * line increment the count. + */ + if(*(tmp+1)) + loc++; + } + tmp++; + } + if(*argstart) + argv[loc] = strdup(argstart); + } + argv[loc+1] = NULL; + return argv; +} + +/* Ok this is a really big hack but what the hell ;) */ +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +{ + char **argv; + int argc; + + Win32_Set_Instance(hInstance); + + argv = _convertargs(&argc, lpCmdLine, hInstance); + + return main(argc, argv); +}