优化编辑器的自动大小功能

This commit is contained in:
2025-01-24 16:14:06 +08:00
parent 0ff9cbf615
commit 9a87a6286b
7 changed files with 121 additions and 73 deletions
+1
View File
@@ -179,6 +179,7 @@ type tcustomcoolbar=class(tcustomcontrol)
begin
inherited;
doControlALign();
InvalidateRect(nil,false);
end
function doControlALign();override;//调整位置
begin
+45 -9
View File
@@ -5207,7 +5207,7 @@ type TcustomToolBar=class(TCustomControl)
inherited;
end
function GetPreferredSize(w,h);override;
begin
begin
ft := Font;
if not ft then return ;
ftw := ft.Width;
@@ -5216,21 +5216,42 @@ type TcustomToolBar=class(TCustomControl)
crec := ClientRect;
dw := (brec[2]-brec[0])-(crec[2]-crec[0]);
dh := (brec[3]-brec[1])-(crec[3]-crec[1]);
al := Align;
if fmainmenu then
begin
w := 0;
w := 0;
ct := 0;
for i:= 0 to fmenubtns.length()-1 do
begin
mu := getbtnitem(i);
if mu.Visible then
begin
s := mu.Caption;
w +=length(s)*ftw+15;
case al of
alLeft,alRight:
begin
w := max(w,length(s)*ftw+15);
ct++;
end else
begin
w +=length(s)*ftw+15;
end
end ;
end
end
w +=dw+2;
w := max(100,w);
h := fth+2+dh;
w := max(80,w);
case al of
alLeft,alRight:
begin
h := (max(1,ct)*(fth+2));
end else
begin
h := fth+2+dh;
end
end;
return ;
end else
begin
@@ -5248,8 +5269,19 @@ type TcustomToolBar=class(TCustomControl)
bi := FButtons[i];
ct +=bi.Visible;
end
w := max(ct,1)*(imgw+1);
h := imgh;
case al of
alLeft,alRight:
begin
w := imgh;
h :=max(ct,1)*(imgw+1);
end else
begin
w := max(ct,1)*(imgw+1);
h := imgh;
end
end ;
w+=dw;
h+=dh;
return ;
@@ -5316,7 +5348,7 @@ type TcustomToolBar=class(TCustomControl)
end
function DoCNALIGN(o,e);override;
begin
case Align of
{case Align of
alTop,alBottom:
begin
bs := UnAlignBounds;
@@ -5333,7 +5365,7 @@ type TcustomToolBar=class(TCustomControl)
bs[2]+= dh;
FUnAlignBounds := bs;
end
end
end}
inherited;
end
function DoTimerShowTip(); //定时器
@@ -5704,6 +5736,10 @@ type TcustomToolBar=class(TCustomControl)
InvalidateRect(nil,false);
return 0;
end
"getbtncount":
begin
return getbtncount();
end
end ;
return inherited;
end