Re-enable nested (aka recursive) common dialogs (STR 3242, #282)

Apply Fl_Dialog_r10831.patch as given in STR 3242:
https://www.fltk.org/strfiles/3242/Fl_Dialog_r10831.patch

Reformat, add missing pieces, rename private members, cleanup...

Improve documentation, add fl_choice_n() (issue #282)

New methods fl_input_str() and fl_password_str() return Fl_String
This commit is contained in:
Albrecht Schlosser
2021-12-04 13:35:47 +01:00
parent 2404656266
commit b6de09cff2
11 changed files with 1275 additions and 582 deletions
+53 -25
View File
@@ -1,7 +1,7 @@
//
// Standard dialog header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2020 by Bill Spitzak and others.
// Copyright 1998-2021 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
@@ -18,44 +18,71 @@
API for common dialogs.
*/
#ifndef fl_ask_H
# define fl_ask_H
#ifndef _FL_fl_ask_H_
#define _FL_fl_ask_H_
#include <FL/Enumerations.H>
#include <FL/Fl_String.H>
#include <FL/fl_attr.h>
# include "Enumerations.H"
# include "fl_attr.h"
class Fl_Widget;
/** Different system beeps available.
\sa fl_beep(int) */
enum Fl_Beep {
FL_BEEP_DEFAULT = 0, ///< Default beep.
FL_BEEP_MESSAGE, ///< Message beep.
FL_BEEP_ERROR, ///< Error beep.
FL_BEEP_QUESTION, ///< Question beep.
FL_BEEP_PASSWORD, ///< Password beep.
FL_BEEP_NOTIFICATION ///< Notification beep.
FL_BEEP_DEFAULT = 0, ///< Default beep.
FL_BEEP_MESSAGE, ///< Message beep.
FL_BEEP_ERROR, ///< Error beep.
FL_BEEP_QUESTION, ///< Question beep.
FL_BEEP_PASSWORD, ///< Password beep.
FL_BEEP_NOTIFICATION ///< Notification beep.
};
FL_EXPORT void fl_beep(int type = FL_BEEP_DEFAULT);
FL_EXPORT void fl_message(const char *,...) __fl_attr((__format__ (__printf__, 1, 2)));
FL_EXPORT void fl_alert(const char *,...) __fl_attr((__format__ (__printf__, 1, 2)));
FL_EXPORT void fl_message(const char *, ...) __fl_attr((__format__(__printf__, 1, 2)));
FL_EXPORT void fl_alert(const char *, ...) __fl_attr((__format__(__printf__, 1, 2)));
// fl_ask() is deprecated since it uses "Yes" and "No" for the buttons,
// which does not conform to the current FLTK Human Interface Guidelines.
// Use fl_choice() instead with the appropriate verbs instead.
FL_EXPORT int fl_ask(const char *,...) __fl_attr((__format__ (__printf__, 1, 2), __deprecated__));
FL_EXPORT int fl_choice(const char *q,const char *b0,const char *b1,const char *b2,...) __fl_attr((__format__ (__printf__, 1, 5)));
FL_EXPORT const char *fl_input(const char *label, const char *deflt = 0, ...) __fl_attr((__format__ (__printf__, 1, 3)));
FL_EXPORT const char *fl_password(const char *label, const char *deflt = 0, ...) __fl_attr((__format__ (__printf__, 1, 3)));
// Use fl_choice() or fl_choice_n() with the appropriate verbs instead.
FL_EXPORT int fl_ask(const char *, ...) __fl_attr((__format__(__printf__, 1, 2), __deprecated__));
FL_EXPORT int fl_choice(const char *q, const char *b0, const char *b1, const char *b2, ...)
__fl_attr((__format__(__printf__, 1, 5)));
FL_EXPORT const char *fl_input(const char *label, const char *deflt = 0, ...) __fl_attr((__format__(__printf__, 1, 3)));
FL_EXPORT const char *fl_password(const char *label, const char *deflt = 0, ...)
__fl_attr((__format__(__printf__, 1, 3)));
// since FLTK 1.3.8:
// - fl_choice_n() with extended return value (-2, -1, 0, 1, 2)
FL_EXPORT int fl_choice_n(const char *q, const char *b0, const char *b1, const char *b2, ...)
__fl_attr((__format__(__printf__, 1, 5)));
// since FLTK 1.4.0:
// - fl_input_str() with limited input size
// - fl_password_str() with limited input size (*_str)
FL_EXPORT Fl_String fl_input_str(int maxchar, const char *label, const char *deflt = 0, ...)
__fl_attr((__format__(__printf__, 2, 4)));
FL_EXPORT Fl_String fl_password_str(int maxchar, const char *label, const char *deflt = 0, ...)
__fl_attr((__format__(__printf__, 2, 4)));
FL_EXPORT Fl_Widget *fl_message_icon();
extern FL_EXPORT Fl_Font fl_message_font_;
extern FL_EXPORT Fl_Fontsize fl_message_size_;
inline void fl_message_font(Fl_Font f, Fl_Fontsize s) {
fl_message_font_ = f; fl_message_size_ = s;}
fl_message_font_ = f;
fl_message_size_ = s;
}
FL_EXPORT void fl_message_hotspot(int enable);
FL_EXPORT int fl_message_hotspot(void);
// since FLTK 1.4.0: fl_message_position()
FL_EXPORT void fl_message_position(const int x, const int y, const int center = 0);
FL_EXPORT void fl_message_position(Fl_Widget *widget);
FL_EXPORT int fl_message_position(int *x = 0, int *y = 0);
@@ -69,9 +96,10 @@ FL_EXPORT void fl_message_title(const char *title);
FL_EXPORT void fl_message_title_default(const char *title);
// pointers you can use to change FLTK to another language:
extern FL_EXPORT const char* fl_no;
extern FL_EXPORT const char* fl_yes;
extern FL_EXPORT const char* fl_ok;
extern FL_EXPORT const char* fl_cancel;
extern FL_EXPORT const char* fl_close;
#endif // !fl_ask_H
extern FL_EXPORT const char *fl_no;
extern FL_EXPORT const char *fl_yes;
extern FL_EXPORT const char *fl_ok;
extern FL_EXPORT const char *fl_cancel;
extern FL_EXPORT const char *fl_close;
#endif // !_FL_fl_ask_H_
+4 -3
View File
@@ -55,6 +55,7 @@ alignment_panel.o: ../FL/Fl_Scrollbar.H
alignment_panel.o: ../FL/Fl_Simple_Terminal.H
alignment_panel.o: ../FL/Fl_Slider.H
alignment_panel.o: ../FL/Fl_Spinner.H
alignment_panel.o: ../FL/Fl_String.H
alignment_panel.o: ../FL/Fl_Tabs.H
alignment_panel.o: ../FL/Fl_Text_Buffer.H
alignment_panel.o: ../FL/Fl_Text_Display.H
@@ -201,7 +202,7 @@ ExternalCodeEditor_UNIX.o: ../FL/fl_ask.H
ExternalCodeEditor_UNIX.o: ../FL/fl_attr.h
ExternalCodeEditor_UNIX.o: ../FL/fl_casts.H
ExternalCodeEditor_UNIX.o: ../FL/Fl_Export.H
ExternalCodeEditor_UNIX.o: ../FL/fl_string.h
ExternalCodeEditor_UNIX.o: ../FL/Fl_String.H
ExternalCodeEditor_UNIX.o: ../FL/fl_types.h
ExternalCodeEditor_UNIX.o: ../FL/fl_utf8.h
ExternalCodeEditor_UNIX.o: ../FL/platform_types.h
@@ -407,7 +408,7 @@ fluid.o: ../FL/Fl_Shared_Image.H
fluid.o: ../FL/Fl_Simple_Terminal.H
fluid.o: ../FL/Fl_Slider.H
fluid.o: ../FL/Fl_Spinner.H
fluid.o: ../FL/fl_string.h
fluid.o: ../FL/Fl_String.H
fluid.o: ../FL/Fl_Tabs.H
fluid.o: ../FL/Fl_Text_Buffer.H
fluid.o: ../FL/Fl_Text_Display.H
@@ -543,7 +544,7 @@ Fl_Function_Type.o: ../FL/fl_show_input.H
Fl_Function_Type.o: ../FL/Fl_Simple_Terminal.H
Fl_Function_Type.o: ../FL/Fl_Slider.H
Fl_Function_Type.o: ../FL/Fl_Spinner.H
Fl_Function_Type.o: ../FL/fl_string.h
Fl_Function_Type.o: ../FL/Fl_String.H
Fl_Function_Type.o: ../FL/Fl_Tabs.H
Fl_Function_Type.o: ../FL/Fl_Text_Buffer.H
Fl_Function_Type.o: ../FL/Fl_Text_Display.H
+1
View File
@@ -56,6 +56,7 @@ set (CPPFILES
Fl_Menu_Window.cxx
Fl_Menu_add.cxx
Fl_Menu_global.cxx
Fl_Message.cxx
Fl_Multi_Label.cxx
Fl_Native_File_Chooser.cxx
Fl_Overlay_Window.cxx
+5 -2
View File
@@ -21,8 +21,11 @@
// *** BEGIN OUT OF SOURCE DOCUMENTATION ***
/** \defgroup group_comdlg Common Dialogs classes and functions
@{
/** \defgroup group_comdlg Common Dialog Classes and Functions
\brief Common dialog functions for file selection, message output, and more.
@{
*/
/** \class Fl_File_Chooser
The Fl_File_Chooser widget displays a standard file selection
+532
View File
File diff suppressed because it is too large Load Diff
+160
View File
@@ -0,0 +1,160 @@
//
// Common dialog header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2021 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
// file is missing or damaged, see the license at:
//
// https://www.fltk.org/COPYING.php
//
// Please see the following page on how to report bugs and issues:
//
// https://www.fltk.org/bugs.php
//
#ifndef _src_Fl_Message_h_
#define _src_Fl_Message_h_
#include <FL/Fl_Window.H>
#include <FL/fl_ask.H>
class Fl_Box;
class Fl_Button;
class Fl_Input;
/**
\cond DriverDev
\addtogroup DriverDeveloper
\{
*/
/**
This is the base class for all common FLTK dialog windows used in
fl_message(), fl_ask(), fl_choice(), fl_input(), and fl_password().
\note <b>Internal use only. This class may be changed as required
without notice.</b>\n
This class is reserved for FLTK's internal usage in common dialogs
in FLTK 1.4.x and later. The header file is "hidden" in the src/
folder and not installed with the public header files.
This class uses some static variables used to let the user code change
the behavior and look of the \b next call of some of the message related
functions. This is necessary to support the existing fl_message() and
similar functions and is safe as long as the variables are reset before
the function pops up (shows) the message window and enters the internal
(i.e. nested) event loop.
\since 1.4.0
*/
/* Note: Do not FL_EXPORT this class, it's for internal use only */
class Fl_Message {
// static variables and methods
private:
static Fl_Box *message_icon_; // returned by Fl_Message::message_icon()
static const char *message_title_;
static const char *message_title_default_;
// Note: since Fl_Message objects are destroyed before fl_input()
// and fl_password() return their input text, we *need* to store
// the text in an internal (static) buffer. :-(
// The newer functions fl_input_str() and fl_password_str() return the
// text in an Fl_String object that must be allocated and free()'d by
// the caller.
static char *input_buffer_; // points to the allocated text buffer
static int input_size_; // size of allocated text buffer
// the callback for all buttons:
static void button_cb_(Fl_Widget *w, void *d);
// the window callback:
static void window_cb_(Fl_Widget *w, void *d);
// resize to make text and buttons fit
void resizeform();
public:
static Fl_Box *message_icon();
static void message_title(const char *title);
static void message_title_default(const char *title);
/** Implements fl_message_position(const int, const int y, const int center). */
static void message_position(const int x, const int y, const int center) {
form_x_ = x;
form_y_ = y;
form_position_ = center ? 2 : 1;
}
/** Implements fl_message_position(Fl_Widget *widget). */
static void message_position(Fl_Widget *widget) {
form_x_ = widget->x() + widget->w() / 2;
form_y_ = widget->y() + widget->h() / 2;
form_position_ = 2;
}
/** Implements fl_message_position(int *x, int *y). */
static int message_position(int *x, int *y) {
if (x)
*x = form_position_ ? form_x_ : -1;
if (y)
*y = form_position_ ? form_y_ : -1;
return form_position_;
}
/** Implements void fl_message_hotspot(int). */
static void message_hotspot(int enable) { enable_hotspot_ = enable ? 1 : 0; }
/** Implements int fl_message_hotspot(). */
static int message_hotspot() { return enable_hotspot_; }
int window_closed() const {
return window_closed_;
}
// member variables and methods
private:
Fl_Window *window_; ///< message window
Fl_Box *message_; ///< message text
Fl_Box *icon_; ///< contains the icon
Fl_Button *button_[3]; ///< buttons used internally
Fl_Input *input_; ///< normal text or secret input
int retval_; ///< internally used to store the return value
int window_closed_; ///< window close flag (-1 = Escape, -2 = close button)
// static (private) variables
static int enable_hotspot_; ///< follow the mouse pointer (hotspot)
static int form_x_; ///< x position for next dialog
static int form_y_; ///< y position for next dialog
static int form_position_; ///< 0 = not set (may be hotspot), 1 = absolute, 2 = centered
public:
// Constructor
Fl_Message(const char *iconlabel);
/** Destructor. */
~Fl_Message() { delete window_; }
int innards(const char *fmt, va_list ap, const char *b0, const char *b1, const char *b2);
const char *input_innards(const char *fmt, va_list ap, const char *defstr, uchar type, int maxchar = -1);
};
/**
\}
\endcond
*/
#endif // _src_Fl_Message_h_
+1
View File
@@ -58,6 +58,7 @@ CPPFILES = \
Fl_Menu_Window.cxx \
Fl_Menu_add.cxx \
Fl_Menu_global.cxx \
Fl_Message.cxx \
Fl_Multi_Label.cxx \
Fl_Native_File_Chooser.cxx \
Fl_Overlay_Window.cxx \
+389 -497
View File
File diff suppressed because it is too large Load Diff
+49 -11
View File
@@ -207,7 +207,7 @@ drivers/Posix/Fl_Posix_Printer_Driver.o: ../FL/Fl_Repeat_Button.H
drivers/Posix/Fl_Posix_Printer_Driver.o: ../FL/Fl_Return_Button.H
drivers/Posix/Fl_Posix_Printer_Driver.o: ../FL/Fl_Round_Button.H
drivers/Posix/Fl_Posix_Printer_Driver.o: ../FL/Fl_Spinner.H
drivers/Posix/Fl_Posix_Printer_Driver.o: ../FL/fl_string.h
drivers/Posix/Fl_Posix_Printer_Driver.o: ../FL/Fl_String.H
drivers/Posix/Fl_Posix_Printer_Driver.o: ../FL/fl_types.h
drivers/Posix/Fl_Posix_Printer_Driver.o: ../FL/fl_utf8.h
drivers/Posix/Fl_Posix_Printer_Driver.o: ../FL/Fl_Widget.H
@@ -273,7 +273,7 @@ drivers/PostScript/Fl_PostScript.o: ../FL/Fl_Plugin.H
drivers/PostScript/Fl_PostScript.o: ../FL/Fl_PostScript.H
drivers/PostScript/Fl_PostScript.o: ../FL/Fl_Preferences.H
drivers/PostScript/Fl_PostScript.o: ../FL/Fl_Return_Button.H
drivers/PostScript/Fl_PostScript.o: ../FL/fl_string.h
drivers/PostScript/Fl_PostScript.o: ../FL/Fl_String.H
drivers/PostScript/Fl_PostScript.o: ../FL/Fl_Tile.H
drivers/PostScript/Fl_PostScript.o: ../FL/fl_types.h
drivers/PostScript/Fl_PostScript.o: ../FL/fl_utf8.h
@@ -397,6 +397,7 @@ drivers/X11/Fl_X11_Screen_Driver.o: ../FL/Fl_RGB_Image.H
drivers/X11/Fl_X11_Screen_Driver.o: ../FL/Fl_Scrollbar.H
drivers/X11/Fl_X11_Screen_Driver.o: ../FL/Fl_Shared_Image.H
drivers/X11/Fl_X11_Screen_Driver.o: ../FL/Fl_Slider.H
drivers/X11/Fl_X11_Screen_Driver.o: ../FL/Fl_String.H
drivers/X11/Fl_X11_Screen_Driver.o: ../FL/Fl_Text_Buffer.H
drivers/X11/Fl_X11_Screen_Driver.o: ../FL/Fl_Text_Display.H
drivers/X11/Fl_X11_Screen_Driver.o: ../FL/Fl_Text_Editor.H
@@ -463,6 +464,7 @@ drivers/X11/Fl_X11_Window_Driver.o: ../FL/Fl_RGB_Image.H
drivers/X11/Fl_X11_Window_Driver.o: ../FL/Fl_Scrollbar.H
drivers/X11/Fl_X11_Window_Driver.o: ../FL/Fl_Single_Window.H
drivers/X11/Fl_X11_Window_Driver.o: ../FL/Fl_Slider.H
drivers/X11/Fl_X11_Window_Driver.o: ../FL/Fl_String.H
drivers/X11/Fl_X11_Window_Driver.o: ../FL/Fl_Text_Buffer.H
drivers/X11/Fl_X11_Window_Driver.o: ../FL/Fl_Text_Display.H
drivers/X11/Fl_X11_Window_Driver.o: ../FL/Fl_Text_Editor.H
@@ -915,7 +917,6 @@ fl_ask.o: ../FL/fl_ask.H
fl_ask.o: ../FL/fl_attr.h
fl_ask.o: ../FL/Fl_Bitmap.H
fl_ask.o: ../FL/Fl_Box.H
fl_ask.o: ../FL/Fl_Button.H
fl_ask.o: ../FL/fl_casts.H
fl_ask.o: ../FL/Fl_Device.H
fl_ask.o: ../FL/fl_draw.H
@@ -923,18 +924,15 @@ fl_ask.o: ../FL/Fl_Export.H
fl_ask.o: ../FL/Fl_Graphics_Driver.H
fl_ask.o: ../FL/Fl_Group.H
fl_ask.o: ../FL/Fl_Image.H
fl_ask.o: ../FL/Fl_Input.H
fl_ask.o: ../FL/Fl_Input_.H
fl_ask.o: ../FL/Fl_Pixmap.H
fl_ask.o: ../FL/Fl_Plugin.H
fl_ask.o: ../FL/Fl_Preferences.H
fl_ask.o: ../FL/Fl_Rect.H
fl_ask.o: ../FL/Fl_Return_Button.H
fl_ask.o: ../FL/Fl_RGB_Image.H
fl_ask.o: ../FL/Fl_Scrollbar.H
fl_ask.o: ../FL/Fl_Secret_Input.H
fl_ask.o: ../FL/Fl_Slider.H
fl_ask.o: ../FL/fl_string.h
fl_ask.o: ../FL/Fl_String.H
fl_ask.o: ../FL/Fl_Text_Buffer.H
fl_ask.o: ../FL/Fl_Text_Display.H
fl_ask.o: ../FL/Fl_Text_Editor.H
@@ -943,9 +941,9 @@ fl_ask.o: ../FL/fl_utf8.h
fl_ask.o: ../FL/Fl_Valuator.H
fl_ask.o: ../FL/Fl_Widget.H
fl_ask.o: ../FL/Fl_Window.H
fl_ask.o: ../FL/platform.H
fl_ask.o: ../FL/platform_types.h
fl_ask.o: flstring.h
fl_ask.o: Fl_Message.h
fl_ask.o: Fl_Screen_Driver.H
Fl_Bitmap.o: ../FL/abi-version.h
Fl_Bitmap.o: ../FL/Enumerations.H
@@ -1499,6 +1497,7 @@ Fl_File_Chooser.o: ../FL/Fl_Menu_Button.H
Fl_File_Chooser.o: ../FL/Fl_Menu_Item.H
Fl_File_Chooser.o: ../FL/Fl_Preferences.H
Fl_File_Chooser.o: ../FL/Fl_Return_Button.H
Fl_File_Chooser.o: ../FL/Fl_String.H
Fl_File_Chooser.o: ../FL/Fl_Tile.H
Fl_File_Chooser.o: ../FL/fl_types.h
Fl_File_Chooser.o: ../FL/fl_utf8.h
@@ -1536,7 +1535,7 @@ Fl_File_Chooser2.o: ../FL/Fl_Menu_Item.H
Fl_File_Chooser2.o: ../FL/Fl_Preferences.H
Fl_File_Chooser2.o: ../FL/Fl_Return_Button.H
Fl_File_Chooser2.o: ../FL/Fl_Shared_Image.H
Fl_File_Chooser2.o: ../FL/fl_string.h
Fl_File_Chooser2.o: ../FL/Fl_String.H
Fl_File_Chooser2.o: ../FL/Fl_Tile.H
Fl_File_Chooser2.o: ../FL/fl_types.h
Fl_File_Chooser2.o: ../FL/fl_utf8.h
@@ -1575,6 +1574,7 @@ fl_file_dir.o: ../FL/Fl_Menu_Button.H
fl_file_dir.o: ../FL/Fl_Menu_Item.H
fl_file_dir.o: ../FL/Fl_Preferences.H
fl_file_dir.o: ../FL/Fl_Return_Button.H
fl_file_dir.o: ../FL/Fl_String.H
fl_file_dir.o: ../FL/Fl_Tile.H
fl_file_dir.o: ../FL/fl_types.h
fl_file_dir.o: ../FL/fl_utf8.h
@@ -1895,6 +1895,7 @@ Fl_Help_Dialog.o: ../FL/Fl_RGB_Image.H
Fl_Help_Dialog.o: ../FL/Fl_Scrollbar.H
Fl_Help_Dialog.o: ../FL/Fl_Shared_Image.H
Fl_Help_Dialog.o: ../FL/Fl_Slider.H
Fl_Help_Dialog.o: ../FL/Fl_String.H
Fl_Help_Dialog.o: ../FL/fl_types.h
Fl_Help_Dialog.o: ../FL/fl_utf8.h
Fl_Help_Dialog.o: ../FL/Fl_Valuator.H
@@ -2020,6 +2021,7 @@ Fl_Input.o: ../FL/Fl_RGB_Image.H
Fl_Input.o: ../FL/Fl_Scrollbar.H
Fl_Input.o: ../FL/Fl_Secret_Input.H
Fl_Input.o: ../FL/Fl_Slider.H
Fl_Input.o: ../FL/Fl_String.H
Fl_Input.o: ../FL/Fl_Text_Buffer.H
Fl_Input.o: ../FL/Fl_Text_Display.H
Fl_Input.o: ../FL/Fl_Text_Editor.H
@@ -2055,6 +2057,7 @@ Fl_Input_.o: ../FL/Fl_Rect.H
Fl_Input_.o: ../FL/Fl_RGB_Image.H
Fl_Input_.o: ../FL/Fl_Scrollbar.H
Fl_Input_.o: ../FL/Fl_Slider.H
Fl_Input_.o: ../FL/Fl_String.H
Fl_Input_.o: ../FL/Fl_Text_Buffer.H
Fl_Input_.o: ../FL/Fl_Text_Display.H
Fl_Input_.o: ../FL/Fl_Text_Editor.H
@@ -2241,6 +2244,32 @@ Fl_Menu_Window.o: ../FL/Fl_Widget.H
Fl_Menu_Window.o: ../FL/Fl_Window.H
Fl_Menu_Window.o: ../FL/platform_types.h
Fl_Menu_Window.o: Fl_Window_Driver.H
Fl_Message.o: ../config.h
Fl_Message.o: ../FL/abi-version.h
Fl_Message.o: ../FL/Enumerations.H
Fl_Message.o: ../FL/Fl.H
Fl_Message.o: ../FL/fl_ask.H
Fl_Message.o: ../FL/fl_attr.h
Fl_Message.o: ../FL/Fl_Bitmap.H
Fl_Message.o: ../FL/Fl_Box.H
Fl_Message.o: ../FL/Fl_Button.H
Fl_Message.o: ../FL/fl_casts.H
Fl_Message.o: ../FL/fl_draw.H
Fl_Message.o: ../FL/Fl_Export.H
Fl_Message.o: ../FL/Fl_Group.H
Fl_Message.o: ../FL/Fl_Image.H
Fl_Message.o: ../FL/Fl_Input.H
Fl_Message.o: ../FL/Fl_Input_.H
Fl_Message.o: ../FL/Fl_Return_Button.H
Fl_Message.o: ../FL/Fl_Secret_Input.H
Fl_Message.o: ../FL/Fl_String.H
Fl_Message.o: ../FL/fl_types.h
Fl_Message.o: ../FL/fl_utf8.h
Fl_Message.o: ../FL/Fl_Widget.H
Fl_Message.o: ../FL/Fl_Window.H
Fl_Message.o: ../FL/platform_types.h
Fl_Message.o: flstring.h
Fl_Message.o: Fl_Message.h
Fl_Multi_Label.o: ../FL/abi-version.h
Fl_Multi_Label.o: ../FL/Enumerations.H
Fl_Multi_Label.o: ../FL/Fl.H
@@ -2282,6 +2311,7 @@ Fl_Native_File_Chooser.o: ../FL/Fl_Menu_Item.H
Fl_Native_File_Chooser.o: ../FL/Fl_Native_File_Chooser.H
Fl_Native_File_Chooser.o: ../FL/Fl_Preferences.H
Fl_Native_File_Chooser.o: ../FL/Fl_Return_Button.H
Fl_Native_File_Chooser.o: ../FL/Fl_String.H
Fl_Native_File_Chooser.o: ../FL/Fl_Tile.H
Fl_Native_File_Chooser.o: ../FL/fl_types.h
Fl_Native_File_Chooser.o: ../FL/fl_utf8.h
@@ -2317,6 +2347,7 @@ Fl_Native_File_Chooser_FLTK.o: ../FL/Fl_Menu_Item.H
Fl_Native_File_Chooser_FLTK.o: ../FL/Fl_Native_File_Chooser.H
Fl_Native_File_Chooser_FLTK.o: ../FL/Fl_Preferences.H
Fl_Native_File_Chooser_FLTK.o: ../FL/Fl_Return_Button.H
Fl_Native_File_Chooser_FLTK.o: ../FL/Fl_String.H
Fl_Native_File_Chooser_FLTK.o: ../FL/Fl_Tile.H
Fl_Native_File_Chooser_FLTK.o: ../FL/fl_types.h
Fl_Native_File_Chooser_FLTK.o: ../FL/fl_utf8.h
@@ -2360,7 +2391,7 @@ Fl_Native_File_Chooser_GTK.o: ../FL/Fl_Plugin.H
Fl_Native_File_Chooser_GTK.o: ../FL/Fl_Preferences.H
Fl_Native_File_Chooser_GTK.o: ../FL/Fl_Return_Button.H
Fl_Native_File_Chooser_GTK.o: ../FL/Fl_Shared_Image.H
Fl_Native_File_Chooser_GTK.o: ../FL/fl_string.h
Fl_Native_File_Chooser_GTK.o: ../FL/Fl_String.H
Fl_Native_File_Chooser_GTK.o: ../FL/Fl_Tile.H
Fl_Native_File_Chooser_GTK.o: ../FL/fl_types.h
Fl_Native_File_Chooser_GTK.o: ../FL/fl_utf8.h
@@ -2932,7 +2963,7 @@ fl_string.o: ../FL/Fl.H
fl_string.o: ../FL/fl_casts.H
fl_string.o: ../FL/Fl_Export.H
fl_string.o: ../FL/Fl_Preferences.H
fl_string.o: ../FL/fl_string.h
Fl_String.o: ../FL/Fl_String.H
fl_string.o: ../FL/fl_types.h
fl_string.o: ../FL/fl_utf8.h
fl_string.o: ../FL/platform_types.h
@@ -3128,6 +3159,7 @@ Fl_Text_Editor.o: ../FL/Fl_Rect.H
Fl_Text_Editor.o: ../FL/Fl_RGB_Image.H
Fl_Text_Editor.o: ../FL/Fl_Scrollbar.H
Fl_Text_Editor.o: ../FL/Fl_Slider.H
Fl_Text_Editor.o: ../FL/Fl_String.H
Fl_Text_Editor.o: ../FL/Fl_Text_Buffer.H
Fl_Text_Editor.o: ../FL/Fl_Text_Display.H
Fl_Text_Editor.o: ../FL/Fl_Text_Editor.H
@@ -3565,6 +3597,7 @@ Fl_x.o: ../FL/Fl_RGB_Image.H
Fl_x.o: ../FL/Fl_Scrollbar.H
Fl_x.o: ../FL/Fl_Shared_Image.H
Fl_x.o: ../FL/Fl_Slider.H
Fl_x.o: ../FL/Fl_String.H
Fl_x.o: ../FL/Fl_Text_Buffer.H
Fl_x.o: ../FL/Fl_Text_Display.H
Fl_x.o: ../FL/Fl_Text_Editor.H
@@ -3661,6 +3694,7 @@ forms_bitmap.o: ../FL/Fl_RGB_Image.H
forms_bitmap.o: ../FL/Fl_Round_Button.H
forms_bitmap.o: ../FL/fl_show_colormap.H
forms_bitmap.o: ../FL/Fl_Slider.H
forms_bitmap.o: ../FL/Fl_String.H
forms_bitmap.o: ../FL/Fl_Tile.H
forms_bitmap.o: ../FL/Fl_Timer.H
forms_bitmap.o: ../FL/fl_types.h
@@ -3719,6 +3753,7 @@ forms_compatibility.o: ../FL/Fl_RGB_Image.H
forms_compatibility.o: ../FL/Fl_Round_Button.H
forms_compatibility.o: ../FL/fl_show_colormap.H
forms_compatibility.o: ../FL/Fl_Slider.H
forms_compatibility.o: ../FL/Fl_String.H
forms_compatibility.o: ../FL/Fl_Tile.H
forms_compatibility.o: ../FL/Fl_Timer.H
forms_compatibility.o: ../FL/fl_types.h
@@ -3787,6 +3822,7 @@ forms_fselect.o: ../FL/Fl_RGB_Image.H
forms_fselect.o: ../FL/Fl_Round_Button.H
forms_fselect.o: ../FL/fl_show_colormap.H
forms_fselect.o: ../FL/Fl_Slider.H
forms_fselect.o: ../FL/Fl_String.H
forms_fselect.o: ../FL/Fl_Tile.H
forms_fselect.o: ../FL/Fl_Timer.H
forms_fselect.o: ../FL/fl_types.h
@@ -3845,6 +3881,7 @@ forms_pixmap.o: ../FL/Fl_RGB_Image.H
forms_pixmap.o: ../FL/Fl_Round_Button.H
forms_pixmap.o: ../FL/fl_show_colormap.H
forms_pixmap.o: ../FL/Fl_Slider.H
forms_pixmap.o: ../FL/Fl_String.H
forms_pixmap.o: ../FL/Fl_Tile.H
forms_pixmap.o: ../FL/Fl_Timer.H
forms_pixmap.o: ../FL/fl_types.h
@@ -3902,6 +3939,7 @@ forms_timer.o: ../FL/Fl_RGB_Image.H
forms_timer.o: ../FL/Fl_Round_Button.H
forms_timer.o: ../FL/fl_show_colormap.H
forms_timer.o: ../FL/Fl_Slider.H
forms_timer.o: ../FL/Fl_String.H
forms_timer.o: ../FL/Fl_Tile.H
forms_timer.o: ../FL/Fl_Timer.H
forms_timer.o: ../FL/fl_types.h
+56 -43
View File
@@ -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-2017 by Bill Spitzak and others.
// Copyright 1998-2021 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
@@ -17,10 +17,6 @@
// https://www.fltk.org/bugs.php
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Input.H>
@@ -30,33 +26,34 @@
#include <FL/fl_ask.H>
void update_input_text(Fl_Widget* o, const char *input) {
if (input) {
o->copy_label(input);
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
// Button callback: v == 0 ("input") or 1 ("password")
void rename_button(Fl_Widget *o, void *v) {
int what = fl_int(v);
Fl_String input;
if (what == 0)
input = fl_input_str(0, "Input (no size limit, use ctrl/j for newline):", o->label());
else
input = fl_password_str(20, "Enter password (max. 20 characters):", o->label());
if (input.value()) {
o->copy_label(input.value());
o->redraw();
}
}
void rename_me(Fl_Widget*o) {
const char *input = fl_input("Input:", o->label());
update_input_text(o, input);
}
void rename_me_pwd(Fl_Widget*o) {
const char *input = fl_password("Input PWD:", o->label());
update_input_text(o, input);
}
void window_callback(Fl_Widget *win, void*) {
void window_callback(Fl_Widget *win, void *) {
int hotspot = fl_message_hotspot();
fl_message_hotspot(0);
fl_message_title("note: no hotspot set for this dialog");
int rep = fl_choice("Are you sure you want to quit?",
"Cancel", "Quit", "Dunno");
int rep = fl_choice("Are you sure you want to quit?", "Cancel", "Quit", "Dunno");
fl_message_hotspot(hotspot);
if (rep==1)
if (rep == 1)
exit(0);
else if (rep==2) { // (Dunno)
else if (rep == 2) { // (Dunno)
fl_message_position(win);
fl_message_title("This dialog must be centered over the main window");
fl_message("Well, maybe you should know before we quit.");
@@ -65,45 +62,61 @@ void window_callback(Fl_Widget *win, void*) {
/*
This timer callback shows a message dialog (fl_choice) window
every 5 seconds to test "recursive" common dialogs.
every 5 seconds to test "recursive" (aka nested) common dialogs.
The timer can be stopped by clicking the button "Stop these funny popups"
or pressing the Enter key. As it is currently implemented, clicking the
"Close" button will reactivate the popups (only possible if "recursive"
dialogs are enabled, see below).
Note 1: This dialog box is blocked in FLTK 1.3.x if another common dialog
is already open because the window used is a static (i.e. permanently
allocated) Fl_Window instance. This should be fixed in FLTK 1.4.0.
Note 1: This dialog box had been blocked in FLTK 1.3.x if another common
dialog was already open because the window used was a static (i.e. permanently
allocated) Fl_Window instance. This has been fixed in FLTK 1.4.0.
See STR #334 (sic !) and also STR #2751 ("Limit input field characters").
*/
void timer_cb(void *) {
static int stop = 0;
static const double delta = 5.0;
static int n = 0;
const double delta = 5.0; // delay of popups
const int nmax = 10; // limit no. of popups
n++;
if (n >= nmax)
stop = 1;
Fl_Box *message_icon = (Fl_Box *)fl_message_icon();
Fl::repeat_timeout(delta, timer_cb);
if (stop == 1) {
if (stop) {
message_icon->color(FL_WHITE);
return;
}
Fl::repeat_timeout(delta, timer_cb);
// Change the icon box color:
Fl_Color c = message_icon->color();
c = (c+1) % 32;
if (c == message_icon->labelcolor()) c++;
c = (c + 1) % 32;
if (c == message_icon->labelcolor())
c++;
message_icon->color((Fl_Color)c);
// test message title assignment with a local buffer
{ // local scope for buf
char buf[40]; // test: use local variable
sprintf(buf, "Message #%d", n); // fill message title
fl_message_title(buf); // set message title
strcpy(buf, "** void **"); // overwrite buffer to be sure
} // buf goes out of scope here
// pop up a message:
stop = fl_choice("Timeout. Click the 'Close' button.\n"
"Note: this message was blocked in FLTK 1.3\n"
"if another message window is open.\n"
"This *should* be fixed in FLTK 1.4.0!\n"
"This message should pop up every 5 seconds.",
"Close", "Stop these funny popups", NULL);
stop |= fl_choice(
"Timeout. Click the 'Close' button or press Escape.\n"
"Note: this message had been blocked in FLTK 1.3.x\n"
"and earlier if another message window was open.\n"
"This message should pop up every 5 seconds (max. 10 times)\n"
"in FLTK 1.4.0 and later until stopped by clicking the button\n"
"below or by pressing the Enter (Return) key.\n",
"Close", "Stop these funny popups", NULL);
}
int main(int argc, char **argv) {
@@ -115,9 +128,9 @@ int main(int argc, char **argv) {
Fl_Double_Window window(200, 105);
Fl_Return_Button b(20, 10, 160, 35, buffer);
b.callback(rename_me);
b.callback(rename_button, (void *)(0));
Fl_Button b2(20, 50, 160, 35, buffer2);
b2.callback(rename_me_pwd);
b2.callback(rename_button, (void *)(1));
window.end();
window.resizable(&b);
window.show(argc, argv);
@@ -126,9 +139,9 @@ int main(int argc, char **argv) {
window.callback(window_callback);
// Test: set default message window title:
// fl_message_title_default("Default Window Title");
// fl_message_title_default("Default Message Title");
// Test: multiple (nested, aka "recursive") popups
// Test: multiple (nested, aka "recursive") popups (see timer_cb())
Fl::add_timeout(5.0, timer_cb);
return Fl::run();
+25 -1
View File
@@ -83,6 +83,7 @@ ask.o: ../FL/Fl_Image.H
ask.o: ../FL/Fl_Input.H
ask.o: ../FL/Fl_Input_.H
ask.o: ../FL/Fl_Return_Button.H
ask.o: ../FL/Fl_String.H
ask.o: ../FL/fl_types.h
ask.o: ../FL/fl_utf8.h
ask.o: ../FL/Fl_Widget.H
@@ -203,6 +204,7 @@ browser.o: ../FL/Fl_Scrollbar.H
browser.o: ../FL/Fl_Select_Browser.H
browser.o: ../FL/Fl_Simple_Terminal.H
browser.o: ../FL/Fl_Slider.H
browser.o: ../FL/Fl_String.H
browser.o: ../FL/Fl_Text_Buffer.H
browser.o: ../FL/Fl_Text_Display.H
browser.o: ../FL/fl_types.h
@@ -222,6 +224,7 @@ button.o: ../FL/fl_casts.H
button.o: ../FL/Fl_Export.H
button.o: ../FL/Fl_Group.H
button.o: ../FL/Fl_Image.H
button.o: ../FL/Fl_String.H
button.o: ../FL/fl_types.h
button.o: ../FL/fl_utf8.h
button.o: ../FL/Fl_Widget.H
@@ -297,6 +300,7 @@ checkers.o: ../FL/Fl_Preferences.H
checkers.o: ../FL/Fl_Rect.H
checkers.o: ../FL/Fl_RGB_Image.H
checkers.o: ../FL/Fl_Slider.H
checkers.o: ../FL/Fl_String.H
checkers.o: ../FL/fl_types.h
checkers.o: ../FL/fl_utf8.h
checkers.o: ../FL/Fl_Valuator.H
@@ -347,6 +351,7 @@ clipboard.o: ../FL/Fl_RGB_Image.H
clipboard.o: ../FL/Fl_Scrollbar.H
clipboard.o: ../FL/Fl_Shared_Image.H
clipboard.o: ../FL/Fl_Slider.H
clipboard.o: ../FL/Fl_String.H
clipboard.o: ../FL/Fl_Tabs.H
clipboard.o: ../FL/Fl_Text_Buffer.H
clipboard.o: ../FL/Fl_Text_Display.H
@@ -392,6 +397,7 @@ colbrowser.o: ../FL/Fl_Hold_Browser.H
colbrowser.o: ../FL/Fl_Image.H
colbrowser.o: ../FL/Fl_Scrollbar.H
colbrowser.o: ../FL/Fl_Slider.H
colbrowser.o: ../FL/Fl_String.H
colbrowser.o: ../FL/fl_types.h
colbrowser.o: ../FL/fl_utf8.h
colbrowser.o: ../FL/Fl_Valuator.H
@@ -595,6 +601,7 @@ demo.o: ../FL/Fl_RGB_Image.H
demo.o: ../FL/Fl_Scrollbar.H
demo.o: ../FL/Fl_Simple_Terminal.H
demo.o: ../FL/Fl_Slider.H
demo.o: ../FL/Fl_String.H
demo.o: ../FL/Fl_Text_Buffer.H
demo.o: ../FL/Fl_Text_Display.H
demo.o: ../FL/fl_types.h
@@ -653,6 +660,7 @@ device.o: ../FL/Fl_Round_Button.H
device.o: ../FL/Fl_Scrollbar.H
device.o: ../FL/Fl_Shared_Image.H
device.o: ../FL/Fl_Slider.H
device.o: ../FL/Fl_String.H
device.o: ../FL/Fl_SVG_File_Surface.H
device.o: ../FL/Fl_Tile.H
device.o: ../FL/fl_types.h
@@ -733,6 +741,7 @@ editor.o: ../FL/Fl_Return_Button.H
editor.o: ../FL/Fl_RGB_Image.H
editor.o: ../FL/Fl_Scrollbar.H
editor.o: ../FL/Fl_Slider.H
editor.o: ../FL/Fl_String.H
editor.o: ../FL/Fl_Text_Buffer.H
editor.o: ../FL/Fl_Text_Display.H
editor.o: ../FL/Fl_Text_Editor.H
@@ -804,6 +813,7 @@ file_chooser.o: ../FL/Fl_Scrollbar.H
file_chooser.o: ../FL/Fl_Shared_Image.H
file_chooser.o: ../FL/Fl_Simple_Terminal.H
file_chooser.o: ../FL/Fl_Slider.H
file_chooser.o: ../FL/Fl_String.H
file_chooser.o: ../FL/Fl_Text_Buffer.H
file_chooser.o: ../FL/Fl_Text_Display.H
file_chooser.o: ../FL/Fl_Tile.H
@@ -824,6 +834,7 @@ fltk-versions.o: ../FL/fl_casts.H
fltk-versions.o: ../FL/Fl_Export.H
fltk-versions.o: ../FL/Fl_Group.H
fltk-versions.o: ../FL/Fl_Image.H
fltk-versions.o: ../FL/Fl_String.H
fltk-versions.o: ../FL/fl_types.h
fltk-versions.o: ../FL/fl_utf8.h
fltk-versions.o: ../FL/Fl_Widget.H
@@ -869,6 +880,7 @@ fonts.o: ../FL/Fl_Return_Button.H
fonts.o: ../FL/Fl_RGB_Image.H
fonts.o: ../FL/Fl_Scrollbar.H
fonts.o: ../FL/Fl_Slider.H
fonts.o: ../FL/Fl_String.H
fonts.o: ../FL/Fl_Tile.H
fonts.o: ../FL/fl_types.h
fonts.o: ../FL/fl_utf8.h
@@ -925,6 +937,7 @@ forms.o: ../FL/Fl_Round_Button.H
forms.o: ../FL/Fl_Scrollbar.H
forms.o: ../FL/fl_show_colormap.H
forms.o: ../FL/Fl_Slider.H
forms.o: ../FL/Fl_String.H
forms.o: ../FL/Fl_Tile.H
forms.o: ../FL/Fl_Timer.H
forms.o: ../FL/fl_types.h
@@ -1000,6 +1013,7 @@ fullscreen.o: ../FL/Fl_Menu_Item.H
fullscreen.o: ../FL/Fl_Scrollbar.H
fullscreen.o: ../FL/Fl_Single_Window.H
fullscreen.o: ../FL/Fl_Slider.H
fullscreen.o: ../FL/Fl_String.H
fullscreen.o: ../FL/Fl_Toggle_Light_Button.H
fullscreen.o: ../FL/fl_types.h
fullscreen.o: ../FL/fl_utf8.h
@@ -1416,7 +1430,7 @@ menubar.o: ../FL/Fl_RGB_Image.H
menubar.o: ../FL/Fl_Scrollbar.H
menubar.o: ../FL/Fl_Simple_Terminal.H
menubar.o: ../FL/Fl_Slider.H
menubar.o: ../FL/fl_string.h
menubar.o: ../FL/Fl_String.H
menubar.o: ../FL/Fl_Sys_Menu_Bar.H
menubar.o: ../FL/Fl_Text_Buffer.H
menubar.o: ../FL/Fl_Text_Display.H
@@ -1438,6 +1452,7 @@ message.o: ../FL/fl_casts.H
message.o: ../FL/Fl_Export.H
message.o: ../FL/Fl_Group.H
message.o: ../FL/Fl_Image.H
message.o: ../FL/Fl_String.H
message.o: ../FL/fl_types.h
message.o: ../FL/fl_utf8.h
message.o: ../FL/Fl_Widget.H
@@ -1505,6 +1520,7 @@ native-filechooser.o: ../FL/Fl_RGB_Image.H
native-filechooser.o: ../FL/Fl_Scrollbar.H
native-filechooser.o: ../FL/Fl_Simple_Terminal.H
native-filechooser.o: ../FL/Fl_Slider.H
native-filechooser.o: ../FL/Fl_String.H
native-filechooser.o: ../FL/Fl_Text_Buffer.H
native-filechooser.o: ../FL/Fl_Text_Display.H
native-filechooser.o: ../FL/Fl_Tile.H
@@ -1693,6 +1709,7 @@ pixmap_browser.o: ../FL/Fl_Return_Button.H
pixmap_browser.o: ../FL/Fl_Scrollbar.H
pixmap_browser.o: ../FL/Fl_Shared_Image.H
pixmap_browser.o: ../FL/Fl_Slider.H
pixmap_browser.o: ../FL/Fl_String.H
pixmap_browser.o: ../FL/Fl_SVG_File_Surface.H
pixmap_browser.o: ../FL/Fl_Tile.H
pixmap_browser.o: ../FL/fl_types.h
@@ -1727,6 +1744,7 @@ preferences.o: ../FL/Fl_Menu_Item.H
preferences.o: ../FL/Fl_Preferences.H
preferences.o: ../FL/Fl_Round_Button.H
preferences.o: ../FL/Fl_Slider.H
preferences.o: ../FL/Fl_String.H
preferences.o: ../FL/fl_types.h
preferences.o: ../FL/fl_utf8.h
preferences.o: ../FL/Fl_Valuator.H
@@ -1961,6 +1979,7 @@ resizebox.o: ../FL/Fl_Preferences.H
resizebox.o: ../FL/Fl_Radio_Button.H
resizebox.o: ../FL/Fl_Rect.H
resizebox.o: ../FL/Fl_RGB_Image.H
resizebox.o: ../FL/Fl_String.H
resizebox.o: ../FL/fl_types.h
resizebox.o: ../FL/fl_utf8.h
resizebox.o: ../FL/Fl_Widget.H
@@ -2107,6 +2126,7 @@ sudoku.o: ../FL/Fl_RGB_Image.H
sudoku.o: ../FL/Fl_Scrollbar.H
sudoku.o: ../FL/Fl_Shared_Image.H
sudoku.o: ../FL/Fl_Slider.H
sudoku.o: ../FL/Fl_String.H
sudoku.o: ../FL/Fl_Sys_Menu_Bar.H
sudoku.o: ../FL/fl_types.h
sudoku.o: ../FL/fl_utf8.h
@@ -2174,6 +2194,7 @@ table.o: ../FL/Fl_Scroll.H
table.o: ../FL/Fl_Scrollbar.H
table.o: ../FL/Fl_Simple_Terminal.H
table.o: ../FL/Fl_Slider.H
table.o: ../FL/Fl_String.H
table.o: ../FL/Fl_Table.H
table.o: ../FL/Fl_Table_Row.H
table.o: ../FL/Fl_Text_Buffer.H
@@ -2201,6 +2222,7 @@ tabs.o: ../FL/Fl_Image.H
tabs.o: ../FL/Fl_Input.H
tabs.o: ../FL/Fl_Input_.H
tabs.o: ../FL/Fl_Return_Button.H
tabs.o: ../FL/Fl_String.H
tabs.o: ../FL/Fl_Tabs.H
tabs.o: ../FL/fl_types.h
tabs.o: ../FL/fl_utf8.h
@@ -2225,6 +2247,7 @@ threads.o: ../FL/Fl_Group.H
threads.o: ../FL/Fl_Image.H
threads.o: ../FL/Fl_Scrollbar.H
threads.o: ../FL/Fl_Slider.H
threads.o: ../FL/Fl_String.H
threads.o: ../FL/fl_types.h
threads.o: ../FL/fl_utf8.h
threads.o: ../FL/Fl_Valuator.H
@@ -2312,6 +2335,7 @@ tree.o: ../FL/Fl_RGB_Image.H
tree.o: ../FL/Fl_Scrollbar.H
tree.o: ../FL/Fl_Simple_Terminal.H
tree.o: ../FL/Fl_Slider.H
tree.o: ../FL/Fl_String.H
tree.o: ../FL/Fl_Text_Buffer.H
tree.o: ../FL/Fl_Text_Display.H
tree.o: ../FL/Fl_Tile.H