You've already forked lazarus-ccr
lazbarcodes: Maxicode working. Add Zint manual.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8228 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -636,6 +636,7 @@ object MainForm: TMainForm
|
|||||||
Width = 152
|
Width = 152
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
BorderSpacing.Top = 2
|
BorderSpacing.Top = 2
|
||||||
|
DropDownCount = 24
|
||||||
ItemHeight = 15
|
ItemHeight = 15
|
||||||
Items.Strings = (
|
Items.Strings = (
|
||||||
'004 - AFGHANISTAN'
|
'004 - AFGHANISTAN'
|
||||||
|
BIN
components/lazbarcodes/docs/zint_manual_242.pdf
Normal file
BIN
components/lazbarcodes/docs/zint_manual_242.pdf
Normal file
Binary file not shown.
@ -614,17 +614,18 @@ type
|
|||||||
FPrimary: String;
|
FPrimary: String;
|
||||||
FCountryCode: Integer;
|
FCountryCode: Integer;
|
||||||
FServiceCode: Integer;
|
FServiceCode: Integer;
|
||||||
function GetPrimary: String;
|
|
||||||
procedure SetCountryCode(AValue: Integer);
|
procedure SetCountryCode(AValue: Integer);
|
||||||
procedure SetMode(AValue: TBarcodeMaxicodeMode);
|
procedure SetMode(AValue: TBarcodeMaxicodeMode);
|
||||||
procedure SetPostCode(AValue: String);
|
procedure SetPostCode(AValue: String);
|
||||||
procedure SetPrimary(AValue: String);
|
procedure SetPrimary(AValue: String);
|
||||||
procedure SetServiceCode(AValue: Integer);
|
procedure SetServiceCode(AValue: Integer);
|
||||||
protected
|
protected
|
||||||
|
function BuildPrimary: String;
|
||||||
function CalcFactor(AWidth, AHeight: Integer): Integer; override;
|
function CalcFactor(AWidth, AHeight: Integer): Integer; override;
|
||||||
procedure CalcSize(AFactor: Integer;
|
procedure CalcSize(AFactor: Integer;
|
||||||
out ATotalWidth, ATotalHeight, ASymbolWidth, ASymbolHeight,
|
out ATotalWidth, ATotalHeight, ASymbolWidth, ASymbolHeight,
|
||||||
ATextWidth, ATextHeight, ABorderWidth, AWhitespaceWidth: Integer); override;
|
ATextWidth, ATextHeight, ABorderWidth, AWhitespaceWidth: Integer); override;
|
||||||
|
function CalcSymbolStart(ABorderWidth, AWhiteSpaceWidth: Integer): Integer; override;
|
||||||
procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: Integer;
|
procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: Integer;
|
||||||
WithThemeSpace: Boolean); override;
|
WithThemeSpace: Boolean); override;
|
||||||
procedure DrawBarcode(ADrawer: TBasicBarcodeDrawer; AFactor: Double); override;
|
procedure DrawBarcode(ADrawer: TBasicBarcodeDrawer; AFactor: Double); override;
|
||||||
@ -636,7 +637,7 @@ type
|
|||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
published
|
published
|
||||||
property Mode: TBarcodeMaxicodeMode read FMode write SetMode default mcmAuto;
|
property Mode: TBarcodeMaxicodeMode read FMode write SetMode default mcmAuto;
|
||||||
property Primary: String read GetPrimary write SetPrimary;
|
property Primary: String read FPrimary write SetPrimary;
|
||||||
property Postcode: String read FPostCode write SetPostcode;
|
property Postcode: String read FPostCode write SetPostcode;
|
||||||
property CountryCode: Integer read FCountryCode write SetCountryCode default 0;
|
property CountryCode: Integer read FCountryCode write SetCountryCode default 0;
|
||||||
property ServiceCode: Integer read FServiceCode write SetServiceCode default 0;
|
property ServiceCode: Integer read FServiceCode write SetServiceCode default 0;
|
||||||
@ -3223,6 +3224,45 @@ begin
|
|||||||
FShowHumanReadableText := false;
|
FShowHumanReadableText := false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TBarcodeMaxiCode.BuildPrimary: String;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
isMode2: Boolean;
|
||||||
|
postcodeStr, countrycodeStr, servicecodeStr: String;
|
||||||
|
begin
|
||||||
|
Result := '';
|
||||||
|
isMode2 := true;
|
||||||
|
case FMode of
|
||||||
|
mcmAuto:
|
||||||
|
begin
|
||||||
|
for i := 1 to Length(FPostCode) do
|
||||||
|
if not (UpCase(FPostcode[i]) in ['0'..'9']) then
|
||||||
|
begin
|
||||||
|
isMode2 := false;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
if isMode2 and (Length(FPostCode) > 9) then
|
||||||
|
SetLength(FPostcode, 9)
|
||||||
|
else if (not isMode2) and (Length(FPostCode) > 6) then
|
||||||
|
SetLength(FPostCode, 6);
|
||||||
|
end;
|
||||||
|
mcmMode2:
|
||||||
|
if (Length(FPostCode) > 9) then
|
||||||
|
SetLength(FPostcode, 9);
|
||||||
|
mcmMode3:
|
||||||
|
if (Length(FPostcode) > 6) then
|
||||||
|
SetLength(FPostcode, 6);
|
||||||
|
else
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
postcodeStr := FPostcode + StringOfChar(' ', 9 - Length(FPostCode));
|
||||||
|
countrycodeStr := FormatFloat('000', FCountryCode);
|
||||||
|
servicecodeStr := FormatFloat('000', FServiceCode);
|
||||||
|
|
||||||
|
Result := postcodeStr + countrycodeStr + servicecodeStr;
|
||||||
|
end;
|
||||||
|
|
||||||
{ Calculates the pixel multiplication factor to fill the entire control as much
|
{ Calculates the pixel multiplication factor to fill the entire control as much
|
||||||
as possible. Needed when FScale = 0. Considers only integer multiples of
|
as possible. Needed when FScale = 0. Considers only integer multiples of
|
||||||
pixels. For MaxiCode the aspect ratio (height/width) is constant 26.93mm/28.14mm.}
|
pixels. For MaxiCode the aspect ratio (height/width) is constant 26.93mm/28.14mm.}
|
||||||
@ -3265,6 +3305,11 @@ begin
|
|||||||
ATotalHeight := ASymbolHeight + 2 * ABorderWidth;
|
ATotalHeight := ASymbolHeight + 2 * ABorderWidth;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TBarcodeMaxicode.CalcSymbolStart(ABorderWidth, AWhiteSpaceWidth: Integer): Integer;
|
||||||
|
begin
|
||||||
|
Result := ABorderWidth;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBarcodeMaxiCode.CalculatePreferredSize(var PreferredWidth, PreferredHeight: Integer;
|
procedure TBarcodeMaxiCode.CalculatePreferredSize(var PreferredWidth, PreferredHeight: Integer;
|
||||||
WithThemeSpace: Boolean);
|
WithThemeSpace: Boolean);
|
||||||
var
|
var
|
||||||
@ -3335,35 +3380,11 @@ begin
|
|||||||
Result.CY := 88;
|
Result.CY := 88;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBarcodeMaxiCode.GetPrimary: String;
|
|
||||||
var
|
|
||||||
postcodeStr, countrycodeStr, serviceCodeStr: String;
|
|
||||||
postcodeLen: Integer;
|
|
||||||
begin
|
|
||||||
case FMode of
|
|
||||||
mcmAuto:
|
|
||||||
Result := FPrimary;
|
|
||||||
mcmMode2, mcmMode3:
|
|
||||||
begin
|
|
||||||
if FMode = mcmMode2 then
|
|
||||||
postcodeLen := 9
|
|
||||||
else
|
|
||||||
postcodeLen := 6;
|
|
||||||
postcodestr := FPostcode + StringOfChar(' ', postcodeLen - Length(FPostCode));
|
|
||||||
countrycodestr := FormatFloat('000', FCountryCode);
|
|
||||||
servicecodestr := FormatFloat('000', FServiceCode);
|
|
||||||
Result := postcodestr + countrycodestr + servicecodestr;
|
|
||||||
end;
|
|
||||||
else
|
|
||||||
Result := '';
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TBarcodeMaxiCode.InternalGenerate: Integer;
|
function TBarcodeMaxiCode.InternalGenerate: Integer;
|
||||||
begin
|
begin
|
||||||
FSymbol^.option_1 := ord(FMode);
|
FSymbol^.option_1 := ord(FMode);
|
||||||
if FMode in [mcmAuto, mcmMode2, mcmMode3] then
|
if FMode in [mcmAuto, mcmMode2, mcmMode3] then
|
||||||
FSymbol^.SetPrimary(GetPrimary);
|
FSymbol^.SetPrimary(FPrimary);
|
||||||
|
|
||||||
Result := maxicode(FSymbol, @FText[1], Length(FText));
|
Result := maxicode(FSymbol, @FText[1], Length(FText));
|
||||||
end;
|
end;
|
||||||
@ -3467,8 +3488,11 @@ begin
|
|||||||
if (AValue > 0) and (AValue < 1000) then
|
if (AValue > 0) and (AValue < 1000) then
|
||||||
begin
|
begin
|
||||||
FCountryCode := AValue;
|
FCountryCode := AValue;
|
||||||
if FMode in [mcmMode2, mcmMode3] then
|
if FMode in [mcmAuto, mcmMode2, mcmMode3] then
|
||||||
|
begin
|
||||||
|
FPrimary := BuildPrimary;
|
||||||
GenerateAndInvalidate;
|
GenerateAndInvalidate;
|
||||||
|
end;
|
||||||
end else
|
end else
|
||||||
raise Exception.Create('Maxicode country code must be > 0 and < 1000');
|
raise Exception.Create('Maxicode country code must be > 0 and < 1000');
|
||||||
end;
|
end;
|
||||||
@ -3477,6 +3501,8 @@ procedure TBarcodeMaxicode.SetMode(AValue: TBarcodeMaxicodeMode);
|
|||||||
begin
|
begin
|
||||||
if FMode = AValue then exit;
|
if FMode = AValue then exit;
|
||||||
FMode := AValue;
|
FMode := AValue;
|
||||||
|
if FMode in [mcmAuto, mcmMode2, mcmMode3] then
|
||||||
|
FPrimary := BuildPrimary;
|
||||||
GenerateAndInvalidate;
|
GenerateAndInvalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -3484,14 +3510,20 @@ procedure TBarcodeMaxicode.SetPostcode(AValue: String);
|
|||||||
begin
|
begin
|
||||||
if AValue = FPostcode then exit;
|
if AValue = FPostcode then exit;
|
||||||
FPostcode := AValue;
|
FPostcode := AValue;
|
||||||
if FMode in [mcmMode2, mcmMode3] then
|
if FMode in [mcmAuto, mcmMode2, mcmMode3] then
|
||||||
|
begin
|
||||||
|
FPrimary := BuildPrimary;
|
||||||
GenerateAndInvalidate;
|
GenerateAndInvalidate;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBarcodeMaxicode.SetPrimary(AValue: String);
|
procedure TBarcodeMaxicode.SetPrimary(AValue: String);
|
||||||
begin
|
begin
|
||||||
if AValue = FPrimary then exit;
|
if AValue = FPrimary then exit;
|
||||||
FPrimary := AValue;
|
FPrimary := AValue;
|
||||||
|
FPostCode := Copy(FPrimary, 1, 9);
|
||||||
|
FCountryCode := StrToIntDef(Copy(FPrimary, 10, 3), 0);
|
||||||
|
FServiceCode := StrToIntDef(Copy(FPrimary, 13, 3), 0);
|
||||||
if FMode = mcmAuto then
|
if FMode = mcmAuto then
|
||||||
GenerateAndInvalidate;
|
GenerateAndInvalidate;
|
||||||
end;
|
end;
|
||||||
@ -3502,8 +3534,11 @@ begin
|
|||||||
if (AValue > 0) and (AValue < 1000) then
|
if (AValue > 0) and (AValue < 1000) then
|
||||||
begin
|
begin
|
||||||
FServiceCode := AValue;
|
FServiceCode := AValue;
|
||||||
if FMode in [mcmMode2, mcmMode3] then
|
if FMode in [mcmAuto, mcmMode2, mcmMode3] then
|
||||||
|
begin
|
||||||
|
FPrimary := BuildPrimary;
|
||||||
GenerateAndInvalidate;
|
GenerateAndInvalidate;
|
||||||
|
end;
|
||||||
end else
|
end else
|
||||||
raise Exception.Create('Maxicode Service code must be > 0 and < 1000');
|
raise Exception.Create('Maxicode Service code must be > 0 and < 1000');
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user