notifmsg.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: notifmsg.h
  3. // Purpose: interface of wxNotificationMessage
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxNotificationMessage
  9. This class allows to show the user a message non intrusively.
  10. Currently it is implemented natively for Windows and GTK and uses
  11. (non-modal) dialogs for the display of the notifications under the other
  12. platforms.
  13. Notice that this class is not a window and so doesn't derive from wxWindow.
  14. @library{wxadv}
  15. @category{misc}
  16. */
  17. class wxNotificationMessage : public wxEvtHandler
  18. {
  19. public:
  20. /// Possible values for Show() timeout.
  21. enum
  22. {
  23. Timeout_Auto = -1, ///< Notification will be hidden automatically.
  24. Timeout_Never = 0 ///< Notification will never time out.
  25. };
  26. /**
  27. Default constructor, use SetParent(), SetTitle() and SetMessage() to
  28. initialize the object before showing it.
  29. */
  30. wxNotificationMessage();
  31. /**
  32. Create a notification object with the given attributes.
  33. See SetTitle(), SetMessage(), SetParent() and SetFlags() for the
  34. description of the corresponding parameters.
  35. */
  36. wxNotificationMessage(const wxString& title, const wxString& message = wxEmptyString,
  37. wxWindow* parent = NULL, int flags = wxICON_INFORMATION);
  38. /**
  39. Destructor does not hide the notification.
  40. The notification can continue to be shown even after the C++ object was
  41. destroyed, call Close() explicitly if it needs to be hidden.
  42. */
  43. virtual ~wxNotificationMessage();
  44. /**
  45. Hides the notification.
  46. Returns @true if it was hidden or @false if it couldn't be done
  47. (e.g. on some systems automatically hidden notifications can't be
  48. hidden manually).
  49. */
  50. virtual bool Close();
  51. /**
  52. This parameter can be currently used to specify the icon to show in the
  53. notification.
  54. Valid values are @c wxICON_INFORMATION, @c wxICON_WARNING and
  55. @c wxICON_ERROR (notice that @c wxICON_QUESTION is not allowed here).
  56. Some implementations of this class may not support the icons.
  57. */
  58. void SetFlags(int flags);
  59. /**
  60. Set the main text of the notification.
  61. This should be a more detailed description than the title but still limited
  62. to reasonable length (not more than 256 characters).
  63. */
  64. void SetMessage(const wxString& message);
  65. /**
  66. Set the parent for this notification: the notification will be associated with
  67. the top level parent of this window or, if this method is not called, with the
  68. main application window by default.
  69. */
  70. void SetParent(wxWindow* parent);
  71. /**
  72. Set the title, it must be a concise string (not more than 64 characters), use
  73. SetMessage() to give the user more details.
  74. */
  75. void SetTitle(const wxString& title);
  76. /**
  77. Show the notification to the user and hides it after @a timeout seconds
  78. are elapsed.
  79. Special values @c Timeout_Auto and @c Timeout_Never can be used here,
  80. notice that you shouldn't rely on @a timeout being exactly respected
  81. because the current platform may only support default timeout value
  82. and also because the user may be able to close the notification.
  83. @note When using native notifications in wxGTK, the timeout is ignored
  84. for the notifications with @c wxICON_WARNING or @c wxICON_ERROR
  85. flags, they always remain shown unless they're explicitly hidden by
  86. the user, i.e. behave as if Timeout_Auto were given.
  87. @return @false if an error occurred.
  88. */
  89. virtual bool Show(int timeout = Timeout_Auto);
  90. };