changeset 2950:0577a97fe36d

Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings. These APIs function identical to the already existing DW_PIXMAP_HEIGHT/WIDTH() macros. The macros will exist at least until the end of the 3.x series, at which point they may be retired.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 03 Jan 2023 22:23:08 +0000
parents a1d0522d7edf
children 34d16576c156
files android/dw.cpp debian/changelog dw.h dw.hpp gtk/dw.c gtk3/dw.c gtk4/dw.c ios/dw.m mac/dw.m os2/dw.c os2/dw.def os2/dw.lnk readme.txt template/dw.c win/dw.c win/dw.def
diffstat 16 files changed, 185 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/android/dw.cpp	Mon Jan 02 21:41:27 2023 +0000
+++ b/android/dw.cpp	Tue Jan 03 22:23:08 2023 +0000
@@ -4989,6 +4989,24 @@
 }
 
 /*
+ * Returns the width of the pixmap, same as the DW_PIXMAP_WIDTH() macro,
+ * but exported as an API, for non-C language bindings.
+ */
+unsigned long API dw_pixmap_get_width(HPIXMAP pixmap)
+{
+    return pixmap ? pixmap->width : 0;
+}
+
+/*
+ * Returns the height of the pixmap, same as the DW_PIXMAP_HEIGHT() macro,
+ * but exported as an API, for non-C language bindings.
+ */
+unsigned long API dw_pixmap_get_height(HPIXMAP pixmap)
+{
+    return pixmap ? pixmap->height : 0;
+}
+
+/*
  * Copies from one item to another.
  * Parameters:
  *       dest: Destination window handle.
--- a/debian/changelog	Mon Jan 02 21:41:27 2023 +0000
+++ b/debian/changelog	Tue Jan 03 22:23:08 2023 +0000
@@ -18,9 +18,12 @@
   * Added variadic versions of dw_debug() and dw_messagebox().
     This is how the standard library does it so we can call the new
     va_list versions from C++: dw_vdebug() and dw_vmessagebox().
+  * Added dw_pixmap_get_height() and dw_pixmap_get_width() APIs to
+    replace the DW_PIXMAP_HEIGHT() and DW_PIXMAP_WIDTH() macros.
+    This allows non-C bindings to call them directly.
 
  -- Brian Smith <brian@dbsoft.org>  Fri, 6 Jan 2023 08:00:00 +1000
- 
+
 dwindows (3.2-1) unstable; urgency=low
 
   * Added support for initial beta support for GTK 4.  --with-gtk4 is now available.
@@ -45,7 +48,7 @@
   * Fixed a bug in dw_listbox_set_text() on GTK3.
 
  -- Brian Smith <brian@dbsoft.org>  Thu, 6 Jan 2022 08:00:00 +1000
- 
+
 dwindows (3.1-1) unstable; urgency=low
 
   * Added notification APIs: dw_notification_new() dw_notification_send() dw_app_id_set()
--- a/dw.h	Mon Jan 02 21:41:27 2023 +0000
+++ b/dw.h	Tue Jan 03 22:23:08 2023 +0000
@@ -2187,6 +2187,8 @@
 void API dw_pixmap_set_transparent_color( HPIXMAP pixmap, ULONG color );
 int API dw_pixmap_set_font(HPIXMAP pixmap, const char *fontname);
 void API dw_pixmap_destroy(HPIXMAP pixmap);
+unsigned long dw_pixmap_get_width(HPIXMAP pixmap);
+unsigned long dw_pixmap_get_height(HPIXMAP pixmap);
 void API dw_beep(int freq, int dur);
 void API dw_debug(const char *format, ...);
 void API dw_vdebug(const char *format, va_list args);
--- a/dw.hpp	Mon Jan 02 21:41:27 2023 +0000
+++ b/dw.hpp	Tue Jan 03 22:23:08 2023 +0000
@@ -924,14 +924,14 @@
     }
     Pixmap(Render *window, const char *filename) { 
         SetHPIXMAP(dw_pixmap_new_from_file(window ? window->GetHWND() : DW_NOHWND, filename));
-        pwidth = hpixmap ? DW_PIXMAP_WIDTH(hpixmap) : 0;
-        pheight = hpixmap ? DW_PIXMAP_HEIGHT(hpixmap) : 0;
+        pwidth = dw_pixmap_get_width(hpixmap);
+        pheight = dw_pixmap_get_height(hpixmap);
         hpmprot = false;
     }
     Pixmap(HPIXMAP hpm) { 
         SetHPIXMAP(hpm);
-        pwidth = hpixmap ? DW_PIXMAP_WIDTH(hpixmap) : 0;
-        pheight = hpixmap ? DW_PIXMAP_HEIGHT(hpixmap) : 0;
+        pwidth = dw_pixmap_get_width(hpixmap);
+        pheight = dw_pixmap_get_height(hpixmap);
         hpmprot = true;
     }
     // Destructor
--- a/gtk/dw.c	Mon Jan 02 21:41:27 2023 +0000
+++ b/gtk/dw.c	Tue Jan 03 22:23:08 2023 +0000
@@ -9359,7 +9359,7 @@
  *       pixmap: Handle to a pixmap returned by
  *               dw_pixmap_new..
  */
