Dialog boxes are a standard way of requesting more information from the user in order to proceed with an operation. Typically, dialog boxes are modal -- that is, the operation cannot be continued until the dialog is dismissed from the screen. Whenever an application requires additional information from the user before carrying out a particular command or task, you should provide a dialog to gather information.
For general purposes, you can create your own custom dialog boxes using frames: the class <dialog-frame> is provided as a straightforward way of designing frames specifically for use as dialogs. See Section 7.5 on page 123 for an introduction to frames.
For commonly used dialog boxes, DUIM provides you with a number of convenience functions that let you use predefined dialogs in your applications without having to design each one specifically. These convenience functions use pre-built dialog interfaces supplied by the system wherever possible,. This not only makes them more efficient, it also guarantees that the dialogs have the correct look and feel for the system for which you are developing.
Many systems, for example, provide pre-built interfaces for the Open, Save As, Font, and similar dialog boxes. By using the functions described in this section, you can guarantee that your application uses the dialog boxes supplied by the system wherever they are available.
The most commonly used convenience function is notify-user, which you have already seen. This function provides you with a straightforward way of displaying an alert message on screen in whatever format is standard for the target operating system.
contain(make(<push-button>,
label: "Press me!",
activate-callback:
method (gadget)
notify-user
(format-to-string ("You pressed me!"))
end));
The example above creates a push button which, when pressed, calls notify-user to display message.
The common Open File and Save File As dialogs can both be generated using choose-file. The direction: keyword lets you specify a direction that distinguishes between the two types of dialog: thus, if the direction is #"input", a file is opened, and if the direction is #"output" a file is saved.
choose-file(title: "Open File", direction: #"input"); choose-file(title: "Save File As", direction: #"input");
Note that DUIM provides default titles based on the specified direction, so you need only specify these titles if you want to supply a non-standard title to the dialog.
Further examples of this function can be found in Section 5.3.1 on page 48.
The convenience functions choose-color and choose-text-style generate the common dialogs for choosing a color and a font respectively. Use choose-color when you need to ask the user to choose a color from the standard color palette available on the target operating system, and use choose-text-style when you want the user to choose the font, style, and size for a piece of text.
Several other convenience dialogs are provided by DUIM. The following is a complete list, together with a brief description of each. For more information on these dialogs, please refer to the DUIM Reference Manual.
choose-color -- Choose a system color.
choose-directory -- Choose a directory on disk.
choose-file -- Choose an input or output file.
choose-from-dialog -- Choose from a list presented in a dialog.
choose-from-menu -- Choose from a list presented in a popup menu
choose-text-style -- Choose a font.
notify-user -- Provide various kinds of notification to the user.
There are a number of standard dialogs provided by Windows that are not listed above. If you wish to use any of them, you must either use the Win32 control directly, or you must emulate the dialog yourself by building it using DUIM classes.