📄 mmproped.pas
字号:
{========================================================================}
{= (c) 1995-98 SwiftSoft Ronald Dittrich =}
{========================================================================}
{= All Rights Reserved =}
{========================================================================}
{= D 01099 Dresden = Tel.: +0351-8012255 =}
{= Loewenstr.7a = info@swiftsoft.de =}
{========================================================================}
{= Actual versions on http://www.swiftsoft.de/mmtools.html =}
{========================================================================}
{= This code is for reference purposes only and may not be copied or =}
{= distributed in any format electronic or otherwise except one copy =}
{= for backup purposes. =}
{= =}
{= No Delphi Component Kit or Component individually or in a collection=}
{= subclassed or otherwise from the code in this unit, or associated =}
{= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
{= without express permission from SwiftSoft. =}
{= =}
{= For more licence informations please refer to the associated =}
{= HelpFile. =}
{========================================================================}
{= $Date: 20.01.1998 - 18:00:00 $ =}
{========================================================================}
unit MMPropEd;
{$I COMPILER.INC}
interface
uses
Windows,
SysUtils,
Classes,
Controls,
Dialogs,
{$IFDEF DELPHI6}
DesignIntf,
DesignEditors,
{$ELSE}
DsgnIntf,
{$ENDIF}
MMObj,
MMUtils,
MMAbout,
MMProps,
MMMemMap,
MMSplit,
MMLEDs;
type
{$IFDEF TRIAL}
{-- TMMAboutBoxEditor -----------------------------------------------------}
TMMAboutBoxEditor = class(TPropertyEditor)
public
function GetAttributes: TPropertyAttributes; override;
procedure Edit; override;
function GetValue: string; override;
end;
{$ENDIF}
{-- TMMPropertiesEditor ---------------------------------------------------}
TMMPropertiesEditor = class(TComponentEditor)
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
{-- TMMMemMapFileNameProperty ---------------------------------------------}
TMMMemMapFileNameProperty = class(TStringProperty)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;
{-- TMMSplitterSizeControlEditor ------------------------------------------}
TMMSplitterSizeControlEditor = class(TComponentProperty)
public
procedure GetValues(Proc: TGetStrProc); override;
end;
{-- TMMLEDDigitConnectEditor ----------------------------------------------}
TMMLEDDigitConnectEditor = class(TComponentProperty)
public
procedure GetValues(Proc: TGetStrProc); override;
end;
{-- TMMIntegerProperty ----------------------------------------------------}
TMMIntegerProperty = class(TIntegerProperty)
private
FIntToIdent: TIntToIdent;
FIdentToInt: TIdentToInt;
protected
procedure GetConverters(var IntToIdent: TIntToIdent; var IdentToInt: TIdentToInt); virtual; abstract;
procedure GetConsts(List: TList); virtual; abstract;
public
procedure Initialize; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure SetValue(const Value: string); override;
procedure GetValues(Proc: TGetStrProc); override;
end;
{-- TMMDeviceIdProperty ---------------------------------------------------}
TMMDeviceIdProperty = class(TMMIntegerProperty)
protected
procedure GetConverters(var IntToIdent: TIntToIdent; var IdentToInt: TIdentToInt); override;
procedure GetConsts(List: TList); override;
end;
implementation
uses
Consts
{$IFDEF DELPHI6}
,RTLConsts
{$ENDIF}
;
{$IFDEF TRIAL}
{== TMMAboutBoxEditor =========================================================}
function TMMAboutBoxEditor.GetAttributes;
begin
Result := inherited GetAttributes + [paDialog,paReadOnly];
end;
{------------------------------------------------------------------------------}
function TMMAboutBoxEditor.GetValue: string;
begin
{This is the caption displayed in the Object Inspector}
Result := 'About...';
end;
{------------------------------------------------------------------------------}
Procedure TMMAboutBoxEditor.Edit;
begin
with TMMAboutBox.Create(NIL) do
try
MessageBeep(0);
ShowModal;
finally
Free;
end;
end;
{$ENDIF}
{== TMMPropertiesEditor =======================================================}
procedure TMMPropertiesEditor.ExecuteVerb(Index: Integer);
begin
TMMPropertiesDialog(Component).Execute;
end;
{-- TMMPropertiesEditor -------------------------------------------------------}
function TMMPropertiesEditor.GetVerb(Index: Integer): string;
begin
Result := 'Execute Dialog...';
end;
{-- TMMPropertiesEditor -------------------------------------------------------}
function TMMPropertiesEditor.GetVerbCount: Integer;
begin
Result := 1;
end;
{== TMMMemMapFileNameProperty =================================================}
procedure TMMMemMapFileNameProperty.Edit;
begin
with TOpenDialog.Create(nil) do
try
FileName := GetStrValue;
Filter := {$IFDEF DELPHI3}SDefaultFilter{$ELSE}LoadStr(SDefaultFilter){$ENDIF};
Options := Options + [ofPathMustExist, ofFileMustExist, ofHideReadOnly];
Title := LoadResStr(IDS_SELECTFILE);
if Execute then SetValue(FileName);
finally
Free;
end;
end;
{-- TMMMemMapFileNameProperty -------------------------------------------------}
function TMMMemMapFileNameProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
{== TMMSplitterSizeControlEditor ========================================}
procedure TMMSplitterSizeControlEditor.GetValues(Proc: TGetStrProc);
var
i: Integer;
Splitter: TMMSplitter;
P1: TWinControl;
begin
Splitter := GetComponent(0) as TMMSplitter;
for i := 0 to Splitter.Parent.ControlCount-1 do
begin
P1 := TWinControl(Splitter.Parent.Controls[i]);
if (P1.Name <> '') and (P1 is TWinControl) and not (P1 is TMMSplitter) and
(P1.Align in [alLeft,alRight,alTop,alBottom]) then
Proc(P1.Name);
end;
end;
{== TMMLEDDigitConnectEditor ============================================}
procedure TMMLEDDigitConnectEditor.GetValues(Proc: TGetStrProc);
type
TGetStrFunc = function(const Value: string): Integer of object;
var
i: Integer;
LED: TMMLEDDigit;
Component: TComponent;
begin
LED := GetComponent(0) as TMMLEDDigit;
{$IFDEF DELPHI6}
for i := 0 to Designer.Root.ComponentCount-1 do
{$ELSE}
for i := 0 to Designer.Form.ComponentCount-1 do
{$ENDIF}
begin
{$IFDEF DELPHI6}
Component := Designer.Root.Components[i];
{$ELSE}
Component := Designer.Form.Components[i];
{$ENDIF}
if (Component.Name <> '') then
if (Component is TMMLEDDigit) and (Component <> LED) then
Proc(Component.Name);
end;
end;
{== TMMIntegerProperty ========================================================}
procedure TMMIntegerProperty.Initialize;
begin
inherited Initialize;
GetConverters(FIntToIdent,FIdentToInt);
end;
{-- TMMIntegerProperty --------------------------------------------------------}
function TMMIntegerProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect,paValueList{$IFDEF WIN32},paRevertable{$ENDIF}];
end;
{-- TMMIntegerProperty --------------------------------------------------------}
function TMMIntegerProperty.GetValue: string;
begin
if (@FIntToIdent = nil) or not FIntToIdent(GetOrdValue,Result) then
Result := IntToStr(GetOrdValue);
end;
{-- TMMIntegerProperty --------------------------------------------------------}
procedure TMMIntegerProperty.SetValue(const Value: string);
var
IV: LongInt;
begin
if (@FIdentToInt = nil) or not FIdentToInt(Value,IV) then
IV := StrToInt(Value);
SetOrdValue(IV);
end;
{-- TMMIntegerProperty --------------------------------------------------------}
procedure TMMIntegerProperty.GetValues(Proc: TGetStrProc);
var
Vals : TList;
i : Integer;
S : string;
begin
if @FIntToIdent <> nil then
begin
Vals := TList.Create;
try
GetConsts(Vals);
for i := 0 to Vals.Count - 1 do
if FIntToIdent(LongInt(Vals[i]),S) then
Proc(S);
finally
Vals.Free;
end;
end;
end;
{== TMMDeviceIdProperty =======================================================}
procedure TMMDeviceIdProperty.GetConverters(var IntToIdent: TIntToIdent; var IdentToInt: TIdentToInt);
begin
IntToIdent := DeviceIdToIdent;
IdentToInt := IdentToDeviceId;
end;
{-- TMMDeviceIdProperty -------------------------------------------------------}
procedure TMMDeviceIdProperty.GetConsts(List: TList);
begin
List.Add(Pointer(MapperId));
List.Add(Pointer(InvalidId));
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -