Industrial/TLCDDisplay: Fix component editor not executing context menu items. Add edit lines functionality to component editor.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8313 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-06-18 10:57:37 +00:00
parent edb43d5153
commit d926e02845

View File

@ -1,10 +1,10 @@
unit indlcddisplay_editor;
unit indLCDDisplay_Editor;
{$mode objfpc}{$H+}
interface
uses lazlogger,
uses
Classes, SysUtils, PropEdits, ComponentEditors,
indLCDDisplay;
@ -19,10 +19,12 @@ type
function LCDDisplay: TLCDDisplay;
end;
TLCDDisplayComponentEditor = class(TDefaultComponentEditor)
public
TLCDDisplayComponentEditor = class(TComponentEditor)
private
procedure EditLines;
procedure ExecuteVerb(Index: Integer);
public
procedure Edit; override;
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
function LCDDisplay: TLCDDisplay;
@ -33,7 +35,8 @@ procedure EditCharDefs(ALCDDisplay: TLCDDisplay);
implementation
uses
Dialogs, indLCDDisplay_EditorForm;
Controls, StdCtrls, Dialogs, ButtonPanel, Forms,
indLCDDisplay_EditorForm;
{ Opens the char def editor. }
procedure EditCharDefs(ALCDDisplay: TLCDDisplay);
@ -42,6 +45,7 @@ var
begin
F := TLCDCharDefsEditor.Create(nil);
try
F.Position := poScreenCenter;
F.LCDDisplay := TLCDDisplay(ALCDDisplay);
F.ShowModal; // Cancel has been handled by the editor form.
finally
@ -130,34 +134,50 @@ begin
Result := TLCDDisplay(GetComponent(0));
end;
{ TLCDDisplayComponentEditor }
procedure TLCDDisplayComponentEditor.EditLines;
procedure TLCDDisplayComponentEditor.Edit;
begin
{
F := TStringsPropEditorForm.Create(nil);
dlg :=
Old := TStrings(GetObjectValue);
TheDialog := CreateDlg(Old);
ExecuteVerb(0);
end;
procedure TLCDDisplayComponentEditor.EditLines;
var
F: TForm;
Memo: TMemo;
begin
F := TForm.CreateNew(nil);
try
if (TheDialog.ShowModal = mrOK) then begin
New := TheDialog.ListBox.Items;
AssignItems(Old, TheDialog.ListBox.Items);
SetPtrValue(New);
F.Caption := 'Edit LCDDisplay text';
F.Position := poScreenCenter;
F.Width := 300;
F.Height := 200;
Memo := TMemo.Create(F);
with Memo do
begin
Align := alClient;
BorderSpacing.Around := 8;
Parent := F;
Lines.Assign(LCDDisplay.Lines);
end;
with TButtonPanel.Create(F) do
begin
ShowButtons := [pbOK, pbCancel];
Parent := F;
end;
if F.ShowModal = mrOK then
begin
LCDDisplay.Lines.Assign(Memo.Lines);
LCDDisplay.Invalidate;
end;
finally
TheDialog.Free;
F.Free;
end;
}
end;
procedure TLCDDisplayComponentEditor.ExecuteVerb(Index: Integer);
begin
if LCDDisplay = nil then
DebugLn('LCDDisplay = nil')
else
DebugLn(LCDDisplay.ClassName);
case Index of
0: EditLines;
1: EditCharDefs(LCDDisplay);
@ -176,7 +196,7 @@ end;
function TLCDDisplayComponentEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := 'Text...';
0: Result := 'Lines text...';
1: Result := 'Edit character defs...';
2: Result := 'Load character defs from file...';
3: Result := 'Save character defs to file...';