界面库

优化coolbar
This commit is contained in:
JianjunLiu 2022-09-16 17:21:36 +08:00
parent 286af5904f
commit 476be4b95c
4 changed files with 75 additions and 97 deletions

View File

@ -5391,34 +5391,11 @@ type TGridCellVariabletimagelistEdit = class(TGridCellVariableTactionEdit)
inherited; inherited;
end end
end end
type TGridCellVariablehgtEdit = class(TGridCellVariableTactionEdit) type TGridCellVariablehgtEdit = class(TGridCellVariabletimagelistEdit)
Function EditType();override; Function EditType();override;
begin begin
return "thighlighter"; return "thighlighter";
end end
function CellDrawLabel(dc,rect,d);override;
begin
v := d["value"];
if v is class(tcomponent) then
begin
dc.DrawText(v.name,rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE);
end
end
function FormatTMF(d);override;
begin
if d is class(tcomponent) then
begin
r := d.name;
if r then return r;
end
return false;
end
function GetItemValue(V);override;
begin
if v is class(TDComponent) then r := v.GetTrueComponent();
return r;
end
function create(owner);override; function create(owner);override;
begin begin
inherited; inherited;

View File

@ -2518,7 +2518,7 @@ type tcoolbar = class(tcustomcoolbar)
end end
function publishs();override; function publishs();override;
begin begin
return array("name","enabled","caption","autosize","border","wsdlgmodalframe","font","color","dragbtncolor","visible","arrange"); return array("name","enabled","caption","autosize","align","border","wsdlgmodalframe","font","color","dragbtncolor","visible","arrange");
end end
end end
type tsplitter = class(tcustomsplitter) type tsplitter = class(tcustomsplitter)

View File

