Industrial/LCDDisplay: Single-character input of new character name in CharDefs editor.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8317 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-06-19 20:10:47 +00:00
parent 0a73893d27
commit 7bf24c3d0b

View File

@ -29,7 +29,7 @@ type
procedure btReplaceClick(Sender: TObject);
procedure cbCharSelectorChange(Sender: TObject);
procedure dgDotMatrixKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
{%H-}Shift: TShiftState);
procedure dgDotMatrixMouseDown(Sender: TObject; {%H-}Button: TMouseButton;
{%H-}Shift: TShiftState; X, Y: Integer);
procedure dgDotMatrixMouseMove(Sender: TObject; Shift: TShiftState; X,
@ -70,7 +70,60 @@ implementation
{$R *.lfm}
uses
Math;
Math, ButtonPanel;
function CharInputBox(const ACaption, APrompt, ADefault: string): string;
var
F: TForm;
ed: TEdit;
lbl: TLabel;
bp: TButtonPanel;
begin
F := TForm.CreateNew(nil);
try
F.Caption := ACaption;
F.BorderStyle := bsDialog;
lbl := TLabel.Create(F);
lbl.AnchorSideTop.Control := F;
lbl.AnchorSideLeft.Control := F;
lbl.BorderSpacing.Top := F.Scale96ToFont(12);
lbl.BorderSpacing.Bottom := F.Scale96ToFont(2);
lbl.BorderSpacing.Left := F.Scale96ToFont(12);
lbl.BorderSpacing.Right := F.Scale96ToFont(12);
lbl.WordWrap := true;
lbl.AutoSize := true;
lbl.Caption := APrompt;
lbl.Parent := F;
lbl.AdjustSize;
ed := TEdit.Create(F);
ed.AnchorSideTop.Control := lbl;
ed.AnchorSideTop.Side := asrBottom;
ed.AnchorSideLeft.Control := F;
ed.AnchorSideRight.Control := F;
ed.AnchorSideRight.Side := asrRight;
ed.Anchors := [akLeft, akTop, akRight];
ed.BorderSpacing.Left := F.Scale96ToFont(12);
ed.BorderSpacing.Right := F.Scale96ToFont(12);
ed.BorderSpacing.Bottom := F.Scale96ToFont(18);
ed.MaxLength := 1;
ed.Text := ADefault;
ed.Parent := F;
ed.AdjustSize;
bp := TButtonPanel.Create(F);
bp.ShowButtons := [pbOK, pbCancel];
bp.Parent := F;
bp.AdjustSize;
F.Constraints.MinHeight := ed.Top + ed.Height + ed.BorderSpacing.Bottom + bp.Height + 2*bp.BorderSpacing.Around;
F.AutoSize := true;
F.Position := poScreenCenter;
if F.ShowModal = mrOK then
Result := ed.Text
else
Result := ADefault;
finally
F.Free;
end;
end;
procedure TLCDCharDefsEditor.PopulateCharSelector;
var
@ -100,21 +153,8 @@ end;
procedure TLCDCharDefsEditor.btAddClick(Sender: TObject);
var
newChar: String;
perc, pix: Integer;
begin
// Query the name of the new character from an input box. Unfortunately, the
// width of the input box is too wide. We work around this by temporarily
// setting the global parameter cInputQueryEditSizePercents to 0
perc := cInputQueryEditSizePercents;
pix := cInputQueryEditSizePixels;
cInputQueryEditSizePercents := 0;
cInputQueryEditSizePixels := 200;
try
newChar := InputBox('Dotmatrix to be used for...', 'Character', '');
finally
cInputQueryEditSizePercents := perc;
cInputQueryEditSizePixels := pix;
end;
newChar := CharInputBox('Dot matrix for...', 'Character', '');
if newChar = '' then
exit;