2010-11-10 13:03 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

* contrib/hbzebra/hbzebra.hbp
  + contrib/hbzebra/d_hpdf.c
  + contrib/hbzebra/d_win.c
  + contrib/hbzebra/tests/testhpdf.prg
  + contrib/hbzebra/tests/testwin.prg
    + Added Windows DC renderer
    + Added libharu renderer
    ; TODO: rework current rendering solution. Thinking about
            callback based solution, to give it a smoother layout.
            Current system has too much interdependencies and 
            too much redundancy even in renderer "plugins".

  * utils/hbmk2/hbmk2.prg
    + Readded PathNormalize() calls missed after prev modif.
This commit is contained in:
Viktor Szakats
2010-11-10 12:06:28 +00:00
parent d9384a3de1
commit f675856f4a
7 changed files with 455 additions and 1 deletions

View File

@@ -16,6 +16,22 @@
The license applies to all entries newer than 2009-04-28.
*/
2010-11-10 13:03 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbzebra/hbzebra.hbp
+ contrib/hbzebra/d_hpdf.c
+ contrib/hbzebra/d_win.c
+ contrib/hbzebra/tests/testhpdf.prg
+ contrib/hbzebra/tests/testwin.prg
+ Added Windows DC renderer
+ Added libharu renderer
; TODO: rework current rendering solution. Thinking about
callback based solution, to give it a smoother layout.
Current system has too much interdependencies and
too much redundancy even in renderer "plugins".
* utils/hbmk2/hbmk2.prg
+ Readded PathNormalize() calls missed after prev modif.
2010-11-10 02:04 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* utils/hbmk2/hbmk2.prg
! Reworked logic calculating link contents (for -ln= options)

View File

@@ -0,0 +1,103 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Zebra barcode library
*
* Copyright 2010 Viktor Szakats (harbour.01 syenar.hu)
* Copyright 2010 Mindaugas Kavaliauskas <dbtopas at dbtopas.lt>
* www - http://harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#include "hbzebra.h"
#include "hpdf.h"
int hb_zebra_draw_hpdf( PHB_ZEBRA pZebra, HPDF_Page hPage, double dX, double dY, double dWidth, double dHeight, int iFlags )
{
double dLast;
HB_SIZE n, nLen, nCount;
HB_BOOL fBit, fLastBit;
HB_SYMBOL_UNUSED( iFlags );
if( pZebra->iError != 0 )
return HB_ZEBRA_ERROR_INVALIDZEBRA;
HPDF_Page_SetLineWidth( hPage, 0.1 ); /* Standard line width */
nLen = hb_bitbuffer_len( pZebra->pBits );
fLastBit = hb_bitbuffer_get( pZebra->pBits, 0 );
dLast = dX;
nCount = 1;
for( n = 1; n < nLen; n++ )
{
fBit = hb_bitbuffer_get( pZebra->pBits, n );
if( fBit != fLastBit )
{
if( fLastBit )
HPDF_Page_Rectangle( hPage, ( HPDF_REAL ) dLast, ( HPDF_REAL ) dY, ( HPDF_REAL ) ( dWidth * nCount ), ( HPDF_REAL ) dHeight );
dLast += dWidth * nCount;
nCount = 0;
fLastBit = fBit;
}
nCount++;
}
if( fLastBit )
HPDF_Page_Rectangle( hPage, ( HPDF_REAL ) dLast, ( HPDF_REAL ) dY, ( HPDF_REAL ) ( dWidth * nCount ), ( HPDF_REAL ) dHeight );
HPDF_Page_FillStroke( hPage );
return 0;
}
HB_FUNC( HB_ZEBRA_DRAW_HPDF )
{
PHB_ZEBRA pZebra = hb_zebra_param( 1 );
if( pZebra )
{
hb_retni( hb_zebra_draw_hpdf( pZebra, ( HPDF_Page ) hb_parptr( 2 ), hb_parnd( 3 ), hb_parnd( 4 ), hb_parnd( 5 ), hb_parnd( 6 ), hb_parni( 7 ) ) );
}
}

View File

