diff --git a/components/industrialstuff/source/indlcddisplay_editor.pas b/components/industrialstuff/source/indlcddisplay_editor.pas index 9b8114498..f5c45c386 100644 --- a/components/industrialstuff/source/indlcddisplay_editor.pas +++ b/components/industrialstuff/source/indlcddisplay_editor.pas @@ -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) + TLCDDisplayComponentEditor = class(TComponentEditor) + private + procedure EditLines; public - procedure EditLines; - procedure ExecuteVerb(Index: Integer); + 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...';