Restructure wxNotificationMessage.

wxNotificationMessage has been refactored to always use wxNotificationMessageImpl (this was previously already done in the MSW implementation)

This adds various features and fixes to wxNotificationMessage:
- OS X Notification Center implementation
- Generic "toast" notifications
- SetIcon() to specify a custom icon
- AddAction() to add actions to notifications
- Events to get notify of notification clicks, dismiss or actions
This commit is contained in:
Tobias Taschner
2015-09-09 22:59:21 +02:00
parent 39716462e6
commit bf5e403a68
31 changed files with 1999 additions and 817 deletions

View File

@@ -10,12 +10,36 @@
This class allows to show the user a message non intrusively.
Currently it is implemented natively for Windows and GTK and uses
(non-modal) dialogs for the display of the notifications under the other
platforms.
Currently it is implemented natively for Windows, OS X, GTK and uses
generic toast notifications under the other platforms. It's not recommended
but @c wxGenericNotificationMessage can be used instead of the native ones.
This might make sense if your application requires features not available in
the native implementation.
Notice that this class is not a window and so doesn't derive from wxWindow.
@section platform_notes Platform Notes
@par OS X
The OS X implementation uses Notification Center to display native notifications.
In order to use actions your notifications must use the alert style. This can
be enabled by the user in system settings or by setting the
@c NSUserNotificationAlertStyle value in Info.plist to @c alert. Please note
that the user always has the option to change the notification style.
@beginEventEmissionTable{wxCommandEvent}
@event{EVT_NOTIFICATION_MESSAGE_CLICK(id, func)}
Process a @c EVT_NOTIFICATION_MESSAGE_CLICK event, when a notification
is clicked.
@event{wxEVT_NOTIFICATION_MESSAGE_DISMISSED(id, func)}
Process a @c wxEVT_NOTIFICATION_MESSAGE_DISMISSED event, when a notification
is dismissed by the user or times out.
@event{wxEVT_NOTIFICATION_MESSAGE_ACTION(id, func)}
Process a @c wxEVT_NOTIFICATION_MESSAGE_ACTION event, when the user
selects on of the actions added by AddAction()
@endEventTable
@since 2.9.0
@library{wxadv}
@category{misc}
@@ -53,6 +77,17 @@ public:
*/
virtual ~wxNotificationMessage();
/**
Add an action to the notification. If supported by the implementation
this are usually buttons in the notification selectable by the user.
@return @false if the current implementation or OS version
does not support actions in notifications.
@since 3.1.0
*/
bool AddAction(wxWindowID actionid, const wxString &label = wxString());
/**
Hides the notification.
@@ -69,9 +104,22 @@ public:
Valid values are @c wxICON_INFORMATION, @c wxICON_WARNING and
@c wxICON_ERROR (notice that @c wxICON_QUESTION is not allowed here).
Some implementations of this class may not support the icons.
@see SetIcon()
*/
void SetFlags(int flags);
/**
Specify a custom icon to be displayed in the notification.
Some implementations of this class may not support custom icons.
@see SetFlags()
@since 3.1.0
*/
void SetIcon(const wxIcon& icon);
/**
Set the main text of the notification.