Remove obsolete build option 'FLTK_OPTION_STD'

This option is no longer needed since FLTK 1.5 always requires C++11.
This commit is contained in:
Albrecht Schlosser 2025-03-19 14:44:16 +01:00
parent 4b07ab391a
commit 1ccafa83b2
11 changed files with 25 additions and 151 deletions

View File

@ -386,19 +386,6 @@ if(WIN32)
endif(FLTK_GRAPHICS_GDIPLUS) endif(FLTK_GRAPHICS_GDIPLUS)
endif(WIN32) endif(WIN32)
#######################################################################
# FLTK_OPTION_STD: temporary option in 1.4, always on in 1.5.
# FIXME: remove this obsolete option entirely ...
# after the source code has been fixed.
#######################################################################
option(FLTK_OPTION_STD
"Use std:: (obsolete since 1.5.0, ignored: always ON)"
ON)
set(FLTK_USE_STD 1) # always ON since FLTK 1.5.0, option will be
# removed as soon as the code has been updated
####################################################################### #######################################################################
# find X11 libraries and headers # find X11 libraries and headers

View File

@ -353,12 +353,6 @@ endif()
message("") message("")
if(FLTK_USE_STD)
fl_summary("Use std::" "Yes - obsolete: always enabled since FLTK 1.5.0")
else()
fl_summary("Use std::" "No - *should* always be enabled since FLTK 1.5.0 !!")
endif()
fl_summary( "CMAKE_CXX_STANDARD" "${CMAKE_CXX_STANDARD}") fl_summary( "CMAKE_CXX_STANDARD" "${CMAKE_CXX_STANDARD}")
fl_summary_yn("CMAKE_CXX_STANDARD_REQUIRED" CMAKE_CXX_STANDARD_REQUIRED) fl_summary_yn("CMAKE_CXX_STANDARD_REQUIRED" CMAKE_CXX_STANDARD_REQUIRED)
fl_summary_yn("CMAKE_CXX_EXTENSIONS" CMAKE_CXX_EXTENSIONS) fl_summary_yn("CMAKE_CXX_EXTENSIONS" CMAKE_CXX_EXTENSIONS)

View File

