LCL: TPanel: fixed AdjustClientRect

git-svn-id: trunk@23915 -
This commit is contained in:
mattias 2010-03-10 12:04:34 +00:00
parent 51501edffa
commit a146e3b1e7
2 changed files with 21 additions and 12 deletions

View File

@ -1069,7 +1069,7 @@ type
procedure SetBevelWidth(const Value: TBevelWidth);
protected
class procedure WSRegisterClass; override;
procedure AdjustClientRect(var Rect: TRect); override;
procedure AdjustClientRect(var aRect: TRect); override;
class function GetControlClassDefaultSize: TPoint; override;
procedure CMParentColorChanged(var Message: TLMessage); message CM_PARENTCOLORCHANGED;
function GetDefaultDockCaption: String; override;

View File

@ -94,14 +94,16 @@ var
TS : TTextStyle;
begin
ARect := GetClientRect;
if BevelOuter <> bvNone then
Canvas.Frame3d(ARect, BevelWidth, BevelOuter);
// if BevelOuter is set then draw a frame with BevelWidth
if (BevelOuter <> bvNone) and (BevelWidth>0) then
Canvas.Frame3d(ARect, BevelWidth, BevelOuter); // Note: Frame3D inflates ARect
if BevelInner <> bvNone then
// if BevelInner is set then skip the BorderWidth and draw a frame with BevelWidth
if (BevelInner <> bvNone) and (BevelWidth>0) then
begin
if BorderWidth > 0 then
InflateRect(ARect, -BorderWidth, -BorderWidth);
Canvas.Frame3d(ARect, BevelWidth, BevelInner);
Canvas.Frame3d(ARect, BevelWidth, BevelInner); // Note: Frame3D inflates ARect
end;
if Caption <> '' then
@ -129,17 +131,24 @@ begin
inherited Paint;
end;
procedure TCustomPanel.AdjustClientRect(var Rect: TRect);
procedure TCustomPanel.AdjustClientRect(var aRect: TRect);
var
BevelSize: Integer;
begin
inherited AdjustClientRect(Rect);
BevelSize := BorderWidth;
if BevelOuter <> bvNone then
inherited AdjustClientRect(aRect);
BevelSize:=0;
// if BevelOuter is set then draw a frame with BevelWidth
if (BevelOuter <> bvNone) and (BevelWidth > 0) then
inc(BevelSize, BevelWidth);
// if BevelInner is set then skip the BorderWidth and draw a frame with BevelWidth
if (BevelInner <> bvNone) and (BevelWidth > 0) then
begin
if BorderWidth > 0 then
Inc(BevelSize, BorderWidth);
Inc(BevelSize, BevelWidth);
if BevelInner <> bvNone then
Inc(BevelSize, BevelWidth);
InflateRect(Rect, -BevelSize, -BevelSize);
end;
InflateRect(aRect, -BevelSize, -BevelSize);
end;
class function TCustomPanel.GetControlClassDefaultSize: TPoint;