📄 rm_barcode.pas
字号:
FViewMaxi.RelativeBarHeight := RMReadBoolean(aStream);
FViewMaxi.QuietZone := RMReadInt32(aStream);
FViewMaxi.Caption := RMReadString(aStream);
RMReadFont(aStream, FViewMaxi.Font);
end;
end;
procedure TRM2DBarCodeView.SaveToStream(aStream: TStream);
begin
inherited SaveToStream(aStream);
RMWriteWord(aStream, 0); // 版本号
RMWriteByte(aStream, Byte(FBarCodeType));
if FBarCodeType = rmbtpdf417 then
begin
RMWriteByte(aStream, Byte(FViewpdf417.ECCLevel));
RMWriteInt32(aStream, FViewpdf417.NumColumns);
RMWriteInt32(aStream, FViewpdf417.NumRows);
RMWriteBoolean(aStream, FViewpdf417.Truncated);
RMWriteInt32(aStream, FViewpdf417.BarHeight);
RMWriteInt32(aStream, FViewpdf417.BarHeightToWidth);
RMWriteInt32(aStream, FViewpdf417.BarWidth);
RMWriteByte(aStream, Byte(FViewpdf417.CaptionLayout));
RMWriteBoolean(aStream, FViewpdf417.ExtendedSyntax);
RMWriteBoolean(aStream, FViewpdf417.RelativeBarHeight);
RMWriteInt32(aStream, FViewpdf417.QuietZone);
RMWriteString(aStream, FViewpdf417.Caption);
RMWriteFont(aStream, FViewpdf417.Font);
end
else if FBarCodeType = rmbtMAXI then
begin
RMWriteBoolean(aStream, FViewMaxi.AutoScale);
RMWriteInt32(aStream, FViewMaxi.CarrierCountryCode);
RMWriteString(aStream, FViewMaxi.CarrierPostalCode);
RMWriteInt32(aStream, FViewMaxi.CarrierServiceClass);
RMWriteInt32(aStream, Round(FViewMaxi.HorPixelsPerMM * 1000));
RMWriteByte(aStream, Byte(FViewMaxi.Mode));
RMWriteInt32(aStream, Round(FViewMaxi.VerPixelsPerMM * 1000));
RMWriteInt32(aStream, FViewMaxi.BarHeight);
RMWriteInt32(aStream, FViewMaxi.BarHeightToWidth);
RMWriteInt32(aStream, FViewMaxi.BarWidth);
RMWriteByte(aStream, Byte(FViewMaxi.CaptionLayout));
RMWriteBoolean(aStream, FViewMaxi.ExtendedSyntax);
RMWriteBoolean(aStream, FViewMaxi.RelativeBarHeight);
RMWriteInt32(aStream, FViewMaxi.QuietZone);
RMWriteString(aStream, FViewMaxi.Caption);
RMWriteFont(aStream, FViewMaxi.Font);
end;
end;
procedure TRM2DBarCodeView.ShowEditor;
var
tmpForm: TRM2DBarcodeForm;
begin
tmpForm := TRM2DBarcodeForm.Create(nil);
try
tmpForm.FView := Self;
tmpForm.FBusy := True;
tmpForm.edtCode.Text := Memo.Text;
tmpForm.CheckBox2.Checked := FViewpdf417.Caption <> '';
tmpForm.Edit1.Text := FViewpdf417.Caption;
tmpForm.ComboBox2.ItemIndex := Byte(FViewpdf417.CaptionLayout);
tmpForm.FSpinEdit1.Value := FViewpdf417.BarWidth;
tmpForm.FSpinEdit2.Value := FViewpdf417.NumColumns;
tmpForm.FSpinEdit3.Value := FViewpdf417.NumRows;
tmpForm.CheckBox1.Checked := FViewpdf417.Truncated;
tmpForm.ComboBox1.ItemIndex := Byte(FViewpdf417.ECCLevel);
tmpForm.CheckBox3.Checked := FViewpdf417.RelativeBarHeight;
// tmpForm.CheckBox4.Checked:=FViewpdf417.ParentColor;
if FViewpdf417.Alignment = taCenter then
tmpForm.rb2.Checked := True
else if FViewpdf417.Alignment = taLeftJustify then
tmpForm.rb1.Checked := True
else if FViewpdf417.Alignment = taRightJustify then
tmpForm.rb3.Checked := True;
tmpForm.CheckBox5.Checked := FViewMaxi.Caption <> '';
tmpForm.Edit5.Text := FViewMaxi.Caption;
tmpForm.ComboBox4.ItemIndex := Byte(FViewMaxi.CaptionLayout);
tmpForm.Edit2.Text := IntToStr(FViewMaxi.CarrierCountryCode);
tmpForm.Edit3.Text := FViewMaxi.CarrierPostalCode;
tmpForm.edit4.text := IntToStr(FViewMaxi.CarrierServiceClass);
tmpForm.cmbMaxiMode.ItemIndex := Byte(FViewMaxi.Mode);
if FBarCodeType = rmbtpdf417 then
tmpForm.Choos2DType.ActivePage := tmpForm.tabSheet1
else
tmpForm.Choos2DType.ActivePage := tmpForm.tabSheet2;
if tmpForm.ShowModal = mrOk then
begin
RMDesigner.BeforeChange;
Memo.Clear;
Memo.Add(tmpForm.edtCode.Text);
if tmpForm.Choos2DType.ActivePage = tmpForm.TabSheet1 then
begin
FBarCodeType := rmbtpdf417;
if tmpForm.CheckBox2.Checked then
FViewpdf417.Caption := tmpForm.Edit1.Text
else
FViewpdf417.Caption := '';
FViewpdf417.CaptionLayout := TTextLayout(tmpForm.ComboBox2.ItemIndex);
FViewpdf417.BarWidth := tmpForm.FSpinEdit1.AsInteger;
FViewpdf417.NumColumns := tmpForm.FSpinEdit2.AsInteger;
FViewpdf417.NumRows := tmpForm.FSpinEdit3.AsInteger;
FViewpdf417.Truncated := tmpForm.CheckBox1.Checked;
// FViewpdf417.ParentColor:=tmpForm.CheckBox4.Checked;
if tmpForm.rb2.Checked = True then
FViewpdf417.Alignment := taCenter
else if tmpForm.rb1.Checked = True then
FViewpdf417.Alignment := taLeftJustify
else if tmpForm.rb3.Checked = True then
FViewpdf417.Alignment := taRightJustify;
FViewpdf417.RelativeBarHeight := tmpForm.CheckBox3.Checked;
FViewpdf417.ECCLevel := TStPDF417ECCLevels(tmpForm.ComboBox1.ItemIndex);
end
else if tmpForm.Choos2DType.ActivePage = tmpForm.TabSheet2 then
begin
FBarCodeType := rmbtMaxi;
if tmpForm.CheckBox5.Checked then
FViewMaxi.Caption := tmpForm.Edit5.Text
else
FViewMaxi.Caption := '';
FViewMaxi.CaptionLayout := TTextLayout(tmpForm.ComboBox4.ItemIndex);
FViewMaxi.CarrierCountryCode := StrToInt(tmpForm.Edit2.Text);
FViewMaxi.CarrierPostalCode := tmpForm.Edit3.Text;
FViewMaxi.CarrierServiceClass := StrToInt(tmpForm.edit4.text);
FViewMaxi.Mode := TStMaxiCodeMode(tmpForm.cmbMaxiMode.ItemIndex);
end;
end;
finally
tmpForm.Free;
end;
end;
procedure TRM2DBarCodeView.DefinePopupMenu(aPopup: TRMCustomMenuItem);
begin
inherited;
end;
function TRM2DBarCodeView.GetDirectDraw: Boolean;
begin
Result := (FFlags and flBarCodeDirectDraw) = flBarCodeDirectDraw;
end;
procedure TRM2DBarCodeView.SetDirectDraw(Value: Boolean);
begin
FFlags := (FFlags and not flBarCodeDirectDraw);
if Value then
FFlags := FFlags + flBarCodeDirectDraw;
end;
function TRM2DBarCodeView.GetViewCommon: string;
begin
Result := '[2DBarCode]';
end;
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{ TRMBar2CodeForm }
{-----------------------------------------------------------------------------
Procedure: BarcodeEditor
Author: lz
Date: 21-二月-2003
Arguments: Sender: TObject
Result: None
Email : sinmax@163.net
-----------------------------------------------------------------------------}
procedure TRM2DBarCodeForm.FormCreate(Sender: TObject);
begin
FPDF417 := TStPDF417Barcode.Create(Self);
FPDF417.Parent := Panel1;
FPDF417.Align := alClient;
FPDF417.Code := edtCode.Text;
FMaxi := TStMaxiCodeBarcode.Create(Self);
FMaxi.Parent := Panel1;
FMaxi.Align := alClient;
FMaxi.Code := edtCode.Text;
FMaxi.Visible := False;
FSpinEdit1 := TRMSpinEdit.Create(Self);
with FSpinEdit1 do
begin
Parent := GroupBox4;
ValueType := rmvtInteger;
SetBounds(47, 9, 85, 22);
OnChange := SpinEdit1Change;
MinValue := 1;
end;
FSpinEdit2 := TRMSpinEdit.Create(Self);
with FSpinEdit2 do
begin
Parent := GroupBox4;
ValueType := rmvtInteger;
SetBounds(47, 34, 85, 22);
OnChange := SpinEdit1Change;
MinValue := 0;
end;
FSpinEdit3 := TRMSpinEdit.Create(Self);
with FSpinEdit3 do
begin
Parent := GroupBox4;
ValueType := rmvtInteger;
SetBounds(195, 34, 90, 22);
OnChange := SpinEdit1Change;
end;
edit1.Visible := False;
edit5.Visible := False;
Choos2DType.Visible := True;
Localize;
end;
procedure TRM2DBarCodeForm.SpeedButton1Click(Sender: TObject);
begin
SaveDialog1.FileName := '';
SaveDialog1.DefaultExt := '.BMP';
SaveDialog1.Filter := 'BMP图形文件(*.BMP)|*.BMP';
if SaveDialog1.Execute then
begin
Fpdf417.SaveToFile(SaveDialog1.FileName);
end;
end;
procedure TRM2DBarCodeForm.DBBtnClick(Sender: TObject);
var
s: string;
begin
s := RMDesigner.InsertExpression(FView);
if s <> '' then
edtCode.SelText := s;
end;
procedure TRM2DBarCodeForm.SpinEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key = vk_return) then
SelectNext(Sender as Twincontrol, true, true);
end;
procedure TRM2DBarCodeForm.ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key = vk_return) then
SelectNext(Sender as Twincontrol, true, true);
end;
procedure TRM2DBarCodeForm.SpinEdit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key = vk_return) then
SelectNext(Sender as Twincontrol, true, true);
end;
procedure TRM2DBarCodeForm.SpinEdit3KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key = vk_return) then
SelectNext(Sender as Twincontrol, true, true);
end;
procedure TRM2DBarCodeForm.ComboBox2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key = vk_return) then
SelectNext(Sender as Twincontrol, true, true);
end;
procedure TRM2DBarCodeForm.CheckBox2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if CheckBox2.Checked then
begin
ComboBox2.Enabled := True;
label6.Enabled := True;
edit1.Enabled := True;
label9.Enabled := true;
end
else
begin
ComboBox2.Enabled := false;
label6.Enabled := false;
edit1.Enabled := False;
label9.Enabled := False;
end;
end;
procedure TRM2DBarCodeForm.barcolorKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key = vk_return) then
SelectNext(Sender as Twincontrol, true, true);
end;
procedure TRM2DBarCodeForm.backgroundColorKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
if (key = vk_return) then
SelectNext(Sender as Twincontrol, true, true);
end;
procedure TRM2DBarCodeForm.btnOKKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key = vk_down) then
SelectNext(Sender as Twincontrol, true, true)
else if (key = vk_up) then
SelectNext(Sender as Twincontrol, false, true);
end;
procedure TRM2DBarCodeForm.btnCancelKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key = vk_down) then
SelectNext(Sender as Twincontrol, true, true)
else if (key = vk_up) then
SelectNext(Sender as Twincontrol, false, true);
end;
procedure TRM2DBarCodeForm.CheckBox2Click(Sender: TObject);
begin
ShowSample;
if CheckBox2.Checked then
begin
ComboBox2.Visible := True;
label13.Visible := True;
edit1.Visible := True;
label8.Visible := true;
end
else
begin
ComboBox2.Visible := False;
label13.Visible := False;
edit1.Visible := False;
label8.Visible := False;
end;
end;
procedure TRM2DBarCodeForm.FormResize(Sender: TObject);
begin
ShowSample;
{
If RMBar2CodeForm.Width <= 481 Then
RMBar2CodeForm.Width := 481;
If RMBar2CodeForm.Height <= 337 Then
RMBar2CodeForm.Height := 337;
}
end;
procedure TRM2DBarCodeForm.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then
key := #0;
if sender is Tedit then
if ('Edit2' = (sender as Tedit).name) then
begin
if (not ((key in ['0'..'9']) or (key = #8) or (key = #13) or (key = #40))) then
abort;
end;
end;
procedure TRM2DBarCodeForm.Edit3KeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then
key := #0;
if sender is Tedit then
if ('Edit3' = (sender as Tedit).name) then
begin
if (not ((key in ['0'..'9']) or (key = #8) or (key = #13) or (key = #40))) then
abort;
end;
end;
procedure TRM2DBarCodeForm.Edit4KeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then
key := #0;
if sender is Tedit then
if ('Edit4' = (sender as Tedit).name) then
begin
if (not ((key in ['0'..'9']) or (key = #8) or (key = #13) or (key = #40))) then
abort;
end;
end;
procedure TRM2DBarCodeForm.Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key = vk_down) then
SelectNext(Sender as Twincontrol, true, true)
else if (key = vk_up) then
SelectNext(Sender as Twincontrol, false, true);
end;
procedure TRM2DBarCodeForm.Edit3KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key = vk_down) then
SelectNext(Sender as Twincontrol, true, true)
else if (key = vk_up) then
SelectNext(Sender as Twincontrol, false, true);
end;
procedure TRM2DBarCodeForm.Edit4KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key = vk_down) then
SelectNext(Sender as Twincontrol, true, true)
else if (key = vk_up) then
SelectNext(Sender as Twincontrol, false, true);
end;
procedure TRM2DBarCodeForm.Choos2DTypeChange(Sender: TObject);
begin
if Choos2DType.ActivePage = tabSheet1 then
begin
FPDF417.Visible := True;
Fmaxi.Visible := False;
edtCode.MaxLength := 0;
ShowSample;
end
else if Choos2DType.ActivePage = tabSheet2 then
begin
FPDF417.Visible := False;
edtCode.MaxLength := 85;
if Length(edtCode.text) > 85 then
edtCode.text := Copy(edtCode.text, 1, 80);
Fmaxi.Visible := True;
ShowSample;
end;
end;
procedure TRM2DBarCodeForm.Localize;
var
str: string;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -