Dialogs are used to show information and to give a possibility to enter new information.
Encapsulate all dialog handling
All Dialogs are derived from Simple_Dialog or Data_Source_Dialog, depending on the need of a Data_Source providing dialog. All Dialogs are created using a factory which sets some last parameters (e.g. for error dialogs the message, if everything else is the same).
The factory creates a dialog by instantiating it with Create, then calling Build. The dialog itself is shown with Show_Modal. This is done like that, so that additional parameters in the dialog can be set after the widgets are created, but before the dialog layout is done in Build.
A Data_Source_Dialog is shown automatically, when there is a Get call to it's Data_Source. The Data_Source given with Link_Data_Source has to be Valid and not Complete, otherwise the dialog is skipped. This is used to cascade Data_Sources: if one of them is canceled by the user or due to an error, valid is set to false and all following Data_Sources are skipped. The command that requested the Pot from this Data_Source will notice that and probably cancel itself. Setting complete to true is done when all informations are already present. This is important for dialogs that change informations that are already set in the linked Data_Source (i.e. a file dialog lets the user change the last filename; but if the filename is given on the command line, complete is set to true and the dialog will be skipped).
For simplifying the event handling - every event handler is in the class which created the widget - an additional level of callbacks is provided. This is especially useful for using Button_Boxes. Every Dialog is a descendant of Handler_Target and has to provide implementations for Can_Execute and Event. They are called by the event handler of every widget in the dialog to check, if an action can be done and to do it. These calls are stacked, so the handling for every widget can be done in the class that created it.
Every Dialog has an associated Button_Box, which provides a bar of buttons with icons.
For every needed Button_Box there should be a method in the Button_Box_Factory who creates a new box and adds the needed buttons to it. Every button that is added with Add_Button has a Link property, which is needed to identify the button in the handler.
The Button_Box has a Handler_Target property which has to be set (e.g. to a dialog). The Handler_Target's Event method is called every time a button is clicked with the link string that is set in the button.
By calling Update_Sensitivity, the Button_Box asks the Target_Handler for every button, if the action with the associated link string can be executed and updates the button's sensitivity accordingly. Therefore, Can_Execute should return fast, because Update_Sensitivity can be called for every widget changed (e.g. typing a text in an entry widget).
The Button_Box_Factory contains some default buttons with a default icon.
The factory's Window property has to be set to a window prior to adding buttons. It is needed for creating the transparent pixmaps correct.
Every dialog (and some masters) is created with the help of a Layout_Factory. Dialogs use Create_Dialog_Layout to create the needed look, including a pixmap.
The Pixmap_Dialog is a classic dialog with buttons at bottom, a pixmap at left. Since we need that also with and without Data_Source, we have to duplicate it here.
For every dialog class, there is a factory that creates the dialog and does some final settings.