ide: add compiler inherited options frame

git-svn-id: trunk@23342 -
This commit is contained in:
paul 2010-01-02 09:31:05 +00:00
parent 5413724717
commit 074ef3ac0d
6 changed files with 326 additions and 2 deletions

3
.gitattributes vendored
View File

@ -3399,6 +3399,9 @@ ide/frames/codetools_wordpolicy_options.pas svneol=native#text/pascal
ide/frames/compiler_codegen_options.lfm svneol=native#text/plain
ide/frames/compiler_codegen_options.lrs svneol=native#text/pascal
ide/frames/compiler_codegen_options.pas svneol=native#text/pascal
ide/frames/compiler_inherited_options.lfm svneol=native#text/plain
ide/frames/compiler_inherited_options.lrs svneol=native#text/pascal
ide/frames/compiler_inherited_options.pas svneol=native#text/pascal
ide/frames/compiler_linking_options.lfm svneol=native#text/plain
ide/frames/compiler_linking_options.lrs svneol=native#text/pascal
ide/frames/compiler_linking_options.pas svneol=native#text/pascal

View File

@ -0,0 +1,49 @@
inherited CompilerInheritedOptionsFrame: TCompilerInheritedOptionsFrame
Height = 444
Width = 576
ClientHeight = 444
ClientWidth = 576
DesignLeft = 957
DesignTop = 308
object InhNoteLabel: TLabel[0]
Left = 0
Height = 14
Top = 0
Width = 576
Align = alTop
Caption = 'InhNoteLabel'
ParentColor = False
end
object InhTreeView: TTreeView[1]
Left = 0
Height = 247
Top = 14
Width = 576
Align = alTop
DefaultItemHeight = 15
ReadOnly = True
RightClickSelect = True
TabOrder = 0
OnSelectionChanged = InhTreeViewSelectionChanged
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips]
end
object InhItemMemo: TMemo[2]
Left = 0
Height = 178
Top = 266
Width = 576
Align = alClient
ReadOnly = True
ScrollBars = ssAutoVertical
TabOrder = 1
end
object InhSplitter: TSplitter[3]
Cursor = crVSplit
Left = 0
Height = 5
Top = 261
Width = 576
Align = alTop
ResizeAnchor = akTop
end
end

View File

@ -0,0 +1,20 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TCompilerInheritedOptionsFrame','FORMDATA',[
'TPF0'#241#30'TCompilerInheritedOptionsFrame'#29'CompilerInheritedOptionsFram'
+'e'#6'Height'#3#188#1#5'Width'#3'@'#2#12'ClientHeight'#3#188#1#11'ClientWidt'
+'h'#3'@'#2#10'DesignLeft'#3#189#3#9'DesignTop'#3'4'#1#0#242#2#0#6'TLabel'#12
+'InhNoteLabel'#4'Left'#2#0#6'Height'#2#14#3'Top'#2#0#5'Width'#3'@'#2#5'Align'
+#7#5'alTop'#7'Caption'#6#12'InhNoteLabel'#11'ParentColor'#8#0#0#242#2#1#9'TT'
+'reeView'#11'InhTreeView'#4'Left'#2#0#6'Height'#3#247#0#3'Top'#2#14#5'Width'
+#3'@'#2#5'Align'#7#5'alTop'#17'DefaultItemHeight'#2#15#8'ReadOnly'#9#16'Righ'
+'tClickSelect'#9#8'TabOrder'#2#0#18'OnSelectionChanged'#7#27'InhTreeViewSele'
+'ctionChanged'#7'Options'#11#17'tvoAutoItemHeight'#16'tvoHideSelection'#21't'
+'voKeepCollapsedNodes'#11'tvoReadOnly'#19'tvoRightClickSelect'#14'tvoShowBut'
+'tons'#12'tvoShowLines'#11'tvoShowRoot'#11'tvoToolTips'#0#0#0#242#2#2#5'TMem'
+'o'#11'InhItemMemo'#4'Left'#2#0#6'Height'#3#178#0#3'Top'#3#10#1#5'Width'#3'@'
+#2#5'Align'#7#8'alClient'#8'ReadOnly'#9#10'ScrollBars'#7#14'ssAutoVertical'#8
+'TabOrder'#2#1#0#0#242#2#3#9'TSplitter'#11'InhSplitter'#6'Cursor'#7#8'crVSpl'
+'it'#4'Left'#2#0#6'Height'#2#5#3'Top'#3#5#1#5'Width'#3'@'#2#5'Align'#7#5'alT'
+'op'#12'ResizeAnchor'#7#5'akTop'#0#0#0
]);

