/******************************************************************************
* *
* M O D U L E D E F I N E *
* *
******************************************************************************/
#define CPOST_C
/******************************************************************************
* *
* C O M P I L E R D E F I N E D I N C L U D E F I L E S *
* *
******************************************************************************/
#include <string.h>
/******************************************************************************
* *
* U S E R D E F I N E D I N C L U D E F I L E S *
* *
******************************************************************************/
#include "Common.h"
#include "XGraphic.h"
#include "Barcode.h"
/******************************************************************************
* *
* L O C A L D E F I N E S *
* *
******************************************************************************/
#define QUIET_MU 0
#define TEXT_DIS 5
/******************************************************************************
* *
* L O C A L T Y P E D E F S *
* *
******************************************************************************/
/* None */
/******************************************************************************
* *
* L O C A L F U N C T I O N P R O T O T Y P E S *
* *
******************************************************************************/
/* None */
/******************************************************************************
* *
* L O C A L I N I T I A L I Z E D D A T A D E F I N I T I O N S *
* *
******************************************************************************/
CONST STATIC BYTE Chara[10][5] =
{
0,0,1,1,0,
1,0,0,0,1,
0,1,0,0,1,
1,1,0,0,0,
0,0,1,0,1,
1,0,1,0,0,
0,1,1,0,0,
0,0,0,1,1,
1,0,0,1,0,
0,1,0,1,0
};
/******************************************************************************
* *
* L O C A L U N I T I A L I Z E D D A T A D E F I N I T I O N S *
* *
******************************************************************************/
/******************************************************************************
*
* Function:
*
*
* Description:
*
*
* Input:
* None
*
* Output:
* None.
*
******************************************************************************/
/*-----------------02-09-99 09:30-------------------
local globle variable
--------------------------------------------------*/
INT CPost(_BarCodeAttr *psBarCodeAttr)
{
_BarAttr sBarAttr;
_TextAttr sTextAttr;
BYTE aValue[12], aHum[12];
INT i, j, k, iQuiet;
BYTE *pText, *pValue;
INT iFontLen, iBarCodeLen;
INT iTemp_X,iTemp_Y; //alexma
sBarAttr.psImageBuffer = psBarCodeAttr->psImageBuffer;
sBarAttr.iType = DRAW_BAR;
pText = psBarCodeAttr->pExp;
sTextAttr.eLanguage = psBarCodeAttr->eLanguage;
sTextAttr.ePutWay = psBarCodeAttr->ePutWay;
iQuiet = QUIET_MU * psBarCodeAttr->iNarrow;
/* check digit character */
j = 0;
while ( *pText != 0 )
{
if ( *pText < 48 || *pText > 57) /* the character must be number */
{
return FALSE;
}
aHum[j] = *pText;
aValue[j] = *pText - 48;
pText += 1;
j += 1;
if ( j > 11 )
{
return FALSE;
}
}
if ( j == 6 || j == 11 ) /* the total character must be 6 or 11 */
{
aHum[j] = 0;
}
else
{
return FALSE;
}
/* START character */
switch ( psBarCodeAttr->iRotation )
{
case 0:
{
sBarAttr.iHeight = psBarCodeAttr->iHeight;
sBarAttr.sCoord.iX = psBarCodeAttr->sCoord.iX + iQuiet;
sBarAttr.sCoord.iY = psBarCodeAttr->sCoord.iY;
//alexma
iTemp_X = sBarAttr.sCoord.iX;
iTemp_Y = sBarAttr.sCoord.iY;
sBarAttr.iWidth = psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX += psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX += psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
sTextAttr.sCoord.iX = psBarCodeAttr->sCoord.iX + iQuiet;
sTextAttr.sCoord.iY = psBarCodeAttr->sCoord.iY + psBarCodeAttr->iHeight + TEXT_DIS;
break;
}
case 90:
{
sBarAttr.iWidth = psBarCodeAttr->iHeight;
sBarAttr.sCoord.iX = psBarCodeAttr->sCoord.iX - psBarCodeAttr->iHeight;
sBarAttr.sCoord.iY = psBarCodeAttr->sCoord.iY + iQuiet;
//alexma
iTemp_X = sBarAttr.sCoord.iX;
iTemp_Y = sBarAttr.sCoord.iY;
sBarAttr.iHeight = psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY += psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY += psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
sTextAttr.sCoord.iX = psBarCodeAttr->sCoord.iX - psBarCodeAttr->iHeight - TEXT_DIS;
sTextAttr.sCoord.iY = psBarCodeAttr->sCoord.iY + iQuiet;
break;
}
case 180:
{
sBarAttr.iHeight = psBarCodeAttr->iHeight;
sBarAttr.sCoord.iX = psBarCodeAttr->sCoord.iX - iQuiet;
sBarAttr.sCoord.iY = psBarCodeAttr->sCoord.iY - psBarCodeAttr->iHeight;
//alexma
iTemp_X = sBarAttr.sCoord.iX;
iTemp_Y = sBarAttr.sCoord.iY;
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow;
sBarAttr.iWidth = psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow;
sTextAttr.sCoord.iX = psBarCodeAttr->sCoord.iX - iQuiet;
sTextAttr.sCoord.iY = psBarCodeAttr->sCoord.iY - psBarCodeAttr->iHeight - TEXT_DIS;
break;
}
case 270:
{
sBarAttr.iWidth = psBarCodeAttr->iHeight;
sBarAttr.sCoord.iX = psBarCodeAttr->sCoord.iX;
sBarAttr.sCoord.iY = psBarCodeAttr->sCoord.iY - iQuiet;
//alexma
iTemp_X = sBarAttr.sCoord.iX;
iTemp_Y = sBarAttr.sCoord.iY;
sBarAttr.sCoord.iY -= psBarCodeAttr->iNarrow;
sBarAttr.iHeight = psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY -= psBarCodeAttr->iNarrow;
sTextAttr.sCoord.iX = psBarCodeAttr->sCoord.iX + psBarCodeAttr->iHeight + TEXT_DIS;
sTextAttr.sCoord.iY = psBarCodeAttr->sCoord.iY - iQuiet;
break;
}
}
/* human readable */
if ( psBarCodeAttr->iHuman != 0 )
{
sTextAttr.iDirection = psBarCodeAttr->iRotation;
sTextAttr.iRotation = psBarCodeAttr->iRotation;
sTextAttr.iDistance = 0;
sTextAttr.iHoriMulti = psBarCodeAttr->FontHoriMulti;
sTextAttr.iVertMulti = psBarCodeAttr->FontVertMulti;
sTextAttr.ExpLength = strlen((CHAR *)aHum);
sTextAttr.pExp = aHum;
sTextAttr.pFont = psBarCodeAttr->pFont;
sTextAttr.psImageBuffer = psBarCodeAttr->psImageBuffer;
PreviewText(&sTextAttr);
}
pValue = aValue;
switch ( psBarCodeAttr->iRotation )
{
case 0:
{
for ( k = 0 ; k < j ; k++ )
{
for ( i = 0 ; i < 6 ; i++ )
{
if ( Chara[*pValue][i] == 0 )
{
sBarAttr.iWidth = psBarCodeAttr->iNarrow;
}
else
{
sBarAttr.iWidth = psBarCodeAttr->iWide;
}
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX += sBarAttr.iWidth;
i += 1;
if ( i == 5 )
{
break;
}
if ( Chara[*pValue][i] == 0 )
{
sBarAttr.sCoord.iX += psBarCodeAttr->iNarrow;
}
else
{
sBarAttr.sCoord.iX += psBarCodeAttr->iWide;
}
}
pValue += 1;
sBarAttr.sCoord.iX += psBarCodeAttr->iNarrow;
}
break;
}
case 90:
{
for ( k = 0 ; k < j ; k++ )
{
for ( i = 0 ; i < 6 ; i++ )
{
if ( Chara[*pValue][i] == 0 )
{
sBarAttr.iHeight = psBarCodeAttr->iNarrow;
}
else
{
sBarAttr.iHeight = psBarCodeAttr->iWide;
}
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY += sBarAttr.iHeight;
i += 1;
if ( i == 5 )
{
break;
}
if ( Chara[*pValue][i] == 0 )
{
sBarAttr.sCoord.iY += psBarCodeAttr->iNarrow;
}
else
{
sBarAttr.sCoord.iY += psBarCodeAttr->iWide;
}
}
pValue += 1;
sBarAttr.sCoord.iY += psBarCodeAttr->iNarrow;
}
break;
}
case 180:
{
for ( k = 0 ; k < j ; k++ )
{
for ( i = 0 ; i < 6 ; i++ )
{
if ( Chara[*pValue][i] == 0 )
{
sBarAttr.iWidth = psBarCodeAttr->iNarrow;
}
else
{
sBarAttr.iWidth = psBarCodeAttr->iWide;
}
sBarAttr.sCoord.iX -= sBarAttr.iWidth;
DrawBar(&sBarAttr);
i += 1;
if ( i == 5 )
{
break;
}
if ( Chara[*pValue][i] == 0 )
{
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow;
}
else
{
sBarAttr.sCoord.iX -= psBarCodeAttr->iWide;
}
}
pValue += 1;
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow;
}
break;
}
case 270:
{
for ( k = 0 ; k < j ; k++ )
{
for ( i = 0 ; i < 6 ; i++ )
{
if ( Chara[*pValue][i] == 0 )
{
sBarAttr.iHeight = psBarCodeAttr->iNarrow;
}
else
{
sBarAttr.iHeight = psBarCodeAttr->iWide;
}
sBarAttr.sCoord.iY -= sBarAttr.iHeight;
DrawBar(&sBarAttr);
i += 1;
if ( i == 5 )
{
break;
}
if ( Chara[*pValue][i] == 0 )
{
sBarAttr.sCoord.iY -= psBarCodeAttr->iNarrow;
}
else
{
sBarAttr.sCoord.iY -= psBarCodeAttr->iWide;
}
}
pValue += 1;
sBarAttr.sCoord.iY -= psBarCodeAttr->iNarrow;
}
break;
}
}
/* STOP character */
switch ( psBarCodeAttr->iRotation )
{
case 0:
{
sBarAttr.iWidth = psBarCodeAttr->iWide;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX += psBarCodeAttr->iWide + psBarCodeAttr->iNarrow;
sBarAttr.iWidth = psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX += psBarCodeAttr->iNarrow;
iFontLen = sTextAttr.iRealWidth;
iBarCodeLen = sBarAttr.sCoord.iX - sTextAttr.sCoord.iX;
if ( psBarCodeAttr->iHuman == 0 ) //alexma
iBarCodeLen = sBarAttr.sCoord.iX - iTemp_X;
psBarCodeAttr->TotalWidth = iBarCodeLen;
psBarCodeAttr->TotalHeight = psBarCodeAttr->iHeight;
if ( psBarCodeAttr->iHuman != 0 )
psBarCodeAttr->TotalHeight += TEXT_DIS + sTextAttr.iRealHeight;
switch ( psBarCodeAttr->iHuman )
{
case 2:
{
if ( iFontLen/2 > iBarCodeLen/2 )
sTextAttr.sCoord.iX -= ( iFontLen/2 - iBarCodeLen/2 );
else
sTextAttr.sCoord.iX += ( iBarCodeLen/2 - iFontLen/2 );
break;
}
case 3:
{
sTextAttr.sCoord.iX = sBarAttr.sCoord.iX - iFontLen;
break;
}
}
break;
}
case 90:
{
sBarAttr.iHeight = psBarCodeAttr->iWide;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY += psBarCodeAttr->iWide + psBarCodeAttr->iNarrow;
sBarAttr.iHeight = psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY += psBarCodeAttr->iNarrow;
iFontLen = sTextAttr.iRealWidth;
iBarCodeLen = sBarAttr.sCoord.iY - sTextAttr.sCoord.iY;
if ( psBarCodeAttr->iHuman == 0 ) //alexma
iBarCodeLen = sBarAttr.sCoord.iY - iTemp_Y;
psBarCodeAttr->TotalWidth = iBarCodeLen;
psBarCodeAttr->TotalHeight = psBarCodeAttr->iHeight;
if ( psBarCodeAttr->iHuman != 0 )
psBarCodeAttr->TotalHeight += TEXT_DIS + sTextAttr.iRealHeight;
switch ( psBarCodeAttr->iHuman )
{
case 2:
{
if ( iFontLen/2 > iBarCodeLen/2 )
sTextAttr.sCoord.iY -= ( iFontLen/2 - iBarCodeLen/2 );
else
sTextAttr.sCoord.iY += ( iBarCodeLen/2 - iFontLen/2 );
break;
}
case 3:
{
sTextAttr.sCoord.iY = sBarAttr.sCoord.iY - iFontLen;
break;
}
}
break;
}
case 180:
{
sBarAttr.sCoord.iX -= psBarCodeAttr->iWide;
sBarAttr.iWidth = psBarCodeAttr->iWide;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
sBarAttr.iWidth = psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow;
iFontLen = sTextAttr.iRealWidth;
iBarCodeLen = sTextAttr.sCoord.iX - sBarAttr.sCoord.iX;
if ( psBarCodeAttr->iHuman == 0 ) //alexma
iBarCodeLen = iTemp_X - sBarAttr.sCoord.iX;
psBarCodeAttr->TotalWidth = iBarCodeLen;
psBarCodeAttr->TotalHeight = psBarCodeAttr->iHeight;
if ( psBarCodeAttr->iHuman != 0 )
psBarCodeAttr->TotalHeight += TEXT_DIS + sTextAttr.iRealHeight;
switch ( psBarCodeAttr->iHuman )
{
case 2:
{
if ( iFontLen/2 > iBarCodeLen/2 )
sTextAttr.sCoord.iX += ( iFontLen/2 - iBarCodeLen/2 );
else
sTextAttr.sCoord.iX -= ( iBarCodeLen/2 - iFontLen/2 );
break;
}
case 3:
{
sTextAttr.sCoord.iX = sBarAttr.sCoord.iX + iFontLen;
break;
}
}
break;
}
case 270:
{
sBarAttr.sCoord.iY -= psBarCodeAttr->iWide;
sBarAttr.iHeight = psBarCodeAttr->iWide;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
sBarAttr.iHeight = psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY -= psBarCodeAttr->iNarrow;
iFontLen = sTextAttr.iRealWidth;
iBarCodeLen = sTextAttr.sCoord.iY - sBarAttr.sCoord.iY;
if ( psBarCodeAttr->iHuman == 0 ) //alexma
iBarCodeLen = iTemp_Y - sBarAttr.sCoord.iY;
psBarCodeAttr->TotalWidth = iBarCodeLen;
psBarCodeAttr->TotalHeight = psBarCodeAttr->iHeight;
if ( psBarCodeAttr->iHuman != 0 )
psBarCodeAttr->TotalHeight += TEXT_DIS + sTextAttr.iRealHeight;
switch ( psBarCodeAttr->iHuman )
{
case 2:
{
if ( iFontLen/2 > iBarCodeLen/2 )
sTextAttr.sCoord.iY += ( iFontLen/2 - iBarCodeLen/2 );
else
sTextAttr.sCoord.iY -= ( iBarCodeLen/2 - iFontLen/2 );
break;
}
case 3:
{
sTextAttr.sCoord.iY = sBarAttr.sCoord.iY + iFontLen;
break;
}
}
break;
}
}
if ( psBarCodeAttr->iHuman != 0 )
{
sTextAttr.ExpLength = strlen((CHAR *)aHum);
sTextAttr.pExp = aHum;
OutText(&sTextAttr);
}
return TRUE;
}
INT PreviewCPost(_BarCodeAttr *psBarCodeAttr)
{
INT TotalChar;
TotalChar = strlen( (CHAR *)psBarCodeAttr->pExp );
if ( TotalChar != 6 && TotalChar != 11 )
{
psBarCodeAttr->TotalWidth = 0;
psBarCodeAttr->TotalHeight = 0;
return FALSE;
}
psBarCodeAttr->TotalWidth = 6 * psBarCodeAttr->iNarrow + 1 * psBarCodeAttr->iWide +
TotalChar * (4 * psBarCodeAttr->iNarrow + 2 * psBarCodeAttr->iWide ) + QUIET_MU;
psBarCodeAttr->TotalHeight = psBarCodeAttr->iHeight;
return TRUE;
}