fltk  1.3.5-source
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X.
  Fossies Dox: fltk-1.3.5-source.tar.bz2  ("inofficial" and yet experimental doxygen-generated source code documentation)  

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
 

Functions

void fl_beep (int type)
 
void fl_message (const char *fmt,...)
 
void fl_alert (const char *fmt,...)
 
int fl_ask (const char *fmt,...)
 
int fl_choice (const char *fmt, const char *b0, const char *b1, const char *b2,...)
 
Fl_Widgetfl_message_icon ()
 
static const char * input_innards (const char *fmt, va_list ap, const char *defstr, uchar type)
 
const char * fl_input (const char *fmt, const char *defstr,...)
 
const char * fl_password (const char *fmt, const char *defstr,...)
 
void fl_message_hotspot (int enable)
 
int fl_message_hotspot (void)
 
void fl_message_title (const char *title)
 
void fl_message_title_default (const char *title)
 
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. More...
 
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. More...
 
void fl_file_chooser_callback (void(*cb)(const char *))
 
void fl_file_chooser_ok_label (const char *l)
 
char * fl_file_chooser (const char *message, const char *pat, const char *fname, int relative)
 
char * fl_dir_chooser (const char *message, const char *fname, int relative)
 

Variables

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

Detailed Description

Function Documentation

◆ fl_alert()

◆ 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.

Definition at line 390 of file fl_ask.cxx.

References avoidRecursion, fl_no, fl_yes, and innards().

◆ fl_beep()

◆ 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

Definition at line 459 of file fl_ask.cxx.

References avoidRecursion, and innards().

Referenced by ExternalCodeEditor::close_editor(), Fl_FLTK_File_Chooser::exist_dialog(), exit_cb(), fl_show_choice(), fl_show_question(), new_cb(), Fl_Comment_Type::open(), open_cb(), open_history_cb(), revert_cb(), save_cb(), save_template_cb(), and template_delete_cb().

◆ 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

Definition at line 564 of file Fl_Color_Chooser.cxx.

References Fl_Color_Chooser::b(), b, ColorChip::b, Fl_Widget::callback(), cc_cancel_cb(), cc_ok_cb(), chooser_cb(), Fl_Group::end(), fl_cancel, fl_ok, Fl_Color_Chooser::g(), ColorChip::g, Fl_Window::hotspot(), Fl_Color_Chooser::mode(), name, Fl_Color_Chooser::r(), ColorChip::r, Fl_Group::resizable(), Fl_Color_Chooser::rgb(), Fl_Window::set_modal(), Fl_TooltipBox::show(), Fl_Window::shown(), Fl::wait(), and window.

Referenced by Fl_Color_Chooser::fl_color_chooser().

◆ 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

Definition at line 607 of file Fl_Color_Chooser.cxx.

References b, Fl_Color_Chooser::fl_color_chooser(), and name.

◆ 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

Definition at line 167 of file fl_file_dir.cxx.

References callback(), Fl_File_Chooser::callback(), Fl_File_Chooser::CREATE, Fl_File_Chooser::DIRECTORY, fc, Fl_File_Chooser::filter(), fl_filename_relative(), FL_PATH_MAX, fname, Fl_File_Chooser::label(), message, popup(), relative(), Fl_File_Chooser::type(), and Fl_File_Chooser::value().

◆ 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

Definition at line 89 of file fl_file_dir.cxx.

References callback(), Fl_File_Chooser::callback(), Fl_File_Chooser::CREATE, current_label, Fl_File_Chooser::directory(), fc, Fl_File_Chooser::filter(), fl_filename_name(), fl_filename_relative(), FL_PATH_MAX, fname, Fl_File_Chooser::label(), message, Fl_File_Chooser::ok_label(), p, popup(), relative(), strlcpy, Fl_File_Chooser::type(), and Fl_File_Chooser::value().

Referenced by fl_show_file_selector(), and ui_find_image().

◆ 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>

Definition at line 60 of file fl_file_dir.cxx.

References cb(), and current_callback.

◆ 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>

Definition at line 70 of file fl_file_dir.cxx.

References current_label, and fl_ok.

Referenced by ui_find_image().

◆ 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

Definition at line 505 of file fl_ask.cxx.

References avoidRecursion, FL_NORMAL_INPUT, and input_innards().

Referenced by fl_show_input(), fl_show_simple_input(), Fl_File_Chooser::newdir(), Fl_Comment_Type::open(), and Fl_File_Chooser::showChoiceCB().

◆ 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

Definition at line 338 of file fl_ask.cxx.

References avoidRecursion, fl_close, iconlabel, and innards().

