mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-11 20:19:14 +02:00
LCL: added TWinControl.GetEnumeratorControls,GetEnumeratorControlsReverse
git-svn-id: trunk@38570 -
This commit is contained in:
parent
255f81bf6b
commit
60899d17a7
@ -1828,6 +1828,21 @@ type
|
||||
var NewLeft, NewTop, NewWidth, NewHeight: Integer;
|
||||
var AlignRect: TRect; AlignInfo: TAlignInfo) of object;
|
||||
|
||||
{ TWinControlEnumerator }
|
||||
|
||||
TWinControlEnumerator = class
|
||||
protected
|
||||
FIndex: integer;
|
||||
FLowToHigh: boolean;
|
||||
FParent: TWinControl;
|
||||
function GetCurrent: TControl;
|
||||
public
|
||||
constructor Create(Parent: TWinControl; aLowToHigh: boolean = true);
|
||||
function GetEnumerator: TWinControlEnumerator;
|
||||
function MoveNext: Boolean;
|
||||
property Current: TControl read GetCurrent;
|
||||
end;
|
||||
|
||||
TWinControl = class(TControl)
|
||||
private
|
||||
FAlignOrder: TFPList; // list of TControl. Last moved (SetBounds) comes first. Used by AlignControls.
|
||||
@ -2143,9 +2158,14 @@ type
|
||||
function GetTextLen: Integer; override;
|
||||
procedure Invalidate; override;
|
||||
procedure AddControl; virtual; // tell widgetset
|
||||
|
||||
procedure InsertControl(AControl: TControl);
|
||||
procedure InsertControl(AControl: TControl; Index: integer); virtual;
|
||||
procedure RemoveControl(AControl: TControl); virtual;
|
||||
// enumerators
|
||||
function GetEnumeratorControls: TWinControlEnumerator;
|
||||
function GetEnumeratorControlsReverse: TWinControlEnumerator;
|
||||
|
||||
procedure Repaint; override;
|
||||
procedure Update; override;
|
||||
procedure SetFocus; virtual;
|
||||
|
@ -6227,6 +6227,16 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TWinControl.GetEnumeratorControls: TWinControlEnumerator;
|
||||
begin
|
||||
Result:=TWinControlEnumerator.Create(Self,true);
|
||||
end;
|
||||
|
||||
function TWinControl.GetEnumeratorControlsReverse: TWinControlEnumerator;
|
||||
begin
|
||||
Result:=TWinControlEnumerator.Create(Self,false);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
TWinControl AlignControl
|
||||
------------------------------------------------------------------------------}
|
||||
@ -8345,6 +8355,45 @@ begin
|
||||
if Parent <> nil then Parent.ShowControl(Self);
|
||||
end;
|
||||
|
||||
{ TWinControlEnumerator }
|
||||
|
||||
function TWinControlEnumerator.GetCurrent: TControl;
|
||||
begin
|
||||
if (FIndex>=0) and (FIndex<FParent.ControlCount) then
|
||||
Result:=FParent.Controls[FIndex]
|
||||
else
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
constructor TWinControlEnumerator.Create(Parent: TWinControl;
|
||||
aLowToHigh: boolean);
|
||||
begin
|
||||
FParent:=Parent;
|
||||
FLowToHigh:=aLowToHigh;
|
||||
if FLowToHigh then
|
||||
FIndex:=-1
|
||||
else
|
||||
FIndex:=FParent.ControlCount;
|
||||
end;
|
||||
|
||||
function TWinControlEnumerator.GetEnumerator: TWinControlEnumerator;
|
||||
begin
|
||||
Result:=Self;
|
||||
end;
|
||||
|
||||
function TWinControlEnumerator.MoveNext: Boolean;
|
||||
begin
|
||||
if FLowToHigh then
|
||||
begin
|
||||
inc(FIndex);
|
||||
Result:=FIndex<FParent.ControlCount;
|
||||
end
|
||||
else begin
|
||||
dec(FIndex);
|
||||
Result:=FIndex>=0
|
||||
end;
|
||||
end;
|
||||
|
||||
{ $UNDEF CHECK_POSITION}
|
||||
|
||||
{$IFDEF ASSERT_IS_ON}
|
||||
|
Loading…
Reference in New Issue
Block a user