界面库

优化 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
caption="action ·¶Àý"
height=520.0
height=520
left=451
onclose=e_actionmain1_close
popupmenu=popupmenu1

View File

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

View File

@ -193,7 +193,22 @@ public
begin
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
{**
@explan(说明) 通知处理 %%
@ -331,8 +346,11 @@ public
begin
if not FComponentCreated then exit;
Destroying();
//////////////////////////
relnotification(self(true),"recycling");
///////////////////////
DestroyComponents();
If FOwner is class(tcomponent)Then FOwner.RemoveComponent(Self);
If FOwner is class(tcomponent)Then FOwner.RemoveComponent(self(true)); //self
inherited;
end
function Destroy();virtual;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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