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

📄 teechartexp.pas

📁 Delphi TeeChartPro.6.01的源代码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
               FmtWrite(result,'%s *%s;'+CRLF,[ClassName,Name]);

          for t:=0 to Tools.Count-1 do
          with Tools[t] do
               FmtWrite(result,'%s *%s;'+CRLF,[ClassName,Name]);
        end;

        FmtWrite(Result,'private:'+CRLF +
                 'public:' +CRLF +
                 '  __fastcall T%0:s::T%0:s(TComponent* Owner);' + CRLF +
                 '};' + CRLF ,[FormIdent]);

        FmtWrite(Result,
          DashLine + CRLF +
          'extern  T%0:s *%0:s;' + CRLF +
          DashLine + CRLF +
          '#endif', [FormIdent]);
        Result.Position := 0;
      except
        Result.Free;
        raise;
      end;
    finally
      StrDispose(SourceBuffer);
    end;
  end;

  function CreateCppSource(const UnitIdent,FormIdent:String): TMemoryStream;
  begin
    SourceBuffer := StrAlloc(SourceBufferSize);
    with D do
    try
      Result := TMemoryStream.Create;
      try
        FmtWrite(Result,
          DashLine + CRLF + CRLF +
          '#include <vcl\vcl.h>' + CRLF +
          '#pragma hdrstop' + CRLF +
          CRLF +
          '#include "%0:s.h"' + CRLF +
          DashLine + CRLF +
          '#pragma package(smart_init)' + CRLF +
          '#pragma resource "*.dfm"' + CRLF +
          'T%1:s *%1:s;' + CRLF +
          DashLine + CRLF +
          '__fastcall T%1:s::T%1:s(TComponent* Owner)' + CRLF +
          '        : TForm(Owner)' + CRLF +
          '{' + CRLF +
          '}' + CRLF +
          DashLine, [UnitIdent, FormIdent]);
        Result.Position := 0;
      except
        Result.Free;
        raise;
      end;
    finally
      StrDispose(SourceBuffer);
    end;
  end;

{$ELSE}

  function CreateSource(const UnitIdent, FormIdent: string;
                        AForm:TCustomForm): TMemoryStream;
  begin
    SourceBuffer := StrAlloc(SourceBufferSize);
    try
      Result := TMemoryStream.Create;
      try
        FmtWrite(Result,GetPascalSource(D,AForm,UnitIdent,FormIdent),[nil]);
        Result.Position := 0;
      except
        Result.Free;
        raise;
      end;
    finally
      StrDispose(SourceBuffer);
    end;
  end;
{$ENDIF}

var {$IFDEF BCB}
    IHeaderStream : TIMemoryStream;
    {$ENDIF}
    ISourceStream : TIMemoryStream;
    IFormStream   : TIMemoryStream;
    UnitIdent     : String;
    FormIdent     : String;
    FileName      : String;
    ChartForm     : TForm;
    tmpStream     : TMemoryStream;
begin
  if (ToolServices<>nil) and
     ToolServices.GetNewModuleName(UnitIdent, FileName) then
  begin
    D := TTeeDlgWizard.Create(Application);
    try
      if D.ShowModal = mrOK then
      begin
        UnitIdent := LowerCase(UnitIdent);
        UnitIdent[1] := Upcase(UnitIdent[1]);
        FormIdent := 'Form' + Copy(UnitIdent, 5, 255);

        ChartForm:=DoFormCreation(D,FormIdent);
        try
          tmpStream:=TMemoryStream.Create;
          tmpStream.WriteComponentRes(FormIdent, ChartForm);
          tmpStream.Position:=0;

          IFormStream := TIMemoryStream.Create(tmpStream);

          {$IFDEF BCB}
            IHeaderStream := TIMemoryStream.Create(CreateHeader(UnitIdent,FormIdent), soOwned);
            ISourceStream := TIMemoryStream.Create(CreateCppSource(UnitIdent,FormIdent), soOwned);
            ToolServices.CreateCppModule(FileName, '', '', '', IHeaderStream,
              ISourceStream, IFormStream, [cmAddToProject, cmShowSource,
              cmShowForm, cmUnNamed, cmMarkModified]);
          {$ELSE}
            ISourceStream := TIMemoryStream.Create(CreateSource(UnitIdent,FormIdent,ChartForm));
            ToolServices.CreateModule(FileName, ISourceStream, IFormStream,
                  [ cmAddToProject, cmShowSource, cmShowForm, cmUnNamed,
                    cmMarkModified]);
          {$ENDIF}
        finally
          ChartForm.Free;
        end;
      end;
    finally
      D.Free;
    end;
  end;
end;
{$ENDIF}

{ TTeeChartWizard }
function TTeeChartWizard.GetName: string;
begin
  Result:=TeeMsg_TeeChartWizard;
end;

function TTeeChartWizard.GetComment: string;
begin
  Result:=TeeMsg_TeeChartWizard;
end;

{$IFDEF D7} // Delphi 5
function TTeeChartWizard.GetGlyph: Cardinal;
{$ELSE}
function TTeeChartWizard.GetGlyph: HICON;
{$ENDIF}
begin
  {$IFDEF D7}
    Result:=LoadIcon(HInstance, 'TEEEXPICON');
  {$ELSE}
  result:=0;
  try
    Result:=LoadIcon(HInstance, 'TEEEXPICON');
  except
    ToolServices.RaiseException(ReleaseException);
  end;
  {$ENDIF}
end;

{$IFNDEF D7}
function TTeeChartWizard.GetStyle: TExpertStyle;
begin
  Result:=esForm;
end;
{$ENDIF}

