mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 02:16:48 +02:00
Designer: Improve MenuEditor, delete only one item at time. Issue #22142, patch from Anton
git-svn-id: trunk@37659 -
This commit is contained in:
parent
744f01cc46
commit
80fa80846b
@ -70,7 +70,10 @@ type
|
|||||||
procedure TemplateView(templatemenuitem: string; default_template: Integer);
|
procedure TemplateView(templatemenuitem: string; default_template: Integer);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TDesignerMenuItem }
|
||||||
|
|
||||||
TDesignerMenuItem = class
|
TDesignerMenuItem = class
|
||||||
|
public
|
||||||
SelfPanel: TPanel;
|
SelfPanel: TPanel;
|
||||||
SubMenuPanel: TPanel;
|
SubMenuPanel: TPanel;
|
||||||
SubMenuArrow: TArrow;
|
SubMenuArrow: TArrow;
|
||||||
@ -88,6 +91,8 @@ type
|
|||||||
SelfPanelCreated: Boolean;
|
SelfPanelCreated: Boolean;
|
||||||
SubMenuPanelCreated: Boolean;
|
SubMenuPanelCreated: Boolean;
|
||||||
ID: string;
|
ID: string;
|
||||||
|
RealMenuItem: TMenuItem;
|
||||||
|
constructor Create(ARealMenuItem: TMenuItem);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TDesignerMainMenu }
|
{ TDesignerMainMenu }
|
||||||
@ -102,7 +107,6 @@ type
|
|||||||
fMenu: TMenu;
|
fMenu: TMenu;
|
||||||
fDefaultComponentEditor: TDefaultComponentEditor;
|
fDefaultComponentEditor: TDefaultComponentEditor;
|
||||||
FDesignerPopupMenu: TPopupMenu;
|
FDesignerPopupMenu: TPopupMenu;
|
||||||
TemplateMenuForm: TTemplateMenuForm;
|
|
||||||
temp_panel: TPanel;
|
temp_panel: TPanel;
|
||||||
temp_level: Integer;
|
temp_level: Integer;
|
||||||
temp_newitemcounter: Integer;
|
temp_newitemcounter: Integer;
|
||||||
@ -110,6 +114,7 @@ type
|
|||||||
function GetDesigner: TComponentEditorDesigner;
|
function GetDesigner: TComponentEditorDesigner;
|
||||||
procedure SetRoot(const AValue: TDesignerMenuItem);
|
procedure SetRoot(const AValue: TDesignerMenuItem);
|
||||||
protected
|
protected
|
||||||
|
procedure DesignerSetSelection(const ASelection: TPersistentSelectionList);
|
||||||
procedure PersistentDeleting(APersistent: TPersistent);
|
procedure PersistentDeleting(APersistent: TPersistent);
|
||||||
function SearchItemByPanel(DMenuItem: TDesignerMenuItem; APanel: TPanel): TDesignerMenuItem;
|
function SearchItemByPanel(DMenuItem: TDesignerMenuItem; APanel: TPanel): TDesignerMenuItem;
|
||||||
procedure ClearAllMenus;
|
procedure ClearAllMenus;
|
||||||
@ -201,6 +206,48 @@ var
|
|||||||
TemplateMenuFormCreateAction: Integer;
|
TemplateMenuFormCreateAction: Integer;
|
||||||
XMLConfig: TXMLConfig = nil;
|
XMLConfig: TXMLConfig = nil;
|
||||||
|
|
||||||
|
{ TDesignerMenuItem }
|
||||||
|
|
||||||
|
constructor TDesignerMenuItem.Create(ARealMenuItem: TMenuItem);
|
||||||
|
begin
|
||||||
|
Self.RealMenuItem := ARealMenuItem;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TDesignerMainMenu }
|
||||||
|
|
||||||
|
procedure TDesignerMainMenu.DesignerSetSelection(
|
||||||
|
const ASelection: TPersistentSelectionList);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
MenuItem, pMenu: TMenuItem;
|
||||||
|
DesignerItem: TDesignerMenuItem;
|
||||||
|
InvalidateNeeded: Boolean;
|
||||||
|
begin
|
||||||
|
InvalidateNeeded := False;
|
||||||
|
for i := 0 to ASelection.Count - 1 do
|
||||||
|
if ASelection.Items[i] is TMenuItem then
|
||||||
|
begin
|
||||||
|
MenuItem := TMenuItem(ASelection.Items[i]);
|
||||||
|
pMenu := MenuItem;
|
||||||
|
while pMenu.HasParent do
|
||||||
|
pMenu := pMenu.Parent;
|
||||||
|
if pMenu <> fMenu.Items then Continue;
|
||||||
|
DesignerItem := FindDesignerMenuItem(MenuItem);
|
||||||
|
if not Assigned(DesignerItem) then Continue;
|
||||||
|
|
||||||
|
ChangeMenuItem(Root, 2, Root.ID);
|
||||||
|
InitIndexSequence;
|
||||||
|
|
||||||
|
SelectedDesignerMenuItem := DesignerItem.ID;
|
||||||
|
ChangeMenuItem(Root, 1, SelectedDesignerMenuItem);
|
||||||
|
CreateIndexSequence(Root, SelectedDesignerMenuItem, 1);
|
||||||
|
|
||||||
|
InvalidateNeeded := True;
|
||||||
|
end;
|
||||||
|
if InvalidateNeeded then
|
||||||
|
RealignDesigner;
|
||||||
|
end;
|
||||||
|
|
||||||
function TDesignerMainMenu.GetDesigner: TComponentEditorDesigner;
|
function TDesignerMainMenu.GetDesigner: TComponentEditorDesigner;
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
@ -297,8 +344,9 @@ begin
|
|||||||
GlobalDesignHook.AddHandlerModified(@OnDesignerModified);
|
GlobalDesignHook.AddHandlerModified(@OnDesignerModified);
|
||||||
//GlobalDesignHook.AddHandlerPersistentAdded(@OnComponentAdded);
|
//GlobalDesignHook.AddHandlerPersistentAdded(@OnComponentAdded);
|
||||||
GlobalDesignHook.AddHandlerPersistentDeleting(@PersistentDeleting);
|
GlobalDesignHook.AddHandlerPersistentDeleting(@PersistentDeleting);
|
||||||
|
GlobalDesignHook.AddHandlerSetSelection(@DesignerSetSelection);
|
||||||
|
|
||||||
FRoot := TDesignerMenuItem.Create;
|
FRoot := TDesignerMenuItem.Create(nil);
|
||||||
fMenu := AMenu;
|
fMenu := AMenu;
|
||||||
|
|
||||||
temp_level := 1;
|
temp_level := 1;
|
||||||
@ -395,7 +443,7 @@ begin
|
|||||||
PrevMI := nil;
|
PrevMI := nil;
|
||||||
for i := 0 to fMenu.Items.Count - 1 do
|
for i := 0 to fMenu.Items.Count - 1 do
|
||||||
begin
|
begin
|
||||||
MI := TDesignerMenuItem.Create;
|
MI := TDesignerMenuItem.Create(fMenu.Items[i]);
|
||||||
MI.Caption := fMenu.Items[i].Caption;
|
MI.Caption := fMenu.Items[i].Caption;
|
||||||
MI.Level := temp_level;
|
MI.Level := temp_level;
|
||||||
MI.NextItem := nil;
|
MI.NextItem := nil;
|
||||||
@ -429,7 +477,7 @@ begin
|
|||||||
PrevMI:=nil;
|
PrevMI:=nil;
|
||||||
for i:= 0 to AMenuItem.Count-1 do
|
for i:= 0 to AMenuItem.Count-1 do
|
||||||
begin
|
begin
|
||||||
MI := TDesignerMenuItem.Create;
|
MI := TDesignerMenuItem.Create(AMenuItem.Items[i]);
|
||||||
MI.Caption:=AMenuItem.Items[i].Caption;
|
MI.Caption:=AMenuItem.Items[i].Caption;
|
||||||
MI.Level:=temp_level;
|
MI.Level:=temp_level;
|
||||||
MI.NextItem:=nil;
|
MI.NextItem:=nil;
|
||||||
@ -798,8 +846,8 @@ begin
|
|||||||
SetCoordinates(POSITION_LEFT, POSITION_TOP, 0, Root);
|
SetCoordinates(POSITION_LEFT, POSITION_TOP, 0, Root);
|
||||||
InitIndexSequence;
|
InitIndexSequence;
|
||||||
CreateIndexSequence(Root, SelectedDesignerMenuItem, 1);
|
CreateIndexSequence(Root, SelectedDesignerMenuItem, 1);
|
||||||
UpdateMenu(fMenu.Items, GetDesignerMenuItem(Root, SelectedDesignerMenuItem).PrevItem, 1, 2);
|
UpdateMenu(fMenu.Items,
|
||||||
RealignDesigner;
|
GetDesignerMenuItem(Root, SelectedDesignerMenuItem).PrevItem, 1, 2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// ------------------------------------------------------------//
|
// ------------------------------------------------------------//
|
||||||
@ -816,8 +864,8 @@ begin
|
|||||||
SetCoordinates(POSITION_LEFT, POSITION_TOP, 0, Root);
|
SetCoordinates(POSITION_LEFT, POSITION_TOP, 0, Root);
|
||||||
InitIndexSequence;
|
InitIndexSequence;
|
||||||
CreateIndexSequence(Root, SelectedDesignerMenuItem, 1);
|
CreateIndexSequence(Root, SelectedDesignerMenuItem, 1);
|
||||||
UpdateMenu(fMenu.Items, GetDesignerMenuItem(Root, SelectedDesignerMenuItem).NextItem, 1, 1);
|
UpdateMenu(fMenu.Items,
|
||||||
RealignDesigner;
|
GetDesignerMenuItem(Root,SelectedDesignerMenuItem).NextItem,1,1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// ------------------------------------------------------------//
|
// ------------------------------------------------------------//
|
||||||
@ -834,8 +882,8 @@ begin
|
|||||||
SetCoordinates(POSITION_LEFT, POSITION_TOP, 0, Root);
|
SetCoordinates(POSITION_LEFT, POSITION_TOP, 0, Root);
|
||||||
InitIndexSequence;
|
InitIndexSequence;
|
||||||
CreateIndexSequence(Root, SelectedDesignerMenuItem,1);
|
CreateIndexSequence(Root, SelectedDesignerMenuItem,1);
|
||||||
UpdateMenu(fMenu.Items, GetDesignerMenuItem(Root, SelectedDesignerMenuItem).SubMenu, 1, 3);
|
UpdateMenu(fMenu.Items,
|
||||||
RealignDesigner;
|
GetDesignerMenuItem(Root, SelectedDesignerMenuItem).SubMenu, 1, 3);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------//
|
// -----------------------------------------------------------------------//
|
||||||
@ -917,8 +965,7 @@ begin
|
|||||||
if APersistent is TMenuItem then
|
if APersistent is TMenuItem then
|
||||||
begin
|
begin
|
||||||
Item := FindDesignerMenuItem(MenuItem);
|
Item := FindDesignerMenuItem(MenuItem);
|
||||||
// how we can compare them?
|
if Item <> nil then
|
||||||
if (Item <> nil) and (Item.Caption = MenuItem.Caption) then
|
|
||||||
begin
|
begin
|
||||||
DeleteItem(Item);
|
DeleteItem(Item);
|
||||||
SetCoordinates(POSITION_LEFT, POSITION_TOP, 0, Root);
|
SetCoordinates(POSITION_LEFT, POSITION_TOP, 0, Root);
|
||||||
@ -965,10 +1012,11 @@ procedure TDesignerMainMenu.InsertFromTemplateClick(Sender: TObject);
|
|||||||
var
|
var
|
||||||
templatemenuitem: string;
|
templatemenuitem: string;
|
||||||
temp_designermenuitem: TDesignerMenuItem;
|
temp_designermenuitem: TDesignerMenuItem;
|
||||||
|
TemplateMenuForm: TTemplateMenuForm;
|
||||||
begin
|
begin
|
||||||
TemplateMenuFormCreateAction:=1;
|
TemplateMenuFormCreateAction:=1;
|
||||||
TemplateMenuForm:=TTemplateMenuForm.Create(self);
|
TemplateMenuForm:=TTemplateMenuForm.Create(nil);
|
||||||
|
try
|
||||||
if (TemplateMenuForm.ShowModal = mrOK) then
|
if (TemplateMenuForm.ShowModal = mrOK) then
|
||||||
begin
|
begin
|
||||||
|
|
||||||
@ -997,7 +1045,7 @@ begin
|
|||||||
temp_designermenuitem:=GetDesignerMenuItem(Root, SelectedDesignerMenuItem);
|
temp_designermenuitem:=GetDesignerMenuItem(Root, SelectedDesignerMenuItem);
|
||||||
case TemplateMenuForm.GetSelectedMenuTemplate of
|
case TemplateMenuForm.GetSelectedMenuTemplate of
|
||||||
1: Begin
|
1: Begin
|
||||||
// Change a caption of selected designermenuitem fo "File"
|
// Change a caption of selected designermenuitem to "File"
|
||||||
ChangeCaption (temp_designermenuitem, lisFile);
|
ChangeCaption (temp_designermenuitem, lisFile);
|
||||||
UpdateMenu(fMenu.Items, temp_designermenuitem, 1, 6);
|
UpdateMenu(fMenu.Items, temp_designermenuitem, 1, 6);
|
||||||
|
|
||||||
@ -1167,6 +1215,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
RealignDesigner;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
TemplateMenuForm.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1223,14 +1275,15 @@ procedure TDesignerMainMenu.SaveAsTemplateClick(Sender: TObject);
|
|||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
str_i, templatemenuitem: string;
|
str_i, templatemenuitem: string;
|
||||||
|
TemplateMenuForm: TTemplateMenuForm;
|
||||||
begin
|
begin
|
||||||
i:=1;
|
i:=1;
|
||||||
Str(i,str_i);
|
Str(i,str_i);
|
||||||
templatemenuitem:='menu_' + str_i;
|
templatemenuitem:='menu_' + str_i;
|
||||||
|
|
||||||
TemplateMenuFormCreateAction:=2;
|
TemplateMenuFormCreateAction:=2;
|
||||||
TemplateMenuForm:=TTemplateMenuForm.Create(self);
|
TemplateMenuForm:=TTemplateMenuForm.Create(nil);
|
||||||
|
try
|
||||||
if (TemplateMenuForm.ShowModal = mrOK) then
|
if (TemplateMenuForm.ShowModal = mrOK) then
|
||||||
begin
|
begin
|
||||||
while (XMLConfig.GetValue(templatemenuitem + '/Name/Value','does_not_exists') <> 'does_not_exists') do
|
while (XMLConfig.GetValue(templatemenuitem + '/Name/Value','does_not_exists') <> 'does_not_exists') do
|
||||||
@ -1244,6 +1297,9 @@ begin
|
|||||||
InvalidateFileStateCache;
|
InvalidateFileStateCache;
|
||||||
XMLConfig.Flush;
|
XMLConfig.Flush;
|
||||||
end;
|
end;
|
||||||
|
finally
|
||||||
|
TemplateMenuForm.Free;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1278,12 +1334,14 @@ procedure TDesignerMainMenu.DeleteFromTemplateClick(Sender: TObject);
|
|||||||
var
|
var
|
||||||
i,j: Integer;
|
i,j: Integer;
|
||||||
str_i, str_j, old_templatemenuitem, new_templatemenuitem: string;
|
str_i, str_j, old_templatemenuitem, new_templatemenuitem: string;
|
||||||
|
TemplateMenuForm: TTemplateMenuForm;
|
||||||
begin
|
begin
|
||||||
//SelectedDesignerMenuItem:=GetSelectedDesignerMenuItem(Root);
|
//SelectedDesignerMenuItem:=GetSelectedDesignerMenuItem(Root);
|
||||||
i:=1;
|
i:=1;
|
||||||
j:=1;
|
j:=1;
|
||||||
TemplateMenuFormCreateAction:=3;
|
TemplateMenuFormCreateAction:=3;
|
||||||
TemplateMenuForm:=TTemplateMenuForm.Create(self);
|
TemplateMenuForm:=TTemplateMenuForm.Create(nil);
|
||||||
|
try
|
||||||
if (TemplateMenuForm.ShowModal = mrOK) and (TemplateMenuForm.GetSelectedMenuTemplate > 0) then
|
if (TemplateMenuForm.ShowModal = mrOK) and (TemplateMenuForm.GetSelectedMenuTemplate > 0) then
|
||||||
begin
|
begin
|
||||||
i:=TemplateMenuForm.GetSelectedMenuTemplate;
|
i:=TemplateMenuForm.GetSelectedMenuTemplate;
|
||||||
@ -1339,6 +1397,9 @@ begin
|
|||||||
InvalidateFileStateCache;
|
InvalidateFileStateCache;
|
||||||
XMLConfig.Flush;
|
XMLConfig.Flush;
|
||||||
end;
|
end;
|
||||||
|
finally
|
||||||
|
TemplateMenuForm.Free;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDesignerMainMenu.ReplaceInTemplate(old_Item, new_Item: string);
|
procedure TDesignerMainMenu.ReplaceInTemplate(old_Item, new_Item: string);
|
||||||
@ -1370,42 +1431,30 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------------------------//
|
// --------------------------------------------------------------------------------------------------------------//
|
||||||
// Some property og some object has changed -> we need to know if caption of some menuitem has changed ----------//
|
// Some property of some object has changed -> we need to know if caption of some menuitem has changed ----------//
|
||||||
// --------------------------------------------------------------------------------------------------------------//
|
// --------------------------------------------------------------------------------------------------------------//
|
||||||
procedure TDesignerMainMenu.OnDesignerModified(Sender: TObject);
|
procedure TDesignerMainMenu.OnDesignerModified(Sender: TObject);
|
||||||
var
|
var
|
||||||
Selection: TPersistentSelectionList;
|
|
||||||
i: Integer;
|
i: Integer;
|
||||||
Instance: TPersistent;
|
Instance: TPersistent;
|
||||||
MenuItem: TMenuItem;
|
MenuItem: TMenuItem;
|
||||||
InvalidateNeeded: Boolean;
|
InvalidateNeeded: Boolean;
|
||||||
DesignerMenuItem: TDesignerMenuItem;
|
DesignerMenuItem: TDesignerMenuItem;
|
||||||
begin
|
begin
|
||||||
Selection := TPersistentSelectionList.Create;
|
for i := 0 to TPropertyEditor(Sender).PropCount - 1 do
|
||||||
GlobalDesignHook.GetSelection(Selection);
|
|
||||||
try
|
|
||||||
InvalidateNeeded:=false;
|
|
||||||
for i := Selection.Count - 1 downto 0 do
|
|
||||||
begin
|
begin
|
||||||
Instance := Selection[i];
|
Instance := TPropertyEditor(Sender).GetComponent(i);
|
||||||
if Instance is TMenuItem
|
if Instance is TMenuItem then begin
|
||||||
then begin
|
MenuItem := TMenuItem(Instance);
|
||||||
MenuItem:=TMenuItem(Instance);
|
DesignerMenuItem := FindDesignerMenuItem(MenuItem);
|
||||||
// ToDo
|
|
||||||
// how to get the Designer menu item?
|
|
||||||
DesignerMenuItem:=FindDesignerMenuItem(MenuItem);
|
|
||||||
//writeln('TDesignerMainMenu.OnDesignerModified A ',MenuItem.Name,' ',DesignerMenuItem<>nil,' ',MenuItem.Caption);
|
|
||||||
if DesignerMenuItem = nil then Continue;
|
if DesignerMenuItem = nil then Continue;
|
||||||
|
|
||||||
ChangeCaption(DesignerMenuItem, MenuItem.Caption);
|
ChangeCaption(DesignerMenuItem, MenuItem.Caption);
|
||||||
InvalidateNeeded := true;
|
InvalidateNeeded := True;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if InvalidateNeeded then
|
if InvalidateNeeded then
|
||||||
RealignDesigner;
|
RealignDesigner;
|
||||||
finally
|
|
||||||
Selection.Free;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDesignerMainMenu.OnComponentAdded(Sender: TObject);
|
procedure TDesignerMainMenu.OnComponentAdded(Sender: TObject);
|
||||||
@ -1442,7 +1491,7 @@ begin
|
|||||||
Result:=nil;
|
Result:=nil;
|
||||||
if (DMenuItem.ID = Ident) then
|
if (DMenuItem.ID = Ident) then
|
||||||
begin
|
begin
|
||||||
NewMI := TDesignerMenuItem.Create;
|
NewMI := TDesignerMenuItem.Create(nil); // it's better to move TMenuItem.Create here from UpdateMenu()
|
||||||
Str(temp_newitemcounter, temp_newitemcounterstring);
|
Str(temp_newitemcounter, temp_newitemcounterstring);
|
||||||
NewMI.Caption:='New Item' + temp_newitemcounterstring;
|
NewMI.Caption:='New Item' + temp_newitemcounterstring;
|
||||||
NewMI.Level:=DMenuItem.Level;
|
NewMI.Level:=DMenuItem.Level;
|
||||||
@ -1505,7 +1554,7 @@ begin
|
|||||||
TempMI:=nil;
|
TempMI:=nil;
|
||||||
if (DMenuItem.ID = Ident) then
|
if (DMenuItem.ID = Ident) then
|
||||||
begin
|
begin
|
||||||
NewMI := TDesignerMenuItem.Create;
|
NewMI := TDesignerMenuItem.Create(nil); // it's better to move TMenuItem.Create here from UpdateMenu()
|
||||||
Str(temp_newitemcounter,temp_newitemcounterstring);
|
Str(temp_newitemcounter,temp_newitemcounterstring);
|
||||||
NewMI.Caption:='New Item' + temp_newitemcounterstring;
|
NewMI.Caption:='New Item' + temp_newitemcounterstring;
|
||||||
NewMI.Level:=DMenuItem.Level;
|
NewMI.Level:=DMenuItem.Level;
|
||||||
@ -1550,7 +1599,7 @@ begin
|
|||||||
Result:=nil;
|
Result:=nil;
|
||||||
if ((DMenuItem.ID = Ident) and (DMenuItem.SubMenu = nil)) then
|
if ((DMenuItem.ID = Ident) and (DMenuItem.SubMenu = nil)) then
|
||||||
begin
|
begin
|
||||||
new_menuitem := TDesignerMenuItem.Create;
|
new_menuitem := TDesignerMenuItem.Create(nil); // it's better to move TMenuItem.Create here from UpdateMenu()
|
||||||
Str(temp_newitemcounter,temp_newitemcounterstring);
|
Str(temp_newitemcounter,temp_newitemcounterstring);
|
||||||
new_menuitem.Caption:='New Item' + temp_newitemcounterstring;
|
new_menuitem.Caption:='New Item' + temp_newitemcounterstring;
|
||||||
new_menuitem.Level:=DMenuItem.Level + 1;
|
new_menuitem.Level:=DMenuItem.Level + 1;
|
||||||
@ -1778,7 +1827,6 @@ function TDesignerMainMenu.FindDesignerMenuItem(AMenuItem: TMenuItem): TDesigner
|
|||||||
function FindRecursive(TheMenuItem: TMenuItem): TDesignerMenuItem;
|
function FindRecursive(TheMenuItem: TMenuItem): TDesignerMenuItem;
|
||||||
var
|
var
|
||||||
ParentDesignerMenuItem: TDesignerMenuItem;
|
ParentDesignerMenuItem: TDesignerMenuItem;
|
||||||
i: Integer;
|
|
||||||
begin
|
begin
|
||||||
Result := nil;
|
Result := nil;
|
||||||
if TheMenuItem = nil then
|
if TheMenuItem = nil then
|
||||||
@ -1807,12 +1855,8 @@ function TDesignerMainMenu.FindDesignerMenuItem(AMenuItem: TMenuItem): TDesigner
|
|||||||
end;
|
end;
|
||||||
if Result <> nil then
|
if Result <> nil then
|
||||||
begin
|
begin
|
||||||
i := TheMenuItem.MenuIndex;
|
while (Result <> nil) and (Result.RealMenuItem <> TheMenuItem) do
|
||||||
while (Result <> nil) and (i > 0) do
|
|
||||||
begin
|
|
||||||
Result := Result.NextItem;
|
Result := Result.NextItem;
|
||||||
dec(i);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1871,6 +1915,7 @@ begin
|
|||||||
if (index_sequence[Ind + 1] = -1) then
|
if (index_sequence[Ind + 1] = -1) then
|
||||||
begin
|
begin
|
||||||
temp_menuitem:=TMenuItem.Create(fMenu.Owner);
|
temp_menuitem:=TMenuItem.Create(fMenu.Owner);
|
||||||
|
DMenuItem.RealMenuItem := temp_menuitem;
|
||||||
temp_menuitem.Caption:=DMenuItem.Caption;
|
temp_menuitem.Caption:=DMenuItem.Caption;
|
||||||
|
|
||||||
// code from Mattias (one of mail he sent me)
|
// code from Mattias (one of mail he sent me)
|
||||||
@ -1878,7 +1923,6 @@ begin
|
|||||||
AMenuItem.Insert(index_sequence[Ind] + 1, temp_menuitem);
|
AMenuItem.Insert(index_sequence[Ind] + 1, temp_menuitem);
|
||||||
GetDesigner.PropertyEditorHook.PersistentAdded(temp_menuitem, true);
|
GetDesigner.PropertyEditorHook.PersistentAdded(temp_menuitem, true);
|
||||||
GetDesigner.Modified;
|
GetDesigner.Modified;
|
||||||
|
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
UpdateMenu(AMenuItem.Items[index_sequence[Ind]], DMenuItem, Ind + 1, TheAction);
|
UpdateMenu(AMenuItem.Items[index_sequence[Ind]], DMenuItem, Ind + 1, TheAction);
|
||||||
@ -1889,6 +1933,7 @@ begin
|
|||||||
if (index_sequence[Ind + 1] = -1) then
|
if (index_sequence[Ind + 1] = -1) then
|
||||||
begin
|
begin
|
||||||
temp_menuitem:=TMenuItem.Create(fMenu.Owner);
|
temp_menuitem:=TMenuItem.Create(fMenu.Owner);
|
||||||
|
DMenuItem.RealMenuItem := temp_menuitem;
|
||||||
temp_menuitem.Caption:=DMenuItem.Caption;
|
temp_menuitem.Caption:=DMenuItem.Caption;
|
||||||
|
|
||||||
// code from Mattias (one of mail he sent me)
|
// code from Mattias (one of mail he sent me)
|
||||||
@ -1906,6 +1951,7 @@ begin
|
|||||||
if (index_sequence[Ind + 1] = -1) then
|
if (index_sequence[Ind + 1] = -1) then
|
||||||
begin
|
begin
|
||||||
temp_menuitem:=TMenuItem.Create(fMenu.Owner);
|
temp_menuitem:=TMenuItem.Create(fMenu.Owner);
|
||||||
|
DMenuItem.RealMenuItem := temp_menuitem;
|
||||||
temp_menuitem.Caption:=DMenuItem.Caption;
|
temp_menuitem.Caption:=DMenuItem.Caption;
|
||||||
|
|
||||||
// code from Mattias (one of mail he sent me)
|
// code from Mattias (one of mail he sent me)
|
||||||
@ -2015,10 +2061,6 @@ begin
|
|||||||
Str(i,str_i);
|
Str(i,str_i);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Select the first menu on list and show it in "Template Preview"
|
|
||||||
if (TemplatesListBox.Items.Count > 0) then
|
|
||||||
TemplatesListBox.Selected[0]:=true;
|
|
||||||
|
|
||||||
case fAction of
|
case fAction of
|
||||||
1: begin
|
1: begin
|
||||||
// content of "Caption" is generated from LazarusIDEStrConsts
|
// content of "Caption" is generated from LazarusIDEStrConsts
|
||||||
@ -2042,6 +2084,11 @@ begin
|
|||||||
TemplateView('menu_1/subitem_', 0);
|
TemplateView('menu_1/subitem_', 0);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// Select the first menu on list and show it in "Template Preview"
|
||||||
|
if (TemplatesListBox.Items.Count > 0) then
|
||||||
|
TemplatesListBox.Selected[0]:=true;
|
||||||
|
|
||||||
ButtonPanel1.OKButton.OnClick := @OKBitBtnClick;
|
ButtonPanel1.OKButton.OnClick := @OKBitBtnClick;
|
||||||
ButtonPanel1.CancelButton.OnClick := @CancelBitBtnClick;
|
ButtonPanel1.CancelButton.OnClick := @CancelBitBtnClick;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user