@ -26,7 +26,7 @@ type tcustomcoolbar=class(tcustomcontrol)
end end
function ControlDeleted(AControl);override; function ControlDeleted(AControl);override;
begin begin
fcoolbands.deleteitem(AControl); fcoolbands.deleteitem(AControl,true);
end end
function Notification(o,op);override; function Notification(o,op);override;
begin begin
@ -47,86 +47,80 @@ type tcustomcoolbar=class(tcustomcontrol)
function WMLBUTTONUP(o,e);override;//ÍÏקʵÏÖ function WMLBUTTONUP(o,e);override;//ÍÏקʵÏÖ
begin begin
if csDesigning in ComponentState then exit; if csDesigning in ComponentState then exit;
//if e.button=mbLeft then if FIs_Draging then
//begin begin
if FIs_Draging then _wapi.ImageList_DragLeave(self.Handle);
_wapi.ImageList_EndDrag();
if fdragenode then
begin begin
_wapi.ImageList_DragLeave(self.Handle); r := fcoolbands.getnodebyxy(e.xpos,e.ypos);
_wapi.ImageList_EndDrag(); if fcoolbands.moveitemto(fdragenode,r[0],r[1]) then
if fdragenode then
begin begin
r := fcoolbands.getnodebyxy(e.xpos,e.ypos); doControlALign();
if fcoolbands.moveitemto(fdragenode,r[0],r[1]) then InvalidateRect(nil,false);
end
end else
if fsizenode then
begin
ctl := fsizenode.fctl;
clr := ctl.BoundsRect;
y := e.ypos;
if y> clr[1] and (y<clr[1]+clr[3]) then
begin
nwid := e.xpos-ctl.left;
if nwid>10 then
begin begin
ctl.Width := nwid;
doControlALign(); doControlALign();
InvalidateRect(nil,false); InvalidateRect(nil,false);
end end
end else end
if fsizenode then end
begin EnabledChild(true);
ctl := fsizenode.fctl; FWill_Drag := true;
clr := ctl.BoundsRect; FIs_Draging := false;
y := e.ypos; _wapi.clipcursor(0);
if y> clr[1] and (y<clr[1]+clr[3]) then return ;
begin end
nwid := e.xpos-ctl.left;
if nwid>10 then
begin
ctl.Width := nwid;
doControlALign();
InvalidateRect(nil,false);
end
end
end
EnabledChild(true);
FWill_Drag := true;
FIs_Draging := false;
_wapi.clipcursor(0);
return ;
end
//end
inherited; inherited;
end end
function WMLButtonDown(o,e);override;//ÍÏ×§ÊÍ·Å function WMLButtonDown(o,e);override;//ÍÏ×§ÊÍ·Å
begin begin
if csDesigning in ComponentState then exit; if csDesigning in ComponentState then exit;
//if e.button=mbLeft then xy := e.pos;
//begin trk := -1;
xy := e.pos; for i,v in fcoolbands.data do
trk := -1; begin
for i,v in fcoolbands.data do if pointinrect(xy,v.fdragrect) then //ÍÏ×§
begin begin
if pointinrect(xy,v.fdragrect) then //ÍÏ×§ trk := 0;
begin fdragenode := v;
trk := 0; fsizenode := nil;
fdragenode := v; break;
fsizenode := nil;
break;
end
if pointinrect(xy,v.fsizerect) then //µ÷Õû´óС
begin
trk := 1;
fdragenode := nil;
fsizenode := v;
break;
end
end end
if trk<0 then return inherited; if pointinrect(xy,v.fsizerect) then //µ÷Õû´óС
nxy := clienttowindow(e.xpos,e.ypos);
if FWill_Drag then
begin begin
FWill_Drag := false; trk := 1;
FIs_Draging := true; fdragenode := nil;
_wapi.ImageList_BeginDrag(FDRageimglist.Handle,trk,12,12); fsizenode := v;
_wapi.ImageList_DragEnter(self.Handle,nxy[0],nxy[1]); break;
crect := clientrect; end
ps := array(clienttoscreen(crect[0],crect[1]),clienttoscreen(crect[2],crect[3]));
_wapi.clipcursor(ps); end
EnabledChild(false); if trk<0 then return inherited;
return ; nxy := clienttowindow(e.xpos,e.ypos);
end if FWill_Drag then
//end begin
FWill_Drag := false;
FIs_Draging := true;
_wapi.ImageList_BeginDrag(FDRageimglist.Handle,trk,12,12);
_wapi.ImageList_DragEnter(self.Handle,nxy[0],nxy[1]);
crect := clientrect;
ps := array(clienttoscreen(crect[0],crect[1]),clienttoscreen(crect[2],crect[3]));
_wapi.clipcursor(ps);
EnabledChild(false);
return ;
end
inherited; inherited;
end end
function WMMouseMove(o,e);override; //ÒÆ¶¯ function WMMouseMove(o,e);override; //ÒÆ¶¯
@ -171,7 +165,8 @@ type tcustomcoolbar=class(tcustomcontrol)
swid := 10; swid := 10;
y := 0; y := 0;
rhs := fcoolbands.getrowheights(); rhs := fcoolbands.getrowheights();
if autosize then bal := Align;
if autosize and ( bal =alTop or bal=alBottom) then
begin begin
rc := ClientRect; rc := ClientRect;
nh := sum(rhs); nh := sum(rhs);
@ -182,7 +177,7 @@ type tcustomcoolbar=class(tcustomcontrol)
begin begin
Align := alNone; Align := alNone;
Height := bw+nh; Height := bw+nh;
Align := alTop; Align := bal;
return ; return ;
end end
end end
@ -454,13 +449,15 @@ type tcoolbarlines = class() //
line := new tnumindexarray(); line := new tnumindexarray();
flines.unshift(line); flines.unshift(line);
end end
function deleteitem(it,f); //ɾ³ýÒ»Ïî function deleteitem(it,ifctl); //ɾ³ýÒ»Ïî
begin begin
for i,v in flines.data do for i,v in flines.data do
begin begin
for j ,vj in v.data do for j ,vj in v.data do
begin begin
if vj = it then if ifctl then vjctl := vj.fctl;
else vjctl := vj;
if vjctl = it then
begin begin
v.splice(j,1); v.splice(j,1);
if v.length()<1 then if v.length()<1 then

View File

@ -387,12 +387,16 @@ type tcustompagecontrol = class(TCustomControl)
end end
end end
public
function getsheetrect(); //»ñµÃsheet function getsheetrect(); //»ñµÃsheet
begin begin
{**
@explan(说明) 获得sheet可视区域 %%
@return(array) array(左,上,右,下) %%
**}
if not FClientarea then CalcTabs(); if not FClientarea then CalcTabs();
return FClientarea; return FClientarea;
end end
public
function DesigningClick();override; function DesigningClick();override;
begin begin
return true; return true;