From 1ccafa83b2c783fdfe088af1ddf9a853e071cf5d Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Wed, 19 Mar 2025 14:44:16 +0100 Subject: [PATCH] Remove obsolete build option 'FLTK_OPTION_STD' This option is no longer needed since FLTK 1.5 always requires C++11. --- CMake/options.cmake | 13 ------ CMakeLists.txt | 6 --- FL/Fl_Table.H | 14 +------ FL/fl_ask.H | 11 ++--- README.CMake.txt | 19 ++++----- documentation/src/migration_1_4.dox | 5 ++- fl_config.cmake.in | 15 +------ src/Fl_Table.cxx | 41 +------------------ .../Wayland/Fl_Wayland_Screen_Driver.cxx | 26 ++---------- src/fl_ask.cxx | 7 ---- test/ask.cxx | 19 +-------- 11 files changed, 25 insertions(+), 151 deletions(-) diff --git a/CMake/options.cmake b/CMake/options.cmake index 7bf8f675f..d2fa392f7 100644 --- a/CMake/options.cmake +++ b/CMake/options.cmake @@ -386,19 +386,6 @@ if(WIN32) endif(FLTK_GRAPHICS_GDIPLUS) 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ca5f0862..420e379c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -353,12 +353,6 @@ endif() 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_yn("CMAKE_CXX_STANDARD_REQUIRED" CMAKE_CXX_STANDARD_REQUIRED) fl_summary_yn("CMAKE_CXX_EXTENSIONS" CMAKE_CXX_EXTENSIONS) diff --git a/FL/Fl_Table.H b/FL/Fl_Table.H index 7fb80cd04..99ceb3009 100644 --- a/FL/Fl_Table.H +++ b/FL/Fl_Table.H @@ -22,17 +22,7 @@ #include #include -// 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 -typedef std::vector 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. @@ -167,8 +157,8 @@ private: }; unsigned int flags_; - Fl_Int_Vector *_colwidths; // column widths in pixels - Fl_Int_Vector *_rowheights; // row heights in pixels + std::vector *_colwidths; // column widths in pixels + std::vector *_rowheights; // row heights in pixels // number of columns and rows == size of corresponding vectors int col_size(); // size of the column widths vector diff --git a/FL/fl_ask.H b/FL/fl_ask.H index 2387a1947..830dec97c 100644 --- a/FL/fl_ask.H +++ b/FL/fl_ask.H @@ -1,7 +1,7 @@ // // 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 // the file "COPYING" which should have been included with this file. If this @@ -24,9 +24,7 @@ #include #include -#if (FLTK_USE_STD) #include -#endif 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_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_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_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_attr((__format__(__printf__, 3, 5))); -#endif - FL_EXPORT Fl_Widget *fl_message_icon(); extern FL_EXPORT Fl_Font fl_message_font_; extern FL_EXPORT Fl_Fontsize fl_message_size_; diff --git a/README.CMake.txt b/README.CMake.txt index f36e39b0d..25e19ca42 100644 --- a/README.CMake.txt +++ b/README.CMake.txt @@ -248,13 +248,12 @@ FLTK_OPTION_PRINT_SUPPORT - default ON is somewhat smaller. This option makes sense only on the Unix/Linux platform or on macOS when FLTK_BACKEND_X11 is ON. -FLTK_OPTION_STD - default OFF - This option allows FLTK to use some specific features of modern C++ - like std::string in the public API of FLTK 1.4.x. Users turning this - option ON can benefit from some new functions and methods that return - std::string or use std::string as input parameters. - Note: This option will be removed in the next minor (1.5.0) or major - release which will use std::string and other modern C++ features. +FLTK_OPTION_STD - removed in FLTK 1.5 + This option allowed FLTK 1.4 to use some specific C++11 features like + std::string in the public API of FLTK 1.4.x. + This option has been removed in FLTK 1.5 which uses std::string + and other C++11 features by default. + You may safely remove this CMake option from your configuration. FLTK_OPTION_SVG - default ON 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. 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 -empty library solely for backwards compatibility in FLTK 1.4 and has been -removed from FLTK 1.5. +must be removed from CMake files of user projects. fltk_cairo was an empty +library solely for backwards compatibility in FLTK 1.4 and has been removed +from FLTK 1.5. 3.2 Library Aliases diff --git a/documentation/src/migration_1_4.dox b/documentation/src/migration_1_4.dox index 3455aeb5f..27962129a 100644 --- a/documentation/src/migration_1_4.dox +++ b/documentation/src/migration_1_4.dox @@ -368,7 +368,7 @@ OPTION_USE_GL | FLTK_BUILD_GL OPTION_USE_KDIALOG | FLTK_USE_KDIALOG OPTION_USE_PANGO | FLTK_USE_PANGO 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_SYSTEM_LIBDECOR | FLTK_USE_SYSTEM_LIBDECOR 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_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 diff --git a/fl_config.cmake.in b/fl_config.cmake.in index c1a1b3c5e..1610534fb 100644 --- a/fl_config.cmake.in +++ b/fl_config.cmake.in @@ -30,7 +30,7 @@ /* * FLTK_HAVE_CAIRO * - * Do we have the Fl_Cairo_Window support? + * Do we have Fl_Cairo_Window support? */ #cmakedefine FLTK_HAVE_CAIRO 1 @@ -85,19 +85,6 @@ #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 * diff --git a/src/Fl_Table.cxx b/src/Fl_Table.cxx index c145d9010..d970659a0 100644 --- a/src/Fl_Table.cxx +++ b/src/Fl_Table.cxx @@ -3,7 +3,7 @@ // // Copyright 2002 by Greg Ercolano. // 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 // the file "COPYING" which should have been included with this file. If this @@ -20,16 +20,6 @@ #include #include -// 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 #include // memcpy #include // 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; flags_ = 0; // TABCELLNAV off -#if (FLTK_USE_STDXX) _colwidths = new std::vector; // column widths in pixels _rowheights = new std::vector; // 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); @@ -237,13 +222,7 @@ void Fl_Table::row_height(int row, int height) { // Add row heights, even if none yet int now_size = row_size(); if (row >= now_size) { -#if (FLTK_USE_STD) _rowheights->resize(row, height); -#else - _rowheights->size(row); - while (now_size < row) - (*_rowheights)[now_size++] = height; -#endif // FLTK_USE_STD } (*_rowheights)[row] = height; table_resized(); @@ -270,13 +249,7 @@ void Fl_Table::col_width(int col, int width) // Add column widths, even if none yet int now_size = col_size(); if ( col >= now_size ) { -#if (FLTK_USE_STD) _colwidths->resize(col+1, width); -#else - _colwidths->size(col+1); - while (now_size < col) - (*_colwidths)[now_size++] = width; -#endif } (*_colwidths)[col] = width; table_resized(); @@ -690,14 +663,8 @@ void Fl_Table::rows(int val) { int default_h = row_size() > 0 ? _rowheights->back() : 25; int now_size = row_size(); -#if (FLTK_USE_STD) if (now_size != val) _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(); @@ -718,14 +685,8 @@ void Fl_Table::cols(int val) { int default_w = col_size() > 0 ? (*_colwidths)[col_size()-1] : 80; int now_size = col_size(); -#if (FLTK_USE_STD) if (now_size != val) _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(); redraw(); diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx index cdeeab9ac..8cb90d995 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx @@ -26,12 +26,7 @@ #include #include #include -#if FLTK_USE_STD -# include - typedef std::vector Fl_Int_Vector; -#else -# include "../../Fl_Int_Vector.H" -#endif +#include #include "../../print_button.h" #include #include @@ -90,7 +85,7 @@ struct pointer_output { */ -static Fl_Int_Vector key_vector; // used by Fl_Wayland_Screen_Driver::event_key() +static std::vector key_vector; // used by Fl_Wayland_Screen_Driver::event_key() static struct wl_surface *gtk_shell_surface = NULL; 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& v, int val) { for (unsigned pos = 0; pos < v.size(); 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& v, int val) { int pos = search_int_vector(v, val); if (pos < 0) return; -#if FLTK_USE_STD 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*)data; //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(); -#else - key_vector.size(0); -#endif // Replace wl_array_for_each(p, keys) rejected by C++ for (uint32_t *p = (uint32_t *)(keys)->data; (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); if (!win && Fl::focus()) win = Fl::focus()->top_window(); if (win) Fl::handle(FL_UNFOCUS, win); -#if FLTK_USE_STD key_vector.clear(); -#else - key_vector.size(0); -#endif } diff --git a/src/fl_ask.cxx b/src/fl_ask.cxx index 14913e269..49486716a 100644 --- a/src/fl_ask.cxx +++ b/src/fl_ask.cxx @@ -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. 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); } -#endif // FLTK_USE_STD /** 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; } -#if (FLTK_USE_STD) /** 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); } -#endif // FLTK_USE_STD - /** Sets the preferred position for the message box used in many common dialogs like fl_message(), fl_alert(), diff --git a/test/ask.cxx b/test/ask.cxx index 527b43dfa..93483b757 100644 --- a/test/ask.cxx +++ b/test/ask.cxx @@ -4,7 +4,7 @@ // This also demonstrates how to trap attempts by the user to // 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 // 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) { int what = fl_int(v); int ret = 0; -#if (FLTK_USE_STD) std::string input; if (what == 0) { fl_message_icon_label("§"); @@ -48,22 +47,6 @@ void rename_button(Fl_Widget *o, void *v) { o->copy_label(input.c_str()); 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 *) {