From 3b9ac6f10774fa816c50f32ab0d1c501cf98f502 Mon Sep 17 00:00:00 2001 From: JianjunLiu Date: Tue, 20 Sep 2022 17:01:48 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=8C=E9=9D=A2=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 设计器控件复制,剪切,粘贴,以及优化 coolbar --- designer/tslvcldesigner.tsf | 181 +++++++++++++++++++++++------- funcext/tvclib/tcomponent.tsf | 10 +- funcext/tvclib/utslvclcoolbar.tsf | 16 ++- 3 files changed, 162 insertions(+), 45 deletions(-) diff --git a/designer/tslvcldesigner.tsf b/designer/tslvcldesigner.tsf index febaa02..1860036 100644 --- a/designer/tslvcldesigner.tsf +++ b/designer/tslvcldesigner.tsf @@ -229,6 +229,57 @@ type TDComponent = class() return r; end + function copyclick(o,e);virtual; + begin + cp:=o.Component; + if not cp then exit; + nd := cp.TreeNode; + If not nd then exit; + d := nd.owner.Designer; + d.copynode(nd); + end + function cutclick(o,e);virtual; + begin + cp:=o.Component; + if not cp then exit; + nd := cp.TreeNode; + If not nd then exit; + ndp := nd.parent; + if ndp then + begin + dm := MessageBoxA(":"+nd.Caption,"ɾ",(0x1 .| 0x30),nd.owner);// + if dm<>1 then exit; + d := nd.owner.Designer; + d.cutnode(nd); + wd := nd.Component.Cwnd; + ds := nd.owner.Designer; + //ds.setcomponentfocus(wd,false); + ndp.deletenode(nd); + ns := array(); + wds := array(); + GetDeleteNames(nd,ns,wds); //ɾ + for i,nsv in ns do + ds.DeleFiledFromEdit(nsv,""); + ds.EditerCodeChanged(); + + nd.Recycling(); + if wd then + begin + wd.Recycling(); + end + o.Component := nil; + ndp.Owner.SetSel(ndp); + end + end + function pasteclick(o,e);virtual; + begin + cp:=o.Component; + if not cp then exit; + nd := cp.TreeNode; + If not nd then exit; + d := nd.owner.Designer; + d.pasttonode(nd); + end function deleteclick(o,e);virtual; //ؼɾ begin cp:=o.Component; @@ -238,7 +289,7 @@ type TDComponent = class() ndp := nd.parent; if ndp then begin - dm := MessageBoxA("ɾ:"+nd.Caption,"ɾ",0x1 .| 0x30,nd.owner);// + dm := MessageBoxA("ɾ:"+nd.Caption,"ɾ",(0x1 .| 0x30),nd.owner);// if dm<>1 then exit; wd := nd.Component.Cwnd; ds := nd.owner.Designer; @@ -362,11 +413,16 @@ type TDComponent = class() function menus();virtual; //˵ begin - return array( + r := array( ("type":"menu","caption":"ɾ","id":"delete","onclick":thisfunction(deleteclick)), + ("type":"menu","caption":"","id":"copy","onclick":thisfunction(copyclick)), + ("type":"menu","caption":"","id":"cut","onclick":thisfunction(cutclick)), + ("type":"menu","caption":"ճ","id":"paste","onclick":thisfunction(pasteclick)), ("type":"menu","caption":"","onclick":thisfunction(MoveComponentUp)), ("type":"menu","caption":"","onclick":thisfunction(MoveComponentDown)) ); + if not IsContainer() then r := select * from r where ["caption"]<>"ճ" end; + return r; end function CreateNode(tnode,owner,tree,Pwnd);virtual; begin @@ -400,6 +456,7 @@ type TDComponent = class() tn.SelImgId := Imgs; end o := createobject({ClassObject()}self(true).classinfo(1),owner); + o.imgs := imgs; if not o then return 0; o.TreeNode := tn; SetViewParent(o.Cwnd,Pwnd); @@ -428,12 +485,12 @@ type TDComponent = class() if FCwnd then return FCwnd.GetChangedPropertiesn(n); return nil; end - function GetChangedPublish();virtual; + function GetChangedPublish(f);virtual; begin {** @explan(˵)øı%% **} - if FCwnd then return FCwnd.GetChangedPublish(); + if FCwnd then return FCwnd.GetChangedPublish(f); return array(); end function GetPublishProperties();virtual; @@ -705,11 +762,11 @@ type TDVirutalWindow = class(TCustomControl) if not r then return array();//array(1:nil); return r; end - function GetChangedPublish();override; + function GetChangedPublish(f);override; begin r := getnotnil(inherited); if not FBindComponent then exit; - r2 :=FBindComponent.GetChangedPublish(); + r2 :=FBindComponent.GetChangedPublish(f); if r2 then begin deletefiled(r2); @@ -793,7 +850,7 @@ type TVclDesigner = class(tvcform) @explan(˵) ؼ %% **} private - + fcutcopyinfo;// FChmHelper; tmpcanvas; //canvas FImageList; //ͼ @@ -1006,6 +1063,71 @@ type TVclDesigner = class(tvcform) call(thisfunction,v,pm,oer); end end + public //ճ + function copynode(node); + begin + fcutcopyinfo := getnodeinfodata(node); + end + function cutnode(node); + begin + fcutcopyinfo := getnodeinfodata(node,1); + end + function pasttonode(nd); + begin + if fcutcopyinfo then + begin + pastinfotonode(nd,fcutcopyinfo); + if fcutcopyinfo["name"] then fcutcopyinfo := nil; + end + end + function pastinfotonode(nd,data); + begin + tc := data[0]; + if (tc is class(TDRootComponent)) and not( tc is class(TDMenu)) then + begin + nd := (FTree.RootItem.items)[0]; + end + + nnd := tc.ComponentCreater(nd,nd.Component.Cwnd); + if not nnd then return ; + nnd.CreateName(); + FVariableSelecter.additem(nnd); + BindCwndMessage(nnd.Cwnd); + for i,v in data do + begin + if ifstring(i) then + begin + //if i in array("left","top") then continue; + nnd.SetComponentProperties(i,v); + end + end + for i,v in data[1] do + begin + pastinfotonode(nnd.TreeNode,v); + end + end + function getnodeinfodata(node,f); + begin + tc := node.Component; + r := array(); + if tc is class(TDComponent) then + begin + r[0] := tc; + 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);// + end + end + return r; + end public function OpenFileFromTpjFile(); //ļ򿪹 begin @@ -1646,7 +1768,8 @@ type TVclDesigner = class(tvcform) begin {** @explan(˵) жtreeĽڵ%% - **} + **} + fcutcopyinfo := nil; node := FTree.RootItem; if node.ItemCount>0 then begin @@ -1849,26 +1972,6 @@ type TVclDesigner = class(tvcform) FImageList := new TDesigImageList(self); FTree.Imagelist := FImageList; //******************toolbar *************** - {fdebugtoolbar := new TToolBar(self); - btns := FProjectManager.FTslEditer.getdbugtoolbtns(); - idx := 0; - for i,v in btns do - begin - if idx = 0 then fdebugtoolbar.ImageList := v.parent.ImageList; - idx++; - if v.caption = "/ɾϵF5" then continue; - v.parent := fdebugtoolbar; - v._tag := v.onclick; - - v.onclick := function(o,e)begin - cp := o.caption; - CallMessgeFunction(o._tag,o,e); - if cp<>"ֹ" then - begin - FProjectManager.ShowEditor(); - end - end; - end } tlbar := FProjectManager.FTslEditer.gettoolbar(); savebtn := FProjectManager.FTslEditer.gettoolbarbtn(); for i,v in savebtn do //һ±湤 @@ -1883,7 +1986,7 @@ type TVclDesigner = class(tvcform) end end tlbar.Align := alLeft; - tlbar.width :=440; + tlbar.width :=450; tlbar.parent := self; tlbar.arrange :="0;1"; sp1 := new tsplitter(self); @@ -1903,14 +2006,8 @@ type TVclDesigner = class(tvcform) self.onclose := thisfunction(DesignerClose); ic := new Ticon(); ic.Readvcon(HexFormatStrToTsl(GetTsIconBitmapInfo())); - self.FormICon := ic; - {fdebugtoolbar.Align := alnone; - fdebugtoolbar.left := FToolBars.Flabelcharlen* 10; - fdebugtoolbar.top := 0; - fdebugtoolbar.parent := FToolBars;} - - //ļ򴰿 - + self.FormICon := ic; + //ļ򴰿 FProjectFileOpener := new TOpenFileADlg(self); FProjectFileOpener.filter := array("tvcl":"*.tpj"); FProjectFileOpener.parent := self; @@ -8951,6 +9048,7 @@ type TDForm = class(TDComponent) //r[0] := array("type":"menu","caption":"洰"); r[0] := array("type":"menu","caption":"tsfļ","onclick":thisfunction(OpenClass)); r[1] := array("type":"menu","caption":"浱ǰ","onclick":thisfunction(savecurrentform)); + r[2] := array("type":"menu","caption":"ճ","onclick":thisfunction(pasteclick)); //r[2] := array("type":"menu","caption":"򿪹Ŀ¼","onclick":thisfunction(openProjectDir)); return r; end @@ -9134,6 +9232,11 @@ type TDBtn = class(TDComponent) begin return Class(tbtn); end + function menus();override; + begin + r := inherited; + return select * from r where ["caption"] <> "ճ" end ; + end function Create(AOwner);override; begin inherited; @@ -9173,7 +9276,7 @@ type TDPairSplitterSide = class(TDComponent) function menus();override; begin r := inherited; - return select * from r where ["caption"]="ɾ" end ; + return select * from r where ["caption"] in array("ɾ","ճ","") end ; end function InToolBar();override; begin @@ -9308,7 +9411,7 @@ type TDTabSheet = class(TDComponent) function menus();override; begin r := inherited; - return select * from r where ["caption"]="ɾ" end ; + return select * from r where ["caption"] in array("ɾ","ճ","") end ; end function InToolBar();override; begin diff --git a/funcext/tvclib/tcomponent.tsf b/funcext/tvclib/tcomponent.tsf index 74dca7f..cde05e5 100644 --- a/funcext/tvclib/tcomponent.tsf +++ b/funcext/tvclib/tcomponent.tsf @@ -538,7 +538,7 @@ public begin return FChangedProperties[n]; end - function GetChangedPublish();virtual; + function GetChangedPublish(f);virtual; begin {** @explan(˵)ȡ޸Ĺpublish,ʹ %% @@ -555,7 +555,13 @@ public otype := GetComponentPropertyType(vit);//GetPropertyType(vit); if vi["write"]and otype then begin - r[n]:= otype.FormatTMF(vv); + if f=2 then + begin + r[n] := vv; + end else + begin + r[n]:= otype.FormatTMF(vv); + end end end return r; diff --git a/funcext/tvclib/utslvclcoolbar.tsf b/funcext/tvclib/utslvclcoolbar.tsf index 90777cb..f1bcc39 100644 --- a/funcext/tvclib/utslvclcoolbar.tsf +++ b/funcext/tvclib/utslvclcoolbar.tsf @@ -32,6 +32,7 @@ type tcustomcoolbar=class(tcustomcontrol) begin r := inherited; if class(tflag).haslocker then return r; + if (o is class(TWinControl)) and o.WsPopUp then return r; if HandleAllocated() and ifarray(op) and (op["type"]="possize") then //λôСͱ仯 begin ctls := controls; @@ -188,8 +189,9 @@ type tcustomcoolbar=class(tcustomcontrol) bss := array(); for j,bsi in v do begin - ctl := bsi.fctl; - if ctl.Visible then + ctl := bsi.fctl; + + if ctl.Visible and not(ctl is class(TWinControl) and ctl.WsPopUp) then begin bss[length(bss)]:= bsi; drc := array(x,y,x+mwid,y+rhs[i]); @@ -558,11 +560,17 @@ type tcoolbarlines = class() // h := 0; for j,vj in v do begin - if vj["visible"] then - h := max(h,vj["height"]); + if vj["visible"] and not(vj["wspopup"]) then + begin + h := max(h,vj["height"]); + end end r[i] := h;// max(20,h); end + if (csDesigning in ComponentState) and (length(r)=1 and r[0]<2) then + begin + r[0] := 25; + end return r; end function EnabledChild(f); //enable