⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hwextjvinspdata.pas

📁 用于Delphi程序中嵌入公式解析
💻 PAS
字号:
unit hwExtJvInspData;
{ 本单元扩展JvInspector,用于显示公式对象和用户表达式对象等 }

interface
uses
        SysUtils, Classes, TypInfo, Messages, JvInspector, Dialogs,
        hwExpr, hwExprExt;

type
        TJvStringData = class(TJvCustomInspectorData)
        private
            FValue: string;
        Protected
            procedure CreateChild(const AParent : TJvCustomInspectorItem); override;
            function GetAsFloat: extended; override;
            function GetAsInt64: int64; override;
            function GetAsMethod: TMethod; override;
            function GetAsOrdinal: int64; override;
            function GetAsString: string; override;
            procedure SetAsFloat(const Value : extended); override;
            procedure SetAsInt64(const Value : int64); override;
            procedure SetAsMethod(const Value : TMethod); override;
            procedure SetAsOrdinal(const Value : int64); override;
            procedure SetAsString(const Value : string); override;
        Public
            constructor Create(const AParent: TJvCustomInspectorItem;
                               const AName: string;
                               const AValue: String);
            function HasValue: boolean; override;
            function IsAssigned: boolean; override;
            function IsInitialized: boolean; override;
            procedure GetAsSet(var Buf); override;
            procedure SetAsSet(const Buf); override;
        end;

        { ExtFunctionDeclare data }
        TJvDataForExtFuncDeclare = class(TJvCustomInspectorData)
        Private
            FEFD: TExtFunctionDeclare;
        Protected
            procedure CreateChild(const AParent : TJvCustomInspectorItem); override;
            function GetAsFloat: extended; override;
            function GetAsInt64: int64; override;
            function GetAsMethod: TMethod; override;
            function GetAsOrdinal: int64; override;
            function GetAsString: string; override;
            procedure SetAsFloat(const Value : extended); override;
            procedure SetAsInt64(const Value : int64); override;
            procedure SetAsMethod(const Value : TMethod); override;
            procedure SetAsOrdinal(const Value : int64); override;
            procedure SetAsString(const Value : string); override;

        Public
            class procedure Create(const ExtFuncDeclare: TExtFunctionDeclare;
                                   const AParent: TJvCustomInspectorItem); overload;
            constructor Create(const AParent: TJvCustomInspectorItem;
                               const ExtFuncDeclare: TExtFunctionDeclare;
                               const PropName: string;
                               const ATypeInfo: PTypeInfo); overload;
            procedure GetAsSet(var Buf); override;
            function HasValue: boolean; override;
            function IsAssigned: boolean; override;
            function IsInitialized: boolean; override;
            procedure SetAsSet(const Buf); override;
        end;

        TJvDataForExprFunc = class(TJvCustomInspectorData)
        end;

        TJvDataForIValue = class(TJvCustomInspectorData)
        end;
implementation
{ ============================================================================
  >>>>   Class Implementation Begin                                       <<<<
  >>>>   Class Name  : TJvStringData
  >>>>   Description :
  >>>>   Create Date :
  ---------------------------------------------------------------------------- }
constructor TJvStringData.Create(const AParent: TJvCustomInspectorItem;
                                 const AName: string; const AValue: string);
begin
        inherited Create(AName, system.TypeInfo(String), AParent);
        FValue := AValue;
        Init(AName, System.TypeInfo(String));
        CreateChild(AParent);
end;

function TJvStringData.HasValue: Boolean;
begin
        Result := True;
end;

function TJvStringData.IsAssigned: Boolean;
begin
        Result := HasValue;
end;

function TJvStringData.IsInitialized: Boolean;
begin
        Result := HasValue;
end;

procedure TJvStringData.CreateChild(const AParent: TJvCustomInspectorItem);
begin
        SetItem(TJvInspectorStringItem.Create(AParent, Self));
end;

function TJvStringData.GetAsFloat: Extended;
begin
end;

function TJvStringData.GetAsInt64: Int64;
begin
end;

function TJvStringData.GetAsMethod: TMethod;
begin
end;

function TJvStringData.GetAsOrdinal: Int64;
begin
end;

function TJvStringData.GetAsString: string;
begin
        Result := FValue;
end;

procedure TJvStringData.SetAsString(const Value: String);
begin
        FValue := Value;
end;

procedure TJvStringData.SetAsFloat(const Value: Extended);
begin
end;