-void dw_pixmap_destroy(HPIXMAP pixmap)
+void API dw_pixmap_destroy(HPIXMAP pixmap)
 {
    int _dw_locked_by_me = FALSE;
 
@@ -9373,6 +9373,24 @@
    DW_MUTEX_UNLOCK;
 }
 
+/*
+ * Returns the width of the pixmap, same as the DW_PIXMAP_WIDTH() macro,
+ * but exported as an API, for non-C language bindings.
+ */
+unsigned long API dw_pixmap_get_width(HPIXMAP pixmap)
+{
+    return pixmap ? pixmap->width : 0;
+}
+
+/*
+ * Returns the height of the pixmap, same as the DW_PIXMAP_HEIGHT() macro,
+ * but exported as an API, for non-C language bindings.
+ */
+unsigned long API dw_pixmap_get_height(HPIXMAP pixmap)
+{
+    return pixmap ? pixmap->height : 0;
+}
+
 #if GTK_CHECK_VERSION(2,10,0)
 /* Cairo version of dw_pixmap_bitblt() from GTK3, use if either pixmap is a cairo surface */
 int _dw_cairo_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc, int srcwidth, int srcheight)
--- a/gtk3/dw.c	Mon Jan 02 21:41:27 2023 +0000
+++ b/gtk3/dw.c	Tue Jan 03 22:23:08 2023 +0000
@@ -8220,7 +8220,7 @@
  *       pixmap: Handle to a pixmap returned by
  *               dw_pixmap_new..
  */
-void dw_pixmap_destroy(HPIXMAP pixmap)
+void API dw_pixmap_destroy(HPIXMAP pixmap)
 {
    int _dw_locked_by_me = FALSE;
 
@@ -8234,6 +8234,24 @@
 }
 
 /*
+ * Returns the width of the pixmap, same as the DW_PIXMAP_WIDTH() macro,
+ * but exported as an API, for non-C language bindings.
+ */
+unsigned long API dw_pixmap_get_width(HPIXMAP pixmap)
+{
+    return pixmap ? pixmap->width : 0;
+}
+
+/*
+ * Returns the height of the pixmap, same as the DW_PIXMAP_HEIGHT() macro,
+ * but exported as an API, for non-C language bindings.
+ */
+unsigned long API dw_pixmap_get_height(HPIXMAP pixmap)
+{
+    return pixmap ? pixmap->height : 0;
+}
+
+/*
  * Copies from one item to another.
  * Parameters:
  *       dest: Destination window handle.
--- a/gtk4/dw.c	Mon Jan 02 21:41:27 2023 +0000
+++ b/gtk4/dw.c	Tue Jan 03 22:23:08 2023 +0000
@@ -7352,6 +7352,24 @@
 }
 
 /*
+ * Returns the width of the pixmap, same as the DW_PIXMAP_WIDTH() macro,
+ * but exported as an API, for non-C language bindings.
+ */
+unsigned long API dw_pixmap_get_width(HPIXMAP pixmap)
+{
+    return pixmap ? pixmap->width : 0;
+}
+
+/*
+ * Returns the height of the pixmap, same as the DW_PIXMAP_HEIGHT() macro,
+ * but exported as an API, for non-C language bindings.
+ */
+unsigned long API dw_pixmap_get_height(HPIXMAP pixmap)
+{
+    return pixmap ? pixmap->height : 0;
+}
+
+/*
  * Copies from one item to another.
  * Parameters:
  *       dest: Destination window handle.
--- a/ios/dw.m	Mon Jan 02 21:41:27 2023 +0000
+++ b/ios/dw.m	Tue Jan 03 22:23:08 2023 +0000
@@ -8386,7 +8386,7 @@
  *       pixmap: Handle to a pixmap returned by
  *               dw_pixmap_new..
  *       color:  transparent color
- * Note: This does nothing on Mac as transparency
+ * Note: This does nothing on iOS as transparency
  *       is handled automatically
  */
 void API dw_pixmap_set_transparent_color(HPIXMAP pixmap, ULONG color)
