界面库

优化字体
This commit is contained in:
JianjunLiu 2023-05-08 09:42:36 +08:00
parent 1210422286
commit cbeee269d4
5 changed files with 37 additions and 21 deletions

View File

@ -195,6 +195,7 @@ type tcontrol = class(tcomponent)
if FParentFont <> nv then
begin
FParentFont := nv;
FontChanged();
return 1;
end
end
@ -352,16 +353,16 @@ type tcontrol = class(tcomponent)
protected //部分属性设置
function GetControlFont();virtual;
begin
if ParentFont and Parent then return Parent.FFont;
if ParentFont and Parent then return Parent.font;
return FFont;
end
function SetControlFont(v);virtual;
begin
if ParentFont then return ; //如果使用父节点的字体,那么字体无效
if ifarray(v)then
begin
FFont.SetValues(v);
end else
//if v is class(tfont)then
if v is class(Tcustomfont)then
begin
FFont.copyfont(v);
@ -497,6 +498,7 @@ type tcontrol = class(tcomponent)
{**
@explan(说明) 子控件添加 %%
**}
if AControl and AControl.ParentFont then AControl.FontChanged();
end
function ControlDeleted(AControl);virtual;//子控件被删除
begin
@ -676,7 +678,7 @@ type tcontrol = class(tcomponent)
end;
procedure FontChanged(Sender:TObject);virtual;
begin
if parent then parent.FontChanged(Sender);
//if parent then parent.FontChanged(Sender);
end
function GetClientRect();virtual; // //type_tcontrol visual size of client area
begin

View File

@ -988,6 +988,7 @@ type TVCForm = class(TScrollingWinControl)
end
procedure FontChanged(Sender:TObject);override;
begin
return inherited;
if(HandleAllocated())then
begin
_send_(WM_SETFONT,Font.Handle,1);

View File

@ -793,17 +793,23 @@ type TWinControl = class(tcontrol)
end
procedure FontChanged(Sender:TObject);override;
begin
if(HandleAllocated()and not(ParentFont))then
for i := 0 to ControlCount-1 do
begin
_send_(WM_SETFONT,Font.Handle,1);
it := Controls[i];
if it.ParentFont then
begin
it.FontChanged(sender);
end
//InvalidateRect(nil,false);
//it.Perform(new tuieventbase(CM_PARENTFONTCHANGED,hd,1,0));
end
end
function CMPARENTFONTCHANGED(o,e):CM_PARENTFONTCHANGED;virtual;
begin
if ParentFont then
begin
_send_(WM_SETFONT,e.wparam,1);
end
//if ParentFont then
//begin
// _send_(WM_SETFONT,e.wparam,1);
//end
end
function WMGETMINMAXINFO(o,e):WM_GETMINMAXINFO;virtual;
begin
@ -850,8 +856,8 @@ type TWinControl = class(tcontrol)
end
function WMSETFONT(o,e):WM_SETFONT;virtual;
begin
defaulthandler(e);
Perform(new tuieventbase(CM_FONTCHANGED,e.wparam,e.lparam,0));
//defaulthandler(e);
//Perform(new tuieventbase(CM_FONTCHANGED,e.wparam,e.lparam,0));
end
function WMACTIVATE(o,e):WM_ACTIVATE;virtual;
begin

View File

@ -11,7 +11,7 @@ function GetGdipStatus(v);
type TGdi = class(TSLUIBASE)
private
static GDICache;
FCanvas;
[weakref]FCanvas;
function SetCanvas(c);
begin
FCanvas := c;
@ -428,10 +428,11 @@ type Tcustomfont = class(tgdi)
end
end
end
if ifnumber(vs["color"])then
vsc := vs["color"];
if ifnumber(vsc) and (FColor<>vsc) then
begin
cg := true;
SetColor(vs["color"]);
SetColor(vsc);
end
if cg then Onchange();
return cg;
@ -464,7 +465,7 @@ type TFontControl=class(Tcustomfont)
@explan(说明) 控件字体 %%
**}
private
FControl;
[weakref]FControl;
Function SetControl(v);
begin
if(v <> FControl)and(v is class(tcontrol))then

View File

@ -2959,8 +2959,9 @@ type tthreeEntry=class(TCustomControl)
function FontChanged(o);override;
begin
//¸Ä±ä
FFontWidth := font.width;
for i,v in FEntrys do v.Font := font;
ft := font;
FFontWidth := ft.width;
for i,v in FEntrys do v.Font := ft;
calcCtls();
end
protected
@ -3237,14 +3238,16 @@ type TCustomListBoxbase=class(TCustomScrollControl)
end
function FontChanged(o);override;
begin
wd := font.width;
h := font.Height;
ft := Font;
wd := ft.width;
h := ft.Height;
if h <> FFontHeight or wd <> FFontWidth then
begin
FFontHeight := h;
FFontWidth := wd;
UpDateScrollBar();
end
inherited;
end
function GetItemCount();virtual;
begin
@ -4102,7 +4105,7 @@ type TCustomComboBoxbase=class(TCustomControl)
end
published
property itemcount read GetItemCount ;
property ItemIndex:tsl read GetItemIndex write SetItemIndex;
property ItemIndex:lazytsl read GetItemIndex write SetItemIndex;
property OnSelchanged:eventhandler read FOnSelchanged write FOnSelchanged;
property ondropdown:eventhandler read Fondropdown write Fondropdown;
property oncloseup:eventhandler read Foncloseup write Foncloseup;
@ -4294,10 +4297,12 @@ type TcustomComboBox=class(TCustomComboBoxbase)
FEdit.Readonly := Freadonly;
FListBox.parent := self;
FEdit.parent := self;
FEdit.ParentFont := true;
end
function CreateAlist();override;
begin
r := new TComboListBox(self);
r.ParentFont := true;
return r;
end
function SetDesigning(Value,SetChildren);override;
@ -6013,6 +6018,7 @@ type tcustomgroupbox=class(TCustomControl)
wf := ft.width;
hf := ft.height+2;
cvs := Canvas;
cvs.font := ft;
cvs.pen.color := 11184810;//rgb(170,170,170);
cvs.pen.width := 1;
cwd := 0;