+ added / fixed streaming functions for TMenu & TMenuItem, stoppok

git-svn-id: trunk@1716 -
This commit is contained in:
lazarus 2002-05-30 21:33:10 +00:00
parent 6dd3644e4d
commit c587c7186b
3 changed files with 68 additions and 10 deletions

View File

@ -94,8 +94,8 @@ end;
{------------------------------------------------------------------------------
Function: TMenu.GetChildren
Params: proc
root
Params: proc - procedure which has to be called for every item
root - root component
Returns: nothing
Helper function for streaming.
@ -105,7 +105,8 @@ var
i : integer;
begin
for i := 0 to FItems.Count - 1
do Proc (FItems[i]);
do if FItems[i].Owner = Root
then Proc(TComponent (FItems [i]));
end;
{------------------------------------------------------------------------------
@ -150,6 +151,9 @@ end;
{ =============================================================================
$Log$
Revision 1.10 2002/05/30 21:33:10 lazarus
+ added / fixed streaming functions for TMenu & TMenuItem, stoppok
Revision 1.9 2002/05/19 08:27:43 lazarus
+ added helper functions to enabled streaming of TMenu /TMenuItem
stoppok

View File

@ -39,7 +39,10 @@ end;
------------------------------------------------------------------------------}
constructor TMenuItem.Create(AOwner: TComponent);
begin
if not assigned (aOwner) then writeln ('**SH: Warn: creating MenuItem with Owner = nil');
Inherited Create(AOwner);
FCompStyle := csMenuItem;
FHandle := 0;
FItems := nil;
@ -132,6 +135,25 @@ begin
FOnClick(Self);
end;
{------------------------------------------------------------------------------
Function: TMenuItem.GetChildren
Params: Proc - proc to be called for each child
Root - root component
Returns: nothing
For each item call "proc"
------------------------------------------------------------------------------}
procedure TMenuItem.GetChildren(Proc: TGetChildProc; Root: TComponent);
var
i : Integer;
Begin
if not assigned (FItems) then exit;
for i := 0 to FItems.Count - 1
do if TComponent (FItems[i]).Owner = Root
then Proc(TComponent (FItems [i]));
end;
{------------------------------------------------------------------------------
Function: TMenuItem.GetCount
Params: none
@ -226,6 +248,18 @@ begin
if not HandleAllocated then CreateHandle;
end;
{------------------------------------------------------------------------------
Method: TMenuItem.HasParent
Params:
Returns: True - the item has a parent responsible for streaming
------------------------------------------------------------------------------}
function TMenuItem.HasParent : Boolean;
begin
Result := assigned (FParent);
end;
{------------------------------------------------------------------------------
Method: TMenuItem.Insert
Params: Index: Location of the menuitem to insert
@ -277,6 +311,12 @@ end;
Procedure TMenuItem.MenuChanged(Rebuild : Boolean);
Begin
//Use send message to re-create the menu if REBUILD is true.
//send a message to inform the interface that we need to destroy and recreate this control
if not HandleAllocated then Exit;
if FHandle <> 0 then
Begin
// InterfaceObject.IntSendMessage3(LM_RECREATEWND, Self, nil);
end;
end;
{------------------------------------------------------------------------------
@ -376,13 +416,16 @@ begin
if assigned (FParent) and (FParent <> Value)
then TMenuItem (FParent).Remove (self);
if (Value is TMenu)
then TMenu (value).Items.Add (self)
else if (Value is TMenuItem)
then TMenuItem (value).Add (self)
else
raise Exception.Create ('TMenuItem.SetParentComponent: suggestet parent not of type TMenu or TMenuItem');
if assigned (value) then
begin
if (Value is TMenu)
then TMenu (value).Items.Add (self)
else if (Value is TMenuItem)
then TMenuItem (value).Add (self)
else
raise Exception.Create ('TMenuItem.SetParentComponent: suggestet parent not of type TMenu or TMenuItem');
end;
end;
@ -449,6 +492,9 @@ end;
{ =============================================================================
$Log$
Revision 1.14 2002/05/30 21:33:10 lazarus
+ added / fixed streaming functions for TMenu & TMenuItem, stoppok
Revision 1.13 2002/05/19 08:27:43 lazarus
+ added helper functions to enabled streaming of TMenu /TMenuItem
stoppok
@ -516,6 +562,9 @@ end;
$Log$
Revision 1.14 2002/05/30 21:33:10 lazarus
+ added / fixed streaming functions for TMenu & TMenuItem, stoppok
Revision 1.13 2002/05/19 08:27:43 lazarus
+ added helper functions to enabled streaming of TMenu /TMenuItem
stoppok

View File

@ -89,6 +89,7 @@ type
procedure SetVisible(Value: Boolean);
procedure MenuChanged(Rebuild : Boolean);
procedure SetParentComponent(Value : TComponent); override;
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
public
FCompStyle : LongInt;
procedure Add(Item: TMenuItem);
@ -98,6 +99,7 @@ type
function GetParentMenu: TMenu;
function HandleAllocated : Boolean;
procedure HandleNeeded;
function HasParent : Boolean; override;
function IndexOf(Item: TMenuItem): Integer;
procedure Insert(Index: Integer; Item: TMenuItem);
procedure Remove(Item: TMenuItem);
@ -213,6 +215,9 @@ end.
{
$Log$
Revision 1.13 2002/05/30 21:33:10 lazarus
+ added / fixed streaming functions for TMenu & TMenuItem, stoppok
Revision 1.12 2002/05/19 08:28:50 lazarus
+ added helper functions to enable streaming of TMenu / TMenuItem
stoppok