mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-27 11:00:37 +02:00
Designer: cleanup for MenuEditor
git-svn-id: trunk@37661 -
This commit is contained in:
parent
d73084acb7
commit
3b50e92d50
@ -11,14 +11,14 @@ object TemplateMenuForm: TTemplateMenuForm
|
||||
OnCreate = FormCreate
|
||||
OnResize = FormResize
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '0.9.27'
|
||||
LCLVersion = '1.1'
|
||||
object Label_template_description: TLabel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = Owner
|
||||
Left = 6
|
||||
Height = 14
|
||||
Height = 15
|
||||
Top = 6
|
||||
Width = 132
|
||||
Width = 139
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'Label_template_description'
|
||||
@ -28,18 +28,26 @@ object TemplateMenuForm: TTemplateMenuForm
|
||||
AnchorSideLeft.Control = ListBoxView
|
||||
AnchorSideTop.Control = Owner
|
||||
Left = 262
|
||||
Height = 14
|
||||
Height = 15
|
||||
Top = 6
|
||||
Width = 102
|
||||
Width = 107
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'Label_template_view'
|
||||
ParentColor = False
|
||||
end
|
||||
object ButtonPanel1: TButtonPanel
|
||||
Left = 6
|
||||
Height = 26
|
||||
Top = 212
|
||||
Height = 33
|
||||
Top = 205
|
||||
Width = 508
|
||||
OKButton.Name = 'OKButton'
|
||||
OKButton.DefaultCaption = True
|
||||
HelpButton.Name = 'HelpButton'
|
||||
HelpButton.DefaultCaption = True
|
||||
CloseButton.Name = 'CloseButton'
|
||||
CloseButton.DefaultCaption = True
|
||||
CancelButton.Name = 'CancelButton'
|
||||
CancelButton.DefaultCaption = True
|
||||
TabOrder = 3
|
||||
ShowButtons = [pbOK, pbCancel]
|
||||
ShowBevel = False
|
||||
@ -51,8 +59,8 @@ object TemplateMenuForm: TTemplateMenuForm
|
||||
AnchorSideBottom.Control = ListBoxView
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 180
|
||||
Top = 26
|
||||
Height = 172
|
||||
Top = 27
|
||||
Width = 244
|
||||
Anchors = [akTop, akLeft, akBottom]
|
||||
BorderSpacing.Left = 6
|
||||
@ -70,8 +78,8 @@ object TemplateMenuForm: TTemplateMenuForm
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = ButtonPanel1
|
||||
Left = 262
|
||||
Height = 180
|
||||
Top = 26
|
||||
Height = 172
|
||||
Top = 27
|
||||
Width = 252
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Left = 6
|
||||
@ -86,8 +94,8 @@ object TemplateMenuForm: TTemplateMenuForm
|
||||
AnchorSideRight.Control = TemplatesListBox
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 23
|
||||
Top = 212
|
||||
Height = 24
|
||||
Top = 205
|
||||
Width = 244
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 6
|
||||
|
@ -123,7 +123,7 @@ type
|
||||
constructor CreateWithMenu(AOwner: TComponent; AMenu: TMenu);
|
||||
destructor Destroy; override;
|
||||
|
||||
// Properties for accesing private variables
|
||||
// Properties for accesing private variables
|
||||
property Root: TDesignerMenuItem read FRoot write SetRoot;
|
||||
property Panel: TPanel read FPanel write FPanel;
|
||||
property DesignerMenuItemIdent: Integer read FDesignerMenuItemIdent write FDesignerMenuItemIdent;
|
||||
@ -183,7 +183,7 @@ type
|
||||
function GetDesignerMenuItem(DMenuItem: TDesignerMenuItem; const Ident: string): TDesignerMenuItem;
|
||||
function FindDesignerMenuItem(AMenuItem: TMenuItem): TDesignerMenuItem;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
@ -202,7 +202,7 @@ const
|
||||
// Name of the file where menu templates are stored
|
||||
MenuTemplatesFile='menutemplates.xml';
|
||||
|
||||
var
|
||||
var
|
||||
TemplateMenuFormCreateAction: Integer;
|
||||
XMLConfig: TXMLConfig = nil;
|
||||
|
||||
@ -339,8 +339,7 @@ begin
|
||||
PopupMenuItem.OnClick := @DeleteFromTemplateClick;
|
||||
FDesignerPopupMenu.Items.Add(PopupMenuItem);
|
||||
|
||||
//Handler for renaming a caption in the OI for some menuitem to rename also a
|
||||
// designermenuitem
|
||||
//Handler for renaming a caption in OI for some menuitem to rename also designermenuitem
|
||||
GlobalDesignHook.AddHandlerModified(@OnDesignerModified);
|
||||
//GlobalDesignHook.AddHandlerPersistentAdded(@OnComponentAdded);
|
||||
GlobalDesignHook.AddHandlerPersistentDeleting(@PersistentDeleting);
|
||||
@ -563,12 +562,9 @@ begin
|
||||
end;
|
||||
end;
|
||||
if (DMenuItem.Selected) or ((DMenuItem.Level = 1) and (fMenu is TMainMenu)) then
|
||||
begin
|
||||
Bevelouter:=bvraised;
|
||||
end else
|
||||
begin
|
||||
Bevelouter:=bvraised
|
||||
else
|
||||
Bevelouter:=bvnone;
|
||||
end;
|
||||
end;
|
||||
|
||||
DMenuItem.CaptionLabel.Caption:=DMenuItem.Caption;
|
||||
@ -606,12 +602,9 @@ begin
|
||||
if (DMenuItem.SubMenu <> nil) then
|
||||
begin
|
||||
if (DMenuItem.Level = 1) and (fMenu is TMainMenu) then
|
||||
begin
|
||||
DMenuItem.SubMenuArrow.ArrowType:=atdown;
|
||||
end else
|
||||
begin
|
||||
DMenuItem.SubMenuArrow.ArrowType:=atdown
|
||||
else
|
||||
DMenuItem.SubMenuArrow.ArrowType:=atright;
|
||||
end;
|
||||
DMenuItem.SubMenuArrow.Left:=DMenuItem.SelfPanel.Width - DMenuItem.SubMenuArrow.Width - 1;
|
||||
DMenuItem.SubMenuArrow.Top:=(DMenuItem.SelfPanel.Height - DMenuItem.SubMenuArrow.Height) div 2;
|
||||
DMenuItem.SubMenuArrow.Visible:=true;
|
||||
@ -1853,11 +1846,8 @@ function TDesignerMainMenu.FindDesignerMenuItem(AMenuItem: TMenuItem): TDesigner
|
||||
if ParentDesignerMenuItem <> nil then
|
||||
Result := ParentDesignerMenuItem.SubMenu;
|
||||
end;
|
||||
if Result <> nil then
|
||||
begin
|
||||
while (Result <> nil) and (Result.RealMenuItem <> TheMenuItem) do
|
||||
Result := Result.NextItem;
|
||||
end;
|
||||
while (Result <> nil) and (Result.RealMenuItem <> TheMenuItem) do
|
||||
Result := Result.NextItem;
|
||||
end;
|
||||
|
||||
begin
|
||||
@ -1893,7 +1883,7 @@ begin
|
||||
else
|
||||
index_sequence[Ind + 1]:=-1;
|
||||
end;
|
||||
if not (Result) then
|
||||
if not Result then
|
||||
if (DMenuItem.NextItem <> nil) then
|
||||
if (CreateIndexSequence(DMenuItem.NextItem,Ident,Ind)) then
|
||||
Result:=true;
|
||||
@ -2108,14 +2098,12 @@ var
|
||||
i: Integer;
|
||||
begin
|
||||
for i:=0 to TemplatesListBox.Items.Count-1 do
|
||||
if TemplatesListBox.Selected[i] then SelectedMenuTemplate:=i + 1;
|
||||
if (fAction = 2) and (Edit_template_description.Text <> '') then
|
||||
begin
|
||||
Description:=Edit_template_description.Text;
|
||||
end else
|
||||
begin
|
||||
if (fAction = 2) then
|
||||
// content of "Description" is generated from LazarusIDEStrConsts
|
||||
if TemplatesListBox.Selected[i] then
|
||||
SelectedMenuTemplate:=i + 1;
|
||||
if (fAction = 2) then begin
|
||||
if Edit_template_description.Text <> '' then
|
||||
Description:=Edit_template_description.Text
|
||||
else // content of "Description" is generated from LazarusIDEStrConsts
|
||||
Description:=lisMenuEditorNewTemplateDescription;
|
||||
end;
|
||||
end;
|
||||
|
@ -1,7 +1,7 @@
|
||||
object MainMenuEditorForm: TMainMenuEditorForm
|
||||
Left = 397
|
||||
Left = 395
|
||||
Height = 220
|
||||
Top = 505
|
||||
Top = 480
|
||||
Width = 600
|
||||
Caption = 'MainMenuEditorForm'
|
||||
ClientHeight = 220
|
||||
@ -11,7 +11,7 @@ object MainMenuEditorForm: TMainMenuEditorForm
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '0.9.31'
|
||||
LCLVersion = '1.1'
|
||||
object MenuScrollBox: TScrollBox
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = Owner
|
||||
@ -56,9 +56,9 @@ object MainMenuEditorForm: TMainMenuEditorForm
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = List_menus
|
||||
Left = 8
|
||||
Height = 16
|
||||
Top = 10
|
||||
Width = 70
|
||||
Height = 15
|
||||
Top = 11
|
||||
Width = 65
|
||||
Anchors = [akLeft, akBottom]
|
||||
Caption = 'Label_menus'
|
||||
ParentColor = False
|
||||
|
@ -60,7 +60,6 @@ type
|
||||
FDesigner: TComponentEditorDesigner;
|
||||
procedure OnPersistentDeleting(APersistent: TPersistent);
|
||||
procedure OnPersistentAdded(APersistent: TPersistent; Select: boolean);
|
||||
procedure CreateDesignerMenu;
|
||||
procedure UpdateListOfMenus;
|
||||
public
|
||||
procedure SetMenu(NewMenu: TMenu);
|
||||
@ -68,8 +67,8 @@ type
|
||||
write FDesignerMainMenu;
|
||||
end;
|
||||
|
||||
{ TMenuComponentEditor
|
||||
The default component editor for TMenu. }
|
||||
{ TMenuComponentEditor -- The default component editor for TMenu. }
|
||||
|
||||
TMainMenuComponentEditor = class(TComponentEditor)
|
||||
private
|
||||
FDesigner: TComponentEditorDesigner;
|
||||
@ -85,8 +84,7 @@ type
|
||||
|
||||
|
||||
{ TMenuItemsPropertyEditor
|
||||
PropertyEditor editor for the TMenu.Items properties.
|
||||
Brings up the menu editor. }
|
||||
PropertyEditor editor for the TMenu.Items properties. Brings up the menu editor. }
|
||||
|
||||
TMenuItemsPropertyEditor = class(TClassPropertyEditor)
|
||||
public
|
||||
@ -126,8 +124,7 @@ begin
|
||||
GlobalDesignHook.AddHandlerPersistentAdded(@OnPersistentAdded);
|
||||
end;
|
||||
|
||||
procedure TMainMenuEditorForm.FormClose(Sender: TObject;
|
||||
var CloseAction: TCloseAction);
|
||||
procedure TMainMenuEditorForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
begin
|
||||
SetMenu(nil);
|
||||
end;
|
||||
@ -144,9 +141,7 @@ var
|
||||
CurComponent: TComponent;
|
||||
begin
|
||||
for i := 0 to List_menus.Items.Count - 1 do
|
||||
begin
|
||||
if List_menus.Selected[i] then
|
||||
begin
|
||||
for j := 0 to FDesigner.Form.ComponentCount - 1 do
|
||||
begin
|
||||
CurComponent:=FDesigner.Form.Components[j];
|
||||
@ -156,8 +151,6 @@ begin
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainMenuEditorForm.OnPersistentDeleting(APersistent: TPersistent);
|
||||
@ -172,7 +165,8 @@ begin
|
||||
i := List_menus.Items.IndexOf(AComponent.Name);
|
||||
if i >= 0 then List_menus.Items.Delete(i);
|
||||
|
||||
if AComponent = FMenu then SetMenu(nil);
|
||||
if AComponent = FMenu then
|
||||
SetMenu(nil);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -184,19 +178,6 @@ begin
|
||||
UpdateListOfMenus;
|
||||
end;
|
||||
|
||||
procedure TMainMenuEditorForm.CreateDesignerMenu;
|
||||
begin
|
||||
DesignerMainMenu := TDesignerMainMenu.CreateWithMenu(Self, FMenu);
|
||||
with DesignerMainMenu do
|
||||
begin
|
||||
Parent := Self;
|
||||
ParentCanvas := Canvas;
|
||||
LoadMainMenu;
|
||||
SetCoordinates(10, 10, 0, DesignerMainMenu.Root);
|
||||
end;
|
||||
DesignerMainMenu.Panel := Panel;
|
||||
end;
|
||||
|
||||
procedure TMainMenuEditorForm.UpdateListOfMenus;
|
||||
var
|
||||
i: Integer;
|
||||
@ -211,38 +192,37 @@ begin
|
||||
CurComponent:=FDesigner.Form.Components[i];
|
||||
//debugln('TMainMenuEditorForm.UpdateListOfMenus A ',dbgsName(CurComponent));
|
||||
if (CurComponent is TMainMenu) or (CurComponent is TPopupMenu) then
|
||||
begin
|
||||
List_menus.Items.Add(CurComponent.Name);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
List_menus.Items.EndUpdate;
|
||||
|
||||
if FMenu <> nil then
|
||||
begin
|
||||
for i := 0 to List_menus.Items.Count - 1 do
|
||||
begin
|
||||
if (FMenu.Name = List_menus.Items[i]) then
|
||||
begin
|
||||
List_menus.Selected[i] := True;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if (FMenu.Name = List_menus.Items[i]) then
|
||||
List_menus.Selected[i] := True;
|
||||
end;
|
||||
|
||||
procedure TMainMenuEditorForm.SetMenu(NewMenu: TMenu);
|
||||
begin
|
||||
if NewMenu <> FMenu then
|
||||
begin
|
||||
DesignerMainMenu.Free;
|
||||
DesignerMainMenu := nil;
|
||||
FreeAndNil(FDesignerMainMenu);
|
||||
FMenu := NewMenu;
|
||||
FDesigner := FindRootDesigner(FMenu) as TComponentEditorDesigner;
|
||||
UpdateListOfMenus;
|
||||
if FMenu <> nil then
|
||||
begin
|
||||
CreateDesignerMenu;
|
||||
DesignerMainMenu.RealignDesigner;
|
||||
FDesignerMainMenu := TDesignerMainMenu.CreateWithMenu(Self, FMenu);
|
||||
with FDesignerMainMenu do
|
||||
begin
|
||||
Parent := Self;
|
||||
ParentCanvas := Canvas;
|
||||
LoadMainMenu;
|
||||
SetCoordinates(10, 10, 0, FDesignerMainMenu.Root);
|
||||
end;
|
||||
FDesignerMainMenu.Panel := Panel;
|
||||
FDesignerMainMenu.RealignDesigner;
|
||||
end
|
||||
else
|
||||
Close;
|
||||
|
Loading…
Reference in New Issue
Block a user