[glabels/vala] Initial bala implementation of libzint backend.



commit 75d90dc8f041c3dffd622aac080b1e367af52424
Author: Jim Evins <evins snaught com>
Date:   Sat Sep 29 18:42:45 2012 -0400

    Initial bala implementation of libzint backend.

 configure.ac                          |   25 ++
 glabels/Makefile.am                   |    5 +
 glabels/barcode_backends.vala         |   78 ++++-
 glabels/barcode_backends/libzint.vapi |  214 ++++++++++
 glabels/barcode_backends/zint.vala    |  742 +++++++++++++++++++++++++++++++++
 5 files changed, 1062 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 405facc..eb44798 100644
--- a/configure.ac
+++ b/configure.ac
@@ -207,6 +207,30 @@ else
 fi
 
 
+dnl ---------------------------------------------------------------------------
+dnl - Check for optional Zint backend
+dnl ---------------------------------------------------------------------------
+AC_ARG_WITH(libzint,
+	    [AS_HELP_STRING([--without-libzint],[build without Zint Barcode support])])
+have_libzint=no
+if test "x$with_libzint" != xno; then
+   AC_CHECK_LIB(zint, ZBarcode_Render,
+		[have_libzint=yes], [have_libzint=no])
+fi
+
+if test "x$have_libzint" = "xyes"; then
+	AC_DEFINE(HAVE_LIBZINT,1,[Define to 1 for Zint Barcode support])
+	LIBZINT_VALAFLAGS="-D HAVE_LIBZINT"
+	LIBZINT_CFLAGS=""
+	LIBZINT_LIBS="-lzint"
+	AC_SUBST(LIBZINT_VALAFLAGS)
+	AC_SUBST(LIBZINT_CFLAGS)
+	AC_SUBST(LIBZINT_LIBS)
+else
+	help_libzint="(See http://www.zint.org.uk)"
+fi
+
+
 AC_CONFIG_FILES([Makefile
 	vapi/Makefile
 	libglabels/Makefile
@@ -251,5 +275,6 @@ Optional barcode backends:
         GNU Barcode ............. ${have_libbarcode} ${help_libbarcode}
         QR Code ................. ${have_libqrencode} ${help_libqrencode}
         IEC 16022 ............... ${have_libiec16022} ${help_libiec16022}
+        Zint .................... ${have_libzint} ${help_libzint}
 
 "
diff --git a/glabels/Makefile.am b/glabels/Makefile.am
index e75f75a..038a3e8 100644
--- a/glabels/Makefile.am
+++ b/glabels/Makefile.am
@@ -15,7 +15,9 @@ glabels_4_SOURCES = \
 	barcode_backends/libbarcode.vapi \
 	barcode_backends/libiec16022.vapi \
 	barcode_backends/libqrencode.vapi \
+	barcode_backends/libzint.vapi \
 	barcode_backends/qrencode.vala \
+	barcode_backends/zint.vala \
 	barcode_menu.vala \
 	barcode_menu_button.vala \
 	barcode_menu_item.vala \
@@ -100,6 +102,7 @@ INCLUDES = \
 	$(LIBBARCODE_CFLAGS) \
 	$(LIBIEC16022_CFLAGS) \
 	$(LIBQRENCODE_CFLAGS) \
+	$(LIBZINT_CFLAGS) \
 	$(NULL)
 
 VALAFLAGS = \
@@ -117,6 +120,7 @@ VALAFLAGS = \
 	$(LIBBARCODE_VALAFLAGS) \
 	$(LIBIEC16022_VALAFLAGS) \
 	$(LIBQRENCODE_VALAFLAGS) \
+	$(LIBZINT_VALAFLAGS) \
 	$(NULL)
 
 
@@ -127,6 +131,7 @@ glabels_4_LDADD = \
 	$(LIBBARCODE_LIBS) \
 	$(LIBIEC16022_LIBS) \
 	$(LIBQRENCODE_LIBS) \
+	$(LIBZINT_LIBS) \
 	$(NULL)
 
 
diff --git a/glabels/barcode_backends.vala b/glabels/barcode_backends.vala
index 7435e66..7f60fbf 100644
--- a/glabels/barcode_backends.vala
+++ b/glabels/barcode_backends.vala
@@ -189,6 +189,74 @@ namespace glabels
 
 			register_backend( "zint", _("Zint") );
 
+			glbarcode.Factory.register_type( "zint:AUSP",     typeof(BackendZint.AusP)     );
+			glbarcode.Factory.register_type( "zint:AUSRP",    typeof(BackendZint.AusRP)    );
+			glbarcode.Factory.register_type( "zint:AUSRT",    typeof(BackendZint.AusRT)    );
+			glbarcode.Factory.register_type( "zint:AUSRD",    typeof(BackendZint.AusRD)    );
+			glbarcode.Factory.register_type( "zint:AZTEC",    typeof(BackendZint.Aztec)    );
+			glbarcode.Factory.register_type( "zint:AZRUN",    typeof(BackendZint.Azrun)    );
+			glbarcode.Factory.register_type( "zint:CBR",      typeof(BackendZint.Cbr)      );
+			glbarcode.Factory.register_type( "zint:Code1",    typeof(BackendZint.Code1)    );
+			glbarcode.Factory.register_type( "zint:Code11",   typeof(BackendZint.Code11)   );
+			glbarcode.Factory.register_type( "zint:C16K",     typeof(BackendZint.C16k)     );
+			glbarcode.Factory.register_type( "zint:C25M",     typeof(BackendZint.C25m)     );
+			glbarcode.Factory.register_type( "zint:C25I",     typeof(BackendZint.C25i)     );
+			glbarcode.Factory.register_type( "zint:C25DL",    typeof(BackendZint.C25dl)    );
+			glbarcode.Factory.register_type( "zint:Code32",   typeof(BackendZint.Code32)   );
+			glbarcode.Factory.register_type( "zint:Code39",   typeof(BackendZint.Code39)   );
+			glbarcode.Factory.register_type( "zint:Code39E",  typeof(BackendZint.Code39e)  );
+			glbarcode.Factory.register_type( "zint:Code49",   typeof(BackendZint.Code49)   );
+			glbarcode.Factory.register_type( "zint:Code93",   typeof(BackendZint.Code93)   );
+			glbarcode.Factory.register_type( "zint:Code128",  typeof(BackendZint.Code128)  );
+			glbarcode.Factory.register_type( "zint:Code128B", typeof(BackendZint.Code128b) );
+			glbarcode.Factory.register_type( "zint:DAFT",     typeof(BackendZint.Daft)     );
+			glbarcode.Factory.register_type( "zint:DMTX",     typeof(BackendZint.Dmtx)     );
+			glbarcode.Factory.register_type( "zint:DPL",      typeof(BackendZint.Dpl)      );
+			glbarcode.Factory.register_type( "zint:DPI",      typeof(BackendZint.Dpi)      );
+			glbarcode.Factory.register_type( "zint:KIX",      typeof(BackendZint.Kix)      );
+			glbarcode.Factory.register_type( "zint:EAN",      typeof(BackendZint.Ean)      );
+			glbarcode.Factory.register_type( "zint:GMTX",     typeof(BackendZint.Gmtx)     );
+			glbarcode.Factory.register_type( "zint:GS1128",   typeof(BackendZint.Gs1128)   );
+			glbarcode.Factory.register_type( "zint:RSS14",    typeof(BackendZint.Rss14)    );
+			glbarcode.Factory.register_type( "zint:RSSLTD",   typeof(BackendZint.Rssltd)   );
+			glbarcode.Factory.register_type( "zint:RSSEXP",   typeof(BackendZint.Rssexp)   );
+			glbarcode.Factory.register_type( "zint:RSSS",     typeof(BackendZint.Rsss)     );
+			glbarcode.Factory.register_type( "zint:RSSSO",    typeof(BackendZint.Rssso)    );
+			glbarcode.Factory.register_type( "zint:RSSSE",    typeof(BackendZint.Rssse)    );
+			glbarcode.Factory.register_type( "zint:HIBC128",  typeof(BackendZint.Hibc128)  );
+			glbarcode.Factory.register_type( "zint:HIBC39",   typeof(BackendZint.Hibc39)   );
+			glbarcode.Factory.register_type( "zint:HIBCDM",   typeof(BackendZint.Hibcdm)   );
+			glbarcode.Factory.register_type( "zint:HIBCQR",   typeof(BackendZint.Hibcqr)   );
+			glbarcode.Factory.register_type( "zint:HIBCPDF",  typeof(BackendZint.Hibcpdf)  );
+			glbarcode.Factory.register_type( "zint:HIBCMPDF", typeof(BackendZint.Hibcmpdf) );
+			glbarcode.Factory.register_type( "zint:HIBCAZ",   typeof(BackendZint.Hibcaz)   );
+			glbarcode.Factory.register_type( "zint:I25",      typeof(BackendZint.I25)      );
+			glbarcode.Factory.register_type( "zint:ISBN",     typeof(BackendZint.Isbn)     );
+			glbarcode.Factory.register_type( "zint:ITF14",    typeof(BackendZint.Itf14)    );
+			glbarcode.Factory.register_type( "zint:JAPAN",    typeof(BackendZint.Japan)    );
+			glbarcode.Factory.register_type( "zint:KOREA",    typeof(BackendZint.Korea)    );
+			glbarcode.Factory.register_type( "zint:LOGM",     typeof(BackendZint.Logm)     );
+			glbarcode.Factory.register_type( "zint:MAXI",     typeof(BackendZint.Maxi)     );
+			glbarcode.Factory.register_type( "zint:MPDF",     typeof(BackendZint.Mpdf)     );
+			glbarcode.Factory.register_type( "zint:MQR",      typeof(BackendZint.Mqr)      );
+			glbarcode.Factory.register_type( "zint:MSI",      typeof(BackendZint.Msi)      );
+			glbarcode.Factory.register_type( "zint:NVE",      typeof(BackendZint.Nve)      );
+			glbarcode.Factory.register_type( "zint:PDF",      typeof(BackendZint.Pdf)      );
+			glbarcode.Factory.register_type( "zint:PDFT",     typeof(BackendZint.Pdft)     );
+			glbarcode.Factory.register_type( "zint:PLAN",     typeof(BackendZint.Plan)     );
+			glbarcode.Factory.register_type( "zint:POSTNET",  typeof(BackendZint.Postnet)  );
+			glbarcode.Factory.register_type( "zint:PHARMA",   typeof(BackendZint.Pharma)   );
+			glbarcode.Factory.register_type( "zint:PHARMA2",  typeof(BackendZint.Pharma2)  );
+			glbarcode.Factory.register_type( "zint:PZN",      typeof(BackendZint.Pzn)      );
+			glbarcode.Factory.register_type( "zint:QR",       typeof(BackendZint.Qr)       );
+			glbarcode.Factory.register_type( "zint:RM4",      typeof(BackendZint.Rm4)      );
+			glbarcode.Factory.register_type( "zint:TELE",     typeof(BackendZint.Tele)     );
+			glbarcode.Factory.register_type( "zint:TELEX",    typeof(BackendZint.Telex)    );
+			glbarcode.Factory.register_type( "zint:UPC-A",    typeof(BackendZint.UpcA)     );
+			glbarcode.Factory.register_type( "zint:UPC-E",    typeof(BackendZint.UpcE)     );
+			glbarcode.Factory.register_type( "zint:USPS",     typeof(BackendZint.Usps)     );
+			glbarcode.Factory.register_type( "zint:PLS",      typeof(BackendZint.Pls)      );
+
 			register_style( "zint:AUSP", "zint", _("Australia Post Standard"),
 			                false, false, true, false, "12345678901234567890123", true, 23 );
 
@@ -201,8 +269,11 @@ namespace glabels
 			register_style( "zint:AUSRD", "zint", _("Australia Post Redirect"),
 			                false, false, true, false, "12345678", true, 8 );
 
+#if FIXME
+			/* TODO: fix crash, zint-2.4.2 */
 			register_style( "zint:AZTEC", "zint", _("Aztec Code"),
 			                false, false, true, false, "1234567890", true, 10 );
+#endif
           
 			register_style( "zint:AZRUN", "zint", _("Aztec Rune"),
 			                false, false, true, false, "255", true, 3 );
@@ -210,8 +281,11 @@ namespace glabels
 			register_style( "zint:CBR", "zint", _("Codabar"),
 			                true, true, true, false, "ABCDABCDAB", true, 10 );
 
+#if FIXME
+			/* TODO: fix crash, zint-2.4.2 */
 			register_style( "zint:Code1", "zint", _("Code One"), 
 			                false, false, true, false, "0000000000", true, 10 );
+#endif
 
 			register_style( "zint:Code11", "zint", _("Code 11"),
 			                true, true, true, false, "0000000000", true, 10 );
@@ -276,10 +350,10 @@ namespace glabels
 			register_style( "zint:RSS14", "zint", _("GS1 DataBar-14"),
 			                true, true, true, false, "1234567890123", true, 13 );
           
-			register_style( "zint:RSSLTD", "GS1 DataBar-14 Limited", 
+			register_style( "zint:RSSLTD", "zint", "GS1 DataBar-14 Limited", 
 			                true, true, true, false, "1234567890123", true, 13 );
           
-			register_style( "zint:RSSEXP", "GS1 DataBar Extended", 
+			register_style( "zint:RSSEXP", "zint", "GS1 DataBar Extended", 
 			                true, true, true, false, "[01]12345678901234", false, 18 );
           
 			register_style( "zint:RSSS", "zint", _("GS1 DataBar-14 Stacked"),
diff --git a/glabels/barcode_backends/libzint.vapi b/glabels/barcode_backends/libzint.vapi
new file mode 100644
index 0000000..f6c6ae1
--- /dev/null
+++ b/glabels/barcode_backends/libzint.vapi
@@ -0,0 +1,214 @@
+
+/*
+ * Minimal VAPI file for LIBZINT Barcode library.
+ */
+
+#if HAVE_LIBZINT
+
+namespace zint
+{
+
+	[CCode (cheader_filename = "zint.h", cname = "struct zint_symbol", unref_function = "ZBarcode_Delete")]
+	public class Symbol
+	{
+		[CCode (cname = "ZBarcode_Create")]
+		public Symbol();
+
+		public int          symbology;
+		public int          show_hrt;
+		public string       errtxt;
+		public Render      *rendered;
+
+		[CCode (cname = "ZBarcode_Encode")]
+		public int Encode( string input, int length );
+		[CCode (cname = "ZBarcode_Render")]
+		public int Render( float w, float h );
+	}
+
+	[CCode (cheader_filename = "zint.h", cname="struct zint_render")]
+	public struct Render {
+		float          width;
+		float          height;
+		RenderLine    *lines;
+		RenderString  *strings;
+		RenderRing    *rings;
+		RenderHexagon *hexagons;
+	}
+
+	[CCode (cheader_filename = "zint.h", cname="struct zint_render_line")]
+	public struct RenderLine {
+		float          x;
+		float          y;
+		float          length;
+		float          width;
+		RenderLine    *next;
+	}
+
+	[CCode (cheader_filename = "zint.h", cname="struct zint_render_string")]
+	public struct RenderString {
+		float          x;
+		float          y;
+		float          fsize;
+		float          width;
+		int            length;
+		string         text;
+		RenderString  *next;
+	}
+
+	[CCode (cheader_filename = "zint.h", cname="struct zint_render_ring")]
+	public struct RenderRing {
+		float          x;
+		float          y;
+		float          radius;
+		float          line_width;
+		RenderRing    *next;
+	}
+
+	[CCode (cheader_filename = "zint.h", cname="struct zint_render_hexagon")]
+	public struct RenderHexagon {
+		float          x;
+		float          y;
+		RenderHexagon *next;
+	}
+
+	namespace Barcode
+	{
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_AUSPOST")]
+        public const int AUSPOST;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_AUSREPLY")]
+        public const int AUSREPLY;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_AUSROUTE")]
+        public const int AUSROUTE;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_AUSREDIRECT")]
+        public const int AUSREDIRECT;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_AZTEC")]
+        public const int AZTEC;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_AZRUNE")]
+        public const int AZRUNE;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_CODABAR")]
+        public const int CODABAR;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_CODEONE")]
+        public const int CODEONE;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_CODE11")]
+        public const int CODE11;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_CODE16K")]
+        public const int CODE16K;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_C25MATRIX")]
+        public const int C25MATRIX;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_C25IATA")]
+        public const int C25IATA;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_C25LOGIC")]
+        public const int C25LOGIC;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_CODE32")]
+        public const int CODE32;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_CODE39")]
+        public const int CODE39;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_EXCODE39")]
+        public const int EXCODE39;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_CODE49")]
+        public const int CODE49;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_CODE93")]
+        public const int CODE93;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_CODE128")]
+        public const int CODE128;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_CODE128B")]
+        public const int CODE128B;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_DAFT")]
+        public const int DAFT;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_DATAMATRIX")]
+        public const int DATAMATRIX;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_DPLEIT")]
+        public const int DPLEIT;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_DPIDENT")]
+        public const int DPIDENT;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_KIX")]
+        public const int KIX;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_EANX")]
+        public const int EANX;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_HIBC_128")]
+        public const int HIBC_128;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_HIBC_39")]
+        public const int HIBC_39;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_HIBC_DM")]
+        public const int HIBC_DM;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_HIBC_QR")]
+        public const int HIBC_QR;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_HIBC_PDF")]
+        public const int HIBC_PDF;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_HIBC_MICPDF")]
+        public const int HIBC_MICPDF;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_HIBC_AZTEC")]
+        public const int HIBC_AZTEC;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_C25INTER")]
+        public const int C25INTER;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_ISBNX")]
+        public const int ISBNX;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_ITF14")]
+        public const int ITF14;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_GRIDMATRIX")]
+        public const int GRIDMATRIX;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_EAN128")]
+        public const int EAN128;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_LOGMARS")]
+        public const int LOGMARS;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_RSS14")]
+        public const int RSS14;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_RSS_LTD")]
+        public const int RSS_LTD;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_RSS_EXP")]
+        public const int RSS_EXP;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_RSS14STACK")]
+        public const int RSS14STACK;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_RSS14STACK_OMNI")]
+        public const int RSS14STACK_OMNI;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_RSS_EXPSTACK")]
+        public const int RSS_EXPSTACK;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_PHARMA")]
+        public const int PHARMA;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_PHARMA_TWO")]
+        public const int PHARMA_TWO;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_PZN")]
+        public const int PZN;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_TELEPEN")]
+        public const int TELEPEN;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_TELEPEN_NUM")]
+        public const int TELEPEN_NUM;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_JAPANPOST")]
+        public const int JAPANPOST;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_KOREAPOST")]
+        public const int KOREAPOST;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_MAXICODE")]
+        public const int MAXICODE;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_MICROPDF417")]
+        public const int MICROPDF417;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_PLESSEY")]
+        public const int MSI_PLESSEY;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_MICROQR")]
+        public const int MICROQR;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_NVE18")]
+        public const int NVE18;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_PLANET")]
+        public const int PLANET;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_POSTNET")]
+        public const int POSTNET;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_PDF417")]
+        public const int PDF417;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_PDF417TRUNC")]
+        public const int PDF417TRUNC;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_QRCODE")]
+        public const int QRCODE;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_RM4SCC")]
+        public const int RM4SCC;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_UPCA")]
+        public const int UPCA;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_UPCE")]
+        public const int UPCE;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_ONECODE")]
+        public const int ONECODE;
+		[CCode (cheader_filename = "zint.h", cname="BARCODE_PLESSEY")]
+        public const int PLESSEY;
+	}
+
+}
+
+#endif
diff --git a/glabels/barcode_backends/zint.vala b/glabels/barcode_backends/zint.vala
new file mode 100644
index 0000000..55706be
--- /dev/null
+++ b/glabels/barcode_backends/zint.vala
@@ -0,0 +1,742 @@
+/*  zint.vala
+ *
+ *  Copyright (C) 2012  Jim Evins <evins snaught com>
+ *
+ *  This file is part of libglbarcode.
+ *
+ *  libglabels is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Lesser General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  libglabels is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public License
+ *  along with libglabels.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#if HAVE_LIBZINT
+
+using GLib;
+using glbarcode.Constants;
+
+namespace glabels
+{
+
+	namespace BackendZint
+	{
+
+		/**
+		 * Concrete Barcode Classes
+		 */
+		public class AusP : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.AUSPOST;
+				return "";
+			}
+		}
+
+		public class AusRP : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.AUSREPLY;
+				return "";
+			}
+		}
+
+		public class AusRT : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.AUSROUTE;
+				return "";
+			}
+		}
+
+		public class AusRD : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.AUSREDIRECT;
+				return "";
+			}
+		}
+
+		public class Aztec : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.AZTEC;
+				return "";
+			}
+		}
+
+		public class Azrun : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.AZRUNE;
+				return "";
+			}
+		}
+
+		public class Cbr : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.CODABAR;
+				return "";
+			}
+		}
+
+		public class Code1 : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.CODEONE;
+				return "";
+			}
+		}
+
+		public class Code11 : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.CODE11;
+				return "";
+			}
+		}
+
+		public class C16k : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.CODE16K;
+				return "";
+			}
+		}
+
+		public class C25m : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.C25MATRIX;
+				return "";
+			}
+		}
+
+		public class C25i : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.C25IATA;
+				return "";
+			}
+		}
+
+		public class C25dl : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.C25LOGIC;
+				return "";
+			}
+		}
+
+		public class Code32 : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.CODE32;
+				return "";
+			}
+		}
+
+		public class Code39 : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.CODE39;
+				return "";
+			}
+		}
+
+		public class Code39e : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.EXCODE39;
+				return "";
+			}
+		}
+
+		public class Code49 : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.CODE49;
+				return "";
+			}
+		}
+
+		public class Code93 : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.CODE93;
+				return "";
+			}
+		}
+
+		public class Code128 : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.CODE128;
+				return "";
+			}
+		}
+
+		public class Code128b : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.CODE128B;
+				return "";
+			}
+		}
+
+		public class Daft : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.DAFT;
+				return "";
+			}
+		}
+
+		public class Dmtx : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.DATAMATRIX;
+				return "";
+			}
+		}
+
+		public class Dpl : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.DPLEIT;
+				return "";
+			}
+		}
+
+		public class Dpi : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.DPIDENT;
+				return "";
+			}
+		}
+
+		public class Kix : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.KIX;
+				return "";
+			}
+		}
+
+		public class Ean : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.EANX;
+				return "";
+			}
+		}
+
+		public class Hibc128 : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.HIBC_128;
+				return "";
+			}
+		}
+
+		public class Hibc39 : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.HIBC_39;
+				return "";
+			}
+		}
+
+		public class Hibcdm : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.HIBC_DM;
+				return "";
+			}
+		}
+
+		public class Hibcqr : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.HIBC_QR;
+				return "";
+			}
+		}
+
+		public class Hibcpdf : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.HIBC_PDF;
+				return "";
+			}
+		}
+
+		public class Hibcmpdf : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.HIBC_MICPDF;
+				return "";
+			}
+		}
+
+		public class Hibcaz : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.HIBC_AZTEC;
+				return "";
+			}
+		}
+
+		public class I25 : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.C25INTER;
+				return "";
+			}
+		}
+
+		public class Isbn : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.ISBNX;
+				return "";
+			}
+		}
+
+		public class Itf14 : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.ITF14;
+				return "";
+			}
+		}
+
+		public class Gmtx : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.GRIDMATRIX;
+				return "";
+			}
+		}
+
+		public class Gs1128 : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.EAN128;
+				return "";
+			}
+		}
+
+		public class Logm : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.LOGMARS;
+				return "";
+			}
+		}
+
+		public class Rss14 : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.RSS14;
+				return "";
+			}
+		}
+
+		public class Rssltd : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.RSS_LTD;
+				return "";
+			}
+		}
+
+		public class Rssexp : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.RSS_EXP;
+				return "";
+			}
+		}
+
+		public class Rsss : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.RSS14STACK;
+				return "";
+			}
+		}
+
+		public class Rssso : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.RSS14STACK_OMNI;
+				return "";
+			}
+		}
+
+		public class Rssse : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.RSS_EXPSTACK;
+				return "";
+			}
+		}
+
+		public class Pharma : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.PHARMA;
+				return "";
+			}
+		}
+
+		public class Pharma2 : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.PHARMA_TWO;
+				return "";
+			}
+		}
+
+		public class Pzn : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.PZN;
+				return "";
+			}
+		}
+
+		public class Tele : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.TELEPEN;
+				return "";
+			}
+		}
+
+		public class Telex : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.TELEPEN_NUM;
+				return "";
+			}
+		}
+
+		public class Japan : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.JAPANPOST;
+				return "";
+			}
+		}
+
+		public class Korea : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.KOREAPOST;
+				return "";
+			}
+		}
+
+		public class Maxi : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.MAXICODE;
+				return "";
+			}
+		}
+
+		public class Mpdf : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.MICROPDF417;
+				return "";
+			}
+		}
+
+		public class Msi : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.MSI_PLESSEY;
+				return "";
+			}
+		}
+
+		public class Mqr : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.MICROQR;
+				return "";
+			}
+		}
+
+		public class Nve : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.NVE18;
+				return "";
+			}
+		}
+
+		public class Plan : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.PLANET;
+				return "";
+			}
+		}
+
+		public class Postnet : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.POSTNET;
+				return "";
+			}
+		}
+
+		public class Pdf : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.PDF417;
+				return "";
+			}
+		}
+
+		public class Pdft : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.PDF417TRUNC;
+				return "";
+			}
+		}
+
+		public class Qr : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.QRCODE;
+				return "";
+			}
+		}
+
+		public class Rm4 : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.RM4SCC;
+				return "";
+			}
+		}
+
+		public class UpcA : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.UPCA;
+				return "";
+			}
+		}
+
+		public class UpcE : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.UPCE;
+				return "";
+			}
+		}
+
+		public class Usps : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.ONECODE;
+				return "";
+			}
+		}
+
+		public class Pls : BarcodeBase
+		{
+			protected override string encode( string data )
+			{
+				my_symbology = zint.Barcode.PLESSEY;
+				return "";
+			}
+		}
+
+
+		/**
+		 * Base class for Zint backend barcodes
+		 */
+		public abstract class BarcodeBase : glbarcode.Barcode
+		{
+
+			private const int W_DEFAULT = 144;
+			private const int H_DEFAULT =  72;
+
+
+			protected int my_symbology;
+
+
+			/**
+			 * Zint Barcode data validation method
+			 */
+			protected override bool validate( string data )
+			{
+				if (data.length == 0)
+				{
+					return false;
+				}
+
+				return true;
+			}
+
+
+			/**
+			 * Zint Barcode vectorization method
+			 */
+			protected override void vectorize( string coded_data, string data, string text )
+			{
+				/*
+				 * First encode using Zint barcode library.
+				 */
+				if ( w == 0 )
+				{
+					w = W_DEFAULT;
+				}
+				if ( h == 0 )
+				{
+					h = H_DEFAULT;
+				}
+
+				zint.Symbol symbol = new zint.Symbol();
+
+				symbol.symbology = my_symbology;
+
+				if ( symbol.Encode( data, 0 ) != 0 )
+				{
+					debug( "Zint::ZBarcode_Encode:  %s\n", symbol.errtxt );
+					is_data_valid = false;
+					return;
+				}
+
+				symbol.show_hrt = text_flag ? 1 : 0;
+
+				if ( symbol.Render( (float)w, (float)h ) == 0 )
+				{
+					message( "Zint::ZBarcode_Render:  %s\n", symbol.errtxt );
+					is_data_valid = false;
+					return;
+				}
+
+
+				/*
+				 * Now do the actual vectorization.
+				 */
+				zint.Render *render = symbol.rendered;
+
+				for ( zint.RenderLine *zline = render->lines; zline != null; zline = zline->next )
+				{
+					add_box( zline->x, zline->y, zline->width, zline->length );
+				}
+
+				for ( zint.RenderRing *zring = render->rings; zring != null; zring = zring->next )
+				{
+					add_ring( zring->x, zring->y, zring->radius, zring->line_width );
+				}
+
+				for ( zint.RenderHexagon *zhexagon = render->hexagons; zhexagon != null; zhexagon = zhexagon->next )
+				{
+					add_hexagon( zhexagon->x, zhexagon->y, 2.89 );
+				}
+
+				if(text_flag)
+				{
+					for ( zint.RenderString *zstring = render->strings; zstring != null; zstring = zstring->next )
+					{
+						add_string( zstring->x, zstring->y, zstring->fsize, zstring->text );
+					}
+				}
+
+			}
+
+
+		}
+
+	}
+
+}
+
+#endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]