VModalDialog

Used to show modal dialogs.

Synopsis

 * Header:
 * 


 * Class name:
 * vModalDialog


 * Hierarchy:
 * (vBaseWindow,vCmdParent) ->vDialog ->vModalDialog


 * Contains:
 * CommandObject

Description
This class is an implementation of a modal dialog. This means that the dialog grabs control, and waits for the user to select an appropriate command from the dialog. You can use any of the methods defined by the vDialog class, as well as the new ShowModalDialog method.

vModalDialog(vApp* parent, char* title)
There are two versions of the constructor, one for constructing dialogs from windows, the other from the vApp object. See the description of the vDialog constructor for more details.

The default value for the title is an empty string, so you can declare instances of modal dialogs without the title string if you wish. The dialog title will always show in Windows, but in X is dependent on how the window manager treats decorations on transient windows.

virtual ItemVal ShowModalDialog(char* message, ItemVal& retval)
This method displays the dialog, and does not return until the modal dialog is closed. It returns the id of the button that caused the return, and in retval, the value of the button causing the return as defined in the dialog declaration.

Please see the description of DialogDisplayed for an important discussion of setting dialog control values.

There are a couple of ways to close a modal dialog and make ShowModalDialog return, all controlled by the DialogCommand</tt> method. The default DialogCommand</tt> will close the modal dialog automatically when the user clicks the M_Cancel</tt>, M_Done</tt>, or M_OK</tt> buttons.

All command actions are still passed to the virtual DialogCommand</tt> method, which is usually overridden in the derived class. By first calling vModalDialog::DialogCommand</tt> to handle the default operation, and then checking for the other buttons that should close the dialog, you can also close the dialog by calling the CloseDialog</tt> method, which will cause the return.

The following code demonstrates this. void myModal::DialogCommand(ItemVal id, ItemVal val,        CmdType ctype) {        // Call the parent for default processing vModalDialog::DialogCommand(id,val,ctype); if (id == M_Yes || id == M_No) // These close, too. CloseDialog; }

virtual void DialogCommand(ItemVal Id, ItemVal val, CmdType type)
Adds a little functionality for handling this modally.