mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-27 04:53:39 +02:00
fixed updating menu designer caption when editing in OI
git-svn-id: trunk@5166 -
This commit is contained in:
parent
a60b5f032e
commit
1ef103e7bf
@ -58,7 +58,7 @@ type
|
|||||||
public
|
public
|
||||||
constructor CreateWithAction(AOwner: TComponent; TheAction: Integer);
|
constructor CreateWithAction(AOwner: TComponent; TheAction: Integer);
|
||||||
procedure OkButtonClick(Sender: TObject);
|
procedure OkButtonClick(Sender: TObject);
|
||||||
procedure CancelButtonCLick(Sender: TObject);
|
procedure CancelButtonClick(Sender: TObject);
|
||||||
function GetSelectedMenuTemplate: Integer;
|
function GetSelectedMenuTemplate: Integer;
|
||||||
function GetDescription: string;
|
function GetDescription: string;
|
||||||
procedure TemplateView(templatemenuitem: string; default_template: Integer);
|
procedure TemplateView(templatemenuitem: string; default_template: Integer);
|
||||||
@ -163,6 +163,7 @@ type
|
|||||||
|
|
||||||
procedure HideDesignerMenuItem(DesignerMenuItem: PDesignerMenuItem);
|
procedure HideDesignerMenuItem(DesignerMenuItem: PDesignerMenuItem);
|
||||||
function GetDesignerMenuItem(DesignerMenuItem: PDesignerMenuItem; const Ident: string): PDesignerMenuItem;
|
function GetDesignerMenuItem(DesignerMenuItem: PDesignerMenuItem; const Ident: string): PDesignerMenuItem;
|
||||||
|
function FindDesignerMenuItem(AMenuItem: TMenuItem): PDesignerMenuItem;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -276,7 +277,7 @@ begin
|
|||||||
PopupMenuItem.OnClick:=@DeleteFromTemplateClick;
|
PopupMenuItem.OnClick:=@DeleteFromTemplateClick;
|
||||||
DesignerPopupMenu.Items.Add(PopupMenuItem);
|
DesignerPopupMenu.Items.Add(PopupMenuItem);
|
||||||
|
|
||||||
//Handle for renaming a caption in the OI for some menuitem to rename also a
|
//Handler for renaming a caption in the OI for some menuitem to rename also a
|
||||||
// designermenuitem
|
// designermenuitem
|
||||||
GlobalDesignHook.AddHandlerModified(@OnComponentModified);
|
GlobalDesignHook.AddHandlerModified(@OnComponentModified);
|
||||||
|
|
||||||
@ -1273,10 +1274,11 @@ begin
|
|||||||
MenuItem:=TMenuItem(Instance);
|
MenuItem:=TMenuItem(Instance);
|
||||||
// ToDo
|
// ToDo
|
||||||
// how to get the Designer menu item?
|
// how to get the Designer menu item?
|
||||||
DesignerMenuItem:=GetDesignerMenuItem(Root, MenuItem.Name);
|
DesignerMenuItem:=FindDesignerMenuItem(MenuItem);
|
||||||
|
//writeln('TDesignerMainMenu.OnComponentModified 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;
|
||||||
@ -1602,6 +1604,7 @@ function TDesignerMainMenu.ChangeCaption(DesignerMenuItem: PDesignerMenuItem;
|
|||||||
const newcaption: string): Integer;
|
const newcaption: string): Integer;
|
||||||
begin
|
begin
|
||||||
Result:=0;
|
Result:=0;
|
||||||
|
if DesignerMenuItem^.Caption=NewCaption then exit;
|
||||||
InitIndexSequence;
|
InitIndexSequence;
|
||||||
CreateIndexSequence(Root, DesignerMenuItem^.ID, 1);
|
CreateIndexSequence(Root, DesignerMenuItem^.ID, 1);
|
||||||
DesignerMenuItem^.Caption:=newcaption;
|
DesignerMenuItem^.Caption:=newcaption;
|
||||||
@ -1631,18 +1634,57 @@ function TDesignerMainMenu.GetDesignerMenuItem(
|
|||||||
DesignerMenuItem: PDesignerMenuItem; const Ident: string): PDesignerMenuItem;
|
DesignerMenuItem: PDesignerMenuItem; const Ident: string): PDesignerMenuItem;
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
|
if DesignerMenuItem=nil then exit;
|
||||||
if (AnsiCompareText(DesignerMenuItem^.ID,Ident)=0) then
|
if (AnsiCompareText(DesignerMenuItem^.ID,Ident)=0) then
|
||||||
Result:=DesignerMenuItem
|
Result:=DesignerMenuItem
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
if (DesignerMenuItem^.SubMenu <> nil) then
|
Result:=GetDesignerMenuItem(DesignerMenuItem^.SubMenu, Ident);
|
||||||
Result:=GetDesignerMenuItem(DesignerMenuItem^.SubMenu, Ident);
|
if Result<>nil then exit;
|
||||||
if (Result = nil) then
|
Result:=GetDesignerMenuItem(DesignerMenuItem^.NextItem, Ident);
|
||||||
if (DesignerMenuItem^.NextItem <> nil) then
|
|
||||||
Result:=GetDesignerMenuItem(DesignerMenuItem^.NextItem, Ident);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TDesignerMainMenu.FindDesignerMenuItem(AMenuItem: TMenuItem
|
||||||
|
): PDesignerMenuItem;
|
||||||
|
// search the corresponding designer menu item
|
||||||
|
|
||||||
|
function FindRecursive(TheMenuItem: TMenuItem): PDesignerMenuItem;
|
||||||
|
var
|
||||||
|
ParentDesignerMenuItem: PDesignerMenuItem;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
Result:=nil;
|
||||||
|
if TheMenuItem=nil then exit;
|
||||||
|
// find parent
|
||||||
|
if TheMenuItem.Parent=nil then begin
|
||||||
|
// this is TMenu.Items -> no corresponding
|
||||||
|
end else if TheMenuItem.Parent.Parent=nil then begin
|
||||||
|
// top level menu item
|
||||||
|
if (TheMenuItem.GetParentMenu=fMenu) then begin
|
||||||
|
// root item
|
||||||
|
Result:=Root;
|
||||||
|
end;
|
||||||
|
end else begin
|
||||||
|
// sub menu item
|
||||||
|
// -> search parent
|
||||||
|
ParentDesignerMenuItem:=FindRecursive(TheMenuItem.Parent);
|
||||||
|
if ParentDesignerMenuItem<>nil then
|
||||||
|
Result:=ParentDesignerMenuItem^.SubMenu;
|
||||||
|
end;
|
||||||
|
if Result<>nil then begin
|
||||||
|
i:=TheMenuItem.MenuIndex;
|
||||||
|
while (Result<>nil) and (i>0) do begin
|
||||||
|
Result:=Result^.NextItem;
|
||||||
|
dec(i);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=FindRecursive(AMenuItem);
|
||||||
|
end;
|
||||||
|
|
||||||
// ------------------------------------------------
|
// ------------------------------------------------
|
||||||
// ------------------------------------------------
|
// ------------------------------------------------
|
||||||
// Procedures for updating the Menu of the Designer
|
// Procedures for updating the Menu of the Designer
|
||||||
|
@ -2273,7 +2273,7 @@ resourcestring
|
|||||||
lisMenuEditorInsertNewItemBefore = 'Insert New Item (before)';
|
lisMenuEditorInsertNewItemBefore = 'Insert New Item (before)';
|
||||||
lisMenuEditorDeleteItem = 'Delete Item';
|
lisMenuEditorDeleteItem = 'Delete Item';
|
||||||
lisMenuEditorCreateSubMenu = 'Create Submenu';
|
lisMenuEditorCreateSubMenu = 'Create Submenu';
|
||||||
lisMenuEditorHandleOnClickEvent = 'Handle OnCLick Event';
|
lisMenuEditorHandleOnClickEvent = 'Handle OnClick Event';
|
||||||
lisMenuEditorMoveUp = 'Move Up(left)';
|
lisMenuEditorMoveUp = 'Move Up(left)';
|
||||||
lisMenuEditorMoveDown = 'Move Up(right)';
|
lisMenuEditorMoveDown = 'Move Up(right)';
|
||||||
lisMenuEditorInsertFromTemplate = 'Insert From Template...';
|
lisMenuEditorInsertFromTemplate = 'Insert From Template...';
|
||||||
|
@ -703,6 +703,7 @@ begin
|
|||||||
FCaption := AValue;
|
FCaption := AValue;
|
||||||
if HandleAllocated then
|
if HandleAllocated then
|
||||||
SendMsgToInterface(LM_SetLabel, Self, PChar(AValue));
|
SendMsgToInterface(LM_SetLabel, Self, PChar(AValue));
|
||||||
|
OwnerFormDesignerModified(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -723,6 +724,7 @@ begin
|
|||||||
and not (csReading in ComponentState)
|
and not (csReading in ComponentState)
|
||||||
and HandleAllocated
|
and HandleAllocated
|
||||||
then MenuItemSetCheck(Self);
|
then MenuItemSetCheck(Self);
|
||||||
|
OwnerFormDesignerModified(Self);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1078,6 +1080,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.49 2004/02/04 17:06:26 mattias
|
||||||
|
fixed updating menu designer caption when editing in OI
|
||||||
|
|
||||||
Revision 1.48 2004/02/04 13:55:08 mattias
|
Revision 1.48 2004/02/04 13:55:08 mattias
|
||||||
implemented generic function to hide TComponents without page in designer
|
implemented generic function to hide TComponents without page in designer
|
||||||
|
|
||||||
@ -1253,6 +1258,9 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.49 2004/02/04 17:06:26 mattias
|
||||||
|
fixed updating menu designer caption when editing in OI
|
||||||
|
|
||||||
Revision 1.48 2004/02/04 13:55:08 mattias
|
Revision 1.48 2004/02/04 13:55:08 mattias
|
||||||
implemented generic function to hide TComponents without page in designer
|
implemented generic function to hide TComponents without page in designer
|
||||||
|
|
||||||
|
@ -259,8 +259,12 @@ end;
|
|||||||
|
|
||||||
procedure OwnerFormDesignerModified(AComponent: TComponent);
|
procedure OwnerFormDesignerModified(AComponent: TComponent);
|
||||||
begin
|
begin
|
||||||
if OwnerFormDesignerModifiedProc<>nil then
|
if ([csDesigning,csLoading,csDestroying]*AComponent.ComponentState
|
||||||
OwnerFormDesignerModifiedProc(AComponent);
|
=[csDesigning]
|
||||||
|
then begin
|
||||||
|
if OwnerFormDesignerModifiedProc<>nil then
|
||||||
|
OwnerFormDesignerModifiedProc(AComponent);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function OffSetRect(var ARect: TRect; dx,dy: Integer): Boolean;
|
function OffSetRect(var ARect: TRect; dx,dy: Integer): Boolean;
|
||||||
|
25
lcl/menus.pp
25
lcl/menus.pp
@ -145,23 +145,23 @@ type
|
|||||||
procedure TurnSiblingsOff;
|
procedure TurnSiblingsOff;
|
||||||
procedure DoActionChange(Sender: TObject);
|
procedure DoActionChange(Sender: TObject);
|
||||||
protected
|
protected
|
||||||
|
function GetAction: TBasicAction;
|
||||||
|
function GetActionLinkClass: TMenuActionLinkClass; dynamic;
|
||||||
|
function GetHandle: HMenu;
|
||||||
|
procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); dynamic;
|
||||||
procedure CreateHandle; virtual;
|
procedure CreateHandle; virtual;
|
||||||
procedure DestroyHandle; virtual;
|
procedure DestroyHandle; virtual;
|
||||||
procedure DoClicked(var msg); message LM_ACTIVATE;
|
procedure DoClicked(var msg); message LM_ACTIVATE;
|
||||||
function GetHandle: HMenu;
|
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
|
||||||
Procedure SetImageIndex(value : Integer);
|
procedure InitiateActions;
|
||||||
|
procedure MenuChanged(Rebuild : Boolean);
|
||||||
|
procedure SetAction(Value: TBasicAction);
|
||||||
|
procedure SetChildOrder(Child: TComponent; Order: Integer); override;
|
||||||
procedure SetGroupIndex(AValue: Byte);
|
procedure SetGroupIndex(AValue: Byte);
|
||||||
|
Procedure SetImageIndex(value : Integer);
|
||||||
|
procedure SetParentComponent(AValue : TComponent); override;
|
||||||
procedure SetShortCut(const AValue : TShortCut);
|
procedure SetShortCut(const AValue : TShortCut);
|
||||||
procedure SetVisible(AValue: Boolean);
|
procedure SetVisible(AValue: Boolean);
|
||||||
procedure MenuChanged(Rebuild : Boolean);
|
|
||||||
procedure SetChildOrder(Child: TComponent; Order: Integer); override;
|
|
||||||
procedure SetParentComponent(AValue : TComponent); override;
|
|
||||||
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
|
|
||||||
function GetAction: TBasicAction;
|
|
||||||
procedure SetAction(Value: TBasicAction);
|
|
||||||
procedure InitiateActions;
|
|
||||||
procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); dynamic;
|
|
||||||
function GetActionLinkClass: TMenuActionLinkClass; dynamic;
|
|
||||||
protected
|
protected
|
||||||
property ActionLink: TMenuActionLink read FActionLink write FActionLink;
|
property ActionLink: TMenuActionLink read FActionLink write FActionLink;
|
||||||
public
|
public
|
||||||
@ -391,6 +391,9 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.61 2004/02/04 17:06:26 mattias
|
||||||
|
fixed updating menu designer caption when editing in OI
|
||||||
|
|
||||||
Revision 1.60 2004/02/04 13:40:19 mattias
|
Revision 1.60 2004/02/04 13:40:19 mattias
|
||||||
ShortCutToText now deletes any modifier
|
ShortCutToText now deletes any modifier
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user