mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 22:16:17 +02:00
lcl: adjust static text size on border change
win32: implement autosize for TStaticText git-svn-id: trunk@18416 -
This commit is contained in:
parent
2b5fa9f4a9
commit
f22cb37270
@ -135,7 +135,14 @@ begin
|
||||
begin
|
||||
FStaticBorderStyle := Value;
|
||||
if HandleAllocated then
|
||||
begin
|
||||
TWSCustomStaticTextClass(WidgetsetClass).SetStaticBorderStyle(Self, Value);
|
||||
if AutoSize then
|
||||
begin
|
||||
InvalidatePreferredSize;
|
||||
AdjustSize;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -208,6 +208,9 @@ type
|
||||
published
|
||||
class function CreateHandle(const AWinControl: TWinControl;
|
||||
const AParams: TCreateParams): HWND; override;
|
||||
class procedure GetPreferredSize(const AWinControl: TWinControl;
|
||||
var PreferredWidth, PreferredHeight: integer;
|
||||
WithThemeSpace: Boolean); override;
|
||||
class procedure SetAlignment(const ACustomStaticText: TCustomStaticText; const NewAlignment: TAlignment); override;
|
||||
class procedure SetStaticBorderStyle(const ACustomStaticText: TCustomStaticText; const NewBorderStyle: TStaticBorderStyle); override;
|
||||
class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
|
||||
@ -1329,6 +1332,29 @@ begin
|
||||
Result := Params.Window;
|
||||
end;
|
||||
|
||||
class procedure TWin32WSCustomStaticText.GetPreferredSize(
|
||||
const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer;
|
||||
WithThemeSpace: Boolean);
|
||||
begin
|
||||
if MeasureText(AWinControl, AWinControl.Caption, PreferredWidth, PreferredHeight) then
|
||||
begin
|
||||
Inc(PreferredHeight);
|
||||
if TCustomStaticText(AWinControl).BorderStyle <> sbsNone then
|
||||
begin
|
||||
if ThemeServices.ThemesEnabled and (TCustomStaticText(AWinControl).BorderStyle = sbsSingle) then
|
||||
begin
|
||||
inc(PreferredWidth, 4);
|
||||
inc(PreferredHeight, 4);
|
||||
end
|
||||
else
|
||||
begin
|
||||
inc(PreferredWidth, 2);
|
||||
inc(PreferredHeight, 2);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
class procedure TWin32WSCustomStaticText.SetAlignment(const ACustomStaticText: TCustomStaticText; const NewAlignment: TAlignment);
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ACustomStaticText, 'SetAlignment') then
|
||||
|
Loading…
Reference in New Issue
Block a user