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
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 2
|
||||
DropDownCount = 24
|
||||
ItemHeight = 15
|
||||
Items.Strings = (
|
||||
'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;
|
||||
FCountryCode: Integer;
|
||||
FServiceCode: Integer;
|
||||
function GetPrimary: String;
|
||||
procedure SetCountryCode(AValue: Integer);
|
||||
procedure SetMode(AValue: TBarcodeMaxicodeMode);
|
||||
procedure SetPostCode(AValue: String);
|
||||
procedure SetPrimary(AValue: String);
|
||||
procedure SetServiceCode(AValue: Integer);
|
||||
protected
|
||||
function BuildPrimary: String;
|
||||
function CalcFactor(AWidth, AHeight: Integer): Integer; override;
|
||||
procedure CalcSize(AFactor: Integer;
|
||||
out ATotalWidth, ATotalHeight, ASymbolWidth, ASymbolHeight,
|
||||
ATextWidth, ATextHeight, ABorderWidth, AWhitespaceWidth: Integer); override;
|
||||
function CalcSymbolStart(ABorderWidth, AWhiteSpaceWidth: Integer): Integer; override;
|
||||
procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: Integer;
|
||||
WithThemeSpace: Boolean); override;
|
||||
procedure DrawBarcode(ADrawer: TBasicBarcodeDrawer; AFactor: Double); override;
|
||||
@ -636,7 +637,7 @@ type
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
published
|
||||
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 CountryCode: Integer read FCountryCode write SetCountryCode default 0;
|
||||
property ServiceCode: Integer read FServiceCode write SetServiceCode default 0;
|
||||
@ -3223,6 +3224,45 @@ begin
|
||||
FShowHumanReadableText := false;
|
||||
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
|
||||
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.}
|
||||
@ -3265,6 +3305,11 @@ begin
|
||||
ATotalHeight := ASymbolHeight + 2 * ABorderWidth;
|
||||
end;
|
||||
|
||||
function TBarcodeMaxicode.CalcSymbolStart(ABorderWidth, AWhiteSpaceWidth: Integer): Integer;
|
||||
begin
|
||||
Result := ABorderWidth;
|
||||
end;
|
||||
|
||||
procedure TBarcodeMaxiCode.CalculatePreferredSize(var PreferredWidth, PreferredHeight: Integer;
|
||||
WithThemeSpace: Boolean);
|
||||
var
|
||||
@ -3335,35 +3380,11 @@ begin
|
||||
Result.CY := 88;
|
||||
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;
|
||||
begin
|
||||
FSymbol^.option_1 := ord(FMode);
|
||||
if FMode in [mcmAuto, mcmMode2, mcmMode3] then
|
||||
FSymbol^.SetPrimary(GetPrimary);
|
||||
FSymbol^.SetPrimary(FPrimary);
|
||||
|
||||
Result := maxicode(FSymbol, @FText[1], Length(FText));
|
||||
end;
|
||||
@ -3467,8 +3488,11 @@ begin
|
||||
if (AValue > 0) and (AValue < 1000) then
|
||||
begin
|
||||
FCountryCode := AValue;
|
||||
if FMode in [mcmMode2, mcmMode3] then
|
||||
if FMode in [mcmAuto, mcmMode2, mcmMode3] then
|
||||
begin
|
||||
FPrimary := BuildPrimary;
|
||||
GenerateAndInvalidate;
|
||||
end;
|
||||
end else
|
||||
raise Exception.Create('Maxicode country code must be > 0 and < 1000');
|
||||
end;
|
||||
@ -3477,6 +3501,8 @@ procedure TBarcodeMaxicode.SetMode(AValue: TBarcodeMaxicodeMode);
|
||||
begin
|
||||
if FMode = AValue then exit;
|
||||
FMode := AValue;
|
||||
if FMode in [mcmAuto, mcmMode2, mcmMode3] then
|
||||
FPrimary := BuildPrimary;
|
||||
GenerateAndInvalidate;
|
||||
end;
|
||||
|
||||
@ -3484,14 +3510,20 @@ procedure TBarcodeMaxicode.SetPostcode(AValue: String);
|
||||
begin
|
||||
if AValue = FPostcode then exit;
|
||||
FPostcode := AValue;
|
||||
if FMode in [mcmMode2, mcmMode3] then
|
||||
if FMode in [mcmAuto, mcmMode2, mcmMode3] then
|
||||
begin
|
||||
FPrimary := BuildPrimary;
|
||||
GenerateAndInvalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TBarcodeMaxicode.SetPrimary(AValue: String);
|
||||
begin
|
||||
if AValue = FPrimary then exit;
|
||||
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
|
||||
GenerateAndInvalidate;
|
||||
end;
|
||||
@ -3502,8 +3534,11 @@ begin
|
||||
if (AValue > 0) and (AValue < 1000) then
|
||||
begin
|
||||
FServiceCode := AValue;
|
||||
if FMode in [mcmMode2, mcmMode3] then
|
||||
if FMode in [mcmAuto, mcmMode2, mcmMode3] then
|
||||
begin
|
||||
FPrimary := BuildPrimary;
|
||||
GenerateAndInvalidate;
|
||||
end;
|
||||
end else
|
||||
raise Exception.Create('Maxicode Service code must be > 0 and < 1000');
|
||||
end;
|
||||
|
Reference in New Issue
Block a user