mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-26 03:59:10 +02:00
enable autoadjust size of tLabel after changing font from Darek
git-svn-id: trunk@9125 -
This commit is contained in:
parent
35937a06f1
commit
5c9c26ad49
@ -54,6 +54,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomLabel.FontChanged(Sender: TObject);
|
||||||
|
begin
|
||||||
|
inherited FontChanged(Sender);
|
||||||
|
AdjustSize;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCustomLabel.HasMultiLine: boolean;
|
function TCustomLabel.HasMultiLine: boolean;
|
||||||
var
|
var
|
||||||
s: String;
|
s: String;
|
||||||
|
@ -66,6 +66,7 @@ var
|
|||||||
PointSize, ResolutionX, ResolutionY, Spacing, AverageWidth,
|
PointSize, ResolutionX, ResolutionY, Spacing, AverageWidth,
|
||||||
CharSetRegistry, CharSetCoding: string;
|
CharSetRegistry, CharSetCoding: string;
|
||||||
FullString : AnsiString;
|
FullString : AnsiString;
|
||||||
|
SizeFont : integer;
|
||||||
|
|
||||||
procedure LoadDefaultFont;
|
procedure LoadDefaultFont;
|
||||||
begin
|
begin
|
||||||
@ -128,22 +129,19 @@ begin
|
|||||||
LoadDefaultFont;
|
LoadDefaultFont;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
FullString := FamilyName;
|
|
||||||
if IsFontNameXLogicalFontDesc(LongFontName) then
|
|
||||||
if Abs(lfHeight)=0 then
|
|
||||||
FullString := FullString + ' 12'
|
|
||||||
else
|
|
||||||
FullString := FullString + ' ' + IntToStr(Abs(lfHeight));
|
|
||||||
end
|
|
||||||
else begin
|
|
||||||
FullString := FamilyName;
|
|
||||||
if IsFontNameXLogicalFontDesc(LongFontName) then
|
|
||||||
if (PointSize = '') or (CompareText(PointSize,'*')=0) then
|
|
||||||
FullString := FullString + ' 12'
|
|
||||||
else
|
|
||||||
FullString := FullString + ' ' + IntToStr(StrToInt(PointSize) div 10);
|
|
||||||
end;
|
end;
|
||||||
|
sizeFont:=0;
|
||||||
|
if IsFontNameXLogicalFontDesc(LongFontName) then
|
||||||
|
if (PointSize <> '') and (CompareText(PointSize,'*')<>0) then
|
||||||
|
sizeFont:=StrToInt(PointSize) div 10;
|
||||||
|
if sizeFont = 0 then sizeFont:=abs(lfHeight);
|
||||||
|
if sizeFont = 0 then sizeFont:=12;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
FullString := FamilyName + ' '+ IntToStr(sizeFont );
|
||||||
|
|
||||||
if FontNameRegistry='' then ;
|
if FontNameRegistry='' then ;
|
||||||
if Foundry='' then ;
|
if Foundry='' then ;
|
||||||
if WeightName='' then ;
|
if WeightName='' then ;
|
||||||
@ -160,7 +158,7 @@ begin
|
|||||||
|
|
||||||
GdiObject^.GDIFontObject :=
|
GdiObject^.GDIFontObject :=
|
||||||
pango_font_description_from_string(PChar(FullString));
|
pango_font_description_from_string(PChar(FullString));
|
||||||
If lfWeight <> FW_DONTCARE then
|
if lfWeight <> FW_DONTCARE then
|
||||||
pango_font_description_set_weight(GdiObject^.GDIFontObject, lfWeight);
|
pango_font_description_set_weight(GdiObject^.GDIFontObject, lfWeight);
|
||||||
|
|
||||||
if lfItalic = 0 then
|
if lfItalic = 0 then
|
||||||
@ -169,6 +167,8 @@ begin
|
|||||||
else
|
else
|
||||||
pango_font_description_set_style(GdiObject^.GDIFontObject,
|
pango_font_description_set_style(GdiObject^.GDIFontObject,
|
||||||
PANGO_STYLE_ITALIC);
|
PANGO_STYLE_ITALIC);
|
||||||
|
if lfHeight<>0 then
|
||||||
|
pango_font_description_set_size(GdiObject^.GDIFontObject,abs(lfHeight)*PANGO_SCALE);
|
||||||
|
|
||||||
GdiObject^.StrikeOut := lfStrikeOut <> 0;
|
GdiObject^.StrikeOut := lfStrikeOut <> 0;
|
||||||
GdiObject^.Underline := lfUnderline <> 0;
|
GdiObject^.Underline := lfUnderline <> 0;
|
||||||
@ -502,13 +502,6 @@ begin
|
|||||||
Attr := pango_attr_strikethrough_new(StrikeOut);
|
Attr := pango_attr_strikethrough_new(StrikeOut);
|
||||||
pango_attr_list_change(AttrList,Attr);
|
pango_attr_list_change(AttrList,Attr);
|
||||||
|
|
||||||
RGBColor := ColorToRGB(CurrentTextColor.ColorRef);
|
|
||||||
|
|
||||||
Attr := pango_attr_foreground_new(gushort(GetRValue(RGBColor)) shl 8,
|
|
||||||
gushort(GetGValue(RGBColor)) shl 8,
|
|
||||||
gushort(GetBValue(RGBColor)) shl 8);
|
|
||||||
|
|
||||||
pango_attr_list_change(AttrList,Attr);
|
|
||||||
pango_layout_set_attributes(Layout, AttrList);
|
pango_layout_set_attributes(Layout, AttrList);
|
||||||
|
|
||||||
pango_layout_set_single_paragraph_mode(Layout, TRUE);
|
pango_layout_set_single_paragraph_mode(Layout, TRUE);
|
||||||
@ -619,6 +612,7 @@ begin
|
|||||||
gushort(GetBValue(RGBColor)) shl 8);
|
gushort(GetBValue(RGBColor)) shl 8);
|
||||||
|
|
||||||
pango_attr_list_change(AttrList,Attr);
|
pango_attr_list_change(AttrList,Attr);
|
||||||
|
|
||||||
pango_layout_set_attributes(Layout, AttrList);
|
pango_layout_set_attributes(Layout, AttrList);
|
||||||
|
|
||||||
Foreground := StyleForegroundColor(CurrentTextColor.ColorRef, nil);
|
Foreground := StyleForegroundColor(CurrentTextColor.ColorRef, nil);
|
||||||
@ -640,9 +634,8 @@ begin
|
|||||||
pango_layout_get_pixel_size(Layout, @arect.Right, @arect.Bottom);
|
pango_layout_get_pixel_size(Layout, @arect.Right, @arect.Bottom);
|
||||||
|
|
||||||
OffsetRect(aRect, X+DCOrigin.X,Y+DCOrigin.Y);
|
OffsetRect(aRect, X+DCOrigin.X,Y+DCOrigin.Y);
|
||||||
FillRect(DC,aRect,hBrush(CurrentBrush));
|
|
||||||
|
|
||||||
gdk_draw_layout_with_colors(drawable, gc, aRect.Left, aRect.Top, Layout, Foreground, nil);
|
gdk_draw_layout_with_colors(drawable, GC, aRect.Left, aRect.Top, Layout, Foreground, nil);
|
||||||
g_object_unref(Layout);
|
g_object_unref(Layout);
|
||||||
Result := True;
|
Result := True;
|
||||||
If UnRef then
|
If UnRef then
|
||||||
|
@ -1152,6 +1152,7 @@ type
|
|||||||
function DialogChar(var Message: TLMKey): boolean; override;
|
function DialogChar(var Message: TLMKey): boolean; override;
|
||||||
procedure TextChanged; override;
|
procedure TextChanged; override;
|
||||||
procedure Resize; override;
|
procedure Resize; override;
|
||||||
|
procedure FontChanged(Sender: TObject); override;
|
||||||
|
|
||||||
procedure WMActivate(var Message: TLMActivate); message LM_ACTIVATE;
|
procedure WMActivate(var Message: TLMActivate); message LM_ACTIVATE;
|
||||||
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
||||||
|
Loading…
Reference in New Issue
Block a user