From fad69fa5e4da9d539e9987b8bd068a7ebd76cec1 Mon Sep 17 00:00:00 2001 From: JianjunLiu Date: Mon, 29 Aug 2022 15:28:37 +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 --- funcext/tvclib/tslvcl.tsf | 3 +- funcext/tvclib/utslvclcoolbar.tsf | 77 ++++++++++++++++++++++--------- 2 files changed, 56 insertions(+), 24 deletions(-) diff --git a/funcext/tvclib/tslvcl.tsf b/funcext/tvclib/tslvcl.tsf index c0099f7..22bd6b1 100644 --- a/funcext/tvclib/tslvcl.tsf +++ b/funcext/tvclib/tslvcl.tsf @@ -2490,7 +2490,7 @@ type tcoolbar = class(tcustomcoolbar) end function publishs();override; begin - return array("name","enabled","caption","autosize","font","color","dragbtncolor","sizebtncolor","visible","arrange"); + return array("name","enabled","caption","autosize","border","font","color","dragbtncolor","visible","arrange"); end end @@ -2503,7 +2503,6 @@ type TTreeCtlNode = class( TcustomTreeCtlNode) begin inherited; end - end type TTreeCtl = class(TcustomTreeCtl) {** diff --git a/funcext/tvclib/utslvclcoolbar.tsf b/funcext/tvclib/utslvclcoolbar.tsf index f3b1996..7a29b59 100644 --- a/funcext/tvclib/utslvclcoolbar.tsf +++ b/funcext/tvclib/utslvclcoolbar.tsf @@ -17,8 +17,7 @@ type tcustomcoolbar=class(tcustomcontrol) Align := alTop; FWill_Drag := true; cimgst(); - fsizebtncolor := _wapi.GetSysColor(COLOR_MENUBAR); - fdragbtncolor := fsizebtncolor; + fdragbtncolor := _wapi.GetSysColor(COLOR_MENUBAR); end function ControlAppended(AControl);override; begin @@ -137,13 +136,35 @@ type tcustomcoolbar=class(tcustomcontrol) begin nxy := clienttowindow(e.xpos,e.ypos); _wapi.ImageList_DragMove(nxy[0],nxy[1]); - end + end else + begin + xy := e.pos(); + for i,v in fcoolbands.data do + begin + if pointinrect(xy,v.fdragrect) then //拖拽 + begin + cursor := OCR_SIZEALL; + flg := true; + break; + end + if pointinrect(xy,v.fsizerect) then //拖拽 + begin + cursor := OCR_SIZEWE; + flg := true; + break; + end + end + if not flg then + begin + cursor := OCR_NORMAL; + end + end inherited; end function doControlALign();override;//调整位置 begin mwid := 10; - swid := 12; + swid := 10; y := 0; rhs := fcoolbands.getrowheights(); if autosize then @@ -163,13 +184,17 @@ type tcustomcoolbar=class(tcustomcontrol) lk := new tflag(); for i,v in fcoolbands.data2 do begin - x := 0; + x := 0; + bss := array(); for j,bsi in v do begin ctl := bsi.fctl; if ctl.Visible then begin - bsi.fdragrect := array(x,y,x+mwid,y+rhs[i]); + bss[length(bss)]:= bsi; + drc := array(x,y,x+mwid,y+rhs[i]); + bsi.fdragrect := drc; + bsi.fbtnrect := drc; h := ctl.Height; w := ctl.Width; x += mwid; @@ -182,17 +207,31 @@ type tcustomcoolbar=class(tcustomcontrol) ctl.SetBounds(x,y+dy,w,h); x+=w; bsi.fsizerect := array(x,y,x+swid,y+rhs[i]); - x+=swid; + //x+=swid; end else begin - bsi.fdragrect := array(0,0,0,0); - bsi.fctlrect := array(0,0,0,0); - bsi.fsizerect := array(0,0,0,0); - end - + bsi.fdragrect := array();//array(0,0,0,0); + bsi.fctlrect := array();//array(0,0,0,0); + bsi.fsizerect := array();//array(0,0,0,0); + end end - bsi.fsizerect := array(0,0,0,0); + bsi.fsizerect := array();//array(0,0,0,0); y+=rhs[i]; + for i := 0 to length(bss)-2 do //重新设置位置 + begin + bs := bss[i]; + rc := bs.fsizerect; + if rc then + begin + bs2 := bss[i+1]; + rc[1] := rc[1]+integer((rc[3]-rc[1])/2); + bs.fsizerect := rc; + rc := bs2.fdragrect; + rc[3] := rc[3]-integer((rc[3]-rc[1])/2); + bs2.fdragrect := rc; + end + end + end end function paint();override; //绘制 @@ -211,13 +250,8 @@ type tcustomcoolbar=class(tcustomcontrol) end for i,v in fcoolbands.data do begin - //dc.brush.color := 0x87CEEB; dc.brush.color := fdragbtncolor; - rc1 := v.fdragrect; - paintbtn(v.fdragrect); - //dc.brush.color := 0xEEE8AA; - dc.brush.color := fsizebtncolor; - paintbtn(v.fsizerect); + paintbtn(v.fbtnrect); end dc.brush.color := cl; dc.pen.color := bcl; @@ -230,11 +264,9 @@ type tcustomcoolbar=class(tcustomcontrol) property autosize:bool read fautosize write setautosize; property arrange:lazystr read getarrange write setarrange; property dragbtncolor:color read fdragbtncolor write fdragbtncolor; - property sizebtncolor:color read fsizebtncolor write fsizebtncolor; private fautosize ; fdragbtncolor; - fsizebtncolor; fsizelocker; function paintbtn(rc1); begin @@ -397,6 +429,7 @@ type tcoolband = class() // fdragrect; fsizerect; fctlrect; + fbtnrect; private fenable; end @@ -526,7 +559,7 @@ type tcoolbarlines = class() // if vj["visible"] then h := max(h,vj["height"]); end - r[i] := max(20,h); + r[i] := h;// max(20,h); end return r; end