richmsgdlg.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/richmsgdlg.h
  3. // Purpose: interface of wxRichMessageDialog
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxRichMessageDialog
  9. Extension of wxMessageDialog with additional functionality.
  10. This class adds the possibility of using a checkbox (that is especially
  11. useful for implementing the "Don't ask me again" kind of dialogs) and an
  12. extra explanatory text which is initially collapsed and not shown to the
  13. user but can be expanded to show more information.
  14. Notice that currently the native dialog is used only under MSW when using
  15. Vista or later Windows version. Elsewhere, or for older versions of
  16. Windows, a generic implementation which is less familiar to the users is
  17. used. Because of this it's recommended to use this class only if you do
  18. need its extra functionality and use wxMessageDialog which does have native
  19. implementation under all platforms otherwise. However if you do need to put
  20. e.g. a checkbox in a dialog, you should definitely consider using this
  21. class instead of using your own custom dialog because it will have much
  22. better appearance at least under recent Windows versions.
  23. To use this class, you need to create the dialog object and call
  24. ShowCheckBox() and/or ShowDetailedText() to configure its contents.
  25. Other than that, it is used in exactly the same way as wxMessageDialog and
  26. supports all the styles supported by it. In particular, ShowModal() return
  27. value is the same as for wxMessageDialog. The only difference is that you
  28. need to use IsCheckBoxChecked() to examine the checkbox value if you had
  29. called ShowCheckBox().
  30. Here is a simple example:
  31. @code
  32. void MyFrame::ShowDialog()
  33. {
  34. if ( ... shouldn't show this dialog again ... )
  35. return;
  36. wxRichMessageDialog dlg(this, "Welcome to my wonderful program!");
  37. dlg.ShowCheckBox("Don't show welcome dialog again");
  38. dlg.ShowModal(); // return value ignored as we have "Ok" only anyhow
  39. if ( dlg.IsCheckBoxChecked() )
  40. ... make sure we won't show it again the next time ...
  41. }
  42. @endcode
  43. @since 2.9.2
  44. @library{wxcore}
  45. @category{cmndlg}
  46. @see @ref overview_cmndlg_msg
  47. */
  48. class wxRichMessageDialog : public wxRichMessageDialogBase
  49. {
  50. public:
  51. /**
  52. Constructor specifying the rich message dialog properties.
  53. Works just like the constructor for wxMessageDialog.
  54. */
  55. wxRichMessageDialog(wxWindow* parent,
  56. const wxString& message,
  57. const wxString& caption = wxMessageBoxCaptionStr,
  58. long style = wxOK | wxCENTRE);
  59. /**
  60. Shows a checkbox with a given label or hides it.
  61. @param checkBoxText
  62. If the parameter is non-empty a checkbox will be shown with that
  63. label, otherwise it will be hidden.
  64. @param checked
  65. The initial state of the checkbox.
  66. */
  67. void ShowCheckBox(const wxString& checkBoxText, bool checked = false);
  68. /**
  69. Retrieves the label for the checkbox.
  70. @return
  71. The label for the checkbox, will be the empty string if no
  72. checkbox is used.
  73. */
  74. wxString GetCheckBoxText() const;
  75. /**
  76. Shows or hides a detailed text and an expander that is used to
  77. show or hide the detailed text.
  78. @param detailedText
  79. The detailed text that can be expanded when the dialog is shown,
  80. if empty no detailed text will be used.
  81. */
  82. void ShowDetailedText(const wxString& detailedText);
  83. /**
  84. Retrieves the detailed text.
  85. @return
  86. The detailed text or empty if detailed text is not used.
  87. */
  88. wxString GetDetailedText() const;
  89. /**
  90. Retrieves the state of the checkbox.
  91. If this method is called before showing the dialog, the initial value
  92. of the checkbox, as set by ShowCheckBox() is used. If it is called
  93. after calling wxDialog::ShowModal(), the value set by the user is
  94. returned.
  95. @return @true if the checkbox is checked or @false if not.
  96. */
  97. bool IsCheckBoxChecked() const;
  98. /**
  99. Shows the dialog, returning one of wxID_OK, wxID_CANCEL, wxID_YES, wxID_NO.
  100. IsCheckBoxChecked() can be called afterwards to retrieve the value of the
  101. check box if one was used.
  102. */
  103. virtual int ShowModal();
  104. };