📄 lcdanimatoreditor.pas.svn-base
字号:
unit LCDAnimatorEditor;
////////////////////////////////////////////////////////////////////////////////
//
// TLCDScreen / TLCDAnimator v2.5 (15/aug/01)
// written by Jacques VOIRIN
// E-Mail: jacques.voirin@iname.com
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
// This unit contain all the routines for the TLCDAnimatorCodeEditor
// (registering the editor, associate TLCDAnimator.Code to it), the syntax
// analysis and its form TLCDAnimatorCodeEditorForm.
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
// Please notice bugs or problems, suggestions and improvements at
//
// jacques.voirin@iname.com
//
////////////////////////////////////////////////////////////////////////////////
interface
uses
Windows, SysUtils, Classes, Controls, Forms, StdCtrls,
{$IFDEF VER140}
DesignIntf, DesignEditors,
{$ELSE}
DsgnIntf,
{$ENDIF}
Grids, Graphics, Menus, Dialogs, ExtCtrls, Messages, LCDScreen;
type
////////////////////////////////////////////////////////////////////////////////
//
// TLCDAnimatorEditor is the TComponentEditor which generate the custom context
// menu when TLCDAnimator is left-clicked and then display the LCDAnimatorCodeEditorForm.
//
////////////////////////////////////////////////////////////////////////////////
TLCDAnimatorEditor = class(TComponentEditor)
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): String; override;
function GetVerbCount: Integer; override;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TLCDAnimatorCodeEditorProperty is the TPropertyEditor in relation with 'Code'
// property of TLCDAnimator. Clicking on '...' in the Object Inspector display
// the LCDAnimatorCodeEditorForm.
//
////////////////////////////////////////////////////////////////////////////////
TLCDAnimatorCodeEditorProperty = class(TPropertyEditor)
procedure Edit; override;
function GetValue: String; override;
function GetAttributes: TPropertyAttributes; override;
private
end;
////////////////////////////////////////////////////////////////////////////////
//
// TLCDAnimatorCodeEditorForm is the CodeEditor form, which allow to write
// the code for the animation.
//
////////////////////////////////////////////////////////////////////////////////
TLCDAnimatorCodeEditorForm = class(TForm)
CancelButton: TButton;
OkButton: TButton;
InsertButton: TButton;
AddButton: TButton;
HorzScrollButton: TButton;
VertScrollButton: TButton;
LineBeginningButton: TButton;
LineEndingButton: TButton;
InstructionEndingButton: TButton;
SetIntensityButton: TButton;
AnimationDelayButton: TButton;
ResetDisplayButton: TButton;
PanelOnButton: TButton;
PanelOffButton: TButton;
GotoLineButton: TButton;
BlankButton: TButton;
DeleteButton: TButton;
CodeCellPUM: TPopupMenu;
EditMenu: TMenuItem;
N1: TMenuItem;
DeleteMenu: TMenuItem;
DeleteAllMenu: TMenuItem;
SynthaxPanel: TPanel;
SynthaxLabel2: TLabel;
SynthaxLabel1: TLabel;
SynthaxLabel3: TLabel;
InsertMenu: TMenuItem;
AddMenu: TMenuItem;
N2: TMenuItem;
Bevel1: TBevel;
N3: TMenuItem;
SyntaxAnalysisMenu: TMenuItem;
CodeStringGrid: TStringGrid;
Bevel2: TBevel;
Bevel3: TBevel;
procedure FormActivate(Sender: TObject);
procedure InsertLineClick(Sender: TObject);
procedure WordClick(Sender: TObject);
procedure DeleteLineClick(Sender: TObject);
procedure DeleteAllClick(Sender: TObject);
procedure CodeStringGridDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure AddLineClick(Sender: TObject);
procedure CodeStringGridSelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
procedure EditMenuClick(Sender: TObject);
procedure SyntaxAnalysisMenuClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure CodeStringGridDblClick(Sender: TObject);
end;
procedure Register;
var
LCDAnimatorCodeEditorForm: TLCDAnimatorCodeEditorForm;
implementation
{$R *.DFM}
////////////////////////////////////////////////////////////////////////////////
//
// TLCDAnimatorEditor
//
// Result := 1; Only one personalized entry in the context menu
//
////////////////////////////////////////////////////////////////////////////////
function TLCDAnimatorEditor.GetVerbCount: Integer;
begin
Result := 1;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TLCDAnimatorEditor
//
// Result := 'LCDAnimator Code Editor'; The caption of the personalized entry
// in the context menu
//
////////////////////////////////////////////////////////////////////////////////
function TLCDAnimatorEditor.GetVerb(Index: Integer): String;
begin
Result := 'LCDAnimator Code Editor';
end;
////////////////////////////////////////////////////////////////////////////////
//
// TLCDAnimatorEditor
//
// This is te code displaying the editor form when 'LCDAnimator Code Editor' in
// the context menu is clicked or the component double-clicked;
//
////////////////////////////////////////////////////////////////////////////////
procedure TLCDAnimatorEditor.ExecuteVerb(Index: Integer);
var F: TLCDAnimatorCodeEditorForm;
i: Byte;
begin
F := TLCDAnimatorCodeEditorForm.Create(Application);
F.Caption := 'TLCDAnimator Code Editor - ' + (Component as TLCDAnimator).Name;
try
F.CodeStringGrid.RowCount := (Component as TLCDAnimator).Code.Count;
{ Load Code lines from TLCDAnimator to CodeStringGrid }
if (Component as TLCDAnimator).Code.Count <> 0
then for i := 0 to F.CodeStringGrid.RowCount - 1
do F.CodeStringGrid.Cells[1, i] := (Component as TLCDAnimator).Code[i];
if F.ShowModal = mrOK //Display the Editor form
then begin
(Component as TLCDAnimator).Code.Clear;
{ UnLoad Code lines from CodeStringGrid to TLCDAnimator }
if F.CodeStringGrid.RowCount <> 0
then for i := 0 to F.CodeStringGrid.RowCount - 1
do (Component as TLCDAnimator).Code.Append(F.CodeStringGrid.Cells[1, i]);
try Designer.Modified; except end;
end;
{ Check if a code synthax error had been detected and update CodeErrorFond prop.}
if F.Tag = 0 then (Component as TLCDAnimator).CodeErrorFound := False
else (Component as TLCDAnimator).CodeErrorFound := True;
finally
F.Free;
end;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TLCDAnimatorCodeEditorProperty
//
// Result := '(TStrings)'; The 'Code' caption displayed in the Object Inspector
//
////////////////////////////////////////////////////////////////////////////////
function TLCDAnimatorCodeEditorProperty.GetValue: String;
begin
Result := '(TStrings)';
end;
////////////////////////////////////////////////////////////////////////////////
//
// TLCDAnimatorCodeEditorProperty
//
// Result := [paDialog]; Indicates that the '...' button in the Object Inspector
// will bring up a dialog form
//
////////////////////////////////////////////////////////////////////////////////
function TLCDAnimatorCodeEditorProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
////////////////////////////////////////////////////////////////////////////////
//
// TLCDAnimatorCodeEditorProperty
//
// The code displaying the editor form when the '...' button in the Object
// Inspector is clicked
//
////////////////////////////////////////////////////////////////////////////////
procedure TLCDAnimatorCodeEditorProperty.Edit;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -