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