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