界面库

优化树控件
This commit is contained in:
JianjunLiu 2022-08-09 16:30:11 +08:00
parent 146101a46f
commit 3d3a47f190
3 changed files with 75 additions and 5 deletions

View File

@ -1768,6 +1768,7 @@ type TVclDesigner = class(tvcform)
@explan(说明) 设置当前类使用的函数名称 %%
**}
FFunctionSelecter.clean();
FFunctionSelecter.additem("(none)");
for i,vi in v do
begin
if vi in array("create","destroy","recycling","loadfromtfm") then continue;
@ -7480,7 +7481,14 @@ type TBitmapGrid = class(TGridList)
end
end
type tnone = class()
function create();
begin
name := "(none)";
end
name;
end
type TListVariableFilter = class(TListVariable)
private
FVlist;
@ -7547,7 +7555,7 @@ type TListVariableFilter = class(TListVariable)
vs[length(vs)] := vi;
end
end
additems(vs);
additems(array(new tnone()) union vs);
end
function create(AOwner);override;
begin
@ -7633,7 +7641,7 @@ type TListVariable = class(TGridList)
begin
id := e.iitem;
inherited;
if id<0 then
if id<0 or (SelectedValue is class(tnone)) or (SelectedValue = "(none)") then
begin
UnSelected();
end

View File

@ -305,6 +305,7 @@ type TcustomTreeCtlNode = class(TVirtualListItem)
function Create(AOwner);override;
begin
inherited;
FVisible := true;
FMouseCanChecked := true;
FModifyChildrenChecked := true;
FFocusColor := array(rgb(230,240,250),rgb(0,192,250));
@ -509,7 +510,12 @@ type TcustomTreeCtlNode = class(TVirtualListItem)
@return(TcustomTreeCtlNode) %%
**}
if FItems.Count<1 or not(FExpanded)then return self;
it := FItems[FItems.Count-1];
for i := FItems.Count-1 downto 0 do
begin
it := FItems[i];
if it.Visible then return it.GetLastShowNode();
end
return self;
return it.GetLastShowNode();
end
function InsertNodes(its,idx);virtual;
@ -683,8 +689,11 @@ type TcustomTreeCtlNode = class(TVirtualListItem)
for i := 0 to FItems.Count-1 do
begin
it := FItems[i];
if it.Visible then //可见
begin
r++;
if it.ItemCount and it.Expanded then r += it.GetShowItemCount();
end
end
return r;
end
@ -698,8 +707,11 @@ type TcustomTreeCtlNode = class(TVirtualListItem)
for i := 0 to FItems.Count-1 do
begin
it := FItems[i];
if it.Visible then
begin
lst union=array(it);
if it.ItemCount and it.Expanded then lst union=it.GetShowNodes();
end
end
return lst;
end
@ -730,6 +742,7 @@ type TcustomTreeCtlNode = class(TVirtualListItem)
property ImgId read FImgId write SetImgId;
property SelImgId read FSelImgId write SetSelImgId;
property ExpandImgId read FExpandImgId write SetExpandImgId;
property Visible read FVisible write SetVisible;
property ItemCount read GetItemCount; //½ÚµãÊý
property Hierarchy Read FHierarchy; //²ã´Î
property Expanded read GetExpanded; //Õ¹¿ª
@ -825,6 +838,55 @@ type TcustomTreeCtlNode = class(TVirtualListItem)
FSelImgId := id;
end
end
function SetVisible(v); //可见设置
begin
if Owner.RootNode = self then return ;
nv := v?true:false;
if nv<>FVisible then
begin
FVisible := nv;
p := Parent;
if not p then return ; //无父节点
if p<>Owner.RootNode then //非根节点
begin
if not Owner.NodeInList(p) then return 0;// 不在列表中
if not p.Expanded then return 0; //非展开
pidx := Owner.GetItemIndex(p); //获得位置
end else //根节点
begin
pidx := -1;
end
UnExpand(); //折叠
if nv then //变得可见
begin
cidx := p.GetShowNodeidx(self);
idx := pidx+cidx+1;
Owner.InsertItem(self(true),idx);
end else //变得不可见
begin
idx := Owner.GetItemIndex(self);
owner.DeleteItemByBounds(idx,idx);
end
end
end
function GetShowNodeidx(nd); //获得子节点在父节点后面的序号
begin
idx := 0;
for i := 0 to FItems.Count-1 do
begin
it := FItems[i];
if it = nd then return idx;
if it.Visible then
begin
idx++;
if it.ItemCount and it.Expanded then
idx += it.GetShowNodeidx(0);
end
end
return idx;
end
FVisible;
FDirtype;
FImgId;
FMouseCanChecked;

View File

@ -1524,8 +1524,8 @@ type UniObjectMember=class(UniSelProperty)
FNameMap := New tstrindexarray();
FValueMap := New tstrindexarray();
FInfoObj := CreateInfoOBJ();
r := array();
if not ifobj(FInfoObj)then return array();
r := array();
if not ifobj(FInfoObj)then return array();
for i,v in FInfoObj.classinfo()["members"] do
begin
ni := v["name"];