FLTK 1.3.9
Loading...
Searching...
No Matches
Common Dialogs classes and functions

Classes

class  Fl_Color_Chooser
 The Fl_Color_Chooser widget provides a standard RGB color chooser. More...
 
class  Fl_File_Chooser
 The Fl_File_Chooser widget displays a standard file selection dialog that supports various selection modes. More...
 

Functions

void fl_alert (const char *fmt,...)
 Shows an alert message dialog box.
 
int fl_ask (const char *fmt,...)
 Shows a dialog displaying the fmt message, this dialog features 2 yes/no buttons.
 
void fl_beep (int type)
 Emits a system beep message.
 
int fl_choice (const char *fmt, const char *b0, const char *b1, const char *b2,...)
 Shows a dialog displaying the printf style fmt message, this dialog features up to 3 customizable choice buttons.
 
int fl_choice_n (const char *fmt, const char *b0, const char *b1, const char *b2,...)
 Like fl_choice() but with extended (negative) return values.
 
int fl_color_chooser (const char *name, double &r, double &g, double &b, int cmode)
 Pops up a window to let the user pick an arbitrary RGB color.
 
int fl_color_chooser (const char *name, uchar &r, uchar &g, uchar &b, int cmode)
 Pops up a window to let the user pick an arbitrary RGB color.
 
char * fl_dir_chooser (const char *message, const char *fname, int relative)
 Shows a file chooser dialog and gets a directory.
 
char * fl_file_chooser (const char *message, const char *pat, const char *fname, int relative)
 Shows a file chooser dialog and gets a filename.
 
void fl_file_chooser_callback (void(*cb)(const char *))
 Set the file chooser callback.
 
void fl_file_chooser_ok_label (const char *l)
 Set the "OK" button label.
 
const char * fl_input (const char *fmt, const char *defstr,...)
 Shows an input dialog displaying the fmt message.
 
void fl_message (const char *fmt,...)
 Shows an information message dialog box.
 
void fl_message_hotspot (int enable)
 Sets whether or not to move the common message box used in many common dialogs like fl_message(), fl_alert(), fl_ask(), fl_choice(), fl_input(), fl_password() to follow the mouse pointer.
 
int fl_message_hotspot (void)
 Gets whether or not to move the common message box used in many common dialogs like fl_message(), fl_alert(), fl_ask(), fl_choice(), fl_input(), fl_password() to follow the mouse pointer.
 
Fl_Widgetfl_message_icon ()
 Gets the Fl_Box icon container of the current default dialog used in many common dialogs like fl_message(), fl_alert(), fl_ask(), fl_choice(), fl_input(), fl_password()
 
void fl_message_title (const char *title)
 Sets the title of the dialog window used in many common dialogs.
 
void fl_message_title_default (const char *title)
 Sets the default title of the dialog window used in many common dialogs.
 
const char * fl_password (const char *fmt, const char *defstr,...)
 Shows an input dialog displaying the fmt message.
 

Variables

static void(* Fl::error )(const char *,...) = ::error
 FLTK calls Fl::error() to output a normal error message.
 
static void(* Fl::fatal )(const char *,...) = ::fatal
 FLTK calls Fl::fatal() to output a fatal error message.
 
const char * fl_cancel = "Cancel"
 string pointer used in common dialogs, you can change it to another language
 
const char * fl_close = "Close"
 string pointer used in common dialogs, you can change it to another language
 
const char * fl_no = "No"
 string pointer used in common dialogs, you can change it to another language
 
const char * fl_ok = "OK"
 string pointer used in common dialogs, you can change it to another language
 
const char * fl_yes = "Yes"
 string pointer used in common dialogs, you can change it to another language
 
static void(* Fl::warning )(const char *,...) = ::warning
 FLTK calls Fl::warning() to output a warning message.
 

Detailed Description

Function Documentation

◆ fl_alert()

void fl_alert ( const char *  fmt,
  ... 
)

Shows an alert message dialog box.

Note
Common dialog boxes are application modal. No more than one common dialog box can be open at any time. Requests for additional dialog boxes are ignored.
#include <FL/fl_ask.H>
Parameters
[in]fmtcan be used as an sprintf-like format and variables for the message text

◆ fl_ask()

int fl_ask ( const char *  fmt,
  ... 
)

Shows a dialog displaying the fmt message, this dialog features 2 yes/no buttons.

Note
Common dialog boxes are application modal. No more than one common dialog box can be open at any time. Requests for additional dialog boxes are ignored.
#include <FL/fl_ask.H>
Parameters
[in]fmtcan be used as an sprintf-like format and variables for the message text
Return values
0if the no button is selected or another dialog box is still open
1if yes is selected
Deprecated:
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() with the appropriate verbs instead.

◆ fl_beep()

void fl_beep ( int  type)

Emits a system beep message.

Parameters
[in]typeThe beep type from the Fl_Beep enumeration.
Note
#include <FL/fl_ask.H>

◆ fl_choice()

int fl_choice ( const char *  fmt,
const char *  b0,
const char *  b1,
const char *  b2,
  ... 
)

