diff options
author | Jed Barber <jjbarber@y7mail.com> | 2017-05-22 12:32:04 +1000 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2017-05-22 12:32:04 +1000 |
commit | a504cffaf55d090fea44b4d16e538f77974f842a (patch) | |
tree | 54764e4fa505245d63b63c322ae3339455e9dbe1 | |
parent | 26c270964941639d75d7a4dead0903116e5b62b0 (diff) |
Added XBM Images
-rw-r--r-- | src/c_fl_xbm_image.cpp | 16 | ||||
-rw-r--r-- | src/c_fl_xbm_image.h | 15 | ||||
-rw-r--r-- | src/fltk-images-bitmaps-xbm.adb | 50 | ||||
-rw-r--r-- | src/fltk-images-bitmaps-xbm.ads | 25 |
4 files changed, 106 insertions, 0 deletions
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 <FL/Fl_XBM_Image.H> +#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<Fl_XBM_Image*>(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; + |