How to build a GUI application without minimize, resize icons on title bar using FLTK & gcc?
1) Create a FLTK modal window .
Use of a FLTK modal window means dialog window is one option which does not have close functionality and icon . To exit this modal window, we have to use fl_ask() function. For eq:
FL/fl_ask.h.
if (fl_ask("Do you really want to save and exit?"))
save_and_exit();
2) When we try to close the FLTK window , the default callback function of Fl_Window is called . We can set our own window callback to a different value, by overriding the default close / hide functionality of the window.
The default callback function allows the user to save and exit, don't save, or cancel.
The FLTK man page defination is :
static void window_cb (Fl_Widget *widget, void *)
{ Fl_Window *window = (Fl_Window *)widget;
// fl_choice presents a modal dialog window with up to three choices. int result = fl_choice("Do you want to save before quitting?, "Don't Save",
// 0 "Save",
// 1 "Cancel"
// 2 );
if (result == 0)
{
// Close without saving
hide(); }
else if (result == 1)
{
// Save and close
save(); window->hide(); }
else if (result == 2)
{
// Cancel / don't close
// don't do anything
}
}
You can define your own window callback function in your main function:
window->callback( win_cb );