diff --git a/ChangeLog b/ChangeLog index 0964c2ea..ef4a5a2b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2017-10-30 Markus Gans * Fix scrollview functionality with new inheritance structure + * Add a standardized close confirmation dialog 2017-10-29 Markus Gans * Adaptation of the inheritance diagrams in the header files diff --git a/examples/calculator.cpp b/examples/calculator.cpp index f9f0e970..c8a96bba 100644 --- a/examples/calculator.cpp +++ b/examples/calculator.cpp @@ -574,13 +574,7 @@ void Calc::onAccel (FAccelEvent* ev) //---------------------------------------------------------------------- void Calc::onClose (FCloseEvent* ev) { - int ret = FMessageBox::info ( this, "Quit", - "Do you really want\n" - "to quit the program ?", - FMessageBox::Yes, - FMessageBox::No ); - - ( ret == FMessageBox::Yes ) ? ev->accept() : ev->ignore(); + FApplication::closeConfirmationDialog (this, ev); } //---------------------------------------------------------------------- diff --git a/examples/listbox.cpp b/examples/listbox.cpp index b9dc739b..b62746ed 100644 --- a/examples/listbox.cpp +++ b/examples/listbox.cpp @@ -161,15 +161,7 @@ Listbox::~Listbox() // destructor //---------------------------------------------------------------------- void Listbox::onClose (FCloseEvent* ev) { - int ret = FMessageBox::info ( this, "Quit" - , "Do you really want\n" - "to quit the program ?" - , FMessageBox::Yes - , FMessageBox::No ); - if ( ret == FMessageBox::Yes ) - ev->accept(); - else - ev->ignore(); + FApplication::closeConfirmationDialog (this, ev); } diff --git a/examples/listview.cpp b/examples/listview.cpp index d1d95876..49edd1f3 100644 --- a/examples/listview.cpp +++ b/examples/listview.cpp @@ -159,15 +159,7 @@ Listview::~Listview() // destructor //---------------------------------------------------------------------- void Listview::onClose (FCloseEvent* ev) { - int ret = FMessageBox::info ( this, "Quit" - , "Do you really want\n" - "to quit the program ?" - , FMessageBox::Yes - , FMessageBox::No ); - if ( ret == FMessageBox::Yes ) - ev->accept(); - else - ev->ignore(); + FApplication::closeConfirmationDialog (this, ev); } //---------------------------------------------------------------------- diff --git a/examples/mandelbrot.cpp b/examples/mandelbrot.cpp index 6d606995..f0b14f20 100644 --- a/examples/mandelbrot.cpp +++ b/examples/mandelbrot.cpp @@ -126,16 +126,7 @@ void Mandelbrot::onAccel (FAccelEvent* ev) //---------------------------------------------------------------------- void Mandelbrot::onClose (FCloseEvent* ev) { - int ret = FMessageBox::info ( this, "Quit" - , "Do you really want\n" - "to quit the program ?" - , FMessageBox::Yes - , FMessageBox::No ); - - if ( ret == FMessageBox::Yes ) - ev->accept(); - else - ev->ignore(); + FApplication::closeConfirmationDialog (this, ev); } //---------------------------------------------------------------------- diff --git a/examples/menu.cpp b/examples/menu.cpp index a33d0010..45392669 100644 --- a/examples/menu.cpp +++ b/examples/menu.cpp @@ -263,16 +263,7 @@ void Menu::adjustSize() //---------------------------------------------------------------------- void Menu::onClose (FCloseEvent* ev) { - int ret = FMessageBox::info ( this, "Quit" - , "Do you really want\n" - "to quit the program ?" - , FMessageBox::Yes - , FMessageBox::No ); - - if ( ret == FMessageBox::Yes ) - ev->accept(); - else - ev->ignore(); + FApplication::closeConfirmationDialog (this, ev); } //---------------------------------------------------------------------- diff --git a/examples/mouse.cpp b/examples/mouse.cpp index 99569957..baeec577 100644 --- a/examples/mouse.cpp +++ b/examples/mouse.cpp @@ -404,16 +404,7 @@ void MouseDraw::onAccel (FAccelEvent* ev) //---------------------------------------------------------------------- void MouseDraw::onClose (FCloseEvent* ev) { - int ret = FMessageBox::info ( this, "Quit" - , "Do you really want\n" - "to quit the program ?" - , FMessageBox::Yes - , FMessageBox::No ); - - if ( ret == FMessageBox::Yes ) - ev->accept(); - else - ev->ignore(); + FApplication::closeConfirmationDialog (this, ev); } //---------------------------------------------------------------------- diff --git a/examples/scrollview.cpp b/examples/scrollview.cpp index 62136e46..7da8bc4d 100644 --- a/examples/scrollview.cpp +++ b/examples/scrollview.cpp @@ -257,16 +257,7 @@ void Scrollviewdemo::cb_quit (FWidget*, data_ptr) //---------------------------------------------------------------------- void Scrollviewdemo::onClose (FCloseEvent* ev) { - int ret = FMessageBox::info ( this, "Quit" - , "Do you really want\n" - "to quit the program ?" - , FMessageBox::Yes - , FMessageBox::No ); - - if ( ret == FMessageBox::Yes ) - ev->accept(); - else - ev->ignore(); + FApplication::closeConfirmationDialog (this, ev); } diff --git a/examples/term-attributes.cpp b/examples/term-attributes.cpp index 2cf0a0eb..0a7f43ae 100644 --- a/examples/term-attributes.cpp +++ b/examples/term-attributes.cpp @@ -126,16 +126,7 @@ void AttribDlg::onWheel (FWheelEvent* ev) //---------------------------------------------------------------------- void AttribDlg::onClose (FCloseEvent* ev) { - int ret = FMessageBox::info ( this, "Quit" - , "Do you really want\n" - "to quit the program ?" - , FMessageBox::Yes - , FMessageBox::No ); - - if ( ret == FMessageBox::Yes ) - ev->accept(); - else - ev->ignore(); + FApplication::closeConfirmationDialog (this, ev); } //---------------------------------------------------------------------- diff --git a/examples/transparent.cpp b/examples/transparent.cpp index 4180f639..9112fca2 100644 --- a/examples/transparent.cpp +++ b/examples/transparent.cpp @@ -251,15 +251,7 @@ void MainWindow::draw() //---------------------------------------------------------------------- void MainWindow::onClose (FCloseEvent* ev) { - int ret = FMessageBox::info ( this, "Quit" - , "Do you really want\n" - "to quit the program ?" - , FMessageBox::Yes - , FMessageBox::No ); - if ( ret == FMessageBox::Yes ) - ev->accept(); - else - ev->ignore(); + FApplication::closeConfirmationDialog (this, ev); } //---------------------------------------------------------------------- diff --git a/examples/treeview.cpp b/examples/treeview.cpp index 35cf406c..219e14f4 100644 --- a/examples/treeview.cpp +++ b/examples/treeview.cpp @@ -304,15 +304,7 @@ void Treeview::adjustSize() //---------------------------------------------------------------------- void Treeview::onClose (FCloseEvent* ev) { - int ret = FMessageBox::info ( this, "Quit" - , "Do you really want\n" - "to quit the program ?" - , FMessageBox::Yes - , FMessageBox::No ); - if ( ret == FMessageBox::Yes ) - ev->accept(); - else - ev->ignore(); + FApplication::closeConfirmationDialog (this, ev); } diff --git a/examples/ui.cpp b/examples/ui.cpp index 85846b92..1b34d14c 100644 --- a/examples/ui.cpp +++ b/examples/ui.cpp @@ -669,15 +669,7 @@ void MyDialog::adjustSize() //---------------------------------------------------------------------- void MyDialog::onClose (FCloseEvent* ev) { - int ret = FMessageBox::info ( this, "Quit" - , "Do you really want\n" - "to quit the program ?" - , FMessageBox::Yes - , FMessageBox::No ); - if ( ret == FMessageBox::Yes ) - ev->accept(); - else - ev->ignore(); + FApplication::closeConfirmationDialog (this, ev); } //---------------------------------------------------------------------- diff --git a/examples/watch.cpp b/examples/watch.cpp index cb5633d7..92badb96 100644 --- a/examples/watch.cpp +++ b/examples/watch.cpp @@ -162,15 +162,7 @@ void Watch::onTimer (FTimerEvent*) //---------------------------------------------------------------------- void Watch::onClose (FCloseEvent* ev) { - int ret = FMessageBox::info ( this, "Quit" - , "Do you really want\n" - "to quit the program ?" - , FMessageBox::Yes - , FMessageBox::No ); - if ( ret == FMessageBox::Yes ) - ev->accept(); - else - ev->ignore(); + FApplication::closeConfirmationDialog (this, ev); } //---------------------------------------------------------------------- diff --git a/examples/windows.cpp b/examples/windows.cpp index a598b680..4fe152a2 100644 --- a/examples/windows.cpp +++ b/examples/windows.cpp @@ -407,18 +407,7 @@ void Window::adjustSize() //---------------------------------------------------------------------- void Window::onClose (FCloseEvent* ev) { - int ret = FMessageBox::info ( this, "Quit" - , "Do you really want\n" - "to quit the program ?" - , FMessageBox::Yes - , FMessageBox::No ); - if ( ret == FMessageBox::Yes ) - { - cb_closeWindows(0,0); - ev->accept(); - } - else - ev->ignore(); + FApplication::closeConfirmationDialog (this, ev); } //---------------------------------------------------------------------- diff --git a/include/final/fapplication.h b/include/final/fapplication.h index 620504e8..21365775 100644 --- a/include/final/fapplication.h +++ b/include/final/fapplication.h @@ -106,6 +106,7 @@ class FApplication : public FWidget static bool eventInQueue(); static bool removeQueuedEvent (const FObject*); static FWidget* showParameterUsage (const int&, char*[]); + static void closeConfirmationDialog (FWidget*, FCloseEvent*); // Callback method void cb_exitApp (FWidget*, data_ptr); diff --git a/src/fapplication.cpp b/src/fapplication.cpp index 65908cc7..86e9fdd6 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -23,6 +23,7 @@ #include "final/fapplication.h" #include "final/fmenu.h" +#include "final/fmessagebox.h" #include "final/fstatusbar.h" #include "final/fwindow.h" @@ -329,12 +330,25 @@ FWidget* FApplication::showParameterUsage (const int& argc, char* argv[]) << " Set the standard vga 8x16 font" << std::endl << " --newfont " << " Enables the graphical font" << std::endl; - std::exit(EXIT_SUCCESS); + std::exit(EXIT_SUCCESS); } return 0; } +//---------------------------------------------------------------------- +void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev) +{ + int ret = FMessageBox::info ( w, "Quit" + , "Do you really want\n" + "to quit the program ?" + , FMessageBox::Yes + , FMessageBox::No ); + if ( ret == FMessageBox::Yes ) + ev->accept(); + else + ev->ignore(); +} // private methods of FApplication //----------------------------------------------------------------------