diff --git a/designer/tslvcldesigner.tsf b/designer/tslvcldesigner.tsf index b1c70aa..8c7c0bf 100644 --- a/designer/tslvcldesigner.tsf +++ b/designer/tslvcldesigner.tsf @@ -3,7 +3,9 @@ unit tslvclDesigner; @explan(说明)设计器库 %% **} interface -uses utslvcldesignerresource,cstructurelib,utslvclauxiliary,utslvclbase,utslvclgdi,utslvcldcomponents,utslvcldpropertytypes,tslvcl,UVCPropertyTypesPersistence,utslmemo,UDesignerProject; +uses utslvcldesignerresource,cstructurelib,utslvclauxiliary,utslvclbase, + utslvclgdi,utslvcldcomponents,utslvcldpropertytypes,tslvcl, + UVCPropertyTypesPersistence,utslmemo,UDesignerProject; //*******设计控件基类********************** //**********设计控件类************ @@ -12,28 +14,23 @@ type TVclDesigner = class(tvcform) @explan(说明) 控件设计器 对象 %% **} private - fcwindowinfo; - fwindowinfos; + fcwindowinfo; //当前窗口文件对象 + fwindowinfos; //窗口文件节点存储对象 fcutcopyinfo;//复制的信息 FChmHelper; //帮助文档 FImageList; //图标 - FViewBitmap; - FCTrans; - FVariableSelecter; - FFunctionSelecter; - Ftvclform; + FViewBitmap; //图片管理器 + FVariableSelecter; //当前控件树的变量 + FFunctionSelecter; //当前控件树的函数 //**********菜单*************** - FMenu0; - FParser; + FMenu0; //主菜单 //******************************** - FToolBars; + FToolBars; //控件工具栏 FTree; //当前的树 - FObjInspector; - FPropGrid; - FEventGrid; + FObjInspector; //控件树展示器 + FPropGrid; //控件属性grid + FEventGrid; //控件事件grid - FTempCanvas; - static FClassItems; //************************************ FCurrentNode; FCurrentClikPos; @@ -43,7 +40,7 @@ type TVclDesigner = class(tvcform) FProjectsManager; FProjectManager; //*************************** - function WrapProjectTo(); + function WrapProjectTo(); //打包当前 begin FProjectManager.WrapTo(); end @@ -89,20 +86,16 @@ type TVclDesigner = class(tvcform) begin //extheight := CaptionHeight()+MenuBarHeight(); clc := array(); - //if FClassItems and ifarray(FClassItems) then - //begin - for i,v in class(TDComponent).GetClassItem() do - begin - cli := v.classification; - if not(cli and ifstring(cli)) then cli := "常用"; - if ifnil(clc[cli]) then clc[cli] := 0; - clc[cli]+=1; - end - mx := 0; - for i,v in clc do mx := max(mx,v); - height := (integer(mx*32/twidth)+1)*32+60+30{+24}+5; - //end else - // height := 90+32{+24}+5; + for i,v in class(TDComponent).GetClassItem() do + begin + cli := v.classification; + if not(cli and ifstring(cli)) then cli := "常用"; + if ifnil(clc[cli]) then clc[cli] := 0; + clc[cli]+=1; + end + mx := 0; + for i,v in clc do mx := max(mx,v); + height := (integer(mx*32/twidth)+1)*32+60+30{+24}+5; end function TreeNode2tfmsub(lib,node,itemnames,nd);//tmf文件字符串 @@ -165,21 +158,15 @@ type TVclDesigner = class(tvcform) if node Is class(TComponentTreeNode) then begin comp := node.Component; - tree := Node.owner; - node.Recycling(); - if tree is class(TComponentTree) then - begin - tree.deleteitem(node); - node.Recycling(); - end - if comp is class(TDComponent) then + node.Recycling(); //销毁节点 + if comp is class(TDComponent) then //销毁节点对应控件 begin wd := comp.Cwnd; if wd is class(TComponent) then wd.Recycling(); end end end - function createmainmenubyarray(ms,pm,oer); + function createmainmenubyarray(ms,pm,oer); //构造菜单 begin if not(ifarray(ms) and ms) then exit; if ms["type"]="menu" then @@ -231,23 +218,23 @@ type TVclDesigner = class(tvcform) end end public //复制粘贴 - function copynode(node); + function copynode(node); //复制 begin fcutcopyinfo := getnodeinfodata(node); end - function cutnode(node); + function cutnode(node); //剪切节点 begin - fcutcopyinfo := getnodeinfodata(node,1); + fcutcopyinfo := getnodeinfodata(node); fcutcopyinfo[2] := true; end - function pasttonode(nd); + function pasttonode(nd);//粘贴节点 begin if not fcutcopyinfo then return ; ifc := fcutcopyinfo[2]; r := pastinfotonode(nd,fcutcopyinfo,1,not(ifc)); if ifc and not(r) then fcutcopyinfo := nil; //如果失败就不清除内容 end - function pastinfotonode(nd,data,fst,notcute); + function pastinfotonode(nd,data,fst,notcute); //粘贴节点 begin tc := data[0]; if ifstring(tc) then tc := class(TDComponent).GetClassItem(tc); @@ -279,7 +266,7 @@ type TVclDesigner = class(tvcform) if i = "top" then pidx := 3 ; //位置判断 if vi>pclt[pidx] then begin - vi := integer(pclt[pidx]+(pclt[pidx-2]/2)-5); //位置处理 + vi := integer(pclt[pidx]+(pclt[pidx-2]/2)-10); //位置处理 end end nnd.SetComponentProperties(i,vi); @@ -289,24 +276,22 @@ type TVclDesigner = class(tvcform) pastinfotonode(nnd.TreeNode,v); end end - function getnodeinfodata(node,f); + function getnodeinfodata(node); //复制节点信息 begin tc := node.Component; r := array(); if tc is class(TDComponent) then begin r[0] := tc.dclassname() ; - //if f then r["name"] := tc.name; cr := tc.GetChangedPublish(2); for i,v in cr do begin - //if ifobj(v) then continue; //对象就忽略 if not(v and ifstring(i) ) then continue; //严格判断 r[i] := v; end for i := 0 to node.ItemCount-1 do begin - r[1,i] := getnodeinfodata((node.items)[i],f);// + r[1,i] := getnodeinfodata((node.items)[i]);// end end return r; @@ -330,7 +315,7 @@ type TVclDesigner = class(tvcform) end end end - function OpenExaple(); + function OpenExaple(); begin FProjectFileOpener.caption := "打开范例...."; f := 0;// tslfilename(); @@ -397,21 +382,6 @@ type TVclDesigner = class(tvcform) begin FProjectManager.ShowCurrentFormCode();//ShowEditor(); end - - Function EnabledDesigner(f); - begin - {** - @explan(说明) 设置designer是否可用 %% - @param(f)(bool) - **} - FObjInspector.Visible := F; - self.Enabled := f; - rt := FTree.RootItem; - if rt and rt.ItemCount>0 then - it := (rt.items)[0]; - if it then itt := it.Component; - if itt then itt.Cwnd.Enabled := f; - end function TreeNode2tfm(lib,itemnames,nd); //转换文件 begin {** @@ -426,7 +396,7 @@ type TVclDesigner = class(tvcform) begin FProjectManager.saveCurrentEdit(); end - function mainmenus();virtual; + function mainmenus(); //设计器菜单 begin {** @explan(说明) 菜单 @@ -479,17 +449,17 @@ type TVclDesigner = class(tvcform) ); end public - function DeleFiledFromEdit(n,nn); + function DeleFiledFromEdit(n,nn); //删除变量 begin if FTree.Loading then return ; FProjectManager.DeleteAFiled(n,nn); end - function AddFiledFromEdit(n); + function AddFiledFromEdit(n); //添加变量 begin if FTree.Loading then return ; FProjectManager.AddAFiled(n); end - function AddusesFromEdit(lbs); + function AddusesFromEdit(lbs); //添加uses begin if FTree.Loading then return ; FProjectManager.adduses(lbs); @@ -504,7 +474,7 @@ type TVclDesigner = class(tvcform) SetFunctionList(classinfo["funcs"]); end end - function LoadProject(n); + function LoadProject(n); //当如工程 begin FProjectManager.SetProjectInfo(n); end @@ -522,7 +492,7 @@ type TVclDesigner = class(tvcform) end return r; end - function OpenHelp(o,e); + function OpenHelp(o,e); //打开帮助 begin if not FChmHelper then begin @@ -545,15 +515,13 @@ type TVclDesigner = class(tvcform) end "控件详情": begin - FChmHelper.ChmName := "help\\tslvclhelp.chm"; - - end - + FChmHelper.ChmName := "help\\tslvclhelp.chm"; + end end FChmHelper.ShowTslLangChm(); //_wapi.WinExec('cmd.exe /C start http://bzjj.sinaapp.com/tslvclhelp/index.html',0); end - function ComponentMove(o,e); //移动 + function ComponentMove(o,e); //控件移动 begin {** @explan(说明) 移动 控件 %% @@ -572,7 +540,7 @@ type TVclDesigner = class(tvcform) FPropGrid.SetGridValue("height",o.height,O); //setcomponentfocus(o,false); end - function DesignerClose(o,e) //关闭 + function DesignerClose(o,e) //控件窗口关闭 begin {** @explan(说明)保存 %% @@ -607,7 +575,7 @@ type TVclDesigner = class(tvcform) public //**************************************** - function CreateComponent(); //构造句柄 + function CreateComponent(); //构造控件 begin {** @explan(说明) 构造组件 %% @@ -646,27 +614,16 @@ type TVclDesigner = class(tvcform) //echo "\r\n 添加控件"; return r; end - function RectToPoints(rc); - begin - {** - @explan(说明)辅助函数 - **} - r := array(); - r := array((rc[0],rc[1]),(rc[2],rc[1]),(rc[2],rc[3]),(rc[0],rc[3]),(rc[0],rc[1])); - return r; - end - function setcomponentfocus(cwnd,fk); + function setcomponentfocus(cwnd,fk); //设置获得选中 begin {** @explan(说明) 设计控件获得焦点 %% **} if not(cwnd is class(TWincontrol)) then exit ; if not cwnd.HandleAllocated() then exit; - //if cwnd is class(tvcform) then exit; - //if cwnd.WsPopUp then exit; return cwnd.DesigningSelect(fk); end - function TreeNodeSelected(n); + function TreeNodeSelected(n); //控件树选中节点 begin {** @explan(说明) 节点被选择 %% @@ -686,7 +643,7 @@ type TVclDesigner = class(tvcform) return t.SelectedNode(); end private - function RClickComponent(o,e); + function RClickComponent(o,e); //右键控件窗口 begin {** @explan(说明)右键菜单 %% @@ -696,7 +653,7 @@ type TVclDesigner = class(tvcform) if not(tr.visible) then begin wnd := fwindowinfos.getnodebytree(tr); - FProjectManager.senodesel(wnd); + FProjectManager.setnodesel(wnd); return ;// end if FCurrentNode<>nd then @@ -723,7 +680,7 @@ type TVclDesigner = class(tvcform) end //FClickTime; public - function addandopeneventbyname(nd,n); + function addandopeneventbyname(nd,n); //打开事件函数位置 begin if nd then begin @@ -764,7 +721,7 @@ type TVclDesigner = class(tvcform) end FProjectManager.ShowEditor(); end - function AddAndOPenEvent(nd); + function AddAndOPenEvent(nd); //打开事件函数 begin {** @explan(说明)通过节点打开函数编辑器 %% @@ -790,7 +747,7 @@ type TVclDesigner = class(tvcform) if not(tr.visible) then begin wnd := fwindowinfos.getnodebytree(tr); - FProjectManager.senodesel(wnd); + FProjectManager.setnodesel(wnd); return ;// end if FCurrentNode<> nd then @@ -847,7 +804,7 @@ type TVclDesigner = class(tvcform) if o._Tag is class(tmenu) then o._tag.Checked := false; end - function OnToolButtonCick(o,e); //工具栏 + function OnToolButtonCick(o,e); //工具按钮被点击 begin {** @explan(说明) 选择工具按钮 %% @@ -865,7 +822,7 @@ type TVclDesigner = class(tvcform) FProjectManager.CloseCurrentEdit(nil,true); end public - function BindCwndMessage(wnd); + function BindCwndMessage(wnd); //给控件绑定处理函数 begin {** @explan(说明) 为控件添加事件 %% @@ -891,21 +848,11 @@ type TVclDesigner = class(tvcform) end end end - function UnLoadTreeNode(wndnode); + function UnLoadTreeNode(wndnode); //卸载控件树 begin {** @explan(说明) 卸载tree的节点%% **} - //fcutcopyinfo := nil; - if wndnode = "all" then - begin - for i,v in fwindowinfos.fdata.data do - begin - FProjectManager.saveCurrentEdit(v.fnode); - UnLoadTreeNode(v.fnode); - end - return ; - end nd := fwindowinfos.getdata(wndnode); if not nd then return ; hidenatree(nd); @@ -919,7 +866,7 @@ type TVclDesigner = class(tvcform) tr.Recycling(); end private - function hidenatree(nd); + function hidenatree(nd);//隐藏控件树 begin FCurrentNode := nil; if nd then @@ -927,6 +874,7 @@ type TVclDesigner = class(tvcform) tr := nd.ftree; tr.visible := false; nd.fvars := FVariableSelecter.getlistds(); + nd.fcomp := FEventGrid.Component; FEventGrid.Component := array(); FPropGrid.Component := array(); nd.ffuncs := FFunctionSelecter.List.data; @@ -934,7 +882,7 @@ type TVclDesigner = class(tvcform) class(TDComponent).TemporaryNotName:= array(); end end - function showtree(nd); + function showtree(nd); //显示控件树 begin FCurrentNode := nil; tr := nd.ftree; @@ -943,8 +891,10 @@ type TVclDesigner = class(tvcform) FVariableSelecter.setlistds(nd.fvars); FFunctionSelecter.additems(nd.ffuncs); class(TDComponent).TemporaryNotName := nd.fnames; + FPropGrid.Component := nd.fcomp ; + FEventGrid.Component := nd.fcomp ; end - function switchtree(nd); + function switchtree(nd); //切换控件树 begin FCurrentNode := nil; if nd<>fcwindowinfo then @@ -954,24 +904,28 @@ type TVclDesigner = class(tvcform) hidenatree(fcwindowinfo); end fcwindowinfo := nd; - FTree := fcwindowinfo.ftree; - showtree(fcwindowinfo); - //rnd := FTree.RootItem; - //nnd := rnd.GetNodeByIndex(0); - nnd := ftree.CurrentNode; - if nnd then + if nd then begin - cp := nnd.Component; - if not cp then return ; - wd := cp.Cwnd; - if wd.visible then - begin - wd.visible := false; - wd.visible := true; - + FTree := fcwindowinfo.ftree; + showtree(fcwindowinfo); + if not(nd.fclk) then //不在最上层处理一下 + begin + nnd := FTree.RootItem.GetNodeByIndex(0); + if nnd then + begin + cp := nnd.Component; + if cp then + begin + wd := cp.Cwnd; + if wd.visible then + begin + wd.visible := false; + wd.visible := true; + end + end + end end - FPropGrid.Component := cp; - FEventGrid.Component := cp; + nd.fclk := false; end end end @@ -1012,12 +966,11 @@ type TVclDesigner = class(tvcform) end ; end - function LoadTreeNode(Ptfm,inh,wndnode); + function LoadTreeNode(Ptfm,inh,wndnode);//加载控件树 begin {** @explan(说明) 加载tree节点 %% **} - //UnLoadTreeNode(); if FTree and FTree.Loading then return ; cwindowinfo := fwindowinfos.getorcreate(wndnode,ifold); if cwindowinfo = fcwindowinfo then @@ -1030,14 +983,14 @@ type TVclDesigner = class(tvcform) begin return ;// end - FTree.Loading := true; + FTree.Loading := true; try - prs := array(); - obarray := array(); + prs := array(); + obarray := array(); loadtfmtotree(Ptfm,Ptfm.gettree,FTree.RootItem,FTree,prs,obarray,const inh); for i,v in prs do begin - va := obarray[v[2]]; + va := obarray[v[2]]; if va then begin v[0].SetComponentProperties(v[1],va.GetTrueComponent()); @@ -1048,7 +1001,7 @@ type TVclDesigner = class(tvcform) end ; FTree.Loading := nil; end - function loadtfmtotree(p,d,node,wr,prs,obarray,inhname); + function loadtfmtotree(p,d,node,wr,prs,obarray,inhname);//当如信息 begin {** @explan(说明) 导入tfm文件 %% @@ -1089,7 +1042,7 @@ type TVclDesigner = class(tvcform) comp.Cwnd.align := alnone; end end - lazy := array(); + lazy := array(); for i,v in pubs do begin n := i; @@ -1121,7 +1074,7 @@ type TVclDesigner = class(tvcform) end //comp.DoControlAlign(); end - function SetFunctionList(v); + function SetFunctionList(v); //设置函数信息 begin {** @explan(说明) 设置当前类使用的函数名称 %% @@ -1253,7 +1206,7 @@ type TVclDesigner = class(tvcform) FProjectManager.FTslEditer.setdbugruncall(thisfunction(debugproject)); //设置调试回调 end - property VariableSelecter read FVariableSelecter; + property VariableSelecter read FVariableSelecter; //当前控件树的变量对象 private function ViewBitmap(o,e); begin @@ -1271,7 +1224,7 @@ type TVclDesigner = class(tvcform) FViewBitmap.visible := not FViewBitmap.visible; if o then o.Checked := FViewBitmap.visible; end - function StopProject(o,e); + function StopProject(o,e); //停止运行,目前没用 begin //FRounMenu.Enabled := true; //FStopMenu.Enabled := false; @@ -1285,11 +1238,11 @@ type TVclDesigner = class(tvcform) FRounMenu.Enabled := true; FStopMenu.Enabled := false; end - function editcommandline(); + function editcommandline();//执行命令行 begin FProjectManager.ShowExeEditer(); end - function debugproject(o,e); + function debugproject(o,e); //调试运行 begin FProjectManager.debugproject(); end @@ -1310,7 +1263,7 @@ type TVclDesigner = class(tvcform) o.Checked := FObjInspector.Visible end end - function initobjinspector(); + function initobjinspector(); //初始化 begin project := new TPairSplitter(self); project.visible := false; @@ -1353,13 +1306,15 @@ end implementation type tfileinfonode = class() - fnode; - ftree; - ffuncs; - fvars; - fnames; + fnode; //文件节点 + ftree; //窗口对应树 + ffuncs; //函数名 + fvars; //变量 + fnames; //可用的变量名 + fcomp; //选中的控件 + fclk; //是否点击选择 end -type tfilesinfo = class() +type tfilesinfo = class() //控件树存储对象 private fdesginer; fcompclick; @@ -1375,7 +1330,7 @@ type tfilesinfo = class() fparent := fp; end - function getdata(id); //获得节点信息 + function getdata(id); //通文件节点获得信息 begin if not id then return fdata; for i,v in fdata.data do @@ -1383,7 +1338,7 @@ type tfilesinfo = class() if v.fnode = id then return v; end end - function gettreebyid(id); + function gettreebyid(id); //通过文件节点树获得树 begin if not id then return fdata; for i,v in fdata.data do @@ -1391,14 +1346,18 @@ type tfilesinfo = class() if v.fnode = id then return v.FTree; end end - function getnodebytree(tr); + function getnodebytree(tr); //通过树获得文件节点 begin for i,v in fdata.data do begin - if v.ftree = tr then return v.fnode; + if v.ftree = tr then + begin + v.fclk := true; + return v.fnode; + end end end - function getorcreate(id,ifold); + function getorcreate(id,ifold); //如果存在返回,不存在构造并返回 begin nd := getdata(id); ifold := true ; @@ -1414,7 +1373,7 @@ type tfilesinfo = class() end return nd; end - function add(nd,tr,fcs,vs); + function add(nd,tr,fcs,vs);//添加一个 begin for i,v in FData.data do begin @@ -1443,7 +1402,7 @@ type tfilesinfo = class() ftreeparnet; fdata; end -type TPropEditGrid = class(TPropGrid) +type TPropEditGrid = class(TPropGrid) //属性编辑 {** @explan(说明) 属性编辑 %% **} @@ -1467,7 +1426,7 @@ type TPropEditGrid = class(TPropGrid) end end -type TEventEditGrid = class(TPropGrid) +type TEventEditGrid = class(TPropGrid) //事件编辑器 {** @explan(说明) 事件编辑 %% **} @@ -1492,7 +1451,7 @@ type TEventEditGrid = class(TPropGrid) inherited; OndblClick := thisfunction(GridCellDblClick); end - function GridCellDblClick(o,e);override; + function GridCellDblClick(o,e);override;//双击处理 begin i := e.iitem; j := e.isubitem; @@ -1569,7 +1528,7 @@ type TDesigImageList = class(TControlImageList) return r?r:0; end end -type TDesignertoolbars = class(TPageControl) +type TDesignertoolbars = class(TPageControl) //设计器控件按钮 private FToolbars; FLabels ; @@ -1621,7 +1580,7 @@ type TDesignertoolbars = class(TPageControl) else v.Cursor := OCR_NORMAL; end end - function addbtn(btn,t); + function addbtn(btn,t); //加入按钮 begin if not(t and ifstring(t)) then begin @@ -1649,10 +1608,6 @@ type TDesignertoolbars = class(TPageControl) end - - - - type TViewBitmap = class(TvcForm) {** @explan(说明) 图片信息采集%% diff --git a/designer/udesignerproject.tsf b/designer/udesignerproject.tsf index 4496a71..3c75666 100644 --- a/designer/udesignerproject.tsf +++ b/designer/udesignerproject.tsf @@ -481,7 +481,7 @@ type TProjectView = class(TVCForm) // FWrapFolder.Caption := "打包工程到目录"; return; end - function senodesel(nd); + function setnodesel(nd); begin ftree.setsel(nd); end diff --git a/designer/utslcodeeditor.tsf b/designer/utslcodeeditor.tsf index 4c70d5c..f40a37f 100644 --- a/designer/utslcodeeditor.tsf +++ b/designer/utslcodeeditor.tsf @@ -4389,6 +4389,7 @@ type TTslCodeMap=class(TTreeView) //tsl //双击 if not FTreeEditer then return; nd := CurrentNode; + if not nd then return ; line := nd._tag; if line>0 then begin diff --git a/funcext/tvclib/tslvcl.tsf b/funcext/tvclib/tslvcl.tsf index 63a35f7..a5726bf 100644 --- a/funcext/tvclib/tslvcl.tsf +++ b/funcext/tvclib/tslvcl.tsf @@ -2661,7 +2661,7 @@ type TTreeNode=class(TTreeCtlNode) begin DeleteChildren(); end - function HandleAllocated(); + (*function HandleAllocated(); begin {** @explan(说明)是否句柄有效%% @@ -2674,7 +2674,7 @@ type TTreeNode=class(TTreeCtlNode) {** @explan(说明) 构建句柄 %% **} - end + end *) function InsertNode(node,bnode);override; begin {** @@ -2874,6 +2874,7 @@ type TTreeView=class(TTreeCtl) @explan(说明) 删除 节点,但是节点不会销毁,请用node.recycling 销毁 %% @param(node)(TTreeNode) **} + return deletenode(node); if node is class(TTreeNode)then begin end else