#include </home/zeitlin/src/wx/github/interface/wx/msgdlg.h>
This class represents a dialog that shows a single or multi-line message, with a choice of OK, Yes, No and Cancel buttons.
This class supports the following styles:
wxCANCEL
. wxOK
or wxYES_NO
. wxCANCEL
with this style as otherwise the message box won't have a close button under wxMSW and the user will be forced to answer it. wxYES_NO
. wxCANCEL
wxNO_DEFAULT
. wxCANCEL_DEFAULT
. wxYES_NO
presence as explained in wxICON_QUESTION
and wxICON_INFORMATION
documentation below. wxICON_ERROR
. wxYES_NO
so it's usually unnecessary to specify it explicitly. This style is not supported for message dialogs under wxMSW when a task dialog is used to implement them (i.e. when running under Windows Vista or later) because Microsoft guidelines indicate that no icon should be used for routine confirmations. If it is specified, no icon will be displayed. wxYES_NO
is not given so it is usually unnecessary to specify it explicitly. クラス | |
class | ButtonLabel |
Helper class allowing to use either stock id or string labels. More... | |
Public Member Functions | |
wxMessageDialog (wxWindow *parent, const wxString &message, const wxString &caption=wxMessageBoxCaptionStr, long style=wxOK|wxCENTRE, const wxPoint &pos=wxDefaultPosition) | |
Constructor specifying the message box properties. | |
virtual void | SetExtendedMessage (const wxString &extendedMessage) |
Sets the extended message for the dialog: this message is usually an extension of the short message specified in the constructor or set with SetMessage(). | |
virtual bool | SetHelpLabel (const ButtonLabel &help) |
Sets the label for the Help button. | |
virtual void | SetMessage (const wxString &message) |
Sets the message shown by the dialog. | |
virtual bool | SetOKCancelLabels (const ButtonLabel &ok, const ButtonLabel &cancel) |
Overrides the default labels of the OK and Cancel buttons. | |
virtual bool | SetOKLabel (const ButtonLabel &ok) |
Overrides the default label of the OK button. | |
virtual bool | SetYesNoCancelLabels (const ButtonLabel &yes, const ButtonLabel &no, const ButtonLabel &cancel) |
Overrides the default labels of the Yes, No and Cancel buttons. | |
virtual bool | SetYesNoLabels (const ButtonLabel &yes, const ButtonLabel &no) |
Overrides the default labels of the Yes and No buttons. | |
virtual int | ShowModal () |
Shows the dialog, returning one of wxID_OK, wxID_CANCEL, wxID_YES, wxID_NO or wxID_HELP. | |
wxString | GetCaption () const |
wxString | GetMessage () const |
wxString | GetExtendedMessage () const |
long | GetMessageDialogStyle () const |
bool | HasCustomLabels () const |
wxString | GetYesLabel () const |
wxString | GetNoLabel () const |
wxString | GetOKLabel () const |
wxString | GetCancelLabel () const |
wxString | GetHelpLabel () const |
long | GetEffectiveIcon () const |
wxMessageDialog::wxMessageDialog | ( | wxWindow * | parent, |
const wxString & | message, | ||
const wxString & | caption = wxMessageBoxCaptionStr , |
||
long | style = wxOK|wxCENTRE , |
||
const wxPoint & | pos = wxDefaultPosition |
||
) |
Constructor specifying the message box properties.
Use ShowModal() to show the dialog.
style may be a bit list of the identifiers described above.
Notice that not all styles are compatible: only one of wxOK
and wxYES_NO
may be specified (and one of them must be specified) and at most one default button style can be used and it is only valid if the corresponding button is shown in the message box.
parent | Parent window. |
message | Message to show in the dialog. |
caption | The dialog title. |
style | Combination of style flags described above. |
pos | Dialog position (ignored under MSW). |
wxString wxMessageDialog::GetCancelLabel | ( | ) | const |
wxString wxMessageDialog::GetCaption | ( | ) | const |
long wxMessageDialog::GetEffectiveIcon | ( | ) | const |
wxString wxMessageDialog::GetExtendedMessage | ( | ) | const |
wxString wxMessageDialog::GetHelpLabel | ( | ) | const |
wxString wxMessageDialog::GetMessage | ( | ) | const |
long wxMessageDialog::GetMessageDialogStyle | ( | ) | const |
wxString wxMessageDialog::GetNoLabel | ( | ) | const |
wxString wxMessageDialog::GetOKLabel | ( | ) | const |
wxString wxMessageDialog::GetYesLabel | ( | ) | const |
bool wxMessageDialog::HasCustomLabels | ( | ) | const |
virtual void wxMessageDialog::SetExtendedMessage | ( | const wxString & | extendedMessage | ) | [virtual] |
Sets the extended message for the dialog: this message is usually an extension of the short message specified in the constructor or set with SetMessage().
If it is set, the main message appears highlighted -- if supported -- and this message appears beneath it in normal font. On the platforms which don't support extended messages, it is simply appended to the normal message with an empty line separating them.
virtual bool wxMessageDialog::SetHelpLabel | ( | const ButtonLabel & | help | ) | [virtual] |
Sets the label for the Help button.
Please see the remarks in SetYesNoLabels() documentation.
Notice that changing the label of the help button resets its special status (if any, this depends on the platform) and it will be treated just like another button in this case.
virtual void wxMessageDialog::SetMessage | ( | const wxString & | message | ) | [virtual] |
Sets the message shown by the dialog.
virtual bool wxMessageDialog::SetOKCancelLabels | ( | const ButtonLabel & | ok, |
const ButtonLabel & | cancel | ||
) | [virtual] |
Overrides the default labels of the OK and Cancel buttons.
Please see the remarks in SetYesNoLabels() documentation.
virtual bool wxMessageDialog::SetOKLabel | ( | const ButtonLabel & | ok | ) | [virtual] |
Overrides the default label of the OK button.
Please see the remarks in SetYesNoLabels() documentation.
virtual bool wxMessageDialog::SetYesNoCancelLabels | ( | const ButtonLabel & | yes, |
const ButtonLabel & | no, | ||
const ButtonLabel & | cancel | ||
) | [virtual] |
Overrides the default labels of the Yes, No and Cancel buttons.
Please see the remarks in SetYesNoLabels() documentation.
virtual bool wxMessageDialog::SetYesNoLabels | ( | const ButtonLabel & | yes, |
const ButtonLabel & | no | ||
) | [virtual] |
Overrides the default labels of the Yes and No buttons.
The arguments of this function can be either strings or one of the standard identifiers, such as wxID_APPLY
or wxID_OPEN
. Notice that even if the label is specified as an identifier, the return value of the dialog ShowModal() method still remains one of wxID_OK
, wxID_CANCEL
, wxID_YES
or wxID_NO
values, i.e. this identifier changes only the label appearance but not the return code generated by the button. It is possible to mix stock identifiers and string labels in the same function call, for example:
wxMessageDialog dlg(...); dlg.SetYesNoLabels(wxID_SAVE, _("&Don't save"));
Also notice that this function is not currently available on all platforms (although as of wxWidgets 2.9.0 it is implemented in all major ports), so it may return false to indicate that the labels couldn't be changed. If it returns true, the labels were set successfully.
Typically, if the function was used successfully, the main dialog message may need to be changed, e.g.:
wxMessageDialog dlg(...); if ( dlg.SetYesNoLabels(_("&Quit"), _("&Don't quit")) ) dlg.SetMessage(_("What do you want to do?")); else // buttons have standard "Yes"/"No" values, so rephrase the question dlg.SetMessage(_("Do you really want to quit?"));
virtual int wxMessageDialog::ShowModal | ( | ) | [virtual] |
Shows the dialog, returning one of wxID_OK, wxID_CANCEL, wxID_YES, wxID_NO or wxID_HELP.
Notice that this method returns the identifier of the button which was clicked unlike wxMessageBox() function.
Reimplemented from wxDialog.