LCL: carbon: GetPreferredSize: do not use GetBestControlRect if there are child controls

git-svn-id: trunk@47913 -
This commit is contained in:
mattias 2015-02-20 11:24:10 +00:00
parent 74dd6d36d0
commit 94aa787b23
2 changed files with 18 additions and 7 deletions

View File

@ -186,6 +186,7 @@ type
procedure SetScrollBars(const AValue: TScrollStyle);
protected
function GetFrame({%H-}Index: Integer): ControlRef; override;
function GetPreferredSize: TPoint; override;
procedure CreateWidget(const AParams: TCreateParams); override;
procedure DestroyWidget; override;
procedure GetLineOffset(AIndex: Integer; out AStart, AEnd: TXNOffset);
@ -1526,6 +1527,11 @@ begin
Result:=FBorder;
end;
function TCarbonMemo.GetPreferredSize: TPoint;
begin
Result.X:=0;
Result.Y:=0;
end;
{------------------------------------------------------------------------------
Method: TCarbonMemo.CreateWidget

View File

@ -1747,7 +1747,7 @@ end;
{------------------------------------------------------------------------------
Method: TCarbonControl.GetPreferredSize
Returns: The preffered size of control for autosizing or (0, 0)
Returns: The prefered size of control for autosizing or (0, 0)
------------------------------------------------------------------------------}
function TCarbonControl.GetPreferredSize: TPoint;
var
@ -1757,12 +1757,17 @@ begin
Result.X := 0;
Result.Y := 0;
R := GetCarbonRect(0, 0, 0, 0);
if OSError(GetBestControlRect(ControlRef(Widget), R, S{%H-}), Self,
'GetPreferredSize', 'GetBestControlRect') then Exit;
if (LCLObject is TWinControl) and (TWinControl(LCLObject).ControlCount>0) then
begin
Result.X := R.right - R.left;
Result.Y := R.bottom - R.top;
end else begin
R := GetCarbonRect(0, 0, 0, 0);
if OSError(GetBestControlRect(ControlRef(Widget), R, S{%H-}), Self,
'GetPreferredSize', 'GetBestControlRect') then Exit;
Result.X := R.right - R.left;
Result.Y := R.bottom - R.top;
end;
end;