mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-21 18:46:16 +02:00

sparta: initial commit of "compilable" new sparta package - smart form editor. !NOTE: not for daily usage. ........ sparta: Initial conception for package for MDI: sparta_MDI. Base for sparta_DockedFormEditor package. ........ sparta: Generics.Collections library ( sync with https://github.com/dathox/generics.collections SHA fda586932bd80ef58c08f8ebf5a24316ca4ccca5) ........ sparta: smart form editor adjustment for new sparta_MDI ........ sparta: new class "TFormImpl" for MDI solution (created from TDesignedFormImpl). ........ sparta: -MDI form container "TFormContainer" -New IResizeFrame interface to handle MDI form moving -New frame TfrFormBackgroundForMDI ........ sparta: sparta_MDI package modifications: -new class TMultiplyResizer to menage MDI desktop -more generic resizer: TAbstractResizer. Base for IDE resizer and TMultiplyResizer -more advanced IResizeFrame interface ........ sparta: -DockedFormEditor adjustment for latest changes in mdi package -small changes in mdi (visibility of methods). -OnModified method for IResizeFrame ........ sparta: MDI -simulate MDI forms order for TMultiplyResizer -property DesignedForm: IDesignedForm for IResizeFrame ........ sparta: -IMPORTANT! pixel perfect form resizing (fix for problems for controls with align alLeft, alRight etc on design form). -Fix problem for windows: wrong design design window width (a little bigger than designed size) TFormImpl.SetRealBounds -> AdjustSize ........ sparta: mdi bug fix for AV in TMultiplyResizer ........ Fix compilation for FPC 3.0 (TRect changes in FPC 3.1 trunk) ........ sparta: Cannot resize the docked form designer, issue #29380 patch from Anthony Walter. Thanks! ........ sparta ToolsAPI: Delphi compatible ToolsAPI/DesignIDE interface at XE2 level (proxy for IDEIntf). Initial commit (no functionality yet), just interfaces and classes without implementation: designeditors.pas: -TComponentEditor designintf.pas: -Interfaces: IEventInfo, IClass, IActivatable, IDesignObject, IDesignPersistent, IDesignerSelections, IDesigner60, IDesigner70, IDesigner80, IDesigner100, IDesigner, IComponentEditor -TBaseComponentEditor -RegisterComponentEditor designmenus.pas: -Interfaces: IMenuItems, IMenu, IMainMenu, IPopupMenu, IMenuItem ........ when form is removed we need to remove all handlers located in collections FFormsStack and FForms. Necessary to avoid AV. ........ sparta: more correct and simpler calculation of form border for Windows ........ sparta: * Fix for loop error for resize. Highly visible problem for docked forms/frames with Align=alClient. * New THookFrame class as new meta class for Frames. ........ updated lpl ........ git-svn-id: trunk@52728 -
92 lines
2.2 KiB
ObjectPascal
92 lines
2.2 KiB
ObjectPascal
// Generic types for FreeSparta.com and FreePascal!
|
|
// Original version by keeper89.blogspot.com, 2011
|
|
// FPC version by Maciej Izak (hnb), 2014
|
|
|
|
program TArrayProjectDouble;
|
|
|
|
{$MODE DELPHI}
|
|
{$APPTYPE CONSOLE}
|
|
|
|
uses
|
|
SysUtils, Math, Types, Generics.Collections, Generics.Defaults;
|
|
|
|
type
|
|
TDoubleIntegerArray = array of TIntegerDynArray;
|
|
|
|
procedure PrintMatrix(A: TDoubleIntegerArray);
|
|
var
|
|
i, j: Integer;
|
|
begin
|
|
for i := Low(A) to High(A) do
|
|
begin
|
|
for j := Low(A[0]) to High(A[0]) do
|
|
Write(A[i, j]: 3, ' ');
|
|
Writeln;
|
|
end;
|
|
Writeln; Writeln;
|
|
end;
|
|
|
|
function CustomCompare_1(constref Left, Right: TIntegerDynArray): Integer;
|
|
begin
|
|
Result := TCompare.Integer(Right[0], Left[0]);
|
|
end;
|
|
|
|
function CustomCompare_2(constref Left, Right: TIntegerDynArray): Integer;
|
|
var
|
|
i: Integer;
|
|
begin
|
|
i := 0;
|
|
repeat
|
|
Result := TCompare.Integer(Right[i], Left[i]);
|
|
Inc(i);
|
|
until ((Result <> 0) or (i = Length(Left)));
|
|
end;
|
|
|
|
var
|
|
A: TDoubleIntegerArray;
|
|
FoundIndex: Integer;
|
|
i, j: Integer;
|
|
|
|
begin
|
|
WriteLn('Working with TArray - a two-dimensional integer array');
|
|
WriteLn;
|
|
|
|
// Fill integer array with random numbers [1 .. 50]
|
|
SetLength(A, 4, 7);
|
|
Randomize;
|
|
for i := Low(A) to High(A) do
|
|
for j := Low(A[0]) to High(A[0]) do
|
|
A[i, j] := Math.RandomRange(1, 50);
|
|
|
|
// Equate some of the elements for further "cascade" sorting
|
|
A[1, 0] := A[0, 0];
|
|
A[2, 0] := A[0, 0];
|
|
A[1, 1] := A[0, 1];
|
|
|
|
// Print out what happened
|
|
Writeln('The original array:');
|
|
PrintMatrix(A);
|
|
|
|
// ! FPC don't support anonymous methods yet
|
|
//TArray.Sort<TIntegerDynArray>(A, TComparer<TIntegerDynArray>.Construct(
|
|
// function (const Left, Right: TIntegerDynArray): Integer
|
|
// begin
|
|
// Result := Right[0] - Left[0];
|
|
// end));
|
|
// Sort descending 1st column, with cutom comparer_1
|
|
TArrayHelper<TIntegerDynArray>.Sort(A, TComparer<TIntegerDynArray>.Construct(
|
|
CustomCompare_1));
|
|
Writeln('Descending in column 1:');
|
|
PrintMatrix(A);
|
|
|
|
// Sort descending 1st column "cascade" -
|
|
// If the line items are equal, compare neighboring
|
|
TArrayHelper<TIntegerDynArray>.Sort(A, TComparer<TIntegerDynArray>.Construct(
|
|
CustomCompare_2));
|
|
Writeln('Cascade sorting, starting from the 1st column:');
|
|
PrintMatrix(A);
|
|
|
|
Readln;
|
|
end.
|
|
|