Michael Sweet wrote:
I'd deprecate the functions and non-UI classes in 1.3 (and there are
GCC attributes that can be used for this, just make sure that the
build of FLTK itself doesn't generate the warnings, please :) and add
a note that we no longer test (did we ever?) for forms compatibility.
In 1.4 we can remove the forms functions and non-UI classes.
I've been working a little bit on this, and I removed some Forms
compatibility calls from a few demo programs. Now it looks as if we
could add a configure option and some #ifdef's to disable all or at
least most of the old Forms compatibility features. In my working copy,
there are about 13 files with
#ifdef FORMS_COMPATIBILITY
#endif
combinations.
My proposal would be to add the configure option:
"--enable-forms" (default: --disable-forms)
for FLTK 1.3 (this way we can test, and users who need it can activate
the compatibility functions). In 1.4 we can remove the obsolete code.
Of course we would need some more fine tuning, but for a start I'll
attach a patch that disables almost all Forms compatibility functions
(including the UI classes like Fl_Timer, Fl_Free and maybe more). This
is only a proof of concept, not a proposal for applying to svn(!).
The modifications in fluid are to remove the ability to read (XForms)
FDesign files.
AFAICS there is only one demo program (test/forms.cxx) that still uses
Forms compatibility methods. The patched version displays a message that
Forms compatibility is not enabled.
Please test the attached patch with your application code to see if any
Forms compatibility functions are needed. If yes, then this can be
changed before committing.
Comments? Would it be better to add a branch for testing this?
Albrecht
Index: src/forms_pixmap.cxx
===================================================================
--- src/forms_pixmap.cxx (revision 6606)
+++ src/forms_pixmap.cxx (working copy)
@@ -25,6 +25,8 @@
// http://www.fltk.org/str.php
//
+#ifdef FORMS_COMPATIBILITY
+
#include <FL/forms.H>
/**
@@ -58,6 +60,8 @@
draw_label();
}
+#endif // FORMS_COMPATIBILITY
+
//
// End of "$Id$".
//
Index: src/forms_timer.cxx
===================================================================
--- src/forms_timer.cxx (revision 6606)
+++ src/forms_timer.cxx (working copy)
@@ -29,6 +29,8 @@
// You don't want to use this if you just want a timeout, call
// Fl::add_timeout directly!
+#ifdef FORMS_COMPATIBILITY
+
#include <FL/Fl.H>
#include <FL/Fl_Timer.H>
#include <FL/fl_draw.H>
@@ -181,6 +183,8 @@
}
}
+#endif // FORMS_COMPATIBILITY
+
//
// End of "$Id$".
//
Index: src/forms_compatability.cxx
===================================================================
--- src/forms_compatability.cxx (revision 6606)
+++ src/forms_compatability.cxx (working copy)
@@ -28,6 +28,8 @@
// Forms library compatibility functions.
// Many more functions are defined as inlines in forms.h!
+#ifdef FORMS_COMPATIBILITY
+
#include <FL/forms.H>
#include <stdlib.h>
@@ -206,6 +208,7 @@
return (char *)(r ? r : defstr);
}
+#endif // FORMS_COMPATIBILITY
//
// End of "$Id$".
//
Index: src/forms_free.cxx
===================================================================
--- src/forms_free.cxx (revision 6606)
+++ src/forms_free.cxx (working copy)
@@ -30,6 +30,8 @@
// me to port several other programs, but it is in no way
// complete.
+#ifdef FORMS_COMPATIBILITY
+
#include <FL/Fl.H>
#include <FL/Fl_Free.H>
@@ -109,6 +111,8 @@
return 1;
}
+#endif // FORMS_COMPATIBILITY
+
//
// End of "$Id$".
//
Index: src/forms_bitmap.cxx
===================================================================
--- src/forms_bitmap.cxx (revision 6606)
+++ src/forms_bitmap.cxx (working copy)
@@ -25,6 +25,8 @@
// http://www.fltk.org/str.php
//
+#ifdef FORMS_COMPATIBILITY
+
#include <FL/forms.H>
/** Creates a bitmap widget from a box type, position, size and optional label
specification */
Fl_FormsBitmap::Fl_FormsBitmap(
@@ -48,6 +50,8 @@
draw_label();
}
+#endif // FORMS_COMPATIBILITY
+
//
// End of "$Id$".
//
Index: src/forms_fselect.cxx
===================================================================
--- src/forms_fselect.cxx (revision 6606)
+++ src/forms_fselect.cxx (working copy)
@@ -27,6 +27,8 @@
// Emulate the Forms file chooser using the fltk file chooser.
+#ifdef FORMS_COMPATIBILITY
+
#include <FL/forms.H>
#include "flstring.h"
@@ -62,6 +64,8 @@
char* fl_get_filename() {return fl_filename;}
+#endif // FORMS_COMPATIBILITY
+
//
// End of "$Id$".
//
Index: FL/forms.H
===================================================================
--- FL/forms.H (revision 6606)
+++ FL/forms.H (working copy)
@@ -28,6 +28,8 @@
#ifndef __FORMS_H__
#define __FORMS_H__
+#ifdef FORMS_COMPATIBILITY
+
#include "Fl.H"
#include "Fl_Group.H"
#include "Fl_Window.H"
@@ -839,6 +841,8 @@
inline int fl_double_click() {return Fl::event_clicks();}
inline void fl_draw() {Fl::flush();}
+#endif // FORMS_COMPATIBILITY
+
#endif /* define __FORMS_H__ */
//
Index: test/forms.cxx
===================================================================
--- test/forms.cxx (revision 6606)
+++ test/forms.cxx (working copy)
@@ -3,12 +3,6 @@
//
// Another forms demo for the Fast Light Tool Kit (FLTK).
//
-// This is an XForms program with very few changes.
-// Search for "fltk" to find all changes necessary to port to fltk.
-//
-// This demo show the different boxtypes. Note that some
-// boxtypes are not appropriate for some objects
-//
// Copyright 1998-2008 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
@@ -31,6 +25,39 @@
// http://www.fltk.org/str.php
//
+#ifndef FORMS_COMPATIBILITY
+
+ // configured with --disable-forms (default)
+
+ // This displays a message that Forms compatibility is not enabled.
+
+ #include <FL/Fl.H>
+ #include <FL/Fl_Window.H>
+ #include <FL/Fl_Box.H>
+
+ int main(int argc, char **argv) {
+ Fl_Window *window = new Fl_Window(500,250);
+ Fl_Box *box = new Fl_Box(FL_UP_BOX,10,10,480,230,
+ "Forms compatibility is not enabled !\n\n"
+ "Please configure with --enable-forms if needed.\n\n\n"
+ "Note: Forms compatibility will be removed in FLTK 1.4");
+ box->labelfont(FL_BOLD+FL_ITALIC);
+ box->labelsize(16);
+ window->end();
+ window->show(argc, argv);
+ return Fl::run();
+ }
+
+#else // FORMS_COMPATIBILITY
+
+ // configured with --enable-forms (optional)
+
+ // This is an XForms program with very few changes.
+ // Search for "fltk" to find all changes necessary to port to fltk.
+ //
+ // This demo shows the different boxtypes. Note that some
+ // boxtypes are not appropriate for some objects
+
#include <FL/forms.H> // changed for fltk
static int border = 1; // changed from FL_TRANSIENT for fltk
@@ -232,6 +259,8 @@
return 0;
}
+#endif // (FORMS_COMPATIBILITY)
+
//
// End of "$Id$".
//
Index: fluid/Fl_Type.h
===================================================================
--- fluid/Fl_Type.h (revision 6606)
+++ fluid/Fl_Type.h (working copy)
@@ -115,7 +115,9 @@
void write();
virtual void write_properties();
virtual void read_property(const char *);
+# ifdef FORMS_COMPATIBILITY
virtual int read_fdesign(const char*, const char*);
+# endif // FORMS_COMPATIBILITY
// write code, these are called in order:
virtual void write_static(); // write static stuff to .c file
@@ -349,7 +351,9 @@
virtual void write_properties();
virtual void read_property(const char *);
+# ifdef FORMS_COMPATIBILITY
virtual int read_fdesign(const char*, const char*);
+# endif // FORMS_COMPATIBILITY
virtual Fl_Widget *enter_live_mode(int top=0);
virtual void leave_live_mode();
@@ -518,7 +522,9 @@
virtual void write_properties();
virtual void read_property(const char *);
+# ifdef FORMS_COMPATIBILITY
virtual int read_fdesign(const char*, const char*);
+# endif // FORMS_COMPATIBILITY
void add_child(Fl_Type*, Fl_Type*);
void move_child(Fl_Type*, Fl_Type*);
Index: fluid/Fl_Widget_Type.cxx
===================================================================
--- fluid/Fl_Widget_Type.cxx (revision 6606)
+++ fluid/Fl_Widget_Type.cxx (working copy)
@@ -2580,6 +2580,8 @@
{"11", 0,0,(void *)FL_DOWN_FRAME},
{0}};
+#ifdef FORMS_COMPATIBILITY
+
extern int fdesign_flip;
int lookup_symbol(const char *, int &, int numberok = 0);
@@ -2673,6 +2675,7 @@
}
return 1;
}
+#endif // FORMS_COMPATIBILITY
void leave_live_mode_cb(Fl_Widget*, void*) {
live_mode_cb(0, 0);
Index: fluid/file.cxx
===================================================================
--- fluid/file.cxx (revision 6606)
+++ fluid/file.cxx (working copy)
@@ -379,12 +379,16 @@
break;
}
+#ifdef FORMS_COMPATIBILITY
+
// this is the first word in a .fd file:
if (!strcmp(c,"Magic:")) {
read_fdesign();
return;
}
+#endif
+
if (!strcmp(c,"version")) {
c = read_word();
read_version = strtod(c,0);
@@ -517,6 +521,8 @@
////////////////////////////////////////////////////////////////
// Read Forms and XForms fdesign files:
+#ifdef FORMS_COMPATIBILITY
+
int read_fdesign_line(const char*& name, const char*& value) {
int length = 0;
@@ -645,6 +651,8 @@
}
}
+#endif // FORMS_COMPATIBILITX
+
//
// End of "$Id$".
//
Index: fluid/Fl_Window_Type.cxx
===================================================================
--- fluid/Fl_Window_Type.cxx (revision 6606)
+++ fluid/Fl_Window_Type.cxx (working copy)
@@ -1369,6 +1369,8 @@
}
}
+# ifdef FORMS_COMPATIBILITY
+
int Fl_Window_Type::read_fdesign(const char* propname, const char* value) {
int x;
o->box(FL_NO_BOX); // because fdesign always puts an Fl_Box next
@@ -1388,6 +1390,8 @@
return 1;
}
+# endif // FORMS_COMPATIBILITY
+
///////////////////////////////////////////////////////////////////////
Fl_Widget_Class_Type Fl_Widget_Class_type;
Index: fluid/Fl_Type.cxx
===================================================================
--- fluid/Fl_Type.cxx (revision 6606)
+++ fluid/Fl_Type.cxx (working copy)
@@ -890,8 +890,12 @@
read_error("Unknown property \"%s\"", c);
}
+#ifdef FORMS_COMPATIBILITY
+
int Fl_Type::read_fdesign(const char*, const char*) {return 0;}
+#endif // FORMS_COMPATIBILITY
+
/**
* Return 1 if the list contains a function with the given signature at the
top level
*/
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev