lcl: TControl: add ScaleCoord96 and -Back for 96 PPI

git-svn-id: trunk@53571 -
This commit is contained in:
ondrej 2016-12-06 13:35:18 +00:00
parent f49912d641
commit 4a214df8bf
2 changed files with 30 additions and 0 deletions

View File

@ -1478,6 +1478,8 @@ type
//scale support
function ScaleCoord(const ASize: Integer): Integer;
function ScaleCoordBack(const ASize: Integer): Integer;
function ScaleCoord96(const ASize: Integer): Integer;
function ScaleCoord96Back(const ASize: Integer): Integer;
public
// size
procedure AdjustSize; virtual;// smart calling DoAutoSize

View File

@ -778,6 +778,34 @@ begin
Result := MulDiv(ASize, ParentForm.PixelsPerInch, ParentForm.DesignTimeDPI);
end;
function TControl.ScaleCoord96(const ASize: Integer): Integer;
var
ParentForm: TCustomForm;
begin
ParentForm := GetParentForm(Self);
if ParentForm=nil then
raise EInvalidOperation.CreateFmt(rsControlHasNoParentForm, [Name]);
if ParentForm.PixelsPerInch=96 then
Result := ASize
else
Result := MulDiv(ASize, ParentForm.PixelsPerInch, 96);
end;
function TControl.ScaleCoord96Back(const ASize: Integer): Integer;
var
ParentForm: TCustomForm;
begin
ParentForm := GetParentForm(Self);
if ParentForm=nil then
raise EInvalidOperation.CreateFmt(rsControlHasNoParentForm, [Name]);
if ParentForm.PixelsPerInch=96 then
Result := ASize
else
Result := MulDiv(ASize, 96, ParentForm.PixelsPerInch);
end;
function TControl.ScaleCoordBack(const ASize: Integer): Integer;
var
ParentForm: TCustomForm;