diff --git a/fltk-config.in b/fltk-config.in new file mode 100755 index 000000000..24253987e --- /dev/null +++ b/fltk-config.in @@ -0,0 +1,246 @@ +#! /bin/sh +# +# fltk-config +# +# original version by James Dean Palmer, adapted by Vincent Penne +# +# "$Id: fltk-config.in,v 1.12 2001/08/05 10:48:38 spitzak Exp $" +# + +MAJOR_VERSION=2 +MINOR_VERSION=0 +PATCH_VERSION=0 +VERSION="$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION" + +### BEGIN fltk-config + +# Calculate the prefix from the location of *this* file +prefix=`echo "$0" | sed 's/\/bin\/fltk-config// +s/\/fltk-config//'` + +#prefix=@prefix@ +exec_prefix=@exec_prefix@ +exec_prefix_set=no +bindir=@bindir@ +includedir=@includedir@ +libdir=@libdir@ +srcdir=@srcdir@ + +# compiler names +CXX="@CXX@" +CC="@CC@" + +# flags for C++ compiler: +CFLAGS="@CFLAGS@" +CXXFLAGS="@CXXFLAGS@" + +# program to make the archive: +LIBNAME="@LIBNAME@" +LIBCOMMAND="@LIBCOMMAND@" +RANLIB="@RANLIB@" +DSOLIBNAME="@DSOLIBNAME@" +DSOCOMMAND="@DSOCOMMAND@" + +# flags for the linker +LD_PLUGIN_FLAGS="@LD_PLUGIN_FLAGS@" + +# libraries to link with: +IMAGELIBS="@LIBPNG@ @LIBJPEG@" + +# programs to make archive and build DSOs +RANLIB="@RANLIB@" +DSOCOMMAND="@DSOCOMMAND@" + +usage () +{ + echo "Usage: fltk-config [OPTIONS] +Options: + [--prefix[=DIR]] return/set where FLTK is installed + [--exec-prefix[=DIR]] + [--version] + +options telling what we are doing : + [--use-gl] use GL + [--use-images] use extra image formats (PNG, Jpeg) + [--use-glut] use glut compatibility layer + [--use-forms] use forms compatibility layer + [--multithread] build a multithreaded program + [--build-plugin] build a plugin + [--no-plugins] build a program unable to load plugins (Linux only) + +options telling what information we request + [--cflags] return flags to compile C using FLTK + [--cxxflags] return flags to compile C++ using FLTK + [--ldflags] return flags to link against FLTK + [--ldstaticflags] return flags to link against static FLTK library + even if there are DSOs installed + [--libs] return FLTK libraries full path for dependencies +" + exit $1 +} + +if test $# -eq 0; then usage 1 +fi + +no_plugins=no + +# Parse command line options +while test $# -gt 0 +do + case "$1" in + -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + case $1 in + --prefix=*) + prefix=$optarg + if test $exec_prefix_set = no ; then + exec_prefix=$optarg + fi + ;; + --prefix) + echo_prefix=yes + ;; + --exec-prefix=*) + exec_prefix=$optarg + exec_prefix_set=yes + ;; + --exec-prefix) + echo_exec_prefix=yes + ;; + --version) + echo $VERSION + ;; + --use-gl) + use_gl=yes + ;; + --use-glut) + use_glut=yes + use_gl=yes + ;; + --use-images) + use_images=yes + ;; + --use-forms) + use_forms=yes + ;; + --multithread) + use_threads=yes + ;; + --build-plugin) + build_plugin=yes + ;; + --no-plugins) + no_plugins=yes + ;; + --cflags) + echo_cflags=yes + ;; + --cxxflags) + echo_cxxflags=yes + ;; + --ldflags) + echo_ldflags=yes + ;; + --ldstaticflags) + echo_ldstaticflags=yes + ;; + --libs) + echo_libs=yes + ;; + *) + echo_help=yes + ;; + esac + shift +done + +# Calculate needed libraries +LDLIBS="" +LDSTATIC="" +LIBS="" +if test "$use_forms" = "yes"; then + LDLIBS="$LDLIBS -lfltk_forms" + LDSTATIC="$LDSTATIC $prefix/lib/libfltk_forms.a" + LIBS="$LIBS $prefix/lib/libfltk_forms.a" +fi +if test "$use_glut" = "yes"; then + LDLIBS="$LDLIBS -lfltk_glut" + LDSTATIC="$LDSTATIC $prefix/lib/libfltk_glut.a" + LIBS="$LIBS $prefix/lib/libfltk_glut.a" +fi +if test "$use_gl" = "yes"; then + LDLIBS="$LDLIBS -lfltk_gl @GLLIB@" + LDSTATIC="$LDSTATIC $prefix/lib/libfltk_gl.a @GLLIB@" + LIBS="$LIBS $prefix/lib/libfltk_gl.a" +fi +if test "$use_images" = "yes"; then + LDLIBS="$LDLIBS -lfltk_images $IMAGELIBS" + LDSTATIC="$LDSTATIC $prefix/lib/libfltk_images.a $IMAGELIBS" + LIBS="$LIBS $prefix/lib/libfltk_images.a" +fi +if test "$build_plugin" = "yes"; then + LDLIBS="$LDLIBS $LD_PLUGIN_FLAGS" + LDSTATIC="$LDSTATIC $LD_PLUGIN_FLAGS" +fi +LDLIBS="$LDLIBS -lfltk @LDFLAGS@ @LIBS@ @LDLIBS@ -lm" +LDSTATIC="$LDSTATIC $prefix/lib/libfltk.a @LDFLAGS@ @LIBS@ @LDLIBS@ -lm" +LIBS="$LIBS $prefix/lib/libfltk.a" +if test "$use_threads" = "yes"; then + LDLIBS="$LDLIBS @THREADSLIBS@" + LDSTATIC="$LDSTATIC @THREADSLIBS@" +fi +if test "$no_plugins" = "no"; then + LDLIBS="$LDLIBS @LD_DLOPEN_FLAGS@" + LDSTATIC="$LDSTATIC @LD_DLOPEN_FLAGS@" +fi + +# Answer to user requests +if test -n "$echo_help"; then usage 1 +fi + +if test "$echo_prefix" = "yes"; then + echo $prefix +fi + +if test "$echo_exec_prefix" = "yes"; then + echo $exec_prefix +fi + +if test "$echo_cflags" = "yes"; then + includes=-I`echo "$0" | sed 's/\/bin\/fltk-config/\/include/ +s/\/fltk-config//'` + echo $includes $CFLAGS +fi + +if test "$echo_cxxflags" = "yes"; then + includes=-I`echo "$0" | sed 's/\/bin\/fltk-config/\/include/ +s/\/fltk-config//'` + echo $includes $CXXFLAGS +fi + +if test "$echo_ldflags" = "yes"; then + my_libs= + libdirs=-L${exec_prefix}/lib + for i in $LDLIBS ; do + if test $i != -L${exec_prefix}/lib ; then + if test -z "$my_libs" ; then + my_libs="$i" + else + my_libs="$my_libs $i" + fi + fi + done + echo $libdirs $my_libs +fi + +if test "$echo_ldstaticflags" = "yes"; then + echo $LDSTATIC +fi + +if test "$echo_libs" = "yes"; then + echo $LIBS +fi + +# END of fltk-config diff --git a/src/Fl_Shared_Image.cxx b/src/Fl_Shared_Image.cxx new file mode 100644 index 000000000..fffcb3ea0 --- /dev/null +++ b/src/Fl_Shared_Image.cxx @@ -0,0 +1,261 @@ +// +// "$Id: Fl_Shared_Image.cxx,v 1.23 2001/09/10 01:16:17 spitzak Exp $" +// +// Image drawing code for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-1999 by Bill Spitzak and others. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// +// Please report all bugs and problems to "fltk-bugs@easysw.com". +// + +// Draw an image that is stored compressed in a file or in memory. +// Keep uncompressed images in memory for later use. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +FL_IMAGES_API const char *Fl_Shared_Image::fl_shared_image_root=0; + +FL_IMAGES_API Fl_Shared_Image *Fl_Shared_Image::first_image = 0; + +FL_IMAGES_API int Fl_Shared_Image::image_used=0; +FL_IMAGES_API size_t Fl_Shared_Image::mem_usage_limit=0; + +FL_IMAGES_API size_t Fl_Shared_Image::mem_used=0; +FL_IMAGES_API int Fl_Shared_Image::forbid_delete = 1; + +// static size_t mem_used=0; (now moved to Fl.cxx !) +// This contains the total number of pixmap pixels in the cache +// WARNING : this is updated incrementally, so beware that it keeps balanced +// when deleting or creating pixmaps ! + +Fl_Shared_Image::~Fl_Shared_Image() +{ + if(forbid_delete) + fprintf(stderr, + "FLTK user error : deleting an Fl_Shared_Image object is forbiden !\n"); + if(id) mem_used -= w*h; +} + +void Fl_Shared_Image::set_cache_size(size_t l) +{ + mem_usage_limit = l; +} + +static Fl_Shared_Image *limage; // used to find the less used image +void Fl_Shared_Image::find_less_used() { + if(l1) l1->find_less_used(); + if(l2) l2->find_less_used(); + if(id && (limage->id == 0 || usedused)) limage=this; +} +void Fl_Shared_Image::check_mem_usage() +{ + if(mem_usage_limit==0 || first_image==NULL || mem_used < mem_usage_limit) + return; + + do { + limage=first_image; + first_image->find_less_used(); + if(limage->id) { + mem_used -= limage->w*limage->h; + fl_delete_offscreen(Pixmap(limage->id)); + limage->id=0; + if(limage->mask) { + fl_delete_bitmap(Pixmap(limage->mask)); + limage->mask = 0; + } + } else return; + } while(mem_used >= mem_usage_limit); +} + + +class fl_shared_image_destructor_class { + int dummy; +public: + fl_shared_image_destructor_class() { dummy = 0; } + ~fl_shared_image_destructor_class() { + if (Fl_Shared_Image::first_image) Fl_Shared_Image::first_image->clear_cache(); + } +}; + +fl_shared_image_destructor_class fl_shared_image_destructor; + +void Fl_Shared_Image::clear_cache() +{ + if(id) { + mem_used -= w*h; + fl_delete_offscreen((Pixmap)id); + id=0; + if(mask) { + fl_delete_bitmap((Pixmap)mask); + mask = 0; + } + } + if (l1) l1->clear_cache(); + if (l2) l2->clear_cache(); +} + +void Fl_Shared_Image::set_root_directory(const char *d) { + fl_shared_image_root = d; +} + +void Fl_Shared_Image::insert(Fl_Shared_Image*& p, Fl_Shared_Image* image) { + if(p == 0) + p = image; + else { + int c = strcmp(image->name, p->name); + if(c<0) insert(p->l1, image); + else insert(p->l2, image); + } +} + +Fl_Shared_Image* Fl_Shared_Image::find(Fl_Shared_Image* image, const char* name) { + if(image == 0) return 0; + int c = strcmp(name, image->name); + if(c == 0) return image; + else if(c<0) return find(image->l1, name); + else return find(image->l2, name); +} + + +const char* Fl_Shared_Image::get_filename() { + return get_filename(name); +} + +const char* Fl_Shared_Image::get_filename(const char* name) +{ + if (name[0] == '/' || !fl_shared_image_root || !*fl_shared_image_root) + return name; + int m = strlen(fl_shared_image_root); + int n = strlen(name) + m + 2; + static char *s; + if (s) free(s); + s = (char*) malloc(n+1); + strcpy(s, fl_shared_image_root); + if (s[m-1] != '/') s[m++] = '/'; + strcpy(s+m, name); + return s; +} + + +Fl_Shared_Image* Fl_Shared_Image::get(Fl_Shared_Image* (*create)(), + const char* name, const uchar *datas) +{ + Fl_Shared_Image *image=Fl_Shared_Image::find(first_image, name); + if(!image) + { + image=create(); + image->refcount = 1; + image->name = strdup(name); + image->datas=datas; + image->w = -1; // We mark the fact the it has never been measured yet + image->l1 = image->l2 = 0; + image->id=image->mask=0; + Fl_Shared_Image::insert(first_image, image); + } else { + if(image->datas==NULL) image->datas=datas; + image->refcount++; + } + image->used = image_used++; + return image; +} + +void Fl_Shared_Image::reload(const uchar* pdatas) +{ + if (id) { + mem_used -= w*h; + fl_delete_offscreen((Pixmap)id); + id=0; + if (mask) { + fl_delete_bitmap((Pixmap)mask); + mask = 0; + } + } + if (pdatas) datas = pdatas; + measure(w, h); +} +void Fl_Shared_Image::reload(const char* name, const uchar* pdatas) +{ + Fl_Shared_Image *image=Fl_Shared_Image::find(first_image, name); + if (image) image->reload(pdatas); +} + +void Fl_Shared_Image::remove_from_tree(Fl_Shared_Image*& p, Fl_Shared_Image* image) { + if (p) { + int c = strcmp(image->name, p->name); + if (c == 0) { + if (image->l1) { + p = image->l1; + if (image->l2) insert(first_image, image->l2); + } else + p = image->l2; + } else if (c<0) remove_from_tree(p->l1, image); + else remove_from_tree(p->l2, image); + } +} + +int Fl_Shared_Image::remove() +{ + if (--refcount) return 0; + remove_from_tree(first_image, this); + forbid_delete = 0; + delete this; + forbid_delete = 1; + return 1; +} +int Fl_Shared_Image::remove(const char* name) +{ + Fl_Shared_Image *image=Fl_Shared_Image::find(first_image, name); + if (image) return image->remove(); + else return 0; +} + +void Fl_Shared_Image::draw(int X, int Y, Fl_Flags flags) +{ + if (w<0) measure(w, h); + if (w==0) return; + if (!id) // Need to uncompress the image ? + { + used = image_used++; // do this before check_mem_usage + mem_used += w*h; + check_mem_usage(); + + read(); + if (!id) { // could not read the image for some reason ? + mem_used -= w*h; + w = 0; // Will never try again ... + return; + } + } + else + used = image_used++; + _draw(X, Y, flags); +} + +// +// End of "$Id: Fl_Shared_Image.cxx,v 1.23 2001/09/10 01:16:17 spitzak Exp $" +// diff --git a/src/fl_dnd_win32.cxx b/src/fl_dnd_win32.cxx new file mode 100644 index 000000000..6d4b5ab48 --- /dev/null +++ b/src/fl_dnd_win32.cxx @@ -0,0 +1,56 @@ +// +// "$Id: fl_dnd_win32.cxx,v 1.5 2001/09/10 01:16:17 spitzak Exp $" +// +// Drag & Drop code for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-1999 by Bill Spitzak and others. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// +// Please report all bugs and problems to "fltk-bugs@easysw.com". +// + + +// Dummy version of dnd for now, it waits until the FL_RELEASE and +// then does nothing. The real version should drag the ascii text stored +// in selection_buffer (length = selection_length) and drop it on the +// target. It should either not return until the mouse is released +// or it should cause the DRAG+RELEASE events to not be passed to the +// program somehow. I'm pretty sure this is a simple call in _WIN32: + +#include +#include + +static bool grabfunc(int event) { + if (event == FL_RELEASE) Fl::pushed(0); + return false; +} + +extern bool (*fl_local_grab)(int); // in Fl.cxx + +bool Fl::dnd() { + Fl::first_window()->cursor(FL_CURSOR_HAND); + fl_local_grab = grabfunc; + while (Fl::pushed()) Fl::wait(); + Fl::first_window()->cursor(FL_CURSOR_DEFAULT); + fl_local_grab = 0; + return true; +} + + +// +// End of "$Id: fl_dnd_win32.cxx,v 1.5 2001/09/10 01:16:17 spitzak Exp $". +//