@ -22,17 +22,7 @@
#include <FL/Fl_Group.H> #include <FL/Fl_Group.H>
#include <FL/Fl_Scroll.H> #include <FL/Fl_Scroll.H>
// EXPERIMENTAL
// We use either std::vector or the private class Fl_Int_Vector
// depending on the build option FLTK_OPTION_STD or --enable-use_std.
// This option allows to use std::string and std::vector in FLTK 1.4.x
#if (FLTK_USE_STD)
#include <vector> #include <vector>
typedef std::vector<int> Fl_Int_Vector;
#else
class Fl_Int_Vector; // private class declared in src/Fl_Int_Vector.H
#endif
/** /**
A table of widgets or other content. A table of widgets or other content.
@ -167,8 +157,8 @@ private:
}; };
unsigned int flags_; unsigned int flags_;
Fl_Int_Vector *_colwidths; // column widths in pixels std::vector<int> *_colwidths; // column widths in pixels
Fl_Int_Vector *_rowheights; // row heights in pixels std::vector<int> *_rowheights; // row heights in pixels
// number of columns and rows == size of corresponding vectors // number of columns and rows == size of corresponding vectors
int col_size(); // size of the column widths vector int col_size(); // size of the column widths vector

View File

@ -1,7 +1,7 @@
// //
// Standard dialog header file for the Fast Light Tool Kit (FLTK). // Standard dialog header file for the Fast Light Tool Kit (FLTK).
// //
// Copyright 1998-2022 by Bill Spitzak and others. // Copyright 1998-2025 by Bill Spitzak and others.
// //
// This library is free software. Distribution and use rights are outlined in // This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this // the file "COPYING" which should have been included with this file. If this
@ -24,9 +24,7 @@
#include <FL/Enumerations.H> #include <FL/Enumerations.H>
#include <FL/fl_attr.h> #include <FL/fl_attr.h>
#if (FLTK_USE_STD)
#include <string> #include <string>
#endif
class Fl_Widget; class Fl_Widget;
@ -76,13 +74,12 @@ FL_EXPORT const char *fl_input(int maxchar, const char *label, const char *deflt
FL_EXPORT const char *fl_password(int maxchar, const char *label, const char *deflt = 0, ...) FL_EXPORT const char *fl_password(int maxchar, const char *label, const char *deflt = 0, ...)
__fl_attr((__format__(__printf__, 2, 4))); __fl_attr((__format__(__printf__, 2, 4)));
// since FLTK 1.4.0 -- only with option FLTK_USE_STD // since FLTK 1.4.0 -- optional
// since FLTK 1.5.0 -- always
// - fl_input_str() with limited input size, returns std::string // - fl_input_str() with limited input size, returns std::string
// - fl_password_str() with limited input size, returns std::string // - fl_password_str() with limited input size, returns std::string
#if (FLTK_USE_STD)
FL_EXPORT std::string fl_input_str(int maxchar, const char *label, const char *deflt = 0, ...) FL_EXPORT std::string fl_input_str(int maxchar, const char *label, const char *deflt = 0, ...)
__fl_attr((__format__(__printf__, 2, 4))); __fl_attr((__format__(__printf__, 2, 4)));
@ -95,8 +92,6 @@ FL_EXPORT std::string fl_password_str(int maxchar, const char *label, const char
FL_EXPORT std::string fl_password_str(int &ret, int maxchar, const char *label, const char *deflt = 0, ...) FL_EXPORT std::string fl_password_str(int &ret, int maxchar, const char *label, const char *deflt = 0, ...)
__fl_attr((__format__(__printf__, 3, 5))); __fl_attr((__format__(__printf__, 3, 5)));
#endif
FL_EXPORT Fl_Widget *fl_message_icon(); FL_EXPORT Fl_Widget *fl_message_icon();
extern FL_EXPORT Fl_Font fl_message_font_; extern FL_EXPORT Fl_Font fl_message_font_;
extern FL_EXPORT Fl_Fontsize fl_message_size_; extern FL_EXPORT Fl_Fontsize fl_message_size_;

View File

@ -248,13 +248,12 @@ FLTK_OPTION_PRINT_SUPPORT - default ON
is somewhat smaller. This option makes sense only on the Unix/Linux is somewhat smaller. This option makes sense only on the Unix/Linux
platform or on macOS when FLTK_BACKEND_X11 is ON. platform or on macOS when FLTK_BACKEND_X11 is ON.
FLTK_OPTION_STD - default OFF FLTK_OPTION_STD - removed in FLTK 1.5
This option allows FLTK to use some specific features of modern C++ This option allowed FLTK 1.4 to use some specific C++11 features like
like std::string in the public API of FLTK 1.4.x. Users turning this std::string in the public API of FLTK 1.4.x.
option ON can benefit from some new functions and methods that return This option has been removed in FLTK 1.5 which uses std::string
std::string or use std::string as input parameters. and other C++11 features by default.
Note: This option will be removed in the next minor (1.5.0) or major You may safely remove this CMake option from your configuration.
release which will use std::string and other modern C++ features.
FLTK_OPTION_SVG - default ON FLTK_OPTION_SVG - default ON
FLTK has a built-in SVG library and can create (write) SVG image files. FLTK has a built-in SVG library and can create (write) SVG image files.
@ -826,9 +825,9 @@ and the shared library (fltk-shared) is libfltk.so.1.4.0 (in FLTK 1.4.0) with
additional system specific links. additional system specific links.
Note: since FLTK 1.5.0 the library fltk_cairo is no longer necessary and Note: since FLTK 1.5.0 the library fltk_cairo is no longer necessary and
must be removed from CMake files of user projects. fltk_cairo was an must be removed from CMake files of user projects. fltk_cairo was an empty
empty library solely for backwards compatibility in FLTK 1.4 and has been library solely for backwards compatibility in FLTK 1.4 and has been removed
removed from FLTK 1.5. from FLTK 1.5.
3.2 Library Aliases 3.2 Library Aliases

View File

@ -368,7 +368,7 @@ OPTION_USE_GL | FLTK_BUILD_GL
OPTION_USE_KDIALOG | FLTK_USE_KDIALOG OPTION_USE_KDIALOG | FLTK_USE_KDIALOG
OPTION_USE_PANGO | FLTK_USE_PANGO OPTION_USE_PANGO | FLTK_USE_PANGO
OPTION_USE_POLL | FLTK_USE_POLL OPTION_USE_POLL | FLTK_USE_POLL
OPTION_USE_STD | FLTK_OPTION_STD OPTION_USE_STD | FLTK_OPTION_STD [1]
OPTION_USE_SVG | FLTK_OPTION_SVG OPTION_USE_SVG | FLTK_OPTION_SVG
OPTION_USE_SYSTEM_LIBDECOR | FLTK_USE_SYSTEM_LIBDECOR OPTION_USE_SYSTEM_LIBDECOR | FLTK_USE_SYSTEM_LIBDECOR
OPTION_USE_SYSTEM_LIBJPEG | FLTK_USE_SYSTEM_LIBJPEG OPTION_USE_SYSTEM_LIBJPEG | FLTK_USE_SYSTEM_LIBJPEG
@ -383,6 +383,9 @@ OPTION_USE_XINERAMA | FLTK_USE_XINERAMA
OPTION_USE_XRENDER | FLTK_USE_XRENDER OPTION_USE_XRENDER | FLTK_USE_XRENDER
OPTION_WAYLAND_ONLY | FLTK_BACKEND_X11=OFF OPTION_WAYLAND_ONLY | FLTK_BACKEND_X11=OFF
------------------------------------------------
[1] Note: obsolete and therefore removed in 1.5
\section migration_1_4_windows_font New FL_HELVETICA Font on Windows \section migration_1_4_windows_font New FL_HELVETICA Font on Windows

View File

@ -30,7 +30,7 @@
/* /*
* FLTK_HAVE_CAIRO * FLTK_HAVE_CAIRO
* *
* Do we have the Fl_Cairo_Window support? * Do we have Fl_Cairo_Window support?
*/ */
#cmakedefine FLTK_HAVE_CAIRO 1 #cmakedefine FLTK_HAVE_CAIRO 1
@ -85,19 +85,6 @@
#cmakedefine FLTK_USE_WAYLAND 1 #cmakedefine FLTK_USE_WAYLAND 1
/*
* FLTK_USE_STD
*
* May we use std::string and std::vector for the current build?
*
* This is a build configuration option which allows FLTK to add some
* features based on std::string and std::vector in FLTK 1.4.x
*
*/
#cmakedefine01 FLTK_USE_STD
/* /*
* FLTK_USE_SVG * FLTK_USE_SVG
* *

View File

@ -3,7 +3,7 @@
// //
// Copyright 2002 by Greg Ercolano. // Copyright 2002 by Greg Ercolano.
// Copyright (c) 2004 O'ksi'D // Copyright (c) 2004 O'ksi'D
// Copyright 2023 by Bill Spitzak and others. // Copyright 2023-2025 by Bill Spitzak and others.
// //
// This library is free software. Distribution and use rights are outlined in // This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this // the file "COPYING" which should have been included with this file. If this
@ -20,16 +20,6 @@
#include <FL/Fl.H> #include <FL/Fl.H>
#include <FL/fl_draw.H> #include <FL/fl_draw.H>
// EXPERIMENTAL
// We use either std::vector or the private class Fl_Int_Vector
// depending on the build option FLTK_OPTION_STD or equivalent.
// This option allows to use std::string and maybe std::vector
// already in FLTK 1.4.x
#if (!FLTK_USE_STD)
#include "Fl_Int_Vector.H" // Note: MUST NOT be included in Fl_Table.H
#endif
#include <sys/types.h> #include <sys/types.h>
#include <string.h> // memcpy #include <string.h> // memcpy
#include <stdio.h> // fprintf #include <stdio.h> // fprintf
@ -155,13 +145,8 @@ Fl_Table::Fl_Table(int X, int Y, int W, int H, const char *l) : Fl_Group(X,Y,W,H
_scrollbar_size = 0; _scrollbar_size = 0;
flags_ = 0; // TABCELLNAV off flags_ = 0; // TABCELLNAV off
#if (FLTK_USE_STDXX)
_colwidths = new std::vector<int>; // column widths in pixels _colwidths = new std::vector<int>; // column widths in pixels
_rowheights = new std::vector<int>; // row heights in pixels _rowheights = new std::vector<int>; // row heights in pixels
#else
_colwidths = new Fl_Int_Vector(); // column widths in pixels
_rowheights = new Fl_Int_Vector(); // row heights in pixels
#endif
box(FL_THIN_DOWN_FRAME); box(FL_THIN_DOWN_FRAME);
@ -237,13 +222,7 @@ void Fl_Table::row_height(int row, int height) {
// Add row heights, even if none yet // Add row heights, even if none yet
int now_size = row_size(); int now_size = row_size();
if (row >= now_size) { if (row >= now_size) {
#if (FLTK_USE_STD)
_rowheights->resize(row, height); _rowheights->resize(row, height);
#else
_rowheights->size(row);
while (now_size < row)
(*_rowheights)[now_size++] = height;
#endif // FLTK_USE_STD
} }
(*_rowheights)[row] = height; (*_rowheights)[row] = height;
table_resized(); table_resized();
@ -270,13 +249,7 @@ void Fl_Table::col_width(int col, int width)
// Add column widths, even if none yet // Add column widths, even if none yet
int now_size = col_size(); int now_size = col_size();
if ( col >= now_size ) { if ( col >= now_size ) {
#if (FLTK_USE_STD)
_colwidths->resize(col+1, width); _colwidths->resize(col+1, width);
#else
_colwidths->size(col+1);
while (now_size < col)
(*_colwidths)[now_size++] = width;
#endif
} }
(*_colwidths)[col] = width; (*_colwidths)[col] = width;
table_resized(); table_resized();
@ -690,14 +663,8 @@ void Fl_Table::rows(int val) {
int default_h = row_size() > 0 ? _rowheights->back() : 25; int default_h = row_size() > 0 ? _rowheights->back() : 25;
int now_size = row_size(); int now_size = row_size();
#if (FLTK_USE_STD)
if (now_size != val) if (now_size != val)
_rowheights->resize(val, default_h); // enlarge or shrink as needed _rowheights->resize(val, default_h); // enlarge or shrink as needed
#else
_rowheights->size(val); // enlarge or shrink as needed
while (now_size < val)
(*_rowheights)[now_size++] = default_h; // fill new
#endif
table_resized(); table_resized();
@ -718,14 +685,8 @@ void Fl_Table::cols(int val) {
int default_w = col_size() > 0 ? (*_colwidths)[col_size()-1] : 80; int default_w = col_size() > 0 ? (*_colwidths)[col_size()-1] : 80;
int now_size = col_size(); int now_size = col_size();
#if (FLTK_USE_STD)
if (now_size != val) if (now_size != val)
_colwidths->resize(val, default_w); // enlarge or shrink as needed _colwidths->resize(val, default_w); // enlarge or shrink as needed
#else
_colwidths->size(val); // enlarge or shrink as needed
while (now_size < val)
(*_colwidths)[now_size++] = default_w; // fill new
#endif
table_resized(); table_resized();
redraw(); redraw();

View File

@ -26,12 +26,7 @@
#include <FL/platform.H> #include <FL/platform.H>
#include <FL/fl_ask.H> #include <FL/fl_ask.H>
#include <FL/filename.H> #include <FL/filename.H>
#if FLTK_USE_STD #include <vector>
# include <vector>
typedef std::vector<int> Fl_Int_Vector;
#else
# include "../../Fl_Int_Vector.H"
#endif
#include "../../print_button.h" #include "../../print_button.h"
#include <dlfcn.h> #include <dlfcn.h>
#include <linux/input.h> #include <linux/input.h>
@ -90,7 +85,7 @@ struct pointer_output {
*/ */
static Fl_Int_Vector key_vector; // used by Fl_Wayland_Screen_Driver::event_key() static std::vector<int> key_vector; // used by Fl_Wayland_Screen_Driver::event_key()
static struct wl_surface *gtk_shell_surface = NULL; static struct wl_surface *gtk_shell_surface = NULL;
Fl_Wayland_Screen_Driver::compositor_name Fl_Wayland_Screen_Driver::compositor = Fl_Wayland_Screen_Driver::compositor_name Fl_Wayland_Screen_Driver::compositor =
@ -520,7 +515,7 @@ static void wl_keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard,
} }
static int search_int_vector(Fl_Int_Vector& v, int val) { static int search_int_vector(std::vector<int>& v, int val) {
for (unsigned pos = 0; pos < v.size(); pos++) { for (unsigned pos = 0; pos < v.size(); pos++) {
if (v[pos] == val) return pos; if (v[pos] == val) return pos;
} }
@ -528,15 +523,10 @@ static int search_int_vector(Fl_Int_Vector& v, int val) {
} }
static void remove_int_vector(Fl_Int_Vector& v, int val) { static void remove_int_vector(std::vector<int>& v, int val) {
int pos = search_int_vector(v, val); int pos = search_int_vector(v, val);
if (pos < 0) return; if (pos < 0) return;
#if FLTK_USE_STD
v.erase(v.begin()+pos); v.erase(v.begin()+pos);
#else
int last = v.pop_back();
if (last != val) v[pos] = last;
#endif
} }
@ -567,11 +557,7 @@ static void wl_keyboard_enter(void *data, struct wl_keyboard *wl_keyboard,
struct Fl_Wayland_Screen_Driver::seat *seat = struct Fl_Wayland_Screen_Driver::seat *seat =
(struct Fl_Wayland_Screen_Driver::seat*)data; (struct Fl_Wayland_Screen_Driver::seat*)data;
//fprintf(stderr, "keyboard enter fl_win=%p; keys pressed are: ", Fl_Wayland_Window_Driver::surface_to_window(surface)); //fprintf(stderr, "keyboard enter fl_win=%p; keys pressed are: ", Fl_Wayland_Window_Driver::surface_to_window(surface));
#if FLTK_USE_STD
key_vector.clear(); key_vector.clear();
#else
key_vector.size(0);
#endif
// Replace wl_array_for_each(p, keys) rejected by C++ // Replace wl_array_for_each(p, keys) rejected by C++
for (uint32_t *p = (uint32_t *)(keys)->data; for (uint32_t *p = (uint32_t *)(keys)->data;
(const char *) p < ((const char *) (keys)->data + (keys)->size); (const char *) p < ((const char *) (keys)->data + (keys)->size);
@ -864,11 +850,7 @@ static void wl_keyboard_leave(void *data, struct wl_keyboard *wl_keyboard,
Fl_Window *win = Fl_Wayland_Window_Driver::surface_to_window(surface); Fl_Window *win = Fl_Wayland_Window_Driver::surface_to_window(surface);
if (!win && Fl::focus()) win = Fl::focus()->top_window(); if (!win && Fl::focus()) win = Fl::focus()->top_window();
if (win) Fl::handle(FL_UNFOCUS, win); if (win) Fl::handle(FL_UNFOCUS, win);
#if FLTK_USE_STD
key_vector.clear(); key_vector.clear();
#else
key_vector.size(0);
#endif
} }

View File

@ -346,9 +346,6 @@ const char *fl_input(int maxchar, const char *fmt, const char *defstr, ...) {
} }
#if (FLTK_USE_STD)
/** Shows an input dialog displaying the \p fmt message with variable arguments. /** Shows an input dialog displaying the \p fmt message with variable arguments.
Like fl_input(), but this method has the additional argument \p maxchar Like fl_input(), but this method has the additional argument \p maxchar
@ -412,7 +409,6 @@ std::string fl_input_str(int maxchar, const char *fmt, const char *defstr, ...)
return (r == NULL) ? std::string("") : std::string(r); return (r == NULL) ? std::string("") : std::string(r);
} }
#endif // FLTK_USE_STD
/** Shows an input dialog displaying the \p fmt message with variable arguments. /** Shows an input dialog displaying the \p fmt message with variable arguments.
@ -460,7 +456,6 @@ const char *fl_password(int maxchar, const char *fmt, const char *defstr, ...) {
return r; return r;
} }
#if (FLTK_USE_STD)
/** Shows an input dialog displaying the \p fmt message with variable arguments. /** Shows an input dialog displaying the \p fmt message with variable arguments.
@ -510,8 +505,6 @@ std::string fl_password_str(int maxchar, const char *fmt, const char *defstr, ..
return (r == NULL) ? std::string("") : std::string(r); return (r == NULL) ? std::string("") : std::string(r);
} }
#endif // FLTK_USE_STD
/** Sets the preferred position for the message box used in /** Sets the preferred position for the message box used in
many common dialogs like fl_message(), fl_alert(), many common dialogs like fl_message(), fl_alert(),

View File

@ -4,7 +4,7 @@
// This also demonstrates how to trap attempts by the user to // This also demonstrates how to trap attempts by the user to
// close the last window by overriding Fl::exit // close the last window by overriding Fl::exit
// //
// Copyright 1998-2024 by Bill Spitzak and others. // Copyright 1998-2025 by Bill Spitzak and others.
// //
// This library is free software. Distribution and use rights are outlined in // This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this // the file "COPYING" which should have been included with this file. If this
@ -35,7 +35,6 @@
void rename_button(Fl_Widget *o, void *v) { void rename_button(Fl_Widget *o, void *v) {
int what = fl_int(v); int what = fl_int(v);
int ret = 0; int ret = 0;
#if (FLTK_USE_STD)
std::string input; std::string input;
if (what == 0) { if (what == 0) {
fl_message_icon_label("§"); fl_message_icon_label("§");
@ -48,22 +47,6 @@ void rename_button(Fl_Widget *o, void *v) {
o->copy_label(input.c_str()); o->copy_label(input.c_str());
o->redraw(); o->redraw();
} }
#else
const char *input;
if (what == 0) {
fl_message_icon_label("§");
input = fl_input("Input (no size limit, use ctrl/j for newline):", o->label());
if (!input) ret = 1;
} else {
fl_message_icon_label("");
input = fl_password(20, "Enter password (max. 20 characters):", o->label());
if (!input) ret = 1;
}
if (ret == 0) {
o->copy_label(input);
o->redraw();
}
#endif // FLTK_USE_STD
} }
void window_callback(Fl_Widget *win, void *) { void window_callback(Fl_Widget *win, void *) {