started datamodule

git-svn-id: trunk@4217 -
This commit is contained in:
mattias 2003-05-30 16:25:47 +00:00
parent 4ae40aeab0
commit e830dfbe20
5 changed files with 46 additions and 112 deletions

View File

@ -1535,12 +1535,13 @@ resourcestring
+'type.';
lisNewDlgCreateANewPascalUnit = 'Create a new pascal unit.';
lisNewDlgCreateANewUnitWithALCLForm = 'Create a new unit with a LCL form.';
lisNewDlgCreateANewUnitWithADataModule = 'Create a new unit with a datamodule.';
lisNewDlgCreateANewEmptyTextFile = 'Create a new empty text file.';
lisNewDlgCreateANewGraphicalApplicationTheProgramFileIsMain = 'Create a new '
lisNewDlgCreateANewGraphicalApplication = 'Create a new '
+'graphical application.%sThe program file is maintained by Lazarus.';
lisNewDlgCreateANewProgramTheProgramFileIsMaintainedByLazar = 'Create a new '
lisNewDlgCreateANewProgram = 'Create a new '
+'program.%sThe program file is maintained by Lazarus.';
lisNewDlgCreateANewProgram = 'Create a new program.';
lisNewDlgCreateANewCustomProgram = 'Create a new program.';
lisNewDlgCreateANewStandardPackageAPackageIsACollectionOfUn = 'Create a new '
+'standard package.%sA package is a collection of units and components.';

View File

@ -50,6 +50,7 @@ type
niiCustom, // for experts (IDE plugins)
niiUnit, // pascal unit
niiForm, // pascal unit with lcl form
niiDataModule, // pascal nuit with datamodule
niiText, // text file
niiApplication,// Project: Application
niiFPCProject, // Project: with hidden main file
@ -499,19 +500,22 @@ begin
niiForm:
Result:=lisNewDlgCreateANewUnitWithALCLForm;
niiDataModule:
Result:=lisNewDlgCreateANewUnitWithADataModule;
niiText:
Result:=lisNewDlgCreateANewEmptyTextFile;
niiApplication:
Result:=Format(
lisNewDlgCreateANewGraphicalApplicationTheProgramFileIsMain, [#13#13]);
lisNewDlgCreateANewGraphicalApplication, [#13#13]);
niiFPCProject:
Result:=Format(
lisNewDlgCreateANewProgramTheProgramFileIsMaintainedByLazar, [#13#13]);
lisNewDlgCreateANewProgram, [#13#13]);
niiCustomProject:
Result:=lisNewDlgCreateANewProgram;
Result:=lisNewDlgCreateANewCustomProgram;
niiPackage:
Result:=Format(
@ -546,6 +550,10 @@ begin
Add(NewCategory);
NewCategory.Add(TNewIDEItemTemplate.Create(niiUnit,'Unit',niifCopy,[]));
NewCategory.Add(TNewIDEItemTemplate.Create(niiForm,'Form',niifCopy,[]));
{$IFDEF EnableDataMods}
NewCategory.Add(TNewIDEItemTemplate.Create(niiDataModule,'Data Module',
niifCopy,[]));
{$ENDIF}
NewCategory.Add(TNewIDEItemTemplate.Create(niiText,'Text',niifCopy,[]));
// category project

View File

@ -80,7 +80,8 @@ type
fForm: TComponent;
fFormName: string; { classname is always T<FormName>
this attribute contains the formname, even if the unit is not loaded,
or the designer form is not created }
or the designer form is not created.
A form can be a TForm or a TDataModule }
fFormResourceName: string;
fHasResources: boolean; // source has resource file
FIgnoreFileDateOnDiskValid: boolean;
@ -503,7 +504,7 @@ const
);
UnitTypeDefaultExt: array[TNewUnitType] of string = (
'.pas', '.pas', '.pas', '.txt', '.pas'
'.pas', '.pas', '.pas', '.pas', '.txt', '.pas'
);
DefaultTargetFileExt : string = {$IFDEF win32}'.exe'{$ELSE}''{$ENDIF};
@ -971,7 +972,7 @@ begin
if fSource=nil then exit;
NewSource:='';
LE:=EndOfLine;
if NewUnitType in [nuForm,nuUnit] then begin
if NewUnitType in [nuForm,nuUnit,nuDataModule] then begin
fUnitName:=NewUnitName;
AResourceFilename:=fUnitName+ResourceFileExt;
NewSource:=Beautified(
@ -983,6 +984,7 @@ begin
+LE
+'uses'+LE);
case NewUnitType of
nuUnit:
begin
NewSource:=NewSource+Beautified(
@ -990,14 +992,21 @@ begin
+LE
+'implementation'+LE);
end;
nuForm:
nuForm, nuDataModule:
begin
NewSource:=NewSource+Beautified(
' Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs;'+LE
+LE
+'type'+LE
+' T'+fFormName+' = class(TForm)'+LE
+' private'+LE);
+'type'+LE);
if NewUnitType=nuForm then
NewSource:=NewSource+Beautified(
+' T'+fFormName+' = class(TForm)'+LE)
else
NewSource:=NewSource+Beautified(
+' T'+fFormName+' = class(TDataModule)'+LE);
NewSource:=NewSource+Beautified(
' private'+LE);
NewSource:=NewSource
+' { private declarations }'+LE;
NewSource:=NewSource+Beautified(
@ -1016,6 +1025,7 @@ begin
NewSource:=NewSource
+' {$I '+AResourceFilename+'}'+LE;
end;
end;
NewSource:=NewSource+Beautified(
+LE
@ -1687,7 +1697,7 @@ var u:integer;
begin
u:=1;
case NewUnitType of
nuForm,nuUnit: Prefix:='unit';
nuForm,nuUnit,nuDataModule: Prefix:='unit';
else Prefix:='text'
end;
while (UnitNameExists(Prefix+IntToStr(u))) do inc(u);
@ -1718,7 +1728,8 @@ var i: integer;
begin
i:=1;
case NewUnitType of
nuForm, nuUnit: Prefix:='Form'
nuForm, nuUnit: Prefix:='Form';
nuDataModule: Prefix:='DataModule';
else
Prefix:='form';
end;
@ -1727,7 +1738,7 @@ begin
end;
function TProject.AddCreateFormToProjectFile(
const AClassName,AName:string):boolean;
const AClassName, AName: string):boolean;
begin
Result:=CodeToolBoss.AddCreateFormStatement(MainUnitInfo.Source,
AClassName,AName);
@ -2698,6 +2709,9 @@ end.
{
$Log$
Revision 1.123 2003/05/30 16:25:47 mattias
started datamodule
Revision 1.122 2003/05/26 21:03:27 mattias
added README, describing how to create a gtk2 lcl application

View File

@ -49,11 +49,12 @@ type
TProjectWriteFlags = set of TProjectWriteFlag;
TNewUnitType = (
nuEmpty, // no code
nuUnit, // unit
nuForm, // unit with form
nuText,
nuCustomProgram // program
nuEmpty, // no code
nuUnit, // unit
nuForm, // unit with form
nuDataModule, // unit with data module
nuText,
nuCustomProgram // program
);
TUnitUsage = (uuIsPartOfProject, uuIsLoaded, uuIsModified, uuNotUsed);
@ -136,39 +137,7 @@ type
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
end;
//-----------------------------------------------------------------------------
type
TProjectWatchType = (pwtDefault, pwtChar, pwtString, pwtDecimal, pwtHex,
pwtFloat, pwtPointer, pwtRecord, pwtMemDump);
const
ProjectWatchTypeNames : array[TProjectWatchType] of string = (
'Default', 'Character', 'String', 'Decimal', 'Hexadecimal',
'Float', 'Pointer', 'Record', 'MemDump');
type
TProjectWatch = class
private
fExpression: string;
fRepeatCount: integer;
fDigits: integer;
fEnabled: boolean;
fAllowFunctionCalls: boolean;
fTheType: TProjectWatchType;
public
constructor Create;
procedure Clear;
destructor Destroy; override;
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
property Expression: string read fExpression write fExpression;
property RepeatCount: integer read fRepeatCount write fRepeatCount;
property Digits: integer read fDigits write fDigits;
property Enabled: boolean read fEnabled write fEnabled;
property AllowFunctionCalls: boolean
read fAllowFunctionCalls write fAllowFunctionCalls;
property TheType: TProjectWatchType read fTheType write fTheType;
end;
//---------------------------------------------------------------------------
TProjectJumpHistoryPosition = class
private
@ -266,22 +235,10 @@ const
DefPublProjIncFilter = '*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)';
DefPublProjExcFilter = '*.(bak|ppu|ppw|o|so);*~;backup';
function ProjectWatchTypeNameToType(const s: string): TProjectWatchType;
implementation
function ProjectWatchTypeNameToType(const s: string): TProjectWatchType;
begin
for Result:=Low(TProjectWatchType) to High(TProjectWatchType) do
if lowercase(s)=lowercase(ProjectWatchTypeNames[Result]) then exit;
Result:=pwtDefault;
end;
{ TProjectBookmark }
constructor TProjectBookmark.Create;
@ -427,53 +384,6 @@ begin
end;
end;
{ TProjectWatch }
constructor TProjectWatch.Create;
begin
inherited Create;
Clear;
end;
procedure TProjectWatch.Clear;
begin
fExpression:='';
fRepeatCount:=0;
fDigits:=4;
fEnabled:=true;
fAllowFunctionCalls:=true;
fTheType:=pwtDefault;
end;
destructor TProjectWatch.Destroy;
begin
inherited Destroy;
end;
procedure TProjectWatch.LoadFromXMLConfig(XMLConfig: TXMLConfig;
const Path: string);
begin
Clear;
fExpression:=XMLConfig.GetValue(Path+'Expression',fExpression);
fRepeatCount:=XMLConfig.GetValue(Path+'RepeatCount',fRepeatCount);
fDigits:=XMLConfig.GetValue(Path+'Digits',fDigits);
fEnabled:=XMLConfig.GetValue(Path+'Enabled',fEnabled);
fAllowFunctionCalls:=XMLConfig.GetValue(Path+'AllowFunctionCalls',
fAllowFunctionCalls);
fTheType:=ProjectWatchTypeNameToType(XMLConfig.GetValue(Path+'TheType',''));
end;
procedure TProjectWatch.SaveToXMLConfig(XMLConfig: TXMLConfig;
const Path: string);
begin
XMLConfig.SetValue(Path+'Expression',fExpression);
XMLConfig.SetValue(Path+'RepeatCount',fRepeatCount);
XMLConfig.SetValue(Path+'Digits',fDigits);
XMLConfig.SetValue(Path+'Enabled',fEnabled);
XMLConfig.SetValue(Path+'AllowFunctionCalls',fAllowFunctionCalls);
XMLConfig.SetValue(Path+'TheType',ProjectWatchTypeNames[fTheType]);
end;
{ TProjectJumpHistoryPosition }
constructor TProjectJumpHistoryPosition.Create(const AFilename: string;

View File

@ -159,6 +159,7 @@ ResourceString
rsERRORInLCL = 'ERROR in LCL: ';
rsCreatingGdbCatchableError = 'Creating gdb catchable error:';
rsAControlCanNotHaveItselfAsParent = 'A control can''t have itself as parent';
lisLCLResourceSNotFound = 'Resource %s not found';
rsErrorCreatingDeviceContext = 'Error creating device context for %s.%s';
rssIndexOutOfBounds = '%s Index %d out of bounds 0-%d';
rsUnknownPictureExtension = 'Unknown picture extension';