changeset 2089:bcc7877dcdac

Win: Add the required wintoast.cpp glue and undo a test change that did not help with the flicker on embedded Edge widgets.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 05 Jun 2020 16:49:31 +0000
parents 94ea915bd917
children cdb94c6fd611
files win/dw.c win/wintoast.cpp
diffstat 2 files changed, 92 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/win/dw.c	Fri Jun 05 16:27:00 2020 +0000
+++ b/win/dw.c	Fri Jun 05 16:49:31 2020 +0000
@@ -4425,7 +4425,7 @@
    if (_DW_EDGE_DETECTED = _dw_edge_detect())
    {
       wc.lpfnWndProc = (WNDPROC)_edgeWindowProc;
-      //wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
+      wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    }
    else
 #endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/win/wintoast.cpp	Fri Jun 05 16:49:31 2020 +0000
@@ -0,0 +1,91 @@
+/* Simple WinToast forwarder from Dynamic Windows APIs */
+
+#include "wintoastlib.h"
+
+using namespace WinToastLib;
+
+class DWHandler : public IWinToastHandler {
+public:
+    void toastActivated() const {
+        // The user clicked in this toast
+    }
+
+    void toastActivated(int actionIndex) const {
+        // The user clicked on action
+    }
+
+    void toastDismissed(WinToastDismissalReason state) const {
+        switch (state) {
+        case UserCanceled:
+            // The user dismissed this toast"
+            break;
+        case TimedOut:
+            // The toast has timed out
+            break;
+        case ApplicationHidden:
+            // The application hid the toast using ToastNotifier.hide()
+            break;
+        default:
+            // Toast not activated
+            break;
+        }
+    }
+
+    void toastFailed() const {
+        // Error showing current toast
+    }
+};
+
+
+enum Results {
+	ToastClicked,					// user clicked on the toast
+	ToastDismissed,					// user dismissed the toast
+	ToastTimeOut,					// toast timed out
+	ToastHided,						// application hid the toast
+	ToastNotActivated,				// toast was not activated
+	ToastFailed,					// toast failed
+	SystemNotSupported,				// system does not support toasts
+	UnhandledOption,				// unhandled option
+	MultipleTextNotSupported,		// multiple texts were provided
+	InitializationFailure,			// toast notification manager initialization failure
+	ToastNotLaunched				// toast could not be launched
+};
+
+extern "C" {
+   
+   void _dw_toast_init(LPWSTR AppName, LPWSTR AppID)
+   {
+      if(WinToast::isCompatible()) 
+      {
+         WinToast::instance()->setAppName(AppName);
+         WinToast::instance()->setAppUserModelId(AppID);
+         WinToast::instance()->initialize();
+      }
+   }
+
+   void *_dw_notification_new(LPWSTR title, LPWSTR image, LPWSTR description)
+   {
+      if(WinToast::isCompatible()) 
+      {
+         WinToastTemplate *templ = new WinToastTemplate(image ? WinToastTemplate::ImageAndText02 : WinToastTemplate::Text02);
+         templ->setTextField(title, WinToastTemplate::FirstLine);
+         templ->setAttributionText(description);
+         if(image)
+            templ->setImagePath(image);
+         return (void *)templ;
+      }
+      return NULL;
+   }
+
+   int _dw_notification_send(void *notification)
+   {
+      if(WinToast::isCompatible()) 
+      {
+         WinToastTemplate *templ = (WinToastTemplate *)notification;
+         
+         if(templ && WinToast::instance()->showToast(*templ, new DWHandler()) >= 0)
+            return 0; // DW_ERROR_NONE
+      }
+      return -1; // DW_ERROR_UNKNOWN
+   }
+}