界面库

优化 recycling 通知
This commit is contained in:
JianjunLiu 2022-09-01 17:28:46 +08:00
parent 8df9471fed
commit 5edd6251c4
10 changed files with 50 additions and 33 deletions

View File

@ -1,6 +1,6 @@
object e_actionmain1:e_actionmain object e_actionmain1:e_actionmain
caption="action ·¶Àý" caption="action ·¶Àý"
height=520.0 height=520
left=451 left=451
onclose=e_actionmain1_close onclose=e_actionmain1_close
popupmenu=popupmenu1 popupmenu=popupmenu1

View File

@ -735,11 +735,7 @@ type TDVirutalWindow = class(TCustomControl)
function Recycling();override; function Recycling();override;
begin begin
inherited; inherited;
if FBindComponent is class(TComponent) then FBindComponent := nil;
begin
FBindComponent.Recycling();
FBindComponent := nil;
end
end end
property BindComp read FBindComponent write SetBindComponent; property BindComp read FBindComponent write SetBindComponent;
property WindowFileds read FWindowFileds write FWindowFileds; property WindowFileds read FWindowFileds write FWindowFileds;

View File

@ -193,7 +193,22 @@ public
begin begin
end end
Procedure Notification(AComponent,Operation);virtual; function relnotification(ac,Operation);//֪ͨ¹ØÁªµÄ×é¼þ
begin
ow := ac;
while ow do
begin
nw := ow.Owner;
if not nw then
begin
break;
end
ow := nw;
end
if ow<>ac then
ow.Notification(ac,Operation);
end
function Notification(AComponent,Operation);virtual;
begin begin
{** {**
@explan(说明) 通知处理 %% @explan(说明) 通知处理 %%
@ -331,8 +346,11 @@ public
begin begin
if not FComponentCreated then exit; if not FComponentCreated then exit;
Destroying(); Destroying();
//////////////////////////
relnotification(self(true),"recycling");
///////////////////////
DestroyComponents(); DestroyComponents();
If FOwner is class(tcomponent)Then FOwner.RemoveComponent(Self); If FOwner is class(tcomponent)Then FOwner.RemoveComponent(self(true)); //self
inherited; inherited;
end end
function Destroy();virtual; function Destroy();virtual;

View File

@ -1392,6 +1392,7 @@ type tcontrol = class(tcomponent)
if rchange then if rchange then
begin begin
//mtic; //mtic;
//relnotification(self(true),array("type":"possize","flag":rchange,"data":array(fleft,ftop,FWidth,FHeight)));
obj := class(tUIglobalData).uigetdata("tuiapplication"); obj := class(tUIglobalData).uigetdata("tuiapplication");
if obj then if obj then
begin begin

View File

@ -1021,12 +1021,12 @@ type TTray=class(TComponent)
return true; return true;
end end
end end
procedure Notification(AComponent:TComponent;Operation:TOperation);override; function Notification(AComponent:TComponent;Operation:TOperation);override;
begin begin
{** {**
@explan(说明) 通知消息处理 %% @explan(说明) 通知消息处理 %%
**} **}
if Operation=opRemove then if Operation="recycling" then //opRemove
begin begin
if FPopupMenu=AComponent then if FPopupMenu=AComponent then
begin begin
@ -1428,12 +1428,12 @@ type TVCForm = class(TScrollingWinControl)
end end
end end
end end
procedure Notification(AComponent:TComponent;Operation:TOperation);override; function Notification(AComponent:TComponent;Operation:TOperation);override;
begin begin
{** {**
@explan(说明) 通知消息处理 %% @explan(说明) 通知消息处理 %%
**} **}
if Operation=opRemove then if Operation="recycling" then //opRemove
begin begin
if AComponent=FMainMenu then FMainMenu := nil; if AComponent=FMainMenu then FMainMenu := nil;
if FTray=AComponent then if FTray=AComponent then

View File

@ -106,7 +106,7 @@ type TBasicAction=class(TComponent)
function Notification(AComponent,Operation);override; function Notification(AComponent,Operation);override;
begin begin
inherited; inherited;
if Operation=opRemove and AComponent=FActionComponent then if Operation="recycling" and AComponent=FActionComponent then //opRemove
begin begin
FActionComponent := nil; FActionComponent := nil;
if FParent is class(TCustomactionlist)then if FParent is class(TCustomactionlist)then
@ -332,7 +332,7 @@ type TCustomactionlist=class(TComponent)
function Notification(AComponent,Operation);override; function Notification(AComponent,Operation);override;
begin begin
inherited; inherited;
if Operation=opRemove and AComponent=FActionComponent then if Operation="recycling" and AComponent=FActionComponent then //opRemove
begin begin
DeleteAllActions(); DeleteAllActions();
end end

View File

@ -939,23 +939,25 @@ type tnumindexarray = Class
**} **}
p := params; p := params;
st := p[0]; st := p[0];
if not(st>=0) then st := 0;
sl := p[1]; sl := p[1];
sl := ifnil(sl)?inf:sl; sl := ifnil(sl)?inf:sl;
sl := sl<0?0:sl; sl := (sl>=0)?sl:0;
len := length(FData); len := length(FData);
st := st<0?0:st; st := st<0?0:st;
st := st >= len?(len):st; st := st >= len?(len):st;
et := st+sl; et := st+sl;
et := et >= len?(len):et; et := et >= len?(len):et;
r := array(); r := array();
idx := 0; {idx := 0;
for i := st to et-1 do for i := st to et-1 do
begin begin
r[idx++]:= FData[i]; r[idx++]:= FData[i];
end end }
r := FData[st:(et-1)];
r1 := FData[0:st-1]; r1 := FData[0:st-1];
r2 := FData[et:len-1]; r2 := FData[et:len-1];
FData := r1 union p[2:]union r2; FData := r1 union p[2:] union r2;
if len <> length(FData)then LengthChanged(length(FData)-len); if len <> length(FData)then LengthChanged(length(FData)-len);
return r; return r;
end end
@ -1012,7 +1014,7 @@ type tnumindexarray = Class
end end
function splices(startid,sellength,vs); function splices(startid,sellength,vs);
begin begin
if ifarray(vs)then return callinarray(thisfunction(splice),array(startid,sellength)union vs); if ifarray(vs)then return callinarray(thisfunction(splice),array(startid,sellength) union vs);
return array(); return array();
end end
function LengthChanged(n);virtual; function LengthChanged(n);virtual;

