VModalDialog: Difference between revisions
Appearance
mNo edit summary |
mNo edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 2: | Line 2: | ||
==Synopsis== | ==Synopsis== | ||
; | ;Header: <tt><v/vmodald.h></tt> | ||
: <tt><v/vmodald.h></tt> | ;Class name: vModalDialog | ||
; | ;Hierarchy: (vBaseWindow,vCmdParent) ->vDialog ->vModalDialog | ||
: vModalDialog | ;Contains: CommandObject | ||
; | |||
: (vBaseWindow,vCmdParent) ->vDialog ->vModalDialog | |||
; | |||
: CommandObject | |||
==Description== | ==Description== | ||
Line 15: | Line 11: | ||
==Constructor== | ==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 <tt>vDialog</tt> 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. | |||
There are two versions of the constructor, one for constructing dialogs from windows, the other from the vApp object. See the description of the <tt>vDialog</tt> 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== | ==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 <tt>retval</tt>, the value of the button causing the return as defined in the dialog declaration. | |||
:Please see the description of <tt>DialogDisplayed</tt> for an important discussion of setting dialog control values. | |||
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 <tt>retval</tt>, the value of the button causing the return as defined in the dialog declaration. | :There are a couple of ways to close a modal dialog and make <tt>ShowModalDialog</tt> return, all controlled by the <tt>DialogCommand</tt> method. The default <tt>DialogCommand</tt> will close the modal dialog automatically when the user clicks the <tt>M_Cancel</tt>, <tt>M_Done</tt>, or <tt>M_OK</tt> buttons. | ||
:All command actions are still passed to the virtual <tt>DialogCommand</tt> method, which is usually overridden in the derived class. By first calling <tt>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 <tt>CloseDialog</tt> method, which will cause the return. | |||
Please see the description of <tt>DialogDisplayed</tt> for an important discussion of setting dialog control values. | |||
There are a couple of ways to close a modal dialog and make <tt>ShowModalDialog</tt> return, all controlled by the <tt>DialogCommand</tt> method. The default <tt>DialogCommand</tt> will close the modal dialog automatically when the user clicks the <tt>M_Cancel</tt>, <tt>M_Done</tt>, or <tt>M_OK</tt> buttons. | |||
All command actions are still passed to the virtual <tt>DialogCommand</tt> method, which is usually overridden in the derived class. By first calling <tt>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 <tt>CloseDialog</tt> method, which will cause the return. | |||
The following code demonstrates this. | The following code demonstrates this. | ||
Line 45: | Line 32: | ||
==Derived Methods== | ==Derived Methods== | ||
;virtual void DialogCommand(ItemVal Id, ItemVal val, CmdType type):Adds a little functionality for handling this modally. | |||
Adds a little functionality for handling this modally. | |||
==Inherited Methods== | ==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== | ==See Also== |
Latest revision as of 22:27, 9 April 2020
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