Shows a dialog displaying the printf style fmt message, this dialog features up to 3 customizable choice buttons.

Note
Common dialog boxes are application modal. No more than one common dialog box can be open at any time. Requests for additional dialog boxes are ignored.
#include <FL/fl_ask.H>

Three choices with printf() style formatting:

int num_msgs = GetNumberOfMessages();
switch ( fl_choice("What to do with %d messages?", "Send", "Save", "Delete", num_msgs) ) {
case 0: .. // Send
case 1: .. // Save (default)
case 2: .. // Delete
..
}

Three choice example:

switch ( fl_choice("How many musketeers?", "One", "Two", "Three") ) {
case 0: .. // One
case 1: .. // Two (default)
case 2: .. // Three
}

Two choice example:

switch ( fl_choice("Empty trash?", "Yes", "No", 0) ) {
case 0: .. // Yes
case 1: .. // No (default)
}

One choice example:

fl_choice("All hope is lost.", "OK", 0, 0); // "OK" default
Parameters
[in]fmtcan be used as an sprintf-like format and variables for the message text
[in]b0text label of button 0
[in]b1text label of button 1 (can be 0)
[in]b2text label of button 2 (can be 0)
Return values
0if the first button with b0 text is pushed or another dialog box is still open
1if the second button with b1 text is pushed
2if the third button with b2 text is pushed

◆ fl_choice_n()

int fl_choice_n ( const char *  fmt,
const char *  b0,
const char *  b1,
const char *  b2,
  ... 
)

Like fl_choice() but with extended (negative) return values.

This function can return negative values as described below whereas fl_choice() only returns "button values" (0, 1, 2).

With fl_choice_n() you can arrange the buttons in a way that any button can be the standard "cancel" button because Escape and closing the window with the close button can be distinguished from button return codes.

Negative values are always "special" and should be considered like "cancel".

The special value -3 means that the dialog was blocked (not executed).

Other than that both functions are the same.

See also
fl_choice()
Since
1.3.8
Parameters
[in]fmtcan be used as an sprintf-like format and variables for the message text
[in]b0text label of button 0
[in]b1text label of button 1 (can be 0)
[in]b2text label of button 2 (can be 0)
Return values
-3if another dialog box is still open (the dialog was blocked)
-2if the dialog window was closed by clicking the close button
-1if the dialog was closed by hitting Escape
0if the first button with b0 text is pushed
1if the second button with b1 text is pushed
2if the third button with b2 text is pushed

◆ fl_color_chooser() [1/2]

int fl_color_chooser ( const char name,
double r,
double g,
double b,
int  cmode 
)
related

Pops up a window to let the user pick an arbitrary RGB color.

Note
#include <FL/Fl_Color_Chooser.H>
Parameters
[in]nameTitle label for the window
[in,out]r,g,bColor components in the range 0.0 to 1.0.
[in]cmodeOptional mode for color chooser. See mode(int). Default -1 if none (rgb mode).
Return values
1if user confirms the selection
0if user cancels the dialog

◆ fl_color_chooser() [2/2]

int fl_color_chooser ( const char name,
uchar r,
uchar g,
uchar b,
int  cmode 
)
related

Pops up a window to let the user pick an arbitrary RGB color.

Note
#include <FL/Fl_Color_Chooser.H>
Parameters
[in]nameTitle label for the window
[in,out]r,g,bColor components in the range 0 to 255.
[in]cmodeOptional mode for color chooser. See mode(int). Default -1 if none (rgb mode).
Return values
1if user confirms the selection
0if user cancels the dialog

◆ fl_dir_chooser()

char * fl_dir_chooser ( const char *  message,
const char *  fname,
int  relative 
)
related

Shows a file chooser dialog and gets a directory.

Note
#include <FL/Fl_File_Chooser.H>
Parameters
[in]messagetitle bar text
[in]fnameinitial/default directory name
[in]relative0 for absolute path return, relative otherwise
Returns
the directory path string chosen by the user or NULL if user cancels

◆ fl_file_chooser()

char * fl_file_chooser ( const char *  message,
const char *  pat,
const char *  fname,
int  relative 
)
related

Shows a file chooser dialog and gets a filename.

Note
#include <FL/Fl_File_Chooser.H>
Parameters
[in]messagetext in title bar
[in]patfilename pattern filter
[in]fnameinitial/default filename selection
[in]relative0 for absolute path name, relative path name otherwise
Returns
the user selected filename, in absolute or relative format or NULL if user cancels

◆ fl_file_chooser_callback()

void fl_file_chooser_callback ( void(*)(const char *)  cb)
related

Set the file chooser callback.

Note
#include <FL/Fl_File_Chooser.H>

◆ fl_file_chooser_ok_label()

void fl_file_chooser_ok_label ( const char *  l)
related

Set the "OK" button label.

Note
#include <FL/Fl_File_Chooser.H>

◆ fl_input()

const char * fl_input ( const char *  fmt,
const char *  defstr,
  ... 
)

Shows an input dialog displaying the fmt message.

