mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-08 15:36:03 +02:00
Package editor: Create property Gui controls in code. Makes them easier to manage and reusable.
git-svn-id: trunk@63943 -
This commit is contained in:
parent
24f2147eae
commit
487e62d70d
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -11294,6 +11294,7 @@ packager/pkgregisterbase.pas svneol=native#text/pascal
|
||||
packager/pkgvirtualuniteditor.pas svneol=native#text/pascal
|
||||
packager/projpackchecks.pas svneol=native#text/pascal
|
||||
packager/projpackcommon.pas svneol=native#text/pascal
|
||||
packager/projpackfilepropgui.pas svneol=native#text/pascal
|
||||
packager/registration/Makefile.compiled svneol=native#text/plain
|
||||
packager/registration/README.txt svneol=native#text/plain
|
||||
packager/registration/fcl.lpk svneol=native#text/plain
|
||||
|
@ -1,7 +1,7 @@
|
||||
object PackageEditorForm: TPackageEditorForm
|
||||
Left = 299
|
||||
Left = 340
|
||||
Height = 455
|
||||
Top = 248
|
||||
Top = 245
|
||||
Width = 464
|
||||
AllowDropFiles = True
|
||||
BorderIcons = [biSystemMenu]
|
||||
@ -32,19 +32,19 @@ object PackageEditorForm: TPackageEditorForm
|
||||
object PropsGroupBox: TGroupBox
|
||||
Left = 0
|
||||
Height = 216
|
||||
Top = 218
|
||||
Top = 216
|
||||
Width = 464
|
||||
Align = alBottom
|
||||
Caption = 'PropsGroupBox'
|
||||
ClientHeight = 196
|
||||
ClientWidth = 462
|
||||
ClientHeight = 186
|
||||
ClientWidth = 460
|
||||
ParentFont = False
|
||||
TabOrder = 3
|
||||
object PropsPageControl: TPageControl
|
||||
Left = 0
|
||||
Height = 196
|
||||
Height = 186
|
||||
Top = 0
|
||||
Width = 462
|
||||
Width = 460
|
||||
ActivePage = CommonOptionsTabSheet
|
||||
Align = alClient
|
||||
ParentFont = False
|
||||
@ -53,158 +53,14 @@ object PackageEditorForm: TPackageEditorForm
|
||||
TabOrder = 0
|
||||
object CommonOptionsTabSheet: TTabSheet
|
||||
Caption = 'Common'
|
||||
ClientHeight = 192
|
||||
ClientWidth = 452
|
||||
ParentFont = False
|
||||
object CallRegisterProcCheckBox: TCheckBox
|
||||
Left = 0
|
||||
Height = 23
|
||||
Top = 0
|
||||
Width = 202
|
||||
Caption = 'CallRegisterProcCheckBox'
|
||||
OnChange = CallRegisterProcCheckBoxChange
|
||||
ParentFont = False
|
||||
ParentShowHint = False
|
||||
ShowHint = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object AddToUsesPkgSectionCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = CallRegisterProcCheckBox
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
Left = 212
|
||||
Height = 23
|
||||
Top = 0
|
||||
Width = 239
|
||||
BorderSpacing.Left = 10
|
||||
Caption = 'AddToUsesPkgSectionCheckBox'
|
||||
OnChange = AddToUsesPkgSectionCheckBoxChange
|
||||
ParentFont = False
|
||||
ParentShowHint = False
|
||||
ShowHint = True
|
||||
TabOrder = 1
|
||||
end
|
||||
object UseMinVersionCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = PropsGroupBox
|
||||
AnchorSideTop.Control = MinVersionEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 0
|
||||
Height = 23
|
||||
Top = 7
|
||||
Width = 191
|
||||
Caption = 'UseMinVersionCheckBox'
|
||||
OnChange = UseMinVersionCheckBoxChange
|
||||
ParentFont = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object MinVersionEdit: TEdit
|
||||
AnchorSideLeft.Control = UseMinVersionCheckBox
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = PropsGroupBox
|
||||
Left = 201
|
||||
Height = 36
|
||||
Top = 0
|
||||
Width = 100
|
||||
BorderSpacing.Left = 10
|
||||
OnChange = MinVersionEditChange
|
||||
ParentFont = False
|
||||
TabOrder = 3
|
||||
Text = 'MinVersionEdit'
|
||||
end
|
||||
object UseMaxVersionCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = PropsGroupBox
|
||||
AnchorSideTop.Control = MaxVersionEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 0
|
||||
Height = 23
|
||||
Top = 45
|
||||
Width = 194
|
||||
Caption = 'UseMaxVersionCheckBox'
|
||||
OnChange = UseMaxVersionCheckBoxChange
|
||||
ParentFont = False
|
||||
TabOrder = 4
|
||||
end
|
||||
object MaxVersionEdit: TEdit
|
||||
AnchorSideLeft.Control = UseMaxVersionCheckBox
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = MinVersionEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 204
|
||||
Height = 36
|
||||
Top = 38
|
||||
Width = 100
|
||||
BorderSpacing.Left = 10
|
||||
BorderSpacing.Top = 2
|
||||
OnChange = MaxVersionEditChange
|
||||
ParentFont = False
|
||||
TabOrder = 5
|
||||
Text = 'MaxVersionEdit'
|
||||
end
|
||||
object ApplyDependencyButton: TButton
|
||||
AnchorSideLeft.Control = PropsGroupBox
|
||||
AnchorSideTop.Control = MaxVersionEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 0
|
||||
Height = 35
|
||||
Top = 80
|
||||
Width = 178
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'ApplyDependencyButton'
|
||||
OnClick = ApplyDependencyButtonClick
|
||||
ParentFont = False
|
||||
TabOrder = 6
|
||||
end
|
||||
object RegisteredPluginsGroupBox: TGroupBox
|
||||
Left = 0
|
||||
Height = 165
|
||||
Top = 27
|
||||
Width = 452
|
||||
Align = alBottom
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'RegisteredPluginsGroupBox'
|
||||
ClientHeight = 145
|
||||
ClientWidth = 450
|
||||
ParentFont = False
|
||||
TabOrder = 7
|
||||
object RegisteredListBox: TListBox
|
||||
Left = 0
|
||||
Height = 145
|
||||
Top = 0
|
||||
Width = 450
|
||||
Align = alClient
|
||||
ItemHeight = 0
|
||||
OnDrawItem = RegisteredListBoxDrawItem
|
||||
ParentFont = False
|
||||
ScrollWidth = 448
|
||||
Style = lbOwnerDrawFixed
|
||||
TabOrder = 0
|
||||
TopIndex = -1
|
||||
end
|
||||
end
|
||||
object DisableI18NForLFMCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = AddToUsesPkgSectionCheckBox
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = AddToUsesPkgSectionCheckBox
|
||||
Left = 457
|
||||
Height = 23
|
||||
Top = 0
|
||||
Width = 225
|
||||
BorderSpacing.Left = 6
|
||||
Caption = 'DisableI18NForLFMCheckBox'
|
||||
OnChange = DisableI18NForLFMCheckBoxChange
|
||||
ParentFont = False
|
||||
ParentShowHint = False
|
||||
ShowHint = True
|
||||
TabOrder = 8
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
object StatusBar: TStatusBar
|
||||
Left = 0
|
||||
Height = 21
|
||||
Top = 434
|
||||
Height = 23
|
||||
Top = 432
|
||||
Width = 464
|
||||
Panels = <>
|
||||
ParentFont = False
|
||||
@ -213,7 +69,7 @@ object PackageEditorForm: TPackageEditorForm
|
||||
Cursor = crVSplit
|
||||
Left = 0
|
||||
Height = 5
|
||||
Top = 213
|
||||
Top = 211
|
||||
Width = 464
|
||||
Align = alBottom
|
||||
ResizeAnchor = akBottom
|
||||
@ -279,8 +135,8 @@ object PackageEditorForm: TPackageEditorForm
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 163
|
||||
Height = 36
|
||||
Top = -4
|
||||
Height = 32
|
||||
Top = -2
|
||||
Width = 300
|
||||
ButtonWidth = 23
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
@ -351,7 +207,7 @@ object PackageEditorForm: TPackageEditorForm
|
||||
end
|
||||
object ItemsTreeView: TTreeView
|
||||
Left = 0
|
||||
Height = 136
|
||||
Height = 134
|
||||
Top = 77
|
||||
Width = 464
|
||||
Align = alClient
|
||||
|
@ -48,7 +48,7 @@ uses
|
||||
MainBase, IDEProcs, LazarusIDEStrConsts, IDEDefs, CompilerOptions,
|
||||
EnvironmentOpts, DialogProcs, InputHistory, PackageDefs, AddToPackageDlg,
|
||||
AddPkgDependencyDlg, AddFPMakeDependencyDlg, ProjPackChecks, PkgVirtualUnitEditor,
|
||||
MissingPkgFilesDlg, PackageSystem, CleanPkgDeps;
|
||||
MissingPkgFilesDlg, PackageSystem, CleanPkgDeps, ProjPackFilePropGui;
|
||||
|
||||
const
|
||||
PackageEditorMenuRootName = 'PackageEditor';
|
||||
@ -202,7 +202,6 @@ type
|
||||
MoveUpBtn: TSpeedButton;
|
||||
DirectoryHierarchyButton: TSpeedButton;
|
||||
OpenButton: TSpeedButton;
|
||||
DisableI18NForLFMCheckBox: TCheckBox;
|
||||
FilterEdit: TTreeFilterEdit;
|
||||
FilterPanel: TPanel;
|
||||
AddPopupMenu: TPopupMenu;
|
||||
@ -223,29 +222,15 @@ type
|
||||
ItemsTreeView: TTreeView;
|
||||
// properties
|
||||
PropsGroupBox: TGroupBox;
|
||||
// file properties
|
||||
CallRegisterProcCheckBox: TCheckBox;
|
||||
AddToUsesPkgSectionCheckBox: TCheckBox;
|
||||
RegisteredPluginsGroupBox: TGroupBox;
|
||||
RegisteredListBox: TListBox;
|
||||
// dependency properties
|
||||
UseMinVersionCheckBox: TCheckBox;
|
||||
MinVersionEdit: TEdit;
|
||||
UseMaxVersionCheckBox: TCheckBox;
|
||||
MaxVersionEdit: TEdit;
|
||||
ApplyDependencyButton: TButton;
|
||||
PropsPageControl: TPageControl;
|
||||
CommonOptionsTabSheet: TTabSheet;
|
||||
// statusbar
|
||||
StatusBar: TStatusBar;
|
||||
// hidden components
|
||||
UsePopupMenu: TPopupMenu;
|
||||
ItemsPopupMenu: TPopupMenu;
|
||||
MorePopupMenu: TPopupMenu;
|
||||
PropsPageControl: TPageControl;
|
||||
CommonOptionsTabSheet: TTabSheet;
|
||||
procedure AddToProjectClick(Sender: TObject);
|
||||
procedure AddToUsesPkgSectionCheckBoxChange(Sender: TObject);
|
||||
procedure ApplyDependencyButtonClick(Sender: TObject);
|
||||
procedure CallRegisterProcCheckBoxChange(Sender: TObject);
|
||||
procedure ChangeFileTypeMenuItemClick(Sender: TObject);
|
||||
procedure CleanDependenciesMenuItemClick(Sender: TObject);
|
||||
procedure ClearDependencyFilenameMenuItemClick(Sender: TObject);
|
||||
@ -257,7 +242,6 @@ type
|
||||
procedure CreateMakefileClick(Sender: TObject);
|
||||
procedure CreateFpmakeFileClick(Sender: TObject);
|
||||
procedure DirectoryHierarchyButtonClick(Sender: TObject);
|
||||
procedure DisableI18NForLFMCheckBoxChange(Sender: TObject);
|
||||
procedure EditVirtualUnitMenuItemClick(Sender: TObject);
|
||||
procedure ExpandDirectoryMenuItemClick(Sender: TObject);
|
||||
procedure FilterEditKeyDown(Sender: TObject; var Key: Word; {%H-}Shift: TShiftState);
|
||||
@ -284,8 +268,6 @@ type
|
||||
procedure FixFilesCaseMenuItemClick(Sender: TObject);
|
||||
procedure HelpBitBtnClick(Sender: TObject);
|
||||
procedure InstallClick(Sender: TObject);
|
||||
procedure MaxVersionEditChange(Sender: TObject);
|
||||
procedure MinVersionEditChange(Sender: TObject);
|
||||
procedure MoveDownBtnClick(Sender: TObject);
|
||||
procedure MoveUpBtnClick(Sender: TObject);
|
||||
procedure OnIdle(Sender: TObject; var {%H-}Done: Boolean);
|
||||
@ -296,8 +278,6 @@ type
|
||||
procedure PackageEditorFormCloseQuery(Sender: TObject; var CanClose: boolean);
|
||||
procedure PublishClick(Sender: TObject);
|
||||
procedure ReAddMenuItemClick(Sender: TObject);
|
||||
procedure RegisteredListBoxDrawItem({%H-}Control: TWinControl; Index: Integer;
|
||||
ARect: TRect; {%H-}State: TOwnerDrawState);
|
||||
procedure RemoveBitBtnClick(Sender: TObject);
|
||||
procedure RevertClick(Sender: TObject);
|
||||
procedure SaveAsClick(Sender: TObject);
|
||||
@ -309,8 +289,6 @@ type
|
||||
procedure SortFilesMenuItemClick(Sender: TObject);
|
||||
procedure UninstallClick(Sender: TObject);
|
||||
procedure UseAllUnitsInDirectoryMenuItemClick(Sender: TObject);
|
||||
procedure UseMaxVersionCheckBoxChange(Sender: TObject);
|
||||
procedure UseMinVersionCheckBoxChange(Sender: TObject);
|
||||
procedure UseNoUnitsInDirectoryMenuItemClick(Sender: TObject);
|
||||
procedure UsePopupMenuPopup(Sender: TObject);
|
||||
procedure ViewPkgSourceClick(Sender: TObject);
|
||||
@ -326,6 +304,7 @@ type
|
||||
FRemovedFilesNode: TTreeNode;
|
||||
FRemovedRequiredNode: TTreeNode;
|
||||
FPlugins: TStringList; // ComponentClassName, Objects=TPkgComponent
|
||||
FPropGui: TProjPackFilePropGui;
|
||||
FShowDirectoryHierarchy: boolean;
|
||||
FSortAlphabetically: boolean;
|
||||
FDirSummaryLabel: TLabel;
|
||||
@ -336,6 +315,9 @@ type
|
||||
procedure DoAddNewFile(NewItem: TNewIDEItemTemplate);
|
||||
procedure FreeNodeData(Typ: TPENodeType);
|
||||
function CreateNodeData(Typ: TPENodeType; aName: string; aRemoved: boolean): TPENodeData;
|
||||
function CreateToolButton(AName, ACaption, AHint, AImageName: String;
|
||||
AOnClick: TNotifyEvent): TToolButton;
|
||||
function CreateDivider: TToolButton;
|
||||
procedure SetDependencyDefaultFilename(AsPreferred: boolean);
|
||||
procedure SetIdleConnected(AValue: boolean);
|
||||
procedure SetShowDirectoryHierarchy(const AValue: boolean);
|
||||
@ -353,8 +335,8 @@ type
|
||||
procedure UpdateRequiredPkgs(Immediately: boolean = false);
|
||||
procedure UpdatePEProperties(Immediately: boolean = false);
|
||||
procedure UpdateButtons(Immediately: boolean = false);
|
||||
procedure UpdateApplyDependencyButton(Immediately: boolean = false);
|
||||
procedure UpdateStatusBar(Immediately: boolean = false);
|
||||
function GetDependencyToUpdate(Immediately: boolean): TPkgDependencyBase;
|
||||
procedure GetDirectorySummary(DirNode: TTreeNode;
|
||||
out FileCount, HasRegisterProcCount, AddToUsesPkgSectionCount: integer);
|
||||
procedure ExtendUnitIncPathForNewUnit(const AnUnitFilename,
|
||||
@ -367,6 +349,12 @@ type
|
||||
procedure FileOptionsToGui;
|
||||
procedure GuiToFileOptions(Restore: boolean);
|
||||
procedure FileOptionsChange(Sender: TObject);
|
||||
procedure CallRegisterProcCheckBoxChange(Sender: TObject);
|
||||
procedure AddToUsesPkgSectionCheckBoxChange(Sender: TObject);
|
||||
procedure ApplyDependencyButtonClick(Sender: TObject);
|
||||
procedure RegisteredListBoxDrawItem({%H-}Control: TWinControl; Index: Integer;
|
||||
ARect: TRect; {%H-}State: TOwnerDrawState);
|
||||
procedure DisableI18NForLFMCheckBoxChange(Sender: TObject);
|
||||
protected
|
||||
fFlags: TPEFlags;
|
||||
procedure SetLazPackage(const AValue: TLazPackage); override;
|
||||
@ -1129,16 +1117,6 @@ begin
|
||||
PackageEditors.InstallPackage(LazPackage);
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.MaxVersionEditChange(Sender: TObject);
|
||||
begin
|
||||
UpdateApplyDependencyButton;
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.MinVersionEditChange(Sender: TObject);
|
||||
begin
|
||||
UpdateApplyDependencyButton;
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.SetDepDefaultFilenameMenuItemClick(Sender: TObject);
|
||||
begin
|
||||
SetDependencyDefaultFilename(false);
|
||||
@ -1269,14 +1247,14 @@ begin
|
||||
if CurObject is TPkgComponent then begin
|
||||
// draw registered component
|
||||
CurComponent:=TPkgComponent(CurObject);
|
||||
with RegisteredListBox.Canvas do begin
|
||||
with FPropGui.RegisteredListBox do begin
|
||||
if Assigned(CurComponent.RealPage) then
|
||||
CurStr:=Format(lisPckEditPage,[CurComponent.ComponentClass.ClassName,
|
||||
CurComponent.RealPage.PageName])
|
||||
else
|
||||
CurStr:=CurComponent.ComponentClass.ClassName;
|
||||
TxtH:=TextHeight(CurStr);
|
||||
FillRect(ARect);
|
||||
TxtH:=Canvas.TextHeight(CurStr);
|
||||
Canvas.FillRect(ARect);
|
||||
IL:=CurComponent.Images;
|
||||
II:=CurComponent.ImageIndex;
|
||||
//DebugLn('TPackageEditorForm.RegisteredListBoxDrawItem ',DbgSName(CurIcon),' ',CurComponent.ComponentClass.ClassName);
|
||||
@ -1284,14 +1262,12 @@ begin
|
||||
Res := IL.ResolutionForControl[0, Self];
|
||||
IconWidth:=Res.Width;
|
||||
IconHeight:=Res.Height;
|
||||
Res.Draw(RegisteredListBox.Canvas,
|
||||
Res.Draw(Canvas,
|
||||
ARect.Left+(25-IconWidth) div 2,
|
||||
ARect.Top+(ARect.Bottom-ARect.Top-IconHeight) div 2,
|
||||
II);
|
||||
ARect.Top+(ARect.Bottom-ARect.Top-IconHeight) div 2, II);
|
||||
end;
|
||||
TextOut(ARect.Left+25,
|
||||
ARect.Top+(ARect.Bottom-ARect.Top-TxtH) div 2,
|
||||
CurStr);
|
||||
Canvas.TextOut(ARect.Left+25,
|
||||
ARect.Top+(ARect.Bottom-ARect.Top-TxtH) div 2, CurStr);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -1467,6 +1443,7 @@ begin
|
||||
PackageEditors.DoFreeEditor(LazPackage);
|
||||
FLazPackage:=nil;
|
||||
FreeAndNil(FPlugins);
|
||||
FreeAndNil(FPropGui);
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.FormDropFiles(Sender: TObject;
|
||||
@ -1563,18 +1540,6 @@ begin
|
||||
FFirstNodeData[Typ]:=Result;
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.UseMaxVersionCheckBoxChange(Sender: TObject);
|
||||
begin
|
||||
MaxVersionEdit.Enabled:=UseMaxVersionCheckBox.Checked;
|
||||
UpdateApplyDependencyButton;
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.UseMinVersionCheckBoxChange(Sender: TObject);
|
||||
begin
|
||||
MinVersionEdit.Enabled:=UseMinVersionCheckBox.Checked;
|
||||
UpdateApplyDependencyButton;
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.UseAllUnitsInDirectoryMenuItemClick(Sender: TObject);
|
||||
begin
|
||||
DoUseUnitsInDirectory(true);
|
||||
@ -1642,9 +1607,9 @@ begin
|
||||
if not (Item is TPkgFile) then continue;
|
||||
CurFile:=TPkgFile(Item);
|
||||
if not (CurFile.FileType in PkgFileUnitTypes) then continue;
|
||||
if CurFile.AddToUsesPkgSection=AddToUsesPkgSectionCheckBox.Checked then continue;
|
||||
if CurFile.AddToUsesPkgSection=FPropGui.AddToUsesPkgSectionCheckBox.Checked then continue;
|
||||
// change flag
|
||||
CurFile.AddToUsesPkgSection:=AddToUsesPkgSectionCheckBox.Checked;
|
||||
CurFile.AddToUsesPkgSection:=FPropGui.AddToUsesPkgSectionCheckBox.Checked;
|
||||
if (not NodeData.Removed) and CurFile.AddToUsesPkgSection then begin
|
||||
// mark all other units with the same name as unused
|
||||
for j:=0 to LazPackage.FileCount-1 do begin
|
||||
@ -1666,62 +1631,14 @@ end;
|
||||
|
||||
procedure TPackageEditorForm.ApplyDependencyButtonClick(Sender: TObject);
|
||||
var
|
||||
Flags: TPkgDependencyFlags;
|
||||
MinVers, MaxVers: TPkgVersion;
|
||||
CurDependency: TPkgDependency;
|
||||
begin
|
||||
CurDependency:=GetSingleSelectedDependency;
|
||||
if (LazPackage=nil) or (CurDependency=nil)
|
||||
then exit;
|
||||
|
||||
MinVers:=TPkgVersion.Create;
|
||||
MaxVers:=TPkgVersion.Create;
|
||||
try
|
||||
// Assign relevant data to temp variables
|
||||
Flags:=CurDependency.Flags;
|
||||
MinVers.Assign(CurDependency.MinVersion);
|
||||
MaxVers.Assign(CurDependency.MinVersion);
|
||||
|
||||
// read minimum version
|
||||
if UseMinVersionCheckBox.Checked then begin
|
||||
Include(Flags, pdfMinVersion);
|
||||
if not MinVers.ReadString(MinVersionEdit.Text) then begin
|
||||
MessageDlg(lisPckEditInvalidMinimumVersion,
|
||||
Format(lisPckEditTheMinimumVersionIsNotAValidPackageVersion,
|
||||
[MinVersionEdit.Text, LineEnding]),
|
||||
mtError,[mbCancel],0);
|
||||
exit;
|
||||
end;
|
||||
end
|
||||
else
|
||||
Exclude(Flags, pdfMinVersion);
|
||||
|
||||
// read maximum version
|
||||
if UseMaxVersionCheckBox.Checked then begin
|
||||
Include(Flags, pdfMaxVersion);
|
||||
if not MaxVers.ReadString(MaxVersionEdit.Text) then begin
|
||||
MessageDlg(lisPckEditInvalidMaximumVersion,
|
||||
Format(lisPckEditTheMaximumVersionIsNotAValidPackageVersion,
|
||||
[MaxVersionEdit.Text, LineEnding]),
|
||||
mtError,[mbCancel],0);
|
||||
exit;
|
||||
end;
|
||||
end
|
||||
else
|
||||
Exclude(Flags, pdfMaxVersion);
|
||||
|
||||
// Assign changes back to the dependency
|
||||
CurDependency.Flags := Flags;
|
||||
CurDependency.MinVersion.Assign(MinVers);
|
||||
CurDependency.MaxVersion.Assign(MaxVers);
|
||||
|
||||
or not FPropGui.CheckApplyDependency(CurDependency) then exit;
|
||||
UpdateNodeImage(ItemsTreeView.Selected);
|
||||
//fForcedFlags:=[pefNeedUpdateRequiredPkgs];
|
||||
LazPackage.Modified:=True;
|
||||
finally
|
||||
MaxVers.Free;
|
||||
MinVers.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.CallRegisterProcCheckBoxChange(Sender: TObject);
|
||||
@ -1735,12 +1652,13 @@ begin
|
||||
if LazPackage=nil then exit;
|
||||
for i:=0 to ItemsTreeView.SelectionCount-1 do begin
|
||||
TVNode:=ItemsTreeView.Selections[i];
|
||||
if not GetNodeDataItem(TVNode,NodeData,Item) then continue;
|
||||
if not (Item is TPkgFile) then continue;
|
||||
if not GetNodeDataItem(TVNode,NodeData,Item) or not (Item is TPkgFile) then
|
||||
continue;
|
||||
CurFile:=TPkgFile(Item);
|
||||
if not (CurFile.FileType in PkgFileUnitTypes) then continue;
|
||||
if CurFile.HasRegisterProc=CallRegisterProcCheckBox.Checked then continue;
|
||||
CurFile.HasRegisterProc:=CallRegisterProcCheckBox.Checked;
|
||||
if not (CurFile.FileType in PkgFileUnitTypes)
|
||||
or CurFile.HasRegisterProc=FPropGui.CallRegisterProcCheckBox.Checked then
|
||||
continue;
|
||||
CurFile.HasRegisterProc:=FPropGui.CallRegisterProcCheckBox.Checked;
|
||||
if not NodeData.Removed then
|
||||
LazPackage.ModifySilently;
|
||||
UpdateNodeImage(TVNode, NodeData, Item);
|
||||
@ -1857,13 +1775,13 @@ begin
|
||||
try
|
||||
for i:=0 to ItemsTreeView.SelectionCount-1 do begin
|
||||
TVNode:=ItemsTreeView.Selections[i];
|
||||
if not GetNodeDataItem(TVNode,NodeData,Item) then continue;
|
||||
if not (Item is TPkgFile) then continue;
|
||||
CurFile:=TPkgFile(Item);
|
||||
if not (CurFile.FileType in PkgFileUnitTypes) then continue;
|
||||
if CurFile.DisableI18NForLFM=DisableI18NForLFMCheckBox.Checked then
|
||||
if not GetNodeDataItem(TVNode,NodeData,Item) or not (Item is TPkgFile) then
|
||||
continue;
|
||||
CurFile.DisableI18NForLFM:=DisableI18NForLFMCheckBox.Checked;
|
||||
CurFile:=TPkgFile(Item);
|
||||
if not (CurFile.FileType in PkgFileUnitTypes)
|
||||
or CurFile.DisableI18NForLFM=FPropGui.DisableI18NForLFMCheckBox.Checked then
|
||||
continue;
|
||||
CurFile.DisableI18NForLFM:=FPropGui.DisableI18NForLFMCheckBox.Checked;
|
||||
if not NodeData.Removed then
|
||||
LazPackage.Modified:=true;
|
||||
end;
|
||||
@ -1897,10 +1815,9 @@ begin
|
||||
UpdateAll(true);
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.SetupComponents;
|
||||
|
||||
function CreateToolButton(AName, ACaption, AHint, AImageName: String; AOnClick: TNotifyEvent): TToolButton;
|
||||
begin
|
||||
function TPackageEditorForm.CreateToolButton(AName, ACaption, AHint, AImageName: String;
|
||||
AOnClick: TNotifyEvent): TToolButton;
|
||||
begin
|
||||
Result := TToolButton.Create(Self);
|
||||
Result.Name := AName;
|
||||
Result.Caption := ACaption;
|
||||
@ -1911,16 +1828,17 @@ procedure TPackageEditorForm.SetupComponents;
|
||||
Result.OnClick := AOnClick;
|
||||
Result.AutoSize := True;
|
||||
Result.Parent := ToolBar;
|
||||
end;
|
||||
end;
|
||||
|
||||
function CreateDivider: TToolButton;
|
||||
begin
|
||||
function TPackageEditorForm.CreateDivider: TToolButton;
|
||||
begin
|
||||
Result := TToolButton.Create(Self);
|
||||
Result.Style := tbsDivider;
|
||||
Result.AutoSize := True;
|
||||
Result.Parent := ToolBar;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.SetupComponents;
|
||||
begin
|
||||
ImageIndexFiles := IDEImages.LoadImage('pkg_files');
|
||||
ImageIndexRemovedFiles := IDEImages.LoadImage('pkg_removedfiles');
|
||||
@ -1991,28 +1909,19 @@ begin
|
||||
PropsGroupBox.Caption:=lisPckEditFileProperties;
|
||||
CommonOptionsTabSheet.Caption:=lisPckEditCommonOptions;
|
||||
|
||||
CallRegisterProcCheckBox.Caption:=lisPckEditRegisterUnit;
|
||||
CallRegisterProcCheckBox.Hint:=Format(lisPckEditCallRegisterProcedureOfSelectedUnit, ['"', '"']);
|
||||
|
||||
AddToUsesPkgSectionCheckBox.Caption:=lisPkgMangUseUnit;
|
||||
AddToUsesPkgSectionCheckBox.Hint:=lisPkgMangAddUnitToUsesClause;
|
||||
|
||||
DisableI18NForLFMCheckBox.Caption:=lisPckDisableI18NOfLfm;
|
||||
DisableI18NForLFMCheckBox.Hint:=lisPckWhenTheFormIsSavedTheIDECanStoreAllTTranslateString;
|
||||
|
||||
UseMinVersionCheckBox.Caption:=lisPckEditMinimumVersion;
|
||||
UseMaxVersionCheckBox.Caption:=lisPckEditMaximumVersion;
|
||||
ApplyDependencyButton.Caption:=lisPckEditApplyChanges;
|
||||
RegisteredPluginsGroupBox.Caption:=lisPckEditRegisteredPlugins;
|
||||
RegisteredListBox.ItemHeight:=ComponentPaletteImageHeight;
|
||||
FPropGui:=TProjPackFilePropGui.Create(CommonOptionsTabSheet);
|
||||
// file properties
|
||||
FPropGui.AddToUsesPkgSectionCheckBox.OnChange := @AddToUsesPkgSectionCheckBoxChange;
|
||||
FPropGui.CallRegisterProcCheckBox.OnChange := @CallRegisterProcCheckBoxChange;
|
||||
FPropGui.RegisteredListBox.OnDrawItem := @RegisteredListBoxDrawItem;
|
||||
FPropGui.DisableI18NForLFMCheckBox.OnChange := @DisableI18NForLFMCheckBoxChange;
|
||||
// dependency properties
|
||||
FPropGui.OnGetPkgDep := @GetDependencyToUpdate;
|
||||
FPropGui.ApplyDependencyButton.OnClick := @ApplyDependencyButtonClick;
|
||||
|
||||
FDirSummaryLabel:=TLabel.Create(Self);
|
||||
with FDirSummaryLabel do
|
||||
begin
|
||||
Name:='DirSummaryLabel';
|
||||
Parent:=CommonOptionsTabSheet;
|
||||
end;
|
||||
|
||||
FDirSummaryLabel.Name:='DirSummaryLabel';
|
||||
FDirSummaryLabel.Parent:=CommonOptionsTabSheet;
|
||||
CreatePackageFileEditors;
|
||||
end;
|
||||
|
||||
@ -2426,7 +2335,7 @@ begin
|
||||
if pefNeedUpdateButtons in fFlags then
|
||||
UpdateButtons(true);
|
||||
if pefNeedUpdateApplyDependencyButton in fFlags then
|
||||
UpdateApplyDependencyButton(true);
|
||||
FPropGui.UpdateApplyDependencyButton(true);
|
||||
if pefNeedUpdateStatusBar in fFlags then
|
||||
UpdateStatusBar(true);
|
||||
IdleConnected:=false;
|
||||
@ -2444,7 +2353,6 @@ begin
|
||||
if (fUpdateLock>0) and not Immediately then begin
|
||||
Include(fFlags,Flag);
|
||||
IdleConnected:=true;
|
||||
Result:=false;
|
||||
end else begin
|
||||
Exclude(fFlags,Flag);
|
||||
Result:=true;
|
||||
@ -2593,72 +2501,33 @@ begin
|
||||
UpdateButtons;
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.UpdatePEProperties(Immediately: boolean);
|
||||
type
|
||||
TMultiBool = (mubNone, mubAllTrue, mubAllFalse, mubMixed);
|
||||
|
||||
procedure MergeMultiBool(var b: TMultiBool; NewValue: boolean);
|
||||
begin
|
||||
procedure MergeMultiBool(var b: TMultiBool; NewValue: boolean);
|
||||
begin
|
||||
case b of
|
||||
mubNone: if NewValue then b:=mubAllTrue else b:=mubAllFalse;
|
||||
mubAllTrue: if not NewValue then b:=mubMixed;
|
||||
mubNone : if NewValue then b:=mubAllTrue else b:=mubAllFalse;
|
||||
mubAllTrue : if not NewValue then b:=mubMixed;
|
||||
mubAllFalse: if NewValue then b:=mubMixed;
|
||||
mubMixed: ;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure SetCheckBox(Box: TCheckBox; aVisible: boolean; State: TMultiBool);
|
||||
begin
|
||||
Box.Visible:=aVisible;
|
||||
case State of
|
||||
mubAllTrue:
|
||||
begin
|
||||
Box.State:=cbChecked;
|
||||
Box.AllowGrayed:=false;
|
||||
end;
|
||||
mubAllFalse:
|
||||
begin
|
||||
Box.State:=cbUnchecked;
|
||||
Box.AllowGrayed:=false;
|
||||
end;
|
||||
mubMixed:
|
||||
begin
|
||||
Box.AllowGrayed:=true;
|
||||
Box.State:=cbGrayed;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.UpdatePEProperties(Immediately: boolean);
|
||||
var
|
||||
CurFile, SingleSelectedFile: TPkgFile;
|
||||
CurDependency, SingleSelectedDep: TPkgDependency;
|
||||
CurComponent: TPkgComponent;
|
||||
CurLine, CurFilename: string;
|
||||
i, j: Integer;
|
||||
TVNode, SingleSelectedDirectory, SingleSelectedNode: TTreeNode;
|
||||
NodeData: TPENodeData;
|
||||
Item: TObject;
|
||||
SelFileCount: Integer;
|
||||
SelDepCount: Integer;
|
||||
SelHasRegisterProc: TMultiBool;
|
||||
SelAddToUsesPkgSection: TMultiBool;
|
||||
SelDisableI18NForLFM: TMultiBool;
|
||||
SelUnitCount: Integer;
|
||||
SelDirCount: Integer;
|
||||
SelHasLFMCount: Integer;
|
||||
OnlyFilesSelected: Boolean;
|
||||
OnlyFilesWithUnitsSelected: Boolean;
|
||||
aVisible: Boolean;
|
||||
TVNode: TTreeNode;
|
||||
SingleSelectedDirectory, SingleSelectedNode: TTreeNode;
|
||||
SingleSelectedRemoved: Boolean;
|
||||
FileCount: integer;
|
||||
HasRegisterProcCount: integer;
|
||||
AddToUsesPkgSectionCount: integer;
|
||||
i, j: Integer;
|
||||
SelFileCount, SelDepCount, SelUnitCount, SelDirCount, SelHasLFMCount: Integer;
|
||||
FileCount, HasRegisterProcCount, AddToUsesPkgSectionCount: integer;
|
||||
SelHasRegisterProc, SelAddToUsesPkgSection, SelDisableI18NForLFM: TMultiBool;
|
||||
aVisible, OnlyFilesWithUnitsSelected, SingleSelectedRemoved: Boolean;
|
||||
begin
|
||||
if not CanUpdate(pefNeedUpdateProperties,Immediately) then exit;
|
||||
|
||||
GuiToFileOptions(False);
|
||||
|
||||
FPlugins.Clear;
|
||||
|
||||
// check selection
|
||||
@ -2688,12 +2557,12 @@ begin
|
||||
if CurFile.FileType in PkgFileUnitTypes then begin
|
||||
inc(SelUnitCount);
|
||||
MergeMultiBool(SelAddToUsesPkgSection,CurFile.AddToUsesPkgSection);
|
||||
if (CurFile.FileType in PkgFileRealUnitTypes) then
|
||||
if CurFile.FileType in PkgFileRealUnitTypes then
|
||||
begin
|
||||
CurFilename:=CurFile.GetFullFilename;
|
||||
if FilenameIsAbsolute(CurFilename)
|
||||
and FileExistsCached(ChangeFileExt(CurFilename,'.lfm'))
|
||||
then begin
|
||||
and FileExistsCached(ChangeFileExt(CurFilename,'.lfm')) then
|
||||
begin
|
||||
inc(SelHasLFMCount);
|
||||
MergeMultiBool(SelDisableI18NForLFM,CurFile.DisableI18NForLFM);
|
||||
end;
|
||||
@ -2716,7 +2585,8 @@ begin
|
||||
inc(SelDirCount);
|
||||
SingleSelectedDirectory:=TVNode;
|
||||
SingleSelectedNode:=TVNode;
|
||||
end;
|
||||
end //else if TVNode=FRequiredPackagesNode then
|
||||
// DebugLn('UpdatePEProperties: Required packages selected');
|
||||
end;
|
||||
|
||||
if (SelFileCount+SelDepCount+SelDirCount>1) then begin
|
||||
@ -2726,50 +2596,35 @@ begin
|
||||
SingleSelectedDirectory:=nil;
|
||||
SingleSelectedNode:=nil;
|
||||
end;
|
||||
OnlyFilesSelected:=(SelFileCount>0) and (SelDepCount=0) and (SelDirCount=0);
|
||||
OnlyFilesWithUnitsSelected:=OnlyFilesSelected and (SelUnitCount>0);
|
||||
|
||||
//debugln(['TPackageEditorForm.UpdatePEProperties SelFileCount=',SelFileCount,' SelDepCount=',SelDepCount,' SelDirCount=',SelDirCount,' SelUnitCount=',SelUnitCount]);
|
||||
//debugln(['TPackageEditorForm.UpdatePEProperties FSingleSelectedFile=',SingleSelectedFile<>nil,' FSingleSelectedDependency=',SingleSelectedDep<>nil,' SingleSelectedDirectory=',SingleSelectedDirectory<>nil]);
|
||||
|
||||
OnlyFilesWithUnitsSelected:=
|
||||
(SelFileCount>0) and (SelDepCount=0) and (SelDirCount=0) and (SelUnitCount>0);
|
||||
FPropGui.ControlVisible := OnlyFilesWithUnitsSelected;
|
||||
FPropGui.ControlEnabled := not LazPackage.ReadOnly;
|
||||
DisableAlign;
|
||||
try
|
||||
FPropGui.SetAddToUsesCB(SelAddToUsesPkgSection); // 'Add to uses' of files
|
||||
FPropGui.SetCallRegisterProcCB(SelHasRegisterProc); // 'RegisterProc' of files
|
||||
FPropGui.SetRegisteredPluginsGB(FPlugins); // registered plugins
|
||||
|
||||
// Min/Max version of dependency (only single selection)
|
||||
FPropGui.ControlVisible := SingleSelectedDep<>nil;
|
||||
FPropGui.SetMinMaxVisibility;
|
||||
|
||||
// disable i18n for lfm
|
||||
FPropGui.ControlVisible := OnlyFilesWithUnitsSelected and (SelHasLFMCount>0)
|
||||
and LazPackage.EnableI18N and LazPackage.EnableI18NForLFM;
|
||||
FPropGui.SetDisableI18NCB(SelDisableI18NForLFM);
|
||||
|
||||
// move up/down (only single selection)
|
||||
aVisible:=(not (SortAlphabetically or SingleSelectedRemoved))
|
||||
and ((SingleSelectedFile<>nil) or (SingleSelectedDep<>nil));
|
||||
MoveUpBtn.Enabled :=aVisible and Assigned(SingleSelectedNode.GetPrevVisibleSibling);
|
||||
MoveDownBtn.Enabled:=aVisible and Assigned(SingleSelectedNode.GetNextVisibleSibling);
|
||||
|
||||
// Min/Max version of dependency (only single selection)
|
||||
aVisible:=SingleSelectedDep<>nil;
|
||||
UseMinVersionCheckBox.Visible:=aVisible;
|
||||
MinVersionEdit.Visible:=aVisible;
|
||||
UseMaxVersionCheckBox.Visible:=aVisible;
|
||||
MaxVersionEdit.Visible:=aVisible;
|
||||
ApplyDependencyButton.Visible:=aVisible;
|
||||
|
||||
// 'RegisterProc' of files (supports multi selection)
|
||||
SetCheckBox(CallRegisterProcCheckBox,OnlyFilesWithUnitsSelected, SelHasRegisterProc);
|
||||
CallRegisterProcCheckBox.Enabled:=(not LazPackage.ReadOnly);
|
||||
|
||||
// 'Add to uses' of files (supports multi selection)
|
||||
SetCheckBox(AddToUsesPkgSectionCheckBox,OnlyFilesWithUnitsSelected, SelAddToUsesPkgSection);
|
||||
AddToUsesPkgSectionCheckBox.Enabled:=(not LazPackage.ReadOnly);
|
||||
|
||||
// disable i18n for lfm (supports multi selection)
|
||||
SetCheckBox(DisableI18NForLFMCheckBox,
|
||||
OnlyFilesWithUnitsSelected and (SelHasLFMCount>0) and LazPackage.EnableI18N
|
||||
and LazPackage.EnableI18NForLFM,
|
||||
SelDisableI18NForLFM);
|
||||
DisableI18NForLFMCheckBox.Enabled:=(not LazPackage.ReadOnly);
|
||||
|
||||
// registered plugins (supports multi selection)
|
||||
RegisteredPluginsGroupBox.Visible:=OnlyFilesWithUnitsSelected;
|
||||
RegisteredPluginsGroupBox.Enabled:=(not LazPackage.ReadOnly);
|
||||
if not RegisteredPluginsGroupBox.Visible then
|
||||
FPlugins.Clear;
|
||||
RegisteredListBox.Items.Assign(FPlugins);
|
||||
|
||||
// directory summary (only single selection)
|
||||
FDirSummaryLabel.Visible:=(SelFileCount=0) and (SelDepCount=0) and (SelDirCount=1);
|
||||
|
||||
@ -2780,16 +2635,12 @@ begin
|
||||
else if SingleSelectedDep<>nil then begin
|
||||
PropsGroupBox.Enabled:=not SingleSelectedRemoved;
|
||||
PropsGroupBox.Caption:=lisPckEditDependencyProperties;
|
||||
UseMinVersionCheckBox.Checked:=pdfMinVersion in SingleSelectedDep.Flags;
|
||||
MinVersionEdit.Text:=SingleSelectedDep.MinVersion.AsString;
|
||||
MinVersionEdit.Enabled:=pdfMinVersion in SingleSelectedDep.Flags;
|
||||
UseMaxVersionCheckBox.Checked:=pdfMaxVersion in SingleSelectedDep.Flags;
|
||||
MaxVersionEdit.Text:=SingleSelectedDep.MaxVersion.AsString;
|
||||
MaxVersionEdit.Enabled:=pdfMaxVersion in SingleSelectedDep.Flags;
|
||||
UpdateApplyDependencyButton;
|
||||
FPropGui.SetMinMaxValues(SingleSelectedDep);
|
||||
FPropGui.UpdateApplyDependencyButton;
|
||||
end
|
||||
else if SingleSelectedDirectory<>nil then begin
|
||||
PropsGroupBox.Enabled:=true;
|
||||
PropsGroupBox.Caption:=lisPckEditFileProperties;
|
||||
GetDirectorySummary(SingleSelectedDirectory,
|
||||
FileCount,HasRegisterProcCount,AddToUsesPkgSectionCount);
|
||||
FDirSummaryLabel.Caption:=Format(
|
||||
@ -2798,6 +2649,7 @@ begin
|
||||
end
|
||||
else begin
|
||||
PropsGroupBox.Enabled:=false;
|
||||
PropsGroupBox.Caption:=lisPckEditDependencyProperties;
|
||||
end;
|
||||
|
||||
if SingleSelectedFile<>nil then begin
|
||||
@ -2866,38 +2718,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.UpdateApplyDependencyButton(Immediately: boolean);
|
||||
var
|
||||
DependencyChanged: Boolean;
|
||||
AVersion: TPkgVersion;
|
||||
CurDependency: TPkgDependency;
|
||||
function TPackageEditorForm.GetDependencyToUpdate(Immediately: boolean): TPkgDependencyBase;
|
||||
begin
|
||||
if not CanUpdate(pefNeedUpdateApplyDependencyButton,Immediately) then exit;
|
||||
CurDependency:=GetSingleSelectedDependency;
|
||||
DependencyChanged:=false;
|
||||
if (CurDependency<>nil) then begin
|
||||
// check min version
|
||||
if UseMinVersionCheckBox.Checked<>(pdfMinVersion in CurDependency.Flags) then
|
||||
DependencyChanged:=true;
|
||||
if UseMinVersionCheckBox.Checked then begin
|
||||
AVersion:=TPkgVersion.Create;
|
||||
if AVersion.ReadString(MinVersionEdit.Text)
|
||||
and (AVersion.Compare(CurDependency.MinVersion)<>0) then
|
||||
DependencyChanged:=true;
|
||||
AVersion.Free;
|
||||
end;
|
||||
// check max version
|
||||
if UseMaxVersionCheckBox.Checked<>(pdfMaxVersion in CurDependency.Flags) then
|
||||
DependencyChanged:=true;
|
||||
if UseMaxVersionCheckBox.Checked then begin
|
||||
AVersion:=TPkgVersion.Create;
|
||||
if AVersion.ReadString(MaxVersionEdit.Text)
|
||||
and (AVersion.Compare(CurDependency.MaxVersion)<>0) then
|
||||
DependencyChanged:=true;
|
||||
AVersion.Free;
|
||||
end;
|
||||
end;
|
||||
ApplyDependencyButton.Enabled:=DependencyChanged;
|
||||
if CanUpdate(pefNeedUpdateApplyDependencyButton,Immediately) then
|
||||
Result:=GetSingleSelectedDependency
|
||||
else
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.UpdateStatusBar(Immediately: boolean);
|
||||
@ -3427,15 +3253,12 @@ procedure TPackageEditorForm.TraverseSettings(AOptions: TAbstractPackageFileIDEO
|
||||
if Control <> nil then
|
||||
begin
|
||||
if Control is TAbstractIDEOptionsEditor then
|
||||
begin
|
||||
Assert(False,'TPackageEditorForm.TraverseSettings: IDEOptionsEditor found under PropsPageControl');
|
||||
with TAbstractIDEOptionsEditor(Control) do
|
||||
case anAction of
|
||||
iodaRead: ReadSettings(AOptions);
|
||||
iodaWrite: WriteSettings(AOptions);
|
||||
iodaRestore: RestoreSettings(AOptions);
|
||||
end;
|
||||
end;
|
||||
for i := 0 to Control.ControlCount -1 do
|
||||
if Control.Controls[i] is TWinControl then
|
||||
Traverse(TWinControl(Control.Controls[i]));
|
||||
@ -3443,12 +3266,10 @@ procedure TPackageEditorForm.TraverseSettings(AOptions: TAbstractPackageFileIDEO
|
||||
end;
|
||||
|
||||
begin
|
||||
DebugLn(['TPackageEditorForm.TraverseSettings: AOptions=', AOptions, ', Action=', anAction]);
|
||||
Traverse(PropsPageControl);
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.CreatePackageFileEditors;
|
||||
|
||||
var
|
||||
Instance: TAbstractIDEOptionsEditor;
|
||||
i, j: integer;
|
||||
@ -3458,7 +3279,6 @@ var
|
||||
ItemTabSheet: TTabSheet;
|
||||
begin
|
||||
IDEEditorGroups.Resort;
|
||||
|
||||
for i := 0 to IDEEditorGroups.Count - 1 do
|
||||
begin
|
||||
Rec := IDEEditorGroups[i];
|
||||
@ -3469,12 +3289,10 @@ begin
|
||||
AGroupCaption := Rec^.GroupClass.GetGroupCaption
|
||||
else
|
||||
AGroupCaption := '';
|
||||
|
||||
for j := 0 to Rec^.Items.Count - 1 do
|
||||
begin
|
||||
ItemTabSheet := PropsPageControl.AddTabSheet;
|
||||
ItemTabSheet.Align := alClient;
|
||||
|
||||
Instance := Rec^.Items[j]^.EditorClass.Create(Self);
|
||||
// Instance.OnLoadIDEOptions := @LoadIDEOptions;
|
||||
// Instance.OnSaveIDEOptions := @SaveIDEOptions;
|
||||
|
407
packager/projpackfilepropgui.pas
Normal file
407
packager/projpackfilepropgui.pas
Normal file
@ -0,0 +1,407 @@
|
||||
{
|
||||
***************************************************************************
|
||||
* *
|
||||
* 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA. *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
Author: Juha Manninen
|
||||
|
||||
Abstract:
|
||||
TProjPackFilePropGui creates and sets layout for controls that are used for
|
||||
properties of files and dependencies in a package or in a project.
|
||||
Used by the package editor and the project inspector.
|
||||
}
|
||||
unit ProjPackFilePropGui;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils,
|
||||
// LCL
|
||||
LResources, Forms, Controls, StdCtrls, Dialogs,
|
||||
// BuildIntf
|
||||
PackageDependencyIntf,
|
||||
// IdeIntf
|
||||
FormEditingIntf,
|
||||
// IDE
|
||||
LazarusIDEStrConsts;
|
||||
|
||||
type
|
||||
|
||||
TMultiBool = (mubNone, mubAllTrue, mubAllFalse, mubMixed);
|
||||
TGetPkgDepEvent = function(Immediately: boolean): TPkgDependencyBase of object;
|
||||
|
||||
{ TProjPackFilePropGui }
|
||||
|
||||
TProjPackFilePropGui = class
|
||||
private
|
||||
fOwner: TWinControl;
|
||||
fOnGetPkgDep: TGetPkgDepEvent;
|
||||
procedure MinMaxVersionEditChange(Sender: TObject);
|
||||
procedure UseMinVersionCheckBoxChange(Sender: TObject);
|
||||
procedure UseMaxVersionCheckBoxChange(Sender: TObject);
|
||||
public
|
||||
// file properties
|
||||
AddToUsesPkgSectionCheckBox: TCheckBox;
|
||||
CallRegisterProcCheckBox: TCheckBox;
|
||||
RegisteredPluginsGroupBox: TGroupBox;
|
||||
RegisteredListBox: TListBox;
|
||||
DisableI18NForLFMCheckBox: TCheckBox; // I18N
|
||||
// dependency properties
|
||||
UseMinVersionCheckBox: TCheckBox;
|
||||
MinVersionEdit: TEdit;
|
||||
UseMaxVersionCheckBox: TCheckBox;
|
||||
MaxVersionEdit: TEdit;
|
||||
ApplyDependencyButton: TButton;
|
||||
// Values used when setting controls' visibility and Enabled state.
|
||||
ControlVisible, ControlEnabled: Boolean;
|
||||
|
||||
constructor Create(aOwner: TWinControl);
|
||||
destructor Destroy; override;
|
||||
procedure SetAddToUsesCB(State: TMultiBool);
|
||||
procedure SetCallRegisterProcCB(State: TMultiBool);
|
||||
procedure SetRegisteredPluginsGB(aPlugins: TStringList);
|
||||
procedure SetMinMaxVisibility;
|
||||
procedure SetMinMaxValues(aDep: TPkgDependencyBase);
|
||||
procedure SetDisableI18NCB(State: TMultiBool);
|
||||
function CheckApplyDependency(aDep: TPkgDependencyBase): Boolean;
|
||||
procedure UpdateApplyDependencyButton(Immediately: boolean = False);
|
||||
|
||||
property OnGetPkgDep: TGetPkgDepEvent read fOnGetPkgDep write fOnGetPkgDep;
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{ TProjPackFilePropGui }
|
||||
|
||||
constructor TProjPackFilePropGui.Create(aOwner: TWinControl);
|
||||
begin
|
||||
fOwner := aOwner;
|
||||
|
||||
// file properties
|
||||
// ---------------
|
||||
CallRegisterProcCheckBox := TCheckBox.Create(fOwner);
|
||||
CallRegisterProcCheckBox.Parent := fOwner;
|
||||
CallRegisterProcCheckBox.Visible := False;
|
||||
CallRegisterProcCheckBox.Left := 6;
|
||||
CallRegisterProcCheckBox.Top := 0;
|
||||
CallRegisterProcCheckBox.Width := 185;
|
||||
CallRegisterProcCheckBox.ShowHint := True;
|
||||
CallRegisterProcCheckBox.TabOrder := 0;
|
||||
CallRegisterProcCheckBox.Caption := lisPckEditRegisterUnit;
|
||||
CallRegisterProcCheckBox.Hint := Format(lisPckEditCallRegisterProcedureOfSelectedUnit, ['"', '"']);
|
||||
|
||||
AddToUsesPkgSectionCheckBox := TCheckBox.Create(fOwner);
|
||||
AddToUsesPkgSectionCheckBox.Parent := fOwner;
|
||||
AddToUsesPkgSectionCheckBox.Visible := False;
|
||||
AddToUsesPkgSectionCheckBox.AnchorSideLeft.Control := CallRegisterProcCheckBox;
|
||||
AddToUsesPkgSectionCheckBox.AnchorSideLeft.Side := asrBottom;
|
||||
AddToUsesPkgSectionCheckBox.Left := 195;
|
||||
AddToUsesPkgSectionCheckBox.Top := 0;
|
||||
AddToUsesPkgSectionCheckBox.Width := 222;
|
||||
AddToUsesPkgSectionCheckBox.BorderSpacing.Left := 10;
|
||||
AddToUsesPkgSectionCheckBox.ShowHint := True;
|
||||
AddToUsesPkgSectionCheckBox.TabOrder := 1;
|
||||
AddToUsesPkgSectionCheckBox.Caption := lisPkgMangUseUnit;
|
||||
AddToUsesPkgSectionCheckBox.Hint := lisPkgMangAddUnitToUsesClause;
|
||||
|
||||
RegisteredPluginsGroupBox := TGroupBox.Create(fOwner);
|
||||
RegisteredPluginsGroupBox.Parent := fOwner;
|
||||
RegisteredPluginsGroupBox.Visible := False;
|
||||
RegisteredPluginsGroupBox.Left := 3;
|
||||
RegisteredPluginsGroupBox.Height := 165;
|
||||
RegisteredPluginsGroupBox.Top := 27;
|
||||
RegisteredPluginsGroupBox.Width := 452;
|
||||
RegisteredPluginsGroupBox.Align := alBottom;
|
||||
RegisteredPluginsGroupBox.Anchors := [akTop, akLeft, akRight, akBottom];
|
||||
RegisteredPluginsGroupBox.BorderSpacing.Top := 6;
|
||||
RegisteredPluginsGroupBox.TabOrder := 7;
|
||||
RegisteredPluginsGroupBox.Caption := lisPckEditRegisteredPlugins;
|
||||
|
||||
RegisteredListBox := TListBox.Create(fOwner);
|
||||
RegisteredListBox.Parent := RegisteredPluginsGroupBox;
|
||||
RegisteredListBox.Align := alClient;
|
||||
RegisteredListBox.ScrollWidth := 448;
|
||||
RegisteredListBox.Style := lbOwnerDrawFixed;
|
||||
RegisteredListBox.TabOrder := 0;
|
||||
RegisteredListBox.ItemHeight := ComponentPaletteImageHeight;
|
||||
|
||||
// I18N
|
||||
DisableI18NForLFMCheckBox := TCheckBox.Create(fOwner);
|
||||
DisableI18NForLFMCheckBox.Parent := fOwner;
|
||||
DisableI18NForLFMCheckBox.Visible := False;
|
||||
DisableI18NForLFMCheckBox.AnchorSideLeft.Control := AddToUsesPkgSectionCheckBox;
|
||||
DisableI18NForLFMCheckBox.AnchorSideLeft.Side := asrBottom;
|
||||
DisableI18NForLFMCheckBox.AnchorSideTop.Control := AddToUsesPkgSectionCheckBox;
|
||||
DisableI18NForLFMCheckBox.Left := 423;
|
||||
DisableI18NForLFMCheckBox.Top := 0;
|
||||
DisableI18NForLFMCheckBox.Width := 208;
|
||||
DisableI18NForLFMCheckBox.BorderSpacing.Left := 10;
|
||||
DisableI18NForLFMCheckBox.ShowHint := True;
|
||||
DisableI18NForLFMCheckBox.TabOrder := 8;
|
||||
DisableI18NForLFMCheckBox.Caption := lisPckDisableI18NOfLfm;
|
||||
DisableI18NForLFMCheckBox.Hint := lisPckWhenTheFormIsSavedTheIDECanStoreAllTTranslateString;
|
||||
|
||||
// dependency properties
|
||||
// ---------------------
|
||||
UseMinVersionCheckBox := TCheckBox.Create(fOwner);
|
||||
UseMinVersionCheckBox.Parent := fOwner;
|
||||
UseMinVersionCheckBox.Visible := False;
|
||||
UseMinVersionCheckBox.AnchorSideTop.Control := MinVersionEdit;
|
||||
UseMinVersionCheckBox.AnchorSideTop.Side := asrCenter;
|
||||
UseMinVersionCheckBox.Left := 6;
|
||||
UseMinVersionCheckBox.Top := 6;
|
||||
UseMinVersionCheckBox.Width := 179;
|
||||
UseMinVersionCheckBox.TabOrder := 2;
|
||||
UseMinVersionCheckBox.Caption := lisPckEditMinimumVersion;
|
||||
UseMinVersionCheckBox.OnChange := @UseMinVersionCheckBoxChange;
|
||||
|
||||
MinVersionEdit := TEdit.Create(fOwner);
|
||||
MinVersionEdit.Parent := fOwner;
|
||||
MinVersionEdit.Visible := False;
|
||||
MinVersionEdit.AnchorSideLeft.Control := UseMinVersionCheckBox;
|
||||
MinVersionEdit.AnchorSideLeft.Side := asrBottom;
|
||||
MinVersionEdit.Left := 201;
|
||||
MinVersionEdit.Top := 0;
|
||||
MinVersionEdit.Width := 100;
|
||||
MinVersionEdit.BorderSpacing.Left := 10;
|
||||
MinVersionEdit.TabOrder := 3;
|
||||
MinVersionEdit.OnChange := @MinMaxVersionEditChange;
|
||||
|
||||
UseMaxVersionCheckBox := TCheckBox.Create(fOwner);
|
||||
UseMaxVersionCheckBox.Parent := fOwner;
|
||||
UseMaxVersionCheckBox.Visible := False;
|
||||
UseMaxVersionCheckBox.AnchorSideTop.Control := MaxVersionEdit;
|
||||
UseMaxVersionCheckBox.AnchorSideTop.Side := asrCenter;
|
||||
UseMaxVersionCheckBox.Left := 6;
|
||||
UseMaxVersionCheckBox.Top := 43;
|
||||
UseMaxVersionCheckBox.Width := 182;
|
||||
UseMaxVersionCheckBox.TabOrder := 4;
|
||||
UseMaxVersionCheckBox.Caption := lisPckEditMaximumVersion;
|
||||
UseMaxVersionCheckBox.OnChange := @UseMaxVersionCheckBoxChange;
|
||||
|
||||
MaxVersionEdit := TEdit.Create(fOwner);
|
||||
MaxVersionEdit.Parent := fOwner;
|
||||
MaxVersionEdit.Visible := False;
|
||||
MaxVersionEdit.AnchorSideLeft.Control := UseMaxVersionCheckBox;
|
||||
MaxVersionEdit.AnchorSideLeft.Side := asrBottom;
|
||||
MaxVersionEdit.AnchorSideTop.Control := MinVersionEdit;
|
||||
MaxVersionEdit.AnchorSideTop.Side := asrBottom;
|
||||
MaxVersionEdit.Left := 204;
|
||||
MaxVersionEdit.Top := 38;
|
||||
MaxVersionEdit.Width := 100;
|
||||
MaxVersionEdit.BorderSpacing.Left := 10;
|
||||
MaxVersionEdit.BorderSpacing.Top := 2;
|
||||
MaxVersionEdit.TabOrder := 5;
|
||||
MaxVersionEdit.OnChange := @MinMaxVersionEditChange;
|
||||
|
||||
ApplyDependencyButton := TButton.Create(fOwner);
|
||||
ApplyDependencyButton.Parent := fOwner;
|
||||
ApplyDependencyButton.Visible := False;
|
||||
ApplyDependencyButton.AnchorSideTop.Control := MaxVersionEdit;
|
||||
ApplyDependencyButton.AnchorSideTop.Side := asrBottom;
|
||||
ApplyDependencyButton.Left := 6;
|
||||
ApplyDependencyButton.Top := 80;
|
||||
ApplyDependencyButton.AutoSize := True;
|
||||
ApplyDependencyButton.BorderSpacing.Top := 6;
|
||||
ApplyDependencyButton.TabOrder := 6;
|
||||
ApplyDependencyButton.Caption := lisPckEditApplyChanges;
|
||||
end;
|
||||
|
||||
destructor TProjPackFilePropGui.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure SetCheckBox(Box: TCheckBox; aVisible: boolean; State: TMultiBool);
|
||||
begin
|
||||
Box.Visible:=aVisible;
|
||||
case State of
|
||||
mubAllTrue:
|
||||
begin
|
||||
Box.State:=cbChecked;
|
||||
Box.AllowGrayed:=false;
|
||||
end;
|
||||
mubAllFalse:
|
||||
begin
|
||||
Box.State:=cbUnchecked;
|
||||
Box.AllowGrayed:=false;
|
||||
end;
|
||||
mubMixed:
|
||||
begin
|
||||
Box.State:=cbGrayed;
|
||||
Box.AllowGrayed:=true;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TProjPackFilePropGui.SetAddToUsesCB(State: TMultiBool);
|
||||
begin
|
||||
SetCheckBox(AddToUsesPkgSectionCheckBox, ControlVisible, State);
|
||||
AddToUsesPkgSectionCheckBox.Enabled := ControlEnabled;
|
||||
end;
|
||||
|
||||
procedure TProjPackFilePropGui.SetCallRegisterProcCB(State: TMultiBool);
|
||||
begin
|
||||
SetCheckBox(CallRegisterProcCheckBox, ControlVisible, State);
|
||||
CallRegisterProcCheckBox.Enabled := ControlEnabled;
|
||||
end;
|
||||
|
||||
procedure TProjPackFilePropGui.SetRegisteredPluginsGB(aPlugins: TStringList);
|
||||
begin
|
||||
RegisteredPluginsGroupBox.Visible := ControlVisible;
|
||||
RegisteredPluginsGroupBox.Enabled := ControlEnabled;
|
||||
if not ControlVisible then
|
||||
aPlugins.Clear;
|
||||
RegisteredListBox.Items.Assign(aPlugins);
|
||||
end;
|
||||
|
||||
procedure TProjPackFilePropGui.SetMinMaxVisibility;
|
||||
begin
|
||||
UseMinVersionCheckBox.Visible := ControlVisible;
|
||||
MinVersionEdit.Visible := ControlVisible;
|
||||
UseMaxVersionCheckBox.Visible := ControlVisible;
|
||||
MaxVersionEdit.Visible := ControlVisible;
|
||||
ApplyDependencyButton.Visible := ControlVisible;
|
||||
end;
|
||||
|
||||
procedure TProjPackFilePropGui.SetMinMaxValues(aDep: TPkgDependencyBase);
|
||||
begin
|
||||
UseMinVersionCheckBox.Checked := pdfMinVersion in aDep.Flags;
|
||||
MinVersionEdit.Text := aDep.MinVersion.AsString;
|
||||
MinVersionEdit.Enabled := pdfMinVersion in aDep.Flags;
|
||||
UseMaxVersionCheckBox.Checked := pdfMaxVersion in aDep.Flags;
|
||||
MaxVersionEdit.Text := aDep.MaxVersion.AsString;
|
||||
MaxVersionEdit.Enabled := pdfMaxVersion in aDep.Flags;
|
||||
end;
|
||||
|
||||
procedure TProjPackFilePropGui.SetDisableI18NCB(State: TMultiBool);
|
||||
begin
|
||||
SetCheckBox(DisableI18NForLFMCheckBox, ControlVisible, State);
|
||||
DisableI18NForLFMCheckBox.Enabled := ControlEnabled;
|
||||
end;
|
||||
|
||||
function TProjPackFilePropGui.CheckApplyDependency(aDep: TPkgDependencyBase): Boolean;
|
||||
var
|
||||
Flags: TPkgDependencyFlags;
|
||||
MinVers, MaxVers: TPkgVersion;
|
||||
begin
|
||||
Result := False;
|
||||
MinVers:=TPkgVersion.Create;
|
||||
MaxVers:=TPkgVersion.Create;
|
||||
try
|
||||
// Assign relevant data to temp variables
|
||||
Flags:=aDep.Flags;
|
||||
MinVers.Assign(aDep.MinVersion);
|
||||
MaxVers.Assign(aDep.MinVersion);
|
||||
|
||||
// read minimum version
|
||||
if UseMinVersionCheckBox.Checked then begin
|
||||
Include(Flags, pdfMinVersion);
|
||||
if not MinVers.ReadString(MinVersionEdit.Text) then begin
|
||||
MessageDlg(lisPckEditInvalidMinimumVersion,
|
||||
Format(lisPckEditTheMinimumVersionIsNotAValidPackageVersion,
|
||||
[MinVersionEdit.Text, LineEnding]),
|
||||
mtError,[mbCancel],0);
|
||||
exit;
|
||||
end;
|
||||
end
|
||||
else
|
||||
Exclude(Flags, pdfMinVersion);
|
||||
|
||||
// read maximum version
|
||||
if UseMaxVersionCheckBox.Checked then begin
|
||||
Include(Flags, pdfMaxVersion);
|
||||
if not MaxVers.ReadString(MaxVersionEdit.Text) then begin
|
||||
MessageDlg(lisPckEditInvalidMaximumVersion,
|
||||
Format(lisPckEditTheMaximumVersionIsNotAValidPackageVersion,
|
||||
[MaxVersionEdit.Text, LineEnding]),
|
||||
mtError,[mbCancel],0);
|
||||
exit;
|
||||
end;
|
||||
end
|
||||
else
|
||||
Exclude(Flags, pdfMaxVersion);
|
||||
|
||||
// Assign changes back to the dependency
|
||||
aDep.Flags := Flags;
|
||||
aDep.MinVersion.Assign(MinVers);
|
||||
aDep.MaxVersion.Assign(MaxVers);
|
||||
Result := True;
|
||||
finally
|
||||
MaxVers.Free;
|
||||
MinVers.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TProjPackFilePropGui.UpdateApplyDependencyButton(Immediately: boolean);
|
||||
var
|
||||
DependencyChanged: Boolean;
|
||||
AVersion: TPkgVersion;
|
||||
CurDependency: TPkgDependencyBase;
|
||||
begin
|
||||
Assert(Assigned(OnGetPkgDep), 'UpdateApplyDependencyButton: OnPkgDepToUpdate = Nil.');
|
||||
CurDependency := OnGetPkgDep(Immediately);
|
||||
DependencyChanged := false;
|
||||
if Assigned(CurDependency) then
|
||||
begin
|
||||
// check min version
|
||||
if UseMinVersionCheckBox.Checked <> (pdfMinVersion in CurDependency.Flags) then
|
||||
DependencyChanged := true;
|
||||
if UseMinVersionCheckBox.Checked then begin
|
||||
AVersion := TPkgVersion.Create;
|
||||
if AVersion.ReadString(MinVersionEdit.Text)
|
||||
and (AVersion.Compare(CurDependency.MinVersion)<>0) then
|
||||
DependencyChanged := true;
|
||||
AVersion.Free;
|
||||
end;
|
||||
// check max version
|
||||
if UseMaxVersionCheckBox.Checked <> (pdfMaxVersion in CurDependency.Flags) then
|
||||
DependencyChanged := true;
|
||||
if UseMaxVersionCheckBox.Checked then begin
|
||||
AVersion := TPkgVersion.Create;
|
||||
if AVersion.ReadString(MaxVersionEdit.Text)
|
||||
and (AVersion.Compare(CurDependency.MaxVersion)<>0) then
|
||||
DependencyChanged := true;
|
||||
AVersion.Free;
|
||||
end;
|
||||
end;
|
||||
ApplyDependencyButton.Enabled := DependencyChanged;
|
||||
end;
|
||||
|
||||
procedure TProjPackFilePropGui.MinMaxVersionEditChange(Sender: TObject);
|
||||
begin
|
||||
UpdateApplyDependencyButton;
|
||||
end;
|
||||
|
||||
procedure TProjPackFilePropGui.UseMinVersionCheckBoxChange(Sender: TObject);
|
||||
begin
|
||||
MinVersionEdit.Enabled := UseMinVersionCheckBox.Checked;
|
||||
UpdateApplyDependencyButton;
|
||||
end;
|
||||
|
||||
procedure TProjPackFilePropGui.UseMaxVersionCheckBoxChange(Sender: TObject);
|
||||
begin
|
||||
MaxVersionEdit.Enabled := UseMaxVersionCheckBox.Checked;
|
||||
UpdateApplyDependencyButton;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user