Referenced by Fl_Table_Type::add_child(), callback_cb(), comment_cb(), copy_cb(), cut_cb(), duplicate_cb(), fl_show_message(), group_cb(), main(), Fl_Code_Type::make(), Fl_CodeBlock_Type::make(), Fl_Widget_Type::make(), Fl_Window_Type::make(), Fl_Menu_Item_Type::make(), Fl_Comment_Type::open(), open_cb(), open_history_cb(), openwidget_cb(), paste_cb(), read_error(), revert_cb(), show_global_settings_window(), ungroup_cb(), user_data_cb(), user_data_type_cb(), v_input_cb(), write_cb(), and write_strings_cb().

◆ 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

Definition at line 555 of file fl_ask.cxx.

References enableHotspot.

◆ 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)

Definition at line 567 of file fl_ask.cxx.

References enableHotspot.

◆ 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>

Definition at line 477 of file fl_ask.cxx.

References icon, and makeform().

◆ 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

Definition at line 586 of file fl_ask.cxx.

References Fl_Window::copy_label(), makeform(), message_form, and title.

◆ 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

Definition at line 607 of file fl_ask.cxx.

References free(), message_title_default, and title.

◆ 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

Definition at line 531 of file fl_ask.cxx.

References avoidRecursion, FL_SECRET_INPUT, and input_innards().

◆ input_innards()

static const char* input_innards ( const char *  fmt,
va_list  ap,
const char *  defstr,
uchar  type 
)
static

Variable Documentation

◆ error

void(* Fl::error = ::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>

Definition at line 513 of file Fl.H.

Referenced by Fl::args(), Fl_GIF_Image::Fl_GIF_Image(), Fl_PNM_Image::Fl_PNM_Image(), fontopen(), getsyscolor(), Fl_Graphics_Driver::line_style(), Fl_File_Icon::load_fti(), Fl_Graphics_Driver::pop_matrix(), Fl_Text_Display::position_to_line(), Fl_Graphics_Driver::push_matrix(), Fl_Text_Buffer::remove_modify_callback(), and Fl_Text_Buffer::remove_predelete_callback().

◆ fatal

void(* Fl::fatal = ::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>

Definition at line 530 of file Fl.H.

Referenced by Fl_Gl_Window::draw(), figure_out_visual(), fl_open_display(), get_imm_module(), get_wsock_mod(), io_error_handler(), and WndProc().

◆ fl_cancel

const char* fl_cancel = "Cancel"

string pointer used in common dialogs, you can change it to another language

Definition at line 274 of file fl_ask.cxx.

Referenced by Fl_FLTK_File_Chooser::exist_dialog(), Fl_Color_Chooser::fl_color_chooser(), Fl_File_Chooser::Fl_File_Chooser(), and input_innards().

◆ fl_close

const char* fl_close = "Close"

string pointer used in common dialogs, you can change it to another language

Definition at line 275 of file fl_ask.cxx.

Referenced by fl_alert(), and fl_message().

◆ fl_no

const char* fl_no = "No"

string pointer used in common dialogs, you can change it to another language

Definition at line 271 of file fl_ask.cxx.

Referenced by fl_ask(), and fl_show_question().

◆ fl_ok

const char* fl_ok = "OK"

string pointer used in common dialogs, you can change it to another language

Definition at line 273 of file fl_ask.cxx.

Referenced by Fl_FLTK_File_Chooser::exist_dialog(), Fl_Color_Chooser::fl_color_chooser(), Fl_File_Chooser::Fl_File_Chooser(), Fl_File_Chooser::fl_file_chooser_ok_label(), and input_innards().

◆ fl_yes

const char* fl_yes = "Yes"

string pointer used in common dialogs, you can change it to another language

Definition at line 272 of file fl_ask.cxx.

Referenced by fl_ask(), and fl_show_question().

◆ warning

void(* Fl::warning = ::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>

Definition at line 498 of file Fl.H.

Referenced by Fl_BMP_Image::Fl_BMP_Image(), Fl_GIF_Image::Fl_GIF_Image(), fl_init_xim(), Fl_JPEG_Image::Fl_JPEG_Image(), Fl_PNM_Image::Fl_PNM_Image(), Fl_File_Icon::load(), Fl_PNG_Image::load_png_(), Fl_Graphics_Driver::pop_clip(), Fl_Graphics_Driver::push_clip(), Fl_Graphics_Driver::push_no_clip(), Fl_translated_Xlib_Graphics_Driver_::translate_all(), and xerror_handler().

fl_choice
int fl_choice(const char *q, const char *b0, const char *b1, const char *b2,...)
Definition: fl_ask.cxx:459