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

📄 dmwizard.pas

📁 Delphi下用于编写向导的组件
💻 PAS
📖 第 1 页 / 共 2 页
字号:
begin
  Result := CreatorTypes[FCreatorType];
end;

//----------------------------------------------------------------------------------------------------------------------

function TCreator.GetExisting: Boolean;

begin
  Result := FExisting;
end;

//----------------------------------------------------------------------------------------------------------------------

function TCreator.GetFileSystem: string;

begin
  Result := FFileSystem;
end;

//----------------------------------------------------------------------------------------------------------------------

function TCreator.GetUnnamed: Boolean;

begin
  Result := FUnnamed;
end;

//----------------------------------------------------------------------------------------------------------------------

{ TCreator public }

//----------------------------------------------------------------------------------------------------------------------

constructor TCreator.Create(AOwner: TComponent);

begin
  inherited Create(AOwner);
  FWizardModule := AOwner as TWizardModule;
  FUnnamed := True;
end;

//----------------------------------------------------------------------------------------------------------------------

{ TModuleFile protected: IOTAFile }

//----------------------------------------------------------------------------------------------------------------------

constructor TModuleFile.Create(ACreator: TModuleCreator; ASourceType: TModuleSourceType;
  const AModuleIdent, AFormIdent, AAncestorIdent: string);

begin
  inherited Create;
  FCreator := ACreator;
  FSourceType := ASourceType;
  FModuleIdent := AModuleIdent;
  FFormIdent := AFormIdent;
  FAncestorIdent := AAncestorIdent;
end;

//----------------------------------------------------------------------------------------------------------------------

function TModuleFile.GetAge: TDateTime;

begin
  Result := -1;
  if Assigned(FCreator) and Assigned(FCreator.OnGetAge) then
    FCreator.OnGetAge(FCreator, Result);
end;

//----------------------------------------------------------------------------------------------------------------------

function TModuleFile.GetSource: string;