@@ -0,0 +1,116 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Zebra barcode library
*
* Copyright 2010 Viktor Szakats (harbour.01 syenar.hu)
* Copyright 2010 Mindaugas Kavaliauskas <dbtopas at dbtopas.lt>
* www - http://harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#include "hbzebra.h"
#include "hbwapi.h"
int hb_zebra_draw_wapi( PHB_ZEBRA pZebra, HDC hDC, HBRUSH hBrush, double dX, double dY, double dWidth, double dHeight, int iFlags )
{
double dLast;
HB_SIZE n, nLen, nCount;
HB_BOOL fBit, fLastBit;
RECT rect;
HB_SYMBOL_UNUSED( iFlags );
if( pZebra->iError != 0 )
return HB_ZEBRA_ERROR_INVALIDZEBRA;
nLen = hb_bitbuffer_len( pZebra->pBits );
fLastBit = hb_bitbuffer_get( pZebra->pBits, 0 );
dLast = dX;
nCount = 1;
for( n = 1; n < nLen; n++ )
{
fBit = hb_bitbuffer_get( pZebra->pBits, n );
if( fBit != fLastBit )
{
if( fLastBit )
{
rect.left = ( LONG ) dLast;
rect.top = ( LONG ) dY;
rect.right = ( LONG ) ( dLast + dWidth * nCount );
rect.bottom = ( LONG ) ( dY + dHeight );
FillRect( hDC, &rect, hBrush );
}
dLast += dWidth * nCount;
nCount = 0;
fLastBit = fBit;
}
nCount++;
}
if( fLastBit )
{
rect.left = ( LONG ) dLast;
rect.top = ( LONG ) dY;
rect.right = ( LONG ) ( dLast + dWidth * nCount );
rect.bottom = ( LONG ) ( dY + dHeight );
FillRect( hDC, &rect, hBrush );
}
return 0;
}
HB_FUNC( HB_ZEBRA_DRAW_WAPI )
{
PHB_ZEBRA pZebra = hb_zebra_param( 1 );
if( pZebra )
{
HDC hDC = hbwapi_par_HDC( 2 );
HBRUSH hBrush = hbwapi_par_HBRUSH( 8 );
if( hDC && hBrush )
{
hb_retni( hb_zebra_draw_wapi( pZebra, hDC, hBrush, hb_parnd( 3 ), hb_parnd( 4 ), hb_parnd( 5 ), hb_parnd( 6 ), hb_parni( 7 ) ) );
}
}
}

View File

@@ -38,3 +38,19 @@ msi.c
{HBMK_HAS_CAIRO}cairo.c
{HBMK_HAS_CAIRO}../hbcairo/hbcairo.hbc
{allwin}d_win.c
{allwin}../hbwin/hbwin.hbc
-depoptional=libharu:yes
-depkeyhead=libharu:hpdf.h
-depcontrol=libharu:local{HB_BUILD_3RDEXT='no'}
-depcontrol=libharu:${HB_WITH_LIBHARU}
-depincpath=libharu:/usr/include
-depincpath=libharu:/usr/local/include
-depincpathlocal=libharu:../hbhpdf/3rd/libhpdf
-depimplibs=libharu:../libhpdf.dll
-depimplibs=libharu:../lib_dll/libhpdf.dll
-depfinish=libharu
{HBMK_HAS_LIBHARU}d_hpdf.c

View File

@@ -0,0 +1,84 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
*
* Copyright 2010 Viktor Szakats (harbour.01 syenar.hu)
* www - http://harbour-project.org
*
*/
#include "hbzebra.ch"
#include "harupdf.ch"
PROCEDURE Main()
LOCAL pdf
LOCAL page
pdf := HPDF_New()
page := HPDF_AddPage( pdf )
HPDF_Page_SetSize( page, HPDF_PAGE_SIZE_A4, HPDF_PAGE_PORTRAIT )
HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "Helvetica", NIL ), 12 )
DrawBarcode( page, 20, 1, "EAN13", "477012345678" )
DrawBarcode( page, 40, 1, "EAN8", "1234567" )
DrawBarcode( page, 60, 1, "UPCA", "01234567891" )
DrawBarcode( page, 80, 1, "UPCE", "123456" )
DrawBarcode( page, 100, 1, "CODE39", "ABC123" )
DrawBarcode( page, 120, 1, "CODE39", "ABC123", HB_ZEBRA_FLAG_CHECKSUM )
DrawBarcode( page, 140, 0.5, "CODE39", "ABC123", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE2_5 )
DrawBarcode( page, 160, 1, "CODE39", "ABC123", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )
DrawBarcode( page, 180, 1, "ITF", "1234", HB_ZEBRA_FLAG_WIDE3 )
DrawBarcode( page, 200, 1, "ITF", "12345678901", HB_ZEBRA_FLAG_CHECKSUM )
DrawBarcode( page, 220, 1, "MSI", "1234" )
DrawBarcode( page, 240, 1, "MSI", "1234", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )
DrawBarcode( page, 260, 1, "MSI", "1234567", HB_ZEBRA_FLAG_CHECKSUM )
DrawBarcode( page, 280, 1, "CODABAR", "40156", HB_ZEBRA_FLAG_WIDE3 )
DrawBarcode( page, 300, 1, "CODABAR", "-1234", HB_ZEBRA_FLAG_WIDE3 )
DrawBarcode( page, 320, 1, "CODE93", "ABC-123" )
DrawBarcode( page, 340, 1, "CODE93", "TEST93" )
DrawBarcode( page, 360, 1, "CODE11", "12", HB_ZEBRA_FLAG_WIDE3 )
DrawBarcode( page, 380, 1, "CODE11", "1234567890", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )
DrawBarcode( page, 400, 1, "CODE128", "Code 128")
DrawBarcode( page, 420, 1, "CODE128", "1234567890")
DrawBarcode( page, 440, 1, "CODE128", "Wikipedia")
? HPDF_SaveToFile( pdf, "testhpdf.pdf" )
RETURN
PROCEDURE DrawBarcode( page, nY, nLineWidth, cType, cCode, nFlags )
LOCAL hZebra
SWITCH cType
CASE "EAN13" ; hZebra := hb_zebra_create_ean13( cCode, nFlags ) ; EXIT
CASE "EAN8" ; hZebra := hb_zebra_create_ean8( cCode, nFlags ) ; EXIT
CASE "UPCA" ; hZebra := hb_zebra_create_upca( cCode, nFlags ) ; EXIT
CASE "UPCE" ; hZebra := hb_zebra_create_upce( cCode, nFlags ) ; EXIT
CASE "CODE39" ; hZebra := hb_zebra_create_code39( cCode, nFlags ) ; EXIT
CASE "ITF" ; hZebra := hb_zebra_create_itf( cCode, nFlags ) ; EXIT
CASE "MSI" ; hZebra := hb_zebra_create_msi( cCode, nFlags ) ; EXIT
CASE "CODABAR" ; hZebra := hb_zebra_create_codabar( cCode, nFlags ) ; EXIT
CASE "CODE93" ; hZebra := hb_zebra_create_code93( cCode, nFlags ) ; EXIT
CASE "CODE11" ; hZebra := hb_zebra_create_code11( cCode, nFlags ) ; EXIT
CASE "CODE128" ; hZebra := hb_zebra_create_code128( cCode, nFlags ) ; EXIT
ENDSWITCH
IF hZebra != NIL
IF hb_zebra_geterror( hZebra ) == 0
HPDF_Page_BeginText( page )
HPDF_Page_TextOut( page, 40, nY, cType )
HPDF_Page_TextOut( page, 150, nY, hb_zebra_getcode( hZebra ) )
HPDF_Page_EndText( page )
hb_zebra_draw_hpdf( hZebra, page, 300, nY, nLineWidth, 16 )
ELSE
? "Type", cType, "Code", cCode, "Error", hb_zebra_geterror( hZebra )
ENDIF
hb_zebra_destroy( hZebra )
ELSE
? "Invalid barcode type", cType
ENDIF
RETURN

View File

