VModalDialog: Difference between revisions
mNo edit summary |
m Ak120 moved page The V C++ GUI Framework:vModalDialog to VModalDialog |
(No difference)
|
Revision as of 20:47, 7 December 2019
Used to show modal dialogs.
Synopsis
- Header:
- <v/vmodald.h>
- 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.
Constructor
vModalDialog(vBaseWindow* parent, char* title)
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.
New Methods
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 method. The default DialogCommand will close the modal dialog automatically when the user clicks the M_Cancel, M_Done, or M_OK buttons.
All command actions are still passed to the virtual DialogCommand method, which is usually overridden in the derived class. By first calling vModalDialog::DialogCommand 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 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(); }
Derived Methods
virtual void DialogCommand(ItemVal Id, ItemVal val, CmdType type)
Adds a little functionality for handling this modally.
Inherited Methods
vDialog(vBaseWindow* parent)
vDialog(vBaseWindow* parent, int modalflag)
vDialog(vApp* parent)
vDialog(vApp* parent, int modalflag)
void vDialog::AddDialogCmds(CommandObject* cList)
virtual void CancelDialog()
virtual void CloseDialog()
virtual int GetTextIn(ItemVal Id, char* str, int maxlen)
virtual int GetValue(ItemVal Id)
virtual void SetValue(ItemVal Id, ItemVal val, ItemSetType type)
virtual void SetString(ItemVal Id, char* str)
virtual void ShowDialog(char* message)
See Also
vDialog