View File

@ -25,7 +25,7 @@ type TCommDlg=class(tcomponent)
end end
function Notification(AComponent,Operation);override; function Notification(AComponent,Operation);override;
begin begin
if Operation=opRemove then if Operation="recycling" then //opRemove
begin begin
if AComponent=FWndOwner then FWndOwner := nil; if AComponent=FWndOwner then FWndOwner := nil;
end end

View File

@ -472,7 +472,7 @@ private
function Notification(AComponent:TComponent;Operation:TOperation);override; function Notification(AComponent:TComponent;Operation:TOperation);override;
begin begin
inherited; inherited;
if Operation=opRemove then if Operation="recycling" then //opRemove
begin begin
if AComponent=Action then Action := nil; if AComponent=Action then Action := nil;
end end

View File

@ -4089,7 +4089,7 @@ type tcustommenubutton = class()//
end end
function DoOnClick(o,e); //点击 function DoOnClick(o,e); //点击
begin begin
if fParent and (fmenu is class(TcustomMenu)) then if fParent.HandleAllocated() and (fmenu is class(TcustomMenu)) then
begin begin
if fmenu.ItemCount>0 then //弹出菜单处理 if fmenu.ItemCount>0 then //弹出菜单处理
begin begin
@ -4732,8 +4732,8 @@ type TcustomToolBar=class(TCustomControl)
return font.Height+bw+4; return font.Height+bw+4;
end end
imglst := ImageList; //图标 imglst := ImageList; //图标
imgw := 36; imgw := 28;
imgh := 36; imgh := 28;
if imglst is class(TCustomImageList)then if imglst is class(TCustomImageList)then
begin begin
imgw := imglst.Width+4; imgw := imglst.Width+4;
@ -4772,8 +4772,8 @@ type TcustomToolBar=class(TCustomControl)
return 40; return 40;
end end
imglst := ImageList; //图标 imglst := ImageList; //图标
imgw := 36; imgw := 28;
imgh := 36; imgh := 28;
if imglst is class(TCustomImageList)then if imglst is class(TCustomImageList)then
begin begin
imgw := imglst.Width+4; imgw := imglst.Width+4;
@ -4812,7 +4812,7 @@ type TcustomToolBar=class(TCustomControl)
end end
function Notification(a,op);override; function Notification(a,op);override;
begin begin
if a=fmainmenu and op=opRemove then if a=fmainmenu and op="recycling" then
begin begin
setmainmenu(nil); setmainmenu(nil);
end end
@ -4887,7 +4887,7 @@ type TcustomToolBar=class(TCustomControl)
end end
CalcButtonsRect(); CalcButtonsRect();
end end
function setmainmenu(v); function setmainmenu(v); //设置主菜单
begin begin
if v<>fmainmenu then if v<>fmainmenu then
begin begin
@ -4895,24 +4895,24 @@ type TcustomToolBar=class(TCustomControl)
begin begin
fmainmenu := v; fmainmenu := v;
fmainmenu.onchanged := thisfunction(mainmenuchanged); fmainmenu.onchanged := thisfunction(mainmenuchanged);
mainmenuchanged(); mainmenuchanged();
doControlALign();
end else end else
begin begin
fmainmenu := nil; fmainmenu := nil;
fmenubtns := new tnumindexarray(); fmenubtns := new tnumindexarray();
end end
doControlALign();
InvalidateRect(nil,false); InvalidateRect(nil,false);
end end
end end
function EndShowWnd(); function EndShowWnd();//提示框
begin begin
FShowTimeIndexA :=-1; FShowTimeIndexA :=-1;
FTimer.Stop(); FTimer.Stop();
FTipWnd.Visible := false; FTipWnd.Visible := false;
end end
function CalcButtonsRect(); function CalcButtonsRect(); //计算按钮区域
begin begin
if(IsUpDating())then if(IsUpDating())then
begin begin
@ -4933,7 +4933,7 @@ type TcustomToolBar=class(TCustomControl)
s := mu.Caption; s := mu.Caption;
wh := GetTextWidthAndHeightWidthFont(s,self.font,0);// wh wh := GetTextWidthAndHeightWidthFont(s,self.font,0);// wh
fmenubtnrects[i]:= array(x,y,x+wh[0]+5,rc[3]); fmenubtnrects[i]:= array(x,y,x+wh[0]+5,rc[3]);
x:=x+wh[0]+8; x:=x+wh[0]+15;
if x>rc[2] then break; //只有一行 if x>rc[2] then break; //只有一行
end else end else
begin begin