changeset 102:76331c5ba1ac

Added new functions introduced since 3.0... need to implement new callbacks. Also need to add the new tests to the dwtest and dwootest programs.
author Brian Smith <brian@dbsoft.org>
date Mon, 08 Nov 2021 17:18:57 -0600
parents 22ce98fcafa1
children 59f9c8888e0a
files dw/dw.go dw/dwglue.c
diffstat 2 files changed, 208 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/dw/dw.go	Sat Nov 06 23:20:38 2021 -0500
+++ b/dw/dw.go	Mon Nov 08 17:18:57 2021 -0600
@@ -99,6 +99,9 @@
 type HSPLITBAR struct {
 	hwnd C.uintptr_t
 }
+type HNOTIFICATION struct {
+	hwnd C.uintptr_t
+}
 type HTREEITEM struct {
 	htreeitem C.uintptr_t
 	htree     HANDLE
@@ -254,6 +257,12 @@
 var HTML_STOP = C.DW_HTML_STOP
 var HTML_PRINT = C.DW_HTML_PRINT
 
+/* Embedded HTML notifcations */
+var HTML_CHANGE_STARTED = C.DW_HTML_CHANGE_STARTED
+var HTML_CHANGE_REDIRECT = C.DW_HTML_CHANGE_REDIRECT
+var HTML_CHANGE_LOADING = C.DW_HTML_CHANGE_LOADING
+var HTML_CHANGE_COMPLETE = C.DW_HTML_CHANGE_COMPLETE
+
 /* Drawing flags  */
 var DRAW_DEFAULT = C.DW_DRAW_DEFAULT
 var DRAW_FILL = C.DW_DRAW_FILL
@@ -329,6 +338,11 @@
 var CRA_SELECTED uint = C.DW_CRA_SELECTED
 var CRA_CUROSRED uint = C.DW_CRA_CURSORED
 
+/* MLE Auto Complete States */
+var MLE_COMPLETE_TEXT = int(C.DW_MLE_COMPLETE_TEXT)
+var MLE_COMPLETE_DASH = int(C.DW_MLE_COMPLETE_DASH)
+var MLE_COMPLETE_QUITE = int(C.DW_MLE_COMPLETE_QUOTE)
+
 /* Mouse buttons */
 var BUTTON1_MASK = C.DW_BUTTON1_MASK
 var BUTTON2_MASK = C.DW_BUTTON2_MASK
@@ -415,6 +429,28 @@
 var VK_LCONTROL = int(C.VK_LCONTROL)
 var VK_RCONTROL = int(C.VK_RCONTROL)
 
+/* Feature constants */
+var FEATURE_UNSUPPORTED = int(C.DW_FEATURE_UNSUPPORTED)
+var FEATURE_ENABLED = int(C.DW_FEATURE_ENABLED)
+var FEATURE_DISABLED = int(C.DW_FEATURE_DISABLED)
+
+var FEATURE_HTML = int(C.DW_FEATURE_HTML)
+var FEATURE_HTML_RESULT = int(C.DW_FEATURE_HTML_RESULT)
+var FEATURE_WINDOW_BORDER = int(C.DW_FEATURE_WINDOW_BORDER)
+var FEATURE_WINDOW_TRANSPARENCY = int(C.DW_FEATURE_WINDOW_TRANSPARENCY)
+var FEATURE_DARK_MODE = int(C.DW_FEATURE_DARK_MODE)
+var FEATURE_MLE_AUTO_COMPLETE = int(C.DW_FEATURE_MLE_AUTO_COMPLETE)
+var FEATURE_MLE_WORD_WRAP = int(C.DW_FEATURE_MLE_WORD_WRAP)
+var FEATURE_CONTAINER_STRIPE = int(C.DW_FEATURE_CONTAINER_STRIPE)
+var FEATURE_MDI = int(C.DW_FEATURE_MDI)
+var FEATURE_NOTEBOOK_STATUS_TEXT = int(C.DW_FEATURE_NOTEBOOK_STATUS_TEXT)
+var FEATURE_NOTIFICATION = int(C.DW_FEATURE_NOTIFICATION)
+var FEATURE_UTF8_UNICODE = int(C.DW_FEATURE_UTF8_UNICODE)
+var FEATURE_MLE_RICH_EDIT = int(C.DW_FEATURE_MLE_RICH_EDIT)
+var FEATURE_TASK_BAR = int(C.DW_FEATURE_TASK_BAR)
+var FEATURE_TREE = int(C.DW_FEATURE_TREE)
+var FEATURE_WINDOW_PLACEMENT = int(C.DW_FEATURE_WINDOW_PLACEMENT)
+
 // Convert a resource ID into a pointer
 func RESOURCE(id uintptr) unsafe.Pointer {
 	return unsafe.Pointer(id)
@@ -853,6 +889,14 @@
 	return 0
 }
 
+func (notification HNOTIFICATION) GetHandle() C.uintptr_t {
+	return notification.hwnd
+}
+
+func (notification HNOTIFICATION) GetType() C.uint {
+	return 0
+}
+
 // Initializes the Dynamic Windows engine.
 func Init(newthread int) int {
 	if len(os.Args) > 0 {
@@ -886,6 +930,51 @@
 	C.dw_shutdown()
 }
 
+// Gets the path to the application
+func App_dir() string {
+	cappdir := C.go_app_dir()
+	return C.GoString(cappdir)
+}
+
+// Gets the path to the application
+func AppDir() string {
+	return App_dir()
+}
+
+// Sets the application ID and name
+func App_id_set(appid string, appname string) int {
+	cappid := C.CString(appid)
+	defer C.free(unsafe.Pointer(cappid))
+	cappname := C.CString(appname)
+	defer C.free(unsafe.Pointer(cappname))
+	return int(C.go_app_id_set(cappid, cappname))
+}
+
+// Sets the application ID and name
+func AppIdSet(appid string, appname string) int {
+	return App_id_set(appid, appname)
+}
+
+// Gets the status of a feature on the current platform
+func Feature_get(feature int) int {
+	return int(C.go_feature_get(C.int(feature)))
+}
+
+// Gets the status of a feature on the current platform
+func FeatureGet(feature int) int {
+	return Feature_get(feature)
+}
+
+// Sets the status of a feature on the current platform
+func Feature_set(feature int, status int) int {
+	return int(C.go_feature_set(C.int(feature), C.int(status)))
+}
+
+// Sets the status of a feature on the current platform
+func FeatureSet(feature int, status int) int {
+	return Feature_set(feature, status)
+}
+
 // Returns some information about the current operating environment.
 func Environment_query(env *Env) {
 	var cenv C.DWEnv
@@ -1153,6 +1242,11 @@
 	C.go_window_redraw(handle.GetHandle())
 }
 
+// Check if two window handles are the same window
+func Window_compare(handle1 HANDLE, handle2 HANDLE) int {
+	return int(C.go_window_compare(handle1.GetHandle(), handle2.GetHandle()))
+}
+
 // Causes entire window to be invalidated and redrawn.
 func (window HWND) Redraw() {
 	Window_redraw(window)
@@ -3406,6 +3500,16 @@
 	return Render_new(id)
 }
 
+// Causes an expose event to trigger for the render widget
+func Render_redraw(handle HANDLE) {
+	C.go_render_redraw(handle.GetHandle())
+}
+
+// Causes an expose event to trigger for the render widget
+func (handle HRENDER) Redraw() {
+	Render_redraw(handle)
+}
+
 // Allows the user to choose a font using the system's font chooser dialog.
 func Font_choose(currfont string) string {
 	ccurrfont := C.CString(currfont)
@@ -3900,6 +4004,19 @@
 	return Html_url(handle, url)
 }
 
+// Run javascript code in the embedded HTML widget
+func Html_javascript_run(handle HANDLE, script string, data POINTER) int {
+	cscript := C.CString(script)
+	defer C.free(unsafe.Pointer(cscript))
+
+	return int(C.go_html_javascript_run(handle.GetHandle(), cscript, unsafe.Pointer(data)))
+}
+
+// Run javascript code in the embedded HTML widget
+func (handle HHTML) JavascriptRun(script string, data POINTER) int {
+	return Html_javascript_run(handle, script, data)
+}
+
 // Create a new Multiline Editbox widget to be packed.
 func Mle_new(id uint) HMLE {
 	return HMLE{C.go_mle_new(C.ulong(id))}
@@ -4029,6 +4146,16 @@
 	Mle_set_word_wrap(handle, state)
 }
 
+// Sets the auto complete state of an MLE box.
+func Mle_set_auto_complete(handle HANDLE, state int) {
+	C.go_mle_set_auto_complete(handle.GetHandle(), C.int(state))
+}
+
+// Sets the auto complete state of an MLE box.
+func (handle HMLE) SetAutoComplete(state int) {
+	Mle_set_auto_complete(handle, state)
+}
+
 // Finds text in an MLE box.
 func Mle_search(handle HANDLE, text string, point int, flags uint) int {
 	ctext := C.CString(text)
@@ -4749,6 +4876,32 @@
 	return Mutex_trylock(handle)
 }
 
+// Creates a new notificaiton
+func Notification_new(title string, imagepath string, description string) HNOTIFICATION {
+	ctitle := C.CString(title)
+	defer C.free(unsafe.Pointer(ctitle))
+	cimagepath := C.CString(imagepath)
+	defer C.free(unsafe.Pointer(cimagepath))
+	cdescription := C.CString(description)
+	defer C.free(unsafe.Pointer(cdescription))
+	return HNOTIFICATION{C.go_notification_new(ctitle, cimagepath, cdescription)}
+}
+
+// Creates a new notificaiton
+func NotificatioNew(title string, imagepath string, description string) HNOTIFICATION {
+	return Notification_new(title, imagepath, description)
+}
+
+// Sends a created notification
+func Notification_send(handle HANDLE) int {
+	return int(C.go_notification_send(handle.GetHandle()))
+}
+
+// Sends a created notification
+func (handle HNOTIFICATION) Send() int {
+	return Notification_send(handle)
+}
+
 // Allocates and initializes a dialog.
 func Dialog_new() HDIALOG {
 	return HDIALOG{C.go_dialog_new()}
--- a/dw/dwglue.c	Sat Nov 06 23:20:38 2021 -0500
+++ b/dw/dwglue.c	Mon Nov 08 17:18:57 2021 -0600
@@ -182,6 +182,46 @@
    dw_window_set_pointer((HWND)handle, cursortype);
 }
 
+static int go_window_compare(uintptr_t window1, uintptr_t window2)
+{
+   return dw_window_compare((HWND)window1, (HWND)window2);
+}
+
+
+static uintptr_t go_notification_new(char *title, char *imagepath, char *description)
+{
+   return (uintptr_t)dw_notification_new(title, imagepath, description);
+}
+
+static int go_notification_send(uintptr_t notification)
+{
+   return dw_notification_send((HWND)notification);
+}
+
+static int go_feature_get(int feature) 
+{
+   if(feature >= 0 && feature < DW_FEATURE_MAX)
+      return dw_feature_get((DWFEATURE)feature);
+   return DW_FEATURE_UNSUPPORTED;
+}
+
+static int go_feature_set(int feature, int state) 
+{
+   if(feature >= 0 && feature < DW_FEATURE_MAX)
+      return dw_feature_set((DWFEATURE)feature, state);
+   return DW_FEATURE_UNSUPPORTED;
+}
+
+static char *go_app_dir(void)
+{
+   return dw_app_dir();
+}
+
+static int go_app_id_set(char *appid, char *appname)
+{
+   return dw_app_id_set(appid, appname);
+}
+
 static uintptr_t go_box_new(int type, int pad)
 {
    return (uintptr_t)dw_box_new(type, pad);
@@ -513,6 +553,11 @@
    return (uintptr_t)dw_render_new(id);
 }
 
+static void go_render_redraw(uintptr_t handle)
+{
+   dw_render_redraw((HWND)handle);
+}
+
 static void go_font_text_extents_get(uintptr_t handle, uintptr_t pixmap, char *text, int *width, int *height)
 {
    dw_font_text_extents_get((HWND)handle, (HPIXMAP)pixmap, text, width, height);
@@ -663,7 +708,6 @@
    return (uintptr_t)dw_html_new(id);
 }
 
-
 static void go_html_action(uintptr_t hwnd, int action)
 {
     dw_html_action((HWND)hwnd, action);
@@ -679,6 +723,11 @@
     return dw_html_url((HWND)hwnd, url);
 }
 
+static int go_html_javascript_run(uintptr_t handle, char *script, void *scriptdata)
+{
+    return dw_html_javascript_run((HWND)handle, script, scriptdata);
+}
+
 static uintptr_t go_mle_new(unsigned long id)
 {
    return (uintptr_t)dw_mle_new(id);
@@ -739,6 +788,11 @@
     dw_mle_set_word_wrap((HWND)handle, state);
 }
 
+static void go_mle_set_auto_complete(uintptr_t handle, int state)
+{
+    dw_mle_set_auto_complete((HWND)handle, state);
+}
+
 static int go_mle_search(uintptr_t handle, char *text, int point, unsigned long flags)
 {
     return dw_mle_search((HWND)handle, text, point, flags);