procedure TJvStringData.SetAsInt64(const Value: Int64);
begin
end;

procedure TJvStringData.SetAsMethod(const Value: TMethod);
begin
end;

procedure TJvStringData.SetAsOrdinal(const Value: Int64);
begin
end;

procedure TJvStringData.GetAsSet(var Buf);
begin
end;

procedure TJvStringData.SetAsSet(const Buf);
begin
end;

{ ============================================================================
  >>>>   Class Implementation Begin                                       <<<<
  >>>>   Class Name  : TJvDataForExtFuncDeclare
  >>>>   Description :
  >>>>   Create Date :
  ---------------------------------------------------------------------------- }
constructor TJvDataForExtFuncDeclare.Create
            (const AParent: TJvCustomInspectorItem;
             const ExtFuncDeclare: TExtFunctionDeclare;
             const PropName: string;
             const ATypeInfo: PTypeInfo);
begin
        Inherited Create;
        FEFD := ExtFuncDeclare;
        Init(PropName, ATypeInfo);
        CreateChild(Aparent);
end;

class procedure TJvDataForExtFuncDeclare.Create
                (const ExtFuncDeclare: TExtFunctionDeclare;
                 const AParent: TJvCustomInspectorItem);
var     inspCat: TJvInspectorCustomCategoryItem;
        i : Integer;
        paramData: TJvStringData;
begin
        if ExtFuncDeclare = nil then
            raise EJvInspectorData.Create('没有公式定义对象。笨蛋,你的程序是怎么写的?');
        { 根据公式定义对象逐一显示其属性 }
        { 函数名 }
        Create(AParent, ExtFuncDeclare, '函数名', System.TypeInfo(string));
        Create(AParent, ExtFuncDeclare, '返回值类型', System.TypeInfo(String));
        inspCat := TJvInspectorCustomCategoryItem.Create(AParent, nil);

        inspCat.DisplayName := '参数表(' + IntToStr(ExtFuncDeclare.ParamsCount) + ')';
        if ExtFuncDeclare.ParamsCount > 0 then
        for i := 0 to ExtFuncDeclare.ParamsCount -1 do
        begin
            TJvInspectorVarData.Create(ExtFuncDeclare.ParamsName[i], system.TypeInfo(String),
                InspCat, ExprTypeName[ExtFuncDeclare.ParamsType[i]]);
        end;
end;

function TJvDataForExtFuncDeclare.HasValue: Boolean;
begin
        if FEFD <> nil then Result := True;
end;

function TJvDataForExtFuncDeclare.IsAssigned: Boolean;
begin
        Result := HasValue;
end;

function TJvDataForExtFuncDeclare.IsInitialized: Boolean;
begin
        result := HasValue;
end;

procedure TJvDataForExtFuncDeclare.CreateChild(const AParent: TJvCustomInspectorItem);
begin
        if Name = '函数名' then
            SetItem(TJvInspectorStringItem.Create(AParent, Self))
        else if Name = '返回值类型' then
            SetItem(TJvInspectorStringItem.Create(AParent, Self));
            
end;

function TJvDataForExtFuncDeclare.GetAsFloat: Extended;
begin
end;

procedure TJvDataForExtFuncDeclare.SetAsFloat(const Value: Extended);
begin
end;

function TJvDataForExtFuncDeclare.GetAsInt64: Int64;
begin
end;

procedure TJvDataForExtFuncDeclare.SetAsInt64(const Value: Int64);
begin

end;    //

function TJvDataForExtFuncDeclare.GetAsMethod: TMethod;
begin

end;        //

procedure TJvDataForExtFuncDeclare.SetAsMethod(const Value: TMethod);
begin

end;        //

function TJvDataForExtFuncDeclare.GetAsOrdinal: Int64;
begin
end;

procedure TJvDataForExtFuncDeclare.SetAsOrdinal(const Value: Int64);
begin

end;        //

function TJvDataForExtFuncDeclare.GetAsString: string;
begin
        if Name = '函数名' then Result := FEFD.FunctionName
        else if Name = '返回值类型' then Result := ExprTypeName[FEFD.ResultType];
end;

procedure TJvDataForExtFuncDeclare.SetAsString(const Value: string);
begin
end;

procedure TJvDataForExtFuncDeclare.GetAsSet(var Buf);
begin
end;

procedure TJvDataForExtFuncDeclare.SetAsSet(const Buf);
begin
end;
 
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -