IDE: designer added option to ask for component name on create

git-svn-id: trunk@22221 -
This commit is contained in:
mattias 2009-10-18 11:32:42 +00:00
parent 791747d822
commit 8d7e5bda13
3 changed files with 42 additions and 7 deletions

View File

@ -45,7 +45,7 @@ uses
// IDE
LazarusIDEStrConsts, EnvironmentOpts, IDECommands, ComponentReg,
NonControlDesigner, FrameDesigner, AlignCompsDlg, SizeCompsDlg, ScaleCompsDlg,
TabOrderDlg, DesignerProcs, CustomFormEditor,
TabOrderDlg, DesignerProcs, CustomFormEditor, AskCompNameDlg,
ControlSelection, ChangeClassDialog, EditorOptions;
type
@ -1728,6 +1728,7 @@ var
NewParentControl: TWinControl;
NewComponent: TComponent;
NewComponentClass: TComponentClass;
NewName: String;
begin
if MouseDownComponent=nil then exit;
@ -1831,6 +1832,13 @@ var
if Assigned(FOnSetDesigning) then
FOnSetDesigning(Self,NewComponent,True);
if EnvironmentOptions.CreateComponentFocusNameProperty then begin
// ask user for name
NewName:=NewComponent.Name;
ShowComponentNameDialog(LookupRoot,NewComponent,NewName);
NewComponent.Name:=NewName;
end;
// tell IDE about the new component (e.g. add it to the source)
NotifyPersistentAdded(NewComponent);

View File

@ -166,6 +166,7 @@ type
FDebuggerSearchPath: string;
// designer
FCreateComponentFocusNameProperty: boolean;
FDesignerPaintLazy: boolean;
FShowBorderSpacing: boolean;
FShowGrid: boolean;
@ -242,6 +243,7 @@ type
fCharcaseFileAction : TCharCaseFileAction;
fAmbiguousFileAction: TAmbiguousFileAction;
FUnitRenameReferencesAction: TUnitRenameReferencesAction;
FAskForFilenameOnNewFile: boolean;
// lazdoc
FLazDocPaths: string;
@ -361,6 +363,8 @@ type
write FRubberbandSelectsGrandChilds;
property DesignerPaintLazy: boolean read FDesignerPaintLazy
write FDesignerPaintLazy;
property CreateComponentFocusNameProperty: boolean read FCreateComponentFocusNameProperty
write FCreateComponentFocusNameProperty;
// object inspector
property ObjectInspectorOptions: TOIOptions read FObjectInspectorOptions
@ -450,6 +454,8 @@ type
write fCharcaseFileAction;
property UnitRenameReferencesAction: TUnitRenameReferencesAction
read FUnitRenameReferencesAction write FUnitRenameReferencesAction;
property AskForFilenameOnNewFile: boolean read FAskForFilenameOnNewFile
write FAskForFilenameOnNewFile;
// lazdoc
property LazDocPaths: string read FLazDocPaths write FLazDocPaths;
@ -655,6 +661,7 @@ begin
FRubberbandCreationColor:=clMaroon;
FRubberbandSelectsGrandChilds:=true;
FDesignerPaintLazy:=true;
FCreateComponentFocusNameProperty:=false;
// object inspector
FObjectInspectorOptions:=TOIOptions.Create;
@ -717,6 +724,7 @@ begin
fPascalFileExtension:=petPAS;
fCharcaseFileAction:=ccfaAutoRename;
FUnitRenameReferencesAction:=urraAsk;
FAskForFilenameOnNewFile:=false;
// lazdoc
FLazDocPaths:=SetDirSeparators(DefaultLazDocPath);
@ -910,6 +918,8 @@ begin
false);
FDesignerPaintLazy:=XMLConfig.GetValue(
Path+'FormEditor/DesignerPaint/Lazy/Value',true);
FCreateComponentFocusNameProperty:=XMLConfig.GetValue(
Path+'FormEditor/CreateComponentFocusNameProperty/Value',false);
if not OnlyDesktop then begin
// files
@ -1036,6 +1046,8 @@ begin
CurPath,AmbiguousFileActionNames[fAmbiguousFileAction]));
FUnitRenameReferencesAction:=UnitRenameReferencesActionNameToType(XMLConfig.GetValue(
Path+'UnitRenameReferencesAction/Value',UnitRenameReferencesActionNames[urraAsk]));
FAskForFilenameOnNewFile:=XMLConfig.GetValue(
Path+'AskForFilenameOnNewFile/Value',false);
//lazdoc
FLazDocPaths := XMLConfig.GetValue(Path+'LazDoc/Paths', DefaultLazDocPath);
@ -1163,6 +1175,8 @@ begin
FRubberbandSelectsGrandChilds,false);
XMLConfig.SetDeleteValue(
Path+'FormEditor/DesignerPaint/Lazy/Value',FDesignerPaintLazy,true);
XMLConfig.SetDeleteValue(
Path+'FormEditor/CreateComponentFocusNameProperty/Value',FCreateComponentFocusNameProperty,false);
XMLConfig.SetDeleteValue(
Path+'ShowCompileDialog/Value',FShowCompileDialog,False);
@ -1249,18 +1263,14 @@ begin
// naming
XMLConfig.SetDeleteValue(Path+'Naming/PascalFileExtension',
PascalExtension[fPascalFileExtension],'.pas');
XMLConfig.SetDeleteValue(Path+'CharcaseFileAction/Value',
CharCaseFileActionNames[fCharcaseFileAction],
CharCaseFileActionNames[ccfaAutoRename]);
XMLConfig.SetDeleteValue(Path+'UnitRenameReferencesAction/Value',
UnitRenameReferencesActionNames[FUnitRenameReferencesAction],
UnitRenameReferencesActionNames[urraAsk]);
XMLConfig.SetDeleteValue(Path+'AutoDeleteAmbiguousSources/Value',
AmbiguousFileActionNames[fAmbiguousFileAction],
AmbiguousFileActionNames[afaAsk]);
XMLConfig.SetDeleteValue(Path+'AskForFilenameOnNewFile/Value',
FAskForFilenameOnNewFile,false);
// lazdoc
XMLConfig.SetDeleteValue(Path+'LazDoc/Paths',FLazDocPaths,DefaultLazDocPath);

View File

@ -4482,6 +4482,23 @@ resourcestring
lisUsePackageInPackage2 = 'Use package in package';
lisCenterForm = 'Center form';
lisFindMissingUnit = 'Find missing unit';
lisFocusNameOnCreate = 'Focus name on create';
lisAfterPuttingANewComponentOnADesignerFormFocusTheNa = 'After putting a '
+'new component on a designer form, focus the name property in the Object '
+'Inspector';
lisEmpty = 'Empty';
lisNotAValidPascalIdentifier = 'Not a valid pascal identifier';
lisThereIsAlreadyAComponentWithThisName = 'There is already a component '
+'with this name';
lisTheOwnerHasThisName = 'The owner has this name';
lisTheOwnerClassHasThisName = 'The owner class has this name';
lisTheUnitHasThisName = 'The unit has this name';
lisChooseName = 'Choose name';
lisChooseANameForTheNewComponent = 'Choose a name for the new component';
lisTheComponentNameMustBeUniqueInAllComponentsOnTheFo = 'The component name '
+'must be unique in all components on the form/datamodule.The name is '
+'compared case insensitive like a normal pascal identifier.';
lisAskForFileNameOnNewFile = 'Ask for file name on new file';
implementation