fixed updating menu designer caption when editing in OI

git-svn-id: trunk@5166 -
This commit is contained in:
mattias 2004-02-04 17:06:26 +00:00
parent a60b5f032e
commit 1ef103e7bf
5 changed files with 80 additions and 23 deletions

View File

@ -58,7 +58,7 @@ type
public
constructor CreateWithAction(AOwner: TComponent; TheAction: Integer);
procedure OkButtonClick(Sender: TObject);
procedure CancelButtonCLick(Sender: TObject);
procedure CancelButtonClick(Sender: TObject);
function GetSelectedMenuTemplate: Integer;
function GetDescription: string;
procedure TemplateView(templatemenuitem: string; default_template: Integer);
@ -163,6 +163,7 @@ type
procedure HideDesignerMenuItem(DesignerMenuItem: PDesignerMenuItem);
function GetDesignerMenuItem(DesignerMenuItem: PDesignerMenuItem; const Ident: string): PDesignerMenuItem;
function FindDesignerMenuItem(AMenuItem: TMenuItem): PDesignerMenuItem;
end;
@ -276,7 +277,7 @@ begin
PopupMenuItem.OnClick:=@DeleteFromTemplateClick;
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
GlobalDesignHook.AddHandlerModified(@OnComponentModified);
@ -1273,10 +1274,11 @@ begin
MenuItem:=TMenuItem(Instance);
// ToDo
// 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;
ChangeCaption(DesignerMenuItem, MenuItem. Caption);
ChangeCaption(DesignerMenuItem, MenuItem.Caption);
InvalidateNeeded := true;
end;
end;
@ -1602,6 +1604,7 @@ function TDesignerMainMenu.ChangeCaption(DesignerMenuItem: PDesignerMenuItem;
const newcaption: string): Integer;
begin
Result:=0;
if DesignerMenuItem^.Caption=NewCaption then exit;
InitIndexSequence;
CreateIndexSequence(Root, DesignerMenuItem^.ID, 1);
DesignerMenuItem^.Caption:=newcaption;
@ -1631,18 +1634,57 @@ function TDesignerMainMenu.GetDesignerMenuItem(
DesignerMenuItem: PDesignerMenuItem; const Ident: string): PDesignerMenuItem;
begin
Result:=nil;
if DesignerMenuItem=nil then exit;
if (AnsiCompareText(DesignerMenuItem^.ID,Ident)=0) then
Result:=DesignerMenuItem
else
begin
if (DesignerMenuItem^.SubMenu <> nil) then
Result:=GetDesignerMenuItem(DesignerMenuItem^.SubMenu, Ident);
if (Result = nil) then
if (DesignerMenuItem^.NextItem <> nil) then
Result:=GetDesignerMenuItem(DesignerMenuItem^.NextItem, Ident);
Result:=GetDesignerMenuItem(DesignerMenuItem^.SubMenu, Ident);
if Result<>nil then exit;
Result:=GetDesignerMenuItem(DesignerMenuItem^.NextItem, Ident);
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

View File

@ -2273,7 +2273,7 @@ resourcestring
lisMenuEditorInsertNewItemBefore = 'Insert New Item (before)';
lisMenuEditorDeleteItem = 'Delete Item';
lisMenuEditorCreateSubMenu = 'Create Submenu';
lisMenuEditorHandleOnClickEvent = 'Handle OnCLick Event';
lisMenuEditorHandleOnClickEvent = 'Handle OnClick Event';
lisMenuEditorMoveUp = 'Move Up(left)';
lisMenuEditorMoveDown = 'Move Up(right)';
lisMenuEditorInsertFromTemplate = 'Insert From Template...';

View File

@ -703,6 +703,7 @@ begin
FCaption := AValue;
if HandleAllocated then
SendMsgToInterface(LM_SetLabel, Self, PChar(AValue));
OwnerFormDesignerModified(Self);
end;
{------------------------------------------------------------------------------
@ -723,6 +724,7 @@ begin
and not (csReading in ComponentState)
and HandleAllocated
then MenuItemSetCheck(Self);
OwnerFormDesignerModified(Self);
end;
end;
@ -1078,6 +1080,9 @@ end;
{ =============================================================================
$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
implemented generic function to hide TComponents without page in designer
@ -1253,6 +1258,9 @@ end;
$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
implemented generic function to hide TComponents without page in designer

View File

@ -259,8 +259,12 @@ end;
procedure OwnerFormDesignerModified(AComponent: TComponent);
begin
if OwnerFormDesignerModifiedProc<>nil then
OwnerFormDesignerModifiedProc(AComponent);
if ([csDesigning,csLoading,csDestroying]*AComponent.ComponentState
=[csDesigning]
then begin
if OwnerFormDesignerModifiedProc<>nil then
OwnerFormDesignerModifiedProc(AComponent);
end;
end;
function OffSetRect(var ARect: TRect; dx,dy: Integer): Boolean;

View File

@ -145,23 +145,23 @@ type
procedure TurnSiblingsOff;
procedure DoActionChange(Sender: TObject);
protected
function GetAction: TBasicAction;
function GetActionLinkClass: TMenuActionLinkClass; dynamic;
function GetHandle: HMenu;
procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); dynamic;
procedure CreateHandle; virtual;
procedure DestroyHandle; virtual;
procedure DoClicked(var msg); message LM_ACTIVATE;
function GetHandle: HMenu;
Procedure SetImageIndex(value : Integer);
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
procedure InitiateActions;
procedure MenuChanged(Rebuild : Boolean);
procedure SetAction(Value: TBasicAction);
procedure SetChildOrder(Child: TComponent; Order: Integer); override;
procedure SetGroupIndex(AValue: Byte);
Procedure SetImageIndex(value : Integer);
procedure SetParentComponent(AValue : TComponent); override;
procedure SetShortCut(const AValue : TShortCut);
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
property ActionLink: TMenuActionLink read FActionLink write FActionLink;
public
@ -391,6 +391,9 @@ end.
{
$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
ShortCutToText now deletes any modifier