mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-21 06:06:16 +02:00
Menu designer: Reduce nested functions in TMenuDesigner.GetPopupAssignmentCount.
git-svn-id: trunk@51489 -
This commit is contained in:
parent
b205f54650
commit
233b5770d2
@ -91,6 +91,8 @@ type
|
|||||||
procedure InitializeStatisticVars;
|
procedure InitializeStatisticVars;
|
||||||
procedure LoadFixedButtonGlyphs;
|
procedure LoadFixedButtonGlyphs;
|
||||||
procedure OnDesignerSetSelection(const ASelection: TPersistentSelectionList);
|
procedure OnDesignerSetSelection(const ASelection: TPersistentSelectionList);
|
||||||
|
procedure ProcessForPopup(aControl: TControl);
|
||||||
|
procedure ScanLookupRoot(aForm: TCustomForm);
|
||||||
procedure SetupPopupAssignmentsDisplay;
|
procedure SetupPopupAssignmentsDisplay;
|
||||||
public
|
public
|
||||||
procedure LoadVariableButtonGlyphs(isInMenubar: boolean);
|
procedure LoadVariableButtonGlyphs(isInMenubar: boolean);
|
||||||
@ -363,37 +365,33 @@ begin
|
|||||||
else Result:=nil;
|
else Result:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMenuDesigner.ProcessForPopup(aControl: TControl);
|
||||||
|
var
|
||||||
|
wc: TWinControl;
|
||||||
|
j:integer;
|
||||||
|
begin
|
||||||
|
if (aControl.PopupMenu = FEditedMenu) and (aControl.Name <> '') then
|
||||||
|
FPopupAssignments.Add(aControl.Name);
|
||||||
|
if (aControl is TWinControl) then begin
|
||||||
|
wc:=TWinControl(aControl);
|
||||||
|
for j:=0 to wc.ControlCount-1 do
|
||||||
|
ProcessForPopup(wc.Controls[j]); // Recursive call
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMenuDesigner.ScanLookupRoot(aForm: TCustomForm);
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
begin
|
||||||
|
if (aForm.PopupMenu = FEditedMenu) then
|
||||||
|
FPopupAssignments.Add(aForm.Name);
|
||||||
|
for i:=0 to aForm.ControlCount-1 do
|
||||||
|
ProcessForPopup(aForm.Controls[i]);
|
||||||
|
end;
|
||||||
|
|
||||||
function TMenuDesigner.GetPopupAssignmentCount: integer;
|
function TMenuDesigner.GetPopupAssignmentCount: integer;
|
||||||
var
|
var
|
||||||
lookupRoot: TPersistent;
|
lookupRoot: TPersistent;
|
||||||
|
|
||||||
procedure ScanLookupRoot;
|
|
||||||
var
|
|
||||||
frm: TCustomForm;
|
|
||||||
i: integer;
|
|
||||||
|
|
||||||
procedure ProcessForPopup(aControl: TControl);
|
|
||||||
var
|
|
||||||
wc: TWinControl;
|
|
||||||
j:integer;
|
|
||||||
begin
|
|
||||||
if (aControl.PopupMenu = FEditedMenu) and (aControl.Name <> '') then
|
|
||||||
FPopupAssignments.Add(aControl.Name);
|
|
||||||
if (aControl is TWinControl) then begin
|
|
||||||
wc:=TWinControl(aControl);
|
|
||||||
for j:=0 to wc.ControlCount-1 do
|
|
||||||
ProcessForPopup(wc.Controls[j]);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
begin
|
|
||||||
frm:=TCustomForm(lookupRoot);
|
|
||||||
if (frm.PopupMenu = FEditedMenu) then
|
|
||||||
FPopupAssignments.Add(frm.Name);
|
|
||||||
for i:=0 to frm.ControlCount-1 do
|
|
||||||
ProcessForPopup(frm.Controls[i]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
lookupRoot:=GlobalDesignHook.LookupRoot;
|
lookupRoot:=GlobalDesignHook.LookupRoot;
|
||||||
if (FEditedMenu is TMainMenu) or (lookupRoot is TDataModule) then
|
if (FEditedMenu is TMainMenu) or (lookupRoot is TDataModule) then
|
||||||
@ -401,7 +399,7 @@ begin
|
|||||||
else begin
|
else begin
|
||||||
FreeAndNil(FPopupAssignments);
|
FreeAndNil(FPopupAssignments);
|
||||||
FPopupAssignments:=TStringList.Create;
|
FPopupAssignments:=TStringList.Create;
|
||||||
ScanLookupRoot;
|
ScanLookupRoot(lookupRoot as TCustomForm);
|
||||||
Result:=FPopupAssignments.Count;
|
Result:=FPopupAssignments.Count;
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
@ -695,7 +693,6 @@ end;
|
|||||||
initialization
|
initialization
|
||||||
|
|
||||||
RegisterComponentEditor(TMenu, TMainMenuComponentEditor);
|
RegisterComponentEditor(TMenu, TMainMenuComponentEditor);
|
||||||
|
|
||||||
RegisterPropertyEditor(TypeInfo(TMenu), TMenu, 'Items', TMenuItemsPropertyEditor);
|
RegisterPropertyEditor(TypeInfo(TMenu), TMenu, 'Items', TMenuItemsPropertyEditor);
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user