From a504cffaf55d090fea44b4d16e538f77974f842a Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Mon, 22 May 2017 12:32:04 +1000 Subject: Added XBM Images --- src/c_fl_xbm_image.cpp | 16 +++++++++++++ src/c_fl_xbm_image.h | 15 +++++++++++++ src/fltk-images-bitmaps-xbm.adb | 50 +++++++++++++++++++++++++++++++++++++++++ src/fltk-images-bitmaps-xbm.ads | 25 +++++++++++++++++++++ 4 files changed, 106 insertions(+) create mode 100644 src/c_fl_xbm_image.cpp create mode 100644 src/c_fl_xbm_image.h create mode 100644 src/fltk-images-bitmaps-xbm.adb create mode 100644 src/fltk-images-bitmaps-xbm.ads (limited to 'src') diff --git a/src/c_fl_xbm_image.cpp b/src/c_fl_xbm_image.cpp new file mode 100644 index 0000000..4f3ee47 --- /dev/null +++ b/src/c_fl_xbm_image.cpp @@ -0,0 +1,16 @@ + + +#include +#include "c_fl_xbm_image.h" + + +XBM_IMAGE new_fl_xbm_image(const char * f) { + Fl_XBM_Image *b = new Fl_XBM_Image(f); + return b; +} + + +void free_fl_xbm_image(XBM_IMAGE b) { + delete reinterpret_cast(b); +} + diff --git a/src/c_fl_xbm_image.h b/src/c_fl_xbm_image.h new file mode 100644 index 0000000..72f27fa --- /dev/null +++ b/src/c_fl_xbm_image.h @@ -0,0 +1,15 @@ + + +#ifndef FL_XBM_IMAGE_GUARD +#define FL_XBM_IMAGE_GUARD + + +typedef void* XBM_IMAGE; + + +extern "C" XBM_IMAGE new_fl_xbm_image(const char * f); +extern "C" void free_fl_xbm_image(XBM_IMAGE b); + + +#endif + diff --git a/src/fltk-images-bitmaps-xbm.adb b/src/fltk-images-bitmaps-xbm.adb new file mode 100644 index 0000000..2241332 --- /dev/null +++ b/src/fltk-images-bitmaps-xbm.adb @@ -0,0 +1,50 @@ + + +with Interfaces.C; +with System; +use type System.Address; + + +package body FLTK.Images.Bitmaps.XBM is + + + function new_fl_xbm_image + (F : in Interfaces.C.char_array) + return System.Address; + pragma Import (C, new_fl_xbm_image, "new_fl_xbm_image"); + + procedure free_fl_xbm_image + (P : in System.Address); + pragma Import (C, free_fl_xbm_image, "free_fl_xbm_image"); + + + + + overriding procedure Finalize + (This : in out XBM_Image) is + begin + if This.Void_Ptr /= System.Null_Address and then + This in XBM_Image'Class + then + free_fl_xbm_image (This.Void_Ptr); + This.Void_Ptr := System.Null_Address; + end if; + Finalize (Bitmap (This)); + end Finalize; + + + + + function Create + (Filename : in String) + return XBM_Image is + begin + return This : XBM_Image do + This.Void_Ptr := new_fl_xbm_image + (Interfaces.C.To_C (Filename)); + end return; + end Create; + + +end FLTK.Images.Bitmaps.XBM; + diff --git a/src/fltk-images-bitmaps-xbm.ads b/src/fltk-images-bitmaps-xbm.ads new file mode 100644 index 0000000..fedbd69 --- /dev/null +++ b/src/fltk-images-bitmaps-xbm.ads @@ -0,0 +1,25 @@ + + +package FLTK.Images.Bitmaps.XBM is + + + type XBM_Image is new Bitmap with private; + + + function Create + (Filename : in String) + return XBM_Image; + + +private + + + type XBM_Image is new Bitmap with null record; + + + overriding procedure Finalize + (This : in out XBM_Image); + + +end FLTK.Images.Bitmaps.XBM; + -- cgit