Mercurial > dwindows
changeset 2532:457c91634881
Added dw_window_compare() to check if two window handles refer to the same object.
Most platforms just compare the pointer or handle, but Android uses IsSameObject().
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 11 May 2021 05:00:07 +0000 |
parents | f45ebd96ebe5 |
children | 7c863a3a125f |
files | android/dw.cpp dw.h dwtest.c gtk/dw.c gtk3/dw.c gtk4/dw.c ios/dw.m mac/dw.m os2/dw.c os2/dw.def readme.txt template/dw.c win/dw.c win/dw.def |
diffstat | 14 files changed, 175 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/android/dw.cpp Tue May 11 00:51:20 2021 +0000 +++ b/android/dw.cpp Tue May 11 05:00:07 2021 +0000 @@ -3574,7 +3574,7 @@ jmethodID pixmapBitBlt = env->GetMethodID(clazz, "pixmapBitBlt", "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IIIILorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IIII)I"); // Call the method on the object - retval = env->CallIntMethod(_dw_obj, pixmapBitBlt, dest, destp->bitmap, xdest, ydest, width, height, src, srcp->bitmap, xsrc, ysrc, srcwidth, srcheight); + retval = env->CallIntMethod(_dw_obj, pixmapBitBlt, dest, destp ? destp->bitmap : NULL, xdest, ydest, width, height, src, srcp ? srcp->bitmap : NULL, xsrc, ysrc, srcwidth, srcheight); } return retval; } @@ -4794,6 +4794,27 @@ } /* + * Compare two window handles. + * Parameters: + * window1: First window handle to compare. + * window2: Second window handle to compare. + * Returns: + * TRUE if the windows are the same object, FALSE if not. + */ +int API dw_window_compare(HWND window1, HWND window2) +{ + JNIEnv *env; + void *retval = nullptr; + + if(window1 && window2 && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) + { + if(env->IsSameObject(window1, window2)) + return TRUE; + } + return FALSE; +} + +/* * Add a callback to a timer event. * Parameters: * interval: Milliseconds to delay between calls.
--- a/dw.h Tue May 11 00:51:20 2021 +0000 +++ b/dw.h Tue May 11 05:00:07 2021 +0000 @@ -2122,6 +2122,7 @@ void * API dw_dialog_wait(DWDialog *dialog); void API dw_window_set_data(HWND window, const char *dataname, void *data); void * API dw_window_get_data(HWND window, const char *dataname); +int API dw_window_compare(HWND window1, HWND window2); int API dw_module_load(const char *name, HMOD *handle); int API dw_module_symbol(HMOD handle, const char *name, void**func); int API dw_module_close(HMOD handle);
--- a/dwtest.c Tue May 11 00:51:20 2021 +0000 +++ b/dwtest.c Tue May 11 05:00:07 2021 +0000 @@ -274,9 +274,9 @@ HPIXMAP hpm; unsigned long width,height; - if (hwnd == textbox1) + if(dw_window_compare(hwnd, textbox1)) hpm = text1pm; - else if(hwnd == textbox2) + else if(dw_window_compare(hwnd, textbox2)) hpm = text2pm; else return TRUE;
--- a/gtk/dw.c Tue May 11 00:51:20 2021 +0000 +++ b/gtk/dw.c Tue May 11 05:00:07 2021 +0000 @@ -13519,6 +13519,24 @@ } /* + * Compare two window handles. + * Parameters: + * window1: First window handle to compare. + * window2: Second window handle to compare. + * Returns: + * TRUE if the windows are the same object, FALSE if not. + */ +int API dw_window_compare(HWND window1, HWND window2) +{ + /* If anything special is require to compare... do it + * here otherwise just compare the handles. + */ + if(window1 && window2 && window1 == window2) + return TRUE; + return FALSE; +} + +/* * Add a callback to a timer event. * Parameters: * interval: Milliseconds to delay between calls.
--- a/gtk3/dw.c Tue May 11 00:51:20 2021 +0000 +++ b/gtk3/dw.c Tue May 11 05:00:07 2021 +0000 @@ -12156,6 +12156,24 @@ return ret; } +/* + * Compare two window handles. + * Parameters: + * window1: First window handle to compare. + * window2: Second window handle to compare. + * Returns: + * TRUE if the windows are the same object, FALSE if not. + */ +int API dw_window_compare(HWND window1, HWND window2) +{ + /* If anything special is require to compare... do it + * here otherwise just compare the handles. + */ + if(window1 && window2 && window1 == window2) + return TRUE; + return FALSE; +} + /* Internal function to get the state of the timer before firing */ gboolean _dw_timer_func(gpointer data) {
--- a/gtk4/dw.c Tue May 11 00:51:20 2021 +0000 +++ b/gtk4/dw.c Tue May 11 05:00:07 2021 +0000 @@ -10612,6 +10612,24 @@ return ret; } +/* + * Compare two window handles. + * Parameters: + * window1: First window handle to compare. + * window2: Second window handle to compare. + * Returns: + * TRUE if the windows are the same object, FALSE if not. + */ +int API dw_window_compare(HWND window1, HWND window2) +{ + /* If anything special is require to compare... do it + * here otherwise just compare the handles. + */ + if(window1 && window2 && window1 == window2) + return TRUE; + return FALSE; +} + /* Internal function to get the state of the timer before firing */ gboolean _dw_timer_func(gpointer data) {
--- a/ios/dw.m Tue May 11 00:51:20 2021 +0000 +++ b/ios/dw.m Tue May 11 05:00:07 2021 +0000 @@ -9277,6 +9277,24 @@ DW_FUNCTION_RETURN_THIS(retval); } +/* + * Compare two window handles. + * Parameters: + * window1: First window handle to compare. + * window2: Second window handle to compare. + * Returns: + * TRUE if the windows are the same object, FALSE if not. + */ +int API dw_window_compare(HWND window1, HWND window2) +{ + /* If anything special is require to compare... do it + * here otherwise just compare the handles. + */ + if(window1 && window2 && window1 == window2) + return TRUE; + return FALSE; +} + #define DW_TIMER_MAX 64 static NSTimer *DWTimers[DW_TIMER_MAX];
--- a/mac/dw.m Tue May 11 00:51:20 2021 +0000 +++ b/mac/dw.m Tue May 11 05:00:07 2021 +0000 @@ -11488,6 +11488,24 @@ return NULL; } +/* + * Compare two window handles. + * Parameters: + * window1: First window handle to compare. + * window2: Second window handle to compare. + * Returns: + * TRUE if the windows are the same object, FALSE if not. + */ +int API dw_window_compare(HWND window1, HWND window2) +{ + /* If anything special is require to compare... do it + * here otherwise just compare the handles. + */ + if(window1 && window2 && window1 == window2) + return TRUE; + return FALSE; +} + #define DW_TIMER_MAX 64 static NSTimer *DWTimers[DW_TIMER_MAX];
--- a/os2/dw.c Tue May 11 00:51:20 2021 +0000 +++ b/os2/dw.c Tue May 11 05:00:07 2021 +0000 @@ -13499,6 +13499,24 @@ } /* + * Compare two window handles. + * Parameters: + * window1: First window handle to compare. + * window2: Second window handle to compare. + * Returns: + * TRUE if the windows are the same object, FALSE if not. + */ +int API dw_window_compare(HWND window1, HWND window2) +{ + /* If anything special is require to compare... do it + * here otherwise just compare the handles. + */ + if(window1 && window2 && window1 == window2) + return TRUE; + return FALSE; +} + +/* * Add a callback to a timer event. * Parameters: * interval: Milliseconds to delay between calls.
--- a/os2/dw.def Tue May 11 00:51:20 2021 +0000 +++ b/os2/dw.def Tue May 11 05:00:07 2021 +0000 @@ -77,6 +77,7 @@ dw_window_get_preferred_size @84 dw_window_set_gravity @85 dw_window_set_focus @86 + dw_window_compare @87 dw_button_new @90 dw_bitmapbutton_new @91
--- a/readme.txt Tue May 11 00:51:20 2021 +0000 +++ b/readme.txt Tue May 11 05:00:07 2021 +0000 @@ -83,6 +83,10 @@ callback. GTK4 and GTK3 with Wayland require drawing to be done in the callback, necessitating a dw_render_redraw() or dw_flush() call. dw_flush() may cause multiple draw passes. +Added new function dw_window_compare() to check if two window handles + reference the same object. Necessary in the Android port since + handles passed to callbacks are local references, so they don't + match the handles saved during window creation. Added support for dw_window_set_font() with a NULL font parameter. This resets the font used on the widget to the default font. Fixed GTK warnings on GTK3 caused by using Pango style font syntax.
--- a/template/dw.c Tue May 11 00:51:20 2021 +0000 +++ b/template/dw.c Tue May 11 05:00:07 2021 +0000 @@ -3104,6 +3104,24 @@ } /* + * Compare two window handles. + * Parameters: + * window1: First window handle to compare. + * window2: Second window handle to compare. + * Returns: + * TRUE if the windows are the same object, FALSE if not. + */ +int API dw_window_compare(HWND window1, HWND window2) +{ + /* If anything special is require to compare... do it + * here otherwise just compare the handles. + */ + if(window1 && window2 && window1 == window2) + return TRUE; + return FALSE; +} + +/* * Add a callback to a timer event. * Parameters: * interval: Milliseconds to delay between calls.
--- a/win/dw.c Tue May 11 00:51:20 2021 +0000 +++ b/win/dw.c Tue May 11 05:00:07 2021 +0000 @@ -13546,6 +13546,24 @@ } /* + * Compare two window handles. + * Parameters: + * window1: First window handle to compare. + * window2: Second window handle to compare. + * Returns: + * TRUE if the windows are the same object, FALSE if not. + */ +int API dw_window_compare(HWND window1, HWND window2) +{ + /* If anything special is require to compare... do it + * here otherwise just compare the handles. + */ + if(window1 && window2 && window1 == window2) + return TRUE; + return FALSE; +} + +/* * Add a callback to a timer event. * Parameters: * interval: Milliseconds to delay between calls.