mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-30 22:42:39 +02:00
LCL: update actionlists of nested frames, bug #15229
git-svn-id: trunk@22895 -
This commit is contained in:
parent
affef50bcc
commit
7a89ac6e1f
@ -472,7 +472,7 @@ type
|
||||
function FindDefaultForActiveControl: TWinControl;
|
||||
procedure UpdateMenu;
|
||||
protected
|
||||
FActionLists: TList;
|
||||
FActionLists: TList; // keep this TList for Delphi compatibility
|
||||
FFormBorderStyle: TFormBorderStyle;
|
||||
FFormState: TFormState;
|
||||
class procedure WSRegisterClass; override;
|
||||
@ -514,6 +514,8 @@ type
|
||||
procedure DoAutoSize; override;
|
||||
procedure SetAutoSize(Value: Boolean); override;
|
||||
procedure SetAutoScroll(Value: Boolean); override;
|
||||
procedure DoAddActionList(List: TCustomActionList);
|
||||
procedure DoRemoveActionList(List: TCustomActionList);
|
||||
protected
|
||||
// drag and dock
|
||||
procedure BeginAutoDrag; override;
|
||||
|
@ -141,8 +141,7 @@ begin
|
||||
begin
|
||||
if AComponent is TCustomActionList then
|
||||
begin
|
||||
if FActionLists = nil then FActionLists := TList.Create;
|
||||
FActionLists.Add(AComponent);
|
||||
DoAddActionList(TCustomActionList(AComponent));
|
||||
end
|
||||
else
|
||||
if not (csLoading in ComponentState) and (Menu = nil) and
|
||||
@ -152,7 +151,7 @@ begin
|
||||
opRemove:
|
||||
begin
|
||||
if (FActionLists <> nil) and (AComponent is TCustomActionList) then
|
||||
FActionLists.Remove(AComponent)
|
||||
DoRemoveActionList(TCustomActionList(AComponent))
|
||||
else
|
||||
if AComponent = Menu then Menu := nil;
|
||||
if FActiveControl=AComponent then
|
||||
@ -1127,6 +1126,22 @@ begin
|
||||
inherited SetAutoScroll(Value and (BorderStyle in BorderStylesAllowAutoScroll));
|
||||
end;
|
||||
|
||||
procedure TCustomForm.DoAddActionList(List: TCustomActionList);
|
||||
begin
|
||||
if FActionLists=nil then
|
||||
FActionLists:=TList.Create;
|
||||
if FActionLists.IndexOf(List)<0 then begin
|
||||
FActionLists.Add(List);
|
||||
List.FreeNotification(Self);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomForm.DoRemoveActionList(List: TCustomActionList);
|
||||
begin
|
||||
if FActionLists<>nil then
|
||||
FActionLists.Remove(List);
|
||||
end;
|
||||
|
||||
procedure TCustomForm.BeginAutoDrag;
|
||||
begin
|
||||
// allow form dragging only if it is docked into a site without DockManager
|
||||
|
@ -23,11 +23,7 @@ var
|
||||
begin
|
||||
ParentForm := GetParentForm(Self);
|
||||
if ParentForm <> nil then
|
||||
begin
|
||||
if ParentForm.FActionLists = nil then
|
||||
ParentForm.FActionLists := TList.Create;
|
||||
ParentForm.FActionLists.Add(ActionList);
|
||||
end;
|
||||
ParentForm.DoAddActionList(ActionList);
|
||||
end;
|
||||
|
||||
procedure TCustomFrame.RemoveActionList(ActionList: TCustomActionList);
|
||||
@ -35,8 +31,8 @@ var
|
||||
ParentForm: TCustomForm;
|
||||
begin
|
||||
ParentForm:=GetParentForm(Self);
|
||||
if (ParentForm<>nil) and (ParentForm.FActionLists<>nil) then
|
||||
ParentForm.FActionLists.Remove(ActionList);
|
||||
if (ParentForm<>nil) then
|
||||
ParentForm.DoRemoveActionList(ActionList);
|
||||
end;
|
||||
|
||||
procedure TCustomFrame.ReadDesignLeft(Reader: TReader);
|
||||
@ -107,29 +103,33 @@ end;
|
||||
|
||||
procedure TCustomFrame.SetParent(AParent: TWinControl);
|
||||
|
||||
procedure UpdateActionLists(Operation: TOperation);
|
||||
procedure UpdateActionLists(Root: TComponent; Operation: TOperation);
|
||||
var
|
||||
i: Integer;
|
||||
AComponent: TComponent;
|
||||
begin
|
||||
for i := 0 to ComponentCount - 1 do
|
||||
for i := 0 to Root.ComponentCount - 1 do
|
||||
begin
|
||||
AComponent := Components[i];
|
||||
AComponent := Root.Components[i];
|
||||
if AComponent is TCustomActionList then
|
||||
case Operation of
|
||||
opInsert: AddActionList(TCustomActionList(AComponent));
|
||||
opRemove: RemoveActionList(TCustomActionList(AComponent));
|
||||
end;
|
||||
// update nested frames
|
||||
if csInline in AComponent.ComponentState then
|
||||
UpdateActionLists(AComponent,Operation);
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
if Parent<>nil then UpdateActionLists(opRemove);
|
||||
if Parent<>nil then
|
||||
UpdateActionLists(Self,opRemove);
|
||||
if (Parent=nil) and HandleAllocated then
|
||||
DestroyHandle;
|
||||
inherited SetParent(AParent);
|
||||
if Parent <> nil then
|
||||
UpdateActionLists(opInsert);
|
||||
UpdateActionLists(Self,opInsert);
|
||||
end;
|
||||
|
||||
class function TCustomFrame.GetControlClassDefaultSize: TPoint;
|
||||
|
Loading…
Reference in New Issue
Block a user