Note
Common dialog boxes are application modal. No more than one common dialog box can be open at any time. Requests for additional dialog boxes are ignored.
#include <FL/fl_ask.H>
Parameters
[in]fmtcan be used as an sprintf-like format and variables for the message text
[in]defstrdefines the default returned string if no text is entered
Returns
the user string input if OK was pushed, NULL if Cancel was pushed or another dialog box was still open

◆ fl_message()

void fl_message ( const char *  fmt,
  ... 
)

Shows an information message dialog box.

Note
Common dialog boxes are application modal. No more than one common dialog box can be open at any time. Requests for additional dialog boxes are ignored.
#include <FL/fl_ask.H>
Parameters
[in]fmtcan be used as an sprintf-like format and variables for the message text

◆ fl_message_hotspot() [1/2]

void fl_message_hotspot ( int  enable)

Sets whether or not to move the common message box used in many common dialogs like fl_message(), fl_alert(), fl_ask(), fl_choice(), fl_input(), fl_password() to follow the mouse pointer.

The default is enabled, so that the default button is the hotspot and appears at the mouse position.

Note
#include <FL/fl_ask.H>
Parameters
[in]enablenon-zero enables hotspot behavior, 0 disables hotspot

◆ fl_message_hotspot() [2/2]

int fl_message_hotspot ( void  )

Gets whether or not to move the common message box used in many common dialogs like fl_message(), fl_alert(), fl_ask(), fl_choice(), fl_input(), fl_password() to follow the mouse pointer.

Note
#include <FL/fl_ask.H>
Returns
0 if disable, non-zero otherwise
See also
fl_message_hotspot(int)

◆ fl_message_icon()

Fl_Widget * fl_message_icon ( )

Gets the Fl_Box icon container of the current default dialog used in many common dialogs like fl_message(), fl_alert(), fl_ask(), fl_choice(), fl_input(), fl_password()

Note
#include <FL/fl_ask.H>

◆ fl_message_title()

void fl_message_title ( const char *  title)

Sets the title of the dialog window used in many common dialogs.

This window title will be used in the next call of one of the common dialogs like fl_message(), fl_alert(), fl_ask(), fl_choice(), fl_input(), fl_password().

The title string is copied internally, so that you can use a local variable or free the string immediately after this call. It applies only to the next call of one of the common dialogs and will be reset to an empty title (the default for all dialogs) after that call.

Note
#include <FL/fl_ask.H>
Parameters
[in]titlewindow label, string copied internally

◆ fl_message_title_default()

void fl_message_title_default ( const char *  title)

Sets the default title of the dialog window used in many common dialogs.

This window title will be used in all subsequent calls of one of the common dialogs like fl_message(), fl_alert(), fl_ask(), fl_choice(), fl_input(), fl_password(), unless a specific title has been set with fl_message_title(const char *title).

The default is no title. You can override the default title for a single dialog with fl_message_title(const char *title).

The title string is copied internally, so that you can use a local variable or free the string immediately after this call.

Note
#include <FL/fl_ask.H>
Parameters
[in]titledefault window label, string copied internally

◆ fl_password()

const char * fl_password ( const char *  fmt,
const char *  defstr,
  ... 
)

Shows an input dialog displaying the fmt message.

Like fl_input() except the input text is not shown, '*' characters are displayed instead.

Note
Common dialog boxes are application modal. No more than one common dialog box can be open at any time. Requests for additional dialog boxes are ignored.
#include <FL/fl_ask.H>
Parameters
[in]fmtcan be used as an sprintf-like format and variables for the message text
[in]defstrdefines the default returned string if no text is entered
Returns
the user string input if OK was pushed, NULL if Cancel was pushed or aother dialog box was still open

Variable Documentation

◆ error

void(* Fl::error)(const char *format,...) = ::error
static

FLTK calls Fl::error() to output a normal error message.

The default version on Windows displays the error message in a MessageBox window.

The default version on all other platforms prints the error message to stderr.

You can override the behavior by setting the function pointer to your own routine.

Fl::error() means there is a recoverable error such as the inability to read an image file. The default implementation returns after displaying the message.

Note
#include <FL/Fl.H>

◆ fatal

void(* Fl::fatal)(const char *format,...) = ::fatal
static

FLTK calls Fl::fatal() to output a fatal error message.

The default version on Windows displays the error message in a MessageBox window.

The default version on all other platforms prints the error message to stderr.

You can override the behavior by setting the function pointer to your own routine.

Fl::fatal() must not return, as FLTK is in an unusable state, however your version may be able to use longjmp or an exception to continue, as long as it does not call FLTK again. The default implementation exits with status 1 after displaying the message.

Note
#include <FL/Fl.H>

◆ warning

void(* Fl::warning)(const char *format,...) = ::warning
static

FLTK calls Fl::warning() to output a warning message.

The default version on Windows returns without printing a warning message, because Windows programs normally don't have stderr (a console window) enabled.

The default version on all other platforms prints the warning message to stderr.

You can override the behavior by setting the function pointer to your own routine.

Fl::warning() means that there was a recoverable problem, the display may be messed up, but the user can probably keep working - all X protocol errors call this, for example. The default implementation returns after displaying the message.

Note
#include <FL/Fl.H>