You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The list of compilers in the Configure Compilers dialogue box starts with Delphi 2 and you have to scroll to get to any of the more recent compilers. Reversing the order in the list would make it easier to edit the later compilers.
We're going to need to either (a) create a parallel array to the list items mapping item indices to compiler IDs or (b) to create custom list items that store the related compiler ID.
The parallel array method may be the easiest to implement. Some ideas:
Declare fields
fMapIdxToComp: TArray<TCompilerID>;
fMapCompToIdx: array[TCompilerID] of Integer;
In the Initialise method:
procedureTCompilerListMgr.Initialise;
var
CompID: TCompilerID; // loops thru supported compilers
Idx: Integer;
begininherited;
// Add empty list items - one per supported compiler. Note we don't need item// text since we handle drawing of list items ourselves and get details from// compiler objects.
SetLength(fMapIdxToComp, Length (fMapCompToIdx);
Idx := 0;
for CompID := High(TCompilerID) downto LowTCompilerID) dobegin
fLB.Items.Add('');
fMapIdxToComp[Idx] := CompID;
fMapCompToIdx[CompID] := Idx;
Inc(Idx);
end;
// Select first compiler in list and trigger selection event for it
fLB.ItemIndex := 0;
DoSelect;
end;
In the GetSelected method:
functionTCompilerListMgr.GetSelected: ICompiler;
begin
Result := fCompilers[fMapIdxToComp[fLB.ItemIndex]];
end;
And in list box custom draw method:
procedureTCompilerListMgr.LBDrawItemHandler(Control: TWinControl;
Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
...
// Compiler object associated with list item
Compiler := fCompilers[fMapIdxToComp[fLB.ItemIndex]];
...
end;
And the Refresh method:
procedureTCompilerListMgr.Refresh(Compiler: ICompiler);
var
InvalidRect: TRectEx;
begin
InvalidRect := fLB.ItemRect(fMapCompIDToIdx[Compiler.GetID]);
InvalidateRect(fLB.Handle, @InvalidRect, False);
end;
changed the title [-]Reverse order of compilers Configure Compilers dialogue box[/-][+]Reverse order of compilers in Configure Compilers dialogue box[/+]on Dec 16, 2022
Activity
delphidabbler commentedon Jul 7, 2022
The current code maps the compiler ID to the compiler list box index:
codesnip/Src/FmCompilersDlg.UCompilerListMgr.pas
Line 106 in 19f0ca5
This relationship is also relied upon in the custom draw handler:
codesnip/Src/FmCompilersDlg.UCompilerListMgr.pas
Line 142 in 19f0ca5
We're going to need to either (a) create a parallel array to the list items mapping item indices to compiler IDs or (b) to create custom list items that store the related compiler ID.
Not good code, but there it is.
delphidabbler commentedon Jul 7, 2022
The parallel array method may be the easiest to implement. Some ideas:
Declare fields
In the Initialise method:
In the GetSelected method:
And in list box custom draw method:
And the Refresh method:
Not tested any of this.
delphidabbler commentedon Dec 12, 2022
💡 Order of compilers in Find Compilers dialogue box could also benefit from being revered.
[-]Reverse order of compilers Configure Compilers dialogue box[/-][+]Reverse order of compilers in Configure Compilers dialogue box[/+]15 remaining items