From a146e3b1e783064406b33810de972869b35760e4 Mon Sep 17 00:00:00 2001 From: mattias Date: Wed, 10 Mar 2010 12:04:34 +0000 Subject: [PATCH] LCL: TPanel: fixed AdjustClientRect git-svn-id: trunk@23915 - --- lcl/extctrls.pp | 2 +- lcl/include/custompanel.inc | 31 ++++++++++++++++++++----------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/lcl/extctrls.pp b/lcl/extctrls.pp index 0ca7e64b6b..5f5b1bcaab 100644 --- a/lcl/extctrls.pp +++ b/lcl/extctrls.pp @@ -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; diff --git a/lcl/include/custompanel.inc b/lcl/include/custompanel.inc index 4993e58fa5..247a7ff3e4 100644 --- a/lcl/include/custompanel.inc +++ b/lcl/include/custompanel.inc @@ -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;