Multiple patches from Bill:

- Double-buffered window fixes.
  - Tabs fixes.
  - X/WIN32 fixes.
  - Fl_Input fixes.
  - Support for vsnprintf and friends.
  - Support for printf-style arguments in utility functions.


git-svn-id: file:///fltk/svn/fltk/trunk@52 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 1998-11-05 16:04:53 +00:00
parent 60399e3945
commit 80b1529ef4
26 changed files with 454 additions and 305 deletions

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Browser.H,v 1.4 1998/10/21 14:18:59 mike Exp $"
// "$Id: Fl_Browser.H,v 1.5 1998/11/05 16:04:37 mike Exp $"
//
// Browser header file for the Fast Light Tool Kit (FLTK).
//
@ -79,6 +79,7 @@ public:
int selected(int) const ;
void show(int n);
void hide(int n);
void hide() {Fl_Widget::hide();}
int visible(int n) const ;
int value() const ;
@ -107,5 +108,5 @@ public:
#endif
//
// End of "$Id: Fl_Browser.H,v 1.4 1998/10/21 14:18:59 mike Exp $".
// End of "$Id: Fl_Browser.H,v 1.5 1998/11/05 16:04:37 mike Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Double_Window.H,v 1.4 1998/10/21 14:19:05 mike Exp $"
// "$Id: Fl_Double_Window.H,v 1.5 1998/11/05 16:04:38 mike Exp $"
//
// Double-buffered window header file for the Fast Light Tool Kit (FLTK).
//
@ -29,6 +29,8 @@
#include "Fl_Window.H"
class Fl_Double_Window : public Fl_Window {
protected:
void flush(int eraseoverlay);
public:
void show();
void show(int a, char **b) {Fl_Window::show(a,b);}
@ -44,5 +46,5 @@ public:
#endif
//
// End of "$Id: Fl_Double_Window.H,v 1.4 1998/10/21 14:19:05 mike Exp $".
// End of "$Id: Fl_Double_Window.H,v 1.5 1998/11/05 16:04:38 mike Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: fl_ask.H,v 1.3 1998/10/21 14:19:44 mike Exp $"
// "$Id: fl_ask.H,v 1.4 1998/11/05 16:04:39 mike Exp $"
//
// Standard dialog header file for the Fast Light Tool Kit (FLTK).
//
@ -28,15 +28,13 @@
class Fl_Widget;
void fl_message(const char *);
void fl_alert(const char *);
int fl_ask(const char *);
int fl_choice(const char *q,const char *b0,const char *b1,const char *b2);
const char *fl_input(const char *label, const char *deflt, unsigned char type);
const char *fl_input(const char *label, const char *deflt = 0);
inline const char *fl_password(const char *label, const char *deflt = 0) {
return fl_input(label, deflt, 5);
}
void fl_message(const char *,...);
void fl_alert(const char *,...);
int fl_ask(const char *,...);
int fl_choice(const char *q,const char *b0,const char *b1,const char *b2,...);
const char *fl_input(const char *label, const char *deflt = 0, ...);
const char *fl_password(const char *label, const char *deflt = 0, ...);
Fl_Widget *fl_message_icon();
extern unsigned char fl_message_font_;
extern unsigned char fl_message_size_;
@ -49,27 +47,8 @@ extern const char* fl_yes;
extern const char* fl_ok;
extern const char* fl_cancel;
// back compatability and XForms compatability functions:
inline int fl_show_question(const char *c) {return fl_ask(c);}
void fl_show_message(const char *,const char *,const char *);
void fl_show_alert(const char *,const char *,const char *);
int fl_show_question(const char *,const char *,const char *);
inline const char *fl_show_input(const char *l,const char*d=0) {return fl_input(l,d);}
/*const*/ char *fl_show_simple_input(const char *label, const char *deflt = 0);
// all are implemented using this:
int fl_show_choice(
const char *m1,
const char *m2,
const char *m3,
int numb,
const char *b0,
const char *b1,
const char *b2);
#endif
//
// End of "$Id: fl_ask.H,v 1.3 1998/10/21 14:19:44 mike Exp $".
// End of "$Id: fl_ask.H,v 1.4 1998/11/05 16:04:39 mike Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: forms.H,v 1.3 1998/10/21 14:19:47 mike Exp $"
// "$Id: forms.H,v 1.4 1998/11/05 16:04:39 mike Exp $"
//
// Forms emulation header file for the Fast Light Tool Kit (FLTK).
//
@ -648,9 +648,21 @@ fl_add_free(int t,double x,double y,double w,double h,const char* l,
#include "fl_ask.H"
#include "fl_show_colormap.H"
inline int fl_show_question(const char* c, int) {return fl_ask(c);}
inline void fl_show_alert(const char* a,const char*b,const char*c,int) {
fl_show_alert(a,b,c);}
inline int fl_show_question(const char* c, int = 0) {return fl_ask(c);}
void fl_show_message(const char *,const char *,const char *);
void fl_show_alert(const char *,const char *,const char *,int=0);
int fl_show_question(const char *,const char *,const char *);
inline const char *fl_show_input(const char *l,const char*d=0) {return fl_input(l,d);}
/*const*/ char *fl_show_simple_input(const char *label, const char *deflt = 0);
int fl_show_choice(
const char *m1,
const char *m2,
const char *m3,
int numb,
const char *b0,
const char *b1,
const char *b2);
inline void fl_set_goodies_font(uchar a, uchar b) {fl_message_font(a,b);}
#define fl_show_messages fl_message
inline int fl_show_choices(const char* c,int n,const char* b1,const char* b2,
@ -829,5 +841,5 @@ inline void fl_draw() {Fl::flush();}
#endif /* define __FORMS_H__ */
//
// End of "$Id: forms.H,v 1.3 1998/10/21 14:19:47 mike Exp $".
// End of "$Id: forms.H,v 1.4 1998/11/05 16:04:39 mike Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: glut.H,v 1.3 1998/10/21 14:19:49 mike Exp $"
// "$Id: glut.H,v 1.4 1998/11/05 16:04:40 mike Exp $"
//
// GLUT emulation header file for the Fast Light Tool Kit (FLTK).
//
@ -55,11 +55,12 @@
#include "Fl_Gl_Window.H"
class Fl_Glut_Window : public Fl_Gl_Window {
void _init();
int mouse_down;
protected:
void draw();
void draw_overlay();
int handle(int);
void _init();
int mouse_down;
public: // so the inline functions work
int number;
int menu[3];
@ -466,5 +467,5 @@ extern void glutSolidIcosahedron();
#endif /* __glut_h__ */
//
// End of "$Id: glut.H,v 1.3 1998/10/21 14:19:49 mike Exp $".
// End of "$Id: glut.H,v 1.4 1998/11/05 16:04:40 mike Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: win32.H,v 1.8 1998/10/21 14:19:50 mike Exp $"
// "$Id: win32.H,v 1.9 1998/11/05 16:04:41 mike Exp $"
//
// WIN32 header file for the Fast Light Tool Kit (FLTK).
//
@ -28,9 +28,11 @@
// portability of even the system-specific code...
#include <windows.h>
// In some of the distributions, the gcc header files are missing some stuff:
#ifndef LPMINMAXINFO
// the gcc header files are missing some stuff:
#define LPMINMAXINFO MINMAXINFO*
#endif
#ifndef VK_LWIN
#define VK_LWIN 0x5B
#define VK_RWIN 0x5C
#define VK_APPS 0x5D
@ -72,6 +74,7 @@ public:
HCURSOR cursor;
static Fl_X* first;
static Fl_X* i(const Fl_Window* w) {return w->i;}
static int get_border(const Fl_Window* w,int &bt,int &bx,int &by);
void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
void flush() {w->flush();}
void set_minmax(LPMINMAXINFO minmax);
@ -116,5 +119,5 @@ void fl_copy_offscreen(int x,int y,int w,int h,HBITMAP pixmap,int srcx,int srcy)
#define fl_delete_offscreen(bitmap) DeleteObject(bitmap);
//
// End of "$Id: win32.H,v 1.8 1998/10/21 14:19:50 mike Exp $".
// End of "$Id: win32.H,v 1.9 1998/11/05 16:04:41 mike Exp $".
//

7
FL/x.H
View File

@ -1,5 +1,5 @@
//
// "$Id: x.H,v 1.5 1998/10/21 14:19:51 mike Exp $"
// "$Id: x.H,v 1.6 1998/11/05 16:04:41 mike Exp $"
//
// X11 header file for the Fast Light Tool Kit (FLTK).
//
@ -91,7 +91,8 @@ public:
Fl_Window *w;
Region region;
Fl_X *next;
int wait_for_expose;
char wait_for_expose;
char backbuffer_bad; // used for XDBE
static Fl_X* first;
static Fl_X* i(const Fl_Window* w) {return w->i;}
void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
@ -115,5 +116,5 @@ extern int fl_background_pixel; // hack into Fl_X::make_xid()
#endif
//
// End of "$Id: x.H,v 1.5 1998/10/21 14:19:51 mike Exp $".
// End of "$Id: x.H,v 1.6 1998/11/05 16:04:41 mike Exp $".
//

View File

@ -1,5 +1,5 @@
#
# "$Id: Makefile,v 1.6 1998/10/21 22:03:51 mike Exp $"
# "$Id: Makefile,v 1.7 1998/11/05 16:04:35 mike Exp $"
#
# Top-level makefile for the Fast Light Tool Kit (FLTK).
#
@ -27,8 +27,8 @@ SHELL=/bin/sh
DIRS = src fluid test
all:
for dir in $(DIRS); do\
all: makeinclude
@for dir in $(DIRS); do\
echo "=== making $$dir ===";\
if test ! -f $$dir/makedepend; then\
touch $$dir/makedepend;\
@ -36,8 +36,8 @@ all:
(cd $$dir;$(MAKE));\
done
install:
for dir in $(DIRS); do\
install: makeinclude
@for dir in $(DIRS); do\
echo "=== installing $$dir ===";\
if test ! -f $$dir/makedepend; then\
touch $$dir/makedepend;\
@ -45,8 +45,8 @@ install:
(cd $$dir;$(MAKE) install);\
done
depend:
for dir in $(DIRS); do\
depend: makeinclude
@for dir in $(DIRS); do\
echo "=== making dependencies in $$dir ===";\
if test ! -f $$dir/makedepend; then\
touch $$dir/makedepend;\
@ -56,11 +56,14 @@ depend:
clean:
-@ rm -f core config.cache *.o *.bck
for dir in $(DIRS); do\
@for dir in $(DIRS); do\
echo "=== cleaning $$dir ===";\
(cd $$dir;$(MAKE) clean);\
done
makeinclude: configure configh.in makeinclude.in
./configure
#
# End of "$Id: Makefile,v 1.6 1998/10/21 22:03:51 mike Exp $".
# End of "$Id: Makefile,v 1.7 1998/11/05 16:04:35 mike Exp $".
#

30
README
View File

@ -98,32 +98,18 @@ WHAT DOES "FLTK" MEAN?
BUILDING AND INSTALLING FLTK UNDER UNIX
In most cases you can just type "make". This will run configure
with the default of no options and then compile everything.
FLTK uses GNU autoconf to configure itself for your UNIX platform.
If you aren't using UNIX then you'll need to configure things
differently. See below for other operating system configurations.
Before you configure FLTK you'll want to make sure your environment
is setup properly. Some variables of note are:
CC - C compiler to use
CFLAGS - C compiler options
CXX - C++ compiler to use
CXXFLAGS - C++ compiler options
LDFLAGS - Linker options
LIBS - Linker libraries
The main things that the configure script will look for are the
X11, OpenGL (or Mesa), and JPEG header and library files. Make
sure that they are in the standard include/library locations, and
if not define one or more of the environment variables listed
above.
sure that they are in the standard include/library locations.
Once you have everything ready you can run the "configure" script
located in this directory. The "--enable-windows-style" option to
configure will make the FLTK widgets look more like their Microsoft
Windows counterparts. Other options include:
You can run configure yourself to get the exact setup you need.
Type "./configure <options>". The "--enable-windows-style" option
will make the FLTK widgets look more like their Microsoft Windows
counterparts. Other options include:
--enable-debug - Enable debugging code & symbols
--enable-shared - Enable generation of shared libraries

View File

@ -1,5 +1,5 @@
/*
* "$Id: configh.in,v 1.6 1998/10/21 21:41:41 mike Exp $"
* "$Id: configh.in,v 1.7 1998/11/05 16:04:36 mike Exp $"
*
* Configuration file for the Fast Light Tool Kit (FLTK).
* @configure_input@
@ -122,6 +122,14 @@
#define HAVE_NDIR_H 0
#define HAVE_SCANDIR 0
/*
* possibly missing sprintf-style functions:
*/
#define HAVE_VSNPRINTF 0
#define HAVE_SNPRINTF 0
#define HAVE_VSPRINTF 0
/*
* HAVE_POLL:
*
@ -139,5 +147,5 @@
#define HAVE_LIBJPEG 0
/*
* End of "$Id: configh.in,v 1.6 1998/10/21 21:41:41 mike Exp $".
* End of "$Id: configh.in,v 1.7 1998/11/05 16:04:36 mike Exp $".
*/

View File

@ -1,7 +1,7 @@
dnl# -*- sh -*-
dnl# the "configure" script is made from this by running GNU "autoconf"
dnl#
dnl# "$Id: configure.in,v 1.10 1998/10/21 21:43:54 mike Exp $"
dnl# "$Id: configure.in,v 1.11 1998/11/05 16:04:37 mike Exp $"
dnl#
dnl# for the Fast Light Tool Kit (FLTK).
dnl#
@ -31,9 +31,9 @@ AC_PROG_RANLIB
LIBNAME="libfltk.a"
if test "$RANLIB" != ":"; then
LIBCOMMAND="ar crv"
LIBCOMMAND="ar cr"
else
LIBCOMMAND="ar crvs"
LIBCOMMAND="ar crs"
fi
DEBUGFLAG="-O2"
@ -99,6 +99,9 @@ fi
AC_HEADER_DIRENT
AC_CHECK_FUNCS(scandir)
AC_CHECK_FUNCS(vsnprintf)
AC_CHECK_FUNCS(snprintf)
AC_CHECK_FUNCS(vsprintf)
AC_PATH_XTRA
echo "Ignoring libraries \"$X_PRE_LIBS\" requested by configure."
@ -129,6 +132,28 @@ fi
MAKEDEPEND="\$(CXX) -M"
dnl# add warnings to compiler switches:
dnl# do this last so messing with switches does not break tests
if test -n "$GXX"; then
CFLAGS="-Wall $CFLAGS"
CXXFLAGS="-Wall -Wno-return-type $CXXFLAGS"
else
if test "`(uname) 2>/dev/null`" = IRIX; then
if expr "`(uname -r)`" \>= 6.2; then
CXX="CC -n32"
CC="cc -n32"
LD="ld -n32"
MAKEDEPEND="CC -M"
# -woff 3322 is necessary due to errors in Xlib headers on IRIX
CFLAGS="-fullwarn $CFLAGS"
CXXFLAGS="-fullwarn -woff 1685 -woff 3322 $CXXFLAGS"
MAKEDEPEND="CC -M"
else
CXXFLAGS="+w +pp $CXXFLAGS"
fi
fi
fi
AC_SUBST(LIBNAME)
AC_SUBST(LIBCOMMAND)
AC_SUBST(MAKEDEPEND)
@ -136,5 +161,5 @@ AC_CONFIG_HEADER(config.h:configh.in)
AC_OUTPUT(makeinclude)
dnl#
dnl# End of "$Id: configure.in,v 1.10 1998/10/21 21:43:54 mike Exp $".
dnl# End of "$Id: configure.in,v 1.11 1998/11/05 16:04:37 mike Exp $".
dnl#

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Widget_Type.cxx,v 1.4 1998/10/21 16:28:55 mike Exp $"
// "$Id: Fl_Widget_Type.cxx,v 1.5 1998/11/05 16:04:43 mike Exp $"
//
// Widget type code for the Fast Light Tool Kit (FLTK).
//
@ -758,7 +758,7 @@ void callback_cb(Fl_Input* i, void *v) {
} else {
const char *c = i->value();
const char *d = c_check(c);
if (d) {fl_show_message("Error in callback:",d,0); haderror = 1; return;}
if (d) {fl_message("Error in callback: %s",d); haderror = 1; return;}
for (Fl_Type *o = Fl_Type::first; o; o = o->next) if (o->selected) {
o->callback(c);
}
@ -771,7 +771,7 @@ void user_data_cb(Fl_Input *i, void *v) {
} else {
const char *c = i->value();
const char *d = c_check(c);
if (d) {fl_show_message("Error in user_data:",d,0); haderror = 1; return;}
if (d) {fl_message("Error in user_data: %s",d); haderror = 1; return;}
for (Fl_Type *o = Fl_Type::first; o; o = o->next) if (o->selected) {
o->user_data(c);
}
@ -793,7 +793,7 @@ void user_data_type_cb(Fl_Input *i, void *v) {
if (c && *c && c[strlen(c)-1] != '*' && strcmp(c,"long"))
d = "must be pointer or long";
}
if (d) {fl_show_message("Error in type:",d,0); haderror = 1; return;}
if (d) {fl_message("Error in type: %s",d); haderror = 1; return;}
for (Fl_Type *o = Fl_Type::first; o; o = o->next) if (o->selected) {
o->user_data_type(c);
}
@ -809,7 +809,7 @@ void v_input_cb(Fl_Input* i, void* v) {
} else {
const char *c = i->value();
const char *d = c_check(c&&c[0]=='#' ? c+1 : c);
if (d) {fl_show_message("Error in",i->label(),d); haderror = 1; return;}
if (d) {fl_message("Error in %s: %s",i->label(),d); haderror = 1; return;}
for (Fl_Type *o = Fl_Type::first; o; o = o->next)
if (o->selected && o->is_widget()) {
Fl_Widget_Type *t = (Fl_Widget_Type*)o;
@ -1699,5 +1699,5 @@ int Fl_Widget_Type::read_fdesign(const char* name, const char* value) {
}
//
// End of "$Id: Fl_Widget_Type.cxx,v 1.4 1998/10/21 16:28:55 mike Exp $".
// End of "$Id: Fl_Widget_Type.cxx,v 1.5 1998/11/05 16:04:43 mike Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Window_Type.cxx,v 1.6 1998/10/21 16:28:56 mike Exp $"
// "$Id: Fl_Window_Type.cxx,v 1.7 1998/11/05 16:04:44 mike Exp $"
//
// Window type code for the Fast Light Tool Kit (FLTK).
//
@ -293,29 +293,29 @@ Fl_Window_Type Fl_Window_type;
// Resize from window manager, try to resize it back to a legal size.
// This is not proper X behavior, but works on 4DWM and fvwm
void Overlay_Window::resize(int X,int Y,int W,int H) {
if (!visible() || W==w() && H==h()) {
Fl_Overlay_Window::resize(X,Y,W,H);
return;
}
int nw = gridx&&W!=w() ? ((W+gridx/2)/gridx)*gridx : W;
int nh = gridy&&H!=h() ? ((H+gridy/2)/gridy)*gridy : H;
// if (!visible() || W==w() && H==h()) {
// Fl_Overlay_Window::resize(X,Y,W,H);
// return;
// }
// int nw = gridx&&W!=w() ? ((W+gridx/2)/gridx)*gridx : W;
// int nh = gridy&&H!=h() ? ((H+gridy/2)/gridy)*gridy : H;
Fl_Widget* t = resizable(); resizable(0);
Fl_Overlay_Window::resize(X,Y,W,H);
resizable(t);
// make sure new window size surrounds the widgets:
int b = 0;
int r = 0;
for (Fl_Type *o=window->next; o && o->level>window->level; o=o->next)
if (o->is_widget() && !o->is_menu_item()) {
Fl_Widget* w = ((Fl_Widget_Type*)o)->o;
if (w->x()+w->w() > r) r = w->x()+w->w();
if (w->y()+w->h() > b) b = w->y()+w->h();
}
if (nh < b) nh = b;
if (nw < r) nw = r;
// If changed, tell the window manager. Skip really big windows
// that might be bigger than screen:
if (nw != W && nw < Fl::w()-100 || nh != H && nh < Fl::h()-100) size(nw,nh);
// // make sure new window size surrounds the widgets:
// int b = 0;
// int r = 0;
// for (Fl_Type *o=window->next; o && o->level>window->level; o=o->next)
// if (o->is_widget() && !o->is_menu_item()) {
// Fl_Widget* w = ((Fl_Widget_Type*)o)->o;
// if (w->x()+w->w() > r) r = w->x()+w->w();
// if (w->y()+w->h() > b) b = w->y()+w->h();
// }
// if (nh < b) nh = b;
// if (nw < r) nw = r;
// // If changed, tell the window manager. Skip really big windows
// // that might be bigger than screen:
// if (nw != W && nw < Fl::w()-100 || nh != H && nh < Fl::h()-100) size(nw,nh);
}
// calculate actual move by moving mouse position (mx,my) to
@ -693,5 +693,5 @@ int Fl_Window_Type::read_fdesign(const char* name, const char* value) {
}
//
// End of "$Id: Fl_Window_Type.cxx,v 1.6 1998/10/21 16:28:56 mike Exp $".
// End of "$Id: Fl_Window_Type.cxx,v 1.7 1998/11/05 16:04:44 mike Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: fluid.cxx,v 1.5 1998/10/21 17:28:27 mike Exp $"
// "$Id: fluid.cxx,v 1.6 1998/11/05 16:04:44 mike Exp $"
//
// FLUID main entry for the Fast Light Tool Kit (FLTK).
//
@ -121,7 +121,7 @@ void save_cb(Fl_Widget *, void *v) {
set_filename(c);
}
if (!write_file(c)) {
fl_show_message("Error writing", c, strerror(errno));
fl_message("Error writing %s: %s", c, strerror(errno));
return;
}
modflag = 0;
@ -132,7 +132,7 @@ void open_cb(Fl_Widget *, void *v) {
const char *c;
if (!(c = fl_file_chooser("Open:", "*.f[ld]", filename))) return;
if (!read_file(c, v!=0)) {
fl_show_message("Can't read", c, strerror(errno));
fl_message("Can't read %s: %s", c, strerror(errno));
return;
}
if (!v) {set_filename(c); modflag = 0;}
@ -178,9 +178,9 @@ void write_cb(Fl_Widget *, void *) {
if (!x) {fprintf(stderr,"%s : %s\n",cname,strerror(errno)); exit(1);}
} else {
if (!x) {
fl_show_message("Can't write", cname, strerror(errno));
fl_message("Can't write %s: %s", cname, strerror(errno));
} else {
fl_show_message("Wrote", cname, 0);
fl_message("Wrote %s", cname, 0);
}
}
}
@ -219,7 +219,7 @@ void copy_cb(Fl_Widget*, void*) {
if (!Fl_Type::current) return;
ipasteoffset = 10;
if (!write_file(cutfname(),1)) {
fl_show_message("Can't write", cutfname(), strerror(errno));
fl_message("Can't write %s: %s", cutfname(), strerror(errno));
return;
}
}
@ -231,7 +231,7 @@ void cut_cb(Fl_Widget *, void *) {
Fl_Type *p = Fl_Type::current->parent;
while (p && p->selected) p = p->parent;
if (!write_file(cutfname(),1)) {
fl_show_message("Can't write", cutfname(), strerror(errno));
fl_message("Can't write %s: %s", cutfname(), strerror(errno));
return;
}
delete_all(1);
@ -246,7 +246,7 @@ void paste_cb(Fl_Widget*, void*) {
if (gridx>1) pasteoffset = ((pasteoffset-1)/gridx+1)*gridx;
if (gridy>1) pasteoffset = ((pasteoffset-1)/gridy+1)*gridy;
if (!read_file(cutfname(), 1)) {
fl_show_message("Can't read", cutfname(), strerror(errno));
fl_message("Can't read %s: %s", cutfname(), strerror(errno));
}
pasteoffset = 0;
ipasteoffset += 10;
@ -396,7 +396,7 @@ int main(int argc,char **argv) {
fprintf(stderr,"%s : %s\n", c, strerror(errno));
exit(1);
}
fl_show_message("Can't read", c, strerror(errno));
fl_message("Can't read %s: %s", c, strerror(errno));
}
if (compile_only) {write_cb(0,0); exit(0);}
modflag = 0;
@ -407,5 +407,5 @@ int main(int argc,char **argv) {
}
//
// End of "$Id: fluid.cxx,v 1.5 1998/10/21 17:28:27 mike Exp $".
// End of "$Id: fluid.cxx,v 1.6 1998/11/05 16:04:44 mike Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Double_Window.cxx,v 1.8 1998/10/21 14:20:02 mike Exp $"
// "$Id: Fl_Double_Window.cxx,v 1.9 1998/11/05 16:04:45 mike Exp $"
//
// Double-buffered window code for the Fast Light Tool Kit (FLTK).
//
@ -56,9 +56,6 @@ static int can_xdbe() {
}
return use_xdbe;
}
#define DAMAGE_TEST() (damage() && (use_xdbe || damage() != FL_DAMAGE_EXPOSE))
#else
#define DAMAGE_TEST() (damage() & ~FL_DAMAGE_EXPOSE)
#endif
void Fl_Double_Window::show() {
@ -99,57 +96,66 @@ extern void fl_restore_clip();
#endif
// Fl_Overlay_Window relies on flush() copying the back buffer to the
// front even if damage() == 0, thus erasing the overlay inside the region:
// Fl_Overlay_Window relies on flush(1) copying the back buffer to the
// front everywhere, even if damage() == 0, thus erasing the overlay,
// and leaving the clip region set to the entire window.
void Fl_Double_Window::flush() {
void Fl_Double_Window::flush() {flush(0);}
void Fl_Double_Window::flush(int eraseoverlay) {
make_current(); // make sure fl_gc is non-zero
Fl_X *i = Fl_X::i(this);
if (!i->other_xid) {
#if USE_XDBE
if (can_xdbe()) i->other_xid =
XdbeAllocateBackBufferName(fl_display, fl_xid(this), XdbeCopied);
XdbeAllocateBackBufferName(fl_display, fl_xid(this), XdbeUndefined);
else
#endif
i->other_xid = fl_create_offscreen(w(), h());
clear_damage(FL_DAMAGE_ALL);
}
#if USE_XDBE
if (use_xdbe) {
// if this is true, copy rather than swap so back buffer is preserved:
int copy = (i->region || eraseoverlay);
if (i->backbuffer_bad) { // make sure we do a complete redraw...
if (i->region) {XDestroyRegion(i->region); i->region = 0;}
clear_damage(FL_DAMAGE_ALL);
}
if (damage()) {
fl_clip_region(i->region); i->region = 0;
fl_window = i->other_xid;
draw();
fl_window = i->xid;
}
if (!copy) {
XdbeSwapInfo s;
s.swap_window = fl_xid(this);
s.swap_action = XdbeUndefined;
XdbeSwapBuffers(fl_display, &s, 1);
i->backbuffer_bad = 1;
return;
}
// otherwise just use normal copy from back to front:
i->backbuffer_bad = 0; // which won't destroy the back buffer...
} else
#endif
if (damage() & ~FL_DAMAGE_EXPOSE) {
fl_clip_region(i->region); i->region = 0;
#ifdef WIN32
fl_clip_region(i->region); i->region = 0;
if (DAMAGE_TEST()) {
HDC _sgc = fl_gc;
fl_gc = fl_makeDC(i->other_xid);
fl_restore_clip(); // duplicate region into new gc
draw();
DeleteDC(fl_gc);
fl_gc = _sgc;
}
#else // X:
#if USE_XDBE
int clipped = i->region != 0;
#endif
fl_clip_region(i->region); i->region = 0;
if (DAMAGE_TEST()) {
fl_window = i->other_xid;
draw();
fl_window = i->xid;
}
#if USE_XDBE
// It appears that swapbuffers ignores the clip region (it has to
// as the gc is not passed as an argument to it). This causes it
// to erase parts of the overlay that won't be redrawn, and (at least
// on XFree86) it is slower. So I don't use it unless the entire
// window is being redrawn. Sigh.
if (use_xdbe && !clipped) {
XdbeSwapInfo s;
s.swap_window = fl_xid(this);
s.swap_action = XdbeCopied;
XdbeSwapBuffers(fl_display, &s, 1);
// fl_clip_region(0); older fix for clipping problem but overlay blinked
return;
}
#endif
#endif
}
if (eraseoverlay) fl_clip_region(0);
// on Irix (at least) it is faster to reduce the area copied to
// the current clip region:
int X,Y,W,H; fl_clip_box(0,0,w(),h(),X,Y,W,H);
@ -186,5 +192,5 @@ Fl_Double_Window::~Fl_Double_Window() {
}
//
// End of "$Id: Fl_Double_Window.cxx,v 1.8 1998/10/21 14:20:02 mike Exp $".
// End of "$Id: Fl_Double_Window.cxx,v 1.9 1998/11/05 16:04:45 mike Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Input_.cxx,v 1.4 1998/10/21 14:20:09 mike Exp $"
// "$Id: Fl_Input_.cxx,v 1.5 1998/11/05 16:04:46 mike Exp $"
//
// Common input widget routines for the Fast Light Tool Kit (FLTK).
//
@ -544,7 +544,7 @@ int Fl_Input_::undo() {
if (xlen) {
undobuffersize(xlen);
memcpy(undobuffer, buffer+b, xlen);
memmove(buffer+b, buffer+b+xlen, size_-xlen-b);
memmove(buffer+b, buffer+b+xlen, size_-xlen-b+1);
size_ -= xlen;
}
@ -725,5 +725,5 @@ Fl_Input_::~Fl_Input_() {
}
//
// End of "$Id: Fl_Input_.cxx,v 1.4 1998/10/21 14:20:09 mike Exp $".
// End of "$Id: Fl_Input_.cxx,v 1.5 1998/11/05 16:04:46 mike Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Overlay_Window.cxx,v 1.5 1998/10/21 14:20:15 mike Exp $"
// "$Id: Fl_Overlay_Window.cxx,v 1.6 1998/11/05 16:04:47 mike Exp $"
//
// Overlay window code for the Fast Light Tool Kit (FLTK).
//
@ -43,13 +43,9 @@ void Fl_Overlay_Window::hide() {
}
void Fl_Overlay_Window::flush() {
// turn off the bit set by redraw_overlay:
int erase_overlay = (damage()&FL_DAMAGE_OVERLAY);
clear_damage(damage()&~FL_DAMAGE_OVERLAY);
// even if damage() == 0, flush() will erase the fake overlay by
// copying back buffer over it. It will also set the clip to the
// region made by all the expose events:
Fl_Double_Window::flush();
// Now draw the fake overlay, if any, using the current clip:
Fl_Double_Window::flush(erase_overlay);
if (overlay_ == this) draw_overlay();
}
@ -67,7 +63,11 @@ Fl_Overlay_Window::~Fl_Overlay_Window() {
int Fl_Overlay_Window::can_do_overlay() {return 0;}
void Fl_Overlay_Window::redraw_overlay() {overlay_ = this; damage(FL_DAMAGE_OVERLAY);}
void Fl_Overlay_Window::redraw_overlay() {
overlay_ = this;
clear_damage(damage()|FL_DAMAGE_OVERLAY);
Fl::damage(FL_DAMAGE_CHILD);
}
#else
@ -127,9 +127,10 @@ void Fl_Overlay_Window::redraw_overlay() {
}
}
if (shown()) {
if (overlay_ == this)
damage(FL_DAMAGE_OVERLAY);
else if (!overlay_->shown())
if (overlay_ == this) {
clear_damage(damage()|FL_DAMAGE_OVERLAY);
Fl::damage(FL_DAMAGE_CHILD);
} else if (!overlay_->shown())
overlay_->show();
else
overlay_->redraw();
@ -139,5 +140,5 @@ void Fl_Overlay_Window::redraw_overlay() {
#endif
//
// End of "$Id: Fl_Overlay_Window.cxx,v 1.5 1998/10/21 14:20:15 mike Exp $".
// End of "$Id: Fl_Overlay_Window.cxx,v 1.6 1998/11/05 16:04:47 mike Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Tabs.cxx,v 1.4 1998/10/21 14:20:22 mike Exp $"
// "$Id: Fl_Tabs.cxx,v 1.5 1998/11/05 16:04:47 mike Exp $"
//
// Tab widget for the Fast Light Tool Kit (FLTK).
//
@ -189,12 +189,14 @@ void Fl_Tabs::draw() {
int H = tab_height();
if (damage() & FL_DAMAGE_ALL) { // redraw the entire thing:
fl_clip(x(), y()+(H>=0?H:0), w(), h()-(H>=0?H:-H));
draw_box(box(), x(), y(), w(), h(), v->color());
draw_box(box(), x(), y(), w(), h(), v ? v->color() : color());
fl_pop_clip();
draw_child(*v);
if (v) draw_child(*v);
} else { // redraw the child
update_child(*v);
if (v) update_child(*v);
}
if (!v) return;
if (damage() & (FL_DAMAGE_EXPOSE|FL_DAMAGE_ALL)) {
int p[128]; int w[128];
int selected = tab_positions(p,w);
@ -257,5 +259,5 @@ Fl_Tabs::Fl_Tabs(int X,int Y,int W, int H, const char *l) :
}
//
// End of "$Id: Fl_Tabs.cxx,v 1.4 1998/10/21 14:20:22 mike Exp $".
// End of "$Id: Fl_Tabs.cxx,v 1.5 1998/11/05 16:04:47 mike Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Window_hotspot.cxx,v 1.3 1998/10/21 14:20:28 mike Exp $"
// "$Id: Fl_Window_hotspot.cxx,v 1.4 1998/11/05 16:04:48 mike Exp $"
//
// Common hotspot routines for the Fast Light Tool Kit (FLTK).
//
@ -26,15 +26,36 @@
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#ifdef WIN32
#include <FL/win32.H>
#endif
void Fl_Window::hotspot(int X, int Y, int offscreen) {
int mx,my; Fl::get_mouse(mx,my);
X = mx-X; Y = my-Y;
if (!offscreen) {
if (border()) {
// ensure border is on screen:
#ifdef WIN32
int top, left, right, bottom;
Fl_X::get_border(this, top, left, bottom);
right = left; top += bottom;
#else
const int top = 20;
const int left = 1;
const int right = 1;
const int bottom = 1;
#endif
if (X+w()+right > Fl::w()) X = Fl::w()-right-w();
if (X-left < 0) X = left;
if (Y+h()+bottom > Fl::h()) Y = Fl::h()-bottom-h();
if (Y-top < 0) Y = top;
}
// now insure contents are on-screen (more important than border):
if (X+w() > Fl::w()) X = Fl::w()-w();
if (X < 0) X = 0;
if (X > Fl::w()-w()) X = Fl::w()-w();
if (Y > Fl::h()-h()) Y = Fl::h()-h();
if (Y+h() > Fl::h()) Y = Fl::h()-h();
if (Y < 0) Y = 0;
if (border() && Y < 20) Y = 20;
}
position(X,Y);
}
@ -50,5 +71,5 @@ void Fl_Window::hotspot(const Fl_Widget *o, int offscreen) {
}
//
// End of "$Id: Fl_Window_hotspot.cxx,v 1.3 1998/10/21 14:20:28 mike Exp $".
// End of "$Id: Fl_Window_hotspot.cxx,v 1.4 1998/11/05 16:04:48 mike Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_abort.cxx,v 1.3 1998/10/21 14:20:29 mike Exp $"
// "$Id: Fl_abort.cxx,v 1.4 1998/11/05 16:04:49 mike Exp $"
//
// Warning/error message code for the Fast Light Tool Kit (FLTK).
//
@ -56,12 +56,15 @@ static void error(const char *format, ...) {
#else
#include <windows.h>
extern "C" {
int vsnprintf(char* str, size_t size, const char* fmt, va_list ap);
}
static void warning(const char *format, ...) {
va_list args;
char buf[1024];
va_start(args, format);
vsprintf(buf, format, args);
vnsprintf(buf, 1024, format, args);
va_end(args);
MessageBox(0,buf,"Warning",MB_ICONEXCLAMATION|MB_OK);
}
@ -70,7 +73,7 @@ static void error(const char *format, ...) {
va_list args;
char buf[1024];
va_start(args, format);
vsprintf(buf, format, args);
vnsprintf(buf, 1024, format, args);
va_end(args);
MessageBox(0,buf,"Error",MB_ICONSTOP|MB_SYSTEMMODAL);
::exit(1);
@ -83,5 +86,5 @@ void (*Fl::error)(const char* format, ...) = ::error;
void (*Fl::fatal)(const char* format, ...) = ::error;
//
// End of "$Id: Fl_abort.cxx,v 1.3 1998/10/21 14:20:29 mike Exp $".
// End of "$Id: Fl_abort.cxx,v 1.4 1998/11/05 16:04:49 mike Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_win32.cxx,v 1.10 1998/10/21 14:20:36 mike Exp $"
// "$Id: Fl_win32.cxx,v 1.11 1998/11/05 16:04:50 mike Exp $"
//
// WIN32-specific code for the Fast Light Tool Kit (FLTK).
//
@ -220,9 +220,9 @@ static int ms2fltk(int vk, int extended) {
for (i = 0; i < sizeof(vktab)/sizeof(*vktab); i++) {
vklut[vktab[i].vk] = vktab[i].fltk;
extendedlut[vktab[i].vk] = vktab[i].extended;
}
for (i = 0; i < 256; i++) if (!extendedlut[i]) extendedlut[i] = vklut[i];
}
for (i = 0; i < 256; i++) if (!extendedlut[i]) extendedlut[i] = vklut[i];
}
return extended ? extendedlut[vk] : vklut[vk];
}
@ -411,14 +411,46 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
////////////////////////////////////////////////////////////////
// This function gets the dimensions of the top/left borders and
// the title bar, if there is one, based on the FL_BORDER, FL_MODAL
// and FL_NONMODAL flags, and on the window's size range.
// It returns the following values:
//
// value | border | title bar
// 0 | none | no
// 1 | fix | no
// 2 | fix | yes
// 3 | size | yes
int Fl_X::get_border(const Fl_Window* w,int &T, int &X, int &Y) {
int ret = T = X = Y = 0;
if (w->border() && !w->parent()) {
ret = 2;
if ((w->maxw != w->minw || w->maxh != w->minh) && !w->non_modal()) {
ret |= 1;
X = GetSystemMetrics(SM_CXSIZEFRAME);
Y = GetSystemMetrics(SM_CYSIZEFRAME);
} else {
X = GetSystemMetrics(SM_CXFIXEDFRAME);
Y = GetSystemMetrics(SM_CYFIXEDFRAME);
}
if (w->modal())
ret = 1;
else T = GetSystemMetrics(SM_CYCAPTION);
}
return ret;
}
////////////////////////////////////////////////////////////////
void Fl_Window::resize(int X,int Y,int W,int H) {
UINT flags = SWP_NOSENDCHANGING | SWP_NOZORDER;
int is_a_resize = (W != w() || H != h());
int resize_from_program = (this != resize_bug_fix);
if (!resize_from_program) resize_bug_fix = 0;
if (X != x() || Y != y()) set_flag(FL_FORCE_POSITION);
else if (!is_a_resize) return;
else {if (!is_a_resize) return; flags |= SWP_NOMOVE;}
if (is_a_resize) {
Fl_Group::resize(X,Y,W,H);
if (shown()) {redraw(); i->wait_for_expose = 1;}
@ -426,13 +458,14 @@ void Fl_Window::resize(int X,int Y,int W,int H) {
x(X); y(Y);
}
if (resize_from_program && shown()) {
if (border() && !parent()) {
X -= GetSystemMetrics(SM_CXFRAME);
Y -= GetSystemMetrics(SM_CYFRAME)+GetSystemMetrics(SM_CYCAPTION);
W += 2*GetSystemMetrics(SM_CXFRAME);
H += 2*GetSystemMetrics(SM_CYFRAME)+GetSystemMetrics(SM_CYCAPTION);
}
MoveWindow(i->xid, X, Y, W, H, TRUE);
int bt, bx, by;
if (Fl_X::get_border(this, bt, bx, by)) {
X -= bx;
Y -= by+bt;
W += 2*bx;
H += 2*by+bt;
} else {flags |= SWP_NOSIZE;}
SetWindowPos(i->xid, 0, X, Y, W, H, flags);
}
}
@ -470,16 +503,17 @@ Fl_X* Fl_X::make(Fl_Window* w) {
}
HWND parent;
DWORD style;
DWORD styleEx;
DWORD style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
DWORD styleEx = WS_EX_LEFT;
int xp = w->x();
int yp = w->y();
int wp = w->w();
int hp = w->h();
if (w->parent()) {
style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
styleEx = WS_EX_LEFT | WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT;
style = WS_CHILD;
styleEx = WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT;
parent = fl_xid(w->window());
} else {
if (!w->size_range_set) {
@ -492,24 +526,35 @@ Fl_X* Fl_X::make(Fl_Window* w) {
w->size_range(w->w(), w->h(), w->w(), w->h());
}
}
if (w->border()) {
style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU
| WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
styleEx = WS_EX_LEFT | WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT;
if (w->maxw != w->minw || w->maxh != w->minh)
style |= WS_THICKFRAME | WS_MAXIMIZEBOX;
if (!w->modal()) style |= WS_MINIMIZEBOX;
xp -= GetSystemMetrics(SM_CXFRAME);
yp -= GetSystemMetrics(SM_CYFRAME)+GetSystemMetrics(SM_CYCAPTION);
wp += 2*GetSystemMetrics(SM_CXFRAME);
hp += 2*GetSystemMetrics(SM_CYFRAME)+GetSystemMetrics(SM_CYCAPTION);
} else {
style = WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_OVERLAPPED;
styleEx = WS_EX_LEFT | WS_EX_TOPMOST | WS_EX_TOOLWINDOW;
styleEx |= WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT;
int bt, bx, by;
switch (Fl_X::get_border(w, bt, bx, by)) {
// No border (user for menus)
case 0: style |= WS_POPUP; break;
// Thin border
case 1: style |= WS_POPUP | WS_DLGFRAME; break;
// Thin border and title bar
case 2: style |= WS_DLGFRAME | WS_CAPTION | WS_SYSMENU;
if (!w->non_modal()) style |= WS_MINIMIZEBOX; break;
// Thick, resizable border and title bar, with maximize button
case 3: style |= WS_THICKFRAME | WS_MAXIMIZEBOX | WS_CAPTION |
WS_SYSMENU | WS_MINIMIZEBOX;
}
wp += 2*bx;
hp += 2*by+bt;
if (!(w->flags() & Fl_Window::FL_FORCE_POSITION)) {
xp = yp = CW_USEDEFAULT;
} else {
xp -= bx;
yp -= by+bt;
}
// if (xp<0) xp = 0;
// if (yp<0) yp = 0;
parent = 0;
if (w->non_modal() && !fl_disable_transient_for) {
// find some other window to be "transient for":
@ -581,13 +626,13 @@ void Fl_Window::size_range_() {
void Fl_X::set_minmax(LPMINMAXINFO minmax)
{
int wd, hd;
if (w->border()) {
wd = 2*GetSystemMetrics(SM_CXFRAME);
hd = 2*GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYCAPTION);
} else {
wd = hd = 0;
}
int td, wd, hd;
get_border(w, td, wd, hd);
wd *= 2;
hd *= 2;
hd += td;
minmax->ptMinTrackSize.x = w->minw + wd;
minmax->ptMinTrackSize.y = w->minh + hd;
if (w->maxw) {
@ -642,7 +687,9 @@ void Fl_Window::show() {
Fl_X::make(this);
} else {
// Once again, we would lose the capture if we activated the window.
ShowWindow(i->xid,fl_capture?SW_SHOWNOACTIVATE:SW_RESTORE);
if (IsIconic(i->xid)) OpenIcon(i->xid);
if (!fl_capture) BringWindowToTop(i->xid);
//ShowWindow(i->xid,fl_capture?SW_SHOWNOACTIVATE:SW_RESTORE);
}
}
@ -728,5 +775,5 @@ void Fl_Window::flush() {
}
//
// End of "$Id: Fl_win32.cxx,v 1.10 1998/10/21 14:20:36 mike Exp $".
// End of "$Id: Fl_win32.cxx,v 1.11 1998/11/05 16:04:50 mike Exp $".
//

View File

@ -1,5 +1,5 @@
#
# "$Id: Makefile,v 1.5 1998/10/21 22:03:52 mike Exp $"
# "$Id: Makefile,v 1.6 1998/11/05 16:04:50 mike Exp $"
#
# Library makefile for the Fast Light Tool Kit (FLTK).
#
@ -137,7 +137,7 @@ CPPFILES = \
glut_compatability.C \
glut_font.C
CFILES = scandir.c numericsort.c
CFILES = scandir.c numericsort.c vsnprintf.c
CLEAN =
@ -182,5 +182,5 @@ install: ../lib/$(LIBNAME)
@chmod -R a+r,u+w,g-w,o-w $(includedir)/FL
#
# End of "$Id: Makefile,v 1.5 1998/10/21 22:03:52 mike Exp $".
# End of "$Id: Makefile,v 1.6 1998/11/05 16:04:50 mike Exp $".
#

View File

@ -1,5 +1,5 @@
//
// "$Id: fl_ask.cxx,v 1.3 1998/10/21 14:20:44 mike Exp $"
// "$Id: fl_ask.cxx,v 1.4 1998/11/05 16:04:51 mike Exp $"
//
// Standard dialog functions for the Fast Light Tool Kit (FLTK).
//
@ -39,11 +39,11 @@
#include <FL/Fl_Input.H>
#include <FL/Fl_Secret_Input.H>
static Fl_Window *message_form;
static Fl_Box *message[3];
static Fl_Box *message;
static Fl_Box *icon;
static Fl_Button *button[3];
static Fl_Input *input;
static char *iconlabel;
static char *iconlabel = "?";
uchar fl_message_font_ = 0;
uchar fl_message_size_ = FL_NORMAL_SIZE;
@ -52,11 +52,7 @@ static Fl_Window *makeform() {
Fl_Window *w = message_form = new Fl_Window(410,105);
// w->clear_border();
// w->box(FL_UP_BOX);
(message[0] = new Fl_Box(60, 9, 340, 20))
->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_WRAP);
(message[1] = new Fl_Box(60, 25, 340, 20))
->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_WRAP);
(message[2] = new Fl_Box(60, 41, 340, 20))
(message = new Fl_Box(60, 25, 340, 20))
->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_WRAP);
(input = new Fl_Input(60,32,340,30))->hide();
{Fl_Box* o = icon = new Fl_Box(10, 10, 50, 50);
@ -74,28 +70,32 @@ static Fl_Window *makeform() {
return w;
}
// back-compatable functions:
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#if !HAVE_VSNPRINTF
extern "C" {
int vsnprintf(char* str, size_t size, const char* fmt, va_list ap);
}
#endif
int fl_show_choice(
const char *m0,
const char *m1,
const char *m2,
int, // number of buttons, ignored
static int innards(const char* fmt, va_list ap,
const char *b0,
const char *b1,
const char *b2)
{
makeform();
message[0]->label(m0);
message[1]->label(m1);
message[2]->label(m2);
char buffer[1024];
if (!strcmp(fmt,"%s")) {
message->label(va_arg(ap, const char*));
} else {
vsnprintf(buffer, 1024, fmt, ap);
message->label(buffer);
}
Fl_Font f = (Fl_Font)fl_message_font_;
if (!f) f = Fl_Input_::default_font();
int s = fl_message_size_ + Fl_Input::default_size();
for (int i=0; i<3; i++) {
message[i]->labelfont(f);
message[i]->labelsize(s);
}
message->labelfont(f);
message->labelsize(fl_message_size_ + Fl_Input::default_size());
if (b0) {button[0]->show();button[0]->label(b0);button[1]->position(210,70);}
else {button[0]->hide(); button[1]->position(310,70);}
if (b1) {button[1]->show(); button[1]->label(b1);}
@ -117,7 +117,7 @@ int fl_show_choice(
}
message_form->hide();
icon->label(prev_icon_label);
return r+1;
return r;
}
// pointers you can use to change fltk to a foreign language:
@ -126,64 +126,73 @@ const char* fl_yes= "Yes";
const char* fl_ok = "OK";
const char* fl_cancel= "Cancel";
// back-compatable XForms functions:
void fl_show_message(const char *q1,const char *q2,const char *q3) {
iconlabel = "i";
fl_show_choice(q1, q2, q3, 1, 0, fl_ok, 0);
}
void fl_show_alert(const char *q1,const char *q2,const char *q3) {
iconlabel = "!";
fl_show_choice(q1, q2, q3, 1, 0, fl_ok, 0);
}
int fl_show_question(const char *q1,const char *q2,const char *q3) {
iconlabel = "?";
return fl_show_choice(q1, q2, q3, 2, fl_no, fl_yes, 0) - 1;
}
// fltk functions:
void fl_message(const char *question) {
fl_show_message(0, question, 0);
}
void fl_alert(const char *question) {
fl_show_alert(0, question, 0);
}
int fl_ask(const char *question) {
return fl_show_question(0, question, 0);
}
int fl_choice(const char *q,const char *b0,const char *b1,const char *b2) {
void fl_message(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
iconlabel = "i";
innards(fmt, ap, 0, fl_ok, 0);
va_end(ap);
iconlabel = "?";
return fl_show_choice(0,q,0,3,b0,b1,b2) - 1;
}
void fl_alert(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
iconlabel = "!";
innards(fmt, ap, 0, fl_ok, 0);
va_end(ap);
iconlabel = "?";
}
int fl_ask(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
int r = innards(fmt, ap, fl_no, fl_yes, 0);
va_end(ap);
return r;
}
int fl_choice(const char*fmt,const char *b0,const char *b1,const char *b2,...){
va_list ap;
va_start(ap, b2);
int r = innards(fmt, ap, b0, b1, b2);
va_end(ap);
return r;
}
Fl_Widget *fl_message_icon() {makeform(); return icon;}
const char *fl_input(const char *str1, const char *defstr, uchar type) {
static const char* input_innards(const char* fmt, va_list ap,
const char* defstr, uchar type) {
makeform();
message->position(60,10);
input->type(type);
input->show();
input->value(defstr);
iconlabel = "?";
int r = fl_show_choice(str1,0,0,2,fl_cancel,fl_ok,0);
int r = innards(fmt, ap, fl_cancel, fl_ok, 0);
input->hide();
return r==2 ? input->value() : 0;
message->position(60,25);
return r ? input->value() : 0;
}
const char *fl_input(const char *str1, const char *defstr) {
return fl_input(str1, defstr, FL_NORMAL_INPUT);
const char* fl_input(const char *fmt, const char *defstr, ...) {
va_list ap;
va_start(ap, defstr);
const char* r = input_innards(fmt, ap, defstr, FL_NORMAL_INPUT);
va_end(ap);
return r;
}
char *fl_show_simple_input(const char *str1, const char *defstr) {
const char *r = fl_input(str1, defstr, FL_NORMAL_INPUT);
return (char *)(r ? r : defstr);
const char *fl_password(const char *fmt, const char *defstr, ...) {
va_list ap;
va_start(ap, defstr);
const char* r = input_innards(fmt, ap, defstr, FL_SECRET_INPUT);
va_end(ap);
return r;
}
//
// End of "$Id: fl_ask.cxx,v 1.3 1998/10/21 14:20:44 mike Exp $".
// End of "$Id: fl_ask.cxx,v 1.4 1998/11/05 16:04:51 mike Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: forms_compatability.cxx,v 1.3 1998/10/21 14:21:05 mike Exp $"
// "$Id: forms_compatability.cxx,v 1.4 1998/11/05 16:04:51 mike Exp $"
//
// Forms compatibility functions for the Fast Light Tool Kit (FLTK).
//
@ -175,6 +175,34 @@ Fl_Button *fl_add_button(uchar t,int x,int y,int w,int h,const char *l) {
return b;
}
void fl_show_message(const char *q1,const char *q2,const char *q3) {
fl_message("%s\n%s\n%s", q1?q1:"", q2?q2:"", q3?q3:"");
}
void fl_show_alert(const char *q1,const char *q2,const char *q3,int) {
fl_alert("%s\n%s\n%s", q1?q1:"", q2?q2:"", q3?q3:"");
}
int fl_show_question(const char *q1,const char *q2,const char *q3) {
return fl_ask("%s\n%s\n%s", q1?q1:"", q2?q2:"", q3?q3:"");
}
int fl_show_choice(
const char *q1,
const char *q2,
const char *q3,
int, // number of buttons, ignored
const char *b0,
const char *b1,
const char *b2) {
return fl_choice("%s\n%s\n%s", q1?q1:"", q2?q2:"", q3?q3:"", b0,b1,b2)+1;
}
char *fl_show_simple_input(const char *str1, const char *defstr) {
const char *r = fl_input(str1, defstr);
return (char *)(r ? r : defstr);
}
//
// End of "$Id: forms_compatability.cxx,v 1.3 1998/10/21 14:21:05 mike Exp $".
// End of "$Id: forms_compatability.cxx,v 1.4 1998/11/05 16:04:51 mike Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: message.cxx,v 1.3 1998/10/21 14:21:35 mike Exp $"
// "$Id: message.cxx,v 1.4 1998/11/05 16:04:52 mike Exp $"
//
// Message test program for the Fast Light Tool Kit (FLTK).
//
@ -29,19 +29,30 @@
#include <stdio.h>
int main(int, char **) {
fl_message("Spelling check sucessfull.");
fl_alert("Quantum fluctuations in the space-time continuim detected.");
fl_message("Spelling check sucessfull, %d errors found with %g%% confidence",
1002, 100*(15/77.0));
fl_alert("Quantum fluctuations in the space-time continuim detected, "
"you have %g seconds to comply.", 10.0);
printf("fl_ask returned %d\n",
fl_ask("Do you really want to?"));
fl_ask("Do you really want to %s?", "continue"));
printf("fl_choice returned %d\n",
fl_choice("Choose one of the following:","choice0","choice1","choice2"));
printf("fl_show_input returned \"%s\"\n",
fl_show_input("Please enter a string:", "this is the default value"));
printf("fl_password returned \"%s\"\n",
fl_password("Enter your password:"));
const char *r;
r = fl_input("Please enter a string for '%s':", "this is the default value",
"testing");
printf("fl_input returned \"%s\"\n", r ? r : "NULL");
r = fl_password("Enter %s's password:", 0, "somebody");
printf("fl_password returned \"%s\"\n", r ? r : "NULL");
return 0;
}
//
// End of "$Id: message.cxx,v 1.3 1998/10/21 14:21:35 mike Exp $".
// End of "$Id: message.cxx,v 1.4 1998/11/05 16:04:52 mike Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: pixmap_browser.cxx,v 1.3 1998/10/21 14:21:39 mike Exp $"
// "$Id: pixmap_browser.cxx,v 1.4 1998/11/05 16:04:53 mike Exp $"
//
// Another pixmap test program for the Fast Light Tool Kit (FLTK).
//
@ -55,7 +55,7 @@ static int hexdigit(int x) {
int load_file(const char *name) {
FILE *f = fopen(name,"r");
if (!f) {
fl_show_message("Can't open",name,strerror(errno));
fl_message("Can't open %s, %s",name,strerror(errno));
return 0;
}
if (data) {
@ -164,5 +164,5 @@ int main(int argc, char **argv) {
}
//
// End of "$Id: pixmap_browser.cxx,v 1.3 1998/10/21 14:21:39 mike Exp $".
// End of "$Id: pixmap_browser.cxx,v 1.4 1998/11/05 16:04:53 mike Exp $".
//