printdialog.C
gives another example of using global
singleton pointers.
class my_appObj : virtual public x::obj { public: // ... }; typedef x::singletonptr<my_appObj> my_app; // .............. x::ptr<my_appObj> app_ptr; auto main_window=x::w::main_window::create( [] (const auto &main_window) { // ... app_ptr=x::ref<my_appObj>::create(main_window); }); my_app app{app_ptr};
printdialog.C
uses a global singleton
pointer object for:
The main application window itself.
The main window's dialogs.
The name of the file selected by the “file open” dialog. The file to print gets selected from this dialog and saved in the application object, then the print dialog opens. If the print dialog is not get cancelled, if the dialog's “Print” button gets selected, the name of the previously selected file is retrieved, and printed.