From 1209e9dcd7e1e97bedc747d06ba4eea837562158 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Sun, 22 Oct 2023 19:30:37 +0200 Subject: Make Fl_String and Fl_Int_Vector private (#789) - add CMake option 'OPTION_USE_STD' - add configure option '--enable-use_std' - move FL/Fl_String.H to src/Fl_String.H - move FL/Fl_Int_Vector.H to src/Fl_Int_Vector.H - remove Fl_String from demo program examples/callbacks.cxx - remove Fl_Int_Vector from public header FL/Fl_Table.H - some methods of Fl_Table are no longer inline - add CMake option OPTION_USE_STD to allow std::string in some selected functions and methods Experimental, may be removed before release: - use either Fl_Int_Vector or std::vector in Fl_Table depending on CMake OPTION_USE_STD or configure --enable-use_std Move all fl_filename* functions that use Fl_String to fluid Main changes in fluid: - add fluid_filename.h and .cxx - include "fluid_filename.h" rather than Update fl_input(), fl_password() and test/ask - add maxchar parameter to fl_input() and fl_password() - fl_input_str() and fl_password_str() are optional and return std::string if enabled (FLTK_USE_STD) --- test/ask.cxx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'test/ask.cxx') diff --git a/test/ask.cxx b/test/ask.cxx index 973a42d11..9ff06b45a 100644 --- a/test/ask.cxx +++ b/test/ask.cxx @@ -35,7 +35,8 @@ void rename_button(Fl_Widget *o, void *v) { int what = fl_int(v); int ret = 0; - Fl_String input; +#if (FLTK_USE_STD) + std::string input; if (what == 0) { fl_message_icon_label("§"); input = fl_input_str(ret, 0, "Input (no size limit, use ctrl/j for newline):", o->label()); @@ -47,6 +48,22 @@ 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 *) { -- cgit v1.2.3