@@ -8485,6 +8485,24 @@
 }
 
 /*
+ * Returns the width of the pixmap, same as the DW_PIXMAP_WIDTH() macro,
+ * but exported as an API, for non-C language bindings.
+ */
+unsigned long API dw_pixmap_get_width(HPIXMAP pixmap)
+{
+    return pixmap ? pixmap->width : 0;
+}
+
+/*
+ * Returns the height of the pixmap, same as the DW_PIXMAP_HEIGHT() macro,
+ * but exported as an API, for non-C language bindings.
+ */
+unsigned long API dw_pixmap_get_height(HPIXMAP pixmap)
+{
+    return pixmap ? pixmap->height : 0;
+}
+
+/*
  * Copies from one item to another.
  * Parameters:
  *       dest: Destination window handle.
--- a/mac/dw.m	Mon Jan 02 21:41:27 2023 +0000
+++ b/mac/dw.m	Tue Jan 03 22:23:08 2023 +0000
@@ -9206,6 +9206,24 @@
 }
 
 /*
+ * Returns the width of the pixmap, same as the DW_PIXMAP_WIDTH() macro,
+ * but exported as an API, for non-C language bindings.
+ */
+unsigned long API dw_pixmap_get_width(HPIXMAP pixmap)
+{
+    return pixmap ? pixmap->width : 0;
+}
+
+/*
+ * Returns the height of the pixmap, same as the DW_PIXMAP_HEIGHT() macro,
+ * but exported as an API, for non-C language bindings.
+ */
+unsigned long API dw_pixmap_get_height(HPIXMAP pixmap)
+{
+    return pixmap ? pixmap->height : 0;
+}
+
+/*
  * Copies from one item to another.
  * Parameters:
  *       dest: Destination window handle.
--- a/os2/dw.c	Mon Jan 02 21:41:27 2023 +0000
+++ b/os2/dw.c	Tue Jan 03 22:23:08 2023 +0000
@@ -11473,6 +11473,24 @@
 }
 
 /*
+ * Returns the width of the pixmap, same as the DW_PIXMAP_WIDTH() macro,
+ * but exported as an API, for non-C language bindings.
+ */
+unsigned long API dw_pixmap_get_width(HPIXMAP pixmap)
+{
+    return pixmap ? pixmap->width : 0;
+}
+
+/*
+ * Returns the height of the pixmap, same as the DW_PIXMAP_HEIGHT() macro,
+ * but exported as an API, for non-C language bindings.
+ */
+unsigned long API dw_pixmap_get_height(HPIXMAP pixmap)
+{
+    return pixmap ? pixmap->height : 0;
+}
+
+/*
  * Copies from one item to another.
  * Parameters:
  *       dest: Destination window handle.
--- a/os2/dw.def	Mon Jan 02 21:41:27 2023 +0000
+++ b/os2/dw.def	Tue Jan 03 22:23:08 2023 +0000
@@ -240,6 +240,8 @@
   dw_pixmap_set_transparent_color        @346
   dw_pixmap_set_font                     @347
   dw_pixmap_stretch_bitblt               @348
+  dw_pixmap_get_width                    @355
+  dw_pixmap_get_height                   @356
 
   dw_dialog_new                          @350
   dw_dialog_dismiss                      @351
--- a/os2/dw.lnk	Mon Jan 02 21:41:27 2023 +0000
+++ b/os2/dw.lnk	Tue Jan 03 22:23:08 2023 +0000
@@ -233,6 +233,8 @@
 export dw_pixmap_set_transparent_color.346
 export dw_pixmap_set_font.347
 export dw_pixmap_stretch_bitblt.348
+export dw_pixmap_get_width.355
+export dw_pixmap_get_height.356
 
 export dw_dialog_new.350
 export dw_dialog_dismiss.351
--- a/readme.txt	Mon Jan 02 21:41:27 2023 +0000
+++ b/readme.txt	Tue Jan 03 22:23:08 2023 +0000
@@ -88,6 +88,9 @@
 Added variadic versions of dw_debug() and dw_messagebox().
     This is how the standard library does it so we can call the new
     va_list versions from C++: dw_vdebug() and dw_vmessagebox().
+Added dw_pixmap_get_height() and dw_pixmap_get_width() APIs to
+    replace the DW_PIXMAP_HEIGHT() and DW_PIXMAP_WIDTH() macros.
+    This allows non-C bindings to call them directly.
 Added support for MacOS 13 Ventura and iOS 16.
 
 Dynamic Windows Documentation is available at:
--- a/template/dw.c	Mon Jan 02 21:41:27 2023 +0000
+++ b/template/dw.c	Tue Jan 03 22:23:08 2023 +0000
@@ -2250,6 +2250,24 @@
 }
 
 /*
+ * Returns the width of the pixmap, same as the DW_PIXMAP_WIDTH() macro,
+ * but exported as an API, for non-C language bindings.
+ */
+unsigned long API dw_pixmap_get_width(HPIXMAP pixmap)
+{
+    return pixmap ? pixmap->width : 0;
+}
+
+/*
+ * Returns the height of the pixmap, same as the DW_PIXMAP_HEIGHT() macro,
+ * but exported as an API, for non-C language bindings.
+ */
+unsigned long API dw_pixmap_get_height(HPIXMAP pixmap)
+{
+    return pixmap ? pixmap->height : 0;
+}
+
+/*
  * Copies from one item to another.
  * Parameters:
  *       dest: Destination window handle.
--- a/win/dw.c	Mon Jan 02 21:41:27 2023 +0000
+++ b/win/dw.c	Tue Jan 03 22:23:08 2023 +0000
@@ -11999,6 +11999,24 @@
 }
 
 /*
+ * Returns the width of the pixmap, same as the DW_PIXMAP_WIDTH() macro,
+ * but exported as an API, for non-C language bindings.
+ */
+unsigned long API dw_pixmap_get_width(HPIXMAP pixmap)
+{
+    return pixmap ? pixmap->width : 0;
+}
+
+/*
+ * Returns the height of the pixmap, same as the DW_PIXMAP_HEIGHT() macro,
+ * but exported as an API, for non-C language bindings.
+ */
+unsigned long API dw_pixmap_get_height(HPIXMAP pixmap)
+{
+    return pixmap ? pixmap->height : 0;
+}
+
+/*
  * Copies from one item to another.
  * Parameters:
  *       dest: Destination window handle.
--- a/win/dw.def	Mon Jan 02 21:41:27 2023 +0000
+++ b/win/dw.def	Tue Jan 03 22:23:08 2023 +0000
@@ -238,6 +238,8 @@
   dw_pixmap_set_transparent_color        @346
   dw_pixmap_set_font                     @347
   dw_pixmap_stretch_bitblt               @348
+  dw_pixmap_get_width                    @355
+  dw_pixmap_get_height                   @356
 
   dw_dialog_new                          @350
   dw_dialog_dismiss                      @351