diff --git a/docs/xml/lcl/comctrls.xml b/docs/xml/lcl/comctrls.xml
index c70b02ec08..561c9f06fa 100644
--- a/docs/xml/lcl/comctrls.xml
+++ b/docs/xml/lcl/comctrls.xml
@@ -3549,6 +3549,23 @@
+
+
+ Clears the list of tab names of the control, and causes the associated tab sheets or pages to be freed.
+
+
+
+ By calling the Clear method of the protected Tabs property in the TCustomTabControl ancestor, this method removes all tab sheets from the PageControl. The TPageControl.PageCount is 0 afterwards.
+
+
+ Note, however, that the controls on the tab sheets are only destroyed when their Owner is one of the tabsheets. Otherwise they still exist on the form, but their Parent has been set to nil .
+
+
+
+
+
+
+
Gets the value for the ActivePageIndex property.
@@ -3691,20 +3708,6 @@
-
-
- Clears the list of tab names for the control, and causes the associated tab sheets or pages to be freed.
-
-
-
- Calls the Clear method for the protected Tabs property in the TCustomTabControl ancestor.
-
-
-
-
-
-
-
FindNextPage - returns the next page (TTabSheet ) in the sequence.
@@ -5325,7 +5328,7 @@
-
+
@@ -7206,7 +7209,7 @@
-
+
TSortIndicator is an enumerated type with values that represent the sort indicators available in the TListColumn class. TSortIndicator is the type used to implement the SortIndicator property in TListColumn .
@@ -14425,7 +14428,7 @@ AToolbar.ButtonHeight := 30;
Indent is used in the AdjustClientRect method to increment the left edge of the display area for tool buttons on the control.
-
+
@@ -14446,7 +14449,7 @@ AToolbar.ButtonHeight := 30;
Set ShowCaptions to True to enable Caption text on the tool bar buttons.
-
+
@@ -21098,16 +21101,16 @@ AToolbar.ButtonHeight := 30;
-
-
+
+
TControl.TripleClick
-
-
+
+
TControl.QuadClick
@@ -23627,7 +23630,7 @@ OldExpanded.Free;
-
+
@@ -23884,16 +23887,16 @@ OldExpanded.Free;
-
+
-
+
-
+
-
+
@@ -24593,7 +24596,8 @@ OldExpanded.Free;
Register is a procedure used to register components in the comctrls.pp unit in the Lazarus IDE. Register adds the following components:
- Common Controls Tab
+ Common Controls Tab
+
TTrackbar
TProgressBar
diff --git a/lcl/comctrls.pp b/lcl/comctrls.pp
index 4e7a4f24a3..f19044156e 100644
--- a/lcl/comctrls.pp
+++ b/lcl/comctrls.pp
@@ -589,6 +589,7 @@ type
function DoUndockClientMsg(NewTarget, Client: TControl):boolean; override;
function ChildClassAllowed(ChildClass: TClass): boolean; override;
public
+ procedure Clear;
function FindNextPage(CurPage: TTabSheet;
GoForward, CheckTabVisible: Boolean): TTabSheet;
procedure SelectNextPage(GoForward: Boolean);
@@ -2844,7 +2845,8 @@ type
nsHasChildren, // = Node.HasChildren
nsDeleting, // = Node.Deleting, set on Destroy
nsVisible, // = Node.Visible
- nsBound // bound to a tree, e.g. has Parent or is top lvl node
+ nsBound, // bound to a tree, e.g. has Parent or is top lvl node
+ nsValidHasChildren// Node.HasChildren has been assigned
);
TNodeStates = set of TNodeState;
@@ -2918,6 +2920,8 @@ type
var ATreeNode: TTreenode) of object;
TTVCreateNodeClassEvent = procedure(Sender: TCustomTreeView;
var NodeClass: TTreeNodeClass) of object;
+ TTVHasChildrenEvent = function(Sender: TCustomTreeView;
+ ANode: TTreeNode): Boolean of object;
TTreeNodeCompare = function(Node1, Node2: TTreeNode): integer of object;
@@ -2991,12 +2995,12 @@ type
procedure ExpandItem(ExpandIt, Recurse: Boolean);
function GetAbsoluteIndex: Integer;
function GetDeleting: Boolean;
- function GetHasChildren: Boolean;
function GetCount: Integer;
function GetCut: boolean;
function GetDropTarget: Boolean;
function GetExpanded: Boolean;
function GetFocused: Boolean;
+ function GetHasChildren: Boolean;
function GetHeight: integer;
function GetIndex: Integer;
function GetItems(AnIndex: Integer): TTreeNode;
@@ -3378,6 +3382,7 @@ type
FOnExpanding: TTVExpandingEvent;
FOnGetImageIndex: TTVExpandedEvent;
FOnGetSelectedIndex: TTVExpandedEvent;
+ FOnHasChildren: TTVHasChildrenEvent;
FOnNodeChanged: TTVNodeChangedEvent;
FOnSelectionChanged: TNotifyEvent;
FOptions: TTreeViewOptions;
@@ -3564,6 +3569,7 @@ type
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseLeave; override;
procedure NodeChanged(Node: TTreeNode; ChangeReason: TTreeNodeChangeReason); virtual;
+ function NodeHasChildren(Node: TTreeNode): Boolean; virtual;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure Paint; override;
procedure ScrollView(DeltaX, DeltaY: Integer);
@@ -3623,6 +3629,8 @@ type
read FOnGetImageIndex write FOnGetImageIndex;
property OnGetSelectedIndex: TTVExpandedEvent
read FOnGetSelectedIndex write FOnGetSelectedIndex;
+ property OnHasChildren: TTVHasChildrenEvent
+ read FOnHasChildren write FOnHasChildren;
property OnNodeChanged: TTVNodeChangedEvent read FOnNodeChanged write FOnNodeChanged;
property OnSelectionChanged: TNotifyEvent
read FOnSelectionChanged write FOnSelectionChanged;
@@ -3806,6 +3814,7 @@ type
property OnExpanding;
property OnGetImageIndex;
property OnGetSelectedIndex;
+ property OnHasChildren;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
diff --git a/lcl/include/pagecontrol.inc b/lcl/include/pagecontrol.inc
index 01d78dce84..7eb13a122c 100644
--- a/lcl/include/pagecontrol.inc
+++ b/lcl/include/pagecontrol.inc
@@ -193,5 +193,9 @@ begin
Result.PageControl := Self;
end;
+procedure TPageControl.Clear;
+begin
+ Tabs.Clear;
+end;
// included by comctrls.pp
diff --git a/lcl/include/treeview.inc b/lcl/include/treeview.inc
index bd6a0ac595..de40fbbbcc 100644
--- a/lcl/include/treeview.inc
+++ b/lcl/include/treeview.inc
@@ -854,6 +854,14 @@ end;
function TTreeNode.GetHasChildren: Boolean;
begin
+ if not GetState(nsValidHasChildren) then
+ begin
+ if Owner.Owner.NodeHasChildren(Self) then
+ Include(FStates, nsHasChildren)
+ else
+ Exclude(FStates, nsHasChildren);
+ Include(FStates, nsValidHasChildren);
+ end;
Result := GetState(nsHasChildren);
end;
@@ -895,7 +903,7 @@ end;
procedure TTreeNode.SetHasChildren(AValue: Boolean);
begin
- if AValue=HasChildren then exit;
+ if GetState(nsValidHasChildren) and (AValue=HasChildren) then exit;
//DebugLn('[TTreeNode.SetHasChildren] Self=',DbgS(Self),' Self.Text=',Text,' AValue=',AValue);
if AValue then
Include(FStates,nsHasChildren)
@@ -904,6 +912,7 @@ begin
GetLastChild.Free;
Exclude(FStates,nsHasChildren)
end;
+ Include(FStates, nsValidHasChildren);
Update;
end;
@@ -5943,6 +5952,14 @@ begin
OnNodeChanged(self,Node,ChangeReason);
end;
+function TCustomTreeView.NodeHasChildren(Node: TTreeNode): Boolean;
+begin
+ if Assigned(FOnHasChildren) then
+ Result := FOnHasChildren(Self, Node)
+ else
+ Result := false;
+end;
+
procedure TCustomTreeView.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
diff --git a/lcl/shellctrls.pas b/lcl/shellctrls.pas
index 15fe046d78..f9eee38517 100644
--- a/lcl/shellctrls.pas
+++ b/lcl/shellctrls.pas
@@ -87,6 +87,7 @@ type
function CanExpand(Node: TTreeNode): Boolean; override;
function DrawBuiltInIcon(ANode: TTreeNode; ARect: TRect): TSize; override;
function GetBuiltinIconSize: TSize; override;
+ function NodeHasChildren(Node: TTreeNode): Boolean; override;
public
{ Basic methods }
constructor Create(AOwner: TComponent); override;
@@ -176,6 +177,7 @@ type
property OnExpanding;
property OnGetImageIndex;
property OnGetSelectedIndex;
+ property OnHasChildren;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
@@ -615,9 +617,14 @@ begin
if not Result then exit;
OldAutoExpand:=AutoExpand;
AutoExpand:=False;
- Node.DeleteChildren;
- Result := PopulateTreeNodeWithFiles(Node, GetPathFromNode(Node));
- AutoExpand:=OldAutoExpand;
+ BeginUpdate;
+ try
+ Node.DeleteChildren;
+ Result := PopulateTreeNodeWithFiles(Node, GetPathFromNode(Node));
+ AutoExpand:=OldAutoExpand;
+ finally
+ EndUpdate;
+ end;
end;
constructor TCustomShellTreeView.Create(AOwner: TComponent);
@@ -829,6 +836,54 @@ begin
Result := IncludeTrailingPathDelimiter(Result);
end;
+function TCustomShellTreeView.NodeHasChildren(Node: TTreeNode): Boolean;
+
+ function HasSubDir(Const ADir: String): Boolean;
+ var
+ SR: TSearchRec;
+ FindRes: LongInt;
+ Attr: Longint;
+ IsHidden: Boolean;
+ begin
+ Result:=False;
+ try
+ Attr := faDirectory;
+ if (otHidden in fObjectTypes) then Attr := Attr or faHidden{%H-};
+ FindRes := FindFirstUTF8(AppendPathDelim(ADir) + AllFilesMask, Attr , SR);
+ while (FindRes = 0) do
+ begin
+ if ((SR.Attr and faDirectory <> 0) and (SR.Name <> '.') and
+ (SR.Name <> '..')) then
+ begin
+ IsHidden := ((Attr and faHidden{%H-}) > 0);
+ if not (IsHidden and (not ((otHidden in fObjectTypes)))) then
+ begin
+ Result := True;
+ Break;
+ end;
+ end;
+ FindRes := FindNextUtf8(SR);
+ end;
+ finally
+ FindCloseUTF8(SR);
+ end; //try
+ end;
+
+var
+ NodePath: String;
+begin
+ if Assigned(OnHasChildren) then
+ Result := OnHasChildren(Self, Node)
+ else
+ begin
+ NodePath := GetPathFromNode(Node);
+ if (fObjectTypes * [otNonFolders] = []) then
+ Result := TShellTreeNode(Node).IsDirectory and HasSubDir(NodePath)
+ else
+ Result := TShellTreeNode(Node).IsDirectory;
+ end;
+end;
+
{ Returns true if at least one item was added, false otherwise }
function TCustomShellTreeView.PopulateTreeNodeWithFiles(
ANode: TTreeNode; ANodePath: string): Boolean;
@@ -837,38 +892,6 @@ var
Files: TStringList;
NewNode: TTreeNode;
CanAdd: Boolean;
-
- function HasSubDir(Const ADir: String): Boolean;
- var
- SR: TSearchRec;
- FindRes: LongInt;
- Attr: Longint;
- IsHidden: Boolean;
- begin
- Result:=False;
- try
- Attr := faDirectory;
- if (otHidden in fObjectTypes) then Attr := Attr or faHidden{%H-};
- FindRes := FindFirstUTF8(AppendPathDelim(ADir) + AllFilesMask, Attr , SR);
- while (FindRes = 0) do
- begin
- if ((SR.Attr and faDirectory <> 0) and (SR.Name <> '.') and
- (SR.Name <> '..')) then
- begin
- IsHidden := ((Attr and faHidden{%H-}) > 0);
- if not (IsHidden and (not ((otHidden in fObjectTypes)))) then
- begin
- Result := True;
- Break;
- end;
- end;
- FindRes := FindNextUtf8(SR);
- end;
- finally
- FindCloseUTF8(SR);
- end; //try
- end;
-
begin
Result := False;
// avoids crashes in the IDE by not populating during design
@@ -890,12 +913,8 @@ begin
NewNode := Items.AddChildObject(ANode, Files[i], nil);
TShellTreeNode(NewNode).FFileInfo := TFileItem(Files.Objects[i]).FileInfo;
TShellTreeNode(NewNode).SetBasePath(TFileItem(Files.Objects[i]).FBasePath);
-
- if (fObjectTypes * [otNonFolders] = []) then
- NewNode.HasChildren := (TShellTreeNode(NewNode).IsDirectory and
- HasSubDir(AppendpathDelim(ANodePath)+Files[i]))
- else
- NewNode.HasChildren := TShellTreeNode(NewNode).IsDirectory;
+ // NewNode.HasChildren will be set later when needed to avoid opening
+ // all subdirectories (--> NodeHasChildren).
end;
end;
finally