{$IFDEF D7}
function TTeeChartWizard.GetDesigner: string;
begin
  result:={$IFDEF CLX}dCLX{$ELSE}dVCL{$ENDIF};
end;

function TTeeChartWizard.GetState: TWizardState;
begin
  Result:=[wsEnabled];
end;
{$ELSE}
function TTeeChartWizard.GetState: TExpertState;
begin
  Result:=[esEnabled];
end;
{$ENDIF}

function TTeeChartWizard.GetIDString: string;
begin
  Result:=TeeMsg_TeeChartIDWizard;
end;

function TTeeChartWizard.GetAuthor: string;
begin
  Result:=TeeMsg_TeeChartSL;
end;

function TTeeChartWizard.GetPage: string;
begin
  Result:=TeeMsg_WizardTab;
end;

procedure TTeeChartWizard.Execute;
{$IFDEF D7}
var D: TTeeDlgWizard;
{$ENDIF}
begin
  {$IFDEF D7}
  D := TTeeDlgWizard.Create(Application);
  try
    if D.ShowModal = mrOK then
       (BorlandIDEServices as IOTAModuleServices).CreateModule(TTeeChartModuleCreator.Create(D));
  finally
    D.Free;
  end;
  {$ELSE}
  try
    TeeChartWizard(ToolServices);
  except
    ToolServices.RaiseException(ReleaseException);
  end;
  {$ENDIF}
end;

function TTeeChartWizard.GetMenuText: string;
begin
  result:=TeeMsg_TeeChartWizard+'...';
end;

Procedure Register;
begin
  {$IFDEF D7}
  RegisterPackageWizard(TTeeChartWizard.Create);
  {$ELSE}
  RegisterLibraryExpert(TTeeChartWizard.Create);
  {$ENDIF}
end;

{$IFDEF D7}

{ TTeeChartModuleCreator }

Constructor TTeeChartModuleCreator.Create(AWizard:TTeeDlgWizard);
begin
  inherited Create;
  Wizard:=AWizard;
end;

destructor TTeeChartModuleCreator.Destroy;
begin
  FreeAndNil(TheForm);
  inherited;
end;

procedure TTeeChartModuleCreator.FormCreated(
  const FormEditor: IOTAFormEditor);
begin
  // do nothing
end;

function TTeeChartModuleCreator.GetAncestorName: string;
begin
  Result := 'Form';
end;

function TTeeChartModuleCreator.GetCreatorType: string;
begin
  Result := sForm;
end;

function TTeeChartModuleCreator.GetExisting: Boolean;
begin
  Result := False;
end;

function TTeeChartModuleCreator.GetFileSystem: string;
begin
  Result := '';
end;

function TTeeChartModuleCreator.GetFormName: string;
begin
  Result := '';
end;

function TTeeChartModuleCreator.GetImplFileName: string;
begin
  Result := '';
end;

function TTeeChartModuleCreator.GetIntfFileName: string;
begin
  Result := '';
end;

function TTeeChartModuleCreator.GetMainForm: Boolean;
begin
  Result := False;
end;

// From Delphi 7 help file
function TTeeChartModuleCreator.GetOwner: IOTAModule;
var
  I: Integer;
  Svc: IOTAModuleServices;
  Module: IOTAModule;
  Project: IOTAProject;
  Group: IOTAProjectGroup;
begin
  { Return the current project. }
  Supports(BorlandIDEServices, IOTAModuleServices, Svc);
  Result := nil;
  for I := 0 to Svc.ModuleCount - 1 do
  begin
    Module := Svc.Modules[I];
    if Supports(Module, IOTAProject, Project) then
    begin
      { Remember the first project module}
      if Result = nil then
        Result := Project;
    end
    else if Supports(Module, IOTAProjectGroup, Group) then
    begin
      { Found the project group, so return its active project}
      Result := Group.ActiveProject;
      Exit;
    end;
  end;
end;

function TTeeChartModuleCreator.GetShowForm: Boolean;
begin
  Result := True;
end;

function TTeeChartModuleCreator.GetShowSource: Boolean;
begin
  Result := True;
end;

function TTeeChartModuleCreator.GetUnnamed: Boolean;
begin
  Result := True;
end;

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

  function ComponentToString(Component: TComponent): string;
  var
    BinStream:TMemoryStream;
    StrStream: TStringStream;
    s: string;
  begin
    BinStream := TMemoryStream.Create;
    try
      StrStream := TStringStream.Create(s);
      try
        BinStream.WriteComponent(Component);
        BinStream.Seek(0, soFromBeginning);
        ObjectBinaryToText(BinStream, StrStream);
        StrStream.Seek(0, soFromBeginning);
        Result:= StrStream.DataString;
      finally
        StrStream.Free;
      end;
    finally
      BinStream.Free
    end;
  end;

begin
  if not Assigned(TheForm) then
     TheForm:=DoFormCreation(Wizard,FormIdent);
  result:=StringToIOTAFile(ComponentToString(TheForm));
end;

function TTeeChartModuleCreator.NewImplSource(const ModuleIdent, FormIdent,
  AncestorIdent: string): IOTAFile;
begin
  if not Assigned(TheForm) then
     TheForm:=DoFormCreation(Wizard,FormIdent);

  result:=StringToIOTAFile(GetPascalSource(Wizard,TheForm,ModuleIdent,FormIdent));
end;

function TTeeChartModuleCreator.NewIntfSource(const ModuleIdent, FormIdent,
  AncestorIdent: string): IOTAFile;
begin
  Result := nil;
end;
{$ENDIF}

end.

⌨️ 快捷键说明

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