mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-22 18:21:42 +02:00
fixed newdialog to update description on key navigation
git-svn-id: trunk@8921 -
This commit is contained in:
parent
17cc29fb09
commit
2efffcd1b1
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -58,6 +58,7 @@ components/codetools/codetoolsstructs.pas svneol=native#text/pascal
|
||||
components/codetools/codetree.pas svneol=native#text/pascal
|
||||
components/codetools/customcodetool.pas svneol=native#text/pascal
|
||||
components/codetools/definetemplates.pas svneol=native#text/pascal
|
||||
components/codetools/directorycache.pas svneol=native#text/plain
|
||||
components/codetools/eventcodetool.pas svneol=native#text/pascal
|
||||
components/codetools/examples/finddeclaration.lpi svneol=native#text/plain
|
||||
components/codetools/examples/finddeclaration.lpr svneol=native#text/plain
|
||||
|
@ -189,7 +189,7 @@ end;
|
||||
procedure TCodeToolsOptions.SetProjectDir(const AValue: string);
|
||||
begin
|
||||
if FProjectDir=AValue then exit;
|
||||
FProjectDir:=AValue;
|
||||
FProjectDir:=AppendPathDelim(AValue);
|
||||
Modified:=true;
|
||||
end;
|
||||
|
||||
|
@ -463,6 +463,11 @@ function GetDefaultSrcOS2ForTargetOS(const TargetOS: string): string;
|
||||
procedure SplitLazarusCPUOSWidgetCombo(const Combination: string;
|
||||
var CPU, OS, WidgetSet: string);
|
||||
|
||||
// functions to quickly setup some defines
|
||||
function CreateDefinesInDirectories(const SourcePaths, FlagName: string
|
||||
): TDefineTemplate;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
@ -682,6 +687,42 @@ begin
|
||||
WidgetSet:=copy(Combination,StartPos,EndPos-StartPos);
|
||||
end;
|
||||
|
||||
function CreateDefinesInDirectories(const SourcePaths, FlagName: string
|
||||
): TDefineTemplate;
|
||||
var
|
||||
StartPos: Integer;
|
||||
EndPos: LongInt;
|
||||
CurDirectory: String;
|
||||
DirsTempl: TDefineTemplate;
|
||||
DirTempl: TDefineTemplate;
|
||||
SetFlagTempl: TDefineTemplate;
|
||||
begin
|
||||
// create a block template for the directories
|
||||
DirsTempl:=TDefineTemplate.Create(FlagName,
|
||||
'Block of directories to set '+FlagName,
|
||||
'','',da_Block);
|
||||
|
||||
// create a define flag for every directory
|
||||
StartPos:=1;
|
||||
while StartPos<=length(SourcePaths) do begin
|
||||
EndPos:=StartPos;
|
||||
while (EndPos<=length(SourcePaths)) and (SourcePaths[EndPos]<>';') do
|
||||
inc(EndPos);
|
||||
if EndPos>StartPos then begin
|
||||
CurDirectory:=copy(SourcePaths,StartPos,EndPos-StartPos);
|
||||
DirTempl:=TDefineTemplate.Create('FlagDirectory','FlagDirectory',
|
||||
'',CurDirectory,da_Directory);
|
||||
SetFlagTempl:=TDefineTemplate.Create(FlagName,FlagName,
|
||||
FlagName,'1',da_Define);
|
||||
DirTempl.AddChild(SetFlagTempl);
|
||||
DirsTempl.AddChild(DirTempl);
|
||||
end;
|
||||
StartPos:=EndPos+1;
|
||||
end;
|
||||
|
||||
Result:=DirsTempl;
|
||||
end;
|
||||
|
||||
{ TDefineTemplate }
|
||||
|
||||
procedure TDefineTemplate.MarkFlags(
|
||||
|
54
components/codetools/directorycache.pas
Normal file
54
components/codetools/directorycache.pas
Normal file
@ -0,0 +1,54 @@
|
||||
{
|
||||
***************************************************************************
|
||||
* *
|
||||
* This source is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This code is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* General Public License for more details. *
|
||||
* *
|
||||
* A copy of the GNU General Public License is available on the World *
|
||||
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
|
||||
* obtain it by writing to the Free Software Foundation, *
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
Author: Mattias Gaertner
|
||||
|
||||
Abstract:
|
||||
Caches for directories.
|
||||
The codetools works directory based, that means all define templates are the
|
||||
same for all files in a directory.
|
||||
That's why all the units in a directory use the same search paths and find
|
||||
the same files.
|
||||
|
||||
}
|
||||
unit DirectoryCache;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils;
|
||||
|
||||
type
|
||||
TCTDirectoryCache = class
|
||||
public
|
||||
|
||||
end;
|
||||
|
||||
TCTDirectoryCachePool = class
|
||||
public
|
||||
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
|
@ -116,6 +116,7 @@ begin
|
||||
|
||||
// clean up project
|
||||
Project1.RemoveNonExistingFiles(false);
|
||||
// TODO: remove doubles in search paths -> this should be done on loading the .lpi
|
||||
Project1.CompilerOptions.OtherUnitFiles:=
|
||||
RemoveNonExistingPaths(Project1.CompilerOptions.OtherUnitFiles,
|
||||
Project1.ProjectDirectory);
|
||||
|
@ -17,7 +17,6 @@ object NewOtherDialog: TNewOtherDialog
|
||||
BorderSpacing.Around = 6
|
||||
DefaultItemHeight = 14
|
||||
TabOrder = 0
|
||||
OnClick = ItemsTreeViewClick
|
||||
OnDblClick = OkButtonClick
|
||||
OnSelectionChanged = ItemsTreeViewSelectionChanged
|
||||
Left = 6
|
||||
|
@ -8,24 +8,24 @@ LazarusResources.Add('TNewOtherDialog','FORMDATA',[
|
||||
+'r.Page'#3''''#1#4'Left'#3#225#1#6'Height'#3'('#1#3'Top'#3'j'#1#5'Width'#3
|
||||
+#141#1#0#9'TTreeView'#13'ItemsTreeView'#7'Anchors'#11#5'akTop'#6'akLeft'#8'a'
|
||||
+'kBottom'#0#20'BorderSpacing.Around'#2#6#17'DefaultItemHeight'#2#14#8'TabOrd'
|
||||
+'er'#2#0#7'OnClick'#7#18'ItemsTreeViewClick'#10'OnDblClick'#7#13'OkButtonCli'
|
||||
+'ck'#18'OnSelectionChanged'#7#29'ItemsTreeViewSelectionChanged'#4'Left'#2#6#6
|
||||
+'Height'#3#246#0#3'Top'#2#6#5'Width'#3#178#0#0#0#9'TGroupBox'#19'Description'
|
||||
+'GroupBox'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#20'Bord'
|
||||
+'erSpacing.Around'#2#6#7'Caption'#6#19'DescriptionGroupBox'#12'ClientHeight'
|
||||
+#3#229#0#11'ClientWidth'#3#197#0#8'TabOrder'#2#1#22'AnchorSideLeft.Control'#7
|
||||
+#13'ItemsTreeView'#19'AnchorSideLeft.Side'#7#9'asrBottom'#23'AnchorSideRight'
|
||||
+'.Control'#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#3#190#0
|
||||
+#6'Height'#3#246#0#3'Top'#2#6#5'Width'#3#201#0#0#6'TLabel'#16'DescriptionLab'
|
||||
+'el'#5'Align'#7#8'alClient'#20'BorderSpacing.Around'#2#6#7'Caption'#6#16'Des'
|
||||
+'criptionLabel'#5'Color'#7#6'clNone'#11'ParentColor'#8#8'WordWrap'#9#4'Left'
|
||||
+#2#6#6'Height'#3#217#0#3'Top'#2#6#5'Width'#3#185#0#0#0#0#7'TButton'#12'Cance'
|
||||
+'lButton'#7'Anchors'#11#7'akRight'#8'akBottom'#0#8'AutoSize'#9#20'BorderSpac'
|
||||
+'ing.Around'#2#6#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6#12'CancelBut'
|
||||
+'ton'#11'ModalResult'#2#2#8'TabOrder'#2#2#4'Left'#3'2'#1#6'Height'#2#26#3'To'
|
||||
+'p'#3#8#1#5'Width'#2'U'#0#0#7'TButton'#8'OkButton'#7'Anchors'#11#7'akRight'#8
|
||||
+'akBottom'#0#8'AutoSize'#9#20'BorderSpacing.Around'#2#6#25'BorderSpacing.Inn'
|
||||
+'erBorder'#2#2#7'Caption'#6#8'OkButton'#7'Enabled'#8#7'OnClick'#7#13'OkButto'
|
||||
+'nClick'#8'TabOrder'#2#3#23'AnchorSideRight.Control'#7#12'CancelButton'#4'Le'
|
||||
+'ft'#3#239#0#6'Height'#2#26#3'Top'#3#8#1#5'Width'#2'='#0#0#0
|
||||
+'er'#2#0#10'OnDblClick'#7#13'OkButtonClick'#18'OnSelectionChanged'#7#29'Item'
|
||||
+'sTreeViewSelectionChanged'#4'Left'#2#6#6'Height'#3#246#0#3'Top'#2#6#5'Width'
|
||||
+#3#178#0#0#0#9'TGroupBox'#19'DescriptionGroupBox'#7'Anchors'#11#5'akTop'#6'a'
|
||||
+'kLeft'#7'akRight'#8'akBottom'#0#20'BorderSpacing.Around'#2#6#7'Caption'#6#19
|
||||
+'DescriptionGroupBox'#12'ClientHeight'#3#229#0#11'ClientWidth'#3#197#0#8'Tab'
|
||||
+'Order'#2#1#22'AnchorSideLeft.Control'#7#13'ItemsTreeView'#19'AnchorSideLeft'
|
||||
+'.Side'#7#9'asrBottom'#23'AnchorSideRight.Control'#7#5'Owner'#20'AnchorSideR'
|
||||
+'ight.Side'#7#9'asrBottom'#4'Left'#3#190#0#6'Height'#3#246#0#3'Top'#2#6#5'Wi'
|
||||
+'dth'#3#201#0#0#6'TLabel'#16'DescriptionLabel'#5'Align'#7#8'alClient'#20'Bor'
|
||||
+'derSpacing.Around'#2#6#7'Caption'#6#16'DescriptionLabel'#5'Color'#7#6'clNon'
|
||||
+'e'#11'ParentColor'#8#8'WordWrap'#9#4'Left'#2#6#6'Height'#3#217#0#3'Top'#2#6
|
||||
+#5'Width'#3#185#0#0#0#0#7'TButton'#12'CancelButton'#7'Anchors'#11#7'akRight'
|
||||
+#8'akBottom'#0#8'AutoSize'#9#20'BorderSpacing.Around'#2#6#25'BorderSpacing.I'
|
||||
+'nnerBorder'#2#2#7'Caption'#6#12'CancelButton'#11'ModalResult'#2#2#8'TabOrde'
|
||||
+'r'#2#2#4'Left'#3'2'#1#6'Height'#2#26#3'Top'#3#8#1#5'Width'#2'U'#0#0#7'TButt'
|
||||
+'on'#8'OkButton'#7'Anchors'#11#7'akRight'#8'akBottom'#0#8'AutoSize'#9#20'Bor'
|
||||
+'derSpacing.Around'#2#6#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6#8'OkB'
|
||||
+'utton'#7'Enabled'#8#7'OnClick'#7#13'OkButtonClick'#8'TabOrder'#2#3#23'Ancho'
|
||||
+'rSideRight.Control'#7#12'CancelButton'#4'Left'#3#239#0#6'Height'#2#26#3'Top'
|
||||
+#3#8#1#5'Width'#2'='#0#0#0
|
||||
]);
|
||||
|
@ -145,13 +145,13 @@ type
|
||||
OkButton: TButton;
|
||||
CancelButton: TButton;
|
||||
ItemsTreeView: TTreeView;
|
||||
procedure ItemsTreeViewClick(Sender: TObject);
|
||||
procedure ItemsTreeViewSelectionChanged(Sender: TObject);
|
||||
procedure OkButtonClick(Sender: TObject);
|
||||
private
|
||||
FNewItem: TNewIDEItemTemplate;
|
||||
procedure FillItemsTree;
|
||||
procedure SetupComponents;
|
||||
procedure UpdateDescription;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
@ -215,7 +215,7 @@ begin
|
||||
for TemplateID := 0 to Category.Count - 1 do
|
||||
begin
|
||||
Template := Category[TemplateID];
|
||||
DebugLn('TNewOtherDialog.FillItemsTree ',Template.Name,' ',dbgs(Template.VisibleInNewDialog));
|
||||
//DebugLn('TNewOtherDialog.FillItemsTree ',Template.Name,' ',dbgs(Template.VisibleInNewDialog));
|
||||
if Template.VisibleInNewDialog then
|
||||
ItemsTreeView.Items.AddChildObject(NewParentNode, Template.Name,
|
||||
Template);
|
||||
@ -225,7 +225,24 @@ begin
|
||||
ItemsTreeView.EndUpdate;
|
||||
end;
|
||||
|
||||
procedure TNewOtherDialog.ItemsTreeViewClick(Sender: TObject);
|
||||
procedure TNewOtherDialog.ItemsTreeViewSelectionChanged(Sender: TObject);
|
||||
begin
|
||||
OkButton.Enabled := (ItemsTreeView.Selected <> nil) and
|
||||
(TObject(ItemsTreeView.Selected.Data) is TNewIDEItemTemplate);
|
||||
UpdateDescription;
|
||||
end;
|
||||
|
||||
procedure TNewOtherDialog.SetupComponents;
|
||||
begin
|
||||
DescriptionGroupBox.Caption := lisToDoLDescription;
|
||||
DescriptionLabel.Caption := '';
|
||||
OkButton.Caption := lisLazBuildOk;
|
||||
CancelButton.Caption := dlgCancel;
|
||||
DefaultControl := OkButton;
|
||||
CancelControl := CancelButton;
|
||||
end;
|
||||
|
||||
procedure TNewOtherDialog.UpdateDescription;
|
||||
var
|
||||
Desc: string;
|
||||
ANode: TTreeNode;
|
||||
@ -243,22 +260,6 @@ begin
|
||||
DescriptionLabel.Caption := Desc;
|
||||
end;
|
||||
|
||||
procedure TNewOtherDialog.ItemsTreeViewSelectionChanged(Sender: TObject);
|
||||
begin
|
||||
OkButton.Enabled := (ItemsTreeView.Selected <> nil) and
|
||||
(TObject(ItemsTreeView.Selected.Data) is TNewIDEItemTemplate);
|
||||
end;
|
||||
|
||||
procedure TNewOtherDialog.SetupComponents;
|
||||
begin
|
||||
DescriptionGroupBox.Caption := lisToDoLDescription;
|
||||
DescriptionLabel.Caption := '';
|
||||
OkButton.Caption := lisLazBuildOk;
|
||||
CancelButton.Caption := dlgCancel;
|
||||
DefaultControl := OkButton;
|
||||
CancelControl := CancelButton;
|
||||
end;
|
||||
|
||||
constructor TNewOtherDialog.Create(TheOwner: TComponent);
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
|
Loading…
Reference in New Issue
Block a user