begin
  Result := '';
  if Assigned(FCreator) then
  begin
    case FSourceType of
      mstForm:
        Result := Format(FCreator.FSourceForm.Text, [FModuleIdent, FFormIdent, FAncestorIdent]);
      mstImpl:
        Result := Format(FCreator.FSourceImpl.Text, [FModuleIdent, FFormIdent, FAncestorIdent]);
      mstIntf:
        Result := Format(FCreator.FSourceIntf.Text, [FModuleIdent, FFormIdent, FAncestorIdent]);
    end;
    // remove trailing CRLF
    if (Result[Length(Result) - 1] = #13) and (Result[Length(Result)] = #10) then
      Delete(Result, Length(Result) - 1, 2);
    if Assigned(FCreator.OnGetSource) then
      FCreator.OnGetSource(FCreator, FSourceType, Result);
  end;
end;

//----------------------------------------------------------------------------------------------------------------------

{ TModuleCreator private }

//----------------------------------------------------------------------------------------------------------------------

procedure TModuleCreator.SetSourceForm(Value: TStrings);

begin
  FSourceForm.Assign(Value);
end;

//----------------------------------------------------------------------------------------------------------------------

procedure TModuleCreator.SetSourceImpl(Value: TStrings);

begin
  FSourceImpl.Assign(Value);
end;

//----------------------------------------------------------------------------------------------------------------------

procedure TModuleCreator.SetSourceIntf(Value: TStrings);

begin
  FSourceIntf.Assign(Value);
end;

//----------------------------------------------------------------------------------------------------------------------

{ TModuleCreator protected: IOTAModuleCreator }

//----------------------------------------------------------------------------------------------------------------------

function TModuleCreator.GetAncestorName: string;

begin
  Result := FAncestorName;
end;

//----------------------------------------------------------------------------------------------------------------------

function TModuleCreator.GetFormName: string;

begin
  Result := FFormName;
end;

//----------------------------------------------------------------------------------------------------------------------

function TModuleCreator.GetImplFileName: string;

begin
  Result := FImplFileName;
end;

//----------------------------------------------------------------------------------------------------------------------

function TModuleCreator.GetIntfFileName: string;

begin
  Result := FIntfFileName;
end;

//----------------------------------------------------------------------------------------------------------------------

function TModuleCreator.GetMainForm: Boolean;

begin
  Result := FMainForm;
end;

//----------------------------------------------------------------------------------------------------------------------

function TModuleCreator.GetShowForm: Boolean;

begin
  Result := FShowForm;
end;

//----------------------------------------------------------------------------------------------------------------------

function TModuleCreator.GetShowSource: Boolean;

begin
  Result := FShowSource;
end;

//----------------------------------------------------------------------------------------------------------------------

function TModuleCreator.NewFormFile(const FormIdent, AncestorIdent: string): IOTAFile;

begin
  if FSourceForm.Text = '' then
    Result := nil
  else
    Result := TModuleFile.Create(Self, mstForm, '', FormIdent, AncestorIdent);
end;

//----------------------------------------------------------------------------------------------------------------------

function TModuleCreator.NewImplSource(const ModuleIdent, FormIdent, AncestorIdent: string): IOTAFile;

begin
  if FSourceImpl.Text = '' then
    Result := nil
  else
    Result := TModuleFile.Create(Self, mstImpl, ModuleIdent, FormIdent, AncestorIdent);
end;

//----------------------------------------------------------------------------------------------------------------------

function TModuleCreator.NewIntfSource(const ModuleIdent, FormIdent, AncestorIdent: string): IOTAFile;

begin
  if FSourceIntf.Text = '' then
    Result := nil
  else
    Result := TModuleFile.Create(Self, mstIntf, ModuleIdent, FormIdent, AncestorIdent);
end;

//----------------------------------------------------------------------------------------------------------------------

procedure TModuleCreator.FormCreated(const FormEditor: IOTAFormEditor);

begin
  if Assigned(FOnFormCreated) then
    FOnFormCreated(Self, FormEditor);
end;

//----------------------------------------------------------------------------------------------------------------------

function TModuleCreator.GetOwnerModule: IOTAModule;

begin
  Result := GetCurrentProject as IOTAModule;
  if Assigned(FOnGetOwner) then
    FOnGetOwner(Self, Result);
end;

//----------------------------------------------------------------------------------------------------------------------

{ TModuleCreator public }

//----------------------------------------------------------------------------------------------------------------------

constructor TModuleCreator.Create(AOwner: TComponent);

begin
  inherited Create(AOwner);
  FCreatorType := ctForm;
  FShowForm := True;
  FShowSource := True;
  FSourceForm := TStringList.Create;
  FSourceImpl := TStringList.Create;
  FSourceIntf := TStringList.Create;
end;

//----------------------------------------------------------------------------------------------------------------------

destructor TModuleCreator.Destroy;

begin
  FSourceForm.Free;
  FSourceImpl.Free;
  FSourceIntf.Free;
  inherited Destroy;
end;

//----------------------------------------------------------------------------------------------------------------------

{ TProjectCreator protected: IOTAProjectCreator}

//----------------------------------------------------------------------------------------------------------------------

function TProjectCreator.GetFileName: string;

begin
  Result := FFileName;
end;

//----------------------------------------------------------------------------------------------------------------------

function TProjectCreator.GetOptionFileName: string;

begin
  Result := FOptionFileName;
end;

//----------------------------------------------------------------------------------------------------------------------

function TProjectCreator.GetShowSource: Boolean;

begin
  Result := FShowSource;
end;

//----------------------------------------------------------------------------------------------------------------------

procedure TProjectCreator.NewDefaultModule;

begin
  // do nothing
end;

//----------------------------------------------------------------------------------------------------------------------

function TProjectCreator.NewOptionSource(const ProjectName: string): IOTAFile;

begin
  Result := nil;
end;

//----------------------------------------------------------------------------------------------------------------------

procedure TProjectCreator.NewProjectResource(const Project: IOTAProject);

begin
  if Assigned(FOnNewProjectResource) then
    FOnNewProjectResource(Self, Project);
end;

//----------------------------------------------------------------------------------------------------------------------

function TProjectCreator.NewProjectSource(const ProjectName: string): IOTAFile;

begin
  Result := nil;
end;

//----------------------------------------------------------------------------------------------------------------------

{ TProjectCreator protected: IOTAProjectCreator50 }

//----------------------------------------------------------------------------------------------------------------------

procedure TProjectCreator.NewDefaultProjectModule(const Project: IOTAProject);

begin
  if Assigned(FOnNewDefaultModule) then
    FOnNewDefaultModule(Self, Project);
end;

//----------------------------------------------------------------------------------------------------------------------

{ TProjectCreator protected }

//----------------------------------------------------------------------------------------------------------------------

function TProjectCreator.GetOwnerModule: IOTAModule;

begin
  Result := GetCurrentProjectGroup;
  if Assigned(FOnGetOwner) then
    FOnGetOwner(Self, Result);
end;

//----------------------------------------------------------------------------------------------------------------------

{ TProjectCreator public }

//----------------------------------------------------------------------------------------------------------------------

constructor TProjectCreator.Create(AOwner: TComponent);

begin
  inherited Create(AOwner);
  FCreatorType := ctPackage;
  FShowSource := True;
end;

//----------------------------------------------------------------------------------------------------------------------

end.

⌨️ 快捷键说明

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