@@ -0,0 +1,119 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
*
* Copyright 2010 Viktor Szakats (harbour.01 syenar.hu)
* www - http://harbour-project.org
*
*/
#include "hbzebra.ch"
#include "hbwin.ch"
PROCEDURE Main()
LOCAL hDC
LOCAL pDEVMODE := __wapi_DEVMODE_New( "Microsoft XPS Document Writer" )
LOCAL hOBJECT
__wapi_DEVMODE_Set( pDEVMODE, {;
"dmPaperSize" => WIN_DMPAPER_A4,;
"dmOrientation" => WIN_DMORIENT_PORTRAIT } )
hDC := wapi_CreateDC( NIL, "Microsoft XPS Document Writer", NIL, pDEVMODE )
IF ! Empty( hDC )
wapi_SetMapMode( hDC, WIN_MM_TEXT )
IF wapi_StartDoc( hDC, { "lpszDocName" => "(barcode test)" } ) > 0
wapi_SetBkMode( hDC, WIN_TRANSPARENT )
IF wapi_StartPage( hDC ) > 0
hOBJECT := wapi_CreateFont( 96,;
42,;
NIL,;
NIL,;
WIN_FW_NORMAL,;
.F.,;
.F.,;
NIL,;
WIN_ANSI_CHARSET,;
NIL,;
NIL,;
NIL,;
NIL,;
"Arial" )
wapi_SelectObject( hDC, hOBJECT )
DrawBarcode( hDC, 20, 1, "EAN13", "477012345678" )
DrawBarcode( hDC, 40, 1, "EAN8", "1234567" )
DrawBarcode( hDC, 60, 1, "UPCA", "01234567891" )
DrawBarcode( hDC, 80, 1, "UPCE", "123456" )
DrawBarcode( hDC, 100, 1, "CODE39", "ABC123" )
DrawBarcode( hDC, 120, 1, "CODE39", "ABC123", HB_ZEBRA_FLAG_CHECKSUM )
DrawBarcode( hDC, 140, 0.5, "CODE39", "ABC123", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE2_5 )
DrawBarcode( hDC, 160, 1, "CODE39", "ABC123", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )
DrawBarcode( hDC, 180, 1, "ITF", "1234", HB_ZEBRA_FLAG_WIDE3 )
DrawBarcode( hDC, 200, 1, "ITF", "12345678901", HB_ZEBRA_FLAG_CHECKSUM )
DrawBarcode( hDC, 220, 1, "MSI", "1234" )
DrawBarcode( hDC, 240, 1, "MSI", "1234", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )
DrawBarcode( hDC, 260, 1, "MSI", "1234567", HB_ZEBRA_FLAG_CHECKSUM )
DrawBarcode( hDC, 280, 1, "CODABAR", "40156", HB_ZEBRA_FLAG_WIDE3 )
DrawBarcode( hDC, 300, 1, "CODABAR", "-1234", HB_ZEBRA_FLAG_WIDE3 )
DrawBarcode( hDC, 320, 1, "CODE93", "ABC-123" )
DrawBarcode( hDC, 340, 1, "CODE93", "TEST93" )
DrawBarcode( hDC, 360, 1, "CODE11", "12", HB_ZEBRA_FLAG_WIDE3 )
DrawBarcode( hDC, 380, 1, "CODE11", "1234567890", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )
DrawBarcode( hDC, 400, 1, "CODE128", "Code 128")
DrawBarcode( hDC, 420, 1, "CODE128", "1234567890")
DrawBarcode( hDC, 440, 1, "CODE128", "Wikipedia")
wapi_EndPage( hDC )
ENDIF
wapi_EndDoc( hDC )
ENDIF
ENDIF
RETURN
#define _SCALE_ 7.2
PROCEDURE DrawBarcode( hDC, nY, nLineWidth, cType, cCode, nFlags )
LOCAL hZebra
nY *= _SCALE_
nLineWidth *= _SCALE_
SWITCH cType
CASE "EAN13" ; hZebra := hb_zebra_create_ean13( cCode, nFlags ) ; EXIT
CASE "EAN8" ; hZebra := hb_zebra_create_ean8( cCode, nFlags ) ; EXIT
CASE "UPCA" ; hZebra := hb_zebra_create_upca( cCode, nFlags ) ; EXIT
CASE "UPCE" ; hZebra := hb_zebra_create_upce( cCode, nFlags ) ; EXIT
CASE "CODE39" ; hZebra := hb_zebra_create_code39( cCode, nFlags ) ; EXIT
CASE "ITF" ; hZebra := hb_zebra_create_itf( cCode, nFlags ) ; EXIT
CASE "MSI" ; hZebra := hb_zebra_create_msi( cCode, nFlags ) ; EXIT
CASE "CODABAR" ; hZebra := hb_zebra_create_codabar( cCode, nFlags ) ; EXIT
CASE "CODE93" ; hZebra := hb_zebra_create_code93( cCode, nFlags ) ; EXIT
CASE "CODE11" ; hZebra := hb_zebra_create_code11( cCode, nFlags ) ; EXIT
CASE "CODE128" ; hZebra := hb_zebra_create_code128( cCode, nFlags ) ; EXIT
ENDSWITCH
IF hZebra != NIL
IF hb_zebra_geterror( hZebra ) == 0
wapi_TextOut( hDC, 40 * _SCALE_, nY, cType )
wapi_TextOut( hDC, 150 * _SCALE_, nY, hb_zebra_getcode( hZebra ) )
hb_zebra_draw_wapi( hZebra, hDC, 300 * _SCALE_, nY, nLineWidth, 16 * _SCALE_,, wapi_CreateSolidBrush( 0 ) )
ELSE
? "Type", cType, "Code", cCode, "Error", hb_zebra_geterror( hZebra )
ENDIF
hb_zebra_destroy( hZebra )
ELSE
? "Invalid barcode type", cType
ENDIF
RETURN

View File

@@ -6353,7 +6353,7 @@ STATIC PROCEDURE DoLinkCalc( hbmk )
ENDIF
hb_FNameSplit( hbmk[ _HBMK_cPROGNAME ],, @cName, @cExt )
tmp := { /* <cNewFileName> */ PathMakeAbsolute( tmp, FNameDirGet( hbmk[ _HBMK_cPROGNAME ] ) ),;
tmp := { /* <cNewFileName> */ PathNormalize( PathMakeAbsolute( tmp, FNameDirGet( hbmk[ _HBMK_cPROGNAME ] ) ) ),;
/* <cTargetFileName> */ hb_FNameMerge( cDir, cName, cExt ) }
NEXT