View File

@ -0,0 +1,245 @@
unit compiler_inherited_options;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ComCtrls, ExtCtrls, IDEOptionsIntf, Project, CompilerOptions,
LazarusIDEStrConsts, IDEImagesIntf, IDEProcs;
type
{ TCompilerInheritedOptionsFrame }
TCompilerInheritedOptionsFrame = class(TAbstractIDEOptionsEditor)
InhItemMemo: TMemo;
InhNoteLabel: TLabel;
InhSplitter: TSplitter;
InhTreeView: TTreeView;
procedure InhTreeViewSelectionChanged(Sender: TObject);
private
ImageIndexInherited: Integer;
ImageIndexRequired: Integer;
ImageIndexPackage: Integer;
InheritedChildDatas: TList; // list of PInheritedNodeData
procedure ClearInheritedTree;
procedure UpdateInheritedTree(CompilerOpts: TBaseCompilerOptions);
public
destructor Destroy; override;
function GetTitle: string; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;
implementation
type
TInheritedNodeData = record
FullText: string;
Option: TInheritedCompilerOption;
end;
PInheritedNodeData = ^TInheritedNodeData;
{ TCompilerInheritedOptionsFrame }
function TCompilerInheritedOptionsFrame.GetTitle: string;
begin
Result := dlgCOInherited;
end;
procedure TCompilerInheritedOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
begin
ImageIndexPackage := IDEImages.LoadImage(16, 'item_package');
ImageIndexRequired := IDEImages.LoadImage(16, 'pkg_required');
ImageIndexInherited := IDEImages.LoadImage(16, 'pkg_inherited');
InhNoteLabel.Caption := lisAdditionalCompilerOptionsInheritedFromPackages;
InhTreeView.Images := IDEImages.Images_16;
InhItemMemo.Text := lisSelectANode;
end;
procedure TCompilerInheritedOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
begin
UpdateInheritedTree(AOptions as TBaseCompilerOptions);
end;
procedure TCompilerInheritedOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
begin
end;
class function TCompilerInheritedOptionsFrame.SupportedOptionsClass:
TAbstractIDEOptionsClass;
begin
Result := TBaseCompilerOptions;
end;
procedure TCompilerInheritedOptionsFrame.UpdateInheritedTree(
CompilerOpts: TBaseCompilerOptions);
var
OptionsList: TFPList;
i: integer;
AncestorOptions: TAdditionalCompilerOptions;
AncestorNode: TTreeNode;
procedure AddChildNode(const NewNodeName, Value: string;
Option: TInheritedCompilerOption);
var
VisibleValue: string;
ChildNode: TTreeNode;
ChildData: PInheritedNodeData;
begin
if Value = '' then
exit;
New(ChildData);
ChildData^.FullText := Value;
ChildData^.Option := Option;
if InheritedChildDatas = nil then
InheritedChildDatas := TList.Create;
InheritedChildDatas.Add(ChildData);
if length(Value) > 100 then
VisibleValue := copy(Value, 1, 100) + '[...]'
else
VisibleValue := Value;
ChildNode := InhTreeView.Items.AddChildObject(AncestorNode,
NewNodeName + ' = "' + VisibleValue + '"', ChildData);
ChildNode.ImageIndex := ImageIndexRequired;
ChildNode.SelectedIndex := ChildNode.ImageIndex;
end;
begin
OptionsList := nil;
CompilerOpts.GetInheritedCompilerOptions(OptionsList);
InhTreeView.BeginUpdate;
ClearInheritedTree;
if OptionsList <> nil then
begin
// add All node
AncestorNode := InhTreeView.Items.Add(nil, lisAllInheritedOptions);
AncestorNode.ImageIndex := ImageIndexInherited;
AncestorNode.SelectedIndex := AncestorNode.ImageIndex;
with CompilerOpts do
begin
AddChildNode(lisunitPath,
GetInheritedOption(icoUnitPath, True), icoUnitPath);
AddChildNode(lisincludePath,
GetInheritedOption(icoIncludePath, True), icoIncludePath);
AddChildNode(lisobjectPath,
GetInheritedOption(icoObjectPath, True), icoObjectPath);
AddChildNode(lislibraryPath,
GetInheritedOption(icoLibraryPath, True), icoLibraryPath);
AddChildNode(lislinkerOptions, GetInheritedOption(icoLinkerOptions, True),
icoLinkerOptions);
AddChildNode(liscustomOptions, GetInheritedOption(icoCustomOptions, True),
icoCustomOptions);
end;
AncestorNode.Expanded := True;
// add detail nodes
for i := 0 to OptionsList.Count - 1 do
begin
AncestorOptions := TAdditionalCompilerOptions(OptionsList[i]);
AncestorNode := InhTreeView.Items.Add(nil, '');
AncestorNode.Text := AncestorOptions.GetOwnerName;
AncestorNode.ImageIndex := ImageIndexPackage;
AncestorNode.SelectedIndex := AncestorNode.ImageIndex;
with AncestorOptions.ParsedOpts do
begin
AddChildNode(lisunitPath,
CreateRelativeSearchPath(GetParsedValue(pcosUnitPath),
CompilerOpts.BaseDirectory),
icoUnitPath);
AddChildNode(lisincludePath,
CreateRelativeSearchPath(GetParsedValue(pcosIncludePath),
CompilerOpts.BaseDirectory),
icoIncludePath);
AddChildNode(lisobjectPath,
CreateRelativeSearchPath(GetParsedValue(pcosObjectPath),
CompilerOpts.BaseDirectory),
icoObjectPath);
AddChildNode(lislibraryPath,
CreateRelativeSearchPath(GetParsedValue(pcosLibraryPath),
CompilerOpts.BaseDirectory),
icoLibraryPath);
AddChildNode(lislinkerOptions, GetParsedValue(pcosLinkerOptions),
icoLinkerOptions);
AddChildNode(liscustomOptions, GetParsedValue(pcosCustomOptions),
icoCustomOptions);
end;
AncestorNode.Expanded := True;
end;
OptionsList.Free;
end
else
begin
InhTreeView.Items.Add(nil, lisNoCompilerOptionsInherited);
end;
InhTreeView.EndUpdate;
end;
destructor TCompilerInheritedOptionsFrame.Destroy;
begin
ClearInheritedTree;
inherited Destroy;
end;
procedure TCompilerInheritedOptionsFrame.ClearInheritedTree;
var
i: integer;
ChildData: PInheritedNodeData;
begin
if InhTreeView = nil then
exit;
InhTreeView.BeginUpdate;
// dispose all child data
if InheritedChildDatas <> nil then
begin
for i := 0 to InheritedChildDatas.Count - 1 do
begin
ChildData := PInheritedNodeData(InheritedChildDatas[i]);
Dispose(ChildData);
end;
InheritedChildDatas.Free;
InheritedChildDatas := nil;
end;
InhTreeView.Items.Clear;
InhTreeView.EndUpdate;
end;
procedure TCompilerInheritedOptionsFrame.InhTreeViewSelectionChanged(Sender: TObject);
var
ANode: TTreeNode;
ChildData: PInheritedNodeData;
sl: TStrings;
begin
ANode := InhTreeView.Selected;
if (ANode = nil) or (ANode.Data = nil) then
begin
InhItemMemo.Lines.Text := lisSelectANode;
end
else
begin
ChildData := PInheritedNodeData(ANode.Data);
if ChildData^.Option in icoAllSearchPaths then
begin
sl := SplitString(ChildData^.FullText, ';');
InhItemMemo.Lines.Assign(sl);
sl.Free;
end
else
InhItemMemo.Lines.Text := ChildData^.FullText;
end;
end;
initialization
{$I compiler_inherited_options.lrs}
RegisterIDEOptionsEditor(GroupCompiler, TCompilerInheritedOptionsFrame,
CompilerOptionsInherited);
end.

View File

@ -43,7 +43,7 @@
<PackageName Value="SynEdit"/>
</Item4>
</RequiredPackages>
<Units Count="66">
<Units Count="67">
<Unit0>
<Filename Value="lazarus.pp"/>
<IsPartOfProject Value="True"/>
@ -498,6 +498,13 @@
<ResourceBaseClass Value="Frame"/>
<UnitName Value="compiler_other_options"/>
</Unit65>
<Unit66>
<Filename Value="frames/compiler_inherited_options.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="CompilerInheritedOptionsFrame"/>
<ResourceBaseClass Value="Frame"/>
<UnitName Value="compiler_inherited_options"/>
</Unit66>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -128,7 +128,7 @@ uses
// project compiler options
compiler_path_options, compiler_parsing_options, compiler_codegen_options,
compiler_linking_options, compiler_verbosity_options, compiler_messages_options,
compiler_other_options,
compiler_other_options, compiler_inherited_options,
PublishModule, EnvironmentOpts, TransferMacros, KeyMapping, IDETranslations,
IDEProcs, ExtToolDialog, ExtToolEditDlg, OutputFilter, JumpHistoryView,